diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-14 13:56:42 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-14 13:56:42 +0200 |
commit | 926d801fa51717b3af3faf33f9d686e92a20ecfd (patch) | |
tree | be5d1e982d1ec0330055ebeb0e216eca9a07892f /networking/libiproute/iprule.c | |
parent | 0f296a3a56b52842057e5a2bc653621a3a6c7bec (diff) | |
download | busybox-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/iprule.c')
-rw-r--r-- | networking/libiproute/iprule.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c index c3b210982..dba64346f 100644 --- a/networking/libiproute/iprule.c +++ b/networking/libiproute/iprule.c | |||
@@ -44,7 +44,6 @@ static int FAST_FUNC print_rule(const struct sockaddr_nl *who UNUSED_PARAM, | |||
44 | int len = n->nlmsg_len; | 44 | int len = n->nlmsg_len; |
45 | int host_len = -1; | 45 | int host_len = -1; |
46 | struct rtattr * tb[RTA_MAX+1]; | 46 | struct rtattr * tb[RTA_MAX+1]; |
47 | char abuf[256]; | ||
48 | 47 | ||
49 | if (n->nlmsg_type != RTM_NEWRULE) | 48 | if (n->nlmsg_type != RTM_NEWRULE) |
50 | return 0; | 49 | return 0; |
@@ -71,16 +70,14 @@ static int FAST_FUNC print_rule(const struct sockaddr_nl *who UNUSED_PARAM, | |||
71 | printf("from "); | 70 | printf("from "); |
72 | if (tb[RTA_SRC]) { | 71 | if (tb[RTA_SRC]) { |
73 | if (r->rtm_src_len != host_len) { | 72 | if (r->rtm_src_len != host_len) { |
74 | printf("%s/%u", rt_addr_n2a(r->rtm_family, | 73 | printf("%s/%u", |
75 | RTA_DATA(tb[RTA_SRC]), | 74 | rt_addr_n2a(r->rtm_family, RTA_DATA(tb[RTA_SRC])), |
76 | abuf, sizeof(abuf)), | ||
77 | r->rtm_src_len | 75 | r->rtm_src_len |
78 | ); | 76 | ); |
79 | } else { | 77 | } else { |
80 | fputs(format_host(r->rtm_family, | 78 | fputs(format_host(r->rtm_family, |
81 | RTA_PAYLOAD(tb[RTA_SRC]), | 79 | RTA_PAYLOAD(tb[RTA_SRC]), |
82 | RTA_DATA(tb[RTA_SRC]), | 80 | RTA_DATA(tb[RTA_SRC])), |
83 | abuf, sizeof(abuf)), | ||
84 | stdout | 81 | stdout |
85 | ); | 82 | ); |
86 | } | 83 | } |
@@ -94,15 +91,13 @@ static int FAST_FUNC print_rule(const struct sockaddr_nl *who UNUSED_PARAM, | |||
94 | if (tb[RTA_DST]) { | 91 | if (tb[RTA_DST]) { |
95 | if (r->rtm_dst_len != host_len) { | 92 | if (r->rtm_dst_len != host_len) { |
96 | printf("to %s/%u ", rt_addr_n2a(r->rtm_family, | 93 | printf("to %s/%u ", rt_addr_n2a(r->rtm_family, |
97 | RTA_DATA(tb[RTA_DST]), | 94 | RTA_DATA(tb[RTA_DST])), |
98 | abuf, sizeof(abuf)), | ||
99 | r->rtm_dst_len | 95 | r->rtm_dst_len |
100 | ); | 96 | ); |
101 | } else { | 97 | } else { |
102 | printf("to %s ", format_host(r->rtm_family, | 98 | printf("to %s ", format_host(r->rtm_family, |
103 | RTA_PAYLOAD(tb[RTA_DST]), | 99 | RTA_PAYLOAD(tb[RTA_DST]), |
104 | RTA_DATA(tb[RTA_DST]), | 100 | RTA_DATA(tb[RTA_DST]))); |
105 | abuf, sizeof(abuf))); | ||
106 | } | 101 | } |
107 | } else if (r->rtm_dst_len) { | 102 | } else if (r->rtm_dst_len) { |
108 | printf("to 0/%d ", r->rtm_dst_len); | 103 | printf("to 0/%d ", r->rtm_dst_len); |
@@ -139,8 +134,8 @@ static int FAST_FUNC print_rule(const struct sockaddr_nl *who UNUSED_PARAM, | |||
139 | printf("map-to %s ", | 134 | printf("map-to %s ", |
140 | format_host(r->rtm_family, | 135 | format_host(r->rtm_family, |
141 | RTA_PAYLOAD(tb[RTA_GATEWAY]), | 136 | RTA_PAYLOAD(tb[RTA_GATEWAY]), |
142 | RTA_DATA(tb[RTA_GATEWAY]), | 137 | RTA_DATA(tb[RTA_GATEWAY])) |
143 | abuf, sizeof(abuf))); | 138 | ); |
144 | } else | 139 | } else |
145 | printf("masquerade"); | 140 | printf("masquerade"); |
146 | } else if (r->rtm_type != RTN_UNICAST) | 141 | } else if (r->rtm_type != RTN_UNICAST) |