summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_fw2.c
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>2004-10-03 00:47:15 +0000
committergreen <green@FreeBSD.org>2004-10-03 00:47:15 +0000
commitcb606898b9f83045c54ca6796b13313487916ac0 (patch)
treeed21a6bab51547d776061c9da2318f199ee4ea14 /sys/netinet/ip_fw2.c
parentcdf18c02e63403bcc3ca98fc618b46d5868cd2d3 (diff)
downloadFreeBSD-src-cb606898b9f83045c54ca6796b13313487916ac0.zip
FreeBSD-src-cb606898b9f83045c54ca6796b13313487916ac0.tar.gz
Add support to IPFW for matching by TCP data length.
Diffstat (limited to 'sys/netinet/ip_fw2.c')
-rw-r--r--sys/netinet/ip_fw2.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/sys/netinet/ip_fw2.c b/sys/netinet/ip_fw2.c
index 854e2d9..c45a04f 100644
--- a/sys/netinet/ip_fw2.c
+++ b/sys/netinet/ip_fw2.c
@@ -2203,6 +2203,28 @@ check_body:
flags_match(cmd, ip->ip_tos));
break;
+ case O_TCPDATALEN:
+ if (proto == IPPROTO_TCP && offset == 0) {
+ struct tcphdr *tcp;
+ uint16_t x;
+ uint16_t *p;
+ int i;
+
+ tcp = L3HDR(struct tcphdr,ip);
+ x = ip_len -
+ ((ip->ip_hl + tcp->th_off) << 2);
+ if (cmdlen == 1) {
+ match = (cmd->arg1 == x);
+ break;
+ }
+ /* otherwise we have ranges */
+ p = ((ipfw_insn_u16 *)cmd)->ports;
+ i = cmdlen - 1;
+ for (; !match && i>0; i--, p += 2)
+ match = (x >= p[0] && x <= p[1]);
+ }
+ break;
+
case O_TCPFLAGS:
match = (proto == IPPROTO_TCP && offset == 0 &&
flags_match(cmd,
@@ -3014,6 +3036,7 @@ check_ipfw_struct(struct ip_fw *rule, int size)
case O_IPID:
case O_IPTTL:
case O_IPLEN:
+ case O_TCPDATALEN:
if (cmdlen < 1 || cmdlen > 31)
goto bad_size;
break;
OpenPOWER on IntegriCloud