add new method for external upnp address

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1752 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2009-10-30 00:36:14 +00:00
parent 938c2edef2
commit 04ecbc5514
2 changed files with 27 additions and 13 deletions

View file

@ -170,6 +170,8 @@ void CUPnPLib::ProcessActionResponse(
std::cerr << "\n " << std::cerr << "\n " <<
childTag << "='" << childTag << "='" <<
childValue << "'"; childValue << "'";
//add the variable to the wanservice property map
(m_ctrlPoint.m_WanService->propertyMap)[std::string(childTag)] = std::string(childValue);
child = Element_GetNextSibling(child); child = Element_GetNextSibling(child);
} }
} else { } else {
@ -1021,8 +1023,12 @@ std::string CUPnPControlPoint::getExternalAddress()
"WAN Service not detected." << std::endl; "WAN Service not detected." << std::endl;
return false; return false;
} }
PrivateGetExternalIpAdress();
return m_WanService->GetStateVariable("ExternalIPAddress"); std::string result = m_WanService->GetStateVariable("NewExternalIPAddress");
if (result == "") {
result = m_WanService->GetStateVariable("ExternalIPAddress");
}
return result;
} }
void CUPnPControlPoint::RefreshPortMappings() void CUPnPControlPoint::RefreshPortMappings()
@ -1137,6 +1143,22 @@ bool CUPnPControlPoint::PrivateDeletePortMapping(
return ret; return ret;
} }
bool CUPnPControlPoint::PrivateGetExternalIpAdress()
{
// Start building the action
std::string actionName("GetExternalIPAddress");
std::vector<CUPnPArgumentValue> argval(0);
// Execute
bool ret = true;
for (ServiceMap::iterator it = m_ServiceMap.begin();
it != m_ServiceMap.end(); ++it) {
ret &= it->second->Execute(actionName, argval);
}
return ret;
}
// This function is static // This function is static
int CUPnPControlPoint::Callback(Upnp_EventType EventType, void *Event, void * /*Cookie*/) int CUPnPControlPoint::Callback(Upnp_EventType EventType, void *Event, void * /*Cookie*/)
@ -1362,15 +1384,6 @@ upnpEventSubscriptionExpired:
} else { } else {
//add the variable to the wanservice property map //add the variable to the wanservice property map
(upnpCP->m_WanService->propertyMap)[std::string(sv_event->StateVarName)] = std::string(sv_event->CurrentVal); (upnpCP->m_WanService->propertyMap)[std::string(sv_event->StateVarName)] = std::string(sv_event->CurrentVal);
#if 0
// Warning: The use of UpnpGetServiceVarStatus and
// UpnpGetServiceVarStatusAsync is deprecated by the
// UPnP forum.
TvCtrlPointHandleGetVar(
sv_event->CtrlUrl,
sv_event->StateVarName,
sv_event->CurrentVal );
#endif
} }
break; break;
} }

View file

@ -569,10 +569,10 @@ private:
PortMappingMap m_ActivePortMappingsMap; PortMappingMap m_ActivePortMappingsMap;
RsMutex m_RootDeviceListMutex; RsMutex m_RootDeviceListMutex;
bool m_IGWDeviceDetected; bool m_IGWDeviceDetected;
CUPnPService *m_WanService;
RsMutex m_WaitForSearchTimeoutMutex; RsMutex m_WaitForSearchTimeoutMutex;
public: public:
CUPnPService *m_WanService;
RsMutex m_getStateVariableMutex; RsMutex m_getStateVariableMutex;
std::string m_getStateVariableLastResult; std::string m_getStateVariableLastResult;
static CUPnPControlPoint *s_CtrlPoint; static CUPnPControlPoint *s_CtrlPoint;
@ -622,6 +622,7 @@ private:
CUPnPPortMapping &upnpPortMapping); CUPnPPortMapping &upnpPortMapping);
bool PrivateDeletePortMapping( bool PrivateDeletePortMapping(
CUPnPPortMapping &upnpPortMapping); CUPnPPortMapping &upnpPortMapping);
bool PrivateGetExternalIpAdress();
}; };
// File_checked_for_headers // File_checked_for_headers