}
}
+static void print_iface(char letter, const char *iface,
+ unsigned int format, bool invert, const char **sep)
+{
+ if (iface[0] == '\0' || (!strcmp(iface, "+") && !invert)) {
+ if (!(format & FMT_VIA))
+ return;
+ iface = (format & FMT_NUMERIC) ? "*" : "any";
+ }
+ printf("%s%s-%c %s", *sep, invert ? "! " : "", letter, iface);
+ *sep = " ";
+}
+
static void nft_arp_print_rule_details(const struct iptables_command_state *cs,
unsigned int format)
{
const struct arpt_entry *fw = &cs->arp;
- char iface[IFNAMSIZ+2];
const char *sep = "";
- int print_iface = 0;
int i;
if (strlen(cs->jumpto)) {
sep = " ";
}
- iface[0] = '\0';
-
- if (fw->arp.iniface[0] != '\0') {
- strcat(iface, fw->arp.iniface);
- print_iface = 1;
- }
- else if (format & FMT_VIA) {
- print_iface = 1;
- if (format & FMT_NUMERIC) strcat(iface, "*");
- else strcat(iface, "any");
- }
- if (print_iface) {
- printf("%s%s-i %s", sep, fw->arp.invflags & IPT_INV_VIA_IN ?
- "! " : "", iface);
- sep = " ";
- }
-
- print_iface = 0;
- iface[0] = '\0';
-
- if (fw->arp.outiface[0] != '\0') {
- strcat(iface, fw->arp.outiface);
- print_iface = 1;
- }
- else if (format & FMT_VIA) {
- print_iface = 1;
- if (format & FMT_NUMERIC) strcat(iface, "*");
- else strcat(iface, "any");
- }
- if (print_iface) {
- printf("%s%s-o %s", sep, fw->arp.invflags & IPT_INV_VIA_OUT ?
- "! " : "", iface);
- sep = " ";
- }
+ print_iface('i', fw->arp.iniface, format,
+ fw->arp.invflags & IPT_INV_VIA_IN, &sep);
+ print_iface('o', fw->arp.outiface, format,
+ fw->arp.invflags & IPT_INV_VIA_OUT, &sep);
if (fw->arp.smsk.s_addr != 0L) {
printf("%s%s-s %s", sep,