- {
- const mDNSu8 *ptr = data;
- const mDNSu8 *end = data + len;
- const mDNSu8 *stop = ptr;
-
- if (!mDNSIPPortIsZero(m->UPnPRouterPort)) return; // already have the info we need
-
- // The formatting of the HTTP header is not always the same when it comes to the placement of
- // the service and location strings, so we just look for each of them from the beginning for every response
-
- // figure out if this is a message from a service we care about
- while (ptr && ptr != end)
- {
- if ((*ptr & 0xDF) == 'W' && (strncasecmp((char*)ptr, "WANIPConnection:1", 17) == 0)) break;
- ptr++;
- }
- if (ptr == end)
- {
- ptr = data;
- while (ptr && ptr != end)
- {
- if ((*ptr & 0xDF) == 'W' && (strncasecmp((char*)ptr, "WANPPPConnection:1", 18) == 0)) break;
- ptr++;
- }
- }
- if (ptr == mDNSNULL || ptr == end) return; // not a message we care about
-
- // find "Location:", starting from the beginning
- ptr = data;
- while (ptr && ptr != end)
- {
- if ((*ptr & 0xDF) == 'L' && (strncasecmp((char*)ptr, "Location:", 9) == 0)) break; // find the first 'L'; is this Location? if not, keep looking
- ptr++;
- }
- if (ptr == mDNSNULL || ptr == end)
- {
- mDNSASLLog((uuid_t *)&m->asl_uuid, "natt.legacy.ssdp", "failure", "Location", "");
- return; // not a message we care about
- }
- ptr += 9; //Skip over 'Location:'
- while (*ptr == ' ' && ptr < end) ptr++; // skip over spaces
- if (ptr >= end) return;
-
- // find the end of the line
- for (stop = ptr; stop != end; stop++) { if (*stop == '\r') { end = stop; break; } }
-
- // fill in default port
- m->UPnPRouterPort = mDNSOpaque16fromIntVal(80);
-
- // free string pointers and set to NULL
- if (m->UPnPRouterAddressString != mDNSNULL)
- {
- mDNSPlatformMemFree(m->UPnPRouterAddressString);
- m->UPnPRouterAddressString = mDNSNULL;
- }
- if (m->UPnPRouterURL != mDNSNULL)
- {
- mDNSPlatformMemFree(m->UPnPRouterURL);
- m->UPnPRouterURL = mDNSNULL;
- }
-
- // the Router URL should look something like "/dyndev/uuid:0013-108c-4b3f0000f3dc"
- if (ParseHttpUrl(ptr, end, &m->UPnPRouterAddressString, &m->UPnPRouterPort, &m->UPnPRouterURL) != mStatus_NoError)
- {
- mDNSASLLog((uuid_t *)&m->asl_uuid, "natt.legacy.ssdp", "failure", "Parse URL", "");
- return;
- }
-
- m->UPnPInterfaceID = InterfaceID;
-
- if (m->UPnPRouterAddressString == mDNSNULL)
- {
- mDNSASLLog((uuid_t *)&m->asl_uuid, "natt.legacy.ssdp", "failure", "Router address", "");
- LogMsg("LNT_ConfigureRouterInfo: UPnPRouterAddressString is NULL");
- }
- else LogInfo("LNT_ConfigureRouterInfo: Router address string [%s]", m->UPnPRouterAddressString);
-
- if (m->UPnPRouterURL == mDNSNULL)
- {
- mDNSASLLog((uuid_t *)&m->asl_uuid, "natt.legacy.ssdp", "failure", "Router path", "");
- LogMsg("LNT_ConfigureRouterInfo: UPnPRouterURL is NULL");
- }
- else LogInfo("LNT_ConfigureRouterInfo: Router URL [%s]", m->UPnPRouterURL);
-
- LogInfo("LNT_ConfigureRouterInfo: Router port %d", mDNSVal16(m->UPnPRouterPort));
- LogInfo("LNT_ConfigureRouterInfo: Router interface %d", m->UPnPInterfaceID);
-
- // Don't need the SSDP socket anymore
- if (m->SSDPSocket) { debugf("LNT_ConfigureRouterInfo destroying SSDPSocket %p", &m->SSDPSocket); mDNSPlatformUDPClose(m->SSDPSocket); m->SSDPSocket = mDNSNULL; }
-
- mDNSASLLog((uuid_t *)&m->asl_uuid, "natt.legacy.ssdp", "success", "success", "");
- // now send message to get the device description
- GetDeviceDescription(m, &m->tcpDeviceInfo);
- }
+{
+ const mDNSu8 *ptr = data;
+ const mDNSu8 *end = data + len;
+ const mDNSu8 *stop = ptr;
+
+ if (!mDNSIPPortIsZero(m->UPnPRouterPort)) return; // already have the info we need
+
+ // The formatting of the HTTP header is not always the same when it comes to the placement of
+ // the service and location strings, so we just look for each of them from the beginning for every response
+
+ // figure out if this is a message from a service we care about
+ while (ptr && ptr != end)
+ {
+ if ((*ptr & 0xDF) == 'W' && (strncasecmp((char*)ptr, "WANIPConnection:1", 17) == 0)) break;
+ ptr++;
+ }
+ if (ptr == end)
+ {
+ ptr = data;
+ while (ptr && ptr != end)
+ {
+ if ((*ptr & 0xDF) == 'W' && (strncasecmp((char*)ptr, "WANPPPConnection:1", 18) == 0)) break;
+ ptr++;
+ }
+ }
+ if (ptr == mDNSNULL || ptr == end) return; // not a message we care about
+
+ // find "Location:", starting from the beginning
+ ptr = data;
+ while (ptr && ptr != end)
+ {
+ if ((*ptr & 0xDF) == 'L' && (strncasecmp((char*)ptr, "Location:", 9) == 0)) break; // find the first 'L'; is this Location? if not, keep looking
+ ptr++;
+ }
+ if (ptr == mDNSNULL || ptr == end)
+ {
+ mDNSASLLog((uuid_t *)&m->asl_uuid, "natt.legacy.ssdp", "failure", "Location", "");
+ return; // not a message we care about
+ }
+ ptr += 9; //Skip over 'Location:'
+ while (*ptr == ' ' && ptr < end) ptr++; // skip over spaces
+ if (ptr >= end) return;
+
+ // find the end of the line
+ for (stop = ptr; stop != end; stop++) { if (*stop == '\r') { end = stop; break; } }
+
+ // fill in default port
+ m->UPnPRouterPort = mDNSOpaque16fromIntVal(80);
+
+ // free string pointers and set to NULL
+ if (m->UPnPRouterAddressString != mDNSNULL)
+ {
+ mDNSPlatformMemFree(m->UPnPRouterAddressString);
+ m->UPnPRouterAddressString = mDNSNULL;
+ }
+ if (m->UPnPRouterURL != mDNSNULL)
+ {
+ mDNSPlatformMemFree(m->UPnPRouterURL);
+ m->UPnPRouterURL = mDNSNULL;
+ }
+
+ // the Router URL should look something like "/dyndev/uuid:0013-108c-4b3f0000f3dc"
+ if (ParseHttpUrl(ptr, end, &m->UPnPRouterAddressString, &m->UPnPRouterPort, &m->UPnPRouterURL) != mStatus_NoError)
+ {
+ mDNSASLLog((uuid_t *)&m->asl_uuid, "natt.legacy.ssdp", "failure", "Parse URL", "");
+ return;
+ }
+
+ m->UPnPInterfaceID = InterfaceID;
+
+ if (m->UPnPRouterAddressString == mDNSNULL)
+ {
+ mDNSASLLog((uuid_t *)&m->asl_uuid, "natt.legacy.ssdp", "failure", "Router address", "");
+ LogMsg("LNT_ConfigureRouterInfo: UPnPRouterAddressString is NULL");
+ }
+ else LogInfo("LNT_ConfigureRouterInfo: Router address string [%s]", m->UPnPRouterAddressString);
+
+ if (m->UPnPRouterURL == mDNSNULL)
+ {
+ mDNSASLLog((uuid_t *)&m->asl_uuid, "natt.legacy.ssdp", "failure", "Router path", "");
+ LogMsg("LNT_ConfigureRouterInfo: UPnPRouterURL is NULL");
+ }
+ else LogInfo("LNT_ConfigureRouterInfo: Router URL [%s]", m->UPnPRouterURL);
+
+ LogInfo("LNT_ConfigureRouterInfo: Router port %d", mDNSVal16(m->UPnPRouterPort));
+ LogInfo("LNT_ConfigureRouterInfo: Router interface %d", m->UPnPInterfaceID);
+
+ // Don't need the SSDP socket anymore
+ if (m->SSDPSocket) { debugf("LNT_ConfigureRouterInfo destroying SSDPSocket %p", &m->SSDPSocket); mDNSPlatformUDPClose(m->SSDPSocket); m->SSDPSocket = mDNSNULL; }
+
+ mDNSASLLog((uuid_t *)&m->asl_uuid, "natt.legacy.ssdp", "success", "success", "");
+ // now send message to get the device description
+ GetDeviceDescription(m, &m->tcpDeviceInfo);
+}