0003-Remove-ability-to-compile-without-IPv6-support.patch 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192
  1. From ee8750451b49d27b180517a4e35b636be0fae575 Mon Sep 17 00:00:00 2001
  2. From: Simon Kelley <[email protected]>
  3. Date: Tue, 23 Oct 2018 22:10:17 +0100
  4. Subject: [PATCH 03/30] Remove ability to compile without IPv6 support.
  5. This was the source of a large number of #ifdefs, originally
  6. included for use with old embedded libc versions. I'm
  7. sure no-one wants or needs IPv6-free code these days, so this
  8. is a move towards more maintainable code.
  9. Signed-off-by: Kevin Darbyshire-Bryant <[email protected]>
  10. ---
  11. src/arp.c | 13 ----------
  12. src/auth.c | 53 ++++++++++----------------------------
  13. src/bpf.c | 10 ++------
  14. src/cache.c | 31 ++++------------------
  15. src/config.h | 30 +++-------------------
  16. src/conntrack.c | 2 --
  17. src/dbus.c | 4 ---
  18. src/dnsmasq.c | 6 ++---
  19. src/dnsmasq.h | 20 ++-------------
  20. src/domain.c | 28 +++-----------------
  21. src/dump.c | 4 ---
  22. src/edns0.c | 14 +---------
  23. src/forward.c | 68 ++++---------------------------------------------
  24. src/helper.c | 8 ------
  25. src/ipset.c | 9 +------
  26. src/netlink.c | 5 +---
  27. src/network.c | 54 +++------------------------------------
  28. src/option.c | 34 -------------------------
  29. src/rfc1035.c | 50 +++++++-----------------------------
  30. src/tables.c | 3 +--
  31. src/tftp.c | 17 ++-----------
  32. src/util.c | 13 +---------
  33. 22 files changed, 57 insertions(+), 419 deletions(-)
  34. --- a/src/arp.c
  35. +++ b/src/arp.c
  36. @@ -44,11 +44,6 @@ static int filter_mac(int family, char *
  37. if (maclen > DHCP_CHADDR_MAX)
  38. return 1;
  39. -#ifndef HAVE_IPV6
  40. - if (family != AF_INET)
  41. - return 1;
  42. -#endif
  43. -
  44. /* Look for existing entry */
  45. for (arp = arps; arp; arp = arp->next)
  46. {
  47. @@ -60,13 +55,11 @@ static int filter_mac(int family, char *
  48. if (arp->addr.addr.addr4.s_addr != ((struct in_addr *)addrp)->s_addr)
  49. continue;
  50. }
  51. -#ifdef HAVE_IPV6
  52. else
  53. {
  54. if (!IN6_ARE_ADDR_EQUAL(&arp->addr.addr.addr6, (struct in6_addr *)addrp))
  55. continue;
  56. }
  57. -#endif
  58. if (arp->status == ARP_EMPTY)
  59. {
  60. @@ -103,10 +96,8 @@ static int filter_mac(int family, char *
  61. memcpy(arp->hwaddr, mac, maclen);
  62. if (family == AF_INET)
  63. arp->addr.addr.addr4.s_addr = ((struct in_addr *)addrp)->s_addr;
  64. -#ifdef HAVE_IPV6
  65. else
  66. memcpy(&arp->addr.addr.addr6, addrp, IN6ADDRSZ);
  67. -#endif
  68. }
  69. return 1;
  70. @@ -136,11 +127,9 @@ int find_mac(union mysockaddr *addr, uns
  71. arp->addr.addr.addr4.s_addr != addr->in.sin_addr.s_addr)
  72. continue;
  73. -#ifdef HAVE_IPV6
  74. if (arp->family == AF_INET6 &&
  75. !IN6_ARE_ADDR_EQUAL(&arp->addr.addr.addr6, &addr->in6.sin6_addr))
  76. continue;
  77. -#endif
  78. /* Only accept positive entries unless in lazy mode. */
  79. if (arp->status != ARP_EMPTY || lazy || updated)
  80. @@ -203,10 +192,8 @@ int find_mac(union mysockaddr *addr, uns
  81. if (addr->sa.sa_family == AF_INET)
  82. arp->addr.addr.addr4.s_addr = addr->in.sin_addr.s_addr;
  83. -#ifdef HAVE_IPV6
  84. else
  85. memcpy(&arp->addr.addr.addr6, &addr->in6.sin6_addr, IN6ADDRSZ);
  86. -#endif
  87. }
  88. return 0;
  89. --- a/src/auth.c
  90. +++ b/src/auth.c
  91. @@ -33,10 +33,8 @@ static struct addrlist *find_addrlist(st
  92. if (is_same_net(addr, list->addr.addr.addr4, netmask))
  93. return list;
  94. }
  95. -#ifdef HAVE_IPV6
  96. else if (is_same_net6(&(addr_u->addr.addr6), &list->addr.addr.addr6, list->prefixlen))
  97. return list;
  98. -#endif
  99. } while ((list = list->next));
  100. @@ -189,7 +187,6 @@ size_t answer_auth(struct dns_header *he
  101. while (intr->next && strcmp(intr->intr, intr->next->intr) == 0)
  102. intr = intr->next;
  103. }
  104. -#ifdef HAVE_IPV6
  105. else if (flag == F_IPV6)
  106. for (intr = daemon->int_names; intr; intr = intr->next)
  107. {
  108. @@ -205,7 +202,6 @@ size_t answer_auth(struct dns_header *he
  109. while (intr->next && strcmp(intr->intr, intr->next->intr) == 0)
  110. intr = intr->next;
  111. }
  112. -#endif
  113. if (intr)
  114. {
  115. @@ -378,10 +374,8 @@ size_t answer_auth(struct dns_header *he
  116. if (qtype == T_A)
  117. flag = F_IPV4;
  118. -#ifdef HAVE_IPV6
  119. if (qtype == T_AAAA)
  120. flag = F_IPV6;
  121. -#endif
  122. for (intr = daemon->int_names; intr; intr = intr->next)
  123. if ((rc = hostname_issubdomain(name, intr->name)))
  124. @@ -395,10 +389,9 @@ size_t answer_auth(struct dns_header *he
  125. if (((addrlist->flags & ADDRLIST_IPV6) ? T_AAAA : T_A) == qtype &&
  126. (local_query || filter_zone(zone, flag, &addrlist->addr)))
  127. {
  128. -#ifdef HAVE_IPV6
  129. if (addrlist->flags & ADDRLIST_REVONLY)
  130. continue;
  131. -#endif
  132. +
  133. found = 1;
  134. log_query(F_FORWARD | F_CONFIG | flag, name, &addrlist->addr, NULL);
  135. if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
  136. @@ -424,13 +417,11 @@ size_t answer_auth(struct dns_header *he
  137. if (peer_addr->sa.sa_family == AF_INET)
  138. peer_addr->in.sin_port = 0;
  139. -#ifdef HAVE_IPV6
  140. else
  141. {
  142. peer_addr->in6.sin6_port = 0;
  143. peer_addr->in6.sin6_scope_id = 0;
  144. }
  145. -#endif
  146. for (peers = daemon->auth_peers; peers; peers = peers->next)
  147. if (sockaddr_isequal(peer_addr, &peers->addr))
  148. @@ -442,10 +433,8 @@ size_t answer_auth(struct dns_header *he
  149. {
  150. if (peer_addr->sa.sa_family == AF_INET)
  151. inet_ntop(AF_INET, &peer_addr->in.sin_addr, daemon->addrbuff, ADDRSTRLEN);
  152. -#ifdef HAVE_IPV6
  153. else
  154. inet_ntop(AF_INET6, &peer_addr->in6.sin6_addr, daemon->addrbuff, ADDRSTRLEN);
  155. -#endif
  156. my_syslog(LOG_WARNING, _("ignoring zone transfer request from %s"), daemon->addrbuff);
  157. return 0;
  158. @@ -603,7 +592,6 @@ size_t answer_auth(struct dns_header *he
  159. p += sprintf(p, "%u.in-addr.arpa", a & 0xff);
  160. }
  161. -#ifdef HAVE_IPV6
  162. else
  163. {
  164. char *p = name;
  165. @@ -617,7 +605,6 @@ size_t answer_auth(struct dns_header *he
  166. p += sprintf(p, "ip6.arpa");
  167. }
  168. -#endif
  169. }
  170. /* handle NS and SOA in auth section or for explicit queries */
  171. @@ -754,14 +741,12 @@ size_t answer_auth(struct dns_header *he
  172. daemon->auth_ttl, NULL, T_A, C_IN, "4", cut ? intr->name : NULL, &addrlist->addr))
  173. anscount++;
  174. -#ifdef HAVE_IPV6
  175. for (addrlist = intr->addr; addrlist; addrlist = addrlist->next)
  176. if ((addrlist->flags & ADDRLIST_IPV6) &&
  177. (local_query || filter_zone(zone, F_IPV6, &addrlist->addr)) &&
  178. add_resource_record(header, limit, &trunc, -axfroffset, &ansp,
  179. daemon->auth_ttl, NULL, T_AAAA, C_IN, "6", cut ? intr->name : NULL, &addrlist->addr))
  180. anscount++;
  181. -#endif
  182. /* restore config data */
  183. if (cut)
  184. @@ -798,18 +783,11 @@ size_t answer_auth(struct dns_header *he
  185. {
  186. char *cache_name = cache_get_name(crecp);
  187. if (!strchr(cache_name, '.') &&
  188. - (local_query || filter_zone(zone, (crecp->flags & (F_IPV6 | F_IPV4)), &(crecp->addr.addr))))
  189. - {
  190. - qtype = T_A;
  191. -#ifdef HAVE_IPV6
  192. - if (crecp->flags & F_IPV6)
  193. - qtype = T_AAAA;
  194. -#endif
  195. - if (add_resource_record(header, limit, &trunc, -axfroffset, &ansp,
  196. - daemon->auth_ttl, NULL, qtype, C_IN,
  197. - (crecp->flags & F_IPV4) ? "4" : "6", cache_name, &crecp->addr))
  198. - anscount++;
  199. - }
  200. + (local_query || filter_zone(zone, (crecp->flags & (F_IPV6 | F_IPV4)), &(crecp->addr.addr))) &&
  201. + add_resource_record(header, limit, &trunc, -axfroffset, &ansp,
  202. + daemon->auth_ttl, NULL, (crecp->flags & F_IPV6) ? T_AAAA : T_A, C_IN,
  203. + (crecp->flags & F_IPV4) ? "4" : "6", cache_name, &crecp->addr))
  204. + anscount++;
  205. }
  206. if ((crecp->flags & F_HOSTS) || (((crecp->flags & F_DHCP) && option_bool(OPT_DHCP_FQDN))))
  207. @@ -818,18 +796,13 @@ size_t answer_auth(struct dns_header *he
  208. if (in_zone(zone, name, &cut) &&
  209. (local_query || filter_zone(zone, (crecp->flags & (F_IPV6 | F_IPV4)), &(crecp->addr.addr))))
  210. {
  211. - qtype = T_A;
  212. -#ifdef HAVE_IPV6
  213. - if (crecp->flags & F_IPV6)
  214. - qtype = T_AAAA;
  215. -#endif
  216. - if (cut)
  217. - *cut = 0;
  218. -
  219. - if (add_resource_record(header, limit, &trunc, -axfroffset, &ansp,
  220. - daemon->auth_ttl, NULL, qtype, C_IN,
  221. - (crecp->flags & F_IPV4) ? "4" : "6", cut ? name : NULL, &crecp->addr))
  222. - anscount++;
  223. + if (cut)
  224. + *cut = 0;
  225. +
  226. + if (add_resource_record(header, limit, &trunc, -axfroffset, &ansp,
  227. + daemon->auth_ttl, NULL, (crecp->flags & F_IPV6) ? T_AAAA : T_A, C_IN,
  228. + (crecp->flags & F_IPV4) ? "4" : "6", cut ? name : NULL, &crecp->addr))
  229. + anscount++;
  230. }
  231. }
  232. }
  233. --- a/src/bpf.c
  234. +++ b/src/bpf.c
  235. @@ -31,9 +31,7 @@
  236. # include <net/if_var.h>
  237. #endif
  238. #include <netinet/in_var.h>
  239. -#ifdef HAVE_IPV6
  240. -# include <netinet6/in6_var.h>
  241. -#endif
  242. +#include <netinet6/in6_var.h>
  243. #ifndef SA_SIZE
  244. #define SA_SIZE(sa) \
  245. @@ -121,7 +119,7 @@ int iface_enumerate(int family, void *pa
  246. if (getifaddrs(&head) == -1)
  247. return 0;
  248. -#if defined(HAVE_BSD_NETWORK) && defined(HAVE_IPV6)
  249. +#if defined(HAVE_BSD_NETWORK)
  250. if (family == AF_INET6)
  251. fd = socket(PF_INET6, SOCK_DGRAM, 0);
  252. #endif
  253. @@ -152,7 +150,6 @@ int iface_enumerate(int family, void *pa
  254. if (!((*callback)(addr, iface_index, NULL, netmask, broadcast, parm)))
  255. goto err;
  256. }
  257. -#ifdef HAVE_IPV6
  258. else if (family == AF_INET6)
  259. {
  260. struct in6_addr *addr = &((struct sockaddr_in6 *) addrs->ifa_addr)->sin6_addr;
  261. @@ -219,7 +216,6 @@ int iface_enumerate(int family, void *pa
  262. (int) preferred, (int)valid, parm)))
  263. goto err;
  264. }
  265. -#endif /* HAVE_IPV6 */
  266. #ifdef HAVE_DHCP6
  267. else if (family == AF_LINK)
  268. @@ -427,10 +423,8 @@ void route_sock(void)
  269. del_family = sa->sa_family;
  270. if (del_family == AF_INET)
  271. del_addr.addr.addr4 = ((struct sockaddr_in *)sa)->sin_addr;
  272. -#ifdef HAVE_IPV6
  273. else if (del_family == AF_INET6)
  274. del_addr.addr.addr6 = ((struct sockaddr_in6 *)sa)->sin6_addr;
  275. -#endif
  276. else
  277. del_family = 0;
  278. }
  279. --- a/src/cache.c
  280. +++ b/src/cache.c
  281. @@ -410,11 +410,8 @@ static struct crec *cache_scan_free(char
  282. else
  283. {
  284. int i;
  285. -#ifdef HAVE_IPV6
  286. int addrlen = (flags & F_IPV6) ? IN6ADDRSZ : INADDRSZ;
  287. -#else
  288. - int addrlen = INADDRSZ;
  289. -#endif
  290. +
  291. for (i = 0; i < hash_size; i++)
  292. for (crecp = hash_table[i], up = &hash_table[i];
  293. crecp && ((crecp->flags & F_REVERSE) || !(crecp->flags & F_IMMORTAL));
  294. @@ -512,11 +509,9 @@ static struct crec *really_insert(char *
  295. if ((flags & F_IPV4) && (new->flags & F_IPV4) &&
  296. new->addr.addr.addr.addr4.s_addr == addr->addr.addr4.s_addr)
  297. return new;
  298. -#ifdef HAVE_IPV6
  299. else if ((flags & F_IPV6) && (new->flags & F_IPV6) &&
  300. IN6_ARE_ADDR_EQUAL(&new->addr.addr.addr.addr6, &addr->addr.addr6))
  301. return new;
  302. -#endif
  303. }
  304. insert_error = 1;
  305. @@ -938,11 +933,7 @@ struct crec *cache_find_by_addr(struct c
  306. time_t now, unsigned int prot)
  307. {
  308. struct crec *ans;
  309. -#ifdef HAVE_IPV6
  310. int addrlen = (prot == F_IPV6) ? IN6ADDRSZ : INADDRSZ;
  311. -#else
  312. - int addrlen = INADDRSZ;
  313. -#endif
  314. if (crecp) /* iterating */
  315. ans = crecp->next;
  316. @@ -1171,14 +1162,12 @@ int read_hostsfile(char *filename, unsig
  317. addrlen = INADDRSZ;
  318. domain_suffix = get_domain(addr.addr.addr4);
  319. }
  320. -#ifdef HAVE_IPV6
  321. else if (inet_pton(AF_INET6, token, &addr) > 0)
  322. {
  323. flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV6;
  324. addrlen = IN6ADDRSZ;
  325. domain_suffix = get_domain6(&addr.addr.addr6);
  326. }
  327. -#endif
  328. else
  329. {
  330. my_syslog(LOG_ERR, _("bad address at %s line %d"), filename, lineno);
  331. @@ -1343,7 +1332,7 @@ void cache_reload(void)
  332. cache->flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV4 | F_NAMEP | F_CONFIG;
  333. add_hosts_entry(cache, (struct all_addr *)&hr->addr, INADDRSZ, SRC_CONFIG, (struct crec **)daemon->packet, revhashsz);
  334. }
  335. -#ifdef HAVE_IPV6
  336. +
  337. if (!IN6_IS_ADDR_UNSPECIFIED(&hr->addr6) &&
  338. (cache = whine_malloc(SIZEOF_POINTER_CREC)))
  339. {
  340. @@ -1352,7 +1341,6 @@ void cache_reload(void)
  341. cache->flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV6 | F_NAMEP | F_CONFIG;
  342. add_hosts_entry(cache, (struct all_addr *)&hr->addr6, IN6ADDRSZ, SRC_CONFIG, (struct crec **)daemon->packet, revhashsz);
  343. }
  344. -#endif
  345. }
  346. if (option_bool(OPT_NO_HOSTS) && !daemon->addn_hosts)
  347. @@ -1451,13 +1439,11 @@ void cache_add_dhcp_entry(char *host_nam
  348. int in_hosts = 0;
  349. size_t addrlen = sizeof(struct in_addr);
  350. -#ifdef HAVE_IPV6
  351. if (prot == AF_INET6)
  352. {
  353. flags = F_IPV6;
  354. addrlen = sizeof(struct in6_addr);
  355. }
  356. -#endif
  357. inet_ntop(prot, host_address, daemon->addrbuff, ADDRSTRLEN);
  358. @@ -1810,10 +1796,8 @@ void dump_cache(time_t now)
  359. a = daemon->addrbuff;
  360. if (cache->flags & F_IPV4)
  361. inet_ntop(AF_INET, &cache->addr.addr, a, ADDRSTRLEN);
  362. -#ifdef HAVE_IPV6
  363. else if (cache->flags & F_IPV6)
  364. inet_ntop(AF_INET6, &cache->addr.addr, a, ADDRSTRLEN);
  365. -#endif
  366. }
  367. if (cache->flags & F_IPV4)
  368. @@ -1954,14 +1938,9 @@ void log_query(unsigned int flags, char
  369. sprintf(daemon->addrbuff, "%u", rcode);
  370. }
  371. else
  372. - {
  373. -#ifdef HAVE_IPV6
  374. - inet_ntop(flags & F_IPV4 ? AF_INET : AF_INET6,
  375. - addr, daemon->addrbuff, ADDRSTRLEN);
  376. -#else
  377. - strncpy(daemon->addrbuff, inet_ntoa(addr->addr.addr4), ADDRSTRLEN);
  378. -#endif
  379. - }
  380. + inet_ntop(flags & F_IPV4 ? AF_INET : AF_INET6,
  381. + addr, daemon->addrbuff, ADDRSTRLEN);
  382. +
  383. }
  384. else
  385. dest = arg;
  386. --- a/src/config.h
  387. +++ b/src/config.h
  388. @@ -131,7 +131,6 @@ HAVE_INOTIFY
  389. NO_ID
  390. Don't report *.bind CHAOS info to clients, forward such requests upstream instead.
  391. -NO_IPV6
  392. NO_TFTP
  393. NO_DHCP
  394. NO_DHCP6
  395. @@ -141,8 +140,8 @@ NO_AUTH
  396. NO_DUMPFILE
  397. NO_INOTIFY
  398. these are available to explicitly disable compile time options which would
  399. - otherwise be enabled automatically (HAVE_IPV6, >2Gb file sizes) or
  400. - which are enabled by default in the distributed source tree. Building dnsmasq
  401. + otherwise be enabled automatically or which are enabled by default
  402. + in the distributed source tree. Building dnsmasq
  403. with something like "make COPTS=-DNO_SCRIPT" will do the trick.
  404. NO_GMP
  405. Don't use and link against libgmp, Useful if nettle is built with --enable-mini-gmp.
  406. @@ -308,29 +307,9 @@ HAVE_SOCKADDR_SA_LEN
  407. #endif
  408. -/* Decide if we're going to support IPv6 */
  409. -/* We assume that systems which don't have IPv6
  410. - headers don't have ntop and pton either */
  411. -
  412. -#if defined(INET6_ADDRSTRLEN) && defined(IPV6_V6ONLY)
  413. -# define HAVE_IPV6
  414. -# define ADDRSTRLEN INET6_ADDRSTRLEN
  415. -#else
  416. -# if !defined(INET_ADDRSTRLEN)
  417. -# define INET_ADDRSTRLEN 16 /* 4*3 + 3 dots + NULL */
  418. -# endif
  419. -# undef HAVE_IPV6
  420. -# define ADDRSTRLEN INET_ADDRSTRLEN
  421. -#endif
  422. -
  423. -
  424. /* rules to implement compile-time option dependencies and
  425. the NO_XXX flags */
  426. -#ifdef NO_IPV6
  427. -#undef HAVE_IPV6
  428. -#endif
  429. -
  430. #ifdef NO_TFTP
  431. #undef HAVE_TFTP
  432. #endif
  433. @@ -340,7 +319,7 @@ HAVE_SOCKADDR_SA_LEN
  434. #undef HAVE_DHCP6
  435. #endif
  436. -#if defined(NO_DHCP6) || !defined(HAVE_IPV6)
  437. +#if defined(NO_DHCP6)
  438. #undef HAVE_DHCP6
  439. #endif
  440. @@ -385,9 +364,6 @@ HAVE_SOCKADDR_SA_LEN
  441. #ifdef DNSMASQ_COMPILE_OPTS
  442. static char *compile_opts =
  443. -#ifndef HAVE_IPV6
  444. -"no-"
  445. -#endif
  446. "IPv6 "
  447. #ifndef HAVE_GETOPT_LONG
  448. "no-"
  449. --- a/src/conntrack.c
  450. +++ b/src/conntrack.c
  451. @@ -36,7 +36,6 @@ int get_incoming_mark(union mysockaddr *
  452. nfct_set_attr_u8(ct, ATTR_L4PROTO, istcp ? IPPROTO_TCP : IPPROTO_UDP);
  453. nfct_set_attr_u16(ct, ATTR_PORT_DST, htons(daemon->port));
  454. -#ifdef HAVE_IPV6
  455. if (peer_addr->sa.sa_family == AF_INET6)
  456. {
  457. nfct_set_attr_u8(ct, ATTR_L3PROTO, AF_INET6);
  458. @@ -45,7 +44,6 @@ int get_incoming_mark(union mysockaddr *
  459. nfct_set_attr(ct, ATTR_IPV6_DST, local_addr->addr.addr6.s6_addr);
  460. }
  461. else
  462. -#endif
  463. {
  464. nfct_set_attr_u8(ct, ATTR_L3PROTO, AF_INET);
  465. nfct_set_attr_u32(ct, ATTR_IPV4_SRC, peer_addr->in.sin_addr.s_addr);
  466. --- a/src/dbus.c
  467. +++ b/src/dbus.c
  468. @@ -185,9 +185,6 @@ static void dbus_read_servers(DBusMessag
  469. }
  470. }
  471. -#ifndef HAVE_IPV6
  472. - my_syslog(LOG_WARNING, _("attempt to set an IPv6 server address via DBus - no IPv6 support"));
  473. -#else
  474. if (i == sizeof(struct in6_addr))
  475. {
  476. memcpy(&addr.in6.sin6_addr, p, sizeof(struct in6_addr));
  477. @@ -202,7 +199,6 @@ static void dbus_read_servers(DBusMessag
  478. source_addr.in6.sin6_port = htons(daemon->query_port);
  479. skip = 0;
  480. }
  481. -#endif
  482. }
  483. else
  484. /* At the end */
  485. --- a/src/dnsmasq.c
  486. +++ b/src/dnsmasq.c
  487. @@ -1730,11 +1730,11 @@ static void check_dns_listeners(time_t n
  488. indextoname(listener->tcpfd, if_index, intr_name))
  489. {
  490. struct all_addr addr;
  491. - addr.addr.addr4 = tcp_addr.in.sin_addr;
  492. -#ifdef HAVE_IPV6
  493. +
  494. if (tcp_addr.sa.sa_family == AF_INET6)
  495. addr.addr.addr6 = tcp_addr.in6.sin6_addr;
  496. -#endif
  497. + else
  498. + addr.addr.addr4 = tcp_addr.in.sin_addr;
  499. for (iface = daemon->interfaces; iface; iface = iface->next)
  500. if (iface->index == if_index)
  501. --- a/src/dnsmasq.h
  502. +++ b/src/dnsmasq.h
  503. @@ -126,9 +126,7 @@ typedef unsigned long long u64;
  504. #include <net/if_arp.h>
  505. #include <netinet/in_systm.h>
  506. #include <netinet/ip.h>
  507. -#ifdef HAVE_IPV6
  508. #include <netinet/ip6.h>
  509. -#endif
  510. #include <netinet/ip_icmp.h>
  511. #include <sys/uio.h>
  512. #include <syslog.h>
  513. @@ -159,6 +157,8 @@ extern int capget(cap_user_header_t head
  514. /* daemon is function in the C library.... */
  515. #define daemon dnsmasq_daemon
  516. +#define ADDRSTRLEN INET6_ADDRSTRLEN
  517. +
  518. /* Async event queue */
  519. struct event_desc {
  520. int event, data, msg_sz;
  521. @@ -273,9 +273,7 @@ struct event_desc {
  522. struct all_addr {
  523. union {
  524. struct in_addr addr4;
  525. -#ifdef HAVE_IPV6
  526. struct in6_addr addr6;
  527. -#endif
  528. /* for log_query */
  529. struct {
  530. unsigned short keytag, algo, digest;
  531. @@ -383,9 +381,7 @@ struct host_record {
  532. struct name_list *next;
  533. } *names;
  534. struct in_addr addr;
  535. -#ifdef HAVE_IPV6
  536. struct in6_addr addr6;
  537. -#endif
  538. struct host_record *next;
  539. };
  540. @@ -496,9 +492,7 @@ struct crec {
  541. union mysockaddr {
  542. struct sockaddr sa;
  543. struct sockaddr_in in;
  544. -#if defined(HAVE_IPV6)
  545. struct sockaddr_in6 in6;
  546. -#endif
  547. };
  548. /* bits in flag param to IPv6 callbacks from iface_enumerate() */
  549. @@ -660,9 +654,7 @@ struct frec {
  550. struct all_addr dest;
  551. struct server *sentto; /* NULL means free */
  552. struct randfd *rfd4;
  553. -#ifdef HAVE_IPV6
  554. struct randfd *rfd6;
  555. -#endif
  556. unsigned int iface;
  557. unsigned short orig_id, new_id;
  558. int log_id, fd, forwardall, flags;
  559. @@ -877,9 +869,7 @@ struct dhcp_bridge {
  560. struct cond_domain {
  561. char *domain, *prefix;
  562. struct in_addr start, end;
  563. -#ifdef HAVE_IPV6
  564. struct in6_addr start6, end6;
  565. -#endif
  566. int is6, indexed;
  567. struct cond_domain *next;
  568. };
  569. @@ -1184,9 +1174,7 @@ void blockdata_free(struct blockdata *bl
  570. /* domain.c */
  571. char *get_domain(struct in_addr addr);
  572. -#ifdef HAVE_IPV6
  573. char *get_domain6(struct in6_addr *addr);
  574. -#endif
  575. int is_name_synthetic(int flags, char *name, struct all_addr *addr);
  576. int is_rev_synth(int flag, struct all_addr *addr, char *name);
  577. @@ -1270,11 +1258,9 @@ int hostname_issubdomain(char *a, char *
  578. time_t dnsmasq_time(void);
  579. int netmask_length(struct in_addr mask);
  580. int is_same_net(struct in_addr a, struct in_addr b, struct in_addr mask);
  581. -#ifdef HAVE_IPV6
  582. int is_same_net6(struct in6_addr *a, struct in6_addr *b, int prefixlen);
  583. u64 addr6part(struct in6_addr *addr);
  584. void setaddr6part(struct in6_addr *addr, u64 host);
  585. -#endif
  586. int retry_send(ssize_t rc);
  587. void prettyprint_time(char *buf, unsigned int t);
  588. int prettyprint_addr(union mysockaddr *addr, char *buf);
  589. @@ -1353,9 +1339,7 @@ int loopback_exception(int fd, int famil
  590. int label_exception(int index, int family, struct all_addr *addr);
  591. int fix_fd(int fd);
  592. int tcp_interface(int fd, int af);
  593. -#ifdef HAVE_IPV6
  594. int set_ipv6pktinfo(int fd);
  595. -#endif
  596. #ifdef HAVE_DHCP6
  597. void join_multicast(int dienow);
  598. #endif
  599. --- a/src/domain.c
  600. +++ b/src/domain.c
  601. @@ -18,21 +18,14 @@
  602. static struct cond_domain *search_domain(struct in_addr addr, struct cond_domain *c);
  603. -#ifdef HAVE_IPV6
  604. static struct cond_domain *search_domain6(struct in6_addr *addr, struct cond_domain *c);
  605. -#endif
  606. int is_name_synthetic(int flags, char *name, struct all_addr *addr)
  607. {
  608. char *p;
  609. struct cond_domain *c = NULL;
  610. - int prot = AF_INET;
  611. -
  612. -#ifdef HAVE_IPV6
  613. - if (flags & F_IPV6)
  614. - prot = AF_INET6;
  615. -#endif
  616. + int prot = (flags & F_IPV6) ? AF_INET6 : AF_INET;
  617. for (c = daemon->synth_domains; c; c = c->next)
  618. {
  619. @@ -83,8 +76,7 @@ int is_name_synthetic(int flags, char *n
  620. addr->addr.addr4.s_addr = htonl(ntohl(c->start.s_addr) + index);
  621. found = 1;
  622. }
  623. - }
  624. -#ifdef HAVE_IPV6
  625. + }
  626. else
  627. {
  628. u64 index = atoll(tail);
  629. @@ -98,7 +90,6 @@ int is_name_synthetic(int flags, char *n
  630. found = 1;
  631. }
  632. }
  633. -#endif
  634. }
  635. }
  636. else
  637. @@ -111,10 +102,8 @@ int is_name_synthetic(int flags, char *n
  638. if ((c >='0' && c <= '9') || c == '-')
  639. continue;
  640. -#ifdef HAVE_IPV6
  641. if (prot == AF_INET6 && ((c >='A' && c <= 'F') || (c >='a' && c <= 'f')))
  642. continue;
  643. -#endif
  644. break;
  645. }
  646. @@ -124,7 +113,6 @@ int is_name_synthetic(int flags, char *n
  647. *p = 0;
  648. -#ifdef HAVE_IPV6
  649. if (prot == AF_INET6 && strstr(tail, "--ffff-") == tail)
  650. {
  651. /* special hack for v4-mapped. */
  652. @@ -134,7 +122,6 @@ int is_name_synthetic(int flags, char *n
  653. *p = '.';
  654. }
  655. else
  656. -#endif
  657. {
  658. /* swap . or : for - */
  659. for (p = tail; *p; p++)
  660. @@ -142,10 +129,8 @@ int is_name_synthetic(int flags, char *n
  661. {
  662. if (prot == AF_INET)
  663. *p = '.';
  664. -#ifdef HAVE_IPV6
  665. else
  666. *p = ':';
  667. -#endif
  668. }
  669. }
  670. @@ -158,7 +143,6 @@ int is_name_synthetic(int flags, char *n
  671. ntohl(addr->addr.addr4.s_addr) <= ntohl(c->end.s_addr))
  672. found = 1;
  673. }
  674. -#ifdef HAVE_IPV6
  675. else
  676. {
  677. u64 addrpart = addr6part(&addr->addr.addr6);
  678. @@ -169,7 +153,6 @@ int is_name_synthetic(int flags, char *n
  679. addrpart <= addr6part(&c->end6))
  680. found = 1;
  681. }
  682. -#endif
  683. }
  684. }
  685. @@ -221,8 +204,7 @@ int is_rev_synth(int flag, struct all_ad
  686. return 1;
  687. }
  688. -#ifdef HAVE_IPV6
  689. - if (flag & F_IPV6 && (c = search_domain6(&addr->addr.addr6, daemon->synth_domains)))
  690. + if ((flag & F_IPV6) && (c = search_domain6(&addr->addr.addr6, daemon->synth_domains)))
  691. {
  692. char *p;
  693. @@ -259,7 +241,6 @@ int is_rev_synth(int flag, struct all_ad
  694. return 1;
  695. }
  696. -#endif
  697. return 0;
  698. }
  699. @@ -286,7 +267,7 @@ char *get_domain(struct in_addr addr)
  700. return daemon->domain_suffix;
  701. }
  702. -#ifdef HAVE_IPV6
  703. +
  704. static struct cond_domain *search_domain6(struct in6_addr *addr, struct cond_domain *c)
  705. {
  706. u64 addrpart = addr6part(addr);
  707. @@ -310,4 +291,3 @@ char *get_domain6(struct in6_addr *addr)
  708. return daemon->domain_suffix;
  709. }
  710. -#endif
  711. --- a/src/dump.c
  712. +++ b/src/dump.c
  713. @@ -82,10 +82,8 @@ void dump_init(void)
  714. void dump_packet(int mask, void *packet, size_t len, union mysockaddr *src, union mysockaddr *dst)
  715. {
  716. struct ip ip;
  717. -#ifdef HAVE_IPV6
  718. struct ip6_hdr ip6;
  719. int family;
  720. -#endif
  721. struct udphdr {
  722. u16 uh_sport; /* source port */
  723. u16 uh_dport; /* destination port */
  724. @@ -105,7 +103,6 @@ void dump_packet(int mask, void *packet,
  725. /* So wireshark can Id the packet. */
  726. udp.uh_sport = udp.uh_dport = htons(NAMESERVER_PORT);
  727. -#ifdef HAVE_IPV6
  728. if (src)
  729. family = src->sa.sa_family;
  730. else
  731. @@ -139,7 +136,6 @@ void dump_packet(int mask, void *packet,
  732. sum += ((u16 *)&ip6.ip6_src)[i];
  733. }
  734. else
  735. -#endif
  736. {
  737. iphdr = &ip;
  738. ipsz = sizeof(ip);
  739. --- a/src/edns0.c
  740. +++ b/src/edns0.c
  741. @@ -301,20 +301,14 @@ static size_t add_mac(struct dns_header
  742. struct subnet_opt {
  743. u16 family;
  744. - u8 source_netmask, scope_netmask;
  745. -#ifdef HAVE_IPV6
  746. + u8 source_netmask, scope_netmask;
  747. u8 addr[IN6ADDRSZ];
  748. -#else
  749. - u8 addr[INADDRSZ];
  750. -#endif
  751. };
  752. static void *get_addrp(union mysockaddr *addr, const short family)
  753. {
  754. -#ifdef HAVE_IPV6
  755. if (family == AF_INET6)
  756. return &addr->in6.sin6_addr;
  757. -#endif
  758. return &addr->in.sin_addr;
  759. }
  760. @@ -330,7 +324,6 @@ static size_t calc_subnet_opt(struct sub
  761. opt->source_netmask = 0;
  762. opt->scope_netmask = 0;
  763. -#ifdef HAVE_IPV6
  764. if (source->sa.sa_family == AF_INET6 && daemon->add_subnet6)
  765. {
  766. opt->source_netmask = daemon->add_subnet6->mask;
  767. @@ -342,7 +335,6 @@ static size_t calc_subnet_opt(struct sub
  768. else
  769. addrp = &source->in6.sin6_addr;
  770. }
  771. -#endif
  772. if (source->sa.sa_family == AF_INET && daemon->add_subnet4)
  773. {
  774. @@ -356,11 +348,7 @@ static size_t calc_subnet_opt(struct sub
  775. addrp = &source->in.sin_addr;
  776. }
  777. -#ifdef HAVE_IPV6
  778. opt->family = htons(sa_family == AF_INET6 ? 2 : 1);
  779. -#else
  780. - opt->family = htons(1);
  781. -#endif
  782. len = 0;
  783. --- a/src/forward.c
  784. +++ b/src/forward.c
  785. @@ -38,9 +38,7 @@ int send_from(int fd, int nowild, char *
  786. #elif defined(IP_SENDSRCADDR)
  787. char control[CMSG_SPACE(sizeof(struct in_addr))];
  788. #endif
  789. -#ifdef HAVE_IPV6
  790. char control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
  791. -#endif
  792. } control_u;
  793. iov[0].iov_base = packet;
  794. @@ -79,7 +77,6 @@ int send_from(int fd, int nowild, char *
  795. #endif
  796. }
  797. else
  798. -#ifdef HAVE_IPV6
  799. {
  800. struct in6_pktinfo p;
  801. p.ipi6_ifindex = iface; /* Need iface for IPv6 to handle link-local addrs */
  802. @@ -89,9 +86,6 @@ int send_from(int fd, int nowild, char *
  803. cmptr->cmsg_type = daemon->v6pktinfo;
  804. cmptr->cmsg_level = IPPROTO_IPV6;
  805. }
  806. -#else
  807. - (void)iface; /* eliminate warning */
  808. -#endif
  809. }
  810. while (retry_send(sendmsg(fd, &msg, 0)));
  811. @@ -144,10 +138,8 @@ static unsigned int search_servers(time_
  812. flags = sflag;
  813. if (serv->addr.sa.sa_family == AF_INET)
  814. *addrpp = (struct all_addr *)&serv->addr.in.sin_addr;
  815. -#ifdef HAVE_IPV6
  816. else
  817. *addrpp = (struct all_addr *)&serv->addr.in6.sin6_addr;
  818. -#endif
  819. }
  820. else if (!flags || (flags & F_NXDOMAIN))
  821. flags = F_NOERR;
  822. @@ -204,10 +196,8 @@ static unsigned int search_servers(time_
  823. flags = sflag;
  824. if (serv->addr.sa.sa_family == AF_INET)
  825. *addrpp = (struct all_addr *)&serv->addr.in.sin_addr;
  826. -#ifdef HAVE_IPV6
  827. else
  828. *addrpp = (struct all_addr *)&serv->addr.in6.sin6_addr;
  829. -#endif
  830. }
  831. else if (!flags || (flags & F_NXDOMAIN))
  832. flags = F_NOERR;
  833. @@ -236,10 +226,8 @@ static unsigned int search_servers(time_
  834. /* handle F_IPV4 and F_IPV6 set on ANY query to 0.0.0.0/:: domain. */
  835. if (flags & F_IPV4)
  836. log_query((flags | F_CONFIG | F_FORWARD) & ~F_IPV6, qdomain, *addrpp, NULL);
  837. -#ifdef HAVE_IPV6
  838. if (flags & F_IPV6)
  839. log_query((flags | F_CONFIG | F_FORWARD) & ~F_IPV4, qdomain, *addrpp, NULL);
  840. -#endif
  841. }
  842. }
  843. else if ((*type) & SERV_USE_RESOLV)
  844. @@ -302,20 +290,17 @@ static int forward_query(int udpfd, unio
  845. if (forward->sentto->addr.sa.sa_family == AF_INET)
  846. log_query(F_NOEXTRA | F_DNSSEC | F_IPV4, "retry", (struct all_addr *)&forward->sentto->addr.in.sin_addr, "dnssec");
  847. -#ifdef HAVE_IPV6
  848. else
  849. log_query(F_NOEXTRA | F_DNSSEC | F_IPV6, "retry", (struct all_addr *)&forward->sentto->addr.in6.sin6_addr, "dnssec");
  850. -#endif
  851. +
  852. if (forward->sentto->sfd)
  853. fd = forward->sentto->sfd->fd;
  854. else
  855. {
  856. -#ifdef HAVE_IPV6
  857. if (forward->sentto->addr.sa.sa_family == AF_INET6)
  858. fd = forward->rfd6->fd;
  859. else
  860. -#endif
  861. fd = forward->rfd4->fd;
  862. }
  863. @@ -475,7 +460,6 @@ static int forward_query(int udpfd, unio
  864. fd = start->sfd->fd;
  865. else
  866. {
  867. -#ifdef HAVE_IPV6
  868. if (start->addr.sa.sa_family == AF_INET6)
  869. {
  870. if (!forward->rfd6 &&
  871. @@ -485,7 +469,6 @@ static int forward_query(int udpfd, unio
  872. fd = forward->rfd6->fd;
  873. }
  874. else
  875. -#endif
  876. {
  877. if (!forward->rfd4 &&
  878. !(forward->rfd4 = allocate_rfd(AF_INET)))
  879. @@ -541,11 +524,9 @@ static int forward_query(int udpfd, unio
  880. if (start->addr.sa.sa_family == AF_INET)
  881. log_query(F_SERVER | F_IPV4 | F_FORWARD, daemon->namebuff,
  882. (struct all_addr *)&start->addr.in.sin_addr, NULL);
  883. -#ifdef HAVE_IPV6
  884. else
  885. log_query(F_SERVER | F_IPV6 | F_FORWARD, daemon->namebuff,
  886. (struct all_addr *)&start->addr.in6.sin6_addr, NULL);
  887. -#endif
  888. start->queries++;
  889. forwarded = 1;
  890. forward->sentto = start;
  891. @@ -788,11 +769,8 @@ void reply_query(int fd, int family, tim
  892. daemon->srv_save = NULL;
  893. /* Determine the address of the server replying so that we can mark that as good */
  894. - serveraddr.sa.sa_family = family;
  895. -#ifdef HAVE_IPV6
  896. - if (serveraddr.sa.sa_family == AF_INET6)
  897. + if ((serveraddr.sa.sa_family = family) == AF_INET6)
  898. serveraddr.in6.sin6_flowinfo = 0;
  899. -#endif
  900. header = (struct dns_header *)daemon->packet;
  901. @@ -878,7 +856,6 @@ void reply_query(int fd, int family, tim
  902. fd = start->sfd->fd;
  903. else
  904. {
  905. -#ifdef HAVE_IPV6
  906. if (start->addr.sa.sa_family == AF_INET6)
  907. {
  908. /* may have changed family */
  909. @@ -887,7 +864,6 @@ void reply_query(int fd, int family, tim
  910. fd = forward->rfd6->fd;
  911. }
  912. else
  913. -#endif
  914. {
  915. /* may have changed family */
  916. if (!forward->rfd4)
  917. @@ -902,10 +878,8 @@ void reply_query(int fd, int family, tim
  918. if (start->addr.sa.sa_family == AF_INET)
  919. log_query(F_NOEXTRA | F_DNSSEC | F_IPV4, "retry", (struct all_addr *)&start->addr.in.sin_addr, "dnssec");
  920. -#ifdef HAVE_IPV6
  921. else
  922. log_query(F_NOEXTRA | F_DNSSEC | F_IPV6, "retry", (struct all_addr *)&start->addr.in6.sin6_addr, "dnssec");
  923. -#endif
  924. return;
  925. }
  926. @@ -1099,9 +1073,7 @@ void reply_query(int fd, int family, tim
  927. new->sentto = server;
  928. new->rfd4 = NULL;
  929. -#ifdef HAVE_IPV6
  930. new->rfd6 = NULL;
  931. -#endif
  932. new->flags &= ~(FREC_DNSKEY_QUERY | FREC_DS_QUERY | FREC_HAS_EXTRADATA);
  933. new->forwardall = 0;
  934. @@ -1125,11 +1097,9 @@ void reply_query(int fd, int family, tim
  935. if (server->addr.sa.sa_family == AF_INET)
  936. log_query(F_NOEXTRA | F_DNSSEC | F_IPV4, daemon->keyname, (struct all_addr *)&(server->addr.in.sin_addr),
  937. querystr("dnssec-query", querytype));
  938. -#ifdef HAVE_IPV6
  939. else
  940. log_query(F_NOEXTRA | F_DNSSEC | F_IPV6, daemon->keyname, (struct all_addr *)&(server->addr.in6.sin6_addr),
  941. querystr("dnssec-query", querytype));
  942. -#endif
  943. if ((hash = hash_questions(header, nn, daemon->namebuff)))
  944. memcpy(new->hash, hash, HASH_SIZE);
  945. @@ -1147,14 +1117,12 @@ void reply_query(int fd, int family, tim
  946. else
  947. {
  948. fd = -1;
  949. -#ifdef HAVE_IPV6
  950. if (server->addr.sa.sa_family == AF_INET6)
  951. {
  952. if (new->rfd6 || (new->rfd6 = allocate_rfd(AF_INET6)))
  953. fd = new->rfd6->fd;
  954. }
  955. else
  956. -#endif
  957. {
  958. if (new->rfd4 || (new->rfd4 = allocate_rfd(AF_INET)))
  959. fd = new->rfd4->fd;
  960. @@ -1290,9 +1258,7 @@ void receive_query(struct listener *list
  961. struct cmsghdr *cmptr;
  962. union {
  963. struct cmsghdr align; /* this ensures alignment */
  964. -#ifdef HAVE_IPV6
  965. char control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
  966. -#endif
  967. #if defined(HAVE_LINUX_NETWORK)
  968. char control[CMSG_SPACE(sizeof(struct in_pktinfo))];
  969. #elif defined(IP_RECVDSTADDR) && defined(HAVE_SOLARIS_NETWORK)
  970. @@ -1303,12 +1269,8 @@ void receive_query(struct listener *list
  971. CMSG_SPACE(sizeof(struct sockaddr_dl))];
  972. #endif
  973. } control_u;
  974. -#ifdef HAVE_IPV6
  975. /* Can always get recvd interface for IPv6 */
  976. int check_dst = !option_bool(OPT_NOWILD) || listen->family == AF_INET6;
  977. -#else
  978. - int check_dst = !option_bool(OPT_NOWILD);
  979. -#endif
  980. /* packet buffer overwritten */
  981. daemon->srv_save = NULL;
  982. @@ -1359,7 +1321,6 @@ void receive_query(struct listener *list
  983. if (source_addr.in.sin_port == 0)
  984. return;
  985. }
  986. -#ifdef HAVE_IPV6
  987. else
  988. {
  989. /* Source-port == 0 is an error, we can't send back to that. */
  990. @@ -1367,13 +1328,12 @@ void receive_query(struct listener *list
  991. return;
  992. source_addr.in6.sin6_flowinfo = 0;
  993. }
  994. -#endif
  995. /* We can be configured to only accept queries from at-most-one-hop-away addresses. */
  996. if (option_bool(OPT_LOCAL_SERVICE))
  997. {
  998. struct addrlist *addr;
  999. -#ifdef HAVE_IPV6
  1000. +
  1001. if (listen->family == AF_INET6)
  1002. {
  1003. for (addr = daemon->interface_addrs; addr; addr = addr->next)
  1004. @@ -1382,7 +1342,6 @@ void receive_query(struct listener *list
  1005. break;
  1006. }
  1007. else
  1008. -#endif
  1009. {
  1010. struct in_addr netmask;
  1011. for (addr = daemon->interface_addrs; addr; addr = addr->next)
  1012. @@ -1451,7 +1410,6 @@ void receive_query(struct listener *list
  1013. }
  1014. #endif
  1015. -#ifdef HAVE_IPV6
  1016. if (listen->family == AF_INET6)
  1017. {
  1018. for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
  1019. @@ -1467,7 +1425,6 @@ void receive_query(struct listener *list
  1020. if_index = p.p->ipi6_ifindex;
  1021. }
  1022. }
  1023. -#endif
  1024. /* enforce available interface configuration */
  1025. @@ -1531,11 +1488,9 @@ void receive_query(struct listener *list
  1026. if (listen->family == AF_INET)
  1027. log_query(F_QUERY | F_IPV4 | F_FORWARD, daemon->namebuff,
  1028. (struct all_addr *)&source_addr.in.sin_addr, types);
  1029. -#ifdef HAVE_IPV6
  1030. else
  1031. log_query(F_QUERY | F_IPV6 | F_FORWARD, daemon->namebuff,
  1032. (struct all_addr *)&source_addr.in6.sin6_addr, types);
  1033. -#endif
  1034. #ifdef HAVE_AUTH
  1035. /* find queries for zones we're authoritative for, and answer them directly */
  1036. @@ -1744,11 +1699,9 @@ static int tcp_key_recurse(time_t now, i
  1037. if (server->addr.sa.sa_family == AF_INET)
  1038. log_query(F_NOEXTRA | F_DNSSEC | F_IPV4, keyname, (struct all_addr *)&(server->addr.in.sin_addr),
  1039. querystr("dnssec-query", new_status == STAT_NEED_KEY ? T_DNSKEY : T_DS));
  1040. -#ifdef HAVE_IPV6
  1041. else
  1042. log_query(F_NOEXTRA | F_DNSSEC | F_IPV6, keyname, (struct all_addr *)&(server->addr.in6.sin6_addr),
  1043. querystr("dnssec-query", new_status == STAT_NEED_KEY ? T_DNSKEY : T_DS));
  1044. -#endif
  1045. server->flags |= SERV_GOT_TCP;
  1046. @@ -1813,11 +1766,10 @@ unsigned char *tcp_request(int confd, ti
  1047. if (option_bool(OPT_CONNTRACK))
  1048. {
  1049. struct all_addr local;
  1050. -#ifdef HAVE_IPV6
  1051. +
  1052. if (local_addr->sa.sa_family == AF_INET6)
  1053. local.addr.addr6 = local_addr->in6.sin6_addr;
  1054. else
  1055. -#endif
  1056. local.addr.addr4 = local_addr->in.sin_addr;
  1057. have_mark = get_incoming_mark(&peer_addr, &local, 1, &mark);
  1058. @@ -1828,7 +1780,7 @@ unsigned char *tcp_request(int confd, ti
  1059. if (option_bool(OPT_LOCAL_SERVICE))
  1060. {
  1061. struct addrlist *addr;
  1062. -#ifdef HAVE_IPV6
  1063. +
  1064. if (peer_addr.sa.sa_family == AF_INET6)
  1065. {
  1066. for (addr = daemon->interface_addrs; addr; addr = addr->next)
  1067. @@ -1837,7 +1789,6 @@ unsigned char *tcp_request(int confd, ti
  1068. break;
  1069. }
  1070. else
  1071. -#endif
  1072. {
  1073. struct in_addr netmask;
  1074. for (addr = daemon->interface_addrs; addr; addr = addr->next)
  1075. @@ -1892,11 +1843,9 @@ unsigned char *tcp_request(int confd, ti
  1076. if (peer_addr.sa.sa_family == AF_INET)
  1077. log_query(F_QUERY | F_IPV4 | F_FORWARD, daemon->namebuff,
  1078. (struct all_addr *)&peer_addr.in.sin_addr, types);
  1079. -#ifdef HAVE_IPV6
  1080. else
  1081. log_query(F_QUERY | F_IPV6 | F_FORWARD, daemon->namebuff,
  1082. (struct all_addr *)&peer_addr.in6.sin6_addr, types);
  1083. -#endif
  1084. #ifdef HAVE_AUTH
  1085. /* find queries for zones we're authoritative for, and answer them directly */
  1086. @@ -2072,11 +2021,9 @@ unsigned char *tcp_request(int confd, ti
  1087. if (last_server->addr.sa.sa_family == AF_INET)
  1088. log_query(F_SERVER | F_IPV4 | F_FORWARD, daemon->namebuff,
  1089. (struct all_addr *)&last_server->addr.in.sin_addr, NULL);
  1090. -#ifdef HAVE_IPV6
  1091. else
  1092. log_query(F_SERVER | F_IPV6 | F_FORWARD, daemon->namebuff,
  1093. (struct all_addr *)&last_server->addr.in6.sin6_addr, NULL);
  1094. -#endif
  1095. #ifdef HAVE_DNSSEC
  1096. if (option_bool(OPT_DNSSEC_VALID) && !checking_disabled && (last_server->flags & SERV_DO_DNSSEC))
  1097. @@ -2175,9 +2122,7 @@ static struct frec *allocate_frec(time_t
  1098. f->sentto = NULL;
  1099. f->rfd4 = NULL;
  1100. f->flags = 0;
  1101. -#ifdef HAVE_IPV6
  1102. f->rfd6 = NULL;
  1103. -#endif
  1104. #ifdef HAVE_DNSSEC
  1105. f->dependent = NULL;
  1106. f->blocking_query = NULL;
  1107. @@ -2237,11 +2182,8 @@ static void free_frec(struct frec *f)
  1108. f->rfd4 = NULL;
  1109. f->sentto = NULL;
  1110. f->flags = 0;
  1111. -
  1112. -#ifdef HAVE_IPV6
  1113. free_rfd(f->rfd6);
  1114. f->rfd6 = NULL;
  1115. -#endif
  1116. #ifdef HAVE_DNSSEC
  1117. if (f->stash)
  1118. --- a/src/helper.c
  1119. +++ b/src/helper.c
  1120. @@ -64,9 +64,7 @@ struct script_data
  1121. #ifdef HAVE_TFTP
  1122. off_t file_len;
  1123. #endif
  1124. -#ifdef HAVE_IPV6
  1125. struct in6_addr addr6;
  1126. -#endif
  1127. #ifdef HAVE_DHCP6
  1128. int iaid, vendorclass_count;
  1129. #endif
  1130. @@ -302,10 +300,8 @@ int create_helper(int event_fd, int err_
  1131. if (!is6)
  1132. inet_ntop(AF_INET, &data.addr, daemon->addrbuff, ADDRSTRLEN);
  1133. -#ifdef HAVE_IPV6
  1134. else
  1135. inet_ntop(AF_INET6, &data.addr6, daemon->addrbuff, ADDRSTRLEN);
  1136. -#endif
  1137. #ifdef HAVE_TFTP
  1138. /* file length */
  1139. @@ -826,10 +822,8 @@ void queue_tftp(off_t file_len, char *fi
  1140. if ((buf->flags = peer->sa.sa_family) == AF_INET)
  1141. buf->addr = peer->in.sin_addr;
  1142. -#ifdef HAVE_IPV6
  1143. else
  1144. buf->addr6 = peer->in6.sin6_addr;
  1145. -#endif
  1146. memcpy((unsigned char *)(buf+1), filename, filename_len);
  1147. @@ -851,10 +845,8 @@ void queue_arp(int action, unsigned char
  1148. buf->hwaddr_type = ARPHRD_ETHER;
  1149. if ((buf->flags = family) == AF_INET)
  1150. buf->addr = addr->addr.addr4;
  1151. -#ifdef HAVE_IPV6
  1152. else
  1153. buf->addr6 = addr->addr.addr6;
  1154. -#endif
  1155. memcpy(buf->hwaddr, mac, maclen);
  1156. --- a/src/ipset.c
  1157. +++ b/src/ipset.c
  1158. @@ -120,13 +120,8 @@ static int new_add_to_ipset(const char *
  1159. struct my_nfgenmsg *nfg;
  1160. struct my_nlattr *nested[2];
  1161. uint8_t proto;
  1162. - int addrsz = INADDRSZ;
  1163. + int addrsz = (af == AF_INET6) ? INADDRSZ : IN6ADDRSZ;
  1164. -#ifdef HAVE_IPV6
  1165. - if (af == AF_INET6)
  1166. - addrsz = IN6ADDRSZ;
  1167. -#endif
  1168. -
  1169. if (strlen(setname) >= IPSET_MAXNAMELEN)
  1170. {
  1171. errno = ENAMETOOLONG;
  1172. @@ -213,7 +208,6 @@ int add_to_ipset(const char *setname, co
  1173. {
  1174. int ret = 0, af = AF_INET;
  1175. -#ifdef HAVE_IPV6
  1176. if (flags & F_IPV6)
  1177. {
  1178. af = AF_INET6;
  1179. @@ -224,7 +218,6 @@ int add_to_ipset(const char *setname, co
  1180. ret = -1;
  1181. }
  1182. }
  1183. -#endif
  1184. if (ret != -1)
  1185. ret = old_kernel ? old_add_to_ipset(setname, ipaddr, remove) : new_add_to_ipset(setname, ipaddr, af, remove);
  1186. --- a/src/netlink.c
  1187. +++ b/src/netlink.c
  1188. @@ -51,11 +51,10 @@ void netlink_init(void)
  1189. addr.nl_groups = RTMGRP_IPV4_ROUTE;
  1190. if (option_bool(OPT_CLEVERBIND))
  1191. addr.nl_groups |= RTMGRP_IPV4_IFADDR;
  1192. -#ifdef HAVE_IPV6
  1193. addr.nl_groups |= RTMGRP_IPV6_ROUTE;
  1194. if (option_bool(OPT_CLEVERBIND))
  1195. addr.nl_groups |= RTMGRP_IPV6_IFADDR;
  1196. -#endif
  1197. +
  1198. #ifdef HAVE_DHCP6
  1199. if (daemon->doing_ra || daemon->doing_dhcp6)
  1200. addr.nl_groups |= RTMGRP_IPV6_IFADDR;
  1201. @@ -235,7 +234,6 @@ int iface_enumerate(int family, void *pa
  1202. if (!((*callback)(addr, ifa->ifa_index, label, netmask, broadcast, parm)))
  1203. callback_ok = 0;
  1204. }
  1205. -#ifdef HAVE_IPV6
  1206. else if (ifa->ifa_family == AF_INET6)
  1207. {
  1208. struct in6_addr *addrp = NULL;
  1209. @@ -270,7 +268,6 @@ int iface_enumerate(int family, void *pa
  1210. (int) preferred, (int)valid, parm)))
  1211. callback_ok = 0;
  1212. }
  1213. -#endif
  1214. }
  1215. }
  1216. else if (h->nlmsg_type == RTM_NEWNEIGH && family == AF_UNSPEC)
  1217. --- a/src/network.c
  1218. +++ b/src/network.c
  1219. @@ -137,12 +137,10 @@ int iface_check(int family, struct all_a
  1220. if (family == AF_INET &&
  1221. tmp->addr.in.sin_addr.s_addr == addr->addr.addr4.s_addr)
  1222. ret = match_addr = tmp->used = 1;
  1223. -#ifdef HAVE_IPV6
  1224. else if (family == AF_INET6 &&
  1225. IN6_ARE_ADDR_EQUAL(&tmp->addr.in6.sin6_addr,
  1226. &addr->addr.addr6))
  1227. ret = match_addr = tmp->used = 1;
  1228. -#endif
  1229. }
  1230. }
  1231. @@ -162,11 +160,9 @@ int iface_check(int family, struct all_a
  1232. else if (addr && tmp->addr.sa.sa_family == AF_INET && family == AF_INET &&
  1233. tmp->addr.in.sin_addr.s_addr == addr->addr.addr4.s_addr)
  1234. break;
  1235. -#ifdef HAVE_IPV6
  1236. else if (addr && tmp->addr.sa.sa_family == AF_INET6 && family == AF_INET6 &&
  1237. IN6_ARE_ADDR_EQUAL(&tmp->addr.in6.sin6_addr, &addr->addr.addr6))
  1238. break;
  1239. -#endif
  1240. if (tmp && auth)
  1241. {
  1242. @@ -200,11 +196,8 @@ int loopback_exception(int fd, int famil
  1243. if (iface->addr.in.sin_addr.s_addr == addr->addr.addr4.s_addr)
  1244. return 1;
  1245. }
  1246. -#ifdef HAVE_IPV6
  1247. else if (IN6_ARE_ADDR_EQUAL(&iface->addr.in6.sin6_addr, &addr->addr.addr6))
  1248. return 1;
  1249. -#endif
  1250. -
  1251. }
  1252. }
  1253. return 0;
  1254. @@ -292,19 +285,15 @@ static int iface_allowed(struct iface_pa
  1255. al->addr.addr.addr4 = addr->in.sin_addr;
  1256. al->flags = 0;
  1257. }
  1258. -#ifdef HAVE_IPV6
  1259. else
  1260. {
  1261. al->addr.addr.addr6 = addr->in6.sin6_addr;
  1262. al->flags = ADDRLIST_IPV6;
  1263. }
  1264. -#endif
  1265. }
  1266. }
  1267. -#ifdef HAVE_IPV6
  1268. if (addr->sa.sa_family != AF_INET6 || !IN6_IS_ADDR_LINKLOCAL(&addr->in6.sin6_addr))
  1269. -#endif
  1270. {
  1271. struct interface_name *int_name;
  1272. struct addrlist *al;
  1273. @@ -337,7 +326,6 @@ static int iface_allowed(struct iface_pa
  1274. }
  1275. }
  1276. -#ifdef HAVE_IPV6
  1277. if (addr->sa.sa_family == AF_INET6 && (name->flags & AUTH6))
  1278. {
  1279. if (param->spare)
  1280. @@ -357,8 +345,6 @@ static int iface_allowed(struct iface_pa
  1281. al->flags = ADDRLIST_IPV6;
  1282. }
  1283. }
  1284. -#endif
  1285. -
  1286. }
  1287. #endif
  1288. @@ -386,7 +372,6 @@ static int iface_allowed(struct iface_pa
  1289. al->addr.addr.addr4 = addr->in.sin_addr;
  1290. al->flags = 0;
  1291. }
  1292. -#ifdef HAVE_IPV6
  1293. else
  1294. {
  1295. al->addr.addr.addr6 = addr->in6.sin6_addr;
  1296. @@ -396,7 +381,6 @@ static int iface_allowed(struct iface_pa
  1297. if (!(iface_flags & IFACE_PERMANENT) || (iface_flags & (IFACE_DEPRECATED | IFACE_TENTATIVE)))
  1298. al->flags |= ADDRLIST_REVONLY;
  1299. }
  1300. -#endif
  1301. }
  1302. }
  1303. }
  1304. @@ -438,11 +422,9 @@ static int iface_allowed(struct iface_pa
  1305. !iface_check(AF_INET, (struct all_addr *)&addr->in.sin_addr, label, &auth_dns))
  1306. return 1;
  1307. -#ifdef HAVE_IPV6
  1308. if (addr->sa.sa_family == AF_INET6 &&
  1309. !iface_check(AF_INET6, (struct all_addr *)&addr->in6.sin6_addr, label, &auth_dns))
  1310. return 1;
  1311. -#endif
  1312. #ifdef HAVE_DHCP
  1313. /* No DHCP where we're doing auth DNS. */
  1314. @@ -501,7 +483,6 @@ static int iface_allowed(struct iface_pa
  1315. return 0;
  1316. }
  1317. -#ifdef HAVE_IPV6
  1318. static int iface_allowed_v6(struct in6_addr *local, int prefix,
  1319. int scope, int if_index, int flags,
  1320. int preferred, int valid, void *vparam)
  1321. @@ -529,7 +510,6 @@ static int iface_allowed_v6(struct in6_a
  1322. return iface_allowed((struct iface_param *)vparam, if_index, NULL, &addr, netmask, prefix, flags);
  1323. }
  1324. -#endif
  1325. static int iface_allowed_v4(struct in_addr local, int if_index, char *label,
  1326. struct in_addr netmask, struct in_addr broadcast, void *vparam)
  1327. @@ -633,9 +613,7 @@ int enumerate_interfaces(int reset)
  1328. param.spare = spare;
  1329. -#ifdef HAVE_IPV6
  1330. ret = iface_enumerate(AF_INET6, &param, iface_allowed_v6);
  1331. -#endif
  1332. if (ret)
  1333. ret = iface_enumerate(AF_INET, &param, iface_allowed_v4);
  1334. @@ -740,10 +718,8 @@ static int make_sock(union mysockaddr *a
  1335. if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 || !fix_fd(fd))
  1336. goto err;
  1337. -#ifdef HAVE_IPV6
  1338. if (family == AF_INET6 && setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &opt, sizeof(opt)) == -1)
  1339. goto err;
  1340. -#endif
  1341. if ((rc = bind(fd, (struct sockaddr *)addr, sa_len(addr))) == -1)
  1342. goto err;
  1343. @@ -767,15 +743,12 @@ static int make_sock(union mysockaddr *a
  1344. #endif
  1345. }
  1346. }
  1347. -#ifdef HAVE_IPV6
  1348. else if (!set_ipv6pktinfo(fd))
  1349. goto err;
  1350. -#endif
  1351. return fd;
  1352. }
  1353. -#ifdef HAVE_IPV6
  1354. int set_ipv6pktinfo(int fd)
  1355. {
  1356. int opt = 1;
  1357. @@ -802,7 +775,6 @@ int set_ipv6pktinfo(int fd)
  1358. return 0;
  1359. }
  1360. -#endif
  1361. /* Find the interface on which a TCP connection arrived, if possible, or zero otherwise. */
  1362. @@ -842,7 +814,6 @@ int tcp_interface(int fd, int af)
  1363. }
  1364. }
  1365. }
  1366. -#ifdef HAVE_IPV6
  1367. else
  1368. {
  1369. /* Only the RFC-2292 API has the ability to find the interface for TCP connections,
  1370. @@ -874,7 +845,6 @@ int tcp_interface(int fd, int af)
  1371. }
  1372. }
  1373. }
  1374. -#endif /* IPV6 */
  1375. #endif /* Linux */
  1376. return if_index;
  1377. @@ -904,7 +874,6 @@ static struct listener *create_listeners
  1378. tftpfd = make_sock(addr, SOCK_DGRAM, dienow);
  1379. addr->in.sin_port = save;
  1380. }
  1381. -# ifdef HAVE_IPV6
  1382. else
  1383. {
  1384. short save = addr->in6.sin6_port;
  1385. @@ -912,7 +881,6 @@ static struct listener *create_listeners
  1386. tftpfd = make_sock(addr, SOCK_DGRAM, dienow);
  1387. addr->in6.sin6_port = save;
  1388. }
  1389. -# endif
  1390. }
  1391. #endif
  1392. @@ -945,11 +913,10 @@ void create_wildcard_listeners(void)
  1393. l = create_listeners(&addr, !!option_bool(OPT_TFTP), 1);
  1394. -#ifdef HAVE_IPV6
  1395. memset(&addr, 0, sizeof(addr));
  1396. -# ifdef HAVE_SOCKADDR_SA_LEN
  1397. +#ifdef HAVE_SOCKADDR_SA_LEN
  1398. addr.in6.sin6_len = sizeof(addr.in6);
  1399. -# endif
  1400. +#endif
  1401. addr.in6.sin6_family = AF_INET6;
  1402. addr.in6.sin6_addr = in6addr_any;
  1403. addr.in6.sin6_port = htons(daemon->port);
  1404. @@ -959,7 +926,6 @@ void create_wildcard_listeners(void)
  1405. l->next = l6;
  1406. else
  1407. l = l6;
  1408. -#endif
  1409. daemon->listeners = l;
  1410. }
  1411. @@ -1159,7 +1125,6 @@ int random_sock(int family)
  1412. addr.in.sin_len = sizeof(struct sockaddr_in);
  1413. #endif
  1414. }
  1415. -#ifdef HAVE_IPV6
  1416. else
  1417. {
  1418. addr.in6.sin6_addr = in6addr_any;
  1419. @@ -1168,7 +1133,6 @@ int random_sock(int family)
  1420. addr.in6.sin6_len = sizeof(struct sockaddr_in6);
  1421. #endif
  1422. }
  1423. -#endif
  1424. if (bind(fd, (struct sockaddr *)&addr, sa_len(&addr)) == 0)
  1425. return fd;
  1426. @@ -1193,10 +1157,8 @@ int local_bind(int fd, union mysockaddr
  1427. {
  1428. if (addr_copy.sa.sa_family == AF_INET)
  1429. addr_copy.in.sin_port = 0;
  1430. -#ifdef HAVE_IPV6
  1431. else
  1432. addr_copy.in6.sin6_port = 0;
  1433. -#endif
  1434. }
  1435. if (bind(fd, (struct sockaddr *)&addr_copy, sa_len(&addr_copy)) == -1)
  1436. @@ -1211,7 +1173,7 @@ int local_bind(int fd, union mysockaddr
  1437. return setsockopt(fd, IPPROTO_IP, IP_UNICAST_IF, &ifindex_opt, sizeof(ifindex_opt)) == 0;
  1438. }
  1439. #endif
  1440. -#if defined(HAVE_IPV6) && defined (IPV6_UNICAST_IF)
  1441. +#if defined (IPV6_UNICAST_IF)
  1442. if (addr_copy.sa.sa_family == AF_INET6)
  1443. {
  1444. uint32_t ifindex_opt = htonl(ifindex);
  1445. @@ -1247,12 +1209,10 @@ static struct serverfd *allocate_sfd(uni
  1446. addr->in.sin_port == htons(0))
  1447. return NULL;
  1448. -#ifdef HAVE_IPV6
  1449. if (addr->sa.sa_family == AF_INET6 &&
  1450. memcmp(&addr->in6.sin6_addr, &in6addr_any, sizeof(in6addr_any)) == 0 &&
  1451. addr->in6.sin6_port == htons(0))
  1452. return NULL;
  1453. -#endif
  1454. }
  1455. if (intname && strlen(intname) != 0)
  1456. @@ -1315,7 +1275,7 @@ void pre_allocate_sfds(void)
  1457. #endif
  1458. if ((sfd = allocate_sfd(&addr, "")))
  1459. sfd->preallocated = 1;
  1460. -#ifdef HAVE_IPV6
  1461. +
  1462. memset(&addr, 0, sizeof(addr));
  1463. addr.in6.sin6_family = AF_INET6;
  1464. addr.in6.sin6_addr = in6addr_any;
  1465. @@ -1325,7 +1285,6 @@ void pre_allocate_sfds(void)
  1466. #endif
  1467. if ((sfd = allocate_sfd(&addr, "")))
  1468. sfd->preallocated = 1;
  1469. -#endif
  1470. }
  1471. for (srv = daemon->servers; srv; srv = srv->next)
  1472. @@ -1658,7 +1617,6 @@ int reload_servers(char *fname)
  1473. source_addr.in.sin_addr.s_addr = INADDR_ANY;
  1474. source_addr.in.sin_port = htons(daemon->query_port);
  1475. }
  1476. -#ifdef HAVE_IPV6
  1477. else
  1478. {
  1479. int scope_index = 0;
  1480. @@ -1686,10 +1644,6 @@ int reload_servers(char *fname)
  1481. else
  1482. continue;
  1483. }
  1484. -#else /* IPV6 */
  1485. - else
  1486. - continue;
  1487. -#endif
  1488. add_update_server(SERV_FROM_RESOLV, &addr, &source_addr, NULL, NULL);
  1489. gotone = 1;
  1490. --- a/src/option.c
  1491. +++ b/src/option.c
  1492. @@ -764,10 +764,8 @@ static char *parse_mysockaddr(char *arg,
  1493. {
  1494. if (inet_pton(AF_INET, arg, &addr->in.sin_addr) > 0)
  1495. addr->sa.sa_family = AF_INET;
  1496. -#ifdef HAVE_IPV6
  1497. else if (inet_pton(AF_INET6, arg, &addr->in6.sin6_addr) > 0)
  1498. addr->sa.sa_family = AF_INET6;
  1499. -#endif
  1500. else
  1501. return _("bad address");
  1502. @@ -779,10 +777,8 @@ char *parse_server(char *arg, union myso
  1503. int source_port = 0, serv_port = NAMESERVER_PORT;
  1504. char *portno, *source;
  1505. char *interface_opt = NULL;
  1506. -#ifdef HAVE_IPV6
  1507. int scope_index = 0;
  1508. char *scope_id;
  1509. -#endif
  1510. if (!arg || strlen(arg) == 0)
  1511. {
  1512. @@ -800,9 +796,7 @@ char *parse_server(char *arg, union myso
  1513. !atoi_check16(portno, &serv_port))
  1514. return _("bad port");
  1515. -#ifdef HAVE_IPV6
  1516. scope_id = split_chr(arg, '%');
  1517. -#endif
  1518. if (source) {
  1519. interface_opt = split_chr(source, '@');
  1520. @@ -846,7 +840,6 @@ char *parse_server(char *arg, union myso
  1521. }
  1522. }
  1523. }
  1524. -#ifdef HAVE_IPV6
  1525. else if (inet_pton(AF_INET6, arg, &addr->in6.sin6_addr) > 0)
  1526. {
  1527. if (scope_id && (scope_index = if_nametoindex(scope_id)) == 0)
  1528. @@ -881,7 +874,6 @@ char *parse_server(char *arg, union myso
  1529. }
  1530. }
  1531. }
  1532. -#endif
  1533. else
  1534. return _("bad address");
  1535. @@ -1914,10 +1906,8 @@ static int one_opt(int option, char *arg
  1536. unhide_metas(arg);
  1537. if (inet_pton(AF_INET, arg, &new->addr.in.sin_addr) > 0)
  1538. new->addr.sa.sa_family = AF_INET;
  1539. -#ifdef HAVE_IPV6
  1540. else if (inet_pton(AF_INET6, arg, &new->addr.in6.sin6_addr) > 0)
  1541. new->addr.sa.sa_family = AF_INET6;
  1542. -#endif
  1543. else
  1544. {
  1545. char *fam = split_chr(arg, '/');
  1546. @@ -1927,10 +1917,8 @@ static int one_opt(int option, char *arg
  1547. {
  1548. if (strcmp(fam, "4") == 0)
  1549. new->addr.sa.sa_family = AF_INET;
  1550. -#ifdef HAVE_IPV6
  1551. else if (strcmp(fam, "6") == 0)
  1552. new->addr.sa.sa_family = AF_INET6;
  1553. -#endif
  1554. else
  1555. ret_err(gen_err);
  1556. }
  1557. @@ -1996,14 +1984,12 @@ static int one_opt(int option, char *arg
  1558. subnet->prefixlen = (prefixlen == 0) ? 24 : prefixlen;
  1559. subnet->flags = ADDRLIST_LITERAL;
  1560. }
  1561. -#ifdef HAVE_IPV6
  1562. else if (inet_pton(AF_INET6, arg, &addr.addr.addr6))
  1563. {
  1564. subnet = opt_malloc(sizeof(struct addrlist));
  1565. subnet->prefixlen = (prefixlen == 0) ? 64 : prefixlen;
  1566. subnet->flags = ADDRLIST_LITERAL | ADDRLIST_IPV6;
  1567. }
  1568. -#endif
  1569. else
  1570. {
  1571. struct auth_name_list *name = opt_malloc(sizeof(struct auth_name_list));
  1572. @@ -2015,10 +2001,8 @@ static int one_opt(int option, char *arg
  1573. {
  1574. if (prefixlen == 4)
  1575. name->flags &= ~AUTH6;
  1576. -#ifdef HAVE_IPV6
  1577. else if (prefixlen == 6)
  1578. name->flags &= ~AUTH4;
  1579. -#endif
  1580. else
  1581. ret_err(gen_err);
  1582. }
  1583. @@ -2139,7 +2123,6 @@ static int one_opt(int option, char *arg
  1584. }
  1585. }
  1586. }
  1587. -#ifdef HAVE_IPV6
  1588. else if (inet_pton(AF_INET6, comma, &new->start6))
  1589. {
  1590. u64 mask = (1LLU << (128 - msize)) - 1LLU;
  1591. @@ -2183,7 +2166,6 @@ static int one_opt(int option, char *arg
  1592. }
  1593. }
  1594. }
  1595. -#endif
  1596. else
  1597. ret_err(gen_err);
  1598. }
  1599. @@ -2201,7 +2183,6 @@ static int one_opt(int option, char *arg
  1600. else if (!inet_pton(AF_INET, arg, &new->end))
  1601. ret_err(gen_err);
  1602. }
  1603. -#ifdef HAVE_IPV6
  1604. else if (inet_pton(AF_INET6, comma, &new->start6))
  1605. {
  1606. new->is6 = 1;
  1607. @@ -2210,7 +2191,6 @@ static int one_opt(int option, char *arg
  1608. else if (!inet_pton(AF_INET6, arg, &new->end6))
  1609. ret_err(gen_err);
  1610. }
  1611. -#endif
  1612. else
  1613. ret_err(gen_err);
  1614. @@ -2369,7 +2349,6 @@ static int one_opt(int option, char *arg
  1615. new->addr.in.sin_len = sizeof(new->addr.in);
  1616. #endif
  1617. }
  1618. -#ifdef HAVE_IPV6
  1619. else if (arg && inet_pton(AF_INET6, arg, &new->addr.in6.sin6_addr) > 0)
  1620. {
  1621. new->addr.sa.sa_family = AF_INET6;
  1622. @@ -2380,7 +2359,6 @@ static int one_opt(int option, char *arg
  1623. new->addr.in6.sin6_len = sizeof(new->addr.in6);
  1624. #endif
  1625. }
  1626. -#endif
  1627. else
  1628. ret_err(gen_err);
  1629. @@ -2493,9 +2471,7 @@ static int one_opt(int option, char *arg
  1630. int size;
  1631. struct server *serv;
  1632. struct in_addr addr4;
  1633. -#ifdef HAVE_IPV6
  1634. struct in6_addr addr6;
  1635. -#endif
  1636. unhide_metas(arg);
  1637. if (!arg || !(comma=split(arg)) || !(string = split_chr(arg, '/')) || !atoi_check(string, &size))
  1638. @@ -2507,10 +2483,8 @@ static int one_opt(int option, char *arg
  1639. if (!serv)
  1640. ret_err(_("bad prefix"));
  1641. }
  1642. -#ifdef HAVE_IPV6
  1643. else if (inet_pton(AF_INET6, arg, &addr6))
  1644. serv = add_rev6(&addr6, size);
  1645. -#endif
  1646. else
  1647. ret_err(gen_err);
  1648. @@ -3863,10 +3837,8 @@ err:
  1649. {
  1650. if (strcmp(arg, "4") == 0)
  1651. new->family = AF_INET;
  1652. -#ifdef HAVE_IPV6
  1653. else if (strcmp(arg, "6") == 0)
  1654. new->family = AF_INET6;
  1655. -#endif
  1656. else
  1657. ret_err(gen_err);
  1658. }
  1659. @@ -4156,10 +4128,8 @@ err:
  1660. new->ttl = atoi(arg);
  1661. else if (inet_pton(AF_INET, arg, &addr))
  1662. new->addr = addr.addr.addr4;
  1663. -#ifdef HAVE_IPV6
  1664. else if (inet_pton(AF_INET6, arg, &addr))
  1665. new->addr6 = addr.addr.addr6;
  1666. -#endif
  1667. else
  1668. {
  1669. int nomem;
  1670. @@ -4866,10 +4836,8 @@ void read_opts(int argc, char **argv, ch
  1671. {
  1672. if (tmp->source_addr.sa.sa_family == AF_INET)
  1673. tmp->source_addr.in.sin_port = htons(daemon->query_port);
  1674. -#ifdef HAVE_IPV6
  1675. else if (tmp->source_addr.sa.sa_family == AF_INET6)
  1676. tmp->source_addr.in6.sin6_port = htons(daemon->query_port);
  1677. -#endif
  1678. }
  1679. }
  1680. @@ -4930,10 +4898,8 @@ void read_opts(int argc, char **argv, ch
  1681. for(tmp = daemon->if_addrs; tmp; tmp = tmp->next)
  1682. if (tmp->addr.sa.sa_family == AF_INET)
  1683. tmp->addr.in.sin_port = htons(daemon->port);
  1684. -#ifdef HAVE_IPV6
  1685. else if (tmp->addr.sa.sa_family == AF_INET6)
  1686. tmp->addr.in6.sin6_port = htons(daemon->port);
  1687. -#endif /* IPv6 */
  1688. }
  1689. /* create default, if not specified */
  1690. --- a/src/rfc1035.c
  1691. +++ b/src/rfc1035.c
  1692. @@ -198,7 +198,6 @@ int in_arpa_name_2_addr(char *namein, st
  1693. return F_IPV4;
  1694. }
  1695. -#ifdef HAVE_IPV6
  1696. else if (hostname_isequal(penchunk, "ip6") &&
  1697. (hostname_isequal(lastchunk, "int") || hostname_isequal(lastchunk, "arpa")))
  1698. {
  1699. @@ -243,7 +242,6 @@ int in_arpa_name_2_addr(char *namein, st
  1700. return F_IPV6;
  1701. }
  1702. }
  1703. -#endif
  1704. return 0;
  1705. }
  1706. @@ -426,7 +424,6 @@ int private_net(struct in_addr addr, int
  1707. ((ip_addr & 0xFFFFFFFF) == 0xFFFFFFFF) /* 255.255.255.255/32 (broadcast)*/ ;
  1708. }
  1709. -#ifdef HAVE_IPV6
  1710. static int private_net6(struct in6_addr *a)
  1711. {
  1712. return
  1713. @@ -436,8 +433,6 @@ static int private_net6(struct in6_addr
  1714. ((unsigned char *)a)[0] == 0xfd || /* RFC 6303 4.4 */
  1715. ((u32 *)a)[0] == htonl(0x20010db8); /* RFC 6303 4.6 */
  1716. }
  1717. -#endif
  1718. -
  1719. static unsigned char *do_doctor(unsigned char *p, int count, struct dns_header *header, size_t qlen, char *name, int *doctored)
  1720. {
  1721. @@ -738,13 +733,11 @@ int extract_addresses(struct dns_header
  1722. addrlen = INADDRSZ;
  1723. flags |= F_IPV4;
  1724. }
  1725. -#ifdef HAVE_IPV6
  1726. else if (qtype == T_AAAA)
  1727. {
  1728. addrlen = IN6ADDRSZ;
  1729. flags |= F_IPV6;
  1730. }
  1731. -#endif
  1732. else
  1733. continue;
  1734. @@ -818,7 +811,6 @@ int extract_addresses(struct dns_header
  1735. private_net(addr.addr.addr4, !option_bool(OPT_LOCAL_REBIND)))
  1736. return 1;
  1737. -#ifdef HAVE_IPV6
  1738. if ((flags & F_IPV6) &&
  1739. IN6_IS_ADDR_V4MAPPED(&addr.addr.addr6))
  1740. {
  1741. @@ -827,7 +819,6 @@ int extract_addresses(struct dns_header
  1742. if (private_net(v4, !option_bool(OPT_LOCAL_REBIND)))
  1743. return 1;
  1744. }
  1745. -#endif
  1746. }
  1747. #ifdef HAVE_IPSET
  1748. @@ -966,7 +957,6 @@ size_t setup_reply(struct dns_header *he
  1749. add_resource_record(header, NULL, NULL, sizeof(struct dns_header), &p, ttl, NULL, T_A, C_IN, "4", addrp);
  1750. }
  1751. -#ifdef HAVE_IPV6
  1752. if (flags & F_IPV6)
  1753. {
  1754. SET_RCODE(header, NOERROR);
  1755. @@ -974,7 +964,6 @@ size_t setup_reply(struct dns_header *he
  1756. header->hb3 |= HB3_AA;
  1757. add_resource_record(header, NULL, NULL, sizeof(struct dns_header), &p, ttl, NULL, T_AAAA, C_IN, "6", addrp);
  1758. }
  1759. -#endif
  1760. }
  1761. else /* nowhere to forward to */
  1762. {
  1763. @@ -1164,14 +1153,12 @@ int add_resource_record(struct dns_heade
  1764. for (; *format; format++)
  1765. switch (*format)
  1766. {
  1767. -#ifdef HAVE_IPV6
  1768. case '6':
  1769. CHECK_LIMIT(IN6ADDRSZ);
  1770. sval = va_arg(ap, char *);
  1771. memcpy(p, sval, IN6ADDRSZ);
  1772. p += IN6ADDRSZ;
  1773. break;
  1774. -#endif
  1775. case '4':
  1776. CHECK_LIMIT(INADDRSZ);
  1777. @@ -1413,7 +1400,6 @@ size_t answer_request(struct dns_header
  1778. while (intr->next && strcmp(intr->intr, intr->next->intr) == 0)
  1779. intr = intr->next;
  1780. }
  1781. -#ifdef HAVE_IPV6
  1782. else if (is_arpa == F_IPV6)
  1783. for (intr = daemon->int_names; intr; intr = intr->next)
  1784. {
  1785. @@ -1429,7 +1415,6 @@ size_t answer_request(struct dns_header
  1786. while (intr->next && strcmp(intr->intr, intr->next->intr) == 0)
  1787. intr = intr->next;
  1788. }
  1789. -#endif
  1790. if (intr)
  1791. {
  1792. @@ -1521,9 +1506,7 @@ size_t answer_request(struct dns_header
  1793. }
  1794. }
  1795. else if (option_bool(OPT_BOGUSPRIV) && (
  1796. -#ifdef HAVE_IPV6
  1797. (is_arpa == F_IPV6 && private_net6(&addr.addr.addr6)) ||
  1798. -#endif
  1799. (is_arpa == F_IPV4 && private_net(addr.addr.addr4, 1))))
  1800. {
  1801. struct server *serv;
  1802. @@ -1564,16 +1547,9 @@ size_t answer_request(struct dns_header
  1803. for (flag = F_IPV4; flag; flag = (flag == F_IPV4) ? F_IPV6 : 0)
  1804. {
  1805. - unsigned short type = T_A;
  1806. + unsigned short type = (flag == F_IPV6) ? T_AAAA : T_A;
  1807. struct interface_name *intr;
  1808. - if (flag == F_IPV6)
  1809. -#ifdef HAVE_IPV6
  1810. - type = T_AAAA;
  1811. -#else
  1812. - break;
  1813. -#endif
  1814. -
  1815. if (qtype != type && qtype != T_ANY)
  1816. continue;
  1817. @@ -1596,31 +1572,26 @@ size_t answer_request(struct dns_header
  1818. for (intr = daemon->int_names; intr; intr = intr->next)
  1819. if (hostname_isequal(name, intr->name))
  1820. for (addrlist = intr->addr; addrlist; addrlist = addrlist->next)
  1821. -#ifdef HAVE_IPV6
  1822. - if (!(addrlist->flags & ADDRLIST_IPV6))
  1823. -#endif
  1824. - if (is_same_net(*((struct in_addr *)&addrlist->addr), local_addr, local_netmask))
  1825. - {
  1826. - localise = 1;
  1827. - break;
  1828. - }
  1829. + if (!(addrlist->flags & ADDRLIST_IPV6) &&
  1830. + is_same_net(*((struct in_addr *)&addrlist->addr), local_addr, local_netmask))
  1831. + {
  1832. + localise = 1;
  1833. + break;
  1834. + }
  1835. for (intr = daemon->int_names; intr; intr = intr->next)
  1836. if (hostname_isequal(name, intr->name))
  1837. {
  1838. for (addrlist = intr->addr; addrlist; addrlist = addrlist->next)
  1839. -#ifdef HAVE_IPV6
  1840. if (((addrlist->flags & ADDRLIST_IPV6) ? T_AAAA : T_A) == type)
  1841. -#endif
  1842. {
  1843. if (localise &&
  1844. !is_same_net(*((struct in_addr *)&addrlist->addr), local_addr, local_netmask))
  1845. continue;
  1846. -#ifdef HAVE_IPV6
  1847. if (addrlist->flags & ADDRLIST_REVONLY)
  1848. continue;
  1849. -#endif
  1850. +
  1851. ans = 1;
  1852. sec_data = 0;
  1853. if (!dryrun)
  1854. @@ -1904,11 +1875,8 @@ size_t answer_request(struct dns_header
  1855. crecp = NULL;
  1856. while ((crecp = cache_find_by_name(crecp, rec->target, now, F_IPV4 | F_IPV6)))
  1857. {
  1858. -#ifdef HAVE_IPV6
  1859. int type = crecp->flags & F_IPV4 ? T_A : T_AAAA;
  1860. -#else
  1861. - int type = T_A;
  1862. -#endif
  1863. +
  1864. if (crecp->flags & F_NEG)
  1865. continue;
  1866. --- a/src/tables.c
  1867. +++ b/src/tables.c
  1868. @@ -108,7 +108,7 @@ int add_to_ipset(const char *setname, co
  1869. my_syslog(LOG_INFO, _("info: table created"));
  1870. bzero(&addr, sizeof(addr));
  1871. -#ifdef HAVE_IPV6
  1872. +
  1873. if (flags & F_IPV6)
  1874. {
  1875. addr.pfra_af = AF_INET6;
  1876. @@ -116,7 +116,6 @@ int add_to_ipset(const char *setname, co
  1877. memcpy(&(addr.pfra_ip6addr), &(ipaddr->addr), sizeof(struct in6_addr));
  1878. }
  1879. else
  1880. -#endif
  1881. {
  1882. addr.pfra_af = AF_INET;
  1883. addr.pfra_net = 0x20;
  1884. --- a/src/tftp.c
  1885. +++ b/src/tftp.c
  1886. @@ -60,17 +60,11 @@ void tftp_request(struct listener *liste
  1887. char *prefix = daemon->tftp_prefix;
  1888. struct tftp_prefix *pref;
  1889. struct all_addr addra;
  1890. -#ifdef HAVE_IPV6
  1891. /* Can always get recvd interface for IPv6 */
  1892. int check_dest = !option_bool(OPT_NOWILD) || listen->family == AF_INET6;
  1893. -#else
  1894. - int check_dest = !option_bool(OPT_NOWILD);
  1895. -#endif
  1896. union {
  1897. struct cmsghdr align; /* this ensures alignment */
  1898. -#ifdef HAVE_IPV6
  1899. char control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
  1900. -#endif
  1901. #if defined(HAVE_LINUX_NETWORK)
  1902. char control[CMSG_SPACE(sizeof(struct in_pktinfo))];
  1903. #elif defined(HAVE_SOLARIS_NETWORK)
  1904. @@ -174,7 +168,6 @@ void tftp_request(struct listener *liste
  1905. #endif
  1906. -#ifdef HAVE_IPV6
  1907. if (listen->family == AF_INET6)
  1908. {
  1909. for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
  1910. @@ -190,7 +183,6 @@ void tftp_request(struct listener *liste
  1911. if_index = p.p->ipi6_ifindex;
  1912. }
  1913. }
  1914. -#endif
  1915. if (!indextoname(listen->tftpfd, if_index, namebuff))
  1916. return;
  1917. @@ -199,10 +191,8 @@ void tftp_request(struct listener *liste
  1918. addra.addr.addr4 = addr.in.sin_addr;
  1919. -#ifdef HAVE_IPV6
  1920. if (listen->family == AF_INET6)
  1921. addra.addr.addr6 = addr.in6.sin6_addr;
  1922. -#endif
  1923. if (daemon->tftp_interfaces)
  1924. {
  1925. @@ -262,7 +252,6 @@ void tftp_request(struct listener *liste
  1926. addr.in.sin_len = sizeof(addr.in);
  1927. #endif
  1928. }
  1929. -#ifdef HAVE_IPV6
  1930. else
  1931. {
  1932. addr.in6.sin6_port = htons(port);
  1933. @@ -272,7 +261,6 @@ void tftp_request(struct listener *liste
  1934. addr.in6.sin6_len = sizeof(addr.in6);
  1935. #endif
  1936. }
  1937. -#endif
  1938. if (!(transfer = whine_malloc(sizeof(struct tftp_transfer))))
  1939. return;
  1940. @@ -310,10 +298,9 @@ void tftp_request(struct listener *liste
  1941. {
  1942. if (listen->family == AF_INET)
  1943. addr.in.sin_port = htons(port);
  1944. -#ifdef HAVE_IPV6
  1945. else
  1946. - addr.in6.sin6_port = htons(port);
  1947. -#endif
  1948. + addr.in6.sin6_port = htons(port);
  1949. +
  1950. continue;
  1951. }
  1952. my_syslog(MS_TFTP | LOG_ERR, _("unable to get free port for TFTP"));
  1953. --- a/src/util.c
  1954. +++ b/src/util.c
  1955. @@ -320,13 +320,12 @@ int sockaddr_isequal(union mysockaddr *s
  1956. s1->in.sin_port == s2->in.sin_port &&
  1957. s1->in.sin_addr.s_addr == s2->in.sin_addr.s_addr)
  1958. return 1;
  1959. -#ifdef HAVE_IPV6
  1960. +
  1961. if (s1->sa.sa_family == AF_INET6 &&
  1962. s1->in6.sin6_port == s2->in6.sin6_port &&
  1963. s1->in6.sin6_scope_id == s2->in6.sin6_scope_id &&
  1964. IN6_ARE_ADDR_EQUAL(&s1->in6.sin6_addr, &s2->in6.sin6_addr))
  1965. return 1;
  1966. -#endif
  1967. }
  1968. return 0;
  1969. }
  1970. @@ -336,11 +335,9 @@ int sa_len(union mysockaddr *addr)
  1971. #ifdef HAVE_SOCKADDR_SA_LEN
  1972. return addr->sa.sa_len;
  1973. #else
  1974. -#ifdef HAVE_IPV6
  1975. if (addr->sa.sa_family == AF_INET6)
  1976. return sizeof(addr->in6);
  1977. else
  1978. -#endif
  1979. return sizeof(addr->in);
  1980. #endif
  1981. }
  1982. @@ -437,7 +434,6 @@ int is_same_net(struct in_addr a, struct
  1983. return (a.s_addr & mask.s_addr) == (b.s_addr & mask.s_addr);
  1984. }
  1985. -#ifdef HAVE_IPV6
  1986. int is_same_net6(struct in6_addr *a, struct in6_addr *b, int prefixlen)
  1987. {
  1988. int pfbytes = prefixlen >> 3;
  1989. @@ -476,15 +472,12 @@ void setaddr6part(struct in6_addr *addr,
  1990. }
  1991. }
  1992. -#endif
  1993. -
  1994. /* returns port number from address */
  1995. int prettyprint_addr(union mysockaddr *addr, char *buf)
  1996. {
  1997. int port = 0;
  1998. -#ifdef HAVE_IPV6
  1999. if (addr->sa.sa_family == AF_INET)
  2000. {
  2001. inet_ntop(AF_INET, &addr->in.sin_addr, buf, ADDRSTRLEN);
  2002. @@ -503,10 +496,6 @@ int prettyprint_addr(union mysockaddr *a
  2003. }
  2004. port = ntohs(addr->in6.sin6_port);
  2005. }
  2006. -#else
  2007. - strcpy(buf, inet_ntoa(addr->in.sin_addr));
  2008. - port = ntohs(addr->in.sin_port);
  2009. -#endif
  2010. return port;
  2011. }