From 3daec6014638cccfe205529f829bb6ef6e9383db Mon Sep 17 00:00:00 2001 From: Sebastien Estienne Date: Thu, 20 Oct 2005 17:43:06 +0000 Subject: [PATCH] * preliminary ipv6 support for BSD git-svn-id: file:///home/lennart/svn/public/avahi/trunk@831 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-core/iface-pfroute.c | 11 +++++++++ avahi-core/socket.c | 46 +++++++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/avahi-core/iface-pfroute.c b/avahi-core/iface-pfroute.c index 56149da..f1a1d47 100644 --- a/avahi-core/iface-pfroute.c +++ b/avahi-core/iface-pfroute.c @@ -145,7 +145,18 @@ static void rtm_addr(struct rt_msghdr *rtm, AvahiInterfaceMonitor *m) default: break; } + break; case AF_INET6: + switch (1<sin6_addr.s6_addr); + break; + case RTA_IFA: + memcpy(raddr.data.data, &((struct sockaddr_in6 *)sa)->sin6_addr, sizeof(struct in6_addr)); + raddr_valid = 1; + default: + break; + } break; default: break; diff --git a/avahi-core/socket.c b/avahi-core/socket.c index 497f061..a91a740 100644 --- a/avahi-core/socket.c +++ b/avahi-core/socket.c @@ -403,17 +403,39 @@ int avahi_open_socket_ipv6(int no_reuse) { if (r < 0) goto fail; +#ifdef IPV6_RECVHOPS + yes = 1; + if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVHOPS, &yes, sizeof(yes)) < 0) { + avahi_log_warn("IPV6_RECVHOPS failed: %s", strerror(errno)); + goto fail; + } +#elif IPV6_RECVHOPLIMIT + yes = 1; + if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &yes, sizeof(yes)) < 0) { + avahi_log_warn("IPV6_RECVHOPLIMIT failed: %s", strerror(errno)); + goto fail; + } +#elif IPV6_HOPLIMIT yes = 1; if (setsockopt(fd, IPPROTO_IPV6, IPV6_HOPLIMIT, &yes, sizeof(yes)) < 0) { avahi_log_warn("IPV6_HOPLIMIT failed: %s", strerror(errno)); goto fail; } +#endif +#ifdef IPV6_RECVPKTINFO + yes = 1; + if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &yes, sizeof(yes)) < 0) { + avahi_log_warn("IPV6_RECVPKTINFO failed: %s", strerror(errno)); + goto fail; + } +#elif IPV6_PKTINFO yes = 1; if (setsockopt(fd, IPPROTO_IPV6, IPV6_PKTINFO, &yes, sizeof(yes)) < 0) { avahi_log_warn("IPV6_PKTINFO failed: %s", strerror(errno)); goto fail; } +#endif if (avahi_set_cloexec(fd) < 0) { avahi_log_warn("FD_CLOEXEC failed: %s", strerror(errno)); @@ -679,7 +701,7 @@ AvahiDnsPacket* avahi_recv_dns_packet_ipv4(int fd, struct sockaddr_in *ret_sa, A break; #endif default: - avahi_log_warn("Unhandled cmsg_type : %d\n",cmsg->cmsg_type); + avahi_log_warn("Unhandled cmsg_type : %d",cmsg->cmsg_type); break; } } @@ -843,17 +865,39 @@ int avahi_open_unicast_socket_ipv6(void) { goto fail; } +#ifdef IPV6_RECVHOPS + yes = 1; + if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVHOPS, &yes, sizeof(yes)) < 0) { + avahi_log_warn("IPV6_RECVHOPS failed: %s", strerror(errno)); + goto fail; + } +#elif IPV6_RECVHOPLIMIT + yes = 1; + if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &yes, sizeof(yes)) < 0) { + avahi_log_warn("IPV6_RECVHOPLIMIT failed: %s", strerror(errno)); + goto fail; + } +#elif IPV6_HOPLIMIT yes = 1; if (setsockopt(fd, IPPROTO_IPV6, IPV6_HOPLIMIT, &yes, sizeof(yes)) < 0) { avahi_log_warn("IPV6_HOPLIMIT failed: %s", strerror(errno)); goto fail; } +#endif +#ifdef IPV6_RECVPKTINFO + yes = 1; + if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &yes, sizeof(yes)) < 0) { + avahi_log_warn("IPV6_RECVPKTINFO failed: %s", strerror(errno)); + goto fail; + } +#elif IPV6_PKTINFO yes = 1; if (setsockopt(fd, IPPROTO_IPV6, IPV6_PKTINFO, &yes, sizeof(yes)) < 0) { avahi_log_warn("IPV6_PKTINFO failed: %s", strerror(errno)); goto fail; } +#endif if (avahi_set_cloexec(fd) < 0) { avahi_log_warn("FD_CLOEXEC failed: %s", strerror(errno)); -- 2.39.5