remove upnp mapping before adding new ones

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1821 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2009-11-12 22:19:45 +00:00
parent 8168be6828
commit 573e7b2474
3 changed files with 13 additions and 7 deletions

View file

@ -168,15 +168,20 @@ bool upnphandler::start_upnp()
#endif
}
//build port mapping config
//first of all, build the mappings
std::vector<CUPnPPortMapping> upnpPortMapping1;
CUPnPPortMapping cUPnPPortMapping1 = CUPnPPortMapping(eport_curr, ntohs(localAddr.sin_port), "TCP", true, "tcp retroshare redirection");
upnpPortMapping1.push_back(cUPnPPortMapping1);
bool res = cUPnPControlPoint->AddPortMappings(upnpPortMapping1);
std::vector<CUPnPPortMapping> upnpPortMapping2;
CUPnPPortMapping cUPnPPortMapping2 = CUPnPPortMapping(eport_curr, ntohs(localAddr.sin_port), "UDP", true, "udp retroshare redirection");
upnpPortMapping2.push_back(cUPnPPortMapping2);
//attempt to remove formal port redirection rules
cUPnPControlPoint->DeletePortMappings(upnpPortMapping1);
cUPnPControlPoint->DeletePortMappings(upnpPortMapping2);
//add new rules
bool res = cUPnPControlPoint->AddPortMappings(upnpPortMapping1);
bool res2 = cUPnPControlPoint->AddPortMappings(upnpPortMapping2);
struct sockaddr_in extAddr;