|
@@ -1,6 +1,3 @@
|
1
|
|
-diff --git a/.gitignore b/.gitignore
|
2
|
|
-new file mode 100644
|
3
|
|
-index 0000000..920cdfc
|
4
|
1
|
--- /dev/null
|
5
|
2
|
+++ b/.gitignore
|
6
|
3
|
@@ -0,0 +1,4 @@
|
|
@@ -8,8 +5,6 @@ index 0000000..920cdfc
|
8
|
5
|
+mDNSPosix/build
|
9
|
6
|
+mDNSPosix/objects
|
10
|
7
|
+
|
11
|
|
-diff --git a/mDNSPosix/PosixDaemon.c b/mDNSPosix/PosixDaemon.c
|
12
|
|
-index 88b3292..e86a6c7 100644
|
13
|
8
|
--- a/mDNSPosix/PosixDaemon.c
|
14
|
9
|
+++ b/mDNSPosix/PosixDaemon.c
|
15
|
10
|
@@ -37,6 +37,11 @@
|
|
@@ -75,11 +70,9 @@ index 88b3292..e86a6c7 100644
|
75
|
70
|
if (mStatus_NoError == err)
|
76
|
71
|
err = MainLoop(&mDNSStorage);
|
77
|
72
|
|
78
|
|
-diff --git a/mDNSPosix/Responder.c b/mDNSPosix/Responder.c
|
79
|
|
-index 3996b7b..e58d8eb 100755
|
80
|
73
|
--- a/mDNSPosix/Responder.c
|
81
|
74
|
+++ b/mDNSPosix/Responder.c
|
82
|
|
-@@ -603,7 +603,8 @@ static mStatus RegisterServicesInFile(const char *filePath)
|
|
75
|
+@@ -603,7 +603,8 @@ static mStatus RegisterServicesInFile(co
|
83
|
76
|
status = mStatus_UnknownErr;
|
84
|
77
|
}
|
85
|
78
|
|
|
@@ -89,11 +82,9 @@ index 3996b7b..e58d8eb 100755
|
89
|
82
|
|
90
|
83
|
return status;
|
91
|
84
|
}
|
92
|
|
-diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c
|
93
|
|
-index 953bf64..4e481ea 100755
|
94
|
85
|
--- a/mDNSPosix/mDNSPosix.c
|
95
|
86
|
+++ b/mDNSPosix/mDNSPosix.c
|
96
|
|
-@@ -136,7 +136,7 @@ mDNSlocal void SockAddrTomDNSAddr(const struct sockaddr *const sa, mDNSAddr *ipA
|
|
87
|
+@@ -136,7 +136,7 @@ mDNSlocal void SockAddrTomDNSAddr(const
|
97
|
88
|
|
98
|
89
|
// mDNS core calls this routine when it needs to send a packet.
|
99
|
90
|
mDNSexport mStatus mDNSPlatformSendUDP(const mDNS *const m, const void *const msg, const mDNSu8 *const end,
|
|
@@ -102,7 +93,7 @@ index 953bf64..4e481ea 100755
|
102
|
93
|
mDNSIPPort dstPort, mDNSBool useBackgroundTrafficClass)
|
103
|
94
|
{
|
104
|
95
|
int err = 0;
|
105
|
|
-@@ -574,9 +574,17 @@ mDNSlocal void FreePosixNetworkInterface(PosixNetworkInterface *intf)
|
|
96
|
+@@ -574,9 +574,17 @@ mDNSlocal void FreePosixNetworkInterface
|
106
|
97
|
{
|
107
|
98
|
assert(intf != NULL);
|
108
|
99
|
if (intf->intfName != NULL) free((void *)intf->intfName);
|
|
@@ -122,7 +113,7 @@ index 953bf64..4e481ea 100755
|
122
|
113
|
#endif
|
123
|
114
|
free(intf);
|
124
|
115
|
}
|
125
|
|
-@@ -703,6 +711,29 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf
|
|
116
|
+@@ -703,6 +711,29 @@ mDNSlocal int SetupSocket(struct sockadd
|
126
|
117
|
if (err < 0) { err = errno; perror("setsockopt - IP_MULTICAST_TTL"); }
|
127
|
118
|
}
|
128
|
119
|
|
|
@@ -152,7 +143,7 @@ index 953bf64..4e481ea 100755
|
152
|
143
|
// And start listening for packets
|
153
|
144
|
if (err == 0)
|
154
|
145
|
{
|
155
|
|
-@@ -784,6 +815,29 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf
|
|
146
|
+@@ -784,6 +815,29 @@ mDNSlocal int SetupSocket(struct sockadd
|
156
|
147
|
if (err < 0) { err = errno; perror("setsockopt - IPV6_MULTICAST_HOPS"); }
|
157
|
148
|
}
|
158
|
149
|
|
|
@@ -182,7 +173,7 @@ index 953bf64..4e481ea 100755
|
182
|
173
|
// And start listening for packets
|
183
|
174
|
if (err == 0)
|
184
|
175
|
{
|
185
|
|
-@@ -815,7 +869,12 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf
|
|
176
|
+@@ -815,7 +869,12 @@ mDNSlocal int SetupSocket(struct sockadd
|
186
|
177
|
}
|
187
|
178
|
|
188
|
179
|
// Clean up
|
|
@@ -196,7 +187,7 @@ index 953bf64..4e481ea 100755
|
196
|
187
|
assert((err == 0) == (*sktPtr != -1));
|
197
|
188
|
return err;
|
198
|
189
|
}
|
199
|
|
-@@ -994,7 +1053,7 @@ mDNSlocal mStatus OpenIfNotifySocket(int *pFD)
|
|
190
|
+@@ -994,7 +1053,7 @@ mDNSlocal mStatus OpenIfNotifySocket(int
|
200
|
191
|
/* Subscribe the socket to Link & IP addr notifications. */
|
201
|
192
|
mDNSPlatformMemZero(&snl, sizeof snl);
|
202
|
193
|
snl.nl_family = AF_NETLINK;
|
|
@@ -205,7 +196,7 @@ index 953bf64..4e481ea 100755
|
205
|
196
|
ret = bind(sock, (struct sockaddr *) &snl, sizeof snl);
|
206
|
197
|
if (0 == ret)
|
207
|
198
|
*pFD = sock;
|
208
|
|
-@@ -1072,11 +1131,18 @@ mDNSlocal mDNSu32 ProcessRoutingNotification(int sd)
|
|
199
|
+@@ -1072,11 +1131,18 @@ mDNSlocal mDNSu32 ProcessRoutingNo
|
209
|
200
|
PrintNetLinkMsg(pNLMsg);
|
210
|
201
|
#endif
|
211
|
202
|
|
|
@@ -226,7 +217,7 @@ index 953bf64..4e481ea 100755
|
226
|
217
|
|
227
|
218
|
// Advance pNLMsg to the next message in the buffer
|
228
|
219
|
if ((pNLMsg->nlmsg_flags & NLM_F_MULTI) != 0 && pNLMsg->nlmsg_type != NLMSG_DONE)
|
229
|
|
-@@ -1247,8 +1313,12 @@ mDNSexport mStatus mDNSPlatformInit(mDNS *const m)
|
|
220
|
+@@ -1247,8 +1313,12 @@ mDNSexport mStatus mDNSPlatformInit(mDNS
|
230
|
221
|
if (err == mStatus_NoError) err = SetupSocket(&sa, zeroIPPort, 0, &m->p->unicastSocket6);
|
231
|
222
|
#endif
|
232
|
223
|
|
|
@@ -239,7 +230,7 @@ index 953bf64..4e481ea 100755
|
239
|
230
|
|
240
|
231
|
// Tell mDNS core about DNS Servers
|
241
|
232
|
mDNS_Lock(m);
|
242
|
|
-@@ -1281,9 +1351,17 @@ mDNSexport void mDNSPlatformClose(mDNS *const m)
|
|
233
|
+@@ -1281,9 +1351,17 @@ mDNSexport void mDNSPlatformClose(mDNS *
|
243
|
234
|
{
|
244
|
235
|
assert(m != NULL);
|
245
|
236
|
ClearInterfaceList(m);
|
|
@@ -259,7 +250,7 @@ index 953bf64..4e481ea 100755
|
259
|
250
|
#endif
|
260
|
251
|
}
|
261
|
252
|
|
262
|
|
-@@ -1533,14 +1611,14 @@ mDNSexport mStatus mDNSPlatformClearSPSMACAddr(void)
|
|
253
|
+@@ -1533,14 +1611,14 @@ mDNSexport mStatus mDNSPlatformClearS
|
263
|
254
|
mDNSexport mDNSu16 mDNSPlatformGetUDPPort(UDPSocket *sock)
|
264
|
255
|
{
|
265
|
256
|
(void) sock; // unused
|
|
@@ -276,8 +267,6 @@ index 953bf64..4e481ea 100755
|
276
|
267
|
return mDNSfalse;
|
277
|
268
|
}
|
278
|
269
|
|
279
|
|
-diff --git a/mDNSPosix/mDNSUNP.c b/mDNSPosix/mDNSUNP.c
|
280
|
|
-index b392fc7..9f85e0e 100755
|
281
|
270
|
--- a/mDNSPosix/mDNSUNP.c
|
282
|
271
|
+++ b/mDNSPosix/mDNSUNP.c
|
283
|
272
|
@@ -61,154 +61,86 @@
|
|
@@ -286,7 +275,9 @@ index b392fc7..9f85e0e 100755
|
286
|
275
|
#if defined(AF_INET6) && HAVE_IPV6 && HAVE_LINUX
|
287
|
276
|
-#include <netdb.h>
|
288
|
277
|
-#include <arpa/inet.h>
|
289
|
|
--
|
|
278
|
++#include <sys/types.h>
|
|
279
|
++#include <ifaddrs.h>
|
|
280
|
+
|
290
|
281
|
-/* Converts a prefix length to IPv6 network mask */
|
291
|
282
|
-void plen_to_mask(int plen, char *addr) {
|
292
|
283
|
- int i;
|
|
@@ -301,9 +292,6 @@ index b392fc7..9f85e0e 100755
|
301
|
292
|
- plen -= ones_in_block;
|
302
|
293
|
- }
|
303
|
294
|
-}
|
304
|
|
-+#include <sys/types.h>
|
305
|
|
-+#include <ifaddrs.h>
|
306
|
|
-+
|
307
|
295
|
|
308
|
296
|
-/* Gets IPv6 interface information from the /proc filesystem in linux*/
|
309
|
297
|
-struct ifi_info *get_ifi_info_linuxv6(int family, int doaliases)
|
|
@@ -330,45 +318,12 @@ index b392fc7..9f85e0e 100755
|
330
|
318
|
- ifihead = NULL;
|
331
|
319
|
- ifipnext = &ifihead;
|
332
|
320
|
- lastname[0] = 0;
|
333
|
|
-+ struct ifaddrs *ifap, *ifa;
|
334
|
|
-+ struct ifi_info *ifi = NULL, *head = NULL;
|
335
|
|
-
|
|
321
|
+-
|
336
|
322
|
- if ((fp = fopen(PROC_IFINET6_PATH, "r")) != NULL) {
|
337
|
323
|
- sockfd = socket(AF_INET6, SOCK_DGRAM, 0);
|
338
|
324
|
- if (sockfd < 0) {
|
339
|
325
|
- goto gotError;
|
340
|
|
-+ /* doaliases seems always true in the calls in current code */
|
341
|
|
-+ assert(doaliases);
|
342
|
|
-+
|
343
|
|
-+ if (getifaddrs(&ifap) < 0)
|
344
|
|
-+ {
|
345
|
|
-+ return NULL;
|
346
|
|
-+ }
|
347
|
|
-+ for (ifa = ifap ; ifa ; ifa = ifa->ifa_next)
|
348
|
|
-+ {
|
349
|
|
-+ /* Care only about IPv6 addresses on non-point-to-point links. */
|
350
|
|
-+ if (!ifa->ifa_addr
|
351
|
|
-+ || ifa->ifa_addr->sa_family != AF_INET6)
|
352
|
|
-+ continue;
|
353
|
|
-+ ifi = calloc(1, sizeof(*ifi));
|
354
|
|
-+ if (!ifi)
|
355
|
|
-+ break;
|
356
|
|
-+ strncpy(ifi->ifi_name, ifa->ifa_name, IFI_NAME);
|
357
|
|
-+ /* We ignore ifi_{haddr,hlen}, everyone else does too */
|
358
|
|
-+ ifi->ifi_flags = ifa->ifa_flags;
|
359
|
|
-+ /* We ignore ifi_myflags; IFI_ALIAS isn't used anywhere */
|
360
|
|
-+ ifi->ifi_index = if_nametoindex(ifa->ifa_name);
|
361
|
|
-+ if (!(ifi->ifi_addr = malloc(sizeof(struct sockaddr_in6))))
|
362
|
|
-+ break;
|
363
|
|
-+ memcpy(ifi->ifi_addr, ifa->ifa_addr, sizeof(struct sockaddr_in6));
|
364
|
|
-+
|
365
|
|
-+ if (ifa->ifa_netmask)
|
366
|
|
-+ {
|
367
|
|
-+ if (!(ifi->ifi_netmask = malloc(sizeof(struct sockaddr_in6))))
|
368
|
|
-+ break;
|
369
|
|
-+ memcpy(ifi->ifi_netmask, ifa->ifa_netmask,
|
370
|
|
-+ sizeof(struct sockaddr_in6));
|
371
|
|
- }
|
|
326
|
+- }
|
372
|
327
|
- while (fscanf(fp,
|
373
|
328
|
- "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %8s\n",
|
374
|
329
|
- addr[0],addr[1],addr[2],addr[3],
|
|
@@ -386,7 +341,7 @@ index b392fc7..9f85e0e 100755
|
386
|
341
|
- if (ifi == NULL) {
|
387
|
342
|
- goto gotError;
|
388
|
343
|
- }
|
389
|
|
-
|
|
344
|
+-
|
390
|
345
|
- ifipold = *ifipnext; /* need this later */
|
391
|
346
|
- ifiptr = ifipnext;
|
392
|
347
|
- *ifipnext = ifi; /* prev points to this new one */
|
|
@@ -409,10 +364,7 @@ index b392fc7..9f85e0e 100755
|
409
|
364
|
- goto gotError;
|
410
|
365
|
- }
|
411
|
366
|
- memcpy(ifi->ifi_addr, res0->ai_addr, sizeof(struct sockaddr_in6));
|
412
|
|
-+ if (!(ifi->ifi_addr = malloc(sizeof(struct sockaddr_in6))))
|
413
|
|
-+ break;
|
414
|
|
-+ memcpy(ifi->ifi_addr, ifa->ifa_addr, sizeof(struct sockaddr_in6));
|
415
|
|
-
|
|
367
|
+-
|
416
|
368
|
- /* Add netmask of the interface */
|
417
|
369
|
- char ipv6addr[INET6_ADDRSTRLEN];
|
418
|
370
|
- plen_to_mask(plen, ipv6addr);
|
|
@@ -460,6 +412,8 @@ index b392fc7..9f85e0e 100755
|
460
|
412
|
- }
|
461
|
413
|
- }
|
462
|
414
|
- goto done;
|
|
415
|
++ struct ifaddrs *ifap, *ifa;
|
|
416
|
++ struct ifi_info *ifi = NULL, *head = NULL;
|
463
|
417
|
|
464
|
418
|
-gotError:
|
465
|
419
|
- if (ifihead != NULL) {
|
|
@@ -469,10 +423,47 @@ index b392fc7..9f85e0e 100755
|
469
|
423
|
- if (res0 != NULL) {
|
470
|
424
|
- freeaddrinfo(res0);
|
471
|
425
|
- res0=NULL;
|
472
|
|
-- }
|
|
426
|
++ /* doaliases seems always true in the calls in current code */
|
|
427
|
++ assert(doaliases);
|
|
428
|
++
|
|
429
|
++ if (getifaddrs(&ifap) < 0)
|
|
430
|
++ {
|
|
431
|
++ return NULL;
|
|
432
|
+ }
|
473
|
433
|
-done:
|
474
|
434
|
- if (sockfd != -1) {
|
475
|
435
|
- assert(close(sockfd) == 0);
|
|
436
|
++ for (ifa = ifap ; ifa ; ifa = ifa->ifa_next)
|
|
437
|
++ {
|
|
438
|
++ /* Care only about IPv6 addresses on non-point-to-point links. */
|
|
439
|
++ if (!ifa->ifa_addr
|
|
440
|
++ || ifa->ifa_addr->sa_family != AF_INET6)
|
|
441
|
++ continue;
|
|
442
|
++ ifi = calloc(1, sizeof(*ifi));
|
|
443
|
++ if (!ifi)
|
|
444
|
++ break;
|
|
445
|
++ strncpy(ifi->ifi_name, ifa->ifa_name, IFI_NAME);
|
|
446
|
++ /* We ignore ifi_{haddr,hlen}, everyone else does too */
|
|
447
|
++ ifi->ifi_flags = ifa->ifa_flags;
|
|
448
|
++ /* We ignore ifi_myflags; IFI_ALIAS isn't used anywhere */
|
|
449
|
++ ifi->ifi_index = if_nametoindex(ifa->ifa_name);
|
|
450
|
++ if (!(ifi->ifi_addr = malloc(sizeof(struct sockaddr_in6))))
|
|
451
|
++ break;
|
|
452
|
++ memcpy(ifi->ifi_addr, ifa->ifa_addr, sizeof(struct sockaddr_in6));
|
|
453
|
++
|
|
454
|
++ if (ifa->ifa_netmask)
|
|
455
|
++ {
|
|
456
|
++ if (!(ifi->ifi_netmask = malloc(sizeof(struct sockaddr_in6))))
|
|
457
|
++ break;
|
|
458
|
++ memcpy(ifi->ifi_netmask, ifa->ifa_netmask,
|
|
459
|
++ sizeof(struct sockaddr_in6));
|
|
460
|
++ }
|
|
461
|
++
|
|
462
|
++ if (!(ifi->ifi_addr = malloc(sizeof(struct sockaddr_in6))))
|
|
463
|
++ break;
|
|
464
|
++ memcpy(ifi->ifi_addr, ifa->ifa_addr, sizeof(struct sockaddr_in6));
|
|
465
|
++
|
|
466
|
++
|
476
|
467
|
+ if (ifa->ifa_flags & IFF_POINTOPOINT && ifa->ifa_dstaddr)
|
477
|
468
|
+ {
|
478
|
469
|
+ if (!(ifi->ifi_dstaddr = malloc(sizeof(struct sockaddr_in6))))
|
|
@@ -506,7 +497,7 @@ index b392fc7..9f85e0e 100755
|
506
|
497
|
#endif // defined(AF_INET6) && HAVE_IPV6 && HAVE_LINUX
|
507
|
498
|
|
508
|
499
|
struct ifi_info *get_ifi_info(int family, int doaliases)
|
509
|
|
-@@ -229,7 +161,7 @@ struct ifi_info *get_ifi_info(int family, int doaliases)
|
|
500
|
+@@ -229,7 +161,7 @@ struct ifi_info *get_ifi_info(int family
|
510
|
501
|
#endif
|
511
|
502
|
|
512
|
503
|
#if defined(AF_INET6) && HAVE_IPV6 && HAVE_LINUX
|
|
@@ -515,8 +506,6 @@ index b392fc7..9f85e0e 100755
|
515
|
506
|
#endif
|
516
|
507
|
|
517
|
508
|
sockfd = -1;
|
518
|
|
-diff --git a/mDNSPosix/mDNSUNP.h b/mDNSPosix/mDNSUNP.h
|
519
|
|
-index cc81b7d..e710087 100755
|
520
|
509
|
--- a/mDNSPosix/mDNSUNP.h
|
521
|
510
|
+++ b/mDNSPosix/mDNSUNP.h
|
522
|
511
|
@@ -97,8 +97,7 @@ struct ifi_info {
|
|
@@ -529,8 +518,6 @@ index cc81b7d..e710087 100755
|
529
|
518
|
#endif
|
530
|
519
|
|
531
|
520
|
#if defined(AF_INET6) && HAVE_IPV6
|
532
|
|
-diff --git a/mDNSShared/dnsextd_parser.y b/mDNSShared/dnsextd_parser.y
|
533
|
|
-index 18c5990..d4b63ce 100644
|
534
|
521
|
--- a/mDNSShared/dnsextd_parser.y
|
535
|
522
|
+++ b/mDNSShared/dnsextd_parser.y
|
536
|
523
|
@@ -15,6 +15,8 @@
|