1 /* Kernel module to match packet length. */
2 #include <linux/module.h>
3 #include <linux/skbuff.h>
5 #include <linux/netfilter_ipv4/ipt_length.h>
6 #include <linux/netfilter_ipv4/ip_tables.h>
8 MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");
9 MODULE_DESCRIPTION("IP tables packet length matching module");
10 MODULE_LICENSE("GPL");
13 match(const struct sk_buff
*skb
,
14 const struct net_device
*in
,
15 const struct net_device
*out
,
16 const void *matchinfo
,
22 const struct ipt_length_info
*info
= matchinfo
;
23 u_int16_t pktlen
= ntohs(skb
->nh
.iph
->tot_len
);
25 return (pktlen
>= info
->min
&& pktlen
<= info
->max
) ^ info
->invert
;
29 checkentry(const char *tablename
,
30 const struct ipt_ip
*ip
,
32 unsigned int matchsize
,
33 unsigned int hook_mask
)
35 if (matchsize
!= IPT_ALIGN(sizeof(struct ipt_length_info
)))
41 static struct ipt_match length_match
42 = { { NULL
, NULL
}, "length", &match
, &checkentry
, NULL
, THIS_MODULE
};
44 static int __init
init(void)
46 return ipt_register_match(&length_match
);
49 static void __exit
fini(void)
51 ipt_unregister_match(&length_match
);