diff options
Diffstat (limited to 'networking')
-rw-r--r-- | networking/arp.c | 38 | ||||
-rw-r--r-- | networking/libiproute/ipaddress.c | 19 |
2 files changed, 30 insertions, 27 deletions
diff --git a/networking/arp.c b/networking/arp.c index f42e09f7c..f85a91022 100644 --- a/networking/arp.c +++ b/networking/arp.c @@ -313,6 +313,26 @@ static void arp_disp(const char *name, char *ip, int type, int arp_flags, char *hwa, char *mask, char *dev) { + static const int arp_masks[] = { + ATF_PERM, ATF_PUBL, +#ifdef HAVE_ATF_MAGIC + ATF_MAGIC, +#endif +#ifdef HAVE_ATF_DONTPUB + ATF_DONTPUB, +#endif + ATF_USETRAILERS, + }; + static const char arp_labels[] ALIGN1 = "PERM\0""PUP\0" +#ifdef HAVE_ATF_MAGIC + "AUTO\0" +#endif +#ifdef HAVE_ATF_DONTPUB + "DONTPUB\0" +#endif + "TRAIL\0" + ; + const struct hwtype *xhw; xhw = get_hwntype(type); @@ -333,22 +353,8 @@ arp_disp(const char *name, char *ip, int type, int arp_flags, if (arp_flags & ATF_NETMASK) printf("netmask %s ", mask); - if (arp_flags & ATF_PERM) - printf("PERM "); - if (arp_flags & ATF_PUBL) - printf("PUP "); -#ifdef HAVE_ATF_MAGIC - if (arp_flags & ATF_MAGIC) - printf("AUTO "); -#endif -#ifdef HAVE_ATF_DONTPUB - if (arp_flags & ATF_DONTPUB) - printf("DONTPUB "); -#endif - if (arp_flags & ATF_USETRAILERS) - printf("TRAIL "); - - printf("on %s\n", dev); + print_flags_separated(arp_masks, arp_labels, arp_flags, " "); + printf(" on %s\n", dev); } /* Display the contents of the ARP cache in the kernel. */ diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 07b27870d..faa3f2d06 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c @@ -45,16 +45,15 @@ typedef struct filter_t { static void print_link_flags(unsigned flags, unsigned mdown) { + static const int flag_masks[] = { + IFF_LOOPBACK, IFF_BROADCAST, IFF_POINTOPOINT, + IFF_MULTICAST, IFF_NOARP, IFF_UP, IFF_LOWER_UP }; + static const char flag_labels[] ALIGN1 = + "LOOPBACK\0""BROADCAST\0""POINTOPOINT\0" + "MULTICAST\0""NOARP\0""UP\0""LOWER_UP\0"; + bb_putchar('<'); flags &= ~IFF_RUNNING; -#define _PF(f) if (flags & IFF_##f) { \ - flags &= ~IFF_##f; \ - printf(#f "%s", flags ? "," : ""); } - _PF(LOOPBACK); - _PF(BROADCAST); - _PF(POINTOPOINT); - _PF(MULTICAST); - _PF(NOARP); #if 0 _PF(ALLMULTI); _PF(PROMISC); @@ -66,9 +65,7 @@ static void print_link_flags(unsigned flags, unsigned mdown) _PF(PORTSEL); _PF(NOTRAILERS); #endif - _PF(UP); - _PF(LOWER_UP); -#undef _PF + flags = print_flags_separated(flag_masks, flag_labels, flags, ","); if (flags) printf("%x", flags); if (mdown) |