1/* Length Match - IPv6 Port */
2
3#include <linux/module.h>
4#include <linux/skbuff.h>
5#include <linux/netfilter_ipv6/ip6t_length.h>
6#include <linux/netfilter_ipv6/ip6_tables.h>
7
8static int
9match(const struct sk_buff *skb,
10      const struct net_device *in,
11      const struct net_device *out,
12      const void *matchinfo,
13      int offset,
14      const void *hdr,
15      u_int16_t datalen,
16      int *hotdrop)
17{
18	const struct ip6t_length_info *info = matchinfo;
19	u_int16_t pktlen = ntohs(skb->nh.ipv6h->payload_len) + sizeof(struct ipv6hdr);
20
21	return (pktlen >= info->min && pktlen <= info->max) ^ info->invert;
22}
23
24static int
25checkentry(const char *tablename,
26           const struct ip6t_ip6 *ip,
27           void *matchinfo,
28           unsigned int matchsize,
29           unsigned int hook_mask)
30{
31	if (matchsize != IP6T_ALIGN(sizeof(struct ip6t_length_info)))
32		return 0;
33
34	return 1;
35}
36
37static struct ip6t_match length_match
38= { { NULL, NULL }, "length", &match, &checkentry, NULL, THIS_MODULE };
39
40static int __init init(void)
41{
42	return ip6t_register_match(&length_match);
43}
44
45static void __exit fini(void)
46{
47	ip6t_unregister_match(&length_match);
48}
49
50module_init(init);
51module_exit(fini);
52