<rdar://problem/7196046> Need to wake for IPSec to port 4500 for Back to My Mac
authorcheshire@apple.com <cheshire@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Fri, 4 Sep 2009 00:23:48 +0000 (00:23 +0000)
committercheshire@apple.com <cheshire@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Fri, 4 Sep 2009 00:23:48 +0000 (00:23 +0000)
git-svn-id: http://svn.macosforge.org/repository/mDNSResponder/trunk@6647 214c2c4a-bf3b-4dcf-9390-e4dd3010487d

mDNSCore/DNSCommon.c
mDNSCore/mDNSEmbeddedAPI.h
mDNSMacOSX/mDNSMacOSX.c

index 6cd47ab..5771c61 100644 (file)
@@ -61,6 +61,7 @@ mDNSexport const mDNSInterfaceID mDNSInterface_Unicast   = (mDNSInterfaceID)2;
 #define   SSHPortAsNumber                  22
 #define   UnicastDNSPortAsNumber           53
 #define   SSDPPortAsNumber               1900
+#define   IPSECPortAsNumber              4500
 #define   NSIPCPortAsNumber              5030          // Port used for dnsextd to talk to local nameserver bound to loopback
 #define   NATPMPAnnouncementPortAsNumber 5350
 #define   NATPMPPortAsNumber             5351
@@ -74,6 +75,7 @@ mDNSexport const mDNSIPPort DiscardPort            = { { DiscardPortAsNumber
 mDNSexport const mDNSIPPort SSHPort                = { { SSHPortAsNumber                >> 8, SSHPortAsNumber                & 0xFF } };
 mDNSexport const mDNSIPPort UnicastDNSPort         = { { UnicastDNSPortAsNumber         >> 8, UnicastDNSPortAsNumber         & 0xFF } };
 mDNSexport const mDNSIPPort SSDPPort               = { { SSDPPortAsNumber               >> 8, SSDPPortAsNumber               & 0xFF } };
+mDNSexport const mDNSIPPort IPSECPort              = { { IPSECPortAsNumber              >> 8, IPSECPortAsNumber              & 0xFF } };
 mDNSexport const mDNSIPPort NSIPCPort              = { { NSIPCPortAsNumber              >> 8, NSIPCPortAsNumber              & 0xFF } };
 mDNSexport const mDNSIPPort NATPMPAnnouncementPort = { { NATPMPAnnouncementPortAsNumber >> 8, NATPMPAnnouncementPortAsNumber & 0xFF } };
 mDNSexport const mDNSIPPort NATPMPPort             = { { NATPMPPortAsNumber             >> 8, NATPMPPortAsNumber             & 0xFF } };
index 617f919..bd02bb7 100755 (executable)
@@ -284,6 +284,13 @@ enum
        mDNSAddrType_Unknown = ~0       // Special marker value used in known answer list recording
        };
 
+enum
+       {
+       mDNSTransport_None = 0,
+       mDNSTransport_UDP  = 1,
+       mDNSTransport_TCP  = 2
+       };
+
 typedef struct
        {
        mDNSs32 type;
@@ -1774,6 +1781,7 @@ extern const mDNSIPPort   DiscardPort;
 extern const mDNSIPPort   SSHPort;
 extern const mDNSIPPort   UnicastDNSPort;
 extern const mDNSIPPort   SSDPPort;
+extern const mDNSIPPort   IPSECPort;
 extern const mDNSIPPort   NSIPCPort;
 extern const mDNSIPPort   NATPMPAnnouncementPort;
 extern const mDNSIPPort   NATPMPPort;
index d4420d5..79e7b7e 100644 (file)
@@ -4154,8 +4154,9 @@ typedef struct
 #include <IOKit/IOKitLib.h>
 #include <dns_util.h>
 
-mDNSlocal mDNSu16 GetPortArray(const mDNS *const m, domainlabel *tp, mDNSIPPort *portarray)
+mDNSlocal mDNSu16 GetPortArray(mDNS *const m, int trans, mDNSIPPort *portarray)
        {
+       const domainlabel *const tp = (trans == mDNSTransport_UDP) ? (const domainlabel *)"\x4_udp" : (const domainlabel *)"\x4_tcp";
        int count = 0;
        AuthRecord *rr;
        for (rr = m->ResourceRecords; rr; rr=rr->next)
@@ -4164,6 +4165,14 @@ mDNSlocal mDNSu16 GetPortArray(const mDNS *const m, domainlabel *tp, mDNSIPPort
                        if (portarray) portarray[count] = rr->resrec.rdata->u.srv.port;
                        count++;
                        }
+
+       // If Back to My Mac is on, also wake for packets to the IPSEC UDP port (4500)
+       if (trans == mDNSTransport_UDP && TunnelServers(m))     
+               {
+               LogSPS("GetPortArray Back to My Mac at %d", count);
+               if (portarray) portarray[count] = IPSECPort;
+               count++;
+               }
        return(count);
        }
 
@@ -4266,8 +4275,8 @@ mDNSexport mStatus ActivateLocalProxy(mDNS *const m, char *ifname)
                                        mDNSOffloadCmd cmd;
                                        mDNSPlatformMemZero(&cmd, sizeof(cmd)); // When compiling 32-bit, make sure top 32 bits of 64-bit pointers get initialized to zero
                                        cmd.command       = cmd_mDNSOffloadRR;
-                                       cmd.numUDPPorts   = GetPortArray(m, (domainlabel *)"\x4_udp", mDNSNULL);
-                                       cmd.numTCPPorts   = GetPortArray(m, (domainlabel *)"\x4_tcp", mDNSNULL);
+                                       cmd.numUDPPorts   = GetPortArray(m, mDNSTransport_UDP, mDNSNULL);
+                                       cmd.numTCPPorts   = GetPortArray(m, mDNSTransport_TCP, mDNSNULL);
                                        cmd.numRRRecords  = CountProxyRecords(m, &cmd.rrBufferSize);
                                        cmd.compression   = sizeof(DNSMessageHeader);
 
@@ -4291,8 +4300,8 @@ mDNSexport mStatus ActivateLocalProxy(mDNS *const m, char *ifname)
                                        else
                                                {
                                                GetProxyRecords(m, msg, cmd.rrBufferSize, cmd.rrRecords.ptr);
-                                               GetPortArray(m, (domainlabel *)"\x4_udp", cmd.udpPorts.ptr);
-                                               GetPortArray(m, (domainlabel *)"\x4_tcp", cmd.tcpPorts.ptr);
+                                               GetPortArray(m, mDNSTransport_UDP, cmd.udpPorts.ptr);
+                                               GetPortArray(m, mDNSTransport_TCP, cmd.tcpPorts.ptr);
                                                char outputData[2];
                                                size_t outputDataSize = sizeof(outputData);
                                                kr = IOConnectCallStructMethod(conObj, 0, &cmd, sizeof(cmd), outputData, &outputDataSize);