diff options
author | Phil Sutter <phil@nwl.cc> | 2020-11-03 12:08:39 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2020-12-03 00:27:46 +0100 |
commit | 1bdb5535f561a4e065d766f0f4f41067e31c7281 (patch) | |
tree | d0cb281c247581e071de14d8528e1e6e1ade1a33 /extensions/libarpt_mangle.c | |
parent | 21873c24159053ce0a6bbd7e93091ceb0b73f90b (diff) |
libxtables: Extend MAC address printing/parsing support
Adding a parser which supports common names for special MAC/mask
combinations and a print routine detecting those special addresses and
printing the respective name allows to consolidate all the various
duplicated implementations.
The side-effects of this change are manageable:
* arptables now accepts "BGA" as alias for the bridge group address
* "mac" match now prints MAC addresses in lower-case which is consistent
with the remaining code at least
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'extensions/libarpt_mangle.c')
-rw-r--r-- | extensions/libarpt_mangle.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/extensions/libarpt_mangle.c b/extensions/libarpt_mangle.c index 2fea6185..a2378a8b 100644 --- a/extensions/libarpt_mangle.c +++ b/extensions/libarpt_mangle.c @@ -130,15 +130,6 @@ static void arpmangle_final_check(unsigned int flags) { } -static void print_mac(const unsigned char *mac, int l) -{ - int j; - - for (j = 0; j < l; j++) - printf("%02x%s", mac[j], - (j==l-1) ? "" : ":"); -} - static const char *ipaddr_to(const struct in_addr *addrp, int numeric) { if (numeric) @@ -159,7 +150,7 @@ arpmangle_print(const void *ip, const struct xt_entry_target *target, } if (m->flags & ARPT_MANGLE_SDEV) { printf(" --mangle-mac-s "); - print_mac((unsigned char *)m->src_devaddr, 6); + xtables_print_mac((unsigned char *)m->src_devaddr); } if (m->flags & ARPT_MANGLE_TIP) { printf(" --mangle-ip-d %s", @@ -167,7 +158,7 @@ arpmangle_print(const void *ip, const struct xt_entry_target *target, } if (m->flags & ARPT_MANGLE_TDEV) { printf(" --mangle-mac-d "); - print_mac((unsigned char *)m->tgt_devaddr, 6); + xtables_print_mac((unsigned char *)m->tgt_devaddr); } if (m->target != NF_ACCEPT) { printf(" --mangle-target %s", |