aboutsummaryrefslogtreecommitdiffstats
path: root/net/linuxigd/files/patch-pmlist.cpp
blob: b0301c18f168d1dec482e1d109f1882317898e48 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
--- pmlist.cpp.orig Fri May  3 00:16:28 2002
+++ pmlist.cpp  Sat Aug  3 22:11:41 2002
@@ -30,6 +30,9 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <iostream.h>
+
+extern char *ExtIf;
+
 PortMapList::PortMapList()
 {
 
@@ -190,9 +193,12 @@
    else
        strcpy (prt, "udp");
 
-   sprintf(command,"/usr/sbin/iptables -t nat -A PREROUTING -p %s -d %s --dport %d -j DNAT --to %s:%d", prt, ExtIP, ExtPort, IntIP, IntPort);
-   
-   system(command);
+   FILE *ipnat = popen("/sbin/ipnat -f -", "w");
+   if (ipnat == NULL)
+       return 0;
+   sprintf(command, "rdr %s %s/32 port %d -> %s port %d %s", ExtIf, ExtIP, ExtPort, IntIP, IntPort, prt);
+   fprintf(ipnat, command);
+   pclose(ipnat);
 
    ret=1;
    return (ret);
@@ -234,9 +240,13 @@
    else
        strcpy (prt, "udp");
 
-   sprintf(command, "/usr/sbin/iptables -t nat -D PREROUTING -p %s -d %s --dport %d -j DNAT --to %s:%d", prt, ExtIP, ExtPort, IntIP, IntPort);
-   
-   system(command);
+   FILE *ipnat = popen("/sbin/ipnat -rf -", "w");
+   if (ipnat == NULL)
+       return 0;
+   sprintf(command, "rdr %s %s/32 port %d -> %s port %d %s", ExtIf, ExtIP, ExtPort, IntIP, IntPort, prt);
+   fprintf(ipnat, command);
+   pclose(ipnat);
+
    ret = 1;
 
    return (ret);