1 /* Shared library add-on to iptables to add IMQ target support. */
8 #include <linux/netfilter_ipv6/ip6_tables.h>
9 #include <linux/netfilter_ipv6/ip6t_IMQ.h>
11 /* Function which prints out usage message. */
16 "IMQ target v%s options:\n"
17 " --todev <N> enqueue to imq<N>, defaults to 0\n",
21 static struct option opts
[] = {
22 { "todev", 1, 0, '1' },
26 /* Initialize the target. */
28 init(struct ip6t_entry_target
*t
, unsigned int *nfcache
)
30 struct ip6t_imq_info
*mr
= (struct ip6t_imq_info
*)t
->data
;
33 *nfcache
|= NFC_UNKNOWN
;
36 /* Function which parses command options; returns true if it
39 parse(int c
, char **argv
, int invert
, unsigned int *flags
,
40 const struct ip6t_entry
*entry
,
41 struct ip6t_entry_target
**target
)
43 struct ip6t_imq_info
*mr
= (struct ip6t_imq_info
*)(*target
)->data
;
47 if (check_inverse(optarg
, &invert
, NULL
, 0))
48 exit_error(PARAMETER_PROBLEM
,
49 "Unexpected `!' after --todev");
50 mr
->todev
=atoi(optarg
);
59 final_check(unsigned int flags
)
63 /* Prints out the targinfo. */
65 print(const struct ip6t_ip6
*ip
,
66 const struct ip6t_entry_target
*target
,
69 struct ip6t_imq_info
*mr
= (struct ip6t_imq_info
*)target
->data
;
71 printf("IMQ: todev %u ", mr
->todev
);
74 /* Saves the union ipt_targinfo in parsable form to stdout. */
76 save(const struct ip6t_ip6
*ip
, const struct ip6t_entry_target
*target
)
78 struct ip6t_imq_info
*mr
= (struct ip6t_imq_info
*)target
->data
;
80 printf("--todev %u", mr
->todev
);
83 static struct ip6tables_target imq
= {
86 .version
= IPTABLES_VERSION
,
87 .size
= IP6T_ALIGN(sizeof(struct ip6t_imq_info
)),
88 .userspacesize
= IP6T_ALIGN(sizeof(struct ip6t_imq_info
)),
92 .final_check
= &final_check
,
100 register_target6(&imq
);