15 |
#include "rt_names.h" |
#include "rt_names.h" |
16 |
#include "utils.h" |
#include "utils.h" |
17 |
|
|
18 |
const char *rtnl_rtntype_n2a(int id, char *buf, int len) |
const char* FAST_FUNC rtnl_rtntype_n2a(int id, char *buf) |
19 |
{ |
{ |
20 |
switch (id) { |
switch (id) { |
21 |
case RTN_UNSPEC: |
case RTN_UNSPEC: |
43 |
case RTN_XRESOLVE: |
case RTN_XRESOLVE: |
44 |
return "xresolve"; |
return "xresolve"; |
45 |
default: |
default: |
46 |
snprintf(buf, len, "%d", id); |
/* buf is SPRINT_BSIZE big */ |
47 |
|
sprintf(buf, "%d", id); |
48 |
return buf; |
return buf; |
49 |
} |
} |
50 |
} |
} |
51 |
|
|
52 |
|
|
53 |
int rtnl_rtntype_a2n(int *id, char *arg) |
int FAST_FUNC rtnl_rtntype_a2n(int *id, char *arg) |
54 |
{ |
{ |
55 |
static const char keywords[] ALIGN1 = |
static const char keywords[] ALIGN1 = |
56 |
"local\0""nat\0""broadcast\0""brd\0""anycast\0" |
"local\0""nat\0""broadcast\0""brd\0""anycast\0" |
89 |
res = RTN_THROW; |
res = RTN_THROW; |
90 |
else { |
else { |
91 |
res = strtoul(arg, &end, 0); |
res = strtoul(arg, &end, 0); |
92 |
if (!end || end == arg || *end || res > 255) |
if (end == arg || *end || res > 255) |
93 |
return -1; |
return -1; |
94 |
} |
} |
95 |
*id = res; |
*id = res; |
96 |
return 0; |
return 0; |
97 |
} |
} |
98 |
|
|
99 |
int get_rt_realms(uint32_t *realms, char *arg) |
int FAST_FUNC get_rt_realms(uint32_t *realms, char *arg) |
100 |
{ |
{ |
101 |
uint32_t realm = 0; |
uint32_t realm = 0; |
102 |
char *p = strchr(arg, '/'); |
char *p = strchr(arg, '/'); |