ports/net/linuxigd/files/patch-pmlist.cpp
Clive Lin af66874f38 New port: linuxigd, Linux UPnP Internet Gateway Device.
This project is a deamon that emulates Microsoft's Internet Connection
Service (ICS). It implements the UPnP Internet Gateway Device specification
(IGD) and allows UPnP aware clients, such as MSN Messenger to work properly
from behind a NAT firewall.

PR: ports/41295
Submitted by: Yen-Ming Lee <leeym@utopia.leeym.com>
Submitter sponsored by: Miss WeiWei.
2002-08-04 07:37:39 +00:00

45 lines
1.2 KiB
C++

--- 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);