diff options
author | Dave Zambonini <dave@alfar.co.uk> | 2003-06-14 14:27:51 +0000 |
---|---|---|
committer | Martin Josefsson <gandalf@wlug.westbo.se> | 2003-06-14 14:27:51 +0000 |
commit | 78c57fac86e7ac32332684e80429a8dab9a8f556 (patch) | |
tree | a6d949fea0d30aa781e3b01be2e44fc678c6a741 | |
parent | 0cc203a59f2d8687f8ec3f6ebb86a81aaa574648 (diff) |
Fix save-invert printout (David Zambonini, me)
-rw-r--r-- | extensions/libip6t_mac.c | 17 | ||||
-rw-r--r-- | extensions/libipt_mac.c | 17 |
2 files changed, 22 insertions, 12 deletions
diff --git a/extensions/libip6t_mac.c b/extensions/libip6t_mac.c index fe0d3a45..617b353f 100644 --- a/extensions/libip6t_mac.c +++ b/extensions/libip6t_mac.c @@ -86,11 +86,11 @@ parse(int c, char **argv, int invert, unsigned int *flags, return 1; } -static void print_mac(unsigned char macaddress[ETH_ALEN], int invert) +static void print_mac(unsigned char macaddress[ETH_ALEN]) { unsigned int i; - printf("%s%02X", invert ? "! " : "", macaddress[0]); + printf("%02X", macaddress[0]); for (i = 1; i < ETH_ALEN; i++) printf(":%02X", macaddress[i]); printf(" "); @@ -111,16 +111,21 @@ print(const struct ip6t_ip6 *ip, int numeric) { printf("MAC "); - print_mac(((struct ip6t_mac_info *)match->data)->srcaddr, - ((struct ip6t_mac_info *)match->data)->invert); + + if (((struct ip6t_mac_info *)match->data)->invert) + printf("! "); + + print_mac(((struct ip6t_mac_info *)match->data)->srcaddr); } /* Saves the union ip6t_matchinfo in parsable form to stdout. */ static void save(const struct ip6t_ip6 *ip, const struct ip6t_entry_match *match) { + if (((struct ip6t_mac_info *)match->data)->invert) + printf("! "); + printf("--mac-source "); - print_mac(((struct ip6t_mac_info *)match->data)->srcaddr, - ((struct ip6t_mac_info *)match->data)->invert); + print_mac(((struct ip6t_mac_info *)match->data)->srcaddr); } static diff --git a/extensions/libipt_mac.c b/extensions/libipt_mac.c index b9d3b367..d1079a5e 100644 --- a/extensions/libipt_mac.c +++ b/extensions/libipt_mac.c @@ -86,11 +86,11 @@ parse(int c, char **argv, int invert, unsigned int *flags, return 1; } -static void print_mac(unsigned char macaddress[ETH_ALEN], int invert) +static void print_mac(unsigned char macaddress[ETH_ALEN]) { unsigned int i; - printf("%s%02X", invert ? "! " : "", macaddress[0]); + printf("%02X", macaddress[0]); for (i = 1; i < ETH_ALEN; i++) printf(":%02X", macaddress[i]); printf(" "); @@ -111,16 +111,21 @@ print(const struct ipt_ip *ip, int numeric) { printf("MAC "); - print_mac(((struct ipt_mac_info *)match->data)->srcaddr, - ((struct ipt_mac_info *)match->data)->invert); + + if (((struct ipt_mac_info *)match->data)->invert) + printf("! "); + + print_mac(((struct ipt_mac_info *)match->data)->srcaddr); } /* Saves the union ipt_matchinfo in parsable form to stdout. */ static void save(const struct ipt_ip *ip, const struct ipt_entry_match *match) { + if (((struct ipt_mac_info *)match->data)->invert) + printf("! "); + printf("--mac-source "); - print_mac(((struct ipt_mac_info *)match->data)->srcaddr, - ((struct ipt_mac_info *)match->data)->invert); + print_mac(((struct ipt_mac_info *)match->data)->srcaddr); } static |