mirror of
https://git.freebsd.org/ports.git
synced 2025-06-29 08:30:37 -04:00
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.
45 lines
1.2 KiB
C++
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);
|