avahi-optional-ipv6.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. [PATCH] avahi-core: make ipv6 support optional on uclibc 0.9.31+
  2. uClibc 0.9.31+ doesn't define the IPV6_* defines when IPv6 support isn't
  3. enabled, causing the avahi build to break. Detect this configuration, and
  4. comment out IPv6 code if so.
  5. Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
  6. ---
  7. avahi-core/socket.c | 28 +++++++++++++++++++++++-----
  8. 1 file changed, 23 insertions(+), 5 deletions(-)
  9. Index: avahi-0.6.23/avahi-core/socket.c
  10. ===================================================================
  11. --- avahi-0.6.23.orig/avahi-core/socket.c
  12. +++ avahi-0.6.23/avahi-core/socket.c
  13. @@ -47,6 +47,11 @@
  14. #include <net/if_dl.h>
  15. #endif
  16. +#include <features.h>
  17. +#if defined(__UCLIBC__) && !defined (__UCLIBC_HAS_IPV6__)
  18. +#define NO_IPV6
  19. +#endif
  20. +
  21. #include "dns.h"
  22. #include "fdutil.h"
  23. #include "socket.h"
  24. @@ -75,6 +80,7 @@ static void mdns_mcast_group_ipv4(struct
  25. inet_pton(AF_INET, AVAHI_IPV4_MCAST_GROUP, &ret_sa->sin_addr);
  26. }
  27. +#ifndef NO_IPV6
  28. static void mdns_mcast_group_ipv6(struct sockaddr_in6 *ret_sa) {
  29. assert(ret_sa);
  30. @@ -83,6 +89,7 @@ static void mdns_mcast_group_ipv6(struct
  31. ret_sa->sin6_port = htons(AVAHI_MDNS_PORT);
  32. inet_pton(AF_INET6, AVAHI_IPV6_MCAST_GROUP, &ret_sa->sin6_addr);
  33. }
  34. +#endif
  35. static void ipv4_address_to_sockaddr(struct sockaddr_in *ret_sa, const AvahiIPv4Address *a, uint16_t port) {
  36. assert(ret_sa);
  37. @@ -95,6 +102,7 @@ static void ipv4_address_to_sockaddr(str
  38. memcpy(&ret_sa->sin_addr, a, sizeof(AvahiIPv4Address));
  39. }
  40. +#ifndef NO_IPV6
  41. static void ipv6_address_to_sockaddr(struct sockaddr_in6 *ret_sa, const AvahiIPv6Address *a, uint16_t port) {
  42. assert(ret_sa);
  43. assert(a);
  44. @@ -105,6 +113,7 @@ static void ipv6_address_to_sockaddr(str
  45. ret_sa->sin6_port = htons(port);
  46. memcpy(&ret_sa->sin6_addr, a, sizeof(AvahiIPv6Address));
  47. }
  48. +#endif
  49. int avahi_mdns_mcast_join_ipv4(int fd, const AvahiIPv4Address *a, int idx, int join) {
  50. #ifdef HAVE_STRUCT_IP_MREQN
  51. @@ -143,6 +152,7 @@ int avahi_mdns_mcast_join_ipv4(int fd, c
  52. }
  53. int avahi_mdns_mcast_join_ipv6(int fd, const AvahiIPv6Address *a, int idx, int join) {
  54. +#ifndef NO_IPV6
  55. struct ipv6_mreq mreq6;
  56. struct sockaddr_in6 sa6;
  57. @@ -164,6 +174,9 @@ int avahi_mdns_mcast_join_ipv6(int fd, c
  58. }
  59. return 0;
  60. +#else
  61. + return -1;
  62. +#endif
  63. }
  64. static int reuseaddr(int fd) {
  65. @@ -372,6 +385,7 @@ fail:
  66. }
  67. int avahi_open_socket_ipv6(int no_reuse) {
  68. +#ifndef NO_IPV6
  69. struct sockaddr_in6 sa, local;
  70. int fd = -1, yes, r;
  71. int ttl;
  72. @@ -437,7 +451,7 @@ int avahi_open_socket_ipv6(int no_reuse)
  73. fail:
  74. if (fd >= 0)
  75. close(fd);
  76. -
  77. +#endif
  78. return -1;
  79. }
  80. @@ -567,7 +581,7 @@ int avahi_send_dns_packet_ipv6(
  81. const AvahiIPv6Address *src_address,
  82. const AvahiIPv6Address *dst_address,
  83. uint16_t dst_port) {
  84. -
  85. +#ifndef NO_IPV6
  86. struct sockaddr_in6 sa;
  87. struct msghdr msg;
  88. struct iovec io;
  89. @@ -620,6 +634,9 @@ int avahi_send_dns_packet_ipv6(
  90. }
  91. return sendmsg_loop(fd, &msg, 0);
  92. +#else
  93. + return -1;
  94. +#endif
  95. }
  96. AvahiDnsPacket *avahi_recv_dns_packet_ipv4(
  97. @@ -782,7 +799,7 @@ AvahiDnsPacket *avahi_recv_dns_packet_ip
  98. AvahiIPv6Address *ret_dst_address,
  99. AvahiIfIndex *ret_iface,
  100. uint8_t *ret_ttl) {
  101. -
  102. +#ifndef NO_IPV6
  103. AvahiDnsPacket *p = NULL;
  104. struct msghdr msg;
  105. struct iovec io;
  106. @@ -889,7 +906,7 @@ AvahiDnsPacket *avahi_recv_dns_packet_ip
  107. fail:
  108. if (p)
  109. avahi_dns_packet_free(p);
  110. -
  111. +#endif
  112. return NULL;
  113. }
  114. @@ -934,6 +951,7 @@ fail:
  115. }
  116. int avahi_open_unicast_socket_ipv6(void) {
  117. +#ifndef NO_IPV6
  118. struct sockaddr_in6 local;
  119. int fd = -1, yes;
  120. @@ -974,6 +992,6 @@ int avahi_open_unicast_socket_ipv6(void)
  121. fail:
  122. if (fd >= 0)
  123. close(fd);
  124. -
  125. +#endif
  126. return -1;
  127. }