summaryrefslogtreecommitdiffstats
path: root/iptables.c
diff options
context:
space:
mode:
Diffstat (limited to 'iptables.c')
-rw-r--r--iptables.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/iptables.c b/iptables.c
index b45211a9..2459b648 100644
--- a/iptables.c
+++ b/iptables.c
@@ -1006,22 +1006,22 @@ static void print_proto(uint16_t proto, int invert)
{
if (proto) {
unsigned int i;
- const char *invertstr = invert ? "! " : "";
+ const char *invertstr = invert ? " !" : "";
const struct protoent *pent = getprotobynumber(proto);
if (pent) {
- printf("%s-p %s ", invertstr, pent->p_name);
+ printf("%s -p %s", invertstr, pent->p_name);
return;
}
for (i = 0; xtables_chain_protos[i].name != NULL; ++i)
if (xtables_chain_protos[i].num == proto) {
- printf("%s-p %s ",
+ printf("%s -p %s",
invertstr, xtables_chain_protos[i].name);
return;
}
- printf("%s-p %u ", invertstr, proto);
+ printf("%s -p %u", invertstr, proto);
}
}
@@ -1043,7 +1043,7 @@ print_iface(char letter, const char *iface, const unsigned char *mask,
if (mask[0] == 0)
return;
- printf("%s-%c ", invert ? "! " : "", letter);
+ printf("%s -%c ", invert ? " !" : "", letter);
for (i = 0; i < IFNAMSIZ; i++) {
if (mask[i] != 0) {
@@ -1057,8 +1057,6 @@ print_iface(char letter, const char *iface, const unsigned char *mask,
break;
}
}
-
- printf(" ");
}
static int print_match_save(const struct ipt_entry_match *e,
@@ -1068,7 +1066,7 @@ static int print_match_save(const struct ipt_entry_match *e,
xtables_find_match(e->u.user.name, XTF_TRY_LOAD, NULL);
if (match) {
- printf("-m %s ", e->u.user.name);
+ printf(" -m %s", e->u.user.name);
/* some matches don't provide a save function */
if (match->save)
@@ -1094,13 +1092,13 @@ static void print_ip(const char *prefix, uint32_t ip,
if (!mask && !ip && !invert)
return;
- printf("%s%s %u.%u.%u.%u",
- invert ? "! " : "",
+ printf("%s %s %u.%u.%u.%u",
+ invert ? " !" : "",
prefix,
IP_PARTS(ip));
if (mask == 0xFFFFFFFFU) {
- printf("/32 ");
+ printf("/32");
return;
}
@@ -1109,9 +1107,9 @@ static void print_ip(const char *prefix, uint32_t ip,
while (--i >= 0 && hmask != bits)
bits <<= 1;
if (i >= 0)
- printf("/%u ", i);
+ printf("/%u", i);
else
- printf("/%u.%u.%u.%u ", IP_PARTS(mask));
+ printf("/%u.%u.%u.%u", IP_PARTS(mask));
}
/* We want this to be readable, so only print out neccessary fields.
@@ -1127,7 +1125,7 @@ void print_rule(const struct ipt_entry *e,
printf("[%llu:%llu] ", (unsigned long long)e->counters.pcnt, (unsigned long long)e->counters.bcnt);
/* print chain name */
- printf("-A %s ", chain);
+ printf("-A %s", chain);
/* Print IP part. */
print_ip("-s", e->ip.src.s_addr,e->ip.smsk.s_addr,
@@ -1145,8 +1143,8 @@ void print_rule(const struct ipt_entry *e,
print_proto(e->ip.proto, e->ip.invflags & IPT_INV_PROTO);
if (e->ip.flags & IPT_F_FRAG)
- printf("%s-f ",
- e->ip.invflags & IPT_INV_FRAG ? "! " : "");
+ printf("%s -f",
+ e->ip.invflags & IPT_INV_FRAG ? " !" : "");
/* Print matchinfo part */
if (e->target_offset) {
@@ -1155,15 +1153,15 @@ void print_rule(const struct ipt_entry *e,
/* print counters for iptables -R */
if (counters < 0)
- printf("-c %llu %llu ", (unsigned long long)e->counters.pcnt, (unsigned long long)e->counters.bcnt);
+ printf(" -c %llu %llu", (unsigned long long)e->counters.pcnt, (unsigned long long)e->counters.bcnt);
/* Print target name */
target_name = iptc_get_target(e, h);
if (target_name && (*target_name != '\0'))
#ifdef IPT_F_GOTO
- printf("-%c %s ", e->ip.flags & IPT_F_GOTO ? 'g' : 'j', target_name);
+ printf(" -%c %s", e->ip.flags & IPT_F_GOTO ? 'g' : 'j', target_name);
#else
- printf("-j %s ", target_name);
+ printf(" -j %s", target_name);
#endif
/* Print targinfo part */