]> git.saurik.com Git - apple/mdnsresponder.git/commitdiff
mDNSResponder-176.3.tar.gz mac-os-x-1056 mac-os-x-1057 mac-os-x-1058 v176.3
authorApple <opensource@apple.com>
Tue, 30 Sep 2008 18:05:47 +0000 (18:05 +0000)
committerApple <opensource@apple.com>
Tue, 30 Sep 2008 18:05:47 +0000 (18:05 +0000)
Makefile
mDNSCore/mDNS.c
mDNSCore/mDNSEmbeddedAPI.h
mDNSMacOSX/LegacyNATTraversal.c
mDNSShared/dns_sd.h

index 8f6dfb89bc81ea234b078327cca9298ac21d7115..73dd03ea9aa1b62fe69c6d6f5f486909a2d4c83f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@
 
 include /Developer/Makefiles/pb_makefiles/platform.make
 
-MVERS = "mDNSResponder-176.2"
+MVERS = "mDNSResponder-176.3"
 
 DDNSWRITECONFIG = "$(DSTROOT)/Library/Application Support/Bonjour/ddnswriteconfig"
 
index e8323b7cacfb892ee7c4c5f5f1f5fd0ba2d1d994..25789112012b2c728a1434117f84864973ded85f 100755 (executable)
@@ -38,6 +38,9 @@
     Change History (most recent first):
 
 $Log: mDNS.c,v $
+Revision 1.777.4.5  2008/09/30 18:03:01  mcguire
+<rdar://problem/6129039> BTMM: Add support for WANPPPConnection
+
 Revision 1.777.4.4  2008/08/14 20:43:59  cheshire
 <rdar://problem/6143846> Back to My Mac not working with Time Capsule shared volume
 
@@ -7156,10 +7159,11 @@ mDNSexport mStatus mDNS_Init(mDNS *const m, mDNS_PlatformSupport *const p,
 
        m->UPnPInterfaceID          = 0;
        m->SSDPSocket               = mDNSNULL;
-       m->SSDPMulticast            = mDNSfalse;
+       m->SSDPWANPPPConnection     = mDNSfalse;
        m->UPnPRouterPort           = zeroIPPort;
        m->UPnPSOAPPort             = zeroIPPort;
        m->UPnPRouterURL            = mDNSNULL;
+       m->UPnPWANPPPConnection     = mDNSfalse;
        m->UPnPSOAPURL              = mDNSNULL;
        m->UPnPRouterAddressString  = mDNSNULL;
        m->UPnPSOAPAddressString    = mDNSNULL;
index 1f1c52fb5fd19e760e91f22e5d716bd929bef5f4..8b46b3b7ec23a2eb24d9b8b63154cce6fbfd9d52 100755 (executable)
@@ -54,6 +54,9 @@
     Change History (most recent first):
 
 $Log: mDNSEmbeddedAPI.h,v $
+Revision 1.468.2.4  2008/09/30 18:03:02  mcguire
+<rdar://problem/6129039> BTMM: Add support for WANPPPConnection
+
 Revision 1.468.2.3  2008/07/29 20:46:57  mcguire
 <rdar://problem/6090007> Should use randomized source ports and transaction IDs to avoid DNS cache poisoning
 merge r1.474 from <rdar://problem/3988320>
@@ -2058,10 +2061,11 @@ struct mDNS_struct
        tcpLNTInfo       *tcpInfoUnmapList;                     // list of pending unmap requests
        mDNSInterfaceID   UPnPInterfaceID;
        UDPSocket        *SSDPSocket;               // For SSDP request/response
-       mDNSBool          SSDPMulticast;            // whether we should send the SSDP query via multicast
+       mDNSBool          SSDPWANPPPConnection;     // whether we should send the SSDP query for WANIPConnection or WANPPPConnection
        mDNSIPPort        UPnPRouterPort;                       // port we send discovery messages to
        mDNSIPPort        UPnPSOAPPort;                         // port we send SOAP messages to
        mDNSu8           *UPnPRouterURL;                        // router's URL string
+       mDNSBool          UPnPWANPPPConnection;     // whether we're using WANIPConnection or WANPPPConnection
        mDNSu8           *UPnPSOAPURL;                          // router's SOAP control URL string
        mDNSu8           *UPnPRouterAddressString;      // holds both the router's address and port
        mDNSu8           *UPnPSOAPAddressString;        // holds both address and port for SOAP messages
index 0653dfcd03a39b131d4ad4f477395a847420dc93..d833ca93d282697d95d182d6353032027bb2ca9f 100644 (file)
@@ -17,6 +17,9 @@
     Change History (most recent first):
 
 $Log: LegacyNATTraversal.c,v $
+Revision 1.48.2.1  2008/09/30 18:03:03  mcguire
+<rdar://problem/6129039> BTMM: Add support for WANPPPConnection
+
 Revision 1.48  2008/07/24 20:23:04  cheshire
 <rdar://problem/3988320> Should use randomized source ports and transaction IDs to avoid DNS cache poisoning
 
@@ -212,7 +215,7 @@ mDNSlocal mStatus SendPortMapRequest(mDNS *m, NATTraversalInfo *n);
 #define RequestedPortNum(n) (mDNSVal16(mDNSIPPortIsZero((n)->RequestedPort) ? (n)->IntPort : (n)->RequestedPort) + (n)->tcpInfo.retries)
 
 // This function parses the xml body of the device description response from the router. Basically, we look to make sure this is a response
-// referencing a service we care about (WANIPConnection), look for the "controlURL" header immediately following, and copy the addressing and URL info we need
+// referencing a service we care about (WANIPConnection or WANPPPConnection), look for the "controlURL" header immediately following, and copy the addressing and URL info we need
 mDNSlocal void handleLNTDeviceDescriptionResponse(tcpLNTInfo *tcpInfo)
        {
        mDNS    *m    = tcpInfo->m;
@@ -220,13 +223,29 @@ mDNSlocal void handleLNTDeviceDescriptionResponse(tcpLNTInfo *tcpInfo)
        char    *end  = (char *)tcpInfo->Reply + tcpInfo->nread;
        char    *stop = mDNSNULL;
 
-       // find the service we care about
+       // Always reset our flag to use WANIPConnection.  We'll use WANPPPConnection if we find it and don't find WANIPConnection.
+       m->UPnPWANPPPConnection = mDNSfalse;
+
+       // find either service we care about
        while (ptr && ptr != end)
                {
-               if (*ptr == 'W' && (strncasecmp(ptr, "WANIPConnection:1", 17) == 0)) break;     // find the first 'W'; is this WANIPConnection? if not, keep looking
+               if (*ptr == 'W' && (strncasecmp(ptr, "WANIPConnection:1", 17) == 0)) break;
                ptr++;
                }
-       if (ptr == mDNSNULL || ptr == end) { LogOperation("handleLNTDeviceDescriptionResponse: didn't find WANIPConnection:1 string"); return; }
+       if (ptr == end)
+               {
+               ptr = (char *)tcpInfo->Reply;
+               while (ptr && ptr != end)
+                       {
+                       if (*ptr == 'W' && (strncasecmp(ptr, "WANPPPConnection:1", 18) == 0))
+                               {
+                               m->UPnPWANPPPConnection = mDNStrue;
+                               break;
+                               }
+                       ptr++;
+                       }
+               }
+       if (ptr == mDNSNULL || ptr == end) { LogOperation("handleLNTDeviceDescriptionResponse: didn't find WANIPConnection:1 or WANPPPConnection:1 string"); return; }
 
        // find "controlURL", starting from where we left off
        while (ptr && ptr != end)
@@ -519,7 +538,7 @@ mDNSlocal mStatus SendSOAPMsgControlAction(mDNS *m, tcpLNTInfo *info, char *Acti
        static const char header[] =
                "POST %s HTTP/1.1\r\n"
                "Content-Type: text/xml; charset=\"utf-8\"\r\n"
-               "SOAPAction: \"urn:schemas-upnp-org:service:WANIPConnection:1#%s\"\r\n"
+               "SOAPAction: \"urn:schemas-upnp-org:service:WAN%sConnection:1#%s\"\r\n"
                "User-Agent: Mozilla/4.0 (compatible; UPnP/1.0; Windows 9x)\r\n"
                "Host: %s\r\n"
                "Content-Length: %d\r\n"
@@ -534,7 +553,7 @@ mDNSlocal mStatus SendSOAPMsgControlAction(mDNS *m, tcpLNTInfo *info, char *Acti
                " xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\""
                " SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
                "<SOAP-ENV:Body>"
-               "<m:%s xmlns:m=\"urn:schemas-upnp-org:service:WANIPConnection:1\">";
+               "<m:%s xmlns:m=\"urn:schemas-upnp-org:service:WAN%sConnection:1\">";
 
        static const char body2[] =
                "</m:%s>"
@@ -549,14 +568,14 @@ mDNSlocal mStatus SendSOAPMsgControlAction(mDNS *m, tcpLNTInfo *info, char *Acti
                { LogOperation("SendSOAPMsgControlAction: no SOAP URL or address string"); return mStatus_Invalid; }
 
        // Create body
-       bodyLen  = mDNS_snprintf   (body,           sizeof(m->omsg),           body1,   Action);
+       bodyLen  = mDNS_snprintf   (body,           sizeof(m->omsg),           body1,   Action,   m->UPnPWANPPPConnection ? "PPP" : "IP");
        bodyLen += AddSOAPArguments(body + bodyLen, sizeof(m->omsg) - bodyLen, numArgs, Arguments);
        bodyLen += mDNS_snprintf   (body + bodyLen, sizeof(m->omsg) - bodyLen, body2,   Action);
 
        // Create info->Request; the header needs to contain the bodyLen in the "Content-Length" field
        if (!info->Request) info->Request = mDNSPlatformMemAllocate(LNT_MAXBUFSIZE);
        if (!info->Request) { LogMsg("SendSOAPMsgControlAction: Can't allocate info->Request"); return mStatus_NoMemoryErr; }
-       info->requestLen = mDNS_snprintf((char *)info->Request, LNT_MAXBUFSIZE, header, m->UPnPSOAPURL, Action, m->UPnPSOAPAddressString, bodyLen, body);
+       info->requestLen = mDNS_snprintf((char *)info->Request, LNT_MAXBUFSIZE, header, m->UPnPSOAPURL, m->UPnPWANPPPConnection ? "PPP" : "IP", Action, m->UPnPSOAPAddressString, bodyLen, body);
 
        err = MakeTCPConnection(m, info, &m->Router, m->UPnPSOAPPort, op);
        if (err) { mDNSPlatformMemFree(info->Request); info->Request = mDNSNULL; }
@@ -727,7 +746,7 @@ mDNSlocal mStatus GetDeviceDescription(mDNS *m, tcpLNTInfo *info)
        }
 
 // This function parses the response to our SSDP discovery message. Basically, we look to make sure this is a response
-// referencing a service we care about (WANIPConnection), then look for the "Location:" header and copy the addressing and
+// referencing a service we care about (WANIPConnection or WANPPPConnection), then look for the "Location:" header and copy the addressing and
 // URL info we need.
 mDNSexport void LNT_ConfigureRouterInfo(mDNS *m, const mDNSInterfaceID InterfaceID, mDNSu8 *data, mDNSu16 len)
        {
@@ -740,9 +759,18 @@ mDNSexport void LNT_ConfigureRouterInfo(mDNS *m, const mDNSInterfaceID Interface
        // figure out if this is a message from a service we care about
        while (ptr && ptr != end)
                {
-               if (*ptr == 'W' && (strncasecmp(ptr, "WANIPConnection:1", 17) == 0)) break;     // find the first 'W'; is this WANIPConnection? if not, keep looking
+               if (*ptr == 'W' && (strncasecmp(ptr, "WANIPConnection:1", 17) == 0)) break;
                ptr++;
                }
+       if (ptr == end)
+               {
+               ptr = (char *)data;
+               while (ptr && ptr != end)
+                       {
+                       if (*ptr == 'W' && (strncasecmp(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
@@ -826,26 +854,33 @@ mDNSexport void LNT_ConfigureRouterInfo(mDNS *m, const mDNSInterfaceID Interface
 
 mDNSexport void LNT_SendDiscoveryMsg(mDNS *m)
        {
-       static const mDNSu8 msg[] =
+       static const char msg[] =
                "M-SEARCH * HTTP/1.1\r\n"
                "Host:239.255.255.250:1900\r\n"
-               "ST:urn:schemas-upnp-org:service:WANIPConnection:1\r\n"
+               "ST:urn:schemas-upnp-org:service:WAN%sConnection:1\r\n"
                "Man:\"ssdp:discover\"\r\n"
                "MX:3\r\n\r\n";
        static const mDNSAddr multicastDest = { mDNSAddrType_IPv4, { { { 239, 255, 255, 250 } } } };
        
-       // Always send the first SSDP packet via unicast
-       if (m->retryIntervalGetAddr <= NATMAP_INIT_RETRY) m->SSDPMulticast = mDNSfalse;
+       mDNSu8* buf = (mDNSu8*)&m->omsg; //m->omsg is 8952 bytes, which is plenty
+       unsigned int bufLen;
+
+       // Always query for WANIPConnection in the first SSDP packet
+       if (m->retryIntervalGetAddr <= NATMAP_INIT_RETRY) m->SSDPWANPPPConnection = mDNSfalse;
+
+       // Create message
+       bufLen = mDNS_snprintf((char*)buf, sizeof(m->omsg), msg, m->SSDPWANPPPConnection ? "PPP" : "IP");
 
        LogOperation("LNT_SendDiscoveryMsg Router %.4a Current External Address %.4a", &m->Router.ip.v4, &m->ExternalAddress);
 
        if (!mDNSIPv4AddressIsZero(m->Router.ip.v4) && mDNSIPv4AddressIsZero(m->ExternalAddress))
                {
                if (!m->SSDPSocket) { m->SSDPSocket = mDNSPlatformUDPSocket(m, zeroIPPort); LogOperation("LNT_SendDiscoveryMsg created SSDPSocket %p", &m->SSDPSocket); }
-               mDNSPlatformSendUDP(m, msg, msg + sizeof(msg) - 1, 0, m->SSDPSocket, m->SSDPMulticast ? &multicastDest : &m->Router, SSDPPort);
+               mDNSPlatformSendUDP(m, buf, buf + bufLen, 0, m->SSDPSocket, &m->Router,     SSDPPort);
+               mDNSPlatformSendUDP(m, buf, buf + bufLen, 0, m->SSDPSocket, &multicastDest, SSDPPort);
                }
                
-       m->SSDPMulticast = !m->SSDPMulticast;
+       m->SSDPWANPPPConnection = !m->SSDPWANPPPConnection;
        }
 
 #endif /* _LEGACY_NAT_TRAVERSAL_ */
index b5ecbb6f6719d921936d8596decefc9d71a09659..4dd99a76192ef39fec953020cceb507bf849a701 100644 (file)
@@ -77,7 +77,7 @@
  */
 
 #ifndef _DNS_SD_H
-#define _DNS_SD_H 1760200
+#define _DNS_SD_H 1760300
 
 #ifdef  __cplusplus
     extern "C" {