]> git.pld-linux.org Git - packages/iptables.git/blob - iptables-imq.patch
- up to 1.4.8 (batch disabled; not mainained by anyone)
[packages/iptables.git] / iptables-imq.patch
1 diff -Naurw /dev/null extensions/libxt_IMQ.c
2 --- /dev/null                   1969-12-31 21:00:00.000000000 -0300
3 +++ extensions/libxt_IMQ.c      2008-06-24 22:31:02.000000000 -0300
4 @@ -0,0 +1,103 @@
5 +/* Shared library add-on to iptables to add IMQ target support. */
6 +#include <stdio.h>
7 +#include <string.h>
8 +#include <stdlib.h>
9 +#include <getopt.h>
10 +
11 +#include <xtables.h>
12 +#include <linux/netfilter/x_tables.h>
13 +#include <linux/netfilter/xt_IMQ.h>
14 +
15 +/* Function which prints out usage message. */
16 +static void IMQ_help(void)
17 +{
18 +       printf(
19 +"IMQ target options:\n"
20 +"  --todev <N>         enqueue to imq<N>, defaults to 0\n");
21 +
22 +}
23 +
24 +static struct option IMQ_opts[] = {
25 +       { "todev", 1, 0, '1' },
26 +       { 0 }
27 +};
28 +
29 +/* Initialize the target. */
30 +static void IMQ_init(struct xt_entry_target *t)
31 +{
32 +       struct xt_imq_info *mr = (struct xt_imq_info*)t->data;
33 +
34 +       mr->todev = 0;
35 +}
36 +
37 +/* Function which parses command options; returns true if it
38 +   ate an option */
39 +static int IMQ_parse(int c, char **argv, int invert, unsigned int *flags,
40 +      const void *entry, struct xt_entry_target **target)
41 +{
42 +       struct xt_imq_info *mr = (struct xt_imq_info*)(*target)->data;
43 +       
44 +       switch(c) {
45 +       case '1':
46 +               if (xtables_check_inverse(optarg, &invert, NULL, 0, argv))
47 +                       xtables_error(PARAMETER_PROBLEM,
48 +                                  "Unexpected `!' after --todev");
49 +               mr->todev=atoi(optarg);
50 +               break;
51 +       default:
52 +               return 0;
53 +       }
54 +       return 1;
55 +}
56 +
57 +/* Prints out the targinfo. */
58 +static void IMQ_print(const void *ip,
59 +      const struct xt_entry_target *target,
60 +      int numeric)
61 +{
62 +       struct xt_imq_info *mr = (struct xt_imq_info*)target->data;
63 +
64 +       printf("IMQ: todev %u ", mr->todev);
65 +}
66 +
67 +/* Saves the union ipt_targinfo in parsable form to stdout. */
68 +static void IMQ_save(const void *ip, const struct xt_entry_target *target)
69 +{
70 +       struct xt_imq_info *mr = (struct xt_imq_info*)target->data;
71 +
72 +       printf("--todev %u", mr->todev);
73 +}
74 +
75 +static struct xtables_target imq_target = {
76 +       .name           = "IMQ",
77 +       .version        = XTABLES_VERSION,
78 +       .family         = NFPROTO_IPV4,
79 +       .size           = XT_ALIGN(sizeof(struct xt_imq_info)),
80 +       .userspacesize  = XT_ALIGN(sizeof(struct xt_imq_info)),
81 +       .help           = IMQ_help,
82 +       .init           = IMQ_init,
83 +       .parse          = IMQ_parse,
84 +       .print          = IMQ_print,
85 +       .save           = IMQ_save,
86 +       .extra_opts     = IMQ_opts,
87 +};
88 +
89 +static struct xtables_target imq_target6 = {
90 +       .name           = "IMQ",
91 +       .version        = XTABLES_VERSION,
92 +       .family         = NFPROTO_IPV6,
93 +       .size           = XT_ALIGN(sizeof(struct xt_imq_info)),
94 +       .userspacesize  = XT_ALIGN(sizeof(struct xt_imq_info)),
95 +       .help           = IMQ_help,
96 +       .init           = IMQ_init,
97 +       .parse          = IMQ_parse,
98 +       .print          = IMQ_print,
99 +       .save           = IMQ_save,
100 +       .extra_opts     = IMQ_opts,
101 +};
102 +
103 +// void __attribute((constructor)) nf_ext_init(void){
104 +void _init(void){
105 +       xtables_register_target(&imq_target);
106 +       xtables_register_target(&imq_target6);
107 +}
108 diff -Naurw /dev/null extensions/libxt_IMQ.c
109 --- /dev/null                           1970-01-01 02:00:00.000000000 +0200
110 +++ include/linux/netfilter/xt_IMQ.h    2008-08-05 00:41:28.000000000 +0300
111 @@ -0,0 +1,9 @@
112 +#ifndef _XT_IMQ_H
113 +#define _XT_IMQ_H
114 +
115 +struct xt_imq_info {
116 +       unsigned int todev;     /* target imq device */
117 +};
118 +
119 +#endif /* _XT_IMQ_H */
120 +
This page took 0.037441 seconds and 3 git commands to generate.