aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/avahi/avahi-0.6.25/disable-ipv6.patch
blob: 14c2723f010be0acfa172c29ca452f94b729eb78 (plain)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
diff -ur avahi-0.6.25.orig/avahi-core/iface.c avahi-0.6.25/avahi-core/iface.c
--- avahi-0.6.25.orig/avahi-core/iface.c	2008-12-13 08:06:15.000000000 +1030
+++ avahi-0.6.25/avahi-core/iface.c	2010-11-30 09:33:14.000000000 +1030
@@ -207,7 +207,14 @@
                    avahi_address_snprint(at, sizeof(at), &i->local_mcast_address));
 
     if (i->protocol == AVAHI_PROTO_INET6)
+#ifndef DISABLE_IPV6
         r = avahi_mdns_mcast_join_ipv6(i->monitor->server->fd_ipv6, &i->local_mcast_address.data.ipv6, i->hardware->index, join);
+#else
+    {
+	i->mcast_joined = 0;
+        return -1;
+    }
+#endif
     else {
         assert(i->protocol == AVAHI_PROTO_INET);
 
@@ -569,8 +576,10 @@
 
     if (i->protocol == AVAHI_PROTO_INET && i->monitor->server->fd_ipv4 >= 0)
         avahi_send_dns_packet_ipv4(i->monitor->server->fd_ipv4, i->hardware->index, p, i->mcast_joined ? &i->local_mcast_address.data.ipv4 : NULL, a ? &a->data.ipv4 : NULL, port);
+#ifndef DISABLE_IPV6
     else if (i->protocol == AVAHI_PROTO_INET6 && i->monitor->server->fd_ipv6 >= 0)
         avahi_send_dns_packet_ipv6(i->monitor->server->fd_ipv6, i->hardware->index, p, i->mcast_joined ? &i->local_mcast_address.data.ipv6 : NULL, a ? &a->data.ipv6 : NULL, port);
+#endif
 }
 
 void avahi_interface_send_packet(AvahiInterface *i, AvahiDnsPacket *p) {
@@ -768,6 +777,7 @@
             if ((ntohl(a->data.ipv4.address) & m) == (ntohl(ia->address.data.ipv4.address) & m))
                 return 1;
         } else {
+#ifndef DISABLE_IPV6
             unsigned j;
             unsigned char pl;
             assert(a->proto == AVAHI_PROTO_INET6);
@@ -791,6 +801,9 @@
                 if ((a->data.ipv6.address[j] & m) != (ia->address.data.ipv6.address[j] & m))
                     break;
             }
+#else
+            return 1;
+#endif
         }
     }
 
diff -ur avahi-0.6.25.orig/avahi-core/server.c avahi-0.6.25/avahi-core/server.c
--- avahi-0.6.25.orig/avahi-core/server.c	2009-04-14 10:58:56.000000000 +0930
+++ avahi-0.6.25/avahi-core/server.c	2010-11-30 09:25:29.000000000 +1030
@@ -818,8 +818,11 @@
 
             if (j->protocol == AVAHI_PROTO_INET && s->fd_legacy_unicast_ipv4 >= 0) {
                 avahi_send_dns_packet_ipv4(s->fd_legacy_unicast_ipv4, j->hardware->index, p, NULL, NULL, 0);
-            } else if (j->protocol == AVAHI_PROTO_INET6 && s->fd_legacy_unicast_ipv6 >= 0)
+            }
+#ifndef DISABLE_IPV6
+	    else if (j->protocol == AVAHI_PROTO_INET6 && s->fd_legacy_unicast_ipv6 >= 0)
                 avahi_send_dns_packet_ipv6(s->fd_legacy_unicast_ipv6, j->hardware->index, p, NULL, NULL, 0);
+#endif
         }
 
     /* Reset the id */
@@ -848,6 +851,7 @@
 
     }
 
+#ifndef DISABLE_IPV6
     if (address->proto == AVAHI_PROTO_INET6 && s->fd_legacy_unicast_ipv6 >= 0) {
         struct sockaddr_in6 lsa;
         socklen_t l = sizeof(lsa);
@@ -857,6 +861,7 @@
         else
             return avahi_port_from_sockaddr((struct sockaddr*) &lsa) == port;
     }
+#endif
 
     return 0;
 }
@@ -904,9 +909,11 @@
         return;
     }
 
+#ifndef DISABLE_IPV6
     if (avahi_address_is_ipv4_in_ipv6(src_address))
         /* This is an IPv4 address encapsulated in IPv6, so let's ignore it. */
         return;
+#endif
 
     if (originates_from_local_legacy_unicast_socket(s, src_address, port))
         /* This originates from our local reflector, so let's ignore it */
@@ -1031,11 +1038,14 @@
     if (fd == s->fd_ipv4) {
         dest.proto = src.proto = AVAHI_PROTO_INET;
         p = avahi_recv_dns_packet_ipv4(s->fd_ipv4, &src.data.ipv4, &port, &dest.data.ipv4, &iface, &ttl);
-    } else {
+    }
+#ifndef DISABLE_IPV6
+    else {
         assert(fd == s->fd_ipv6);
         dest.proto = src.proto = AVAHI_PROTO_INET6;
         p = avahi_recv_dns_packet_ipv6(s->fd_ipv6, &src.data.ipv6, &port, &dest.data.ipv6, &iface, &ttl);
     }
+#endif
 
     if (p) {
         if (iface == AVAHI_IF_UNSPEC)
@@ -1062,10 +1072,13 @@
 
     if (fd == s->fd_legacy_unicast_ipv4)
         p = avahi_recv_dns_packet_ipv4(s->fd_legacy_unicast_ipv4, NULL, NULL, NULL, NULL, NULL);
-    else {
+    else
+#ifndef DISABLE_IPV6
+    {
         assert(fd == s->fd_legacy_unicast_ipv6);
         p = avahi_recv_dns_packet_ipv6(s->fd_legacy_unicast_ipv6, NULL, NULL, NULL, NULL, NULL);
     }
+#endif
 
     if (p) {
         dispatch_legacy_unicast_packet(s, p);
@@ -1325,33 +1338,47 @@
     assert(s);
 
     s->fd_ipv4 = s->config.use_ipv4 ? avahi_open_socket_ipv4(s->config.disallow_other_stacks) : -1;
+#ifndef DISABLE_IPV6
     s->fd_ipv6 = s->config.use_ipv6 ? avahi_open_socket_ipv6(s->config.disallow_other_stacks) : -1;
+#endif
 
+#ifndef DISABLE_IPV6
     if (s->fd_ipv6 < 0 && s->fd_ipv4 < 0)
+#else
+    if (s->fd_ipv4 < 0)
+#endif
         return AVAHI_ERR_NO_NETWORK;
 
     if (s->fd_ipv4 < 0 && s->config.use_ipv4)
         avahi_log_notice("Failed to create IPv4 socket, proceeding in IPv6 only mode");
+#ifndef DISABLE_IPV6
     else if (s->fd_ipv6 < 0 && s->config.use_ipv6)
         avahi_log_notice("Failed to create IPv6 socket, proceeding in IPv4 only mode");
+#endif
 
     s->fd_legacy_unicast_ipv4 = s->fd_ipv4 >= 0 && s->config.enable_reflector ? avahi_open_unicast_socket_ipv4() : -1;
+#ifndef DISABLE_IPV6
     s->fd_legacy_unicast_ipv6 = s->fd_ipv6 >= 0 && s->config.enable_reflector ? avahi_open_unicast_socket_ipv6() : -1;
+#endif
 
-    s->watch_ipv4 =
-        s->watch_ipv6 =
-        s->watch_legacy_unicast_ipv4 =
-        s->watch_legacy_unicast_ipv6 = NULL;
+    s->watch_ipv4 = s->watch_legacy_unicast_ipv4 = NULL;
+#ifndef DISABLE_IPV6
+    s->watch_ipv6 = s->watch_legacy_unicast_ipv6 = NULL;
+#endif
 
     if (s->fd_ipv4 >= 0)
         s->watch_ipv4 = s->poll_api->watch_new(s->poll_api, s->fd_ipv4, AVAHI_WATCH_IN, mcast_socket_event, s);
+#ifndef DISABLE_IPV6
     if (s->fd_ipv6 >= 0)
         s->watch_ipv6 = s->poll_api->watch_new(s->poll_api, s->fd_ipv6, AVAHI_WATCH_IN, mcast_socket_event, s);
+#endif
 
     if (s->fd_legacy_unicast_ipv4 >= 0)
         s->watch_legacy_unicast_ipv4 = s->poll_api->watch_new(s->poll_api, s->fd_legacy_unicast_ipv4, AVAHI_WATCH_IN, legacy_unicast_socket_event, s);
+#ifndef DISABLE_IPV6
     if (s->fd_legacy_unicast_ipv6 >= 0)
         s->watch_legacy_unicast_ipv6 = s->poll_api->watch_new(s->poll_api, s->fd_legacy_unicast_ipv6, AVAHI_WATCH_IN, legacy_unicast_socket_event, s);
+#endif
 
     return 0;
 }
@@ -1499,25 +1526,33 @@
 
     if (s->watch_ipv4)
         s->poll_api->watch_free(s->watch_ipv4);
+#ifndef DISABLE_IPV6
     if (s->watch_ipv6)
         s->poll_api->watch_free(s->watch_ipv6);
+#endif
 
     if (s->watch_legacy_unicast_ipv4)
         s->poll_api->watch_free(s->watch_legacy_unicast_ipv4);
+#ifndef DISABLE_IPV6
     if (s->watch_legacy_unicast_ipv6)
         s->poll_api->watch_free(s->watch_legacy_unicast_ipv6);
+#endif
 
     /* Free sockets */
 
     if (s->fd_ipv4 >= 0)
         close(s->fd_ipv4);
+#ifndef DISABLE_IPV6
     if (s->fd_ipv6 >= 0)
         close(s->fd_ipv6);
+#endif
 
     if (s->fd_legacy_unicast_ipv4 >= 0)
         close(s->fd_legacy_unicast_ipv4);
+#ifndef DISABLE_IPV6
     if (s->fd_legacy_unicast_ipv6 >= 0)
         close(s->fd_legacy_unicast_ipv6);
+#endif
 
     /* Free other stuff */
 
@@ -1570,7 +1605,11 @@
     assert(c);
 
     memset(c, 0, sizeof(AvahiServerConfig));
+#ifndef DISABLE_IPV6
     c->use_ipv6 = 1;
+#else
+    c->use_ipv6 = 0;
+#endif
     c->use_ipv4 = 1;
     c->allow_interfaces = NULL;
     c->deny_interfaces = NULL;
@@ -1592,7 +1631,9 @@
     c->disable_publishing = 0;
     c->allow_point_to_point = 0;
     c->publish_aaaa_on_ipv4 = 1;
+#ifndef DISABLE_IPV6
     c->publish_a_on_ipv6 = 0;
+#endif
 
     return c;
 }
diff -ur avahi-0.6.25.orig/avahi-core/socket.c avahi-0.6.25/avahi-core/socket.c
--- avahi-0.6.25.orig/avahi-core/socket.c	2008-06-18 08:43:44.000000000 +0930
+++ avahi-0.6.25/avahi-core/socket.c	2010-11-29 16:55:33.000000000 +1030
@@ -142,6 +142,7 @@
     return 0;
 }
 
+#ifndef DISABLE_IPV6
 int avahi_mdns_mcast_join_ipv6(int fd, const AvahiIPv6Address *a, int idx, int join) {
     struct ipv6_mreq mreq6;
     struct sockaddr_in6 sa6;
@@ -165,6 +166,7 @@
 
     return 0;
 }
+#endif
 
 static int reuseaddr(int fd) {
     int yes;
@@ -371,6 +373,7 @@
     return -1;
 }
 
+#ifndef DISABLE_IPV6
 int avahi_open_socket_ipv6(int no_reuse) {
     struct sockaddr_in6 sa, local;
     int fd = -1, yes, r;
@@ -440,6 +443,7 @@
 
     return -1;
 }
+#endif
 
 static int sendmsg_loop(int fd, struct msghdr *msg, int flags) {
     assert(fd >= 0);
@@ -560,6 +564,7 @@
     return sendmsg_loop(fd, &msg, 0);
 }
 
+#ifndef DISABLE_IPV6
 int avahi_send_dns_packet_ipv6(
         int fd,
         AvahiIfIndex interface,
@@ -621,6 +626,7 @@
 
     return sendmsg_loop(fd, &msg, 0);
 }
+#endif
 
 AvahiDnsPacket *avahi_recv_dns_packet_ipv4(
         int fd,
@@ -775,6 +781,7 @@
     return NULL;
 }
 
+#ifndef DISABLE_IPV6
 AvahiDnsPacket *avahi_recv_dns_packet_ipv6(
         int fd,
         AvahiIPv6Address *ret_src_address,
@@ -892,6 +899,7 @@
 
     return NULL;
 }
+#endif
 
 int avahi_open_unicast_socket_ipv4(void) {
     struct sockaddr_in local;
@@ -933,6 +941,7 @@
     return -1;
 }
 
+#ifndef DISABLE_IPV6
 int avahi_open_unicast_socket_ipv6(void) {
     struct sockaddr_in6 local;
     int fd = -1, yes;
@@ -977,3 +986,4 @@
 
     return -1;
 }
+#endif
diff -ur avahi-0.6.25.orig/avahi-core/socket.h avahi-0.6.25/avahi-core/socket.h
--- avahi-0.6.25.orig/avahi-core/socket.h	2008-06-18 08:43:44.000000000 +0930
+++ avahi-0.6.25/avahi-core/socket.h	2010-11-29 16:53:25.000000000 +1030
@@ -32,18 +32,28 @@
 #define AVAHI_IPV6_MCAST_GROUP "ff02::fb"
 
 int avahi_open_socket_ipv4(int no_reuse);
+#ifndef DISABLE_IPV6
 int avahi_open_socket_ipv6(int no_reuse);
+#endif
 
 int avahi_open_unicast_socket_ipv4(void);
+#ifndef DISABLE_IPV6
 int avahi_open_unicast_socket_ipv6(void);
+#endif
 
 int avahi_send_dns_packet_ipv4(int fd, AvahiIfIndex iface, AvahiDnsPacket *p, const AvahiIPv4Address *src_address, const AvahiIPv4Address *dst_address, uint16_t dst_port);
+#ifndef DISABLE_IPV6
 int avahi_send_dns_packet_ipv6(int fd, AvahiIfIndex iface, AvahiDnsPacket *p, const AvahiIPv6Address *src_address, const AvahiIPv6Address *dst_address, uint16_t dst_port);
+#endif
 
 AvahiDnsPacket *avahi_recv_dns_packet_ipv4(int fd, AvahiIPv4Address *ret_src_address, uint16_t *ret_src_port, AvahiIPv4Address *ret_dst_address, AvahiIfIndex *ret_iface, uint8_t *ret_ttl);
+#ifndef DISABLE_IPV6
 AvahiDnsPacket *avahi_recv_dns_packet_ipv6(int fd, AvahiIPv6Address *ret_src_address, uint16_t *ret_src_port, AvahiIPv6Address *ret_dst_address, AvahiIfIndex *ret_iface, uint8_t *ret_ttl);
+#endif
 
 int avahi_mdns_mcast_join_ipv4(int fd, const AvahiIPv4Address *local_address, int iface, int join);
+#ifndef DISABLE_IPV6
 int avahi_mdns_mcast_join_ipv6(int fd, const AvahiIPv6Address *local_address, int iface, int join);
+#endif
 
 #endif
diff -ur avahi-0.6.25.orig/avahi-core/wide-area.c avahi-0.6.25/avahi-core/wide-area.c
--- avahi-0.6.25.orig/avahi-core/wide-area.c	2008-06-18 08:43:44.000000000 +0930
+++ avahi-0.6.25/avahi-core/wide-area.c	2010-11-29 17:00:46.000000000 +1030
@@ -144,12 +144,16 @@
         return avahi_send_dns_packet_ipv4(l->engine->fd_ipv4, AVAHI_IF_UNSPEC, p, NULL, &a->data.ipv4, AVAHI_DNS_PORT);
         
     } else {
+#ifndef DISABLE_IPV6
         assert(a->proto == AVAHI_PROTO_INET6);
 
         if (l->engine->fd_ipv6 < 0)
             return -1;
         
         return avahi_send_dns_packet_ipv6(l->engine->fd_ipv6, AVAHI_IF_UNSPEC, p, NULL, &a->data.ipv6, AVAHI_DNS_PORT);
+#else
+	return -1;
+#endif
     }
 }
 
@@ -559,8 +563,10 @@
     if (fd == e->fd_ipv4)
         p = avahi_recv_dns_packet_ipv4(e->fd_ipv4, NULL, NULL, NULL, NULL, NULL);
     else {
+#ifndef DISABLE_IPV6
         assert(fd == e->fd_ipv6);
         p = avahi_recv_dns_packet_ipv6(e->fd_ipv6, NULL, NULL, NULL, NULL, NULL);
+#endif
     }
 
     if (p) {
@@ -580,13 +586,21 @@
 
     /* Create sockets */
     e->fd_ipv4 = s->config.use_ipv4 ? avahi_open_unicast_socket_ipv4() : -1;
+#ifndef DISABLE_IPV6
     e->fd_ipv6 = s->config.use_ipv6 ? avahi_open_unicast_socket_ipv6() : -1;
+#endif
 
+#ifndef DISABLE_IPV6
     if (e->fd_ipv4 < 0 && e->fd_ipv6 < 0) {
+#else
+    if (e->fd_ipv4 < 0) {
+#endif
         avahi_log_error(__FILE__": Failed to create wide area sockets: %s", strerror(errno));
-
+ 
+#ifndef DISABLE_IPV6
         if (e->fd_ipv6 >= 0)
             close(e->fd_ipv6);
+#endif
 
         if (e->fd_ipv4 >= 0)
             close(e->fd_ipv4);
@@ -601,8 +615,10 @@
     
     if (e->fd_ipv4 >= 0)
         e->watch_ipv4 = s->poll_api->watch_new(e->server->poll_api, e->fd_ipv4, AVAHI_WATCH_IN, socket_event, e);
+#ifndef DISABLE_IPV6
     if (e->fd_ipv6 >= 0)
         e->watch_ipv6 = s->poll_api->watch_new(e->server->poll_api, e->fd_ipv6, AVAHI_WATCH_IN, socket_event, e);
+#endif
 
     e->n_dns_servers = e->current_dns_server = 0;
     e->next_id = (uint16_t) rand();
@@ -635,11 +651,13 @@
     if (e->watch_ipv4)
         e->server->poll_api->watch_free(e->watch_ipv4);
 
+#ifndef DISABLE_IPV6
     if (e->watch_ipv6)
         e->server->poll_api->watch_free(e->watch_ipv6);
 
     if (e->fd_ipv6 >= 0)
         close(e->fd_ipv6);
+#endif
     
     if (e->fd_ipv4 >= 0)
         close(e->fd_ipv4);
@@ -661,7 +679,11 @@
 
     if (a) {
         for (e->n_dns_servers = 0; n > 0 && e->n_dns_servers < AVAHI_WIDE_AREA_SERVERS_MAX; a++, n--) 
+#ifndef DISABLE_IPV6
             if ((a->proto == AVAHI_PROTO_INET && e->fd_ipv4 >= 0) || (a->proto == AVAHI_PROTO_INET6 && e->fd_ipv6 >= 0))
+#else
+            if (a->proto == AVAHI_PROTO_INET && e->fd_ipv4 >= 0)
+#endif
                 e->dns_servers[e->n_dns_servers++] = *a;
     } else {
         assert(n == 0);