arptables-compat: get output in sync with arptables -L -n --line-numbers
Pablo Neira Ayuso
maintainerPATCH 1/1 arptables-compat: get output in sync with arptables -L -n --line-numbers
# arptables-compat -L -n --line-numbers Chain INPUT (policy ACCEPT) num target prot opt source destination <--
This header is not shown by arptables.
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- iptables/nft-arp.c | 22 ++++++++++++++++++++++ iptables/nft-ipv4.c | 9 +++++++++ iptables/nft-ipv6.c | 9 +++++++++ iptables/nft-shared.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ iptables/nft-shared.h | 8 ++++++++ iptables/nft.c | 48 ++---------------------------------------------- 6 files changed, 94 insertions(+), 46 deletions(-)
iptables/nft-arp.c +22 -0
@@ -414,6 +414,27 @@ void nft_rule_to_arptables_command_state(struct nft_rule *r, cs->jumpto ="" ; } +static void nft_arp_print_header (unsigned int format,const char *chain, +const char *pol, +const struct xt_counters *counters, +bool basechain,uint32_t refs) +{ +printf ("Chain %s" , chain); +if (pol) { +printf (" (policy %s" , pol); +if (!(format &FMT_NOCOUNTS )) { +fputc (' ' , stdout); +xtables_print_num (counters->pcnt, (format|FMT_NOTABLE )); +fputs ("packets, " , stdout); +xtables_print_num (counters->bcnt, (format|FMT_NOTABLE )); +fputs ("bytes" , stdout); + } +printf (")\n" ); + }else { +printf (" (%u references)\n" , refs); + } +} +static void print_fw_details (struct arpt_entry *fw,unsigned int format) {char buf[BUFSIZ ];
@@ -665,6 +686,7 @@ struct nft_family_ops nft_family_ops_arp = { .parse_meta = nft_arp_parse_meta, .parse_payload = nft_arp_parse_payload, .parse_immediate = nft_arp_parse_immediate, + .print_header = nft_arp_print_header, .print_firewall = nft_arp_print_firewall, .save_firewall = nft_arp_save_firewall, .save_counters = nft_arp_save_counters,
iptables/nft-ipv4.c +9 -0
@@ -221,6 +221,14 @@ static void nft_ipv4_parse_immediate(const char *jumpto, bool nft_goto, cs->fw.ip.flags |=IPT_F_GOTO ; } +static void nft_ipv4_print_header (unsigned int format,const char *chain, +const char *pol, +const struct xt_counters *counters, +bool basechain,uint32_t refs) +{ +print_header (format, chain, pol, counters, basechain, refs); +} +static void print_ipv4_addr (const struct iptables_command_state *cs,unsigned int format) {
@@ -415,6 +423,7 @@ struct nft_family_ops nft_family_ops_ipv4 = { .parse_meta = nft_ipv4_parse_meta, .parse_payload = nft_ipv4_parse_payload, .parse_immediate = nft_ipv4_parse_immediate, + .print_header = nft_ipv4_print_header, .print_firewall = nft_ipv4_print_firewall, .save_firewall = nft_ipv4_save_firewall, .save_counters = nft_ipv4_save_counters,
iptables/nft-ipv6.c +9 -0
@@ -158,6 +158,14 @@ static void nft_ipv6_parse_immediate(const char *jumpto, bool nft_goto, cs->fw6.ipv6.flags |=IP6T_F_GOTO ; } +static void nft_ipv6_print_header (unsigned int format,const char *chain, +const char *pol, +const struct xt_counters *counters, +bool basechain,uint32_t refs) +{ +print_header (format, chain, pol, counters, basechain, refs); +} +static void print_ipv6_addr (const struct iptables_command_state *cs,unsigned int format) {
@@ -360,6 +368,7 @@ struct nft_family_ops nft_family_ops_ipv6 = { .parse_meta = nft_ipv6_parse_meta, .parse_payload = nft_ipv6_parse_payload, .parse_immediate = nft_ipv6_parse_immediate, + .print_header = nft_ipv6_print_header, .print_firewall = nft_ipv6_print_firewall, .save_firewall = nft_ipv6_save_firewall, .save_counters = nft_ipv6_save_counters,
iptables/nft-shared.c +44 -0
50 lines not on this page · raw message
iptables/nft-shared.h +8 -0
@@ -82,6 +82,11 @@ struct nft_family_ops {void (*parse_cmp)(struct nft_xt_ctx *ctx,struct nft_rule_expr *e,void *data);void (*parse_immediate)(const char *jumpto,bool nft_goto,void *data); + +void (*print_header)(unsigned int format,const char *chain, +const char *pol, +const struct xt_counters *counters,bool basechain, +uint32_t refs);void (*print_firewall)(struct nft_rule *r,unsigned int num,unsigned int format);void (*save_firewall)(const void *data,unsigned int format);
@@ -131,6 +136,9 @@ void nft_parse_counter(struct nft_rule_expr *e, struct xt_counters *counters);void nft_parse_immediate (struct nft_xt_ctx *ctx,struct nft_rule_expr *e);void nft_rule_to_iptables_command_state (struct nft_rule *r,struct iptables_command_state *cs); +void print_header (unsigned int format,const char *chain,const char *pol, +const struct xt_counters *counters,bool basechain, +uint32_t refs); void print_firewall_details(const struct iptables_command_state *cs, const char *targname, uint8_t flags, uint8_t invflags, uint8_t proto,
iptables/nft.c +2 -46
60 lines not on this page · raw message
Signature · 1 line
1.7.10.4