1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
$NetBSD: patch-ab,v 1.5 2006/07/11 14:39:29 drochner Exp $
--- mDNSPosix/mDNSPosix.c.orig 2006-02-20 22:40:36.000000000 +0100
+++ mDNSPosix/mDNSPosix.c
@@ -852,7 +852,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));
@@ -861,7 +867,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));
@@ -1339,6 +1351,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)
{
@@ -1360,6 +1402,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;
|