2 * Copyright (C)2006 USAGI/WIDE Project
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
9 * Masahide NAKAMURA @USAGI <masahide.nakamura.cz@hitachi.com>
11 * Based on net/netfilter/xt_tcpudp.c
14 #include <linux/types.h>
15 #include <linux/module.h>
17 #include <linux/ipv6.h>
21 #include <linux/netfilter/x_tables.h>
22 #include <linux/netfilter_ipv6/ip6t_mh.h>
24 MODULE_DESCRIPTION("ip6t_tables match for MH");
25 MODULE_LICENSE("GPL");
27 #ifdef DEBUG_IP_FIREWALL_USER
28 #define duprintf(format, args...) printk(format , ## args)
30 #define duprintf(format, args...)
33 /* Returns 1 if the type is matched by the range, 0 otherwise */
35 type_match(u_int8_t min
, u_int8_t max
, u_int8_t type
, bool invert
)
37 return (type
>= min
&& type
<= max
) ^ invert
;
41 match(const struct sk_buff
*skb
,
42 const struct net_device
*in
,
43 const struct net_device
*out
,
44 const struct xt_match
*match
,
45 const void *matchinfo
,
51 const struct ip6_mh
*mh
;
52 const struct ip6t_mh
*mhinfo
= matchinfo
;
54 /* Must not be a fragment. */
58 mh
= skb_header_pointer(skb
, protoff
, sizeof(_mh
), &_mh
);
60 /* We've been asked to examine this packet, and we
61 can't. Hence, no choice but to drop. */
62 duprintf("Dropping evil MH tinygram.\n");
67 if (mh
->ip6mh_proto
!= IPPROTO_NONE
) {
68 duprintf("Dropping invalid MH Payload Proto: %u\n",
74 return type_match(mhinfo
->types
[0], mhinfo
->types
[1], mh
->ip6mh_type
,
75 !!(mhinfo
->invflags
& IP6T_MH_INV_TYPE
));
78 /* Called when user tries to insert an entry of this type. */
80 mh_checkentry(const char *tablename
,
82 const struct xt_match
*match
,
84 unsigned int hook_mask
)
86 const struct ip6t_mh
*mhinfo
= matchinfo
;
88 /* Must specify no unknown invflags */
89 return !(mhinfo
->invflags
& ~IP6T_MH_INV_MASK
);
92 static struct xt_match mh_match
= {
95 .checkentry
= mh_checkentry
,
97 .matchsize
= sizeof(struct ip6t_mh
),
102 static int __init
ip6t_mh_init(void)
104 return xt_register_match(&mh_match
);
107 static void __exit
ip6t_mh_fini(void)
109 xt_unregister_match(&mh_match
);
112 module_init(ip6t_mh_init
);
113 module_exit(ip6t_mh_fini
);
This page took 0.033301 seconds and 6 git commands to generate.