232 | | if (!((!rootDescURL.empty() && UPNP_GetIGDFromUrl(rootDescURL.c_str(), &urls, &data, internalIPAddress, sizeof(internalIPAddress))) |
233 | | || ((devlist = upnpDiscover(10000, 0, 0, 0, 0, 0)) != NULL && (ret = UPNP_GetValidIGD(devlist, &urls, &data, internalIPAddress, sizeof(internalIPAddress))) != 0))) |
| 233 | if (!rootDescURL.empty() && UPNP_GetIGDFromUrl(rootDescURL.c_str(), &urls, &data, internalIPAddress, sizeof(internalIPAddress))) |
| 235 | LOGMESSAGE(L"Net server: using cached IGD = %hs", urls.controlURL); |
| 236 | // Init the return variable for UPNP_GetValidIGD to 1 so things behave when using cached URLs. |
| 237 | ret = 1; |
| 238 | } |
| 239 | // Else if we don't have a cached URL, or the one cached didn't respond. Try getting a valid UPnP device for 10 seconds |
| 240 | else if ((devlist = upnpDiscover(10000, 0, 0, 0, 0, 0)) != NULL) |
| 241 | { |
| 242 | // UPNP_GetValidIGD() allocates struct UPNPUrls urls on the stack for all non-zero return value. |
| 243 | |
| 244 | /* UPNP_GetValidIGD() : |
| 245 | * return values : |
| 246 | * 0 = NO IGD found |
| 247 | * 1 = A valid connected IGD has been found |
| 248 | * 2 = A valid IGD has been found but it reported as |
| 249 | * not connected |
| 250 | * 3 = an UPnP device has been found but was not recognized as an IGD |
| 251 | * |
| 252 | * In any non zero return case, the urls and data structures |
| 253 | * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to |
| 254 | * free allocated memory. |
| 255 | */ |
| 256 | ret = UPNP_GetValidIGD(devlist, &urls, &data, internalIPAddress, sizeof(internalIPAddress)); |
| 257 | (ret != 0) ? bAllocatedDescriptorURL = true: bAllocatedDescriptorURL = false; |
| 258 | } |
| 259 | else { |