|
|
@ -1,6 +1,3 @@ |
|
|
|
diff --git a/.gitignore b/.gitignore
|
|
|
|
new file mode 100644 |
|
|
|
index 0000000..920cdfc
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/.gitignore
|
|
|
|
@@ -0,0 +1,4 @@
|
|
|
@ -8,8 +5,6 @@ index 0000000..920cdfc |
|
|
|
+mDNSPosix/build
|
|
|
|
+mDNSPosix/objects
|
|
|
|
+
|
|
|
|
diff --git a/mDNSPosix/PosixDaemon.c b/mDNSPosix/PosixDaemon.c
|
|
|
|
index 88b3292..e86a6c7 100644
|
|
|
|
--- a/mDNSPosix/PosixDaemon.c
|
|
|
|
+++ b/mDNSPosix/PosixDaemon.c
|
|
|
|
@@ -37,6 +37,11 @@
|
|
|
@ -75,11 +70,9 @@ index 88b3292..e86a6c7 100644 |
|
|
|
if (mStatus_NoError == err) |
|
|
|
err = MainLoop(&mDNSStorage); |
|
|
|
|
|
|
|
diff --git a/mDNSPosix/Responder.c b/mDNSPosix/Responder.c
|
|
|
|
index 3996b7b..e58d8eb 100755
|
|
|
|
--- a/mDNSPosix/Responder.c
|
|
|
|
+++ b/mDNSPosix/Responder.c
|
|
|
|
@@ -603,7 +603,8 @@ static mStatus RegisterServicesInFile(const char *filePath)
|
|
|
|
@@ -603,7 +603,8 @@ static mStatus RegisterServicesInFile(co
|
|
|
|
status = mStatus_UnknownErr; |
|
|
|
} |
|
|
|
|
|
|
@ -89,11 +82,9 @@ index 3996b7b..e58d8eb 100755 |
|
|
|
|
|
|
|
return status; |
|
|
|
} |
|
|
|
diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c
|
|
|
|
index 953bf64..4e481ea 100755
|
|
|
|
--- a/mDNSPosix/mDNSPosix.c
|
|
|
|
+++ b/mDNSPosix/mDNSPosix.c
|
|
|
|
@@ -136,7 +136,7 @@ mDNSlocal void SockAddrTomDNSAddr(const struct sockaddr *const sa, mDNSAddr *ipA
|
|
|
|
@@ -136,7 +136,7 @@ mDNSlocal void SockAddrTomDNSAddr(const
|
|
|
|
|
|
|
|
// mDNS core calls this routine when it needs to send a packet. |
|
|
|
mDNSexport mStatus mDNSPlatformSendUDP(const mDNS *const m, const void *const msg, const mDNSu8 *const end, |
|
|
@ -102,7 +93,7 @@ index 953bf64..4e481ea 100755 |
|
|
|
mDNSIPPort dstPort, mDNSBool useBackgroundTrafficClass) |
|
|
|
{ |
|
|
|
int err = 0; |
|
|
|
@@ -574,9 +574,17 @@ mDNSlocal void FreePosixNetworkInterface(PosixNetworkInterface *intf)
|
|
|
|
@@ -574,9 +574,17 @@ mDNSlocal void FreePosixNetworkInterface
|
|
|
|
{ |
|
|
|
assert(intf != NULL); |
|
|
|
if (intf->intfName != NULL) free((void *)intf->intfName); |
|
|
@ -122,7 +113,7 @@ index 953bf64..4e481ea 100755 |
|
|
|
#endif |
|
|
|
free(intf); |
|
|
|
} |
|
|
|
@@ -703,6 +711,29 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf
|
|
|
|
@@ -703,6 +711,29 @@ mDNSlocal int SetupSocket(struct sockadd
|
|
|
|
if (err < 0) { err = errno; perror("setsockopt - IP_MULTICAST_TTL"); } |
|
|
|
} |
|
|
|
|
|
|
@ -152,7 +143,7 @@ index 953bf64..4e481ea 100755 |
|
|
|
// And start listening for packets |
|
|
|
if (err == 0) |
|
|
|
{ |
|
|
|
@@ -784,6 +815,29 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf
|
|
|
|
@@ -784,6 +815,29 @@ mDNSlocal int SetupSocket(struct sockadd
|
|
|
|
if (err < 0) { err = errno; perror("setsockopt - IPV6_MULTICAST_HOPS"); } |
|
|
|
} |
|
|
|
|
|
|
@ -182,7 +173,7 @@ index 953bf64..4e481ea 100755 |
|
|
|
// And start listening for packets |
|
|
|
if (err == 0) |
|
|
|
{ |
|
|
|
@@ -815,7 +869,12 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf
|
|
|
|
@@ -815,7 +869,12 @@ mDNSlocal int SetupSocket(struct sockadd
|
|
|
|
} |
|
|
|
|
|
|
|
// Clean up |
|
|
@ -196,7 +187,7 @@ index 953bf64..4e481ea 100755 |
|
|
|
assert((err == 0) == (*sktPtr != -1)); |
|
|
|
return err; |
|
|
|
} |
|
|
|
@@ -994,7 +1053,7 @@ mDNSlocal mStatus OpenIfNotifySocket(int *pFD)
|
|
|
|
@@ -994,7 +1053,7 @@ mDNSlocal mStatus OpenIfNotifySocket(int
|
|
|
|
/* Subscribe the socket to Link & IP addr notifications. */ |
|
|
|
mDNSPlatformMemZero(&snl, sizeof snl); |
|
|
|
snl.nl_family = AF_NETLINK; |
|
|
@ -205,7 +196,7 @@ index 953bf64..4e481ea 100755 |
|
|
|
ret = bind(sock, (struct sockaddr *) &snl, sizeof snl); |
|
|
|
if (0 == ret) |
|
|
|
*pFD = sock; |
|
|
|
@@ -1072,11 +1131,18 @@ mDNSlocal mDNSu32 ProcessRoutingNotification(int sd)
|
|
|
|
@@ -1072,11 +1131,18 @@ mDNSlocal mDNSu32 ProcessRoutingNo
|
|
|
|
PrintNetLinkMsg(pNLMsg); |
|
|
|
#endif |
|
|
|
|
|
|
@ -226,7 +217,7 @@ index 953bf64..4e481ea 100755 |
|
|
|
|
|
|
|
// Advance pNLMsg to the next message in the buffer |
|
|
|
if ((pNLMsg->nlmsg_flags & NLM_F_MULTI) != 0 && pNLMsg->nlmsg_type != NLMSG_DONE) |
|
|
|
@@ -1247,8 +1313,12 @@ mDNSexport mStatus mDNSPlatformInit(mDNS *const m)
|
|
|
|
@@ -1247,8 +1313,12 @@ mDNSexport mStatus mDNSPlatformInit(mDNS
|
|
|
|
if (err == mStatus_NoError) err = SetupSocket(&sa, zeroIPPort, 0, &m->p->unicastSocket6); |
|
|
|
#endif |
|
|
|
|
|
|
@ -239,7 +230,7 @@ index 953bf64..4e481ea 100755 |
|
|
|
|
|
|
|
// Tell mDNS core about DNS Servers |
|
|
|
mDNS_Lock(m); |
|
|
|
@@ -1281,9 +1351,17 @@ mDNSexport void mDNSPlatformClose(mDNS *const m)
|
|
|
|
@@ -1281,9 +1351,17 @@ mDNSexport void mDNSPlatformClose(mDNS *
|
|
|
|
{ |
|
|
|
assert(m != NULL); |
|
|
|
ClearInterfaceList(m); |
|
|
@ -259,7 +250,7 @@ index 953bf64..4e481ea 100755 |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
@@ -1533,14 +1611,14 @@ mDNSexport mStatus mDNSPlatformClearSPSMACAddr(void)
|
|
|
|
@@ -1533,14 +1611,14 @@ mDNSexport mStatus mDNSPlatformClearS
|
|
|
|
mDNSexport mDNSu16 mDNSPlatformGetUDPPort(UDPSocket *sock) |
|
|
|
{ |
|
|
|
(void) sock; // unused |
|
|
@ -276,8 +267,6 @@ index 953bf64..4e481ea 100755 |
|
|
|
return mDNSfalse; |
|
|
|
} |
|
|
|
|
|
|
|
diff --git a/mDNSPosix/mDNSUNP.c b/mDNSPosix/mDNSUNP.c
|
|
|
|
index b392fc7..9f85e0e 100755
|
|
|
|
--- a/mDNSPosix/mDNSUNP.c
|
|
|
|
+++ b/mDNSPosix/mDNSUNP.c
|
|
|
|
@@ -61,154 +61,86 @@
|
|
|
@ -286,7 +275,9 @@ index b392fc7..9f85e0e 100755 |
|
|
|
#if defined(AF_INET6) && HAVE_IPV6 && HAVE_LINUX |
|
|
|
-#include <netdb.h>
|
|
|
|
-#include <arpa/inet.h>
|
|
|
|
-
|
|
|
|
+#include <sys/types.h>
|
|
|
|
+#include <ifaddrs.h>
|
|
|
|
|
|
|
|
-/* Converts a prefix length to IPv6 network mask */
|
|
|
|
-void plen_to_mask(int plen, char *addr) {
|
|
|
|
- int i;
|
|
|
@ -301,9 +292,6 @@ index b392fc7..9f85e0e 100755 |
|
|
|
- plen -= ones_in_block;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
+#include <sys/types.h>
|
|
|
|
+#include <ifaddrs.h>
|
|
|
|
+
|
|
|
|
|
|
|
|
-/* Gets IPv6 interface information from the /proc filesystem in linux*/
|
|
|
|
-struct ifi_info *get_ifi_info_linuxv6(int family, int doaliases)
|
|
|
@ -330,45 +318,12 @@ index b392fc7..9f85e0e 100755 |
|
|
|
- ifihead = NULL;
|
|
|
|
- ifipnext = &ifihead;
|
|
|
|
- lastname[0] = 0;
|
|
|
|
+ struct ifaddrs *ifap, *ifa;
|
|
|
|
+ struct ifi_info *ifi = NULL, *head = NULL;
|
|
|
|
|
|
|
|
-
|
|
|
|
- if ((fp = fopen(PROC_IFINET6_PATH, "r")) != NULL) {
|
|
|
|
- sockfd = socket(AF_INET6, SOCK_DGRAM, 0);
|
|
|
|
- if (sockfd < 0) {
|
|
|
|
- goto gotError;
|
|
|
|
+ /* doaliases seems always true in the calls in current code */
|
|
|
|
+ assert(doaliases);
|
|
|
|
+
|
|
|
|
+ if (getifaddrs(&ifap) < 0)
|
|
|
|
+ {
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
|
|
|
+ for (ifa = ifap ; ifa ; ifa = ifa->ifa_next)
|
|
|
|
+ {
|
|
|
|
+ /* Care only about IPv6 addresses on non-point-to-point links. */
|
|
|
|
+ if (!ifa->ifa_addr
|
|
|
|
+ || ifa->ifa_addr->sa_family != AF_INET6)
|
|
|
|
+ continue;
|
|
|
|
+ ifi = calloc(1, sizeof(*ifi));
|
|
|
|
+ if (!ifi)
|
|
|
|
+ break;
|
|
|
|
+ strncpy(ifi->ifi_name, ifa->ifa_name, IFI_NAME);
|
|
|
|
+ /* We ignore ifi_{haddr,hlen}, everyone else does too */
|
|
|
|
+ ifi->ifi_flags = ifa->ifa_flags;
|
|
|
|
+ /* We ignore ifi_myflags; IFI_ALIAS isn't used anywhere */
|
|
|
|
+ ifi->ifi_index = if_nametoindex(ifa->ifa_name);
|
|
|
|
+ if (!(ifi->ifi_addr = malloc(sizeof(struct sockaddr_in6))))
|
|
|
|
+ break;
|
|
|
|
+ memcpy(ifi->ifi_addr, ifa->ifa_addr, sizeof(struct sockaddr_in6));
|
|
|
|
+
|
|
|
|
+ if (ifa->ifa_netmask)
|
|
|
|
+ {
|
|
|
|
+ if (!(ifi->ifi_netmask = malloc(sizeof(struct sockaddr_in6))))
|
|
|
|
+ break;
|
|
|
|
+ memcpy(ifi->ifi_netmask, ifa->ifa_netmask,
|
|
|
|
+ sizeof(struct sockaddr_in6));
|
|
|
|
} |
|
|
|
- }
|
|
|
|
- while (fscanf(fp,
|
|
|
|
- "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %8s\n",
|
|
|
|
- addr[0],addr[1],addr[2],addr[3],
|
|
|
@ -386,7 +341,7 @@ index b392fc7..9f85e0e 100755 |
|
|
|
- if (ifi == NULL) {
|
|
|
|
- goto gotError;
|
|
|
|
- }
|
|
|
|
|
|
|
|
-
|
|
|
|
- ifipold = *ifipnext; /* need this later */
|
|
|
|
- ifiptr = ifipnext;
|
|
|
|
- *ifipnext = ifi; /* prev points to this new one */
|
|
|
@ -409,10 +364,7 @@ index b392fc7..9f85e0e 100755 |
|
|
|
- goto gotError;
|
|
|
|
- }
|
|
|
|
- memcpy(ifi->ifi_addr, res0->ai_addr, sizeof(struct sockaddr_in6));
|
|
|
|
+ if (!(ifi->ifi_addr = malloc(sizeof(struct sockaddr_in6))))
|
|
|
|
+ break;
|
|
|
|
+ memcpy(ifi->ifi_addr, ifa->ifa_addr, sizeof(struct sockaddr_in6));
|
|
|
|
|
|
|
|
-
|
|
|
|
- /* Add netmask of the interface */
|
|
|
|
- char ipv6addr[INET6_ADDRSTRLEN];
|
|
|
|
- plen_to_mask(plen, ipv6addr);
|
|
|
@ -460,6 +412,8 @@ index b392fc7..9f85e0e 100755 |
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- goto done;
|
|
|
|
+ struct ifaddrs *ifap, *ifa;
|
|
|
|
+ struct ifi_info *ifi = NULL, *head = NULL;
|
|
|
|
|
|
|
|
-gotError:
|
|
|
|
- if (ifihead != NULL) {
|
|
|
@ -469,10 +423,47 @@ index b392fc7..9f85e0e 100755 |
|
|
|
- if (res0 != NULL) {
|
|
|
|
- freeaddrinfo(res0);
|
|
|
|
- res0=NULL;
|
|
|
|
- }
|
|
|
|
+ /* doaliases seems always true in the calls in current code */
|
|
|
|
+ assert(doaliases);
|
|
|
|
+
|
|
|
|
+ if (getifaddrs(&ifap) < 0)
|
|
|
|
+ {
|
|
|
|
+ return NULL;
|
|
|
|
} |
|
|
|
-done:
|
|
|
|
- if (sockfd != -1) {
|
|
|
|
- assert(close(sockfd) == 0);
|
|
|
|
+ for (ifa = ifap ; ifa ; ifa = ifa->ifa_next)
|
|
|
|
+ {
|
|
|
|
+ /* Care only about IPv6 addresses on non-point-to-point links. */
|
|
|
|
+ if (!ifa->ifa_addr
|
|
|
|
+ || ifa->ifa_addr->sa_family != AF_INET6)
|
|
|
|
+ continue;
|
|
|
|
+ ifi = calloc(1, sizeof(*ifi));
|
|
|
|
+ if (!ifi)
|
|
|
|
+ break;
|
|
|
|
+ strncpy(ifi->ifi_name, ifa->ifa_name, IFI_NAME);
|
|
|
|
+ /* We ignore ifi_{haddr,hlen}, everyone else does too */
|
|
|
|
+ ifi->ifi_flags = ifa->ifa_flags;
|
|
|
|
+ /* We ignore ifi_myflags; IFI_ALIAS isn't used anywhere */
|
|
|
|
+ ifi->ifi_index = if_nametoindex(ifa->ifa_name);
|
|
|
|
+ if (!(ifi->ifi_addr = malloc(sizeof(struct sockaddr_in6))))
|
|
|
|
+ break;
|
|
|
|
+ memcpy(ifi->ifi_addr, ifa->ifa_addr, sizeof(struct sockaddr_in6));
|
|
|
|
+
|
|
|
|
+ if (ifa->ifa_netmask)
|
|
|
|
+ {
|
|
|
|
+ if (!(ifi->ifi_netmask = malloc(sizeof(struct sockaddr_in6))))
|
|
|
|
+ break;
|
|
|
|
+ memcpy(ifi->ifi_netmask, ifa->ifa_netmask,
|
|
|
|
+ sizeof(struct sockaddr_in6));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!(ifi->ifi_addr = malloc(sizeof(struct sockaddr_in6))))
|
|
|
|
+ break;
|
|
|
|
+ memcpy(ifi->ifi_addr, ifa->ifa_addr, sizeof(struct sockaddr_in6));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (ifa->ifa_flags & IFF_POINTOPOINT && ifa->ifa_dstaddr)
|
|
|
|
+ {
|
|
|
|
+ if (!(ifi->ifi_dstaddr = malloc(sizeof(struct sockaddr_in6))))
|
|
|
@ -506,7 +497,7 @@ index b392fc7..9f85e0e 100755 |
|
|
|
#endif // defined(AF_INET6) && HAVE_IPV6 && HAVE_LINUX |
|
|
|
|
|
|
|
struct ifi_info *get_ifi_info(int family, int doaliases) |
|
|
|
@@ -229,7 +161,7 @@ struct ifi_info *get_ifi_info(int family, int doaliases)
|
|
|
|
@@ -229,7 +161,7 @@ struct ifi_info *get_ifi_info(int family
|
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(AF_INET6) && HAVE_IPV6 && HAVE_LINUX |
|
|
@ -515,8 +506,6 @@ index b392fc7..9f85e0e 100755 |
|
|
|
#endif |
|
|
|
|
|
|
|
sockfd = -1; |
|
|
|
diff --git a/mDNSPosix/mDNSUNP.h b/mDNSPosix/mDNSUNP.h
|
|
|
|
index cc81b7d..e710087 100755
|
|
|
|
--- a/mDNSPosix/mDNSUNP.h
|
|
|
|
+++ b/mDNSPosix/mDNSUNP.h
|
|
|
|
@@ -97,8 +97,7 @@ struct ifi_info {
|
|
|
@ -529,8 +518,6 @@ index cc81b7d..e710087 100755 |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(AF_INET6) && HAVE_IPV6 |
|
|
|
diff --git a/mDNSShared/dnsextd_parser.y b/mDNSShared/dnsextd_parser.y
|
|
|
|
index 18c5990..d4b63ce 100644
|
|
|
|
--- a/mDNSShared/dnsextd_parser.y
|
|
|
|
+++ b/mDNSShared/dnsextd_parser.y
|
|
|
|
@@ -15,6 +15,8 @@
|
|
|
|