diff options
author | Phil Sutter <phil@nwl.cc> | 2022-11-25 04:27:21 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2022-11-29 13:25:26 +0100 |
commit | 7533e96dadfcecbb49f819976ffc986a67920545 (patch) | |
tree | d958a2655969aaf9f52a08c58ac2ac6207ea44f3 /extensions/libxt_tcp.c | |
parent | 023dd2c515be63ddb2f0b6a6f3bccab4cdf7a71c (diff) |
extensions: Leverage xlate auto-spacing
Drop code which is used explicitly to deal with spacing.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'extensions/libxt_tcp.c')
-rw-r--r-- | extensions/libxt_tcp.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/extensions/libxt_tcp.c b/extensions/libxt_tcp.c index 2ef84299..f8257282 100644 --- a/extensions/libxt_tcp.c +++ b/extensions/libxt_tcp.c @@ -397,7 +397,6 @@ static int tcp_xlate(struct xt_xlate *xl, { const struct xt_tcp *tcpinfo = (const struct xt_tcp *)params->match->data; - char *space= ""; if (tcpinfo->spts[0] != 0 || tcpinfo->spts[1] != 0xffff) { if (tcpinfo->spts[0] != tcpinfo->spts[1]) { @@ -411,33 +410,29 @@ static int tcp_xlate(struct xt_xlate *xl, "!= " : "", tcpinfo->spts[0]); } - space = " "; } if (tcpinfo->dpts[0] != 0 || tcpinfo->dpts[1] != 0xffff) { if (tcpinfo->dpts[0] != tcpinfo->dpts[1]) { - xt_xlate_add(xl, "%stcp dport %s%u-%u", space, + xt_xlate_add(xl, "tcp dport %s%u-%u", tcpinfo->invflags & XT_TCP_INV_DSTPT ? "!= " : "", tcpinfo->dpts[0], tcpinfo->dpts[1]); } else { - xt_xlate_add(xl, "%stcp dport %s%u", space, + xt_xlate_add(xl, "tcp dport %s%u", tcpinfo->invflags & XT_TCP_INV_DSTPT ? "!= " : "", tcpinfo->dpts[0]); } - space = " "; } - if (tcpinfo->option) { - xt_xlate_add(xl, "%stcp option %u %s", space, tcpinfo->option, + if (tcpinfo->option) + xt_xlate_add(xl, "tcp option %u %s", tcpinfo->option, tcpinfo->invflags & XT_TCP_INV_OPTION ? "missing" : "exists"); - space = " "; - } if (tcpinfo->flg_mask || (tcpinfo->invflags & XT_TCP_INV_FLAGS)) { - xt_xlate_add(xl, "%stcp flags %s", space, + xt_xlate_add(xl, "tcp flags %s", tcpinfo->invflags & XT_TCP_INV_FLAGS ? "!= ": ""); print_tcp_xlate(xl, tcpinfo->flg_cmp); xt_xlate_add(xl, " / "); |