summaryrefslogtreecommitdiffstats
path: root/iptables/xshared.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2021-11-05 22:02:45 +0100
committerPhil Sutter <phil@nwl.cc>2021-11-23 15:01:23 +0100
commit1d73cec02c8d9a0f5bfbd2983c36cc1228b78f45 (patch)
tree77b13589ecdbbb63ab19adcbcac38e86a04c7f98 /iptables/xshared.c
parente5fb9f8efaa0643a566d079c8201082822a0dc81 (diff)
xshared: Share print_rule_details() with legacy
Have to pass pointer to counters directly since different fields are being used for some reason. Since proto_to_name() is not used outside of xshared.c anymore, make it static. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables/xshared.c')
-rw-r--r--iptables/xshared.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/iptables/xshared.c b/iptables/xshared.c
index 3e06960f..7f2e1a32 100644
--- a/iptables/xshared.c
+++ b/iptables/xshared.c
@@ -48,7 +48,7 @@ void print_extension_helps(const struct xtables_target *t,
}
}
-const char *
+static const char *
proto_to_name(uint16_t proto, int nolookup)
{
unsigned int i;
@@ -999,6 +999,31 @@ void parse_chain(const char *chainname)
"Invalid chain name `%s'", chainname);
}
+void print_rule_details(unsigned int linenum, const struct xt_counters *ctrs,
+ const char *targname, uint8_t proto, uint8_t flags,
+ uint8_t invflags, unsigned int format)
+{
+ const char *pname = proto_to_name(proto, format&FMT_NUMERIC);
+
+ if (format & FMT_LINENUMBERS)
+ printf(FMT("%-4u ", "%u "), linenum);
+
+ if (!(format & FMT_NOCOUNTS)) {
+ xtables_print_num(ctrs->pcnt, format);
+ xtables_print_num(ctrs->bcnt, format);
+ }
+
+ if (!(format & FMT_NOTARGET))
+ printf(FMT("%-9s ", "%s "), targname ? targname : "");
+
+ fputc(invflags & XT_INV_PROTO ? '!' : ' ', stdout);
+
+ if (pname)
+ printf(FMT("%-5s", "%s "), pname);
+ else
+ printf(FMT("%-5hu", "%hu "), proto);
+}
+
void save_rule_details(const char *iniface, unsigned const char *iniface_mask,
const char *outiface, unsigned const char *outiface_mask,
uint16_t proto, int frag, uint8_t invflags)