add packages_10.03.2 in preparation for the 10.03.2 interim release
[10.03/packages.git] / net / linuxigd / patches / 004-iptables-1.4.3.2-compat.patch
1 diff -ur linuxigd-1.0.orig/iptc.c linuxigd-1.0/iptc.c
2 --- linuxigd-1.0.orig/iptc.c    2009-05-05 14:01:59.000000000 +0200
3 +++ linuxigd-1.0/iptc.c 2009-05-05 14:05:48.000000000 +0200
4 @@ -7,16 +7,24 @@
5  #include <iptables.h>
6  #include <libiptc/libiptc.h>
7  #include <linux/version.h>
8 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
9 -#include <linux/netfilter/nf_nat.h>
10 +#ifdef IPTABLES_143
11 +#  include <net/netfilter/nf_nat.h>
12 +#  define ip_nat_multi_range nf_nat_multi_range_compat
13 +#  define ip_nat_range nf_nat_range
14  #else
15 -#include <linux/netfilter_ipv4/ip_nat.h>
16 +#  if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
17 +#    include <linux/netfilter/nf_nat.h>
18 +#  else
19 +#    include <linux/netfilter_ipv4/ip_nat.h>
20 +#  endif
21  #endif
22  #include <arpa/inet.h> /* inet_addr */
23  #include "globals.h"
24  #include "util.h"
25  #include "iptc.h"
26  
27 +#define IPTC_HANDLE struct iptc_handle *
28 +
29  struct ipt_natinfo
30  {
31         struct ipt_entry_target t;
32 @@ -49,7 +57,7 @@
33                     const char *dnat_to,
34                     const int append)
35  {
36 -       iptc_handle_t handle;
37 +       IPTC_HANDLE handle;
38         struct ipt_entry *chain_entry;
39         struct ipt_entry_match *entry_match = NULL;
40         struct ipt_entry_target *entry_target = NULL;
41 @@ -126,15 +134,15 @@
42                 return;
43         }
44         if (append)
45 -               result = iptc_append_entry(labelit, chain_entry, &handle);
46 +               result = iptc_append_entry(labelit, chain_entry, handle);
47         else
48 -               result = iptc_insert_entry(labelit, chain_entry, 0, &handle);
49 +               result = iptc_insert_entry(labelit, chain_entry, 0, handle);
50  
51         if (!result) {
52                 trace(1, "libiptc error: Can't add, %s", iptc_strerror(errno));
53                 return;
54         }
55 -       result = iptc_commit(&handle);
56 +       result = iptc_commit(handle);
57         if (!result) {
58           trace(1, "libiptc error: Commit error, %s", iptc_strerror(errno));
59                 return;
60 @@ -159,7 +167,7 @@
61                        const char *target,
62                        const char *dnat_to)
63  {
64 -       iptc_handle_t handle;
65 +       IPTC_HANDLE handle;
66         const struct ipt_entry *e;
67         ipt_chainlabel labelit;
68         int i, result;
69 @@ -182,7 +190,7 @@
70         }
71         
72         /* check through rules to find match */
73 -       for (e = iptc_first_rule(chain, &handle), i=0; e; e = iptc_next_rule(e, &handle), i++)  {
74 +       for (e = iptc_first_rule(chain, handle), i=0; e; e = iptc_next_rule(e, handle), i++)  {
75                 if (s_src != INADDR_NONE && e->ip.src.s_addr != s_src) continue;
76                 if (s_dest != INADDR_NONE && e->ip.dst.s_addr != s_dest) continue;
77                 if (iniface && strcmp(e->ip.iniface, iniface) != 0) continue;
78 @@ -190,7 +198,7 @@
79                 if (protocol && strcmp(protocol, "TCP") == 0 && e->ip.proto != IPPROTO_TCP) continue;
80                 if (protocol && strcmp(protocol, "UDP") == 0 && e->ip.proto != IPPROTO_UDP) continue;
81                 if ((srcports || destports) && IPT_MATCH_ITERATE(e, matchcmp, srcports, destports) == 0) continue;
82 -               if (target && strcmp(target, iptc_get_target(e, &handle)) != 0) continue;
83 +               if (target && strcmp(target, iptc_get_target(e, handle)) != 0) continue;
84                 if (dnat_to && strcmp(target, "DNAT") == 0) {
85                         struct ipt_entry_target *t;
86                         struct ip_nat_multi_range *mr;
87 @@ -214,12 +222,12 @@
88                 break;
89         }
90         if (!e) return;
91 -       result = iptc_delete_num_entry(chain, i, &handle);
92 +       result = iptc_delete_num_entry(chain, i, handle);
93         if (!result) {
94           trace(1, "libiptc error: Delete error, %s", iptc_strerror(errno));
95                 return;
96         }
97 -       result = iptc_commit(&handle);
98 +       result = iptc_commit(handle);
99         if (!result) {
100           trace(1, "libiptc error: Commit error, %s", iptc_strerror(errno));
101                 return;