Busybox: Upgrade to 1.21.1 (stable). lsof active.
[tomato.git] / release / src / router / iptables / extensions / libip6t_IMQ.c
blob983f5e917bd985f4342aa0bff3c0e26d703a5311
1 /* Shared library add-on to iptables to add IMQ target support. */
2 #include <stdio.h>
3 #include <string.h>
4 #include <stdlib.h>
5 #include <getopt.h>
7 #include <ip6tables.h>
8 #include <linux/netfilter_ipv6/ip6_tables.h>
9 #include <linux/netfilter_ipv6/ip6t_IMQ.h>
11 /* Function which prints out usage message. */
12 static void
13 help(void)
15 printf(
16 "IMQ target v%s options:\n"
17 " --todev <N> enqueue to imq<N>, defaults to 0\n",
18 IPTABLES_VERSION);
21 static struct option opts[] = {
22 { "todev", 1, 0, '1' },
23 { 0 }
26 /* Initialize the target. */
27 static void
28 init(struct ip6t_entry_target *t, unsigned int *nfcache)
30 struct ip6t_imq_info *mr = (struct ip6t_imq_info*)t->data;
32 mr->todev = 0;
33 *nfcache |= NFC_UNKNOWN;
36 /* Function which parses command options; returns true if it
37 ate an option */
38 static int
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;
45 switch(c) {
46 case '1':
47 if (check_inverse(optarg, &invert, NULL, 0))
48 exit_error(PARAMETER_PROBLEM,
49 "Unexpected `!' after --todev");
50 mr->todev=atoi(optarg);
51 break;
52 default:
53 return 0;
55 return 1;
58 static void
59 final_check(unsigned int flags)
63 /* Prints out the targinfo. */
64 static void
65 print(const struct ip6t_ip6 *ip,
66 const struct ip6t_entry_target *target,
67 int numeric)
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. */
75 static void
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 = {
84 .next = NULL,
85 .name = "IMQ",
86 .version = IPTABLES_VERSION,
87 .size = IP6T_ALIGN(sizeof(struct ip6t_imq_info)),
88 .userspacesize = IP6T_ALIGN(sizeof(struct ip6t_imq_info)),
89 .help = &help,
90 .init = &init,
91 .parse = &parse,
92 .final_check = &final_check,
93 .print = &print,
94 .save = &save,
95 .extra_opts = opts
98 void _init(void)
100 register_target6(&imq);