]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/iptables-1.4.2-imq.patch
Stop dhcpcd before starting if it was running
[people/pmueller/ipfire-2.x.git] / src / patches / iptables-1.4.2-imq.patch
1 diff -Naur iptables-1.4.2/extensions/.IMQ-test iptables/extensions/.IMQ-test
2 --- iptables-1.4.2/extensions/.IMQ-test 1970-01-01 10:00:00.000000000 +1000
3 +++ iptables/extensions/.IMQ-test 2008-06-08 22:41:49.000000000 +1000
4 @@ -0,0 +1,3 @@
5 +#!/bin/sh
6 +# True if IMQ target patch is applied.
7 +[ -f $KERNEL_DIR/include/linux/netfilter/xt_IMQ.h ] && echo IMQ
8 diff -Naur iptables-1.4.2/extensions/libipt_IMQ.c iptables/extensions/libipt_IMQ.c
9 --- iptables-1.4.2/extensions/libipt_IMQ.c 1970-01-01 10:00:00.000000000 +1000
10 +++ iptables/extensions/libipt_IMQ.c 2008-06-08 22:46:25.000000000 +1000
11 @@ -0,0 +1,88 @@
12 +/* Shared library add-on to iptables to add IMQ target support. */
13 +#include <stdio.h>
14 +#include <string.h>
15 +#include <stdlib.h>
16 +#include <getopt.h>
17 +
18 +#include <xtables.h>
19 +#include <linux/netfilter/x_tables.h>
20 +#include <linux/netfilter/xt_IMQ.h>
21 +
22 +/* Function which prints out usage message. */
23 +static void IMQ_help(void)
24 +{
25 + printf(
26 +"IMQ target v%s options:\n"
27 +" --todev <N> enqueue to imq<N>, defaults to 0\n",
28 +XTABLES_VERSION);
29 +}
30 +
31 +static struct option IMQ_opts[] = {
32 + { "todev", 1, 0, '1' },
33 + { 0 }
34 +};
35 +
36 +/* Initialize the target. */
37 +static void IMQ_init(struct xt_entry_target *t)
38 +{
39 + struct xt_imq_info *mr = (struct xt_imq_info*)t->data;
40 +
41 + mr->todev = 0;
42 +}
43 +
44 +/* Function which parses command options; returns true if it
45 + ate an option */
46 +static int IMQ_parse(int c, char **argv, int invert, unsigned int *flags,
47 + const void *entry, struct xt_entry_target **target)
48 +{
49 + struct xt_imq_info *mr = (struct xt_imq_info*)(*target)->data;
50 +
51 + switch(c) {
52 + case '1':
53 + if (check_inverse(optarg, &invert, NULL, 0))
54 + exit_error(PARAMETER_PROBLEM,
55 + "Unexpected `!' after --todev");
56 + mr->todev=atoi(optarg);
57 + break;
58 + default:
59 + return 0;
60 + }
61 + return 1;
62 +}
63 +
64 +/* Prints out the targinfo. */
65 +static void IMQ_print(const void *ip,
66 + const struct xt_entry_target *target,
67 + int numeric)
68 +{
69 + struct xt_imq_info *mr = (struct xt_imq_info*)target->data;
70 +
71 + printf("IMQ: todev %u ", mr->todev);
72 +}
73 +
74 +/* Saves the union ipt_targinfo in parsable form to stdout. */
75 +static void IMQ_save(const void *ip, const struct xt_entry_target *target)
76 +{
77 + struct xt_imq_info *mr = (struct xt_imq_info*)target->data;
78 +
79 + printf("--todev %u", mr->todev);
80 +}
81 +
82 +static struct xtables_target imq = {
83 + .name = "IMQ",
84 + .version = XTABLES_VERSION,
85 + .family = PF_INET,
86 + .size = XT_ALIGN(sizeof(struct xt_imq_info)),
87 + .userspacesize = XT_ALIGN(sizeof(struct xt_imq_info)),
88 + .help = IMQ_help,
89 + .init = IMQ_init,
90 + .parse = IMQ_parse,
91 + .print = IMQ_print,
92 + .save = IMQ_save,
93 + .extra_opts = IMQ_opts,
94 +};
95 +
96 +void _init(void)
97 +{
98 + xtables_register_target(&imq);
99 +}