aboutsummaryrefslogtreecommitdiff
path: root/networking/libiproute/ipaddress.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-08 13:02:28 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-08 13:02:28 +0200
commit3d8d5e8ad4d2df71e0307c385b3784586b545cbc (patch)
tree9e543be018a890ee5a2c40a2b3ed0de0f0e7dd36 /networking/libiproute/ipaddress.c
parent7f3a2a22569eb8e4c9fcc1c7f4e51fe0c6155dae (diff)
downloadbusybox-w32-3d8d5e8ad4d2df71e0307c385b3784586b545cbc.tar.gz
busybox-w32-3d8d5e8ad4d2df71e0307c385b3784586b545cbc.tar.bz2
busybox-w32-3d8d5e8ad4d2df71e0307c385b3784586b545cbc.zip
libiproute: use itoa() where appropriate
function old new delta rtnl_rtprot_a2n 31 88 +57 print_tunnel 647 640 -7 print_route 1865 1858 -7 print_linkinfo 820 812 -8 print_addrinfo 1241 1227 -14 rtnl_rttable_n2a 53 38 -15 rtnl_rtscope_n2a 53 38 -15 rtnl_rtrealm_n2a 53 38 -15 rtnl_dsfield_n2a 61 38 -23 rtnl_rtntype_n2a 118 89 -29 print_rule 724 689 -35 ipaddr_list_or_flush 1293 1253 -40 rtnl_rtprot_n2a 53 - -53 rtnl_rtprot_initialize 63 - -63 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 1/11 up/down: 57/-324) Total: -267 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/libiproute/ipaddress.c')
-rw-r--r--networking/libiproute/ipaddress.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index a6d5129e7..8845cab91 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -137,12 +137,11 @@ static NOINLINE int print_linkinfo(const struct nlmsghdr *n)
137 { 137 {
138 unsigned m_flag = 0; 138 unsigned m_flag = 0;
139 if (tb[IFLA_LINK]) { 139 if (tb[IFLA_LINK]) {
140 SPRINT_BUF(b1);
141 int iflink = *(int*)RTA_DATA(tb[IFLA_LINK]); 140 int iflink = *(int*)RTA_DATA(tb[IFLA_LINK]);
142 if (iflink == 0) 141 if (iflink == 0)
143 printf("@NONE: "); 142 printf("@NONE: ");
144 else { 143 else {
145 printf("@%s: ", ll_idx_n2a(iflink, b1)); 144 printf("@%s: ", ll_index_to_name(iflink));
146 m_flag = ll_index_to_flags(iflink); 145 m_flag = ll_index_to_flags(iflink);
147 m_flag = !(m_flag & IFF_UP); 146 m_flag = !(m_flag & IFF_UP);
148 } 147 }
@@ -158,8 +157,7 @@ static NOINLINE int print_linkinfo(const struct nlmsghdr *n)
158 printf("qdisc %s ", (char*)RTA_DATA(tb[IFLA_QDISC])); 157 printf("qdisc %s ", (char*)RTA_DATA(tb[IFLA_QDISC]));
159#ifdef IFLA_MASTER 158#ifdef IFLA_MASTER
160 if (tb[IFLA_MASTER]) { 159 if (tb[IFLA_MASTER]) {
161 SPRINT_BUF(b1); 160 printf("master %s ", ll_index_to_name(*(int*)RTA_DATA(tb[IFLA_MASTER])));
162 printf("master %s ", ll_idx_n2a(*(int*)RTA_DATA(tb[IFLA_MASTER]), b1));
163 } 161 }
164#endif 162#endif
165/* IFLA_OPERSTATE was added to kernel with the same commit as IFF_DORMANT */ 163/* IFLA_OPERSTATE was added to kernel with the same commit as IFF_DORMANT */
@@ -218,7 +216,6 @@ static int FAST_FUNC print_addrinfo(const struct sockaddr_nl *who UNUSED_PARAM,
218 int len = n->nlmsg_len; 216 int len = n->nlmsg_len;
219 struct rtattr * rta_tb[IFA_MAX+1]; 217 struct rtattr * rta_tb[IFA_MAX+1];
220 char abuf[256]; 218 char abuf[256];
221 SPRINT_BUF(b1);
222 219
223 if (n->nlmsg_type != RTM_NEWADDR && n->nlmsg_type != RTM_DELADDR) 220 if (n->nlmsg_type != RTM_NEWADDR && n->nlmsg_type != RTM_DELADDR)
224 return 0; 221 return 0;
@@ -250,7 +247,7 @@ static int FAST_FUNC print_addrinfo(const struct sockaddr_nl *who UNUSED_PARAM,
250 if (rta_tb[IFA_LABEL]) 247 if (rta_tb[IFA_LABEL])
251 label = RTA_DATA(rta_tb[IFA_LABEL]); 248 label = RTA_DATA(rta_tb[IFA_LABEL]);
252 else 249 else
253 label = ll_idx_n2a(ifa->ifa_index, b1); 250 label = ll_index_to_name(ifa->ifa_index);
254 if (fnmatch(G_filter.label, label, 0) != 0) 251 if (fnmatch(G_filter.label, label, 0) != 0)
255 return 0; 252 return 0;
256 } 253 }
@@ -325,7 +322,7 @@ static int FAST_FUNC print_addrinfo(const struct sockaddr_nl *who UNUSED_PARAM,
325 abuf, sizeof(abuf)) 322 abuf, sizeof(abuf))
326 ); 323 );
327 } 324 }
328 printf("scope %s ", rtnl_rtscope_n2a(ifa->ifa_scope, b1)); 325 printf("scope %s ", rtnl_rtscope_n2a(ifa->ifa_scope));
329 if (ifa->ifa_flags & IFA_F_SECONDARY) { 326 if (ifa->ifa_flags & IFA_F_SECONDARY) {
330 ifa->ifa_flags &= ~IFA_F_SECONDARY; 327 ifa->ifa_flags &= ~IFA_F_SECONDARY;
331 printf("secondary "); 328 printf("secondary ");
@@ -556,12 +553,11 @@ int FAST_FUNC ipaddr_list_or_flush(char **argv, int flush)
556 continue; 553 continue;
557 } 554 }
558 if (G_filter.label) { 555 if (G_filter.label) {
559 SPRINT_BUF(b1);
560 const char *label; 556 const char *label;
561 if (tb[IFA_LABEL]) 557 if (tb[IFA_LABEL])
562 label = RTA_DATA(tb[IFA_LABEL]); 558 label = RTA_DATA(tb[IFA_LABEL]);
563 else 559 else
564 label = ll_idx_n2a(ifa->ifa_index, b1); 560 label = ll_index_to_name(ifa->ifa_index);
565 if (fnmatch(G_filter.label, label, 0) != 0) 561 if (fnmatch(G_filter.label, label, 0) != 0)
566 continue; 562 continue;
567 } 563 }