2 * 'raw' table, which is the very first hooked in at PRE_ROUTING and LOCAL_OUT .
4 * Copyright (C) 2003 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
6 #include <linux/module.h>
7 #include <linux/netfilter_ipv4/ip_tables.h>
9 #define RAW_VALID_HOOKS ((1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_OUT))
13 struct ipt_replace repl
;
14 struct ipt_standard entries
[2];
15 struct ipt_error term
;
16 } initial_table __initdata
= {
19 .valid_hooks
= RAW_VALID_HOOKS
,
21 .size
= sizeof(struct ipt_standard
) * 2 + sizeof(struct ipt_error
),
23 [NF_IP_PRE_ROUTING
] = 0,
24 [NF_IP_LOCAL_OUT
] = sizeof(struct ipt_standard
) },
26 [NF_IP_PRE_ROUTING
] = 0,
27 [NF_IP_LOCAL_OUT
] = sizeof(struct ipt_standard
) },
33 .target_offset
= sizeof(struct ipt_entry
),
34 .next_offset
= sizeof(struct ipt_standard
),
39 .target_size
= IPT_ALIGN(sizeof(struct ipt_standard_target
)),
42 .verdict
= -NF_ACCEPT
- 1,
49 .target_offset
= sizeof(struct ipt_entry
),
50 .next_offset
= sizeof(struct ipt_standard
),
55 .target_size
= IPT_ALIGN(sizeof(struct ipt_standard_target
)),
58 .verdict
= -NF_ACCEPT
- 1,
65 .target_offset
= sizeof(struct ipt_entry
),
66 .next_offset
= sizeof(struct ipt_error
),
72 .target_size
= IPT_ALIGN(sizeof(struct ipt_error_target
)),
73 .name
= IPT_ERROR_TARGET
,
82 static struct ipt_table packet_raw
= {
84 .valid_hooks
= RAW_VALID_HOOKS
,
85 .lock
= RW_LOCK_UNLOCKED
,
89 /* The work comes in here from netfilter.c. */
91 ipt_hook(unsigned int hook
,
92 struct sk_buff
**pskb
,
93 const struct net_device
*in
,
94 const struct net_device
*out
,
95 int (*okfn
)(struct sk_buff
*))
97 return ipt_do_table(pskb
, hook
, in
, out
, &packet_raw
, NULL
);
100 /* 'raw' is the very first table. */
101 static struct nf_hook_ops ipt_ops
[] = {
105 .hooknum
= NF_IP_PRE_ROUTING
,
106 .priority
= NF_IP_PRI_RAW
,
107 .owner
= THIS_MODULE
,
112 .hooknum
= NF_IP_LOCAL_OUT
,
113 .priority
= NF_IP_PRI_RAW
,
114 .owner
= THIS_MODULE
,
118 static int __init
init(void)
123 ret
= ipt_register_table(&packet_raw
, &initial_table
.repl
);
128 ret
= nf_register_hook(&ipt_ops
[0]);
132 ret
= nf_register_hook(&ipt_ops
[1]);
139 nf_unregister_hook(&ipt_ops
[0]);
141 ipt_unregister_table(&packet_raw
);
146 static void __exit
fini(void)
150 for (i
= 0; i
< sizeof(ipt_ops
)/sizeof(struct nf_hook_ops
); i
++)
151 nf_unregister_hook(&ipt_ops
[i
]);
153 ipt_unregister_table(&packet_raw
);
158 MODULE_LICENSE("GPL");