diff options
-rw-r--r-- | networking/libiproute/utils.c | 34 | ||||
-rw-r--r-- | networking/libiproute/utils.h | 46 |
2 files changed, 41 insertions, 39 deletions
diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c index 42025bc66..fca167ac6 100644 --- a/networking/libiproute/utils.c +++ b/networking/libiproute/utils.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include "utils.h" | 13 | #include "utils.h" |
14 | #include "inet_common.h" | 14 | #include "inet_common.h" |
15 | 15 | ||
16 | unsigned get_hz(void) | 16 | unsigned FAST_FUNC get_hz(void) |
17 | { | 17 | { |
18 | static unsigned hz_internal; | 18 | static unsigned hz_internal; |
19 | FILE *fp; | 19 | FILE *fp; |
@@ -35,7 +35,7 @@ unsigned get_hz(void) | |||
35 | return hz_internal; | 35 | return hz_internal; |
36 | } | 36 | } |
37 | 37 | ||
38 | unsigned get_unsigned(char *arg, const char *errmsg) | 38 | unsigned FAST_FUNC get_unsigned(char *arg, const char *errmsg) |
39 | { | 39 | { |
40 | unsigned long res; | 40 | unsigned long res; |
41 | char *ptr; | 41 | char *ptr; |
@@ -50,7 +50,7 @@ unsigned get_unsigned(char *arg, const char *errmsg) | |||
50 | invarg_1_to_2(arg, errmsg); /* does not return */ | 50 | invarg_1_to_2(arg, errmsg); /* does not return */ |
51 | } | 51 | } |
52 | 52 | ||
53 | uint32_t get_u32(char *arg, const char *errmsg) | 53 | uint32_t FAST_FUNC get_u32(char *arg, const char *errmsg) |
54 | { | 54 | { |
55 | unsigned long res; | 55 | unsigned long res; |
56 | char *ptr; | 56 | char *ptr; |
@@ -65,7 +65,7 @@ uint32_t get_u32(char *arg, const char *errmsg) | |||
65 | invarg_1_to_2(arg, errmsg); /* does not return */ | 65 | invarg_1_to_2(arg, errmsg); /* does not return */ |
66 | } | 66 | } |
67 | 67 | ||
68 | uint16_t get_u16(char *arg, const char *errmsg) | 68 | uint16_t FAST_FUNC get_u16(char *arg, const char *errmsg) |
69 | { | 69 | { |
70 | unsigned long res; | 70 | unsigned long res; |
71 | char *ptr; | 71 | char *ptr; |
@@ -80,7 +80,7 @@ uint16_t get_u16(char *arg, const char *errmsg) | |||
80 | invarg_1_to_2(arg, errmsg); /* does not return */ | 80 | invarg_1_to_2(arg, errmsg); /* does not return */ |
81 | } | 81 | } |
82 | 82 | ||
83 | int get_addr_1(inet_prefix *addr, char *name, int family) | 83 | int FAST_FUNC get_addr_1(inet_prefix *addr, char *name, int family) |
84 | { | 84 | { |
85 | memset(addr, 0, sizeof(*addr)); | 85 | memset(addr, 0, sizeof(*addr)); |
86 | 86 | ||
@@ -199,7 +199,7 @@ static void get_prefix_1(inet_prefix *dst, char *arg, int family) | |||
199 | bb_error_msg_and_die("an %s %s is expected rather than \"%s\"", "inet", "prefix", arg); | 199 | bb_error_msg_and_die("an %s %s is expected rather than \"%s\"", "inet", "prefix", arg); |
200 | } | 200 | } |
201 | 201 | ||
202 | int get_addr(inet_prefix *dst, char *arg, int family) | 202 | int FAST_FUNC get_addr(inet_prefix *dst, char *arg, int family) |
203 | { | 203 | { |
204 | if (family == AF_PACKET) { | 204 | if (family == AF_PACKET) { |
205 | bb_error_msg_and_die("\"%s\" may be inet %s, but it is not allowed in this context", arg, "address"); | 205 | bb_error_msg_and_die("\"%s\" may be inet %s, but it is not allowed in this context", arg, "address"); |
@@ -210,7 +210,7 @@ int get_addr(inet_prefix *dst, char *arg, int family) | |||
210 | return 0; | 210 | return 0; |
211 | } | 211 | } |
212 | 212 | ||
213 | void get_prefix(inet_prefix *dst, char *arg, int family) | 213 | void FAST_FUNC get_prefix(inet_prefix *dst, char *arg, int family) |
214 | { | 214 | { |
215 | if (family == AF_PACKET) { | 215 | if (family == AF_PACKET) { |
216 | bb_error_msg_and_die("\"%s\" may be inet %s, but it is not allowed in this context", arg, "prefix"); | 216 | bb_error_msg_and_die("\"%s\" may be inet %s, but it is not allowed in this context", arg, "prefix"); |
@@ -218,7 +218,7 @@ void get_prefix(inet_prefix *dst, char *arg, int family) | |||
218 | get_prefix_1(dst, arg, family); | 218 | get_prefix_1(dst, arg, family); |
219 | } | 219 | } |
220 | 220 | ||
221 | uint32_t get_addr32(char *name) | 221 | uint32_t FAST_FUNC get_addr32(char *name) |
222 | { | 222 | { |
223 | inet_prefix addr; | 223 | inet_prefix addr; |
224 | 224 | ||
@@ -228,27 +228,29 @@ uint32_t get_addr32(char *name) | |||
228 | return addr.data[0]; | 228 | return addr.data[0]; |
229 | } | 229 | } |
230 | 230 | ||
231 | void incomplete_command(void) | 231 | char** FAST_FUNC next_arg(char **argv) |
232 | { | 232 | { |
233 | bb_error_msg_and_die("command line is not complete, try \"help\""); | 233 | if (!*++argv) |
234 | bb_error_msg_and_die("command line is not complete, try \"help\""); | ||
235 | return argv; | ||
234 | } | 236 | } |
235 | 237 | ||
236 | void invarg_1_to_2(const char *arg, const char *opt) | 238 | void FAST_FUNC invarg_1_to_2(const char *arg, const char *opt) |
237 | { | 239 | { |
238 | bb_error_msg_and_die(bb_msg_invalid_arg_to, arg, opt); | 240 | bb_error_msg_and_die(bb_msg_invalid_arg_to, arg, opt); |
239 | } | 241 | } |
240 | 242 | ||
241 | void duparg(const char *key, const char *arg) | 243 | void FAST_FUNC duparg(const char *key, const char *arg) |
242 | { | 244 | { |
243 | bb_error_msg_and_die("duplicate \"%s\": \"%s\" is the second value", key, arg); | 245 | bb_error_msg_and_die("duplicate \"%s\": \"%s\" is the second value", key, arg); |
244 | } | 246 | } |
245 | 247 | ||
246 | void duparg2(const char *key, const char *arg) | 248 | void FAST_FUNC duparg2(const char *key, const char *arg) |
247 | { | 249 | { |
248 | bb_error_msg_and_die("either \"%s\" is duplicate, or \"%s\" is garbage", key, arg); | 250 | bb_error_msg_and_die("either \"%s\" is duplicate, or \"%s\" is garbage", key, arg); |
249 | } | 251 | } |
250 | 252 | ||
251 | int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits) | 253 | int FAST_FUNC inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits) |
252 | { | 254 | { |
253 | const uint32_t *a1 = a->data; | 255 | const uint32_t *a1 = a->data; |
254 | const uint32_t *a2 = b->data; | 256 | const uint32_t *a2 = b->data; |
@@ -276,7 +278,7 @@ int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits) | |||
276 | return 0; | 278 | return 0; |
277 | } | 279 | } |
278 | 280 | ||
279 | const char *rt_addr_n2a(int af, void *addr) | 281 | const char* FAST_FUNC rt_addr_n2a(int af, void *addr) |
280 | { | 282 | { |
281 | switch (af) { | 283 | switch (af) { |
282 | case AF_INET: | 284 | case AF_INET: |
@@ -290,7 +292,7 @@ const char *rt_addr_n2a(int af, void *addr) | |||
290 | } | 292 | } |
291 | 293 | ||
292 | #ifdef RESOLVE_HOSTNAMES | 294 | #ifdef RESOLVE_HOSTNAMES |
293 | const char *format_host(int af, int len, void *addr) | 295 | const char* FAST_FUNC format_host(int af, int len, void *addr) |
294 | { | 296 | { |
295 | if (resolve_hosts) { | 297 | if (resolve_hosts) { |
296 | struct hostent *h_ent; | 298 | struct hostent *h_ent; |
diff --git a/networking/libiproute/utils.h b/networking/libiproute/utils.h index 408d5f65f..55490980d 100644 --- a/networking/libiproute/utils.h +++ b/networking/libiproute/utils.h | |||
@@ -26,10 +26,6 @@ extern char _SL_; | |||
26 | #define SPRINT_BSIZE 64 | 26 | #define SPRINT_BSIZE 64 |
27 | #define SPRINT_BUF(x) char x[SPRINT_BSIZE] | 27 | #define SPRINT_BUF(x) char x[SPRINT_BSIZE] |
28 | 28 | ||
29 | extern void incomplete_command(void) NORETURN; | ||
30 | |||
31 | #define NEXT_ARG() do { if (!*++argv) incomplete_command(); } while (0) | ||
32 | |||
33 | typedef struct { | 29 | typedef struct { |
34 | uint8_t family; | 30 | uint8_t family; |
35 | uint8_t bytelen; | 31 | uint8_t bytelen; |
@@ -56,36 +52,40 @@ struct ipx_addr { | |||
56 | uint8_t ipx_node[IPX_NODE_LEN]; | 52 | uint8_t ipx_node[IPX_NODE_LEN]; |
57 | }; | 53 | }; |
58 | 54 | ||
59 | extern uint32_t get_addr32(char *name); | 55 | char** next_arg(char **argv) FAST_FUNC; |
60 | extern int get_addr_1(inet_prefix *dst, char *arg, int family); | 56 | #define NEXT_ARG() do { argv = next_arg(argv); } while (0) |
61 | /*extern void get_prefix_1(inet_prefix *dst, char *arg, int family);*/ | ||
62 | extern int get_addr(inet_prefix *dst, char *arg, int family); | ||
63 | extern void get_prefix(inet_prefix *dst, char *arg, int family); | ||
64 | 57 | ||
65 | extern unsigned get_unsigned(char *arg, const char *errmsg); | 58 | uint32_t get_addr32(char *name) FAST_FUNC; |
66 | extern uint32_t get_u32(char *arg, const char *errmsg); | 59 | int get_addr_1(inet_prefix *dst, char *arg, int family) FAST_FUNC; |
67 | extern uint16_t get_u16(char *arg, const char *errmsg); | 60 | /*void get_prefix_1(inet_prefix *dst, char *arg, int family) FAST_FUNC;*/ |
61 | int get_addr(inet_prefix *dst, char *arg, int family) FAST_FUNC; | ||
62 | void get_prefix(inet_prefix *dst, char *arg, int family) FAST_FUNC; | ||
68 | 63 | ||
69 | extern const char *rt_addr_n2a(int af, void *addr); | 64 | unsigned get_unsigned(char *arg, const char *errmsg) FAST_FUNC; |
65 | uint32_t get_u32(char *arg, const char *errmsg) FAST_FUNC; | ||
66 | uint16_t get_u16(char *arg, const char *errmsg) FAST_FUNC; | ||
67 | |||
68 | const char *rt_addr_n2a(int af, void *addr) FAST_FUNC; | ||
70 | #ifdef RESOLVE_HOSTNAMES | 69 | #ifdef RESOLVE_HOSTNAMES |
71 | extern const char *format_host(int af, int len, void *addr); | 70 | const char *format_host(int af, int len, void *addr) FAST_FUNC; |
72 | #else | 71 | #else |
73 | #define format_host(af, len, addr) \ | 72 | #define format_host(af, len, addr) \ |
74 | rt_addr_n2a(af, addr) | 73 | rt_addr_n2a(af, addr) |
75 | #endif | 74 | #endif |
76 | 75 | ||
77 | void invarg_1_to_2(const char *, const char *) NORETURN; | 76 | void invarg_1_to_2(const char *, const char *) FAST_FUNC NORETURN; |
78 | void duparg(const char *, const char *) NORETURN; | 77 | void duparg(const char *, const char *) FAST_FUNC NORETURN; |
79 | void duparg2(const char *, const char *) NORETURN; | 78 | void duparg2(const char *, const char *) FAST_FUNC NORETURN; |
80 | int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits); | 79 | |
80 | int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits) FAST_FUNC; | ||
81 | 81 | ||
82 | const char *dnet_ntop(int af, const void *addr, char *str, size_t len); | 82 | //const char *dnet_ntop(int af, const void *addr, char *str, size_t len); |
83 | int dnet_pton(int af, const char *src, void *addr); | 83 | //int dnet_pton(int af, const char *src, void *addr); |
84 | 84 | ||
85 | const char *ipx_ntop(int af, const void *addr, char *str, size_t len); | 85 | //const char *ipx_ntop(int af, const void *addr, char *str, size_t len); |
86 | int ipx_pton(int af, const char *src, void *addr); | 86 | //int ipx_pton(int af, const char *src, void *addr); |
87 | 87 | ||
88 | unsigned get_hz(void); | 88 | unsigned get_hz(void) FAST_FUNC; |
89 | 89 | ||
90 | POP_SAVED_FUNCTION_VISIBILITY | 90 | POP_SAVED_FUNCTION_VISIBILITY |
91 | 91 | ||