2 * IPv6 raw table, a port of the IPv4 raw table to IPv6
4 * Copyright (C) 2003 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
6 #include <linux/module.h>
7 #include <linux/netfilter_ipv6/ip6_tables.h>
9 #define RAW_VALID_HOOKS ((1 << NF_IP6_PRE_ROUTING) | (1 << NF_IP6_LOCAL_OUT))
12 #define DEBUGP(x, args...) printk(KERN_DEBUG x, ## args)
14 #define DEBUGP(x, args...)
20 struct ip6t_entry entry
;
21 struct ip6t_standard_target target
;
24 struct ip6t_error_target
26 struct ip6t_entry_target target
;
27 char errorname
[IP6T_FUNCTION_MAXNAMELEN
];
32 struct ip6t_entry entry
;
33 struct ip6t_error_target target
;
38 struct ip6t_replace repl
;
39 struct ip6t_standard entries
[2];
40 struct ip6t_error term
;
41 } initial_table __initdata
= {
44 .valid_hooks
= RAW_VALID_HOOKS
,
46 .size
= sizeof(struct ip6t_standard
) * 2 + sizeof(struct ip6t_error
),
48 [NF_IP6_PRE_ROUTING
] = 0,
49 [NF_IP6_LOCAL_OUT
] = sizeof(struct ip6t_standard
)
52 [NF_IP6_PRE_ROUTING
] = 0,
53 [NF_IP6_LOCAL_OUT
] = sizeof(struct ip6t_standard
)
60 .target_offset
= sizeof(struct ip6t_entry
),
61 .next_offset
= sizeof(struct ip6t_standard
),
66 .target_size
= IP6T_ALIGN(sizeof(struct ip6t_standard_target
)),
69 .verdict
= -NF_ACCEPT
- 1,
76 .target_offset
= sizeof(struct ip6t_entry
),
77 .next_offset
= sizeof(struct ip6t_standard
),
82 .target_size
= IP6T_ALIGN(sizeof(struct ip6t_standard_target
)),
85 .verdict
= -NF_ACCEPT
- 1,
92 .target_offset
= sizeof(struct ip6t_entry
),
93 .next_offset
= sizeof(struct ip6t_error
),
99 .target_size
= IP6T_ALIGN(sizeof(struct ip6t_error_target
)),
100 .name
= IP6T_ERROR_TARGET
,
104 .errorname
= "ERROR",
109 static struct ip6t_table packet_raw
= {
111 .valid_hooks
= RAW_VALID_HOOKS
,
112 .lock
= RW_LOCK_UNLOCKED
,
116 /* The work comes in here from netfilter.c. */
118 ip6t_hook(unsigned int hook
,
119 struct sk_buff
**pskb
,
120 const struct net_device
*in
,
121 const struct net_device
*out
,
122 int (*okfn
)(struct sk_buff
*))
124 return ip6t_do_table(pskb
, hook
, in
, out
, &packet_raw
, NULL
);
127 static struct nf_hook_ops ip6t_ops
[] = {
131 .hooknum
= NF_IP6_PRE_ROUTING
,
132 .priority
= NF_IP6_PRI_FIRST
137 .hooknum
= NF_IP6_LOCAL_OUT
,
138 .priority
= NF_IP6_PRI_FIRST
142 static int __init
init(void)
147 ret
= ip6t_register_table(&packet_raw
, &initial_table
.repl
);
152 ret
= nf_register_hook(&ip6t_ops
[0]);
156 ret
= nf_register_hook(&ip6t_ops
[1]);
163 nf_unregister_hook(&ip6t_ops
[0]);
165 ip6t_unregister_table(&packet_raw
);
170 static void __exit
fini(void)
174 for (i
= 0; i
< sizeof(ip6t_ops
)/sizeof(struct nf_hook_ops
); i
++)
175 nf_unregister_hook(&ip6t_ops
[i
]);
177 ip6t_unregister_table(&packet_raw
);
182 MODULE_LICENSE("GPL");