diff options
Diffstat (limited to 'iptables/xshared.c')
-rw-r--r-- | iptables/xshared.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/iptables/xshared.c b/iptables/xshared.c index db03aaaa..db701ead 100644 --- a/iptables/xshared.c +++ b/iptables/xshared.c @@ -941,3 +941,35 @@ void parse_chain(const char *chainname) xtables_error(PARAMETER_PROBLEM, "Invalid chain name `%s'", chainname); } + +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) +{ + if (iniface != NULL) { + save_iface('i', iniface, iniface_mask, + invflags & IPT_INV_VIA_IN); + } + if (outiface != NULL) { + save_iface('o', outiface, outiface_mask, + invflags & IPT_INV_VIA_OUT); + } + + if (proto > 0) { + const char *pname = proto_to_name(proto, 0); + + if (invflags & XT_INV_PROTO) + printf(" !"); + + if (pname) + printf(" -p %s", pname); + else + printf(" -p %u", proto); + } + + if (frag) { + if (invflags & IPT_INV_FRAG) + printf(" !"); + printf(" -f"); + } +} |