aboutsummaryrefslogtreecommitdiff
path: root/networking/libiproute/iproute.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-14 13:56:42 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-14 13:56:42 +0200
commit926d801fa51717b3af3faf33f9d686e92a20ecfd (patch)
treebe5d1e982d1ec0330055ebeb0e216eca9a07892f /networking/libiproute/iproute.c
parent0f296a3a56b52842057e5a2bc653621a3a6c7bec (diff)
downloadbusybox-w32-926d801fa51717b3af3faf33f9d686e92a20ecfd.tar.gz
busybox-w32-926d801fa51717b3af3faf33f9d686e92a20ecfd.tar.bz2
busybox-w32-926d801fa51717b3af3faf33f9d686e92a20ecfd.zip
libiproute: make rt_addr_n2a() and format_host() return auto strings
function old new delta rt_addr_n2a 56 53 -3 print_addrinfo 1227 1178 -49 print_neigh 933 881 -52 print_rule 689 617 -72 print_tunnel 640 560 -80 print_route 1727 1588 -139 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/6 up/down: 0/-395) Total: -395 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/libiproute/iproute.c')
-rw-r--r--networking/libiproute/iproute.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
index 0d2914405..d232ee6fd 100644
--- a/networking/libiproute/iproute.c
+++ b/networking/libiproute/iproute.c
@@ -61,7 +61,6 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM,
61 struct rtmsg *r = NLMSG_DATA(n); 61 struct rtmsg *r = NLMSG_DATA(n);
62 int len = n->nlmsg_len; 62 int len = n->nlmsg_len;
63 struct rtattr *tb[RTA_MAX+1]; 63 struct rtattr *tb[RTA_MAX+1];
64 char abuf[256];
65 inet_prefix dst; 64 inet_prefix dst;
66 inet_prefix src; 65 inet_prefix src;
67 int host_len = -1; 66 int host_len = -1;
@@ -218,17 +217,15 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM,
218 217
219 if (tb[RTA_DST]) { 218 if (tb[RTA_DST]) {
220 if (r->rtm_dst_len != host_len) { 219 if (r->rtm_dst_len != host_len) {
221 printf("%s/%u ", rt_addr_n2a(r->rtm_family, 220 printf("%s/%u ",
222 RTA_DATA(tb[RTA_DST]), 221 rt_addr_n2a(r->rtm_family, RTA_DATA(tb[RTA_DST])),
223 abuf, sizeof(abuf)), 222 r->rtm_dst_len
224 r->rtm_dst_len 223 );
225 );
226 } else { 224 } else {
227 printf("%s ", format_host(r->rtm_family, 225 printf("%s ", format_host(r->rtm_family,
228 RTA_PAYLOAD(tb[RTA_DST]), 226 RTA_PAYLOAD(tb[RTA_DST]),
229 RTA_DATA(tb[RTA_DST]), 227 RTA_DATA(tb[RTA_DST]))
230 abuf, sizeof(abuf)) 228 );
231 );
232 } 229 }
233 } else if (r->rtm_dst_len) { 230 } else if (r->rtm_dst_len) {
234 printf("0/%d ", r->rtm_dst_len); 231 printf("0/%d ", r->rtm_dst_len);
@@ -237,17 +234,15 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM,
237 } 234 }
238 if (tb[RTA_SRC]) { 235 if (tb[RTA_SRC]) {
239 if (r->rtm_src_len != host_len) { 236 if (r->rtm_src_len != host_len) {
240 printf("from %s/%u ", rt_addr_n2a(r->rtm_family, 237 printf("from %s/%u ",
241 RTA_DATA(tb[RTA_SRC]), 238 rt_addr_n2a(r->rtm_family, RTA_DATA(tb[RTA_SRC])),
242 abuf, sizeof(abuf)), 239 r->rtm_src_len
243 r->rtm_src_len 240 );
244 );
245 } else { 241 } else {
246 printf("from %s ", format_host(r->rtm_family, 242 printf("from %s ", format_host(r->rtm_family,
247 RTA_PAYLOAD(tb[RTA_SRC]), 243 RTA_PAYLOAD(tb[RTA_SRC]),
248 RTA_DATA(tb[RTA_SRC]), 244 RTA_DATA(tb[RTA_SRC]))
249 abuf, sizeof(abuf)) 245 );
250 );
251 } 246 }
252 } else if (r->rtm_src_len) { 247 } else if (r->rtm_src_len) {
253 printf("from 0/%u ", r->rtm_src_len); 248 printf("from 0/%u ", r->rtm_src_len);
@@ -255,8 +250,8 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM,
255 if (tb[RTA_GATEWAY] && G_filter.rvia.bitlen != host_len) { 250 if (tb[RTA_GATEWAY] && G_filter.rvia.bitlen != host_len) {
256 printf("via %s ", format_host(r->rtm_family, 251 printf("via %s ", format_host(r->rtm_family,
257 RTA_PAYLOAD(tb[RTA_GATEWAY]), 252 RTA_PAYLOAD(tb[RTA_GATEWAY]),
258 RTA_DATA(tb[RTA_GATEWAY]), 253 RTA_DATA(tb[RTA_GATEWAY]))
259 abuf, sizeof(abuf))); 254 );
260 } 255 }
261 if (tb[RTA_OIF]) { 256 if (tb[RTA_OIF]) {
262 printf("dev %s ", ll_index_to_name(*(int*)RTA_DATA(tb[RTA_OIF]))); 257 printf("dev %s ", ll_index_to_name(*(int*)RTA_DATA(tb[RTA_OIF])));
@@ -269,8 +264,7 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM,
269 and symbolic name will not be useful. 264 and symbolic name will not be useful.
270 */ 265 */
271 printf(" src %s ", rt_addr_n2a(r->rtm_family, 266 printf(" src %s ", rt_addr_n2a(r->rtm_family,
272 RTA_DATA(tb[RTA_PREFSRC]), 267 RTA_DATA(tb[RTA_PREFSRC])));
273 abuf, sizeof(abuf)));
274 } 268 }
275 if (tb[RTA_PRIORITY]) { 269 if (tb[RTA_PRIORITY]) {
276 printf(" metric %d ", *(uint32_t*)RTA_DATA(tb[RTA_PRIORITY])); 270 printf(" metric %d ", *(uint32_t*)RTA_DATA(tb[RTA_PRIORITY]));