diff options
author | Florian Westphal <fw@strlen.de> | 2018-11-03 23:43:49 +0100 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2018-11-07 20:08:15 +0100 |
commit | 7bd9febf65e98eb1f4b4d51afa2479c442066235 (patch) | |
tree | 016e65d6e7fc85cda5baa28837e8e0f2c2c93240 /extensions/libebt_stp.c | |
parent | a10eb8861c8fdc8894a8c2f6baf4dd791d5ab4f0 (diff) |
libxtables: add and use mac print helpers
This changes ebtables-nft to consistently print mac
address with two characters, i.e.
00:01:02:03:04:0a, not 0:1:2:3:4:a.
Will require another bump of vcurrent/vage.
Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'extensions/libebt_stp.c')
-rw-r--r-- | extensions/libebt_stp.c | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/extensions/libebt_stp.c b/extensions/libebt_stp.c index 25f2735f..06cf93b8 100644 --- a/extensions/libebt_stp.c +++ b/extensions/libebt_stp.c @@ -297,31 +297,6 @@ brstp_parse(int c, char **argv, int invert, unsigned int *flags, return 1; } -static void ebt_print_mac(const unsigned char *mac) -{ - int j; - for (j = 0; j < ETH_ALEN; j++) - printf("%02x%s", mac[j], - (j==ETH_ALEN-1) ? "" : ":"); -} - -static bool mac_all_ones(const unsigned char *mac) -{ - static const char hlpmsk[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - - return memcmp(mac, hlpmsk, sizeof(hlpmsk)) == 0; -} - -static void ebt_print_mac_and_mask(const unsigned char *mac, const unsigned char *mask) -{ - - ebt_print_mac(mac); - if (!mac_all_ones(mask)) { - printf("/"); - ebt_print_mac(mask); - } -} - static void brstp_print(const void *ip, const struct xt_entry_match *match, int numeric) { @@ -351,14 +326,14 @@ static void brstp_print(const void *ip, const struct xt_entry_match *match, } else if (EBT_STP_ROOTPRIO == (1 << i)) print_range(c->root_priol, c->root_priou); else if (EBT_STP_ROOTADDR == (1 << i)) - ebt_print_mac_and_mask((unsigned char *)c->root_addr, + xtables_print_mac_and_mask((unsigned char *)c->root_addr, (unsigned char*)c->root_addrmsk); else if (EBT_STP_ROOTCOST == (1 << i)) print_range(c->root_costl, c->root_costu); else if (EBT_STP_SENDERPRIO == (1 << i)) print_range(c->sender_priol, c->sender_priou); else if (EBT_STP_SENDERADDR == (1 << i)) - ebt_print_mac_and_mask((unsigned char *)c->sender_addr, + xtables_print_mac_and_mask((unsigned char *)c->sender_addr, (unsigned char *)c->sender_addrmsk); else if (EBT_STP_PORT == (1 << i)) print_range(c->portl, c->portu); |