Hi, I was reading through the ip6(4) manpage and I thought it'd be a cute idea to put the example code into my dns daemon. So I took my latest source found at
http://wildcarddns.cvs.sourceforge.net/wildcarddns/ and applied this patch: --- main.c.orig Sun Jun 10 17:13:31 2012 +++ main.c Sun Jun 10 17:13:34 2012 @@ -453,8 +453,13 @@ #endif syslog(LOG_INFO, "setsockopt: %m"); } + } else if (res->ai_family == AF_INET6) { + if (setsockopt(udp[i], IPPROTO_IPV6, + IPV6_HOPLIMIT, &on, sizeof(on)) < 0) { + syslog(LOG_INFO, "setsockopt: %m"); + } } - + ident[i] = bind_list[i]; /* tcp below */ @@ -611,8 +616,15 @@ #endif syslog(LOG_INFO, "setsockopt: %m"); } + } else if (pifap->ifa_addr->sa_family == AF_INET6) { + on = 1; + if (setsockopt(udp[i], IPPROTO_IPV6, + IPV6_HOPLIMIT, &on, sizeof(on)) < 0) { + syslog(LOG_INFO, "setsockopt: %m"); + } } + ident[i] = pifap->ifa_name; if ((tcp[i] = socket(pifap->ifa_addr->sa_family, SOCK_STREAM, IPPROTO_TCP)) < 0) { @@ -2673,8 +2685,22 @@ ttlptr = (int *) CMSG_DATA(cmsg); received_ttl = (u_int)*ttlptr; #endif - break; } + +#ifdef __OpenBSD__ + if (cmsg->cmsg_level == IPPROTO_IPV6 && + cmsg->cmsg_type == IPV6_HOPLIMIT) { + + if (cmsg->cmsg_len != + CMSG_LEN(sizeof(int))) { + syslog(LOG_INFO, "cmsg->cmsg_len == %d", cmsg->cmsg_len); + continue; + } + + ttlptr = (u_char *) CMSG_DATA(cmsg); + received_ttl = (u_int)*ttlptr; + } +#endif /* __OpenBSD__ IPV6 */ } if (rflag) { I'm sad to report that it didn't work. I got setsockopt errors looking like so: Jun 10 17:03:37 uranus wildcarddnsd[27884]: restarting on SIGHUP Jun 10 17:03:37 uranus wildcarddnsd[23411]: starting up Jun 10 17:03:37 uranus wildcarddnsd[11938]: opening configfile "/etc/wildcarddns.conf", device: /dev/wd0a, inode: 78749, ctime: 1320681296 Jun 10 17:03:38 uranus wildcarddnsd[11938]: setsockopt: Protocol not available Jun 10 17:03:38 uranus wildcarddnsd[11938]: skipping interface enc0 Jun 10 17:03:38 uranus wildcarddnsd[11938]: setsockopt: Protocol not available Jun 10 17:03:38 uranus wildcarddnsd[11938]: setsockopt: Protocol not available Jun 10 17:03:45 uranus wildcarddnsd[11938]: request on descriptor 33 interface "em1" from 2a01:4f8:d13:1980::2000 (ttl=0, region=255) for "centroid.eu." type=ANY(255) class=1, answering "centroid.eu." Notice the "Protocol not available" errors. I'm wondering if there is something I'm doing wrong that someone can spot right away. Let me know, I'd be grateful! -peter