116 lines
3.6 KiB
Text
116 lines
3.6 KiB
Text
$NetBSD: patch-ab,v 1.9 2014/05/12 15:06:56 ryoon Exp $
|
|
|
|
1) From http://lists.apple.com/archives/bonjour-dev/2007/Jan/msg00003.html
|
|
|
|
2) add patch from http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/147007
|
|
|
|
-enable ipv6
|
|
-fix some RFC2292 vs 3542 confusion which made the former fail
|
|
-on NetBSD, build a HINFO record from hw.model and kern.osrelease
|
|
|
|
--- mDNSPosix/mDNSPosix.c.orig 2010-05-20 22:35:08.000000000 +0000
|
|
+++ mDNSPosix/mDNSPosix.c
|
|
@@ -256,7 +256,7 @@ mDNSlocal void SocketDataReady(mDNS *con
|
|
// so all we can do is just assume it's a multicast
|
|
|
|
#if HAVE_BROKEN_RECVDSTADDR || (!defined(IP_PKTINFO) && !defined(IP_RECVDSTADDR))
|
|
- if ((destAddr.NotAnInteger == 0) && (flags & MSG_MCAST))
|
|
+ if ((destAddr.ip.v4.NotAnInteger == 0) && (flags & MSG_MCAST))
|
|
{
|
|
destAddr.type = senderAddr.type;
|
|
if (senderAddr.type == mDNSAddrType_IPv4) destAddr.ip.v4 = AllDNSLinkGroup_v4.ip.v4;
|
|
@@ -467,7 +467,7 @@ mDNSexport int ParseDNSServers(mDNS *m,
|
|
{
|
|
char line[256];
|
|
char nameserver[16];
|
|
- char keyword[10];
|
|
+ char keyword[11];
|
|
int numOfServers = 0;
|
|
FILE *fp = fopen(filePath, "r");
|
|
if (fp == NULL) return -1;
|
|
@@ -486,6 +486,7 @@ mDNSexport int ParseDNSServers(mDNS *m,
|
|
numOfServers++;
|
|
}
|
|
}
|
|
+ fclose(fp);
|
|
return (numOfServers > 0) ? 0 : -1;
|
|
}
|
|
|
|
@@ -690,7 +691,13 @@ mDNSlocal int SetupSocket(struct sockadd
|
|
{
|
|
struct ipv6_mreq imr6;
|
|
struct sockaddr_in6 bindAddr6;
|
|
- #if defined(IPV6_PKTINFO)
|
|
+ #if defined(IPV6_RECVPKTINFO)
|
|
+ if (err == 0)
|
|
+ {
|
|
+ err = setsockopt(*sktPtr, IPPROTO_IPV6, IPV6_RECVPKTINFO, &kOn, sizeof(kOn));
|
|
+ if (err < 0) { err = errno; perror("setsockopt - IPV6_RECVPKTINFO"); }
|
|
+ }
|
|
+#elif defined(IPV6_PKTINFO)
|
|
if (err == 0)
|
|
{
|
|
err = setsockopt(*sktPtr, IPPROTO_IPV6, IPV6_PKTINFO, &kOn, sizeof(kOn));
|
|
@@ -699,7 +706,13 @@ mDNSlocal int SetupSocket(struct sockadd
|
|
#else
|
|
#warning This platform has no way to get the destination interface information for IPv6 -- will only work for single-homed hosts
|
|
#endif
|
|
- #if defined(IPV6_HOPLIMIT)
|
|
+ #if defined(IPV6_RECVHOPLIMIT)
|
|
+ if (err == 0)
|
|
+ {
|
|
+ err = setsockopt(*sktPtr, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &kOn, sizeof(kOn));
|
|
+ if (err < 0) { err = errno; perror("setsockopt - IPV6_RECVHOPLIMIT"); }
|
|
+ }
|
|
+ #elif defined(IPV6_HOPLIMIT)
|
|
if (err == 0)
|
|
{
|
|
err = setsockopt(*sktPtr, IPPROTO_IPV6, IPV6_HOPLIMIT, &kOn, sizeof(kOn));
|
|
@@ -1181,6 +1194,36 @@ mDNSlocal mDNSBool mDNSPlatformInit_CanR
|
|
return(err == 0);
|
|
}
|
|
|
|
+#ifdef __NetBSD__
|
|
+#include <sys/param.h>
|
|
+#include <sys/sysctl.h>
|
|
+
|
|
+void
|
|
+initmachinedescr(mDNS *const m)
|
|
+{
|
|
+ char hwbuf[256], swbuf[256];
|
|
+ size_t hwlen, swlen;
|
|
+ const int hwmib[] = { CTL_HW, HW_MODEL };
|
|
+ const int swmib[] = { CTL_KERN, KERN_OSRELEASE };
|
|
+ const char netbsd[] = "NetBSD ";
|
|
+
|
|
+ hwlen = sizeof(hwbuf);
|
|
+ swlen = sizeof(swbuf);
|
|
+ if (sysctl(hwmib, 2, hwbuf, &hwlen, 0, 0) ||
|
|
+ sysctl(swmib, 2, swbuf, &swlen, 0, 0))
|
|
+ return;
|
|
+
|
|
+ if (hwlen + swlen + sizeof(netbsd) >=254)
|
|
+ return;
|
|
+
|
|
+ m->HIHardware.c[0] = hwlen - 1;
|
|
+ m->HISoftware.c[0] = swlen + sizeof(netbsd) - 2;
|
|
+ memcpy(&m->HIHardware.c[1], hwbuf, hwlen - 1);
|
|
+ memcpy(&m->HISoftware.c[1], netbsd, sizeof(netbsd) - 1);
|
|
+ memcpy(&m->HISoftware.c[1 + sizeof(netbsd) - 1], swbuf, swlen - 1);
|
|
+}
|
|
+#endif
|
|
+
|
|
// mDNS core calls this routine to initialise the platform-specific data.
|
|
mDNSexport mStatus mDNSPlatformInit(mDNS *const m)
|
|
{
|
|
@@ -1202,6 +1245,10 @@ mDNSexport mStatus mDNSPlatformInit(mDNS
|
|
GetUserSpecifiedRFC1034ComputerName(&m->hostlabel);
|
|
if (m->hostlabel.c[0] == 0) MakeDomainLabelFromLiteralString(&m->hostlabel, "Computer");
|
|
|
|
+#ifdef __NetBSD__
|
|
+ initmachinedescr(m);
|
|
+#endif
|
|
+
|
|
mDNS_SetFQDN(m);
|
|
|
|
sa.sa_family = AF_INET;
|