summaryrefslogtreecommitdiffstats
path: root/sbin/ipfw/ipfw2.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2012-02-06 11:35:29 +0000
committerglebius <glebius@FreeBSD.org>2012-02-06 11:35:29 +0000
commitd050a38ab423c57cd15f6818d1d27faf9a35b352 (patch)
tree2eb43c8c15636e42b731b89be197bba24de15363 /sbin/ipfw/ipfw2.c
parent52c17430bc70cd8c1e6dc2ff5c7786cc3f4871e4 (diff)
downloadFreeBSD-src-d050a38ab423c57cd15f6818d1d27faf9a35b352.zip
FreeBSD-src-d050a38ab423c57cd15f6818d1d27faf9a35b352.tar.gz
Make the 'tcpwin' option of ipfw(8) accept ranges and lists.
Submitted by: sem
Diffstat (limited to 'sbin/ipfw/ipfw2.c')
-rw-r--r--sbin/ipfw/ipfw2.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index 6b0e0f0..ac0632e 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -512,6 +512,7 @@ static struct _s_x _port_name[] = {
{"ipttl", O_IPTTL},
{"mac-type", O_MAC_TYPE},
{"tcpdatalen", O_TCPDATALEN},
+ {"tcpwin", O_TCPWIN},
{"tagged", O_TAGGED},
{NULL, 0}
};
@@ -1480,7 +1481,11 @@ show_ipfw(struct ip_fw *rule, int pcwidth, int bcwidth)
break;
case O_TCPWIN:
- printf(" tcpwin %d", ntohs(cmd->arg1));
+ if (F_LEN(cmd) == 1)
+ printf(" tcpwin %u", cmd->arg1);
+ else
+ print_newports((ipfw_insn_u16 *)cmd, 0,
+ O_TCPWIN);
break;
case O_TCPACK:
@@ -3447,8 +3452,12 @@ read_options:
case TOK_TCPWIN:
NEED1("tcpwin requires length");
- fill_cmd(cmd, O_TCPWIN, 0,
- htons(strtoul(*av, NULL, 0)));
+ if (strpbrk(*av, "-,")) {
+ if (!add_ports(cmd, *av, 0, O_TCPWIN))
+ errx(EX_DATAERR, "invalid tcpwin len %s", *av);
+ } else
+ fill_cmd(cmd, O_TCPWIN, 0,
+ strtoul(*av, NULL, 0));
av++;
break;
OpenPOWER on IntegriCloud