360e8a4c04c644416252561eaa452128b2850945
[openwrt/staging/stintel.git] /
1 From cc921df9ceac79acf9f1c477d015a3d88275422d Mon Sep 17 00:00:00 2001
2 From: Simon Kelley <simon@thekelleys.org.uk>
3 Date: Wed, 2 Jan 2019 22:48:59 +0000
4 Subject: [PATCH 21/32] Remove nested struct/union in cache records and
5 all_addr.
6
7 Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
8 ---
9 src/arp.c | 18 ++++-----
10 src/auth.c | 36 ++++++++---------
11 src/bpf.c | 10 ++---
12 src/cache.c | 98 +++++++++++++++++++++++-----------------------
13 src/conntrack.c | 6 +--
14 src/dbus.c | 24 ++++++------
15 src/dhcp-common.c | 14 +++----
16 src/dhcp.c | 20 +++++-----
17 src/dhcp6.c | 2 +-
18 src/dnsmasq.c | 6 +--
19 src/dnsmasq.h | 99 ++++++++++++++++++++++++-----------------------
20 src/dnssec.c | 56 +++++++++++++--------------
21 src/domain.c | 32 +++++++--------
22 src/forward.c | 88 ++++++++++++++++++++---------------------
23 src/helper.c | 6 +--
24 src/ipset.c | 10 ++---
25 src/lease.c | 22 +++++------
26 src/network.c | 36 ++++++++---------
27 src/option.c | 16 ++++----
28 src/rfc1035.c | 46 +++++++++++-----------
29 src/rfc3315.c | 12 +++---
30 src/tables.c | 6 +--
31 src/tftp.c | 8 ++--
32 23 files changed, 336 insertions(+), 335 deletions(-)
33
34 --- a/src/arp.c
35 +++ b/src/arp.c
36 @@ -28,7 +28,7 @@ struct arp_record {
37 unsigned short hwlen, status;
38 int family;
39 unsigned char hwaddr[DHCP_CHADDR_MAX];
40 - struct all_addr addr;
41 + union all_addr addr;
42 struct arp_record *next;
43 };
44
45 @@ -52,12 +52,12 @@ static int filter_mac(int family, char *
46
47 if (family == AF_INET)
48 {
49 - if (arp->addr.addr.addr4.s_addr != ((struct in_addr *)addrp)->s_addr)
50 + if (arp->addr.addr4.s_addr != ((struct in_addr *)addrp)->s_addr)
51 continue;
52 }
53 else
54 {
55 - if (!IN6_ARE_ADDR_EQUAL(&arp->addr.addr.addr6, (struct in6_addr *)addrp))
56 + if (!IN6_ARE_ADDR_EQUAL(&arp->addr.addr6, (struct in6_addr *)addrp))
57 continue;
58 }
59
60 @@ -95,9 +95,9 @@ static int filter_mac(int family, char *
61 arp->family = family;
62 memcpy(arp->hwaddr, mac, maclen);
63 if (family == AF_INET)
64 - arp->addr.addr.addr4.s_addr = ((struct in_addr *)addrp)->s_addr;
65 + arp->addr.addr4.s_addr = ((struct in_addr *)addrp)->s_addr;
66 else
67 - memcpy(&arp->addr.addr.addr6, addrp, IN6ADDRSZ);
68 + memcpy(&arp->addr.addr6, addrp, IN6ADDRSZ);
69 }
70
71 return 1;
72 @@ -124,11 +124,11 @@ int find_mac(union mysockaddr *addr, uns
73 continue;
74
75 if (arp->family == AF_INET &&
76 - arp->addr.addr.addr4.s_addr != addr->in.sin_addr.s_addr)
77 + arp->addr.addr4.s_addr != addr->in.sin_addr.s_addr)
78 continue;
79
80 if (arp->family == AF_INET6 &&
81 - !IN6_ARE_ADDR_EQUAL(&arp->addr.addr.addr6, &addr->in6.sin6_addr))
82 + !IN6_ARE_ADDR_EQUAL(&arp->addr.addr6, &addr->in6.sin6_addr))
83 continue;
84
85 /* Only accept positive entries unless in lazy mode. */
86 @@ -191,9 +191,9 @@ int find_mac(union mysockaddr *addr, uns
87 arp->hwlen = 0;
88
89 if (addr->sa.sa_family == AF_INET)
90 - arp->addr.addr.addr4.s_addr = addr->in.sin_addr.s_addr;
91 + arp->addr.addr4.s_addr = addr->in.sin_addr.s_addr;
92 else
93 - memcpy(&arp->addr.addr.addr6, &addr->in6.sin6_addr, IN6ADDRSZ);
94 + memcpy(&arp->addr.addr6, &addr->in6.sin6_addr, IN6ADDRSZ);
95 }
96
97 return 0;
98 --- a/src/auth.c
99 +++ b/src/auth.c
100 @@ -18,22 +18,22 @@
101
102 #ifdef HAVE_AUTH
103
104 -static struct addrlist *find_addrlist(struct addrlist *list, int flag, struct all_addr *addr_u)
105 +static struct addrlist *find_addrlist(struct addrlist *list, int flag, union all_addr *addr_u)
106 {
107 do {
108 if (!(list->flags & ADDRLIST_IPV6))
109 {
110 - struct in_addr netmask, addr = addr_u->addr.addr4;
111 + struct in_addr netmask, addr = addr_u->addr4;
112
113 if (!(flag & F_IPV4))
114 continue;
115
116 netmask.s_addr = htonl(~(in_addr_t)0 << (32 - list->prefixlen));
117
118 - if (is_same_net(addr, list->addr.addr.addr4, netmask))
119 + if (is_same_net(addr, list->addr.addr4, netmask))
120 return list;
121 }
122 - else if (is_same_net6(&(addr_u->addr.addr6), &list->addr.addr.addr6, list->prefixlen))
123 + else if (is_same_net6(&(addr_u->addr6), &list->addr.addr6, list->prefixlen))
124 return list;
125
126 } while ((list = list->next));
127 @@ -41,7 +41,7 @@ static struct addrlist *find_addrlist(st
128 return NULL;
129 }
130
131 -static struct addrlist *find_subnet(struct auth_zone *zone, int flag, struct all_addr *addr_u)
132 +static struct addrlist *find_subnet(struct auth_zone *zone, int flag, union all_addr *addr_u)
133 {
134 if (!zone->subnet)
135 return NULL;
136 @@ -49,7 +49,7 @@ static struct addrlist *find_subnet(stru
137 return find_addrlist(zone->subnet, flag, addr_u);
138 }
139
140 -static struct addrlist *find_exclude(struct auth_zone *zone, int flag, struct all_addr *addr_u)
141 +static struct addrlist *find_exclude(struct auth_zone *zone, int flag, union all_addr *addr_u)
142 {
143 if (!zone->exclude)
144 return NULL;
145 @@ -57,7 +57,7 @@ static struct addrlist *find_exclude(str
146 return find_addrlist(zone->exclude, flag, addr_u);
147 }
148
149 -static int filter_zone(struct auth_zone *zone, int flag, struct all_addr *addr_u)
150 +static int filter_zone(struct auth_zone *zone, int flag, union all_addr *addr_u)
151 {
152 if (find_exclude(zone, flag, addr_u))
153 return 0;
154 @@ -113,7 +113,7 @@ size_t answer_auth(struct dns_header *he
155 struct txt_record *txt;
156 struct interface_name *intr;
157 struct naptr *na;
158 - struct all_addr addr;
159 + union all_addr addr;
160 struct cname *a, *candidate;
161 unsigned int wclen;
162
163 @@ -178,7 +178,7 @@ size_t answer_auth(struct dns_header *he
164 struct addrlist *addrlist;
165
166 for (addrlist = intr->addr; addrlist; addrlist = addrlist->next)
167 - if (!(addrlist->flags & ADDRLIST_IPV6) && addr.addr.addr4.s_addr == addrlist->addr.addr.addr4.s_addr)
168 + if (!(addrlist->flags & ADDRLIST_IPV6) && addr.addr4.s_addr == addrlist->addr.addr4.s_addr)
169 break;
170
171 if (addrlist)
172 @@ -193,7 +193,7 @@ size_t answer_auth(struct dns_header *he
173 struct addrlist *addrlist;
174
175 for (addrlist = intr->addr; addrlist; addrlist = addrlist->next)
176 - if ((addrlist->flags & ADDRLIST_IPV6) && IN6_ARE_ADDR_EQUAL(&addr.addr.addr6, &addrlist->addr.addr.addr6))
177 + if ((addrlist->flags & ADDRLIST_IPV6) && IN6_ARE_ADDR_EQUAL(&addr.addr6, &addrlist->addr.addr6))
178 break;
179
180 if (addrlist)
181 @@ -468,10 +468,10 @@ size_t answer_auth(struct dns_header *he
182 {
183 nxdomain = 0;
184 if ((crecp->flags & flag) &&
185 - (local_query || filter_zone(zone, flag, &(crecp->addr.addr))))
186 + (local_query || filter_zone(zone, flag, &(crecp->addr))))
187 {
188 *cut = '.'; /* restore domain part */
189 - log_query(crecp->flags, name, &crecp->addr.addr, record_source(crecp->uid));
190 + log_query(crecp->flags, name, &crecp->addr, record_source(crecp->uid));
191 *cut = 0; /* remove domain part */
192 found = 1;
193 if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
194 @@ -491,9 +491,9 @@ size_t answer_auth(struct dns_header *he
195 do
196 {
197 nxdomain = 0;
198 - if ((crecp->flags & flag) && (local_query || filter_zone(zone, flag, &(crecp->addr.addr))))
199 + if ((crecp->flags & flag) && (local_query || filter_zone(zone, flag, &(crecp->addr))))
200 {
201 - log_query(crecp->flags, name, &crecp->addr.addr, record_source(crecp->uid));
202 + log_query(crecp->flags, name, &crecp->addr, record_source(crecp->uid));
203 found = 1;
204 if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
205 daemon->auth_ttl, NULL, qtype, C_IN,
206 @@ -580,7 +580,7 @@ size_t answer_auth(struct dns_header *he
207
208 if (!(subnet->flags & ADDRLIST_IPV6))
209 {
210 - in_addr_t a = ntohl(subnet->addr.addr.addr4.s_addr) >> 8;
211 + in_addr_t a = ntohl(subnet->addr.addr4.s_addr) >> 8;
212 char *p = name;
213
214 if (subnet->prefixlen >= 24)
215 @@ -599,7 +599,7 @@ size_t answer_auth(struct dns_header *he
216
217 for (i = subnet->prefixlen-1; i >= 0; i -= 4)
218 {
219 - int dig = ((unsigned char *)&subnet->addr.addr.addr6)[i>>3];
220 + int dig = ((unsigned char *)&subnet->addr.addr6)[i>>3];
221 p += sprintf(p, "%.1x.", (i>>2) & 1 ? dig & 15 : dig >> 4);
222 }
223 p += sprintf(p, "ip6.arpa");
224 @@ -783,7 +783,7 @@ size_t answer_auth(struct dns_header *he
225 {
226 char *cache_name = cache_get_name(crecp);
227 if (!strchr(cache_name, '.') &&
228 - (local_query || filter_zone(zone, (crecp->flags & (F_IPV6 | F_IPV4)), &(crecp->addr.addr))) &&
229 + (local_query || filter_zone(zone, (crecp->flags & (F_IPV6 | F_IPV4)), &(crecp->addr))) &&
230 add_resource_record(header, limit, &trunc, -axfroffset, &ansp,
231 daemon->auth_ttl, NULL, (crecp->flags & F_IPV6) ? T_AAAA : T_A, C_IN,
232 (crecp->flags & F_IPV4) ? "4" : "6", cache_name, &crecp->addr))
233 @@ -794,7 +794,7 @@ size_t answer_auth(struct dns_header *he
234 {
235 strcpy(name, cache_get_name(crecp));
236 if (in_zone(zone, name, &cut) &&
237 - (local_query || filter_zone(zone, (crecp->flags & (F_IPV6 | F_IPV4)), &(crecp->addr.addr))))
238 + (local_query || filter_zone(zone, (crecp->flags & (F_IPV6 | F_IPV4)), &(crecp->addr))))
239 {
240 if (cut)
241 *cut = 0;
242 --- a/src/bpf.c
243 +++ b/src/bpf.c
244 @@ -42,7 +42,7 @@
245
246 #ifdef HAVE_BSD_NETWORK
247 static int del_family = 0;
248 -static struct all_addr del_addr;
249 +static union all_addr del_addr;
250 #endif
251
252 #if defined(HAVE_BSD_NETWORK) && !defined(__APPLE__)
253 @@ -139,7 +139,7 @@ int iface_enumerate(int family, void *pa
254 struct in_addr addr, netmask, broadcast;
255 addr = ((struct sockaddr_in *) addrs->ifa_addr)->sin_addr;
256 #ifdef HAVE_BSD_NETWORK
257 - if (del_family == AF_INET && del_addr.addr.addr4.s_addr == addr.s_addr)
258 + if (del_family == AF_INET && del_addr.addr4.s_addr == addr.s_addr)
259 continue;
260 #endif
261 netmask = ((struct sockaddr_in *) addrs->ifa_netmask)->sin_addr;
262 @@ -159,7 +159,7 @@ int iface_enumerate(int family, void *pa
263 u32 valid = 0xffffffff, preferred = 0xffffffff;
264 int flags = 0;
265 #ifdef HAVE_BSD_NETWORK
266 - if (del_family == AF_INET6 && IN6_ARE_ADDR_EQUAL(&del_addr.addr.addr6, addr))
267 + if (del_family == AF_INET6 && IN6_ARE_ADDR_EQUAL(&del_addr.addr6, addr))
268 continue;
269 #endif
270 #if defined(HAVE_BSD_NETWORK) && !defined(__APPLE__)
271 @@ -422,9 +422,9 @@ void route_sock(void)
272 {
273 del_family = sa->sa_family;
274 if (del_family == AF_INET)
275 - del_addr.addr.addr4 = ((struct sockaddr_in *)sa)->sin_addr;
276 + del_addr.addr4 = ((struct sockaddr_in *)sa)->sin_addr;
277 else if (del_family == AF_INET6)
278 - del_addr.addr.addr6 = ((struct sockaddr_in6 *)sa)->sin6_addr;
279 + del_addr.addr6 = ((struct sockaddr_in6 *)sa)->sin6_addr;
280 else
281 del_family = 0;
282 }
283 --- a/src/cache.c
284 +++ b/src/cache.c
285 @@ -26,7 +26,7 @@ static union bigname *big_free = NULL;
286 static int bignames_left, hash_size;
287
288 static void make_non_terminals(struct crec *source);
289 -static struct crec *really_insert(char *name, struct all_addr *addr, unsigned short class,
290 +static struct crec *really_insert(char *name, union all_addr *addr, unsigned short class,
291 time_t now, unsigned long ttl, unsigned short flags);
292
293 /* type->string mapping: this is also used by the name-hash function as a mixing table. */
294 @@ -202,9 +202,9 @@ static void cache_hash(struct crec *crec
295 static void cache_blockdata_free(struct crec *crecp)
296 {
297 if (crecp->flags & F_DNSKEY)
298 - blockdata_free(crecp->addr.addr.addr.key.keydata);
299 + blockdata_free(crecp->addr.key.keydata);
300 else if ((crecp->flags & F_DS) && !(crecp->flags & F_NEG))
301 - blockdata_free(crecp->addr.addr.addr.ds.keydata);
302 + blockdata_free(crecp->addr.ds.keydata);
303 }
304 #endif
305
306 @@ -330,7 +330,7 @@ static int is_expired(time_t now, struct
307 return 1;
308 }
309
310 -static struct crec *cache_scan_free(char *name, struct all_addr *addr, unsigned short class, time_t now,
311 +static struct crec *cache_scan_free(char *name, union all_addr *addr, unsigned short class, time_t now,
312 unsigned short flags, struct crec **target_crec, unsigned int *target_uid)
313 {
314 /* Scan and remove old entries.
315 @@ -430,7 +430,7 @@ static struct crec *cache_scan_free(char
316 else if (!(crecp->flags & (F_HOSTS | F_DHCP | F_CONFIG)) &&
317 (flags & crecp->flags & F_REVERSE) &&
318 (flags & crecp->flags & (F_IPV4 | F_IPV6)) &&
319 - memcmp(&crecp->addr.addr, addr, addrlen) == 0)
320 + memcmp(&crecp->addr, addr, addrlen) == 0)
321 {
322 *up = crecp->hash_next;
323 cache_unlink(crecp);
324 @@ -466,7 +466,7 @@ void cache_start_insert(void)
325 insert_error = 0;
326 }
327
328 -struct crec *cache_insert(char *name, struct all_addr *addr, unsigned short class,
329 +struct crec *cache_insert(char *name, union all_addr *addr, unsigned short class,
330 time_t now, unsigned long ttl, unsigned short flags)
331 {
332 /* Don't log DNSSEC records here, done elsewhere */
333 @@ -484,7 +484,7 @@ struct crec *cache_insert(char *name, st
334 }
335
336
337 -static struct crec *really_insert(char *name, struct all_addr *addr, unsigned short class,
338 +static struct crec *really_insert(char *name, union all_addr *addr, unsigned short class,
339 time_t now, unsigned long ttl, unsigned short flags)
340 {
341 struct crec *new, *target_crec = NULL;
342 @@ -509,10 +509,10 @@ static struct crec *really_insert(char *
343 if ((flags & (F_IPV4 | F_IPV6)) && (flags & F_FORWARD) && addr)
344 {
345 if ((flags & F_IPV4) && (new->flags & F_IPV4) &&
346 - new->addr.addr.addr.addr4.s_addr == addr->addr.addr4.s_addr)
347 + new->addr.addr4.s_addr == addr->addr4.s_addr)
348 return new;
349 else if ((flags & F_IPV6) && (new->flags & F_IPV6) &&
350 - IN6_ARE_ADDR_EQUAL(&new->addr.addr.addr.addr6, &addr->addr.addr6))
351 + IN6_ARE_ADDR_EQUAL(&new->addr.addr6, &addr->addr6))
352 return new;
353 }
354
355 @@ -557,7 +557,7 @@ static struct crec *really_insert(char *
356 {
357 /* For DNSSEC records, uid holds class. */
358 free_avail = 1; /* Must be free space now. */
359 - cache_scan_free(cache_get_name(new), &new->addr.addr, new->uid, now, new->flags, NULL, NULL);
360 + cache_scan_free(cache_get_name(new), &new->addr, new->uid, now, new->flags, NULL, NULL);
361 daemon->metrics[METRIC_DNS_CACHE_LIVE_FREED]++;
362 }
363 else
364 @@ -616,7 +616,7 @@ static struct crec *really_insert(char *
365 #endif
366
367 if (addr)
368 - new->addr.addr = *addr;
369 + new->addr = *addr;
370
371 new->ttd = now + (time_t)ttl;
372 new->next = new_chain;
373 @@ -665,14 +665,14 @@ void cache_end_insert(void)
374 if (flags & F_DNSKEY)
375 {
376 read_write(daemon->pipe_to_parent, (unsigned char *)&class, sizeof(class), 0);
377 - blockdata_write(new_chain->addr.addr.addr.key.keydata, new_chain->addr.addr.addr.key.keylen, daemon->pipe_to_parent);
378 + blockdata_write(new_chain->addr.key.keydata, new_chain->addr.key.keylen, daemon->pipe_to_parent);
379 }
380 else if (flags & F_DS)
381 {
382 read_write(daemon->pipe_to_parent, (unsigned char *)&class, sizeof(class), 0);
383 /* A negative DS entry is possible and has no data, obviously. */
384 if (!(flags & F_NEG))
385 - blockdata_write(new_chain->addr.addr.addr.ds.keydata, new_chain->addr.addr.addr.ds.keylen, daemon->pipe_to_parent);
386 + blockdata_write(new_chain->addr.ds.keydata, new_chain->addr.ds.keylen, daemon->pipe_to_parent);
387 }
388 #endif
389 }
390 @@ -696,7 +696,7 @@ void cache_end_insert(void)
391 int cache_recv_insert(time_t now, int fd)
392 {
393 ssize_t m;
394 - struct all_addr addr;
395 + union all_addr addr;
396 unsigned long ttl;
397 time_t ttd;
398 unsigned short flags;
399 @@ -736,14 +736,14 @@ int cache_recv_insert(time_t now, int fd
400 if (flags & F_DNSKEY)
401 {
402 if (!read_write(fd, (unsigned char *)&class, sizeof(class), 1) ||
403 - !(addr.addr.key.keydata = blockdata_read(fd, addr.addr.key.keylen)))
404 + !(addr.key.keydata = blockdata_read(fd, addr.key.keylen)))
405 return 0;
406 }
407 else if (flags & F_DS)
408 {
409 if (!read_write(fd, (unsigned char *)&class, sizeof(class), 1) ||
410 (flags & F_NEG) ||
411 - !(addr.addr.key.keydata = blockdata_read(fd, addr.addr.key.keylen)))
412 + !(addr.key.keydata = blockdata_read(fd, addr.key.keylen)))
413 return 0;
414 }
415 #endif
416 @@ -876,7 +876,7 @@ struct crec *cache_find_by_name(struct c
417 return NULL;
418 }
419
420 -struct crec *cache_find_by_addr(struct crec *crecp, struct all_addr *addr,
421 +struct crec *cache_find_by_addr(struct crec *crecp, union all_addr *addr,
422 time_t now, unsigned int prot)
423 {
424 struct crec *ans;
425 @@ -900,7 +900,7 @@ struct crec *cache_find_by_addr(struct c
426 if (!is_expired(now, crecp))
427 {
428 if ((crecp->flags & prot) &&
429 - memcmp(&crecp->addr.addr, addr, addrlen) == 0)
430 + memcmp(&crecp->addr, addr, addrlen) == 0)
431 {
432 if (crecp->flags & (F_HOSTS | F_DHCP | F_CONFIG))
433 {
434 @@ -931,7 +931,7 @@ struct crec *cache_find_by_addr(struct c
435 if (ans &&
436 (ans->flags & F_REVERSE) &&
437 (ans->flags & prot) &&
438 - memcmp(&ans->addr.addr, addr, addrlen) == 0)
439 + memcmp(&ans->addr, addr, addrlen) == 0)
440 return ans;
441
442 return NULL;
443 @@ -961,7 +961,7 @@ static void add_hosts_cname(struct crec
444 }
445 }
446
447 -static void add_hosts_entry(struct crec *cache, struct all_addr *addr, int addrlen,
448 +static void add_hosts_entry(struct crec *cache, union all_addr *addr, int addrlen,
449 unsigned int index, struct crec **rhash, int hashsz)
450 {
451 struct crec *lookup = cache_find_by_name(NULL, cache_get_name(cache), 0, cache->flags & (F_IPV4 | F_IPV6));
452 @@ -972,7 +972,7 @@ static void add_hosts_entry(struct crec
453 if (lookup && (lookup->flags & F_HOSTS))
454 {
455 nameexists = 1;
456 - if (memcmp(&lookup->addr.addr, addr, addrlen) == 0)
457 + if (memcmp(&lookup->addr, addr, addrlen) == 0)
458 {
459 free(cache);
460 return;
461 @@ -1004,7 +1004,7 @@ static void add_hosts_entry(struct crec
462
463 for (lookup = rhash[j]; lookup; lookup = lookup->next)
464 if ((lookup->flags & cache->flags & (F_IPV4 | F_IPV6)) &&
465 - memcmp(&lookup->addr.addr, addr, addrlen) == 0)
466 + memcmp(&lookup->addr, addr, addrlen) == 0)
467 {
468 cache->flags &= ~F_REVERSE;
469 break;
470 @@ -1026,7 +1026,7 @@ static void add_hosts_entry(struct crec
471 }
472
473 cache->uid = index;
474 - memcpy(&cache->addr.addr, addr, addrlen);
475 + memcpy(&cache->addr, addr, addrlen);
476 cache_hash(cache);
477 make_non_terminals(cache);
478
479 @@ -1088,7 +1088,7 @@ int read_hostsfile(char *filename, unsig
480 char *token = daemon->namebuff, *domain_suffix = NULL;
481 int addr_count = 0, name_count = cache_size, lineno = 0;
482 unsigned short flags = 0;
483 - struct all_addr addr;
484 + union all_addr addr;
485 int atnl, addrlen = 0;
486
487 if (!f)
488 @@ -1107,13 +1107,13 @@ int read_hostsfile(char *filename, unsig
489 {
490 flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV4;
491 addrlen = INADDRSZ;
492 - domain_suffix = get_domain(addr.addr.addr4);
493 + domain_suffix = get_domain(addr.addr4);
494 }
495 else if (inet_pton(AF_INET6, token, &addr) > 0)
496 {
497 flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV6;
498 addrlen = IN6ADDRSZ;
499 - domain_suffix = get_domain6(&addr.addr.addr6);
500 + domain_suffix = get_domain6(&addr.addr6);
501 }
502 else
503 {
504 @@ -1246,15 +1246,15 @@ void cache_reload(void)
505 #ifdef HAVE_DNSSEC
506 for (ds = daemon->ds; ds; ds = ds->next)
507 if ((cache = whine_malloc(SIZEOF_POINTER_CREC)) &&
508 - (cache->addr.addr.addr.ds.keydata = blockdata_alloc(ds->digest, ds->digestlen)))
509 + (cache->addr.ds.keydata = blockdata_alloc(ds->digest, ds->digestlen)))
510 {
511 cache->flags = F_FORWARD | F_IMMORTAL | F_DS | F_CONFIG | F_NAMEP;
512 cache->ttd = daemon->local_ttl;
513 cache->name.namep = ds->name;
514 - cache->addr.addr.addr.ds.keylen = ds->digestlen;
515 - cache->addr.addr.addr.ds.algo = ds->algo;
516 - cache->addr.addr.addr.ds.keytag = ds->keytag;
517 - cache->addr.addr.addr.ds.digest = ds->digest_type;
518 + cache->addr.ds.keylen = ds->digestlen;
519 + cache->addr.ds.algo = ds->algo;
520 + cache->addr.ds.keytag = ds->keytag;
521 + cache->addr.ds.digest = ds->digest_type;
522 cache->uid = ds->class;
523 cache_hash(cache);
524 make_non_terminals(cache);
525 @@ -1277,7 +1277,7 @@ void cache_reload(void)
526 cache->name.namep = nl->name;
527 cache->ttd = hr->ttl;
528 cache->flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV4 | F_NAMEP | F_CONFIG;
529 - add_hosts_entry(cache, (struct all_addr *)&hr->addr, INADDRSZ, SRC_CONFIG, (struct crec **)daemon->packet, revhashsz);
530 + add_hosts_entry(cache, (union all_addr *)&hr->addr, INADDRSZ, SRC_CONFIG, (struct crec **)daemon->packet, revhashsz);
531 }
532
533 if (!IN6_IS_ADDR_UNSPECIFIED(&hr->addr6) &&
534 @@ -1286,7 +1286,7 @@ void cache_reload(void)
535 cache->name.namep = nl->name;
536 cache->ttd = hr->ttl;
537 cache->flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV6 | F_NAMEP | F_CONFIG;
538 - add_hosts_entry(cache, (struct all_addr *)&hr->addr6, IN6ADDRSZ, SRC_CONFIG, (struct crec **)daemon->packet, revhashsz);
539 + add_hosts_entry(cache, (union all_addr *)&hr->addr6, IN6ADDRSZ, SRC_CONFIG, (struct crec **)daemon->packet, revhashsz);
540 }
541 }
542
543 @@ -1320,7 +1320,7 @@ struct in_addr a_record_from_hosts(char
544
545 while ((crecp = cache_find_by_name(crecp, name, now, F_IPV4)))
546 if (crecp->flags & F_HOSTS)
547 - return *(struct in_addr *)&crecp->addr;
548 + return crecp->addr.addr4;
549
550 my_syslog(MS_DHCP | LOG_WARNING, _("No IPv4 address found for %s"), name);
551
552 @@ -1379,7 +1379,7 @@ static void add_dhcp_cname(struct crec *
553 }
554
555 void cache_add_dhcp_entry(char *host_name, int prot,
556 - struct all_addr *host_address, time_t ttd)
557 + union all_addr *host_address, time_t ttd)
558 {
559 struct crec *crec = NULL, *fail_crec = NULL;
560 unsigned short flags = F_IPV4;
561 @@ -1403,7 +1403,7 @@ void cache_add_dhcp_entry(char *host_nam
562 my_syslog(MS_DHCP | LOG_WARNING,
563 _("%s is a CNAME, not giving it to the DHCP lease of %s"),
564 host_name, daemon->addrbuff);
565 - else if (memcmp(&crec->addr.addr, host_address, addrlen) == 0)
566 + else if (memcmp(&crec->addr, host_address, addrlen) == 0)
567 in_hosts = 1;
568 else
569 fail_crec = crec;
570 @@ -1423,7 +1423,7 @@ void cache_add_dhcp_entry(char *host_nam
571 /* Name in hosts, address doesn't match */
572 if (fail_crec)
573 {
574 - inet_ntop(prot, &fail_crec->addr.addr, daemon->namebuff, MAXDNAME);
575 + inet_ntop(prot, &fail_crec->addr, daemon->namebuff, MAXDNAME);
576 my_syslog(MS_DHCP | LOG_WARNING,
577 _("not giving name %s to the DHCP lease of %s because "
578 "the name exists in %s with address %s"),
579 @@ -1432,12 +1432,12 @@ void cache_add_dhcp_entry(char *host_nam
580 return;
581 }
582
583 - if ((crec = cache_find_by_addr(NULL, (struct all_addr *)host_address, 0, flags)))
584 + if ((crec = cache_find_by_addr(NULL, (union all_addr *)host_address, 0, flags)))
585 {
586 if (crec->flags & F_NEG)
587 {
588 flags |= F_REVERSE;
589 - cache_scan_free(NULL, (struct all_addr *)host_address, C_IN, 0, flags, NULL, NULL);
590 + cache_scan_free(NULL, (union all_addr *)host_address, C_IN, 0, flags, NULL, NULL);
591 }
592 }
593 else
594 @@ -1455,7 +1455,7 @@ void cache_add_dhcp_entry(char *host_nam
595 crec->flags |= F_IMMORTAL;
596 else
597 crec->ttd = ttd;
598 - crec->addr.addr = *host_address;
599 + crec->addr = *host_address;
600 crec->name.namep = host_name;
601 crec->uid = UID_NONE;
602 cache_hash(crec);
603 @@ -1731,20 +1731,20 @@ void dump_cache(time_t now)
604 else if (cache->flags & F_DS)
605 {
606 if (!(cache->flags & F_NEG))
607 - sprintf(a, "%5u %3u %3u", cache->addr.addr.addr.ds.keytag,
608 - cache->addr.addr.addr.ds.algo, cache->addr.addr.addr.ds.digest);
609 + sprintf(a, "%5u %3u %3u", cache->addr.ds.keytag,
610 + cache->addr.ds.algo, cache->addr.ds.digest);
611 }
612 else if (cache->flags & F_DNSKEY)
613 - sprintf(a, "%5u %3u %3u", cache->addr.addr.addr.key.keytag,
614 - cache->addr.addr.addr.key.algo, cache->addr.addr.addr.key.flags);
615 + sprintf(a, "%5u %3u %3u", cache->addr.key.keytag,
616 + cache->addr.key.algo, cache->addr.key.flags);
617 #endif
618 else if (!(cache->flags & F_NEG) || !(cache->flags & F_FORWARD))
619 {
620 a = daemon->addrbuff;
621 if (cache->flags & F_IPV4)
622 - inet_ntop(AF_INET, &cache->addr.addr, a, ADDRSTRLEN);
623 + inet_ntop(AF_INET, &cache->addr, a, ADDRSTRLEN);
624 else if (cache->flags & F_IPV6)
625 - inet_ntop(AF_INET6, &cache->addr.addr, a, ADDRSTRLEN);
626 + inet_ntop(AF_INET6, &cache->addr, a, ADDRSTRLEN);
627 }
628
629 if (cache->flags & F_IPV4)
630 @@ -1857,7 +1857,7 @@ char *querystr(char *desc, unsigned shor
631 return buff ? buff : "";
632 }
633
634 -void log_query(unsigned int flags, char *name, struct all_addr *addr, char *arg)
635 +void log_query(unsigned int flags, char *name, union all_addr *addr, char *arg)
636 {
637 char *source, *dest = daemon->addrbuff;
638 char *verb = "is";
639 @@ -1870,10 +1870,10 @@ void log_query(unsigned int flags, char
640 if (addr)
641 {
642 if (flags & F_KEYTAG)
643 - sprintf(daemon->addrbuff, arg, addr->addr.log.keytag, addr->addr.log.algo, addr->addr.log.digest);
644 + sprintf(daemon->addrbuff, arg, addr->log.keytag, addr->log.algo, addr->log.digest);
645 else if (flags & F_RCODE)
646 {
647 - unsigned int rcode = addr->addr.log.rcode;
648 + unsigned int rcode = addr->log.rcode;
649
650 if (rcode == SERVFAIL)
651 dest = "SERVFAIL";
652 --- a/src/conntrack.c
653 +++ b/src/conntrack.c
654 @@ -24,7 +24,7 @@ static int gotit = 0; /* yuck */
655
656 static int callback(enum nf_conntrack_msg_type type, struct nf_conntrack *ct, void *data);
657
658 -int get_incoming_mark(union mysockaddr *peer_addr, struct all_addr *local_addr, int istcp, unsigned int *markp)
659 +int get_incoming_mark(union mysockaddr *peer_addr, union all_addr *local_addr, int istcp, unsigned int *markp)
660 {
661 struct nf_conntrack *ct;
662 struct nfct_handle *h;
663 @@ -41,14 +41,14 @@ int get_incoming_mark(union mysockaddr *
664 nfct_set_attr_u8(ct, ATTR_L3PROTO, AF_INET6);
665 nfct_set_attr(ct, ATTR_IPV6_SRC, peer_addr->in6.sin6_addr.s6_addr);
666 nfct_set_attr_u16(ct, ATTR_PORT_SRC, peer_addr->in6.sin6_port);
667 - nfct_set_attr(ct, ATTR_IPV6_DST, local_addr->addr.addr6.s6_addr);
668 + nfct_set_attr(ct, ATTR_IPV6_DST, local_addr->addr6.s6_addr);
669 }
670 else
671 {
672 nfct_set_attr_u8(ct, ATTR_L3PROTO, AF_INET);
673 nfct_set_attr_u32(ct, ATTR_IPV4_SRC, peer_addr->in.sin_addr.s_addr);
674 nfct_set_attr_u16(ct, ATTR_PORT_SRC, peer_addr->in.sin_port);
675 - nfct_set_attr_u32(ct, ATTR_IPV4_DST, local_addr->addr.addr4.s_addr);
676 + nfct_set_attr_u32(ct, ATTR_IPV4_DST, local_addr->addr4.s_addr);
677 }
678
679
680 --- a/src/dbus.c
681 +++ b/src/dbus.c
682 @@ -456,7 +456,7 @@ static DBusMessage *dbus_add_lease(DBusM
683 int clid_len, hostname_len, hw_len, hw_type;
684 dbus_uint32_t expires, ia_id;
685 dbus_bool_t is_temporary;
686 - struct all_addr addr;
687 + union all_addr addr;
688 time_t now = dnsmasq_time();
689 unsigned char dhcp_chaddr[DHCP_CHADDR_MAX];
690
691 @@ -526,20 +526,20 @@ static DBusMessage *dbus_add_lease(DBusM
692
693 dbus_message_iter_get_basic(&iter, &is_temporary);
694
695 - if (inet_pton(AF_INET, ipaddr, &addr.addr.addr4))
696 + if (inet_pton(AF_INET, ipaddr, &addr.addr4))
697 {
698 if (ia_id != 0 || is_temporary)
699 return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
700 "ia_id and is_temporary must be zero for IPv4 lease");
701
702 - if (!(lease = lease_find_by_addr(addr.addr.addr4)))
703 - lease = lease4_allocate(addr.addr.addr4);
704 + if (!(lease = lease_find_by_addr(addr.addr4)))
705 + lease = lease4_allocate(addr.addr4);
706 }
707 #ifdef HAVE_DHCP6
708 - else if (inet_pton(AF_INET6, ipaddr, &addr.addr.addr6))
709 + else if (inet_pton(AF_INET6, ipaddr, &addr.addr6))
710 {
711 - if (!(lease = lease6_find_by_addr(&addr.addr.addr6, 128, 0)))
712 - lease = lease6_allocate(&addr.addr.addr6,
713 + if (!(lease = lease6_find_by_addr(&addr.addr6, 128, 0)))
714 + lease = lease6_allocate(&addr.addr6,
715 is_temporary ? LEASE_TA : LEASE_NA);
716 lease_set_iaid(lease, ia_id);
717 }
718 @@ -570,7 +570,7 @@ static DBusMessage *dbus_del_lease(DBusM
719 DBusMessageIter iter;
720 const char *ipaddr;
721 DBusMessage *reply;
722 - struct all_addr addr;
723 + union all_addr addr;
724 dbus_bool_t ret = 1;
725 time_t now = dnsmasq_time();
726
727 @@ -584,11 +584,11 @@ static DBusMessage *dbus_del_lease(DBusM
728
729 dbus_message_iter_get_basic(&iter, &ipaddr);
730
731 - if (inet_pton(AF_INET, ipaddr, &addr.addr.addr4))
732 - lease = lease_find_by_addr(addr.addr.addr4);
733 + if (inet_pton(AF_INET, ipaddr, &addr.addr4))
734 + lease = lease_find_by_addr(addr.addr4);
735 #ifdef HAVE_DHCP6
736 - else if (inet_pton(AF_INET6, ipaddr, &addr.addr.addr6))
737 - lease = lease6_find_by_addr(&addr.addr.addr6, 128, 0);
738 + else if (inet_pton(AF_INET6, ipaddr, &addr.addr6))
739 + lease = lease6_find_by_addr(&addr.addr6, 128, 0);
740 #endif
741 else
742 return dbus_message_new_error_printf(message, DBUS_ERROR_INVALID_ARGS,
743 --- a/src/dhcp-common.c
744 +++ b/src/dhcp-common.c
745 @@ -403,30 +403,30 @@ void dhcp_update_configs(struct dhcp_con
746 crec = cache_find_by_name(crec, config->hostname, 0, cacheflags);
747 if (!crec)
748 continue; /* should be never */
749 - inet_ntop(prot, &crec->addr.addr, daemon->addrbuff, ADDRSTRLEN);
750 + inet_ntop(prot, &crec->addr, daemon->addrbuff, ADDRSTRLEN);
751 my_syslog(MS_DHCP | LOG_WARNING, _("%s has more than one address in hostsfile, using %s for DHCP"),
752 config->hostname, daemon->addrbuff);
753 }
754
755 if (prot == AF_INET &&
756 - (!(conf_tmp = config_find_by_address(configs, crec->addr.addr.addr.addr4)) || conf_tmp == config))
757 + (!(conf_tmp = config_find_by_address(configs, crec->addr.addr4)) || conf_tmp == config))
758 {
759 - config->addr = crec->addr.addr.addr.addr4;
760 + config->addr = crec->addr.addr4;
761 config->flags |= CONFIG_ADDR | CONFIG_ADDR_HOSTS;
762 continue;
763 }
764
765 #ifdef HAVE_DHCP6
766 if (prot == AF_INET6 &&
767 - (!(conf_tmp = config_find_by_address6(configs, &crec->addr.addr.addr.addr6, 128, 0)) || conf_tmp == config))
768 + (!(conf_tmp = config_find_by_address6(configs, &crec->addr.addr6, 128, 0)) || conf_tmp == config))
769 {
770 - memcpy(&config->addr6, &crec->addr.addr.addr.addr6, IN6ADDRSZ);
771 + memcpy(&config->addr6, &crec->addr.addr6, IN6ADDRSZ);
772 config->flags |= CONFIG_ADDR6 | CONFIG_ADDR_HOSTS;
773 continue;
774 }
775 #endif
776
777 - inet_ntop(prot, &crec->addr.addr, daemon->addrbuff, ADDRSTRLEN);
778 + inet_ntop(prot, &crec->addr, daemon->addrbuff, ADDRSTRLEN);
779 my_syslog(MS_DHCP | LOG_WARNING, _("duplicate IP address %s (%s) in dhcp-config directive"),
780 daemon->addrbuff, config->hostname);
781
782 @@ -693,7 +693,7 @@ char *option_string(int prot, unsigned i
783
784 if (ot[o].size & OT_ADDR_LIST)
785 {
786 - struct all_addr addr;
787 + union all_addr addr;
788 int addr_len = INADDRSZ;
789
790 #ifdef HAVE_DHCP6
791 --- a/src/dhcp.c
792 +++ b/src/dhcp.c
793 @@ -310,7 +310,7 @@ void dhcp_packet(time_t now, int pxe_fd)
794 parm.relay_local.s_addr = 0;
795 parm.ind = iface_index;
796
797 - if (!iface_check(AF_INET, (struct all_addr *)&iface_addr, ifr.ifr_name, NULL))
798 + if (!iface_check(AF_INET, (union all_addr *)&iface_addr, ifr.ifr_name, NULL))
799 {
800 /* If we failed to match the primary address of the interface, see if we've got a --listen-address
801 for a secondary */
802 @@ -558,7 +558,7 @@ static int complete_context(struct in_ad
803 }
804
805 for (relay = daemon->relay4; relay; relay = relay->next)
806 - if (if_index == param->ind && relay->local.addr.addr4.s_addr == local.s_addr && relay->current == relay &&
807 + if (if_index == param->ind && relay->local.addr4.s_addr == local.s_addr && relay->current == relay &&
808 (param->relay_local.s_addr == 0 || param->relay_local.s_addr == local.s_addr))
809 {
810 relay->current = param->relay;
811 @@ -984,7 +984,7 @@ char *host_from_dns(struct in_addr addr)
812 if (daemon->port == 0)
813 return NULL; /* DNS disabled. */
814
815 - lookup = cache_find_by_addr(NULL, (struct all_addr *)&addr, 0, F_IPV4);
816 + lookup = cache_find_by_addr(NULL, (union all_addr *)&addr, 0, F_IPV4);
817
818 if (lookup && (lookup->flags & F_HOSTS))
819 {
820 @@ -1013,25 +1013,25 @@ char *host_from_dns(struct in_addr addr)
821 static int relay_upstream4(struct dhcp_relay *relay, struct dhcp_packet *mess, size_t sz, int iface_index)
822 {
823 /* ->local is same value for all relays on ->current chain */
824 - struct all_addr from;
825 + union all_addr from;
826
827 if (mess->op != BOOTREQUEST)
828 return 0;
829
830 /* source address == relay address */
831 - from.addr.addr4 = relay->local.addr.addr4;
832 + from.addr4 = relay->local.addr4;
833
834 /* already gatewayed ? */
835 if (mess->giaddr.s_addr)
836 {
837 /* if so check if by us, to stomp on loops. */
838 - if (mess->giaddr.s_addr == relay->local.addr.addr4.s_addr)
839 + if (mess->giaddr.s_addr == relay->local.addr4.s_addr)
840 return 1;
841 }
842 else
843 {
844 /* plug in our address */
845 - mess->giaddr.s_addr = relay->local.addr.addr4.s_addr;
846 + mess->giaddr.s_addr = relay->local.addr4.s_addr;
847 }
848
849 if ((mess->hops++) > 20)
850 @@ -1042,7 +1042,7 @@ static int relay_upstream4(struct dhcp_
851 union mysockaddr to;
852
853 to.sa.sa_family = AF_INET;
854 - to.in.sin_addr = relay->server.addr.addr4;
855 + to.in.sin_addr = relay->server.addr4;
856 to.in.sin_port = htons(daemon->dhcp_server_port);
857
858 send_from(daemon->dhcpfd, 0, (char *)mess, sz, &to, &from, 0);
859 @@ -1050,7 +1050,7 @@ static int relay_upstream4(struct dhcp_
860 if (option_bool(OPT_LOG_OPTS))
861 {
862 inet_ntop(AF_INET, &relay->local, daemon->addrbuff, ADDRSTRLEN);
863 - my_syslog(MS_DHCP | LOG_INFO, _("DHCP relay %s -> %s"), daemon->addrbuff, inet_ntoa(relay->server.addr.addr4));
864 + my_syslog(MS_DHCP | LOG_INFO, _("DHCP relay %s -> %s"), daemon->addrbuff, inet_ntoa(relay->server.addr4));
865 }
866
867 /* Save this for replies */
868 @@ -1070,7 +1070,7 @@ static struct dhcp_relay *relay_reply4(s
869
870 for (relay = daemon->relay4; relay; relay = relay->next)
871 {
872 - if (mess->giaddr.s_addr == relay->local.addr.addr4.s_addr)
873 + if (mess->giaddr.s_addr == relay->local.addr4.s_addr)
874 {
875 if (!relay->interface || wildcard_match(relay->interface, arrival_interface))
876 return relay->iface_index != 0 ? relay : NULL;
877 --- a/src/dhcp6.c
878 +++ b/src/dhcp6.c
879 @@ -371,7 +371,7 @@ static int complete_context6(struct in6_
880 }
881
882 for (relay = daemon->relay6; relay; relay = relay->next)
883 - if (IN6_ARE_ADDR_EQUAL(local, &relay->local.addr.addr6) && relay->current == relay &&
884 + if (IN6_ARE_ADDR_EQUAL(local, &relay->local.addr6) && relay->current == relay &&
885 (IN6_IS_ADDR_UNSPECIFIED(&param->relay_local) || IN6_ARE_ADDR_EQUAL(local, &param->relay_local)))
886 {
887 relay->current = param->relay;
888 --- a/src/dnsmasq.c
889 +++ b/src/dnsmasq.c
890 @@ -1721,12 +1721,12 @@ static void check_dns_listeners(time_t n
891 if ((if_index = tcp_interface(confd, tcp_addr.sa.sa_family)) != 0 &&
892 indextoname(listener->tcpfd, if_index, intr_name))
893 {
894 - struct all_addr addr;
895 + union all_addr addr;
896
897 if (tcp_addr.sa.sa_family == AF_INET6)
898 - addr.addr.addr6 = tcp_addr.in6.sin6_addr;
899 + addr.addr6 = tcp_addr.in6.sin6_addr;
900 else
901 - addr.addr.addr4 = tcp_addr.in.sin_addr;
902 + addr.addr4 = tcp_addr.in.sin_addr;
903
904 for (iface = daemon->interfaces; iface; iface = iface->next)
905 if (iface->index == if_index)
906 --- a/src/dnsmasq.h
907 +++ b/src/dnsmasq.h
908 @@ -273,28 +273,39 @@ struct event_desc {
909 #define MS_DHCP LOG_DAEMON
910 #define MS_SCRIPT LOG_MAIL
911
912 -struct all_addr {
913 - union {
914 - struct in_addr addr4;
915 - struct in6_addr addr6;
916 - struct {
917 - struct blockdata *keydata;
918 - unsigned short keylen, flags, keytag;
919 - unsigned char algo;
920 - } key;
921 - struct {
922 - struct blockdata *keydata;
923 - unsigned short keylen, keytag;
924 - unsigned char algo;
925 - unsigned char digest;
926 - } ds;
927 - /* for log_query */
928 - struct {
929 - unsigned short keytag, algo, digest, rcode;
930 - } log;
931 - } addr;
932 +/* Note that this is used widely as a container for IPv4/IPv6 addresses,
933 + so for that reason, was well as to avoid wasting memory in almost every
934 + cache entry, the other variants should not be larger than
935 + sizeof(struct in6_addr) - 16 bytes.
936 +*/
937 +union all_addr {
938 + struct in_addr addr4;
939 + struct in6_addr addr6;
940 + struct {
941 + union {
942 + struct crec *cache;
943 + struct interface_name *int_name;
944 + } target;
945 + unsigned int uid; /* 0 if union is interface-name */
946 + } cname;
947 + struct {
948 + struct blockdata *keydata;
949 + unsigned short keylen, flags, keytag;
950 + unsigned char algo;
951 + } key;
952 + struct {
953 + struct blockdata *keydata;
954 + unsigned short keylen, keytag;
955 + unsigned char algo;
956 + unsigned char digest;
957 + } ds;
958 + /* for log_query */
959 + struct {
960 + unsigned short keytag, algo, digest, rcode;
961 + } log;
962 };
963
964 +
965 struct bogus_addr {
966 struct in_addr addr;
967 struct bogus_addr *next;
968 @@ -359,7 +370,7 @@ struct ds_config {
969 #define ADDRLIST_REVONLY 4
970
971 struct addrlist {
972 - struct all_addr addr;
973 + union all_addr addr;
974 int flags, prefixlen;
975 struct addrlist *next;
976 };
977 @@ -411,17 +422,7 @@ struct blockdata {
978
979 struct crec {
980 struct crec *next, *prev, *hash_next;
981 - /* union is 16 bytes when doing IPv6, 8 bytes on 32 bit machines without IPv6 */
982 - union {
983 - struct all_addr addr;
984 - struct {
985 - union {
986 - struct crec *cache;
987 - struct interface_name *int_name;
988 - } target;
989 - unsigned int uid; /* 0 if union is interface-name */
990 - } cname;
991 - } addr;
992 + union all_addr addr;
993 time_t ttd; /* time to die */
994 /* used as class if DNSKEY/DS, index to source for F_HOSTS */
995 unsigned int uid;
996 @@ -646,7 +647,7 @@ struct hostsfile {
997
998 struct frec {
999 union mysockaddr source;
1000 - struct all_addr dest;
1001 + union all_addr dest;
1002 struct server *sentto; /* NULL means free */
1003 struct randfd *rfd4;
1004 struct randfd *rfd6;
1005 @@ -962,7 +963,7 @@ struct tftp_prefix {
1006 };
1007
1008 struct dhcp_relay {
1009 - struct all_addr local, server;
1010 + union all_addr local, server;
1011 char *interface; /* Allowable interface for replies from server, and dest for IPv6 multicast */
1012 int iface_index; /* working - interface in which requests arrived, for return */
1013 struct dhcp_relay *current, *next;
1014 @@ -1128,22 +1129,22 @@ extern struct daemon {
1015 /* cache.c */
1016 void cache_init(void);
1017 void next_uid(struct crec *crecp);
1018 -void log_query(unsigned int flags, char *name, struct all_addr *addr, char *arg);
1019 +void log_query(unsigned int flags, char *name, union all_addr *addr, char *arg);
1020 char *record_source(unsigned int index);
1021 char *querystr(char *desc, unsigned short type);
1022 int cache_find_non_terminal(char *name, time_t now);
1023 struct crec *cache_find_by_addr(struct crec *crecp,
1024 - struct all_addr *addr, time_t now,
1025 + union all_addr *addr, time_t now,
1026 unsigned int prot);
1027 struct crec *cache_find_by_name(struct crec *crecp,
1028 char *name, time_t now, unsigned int prot);
1029 void cache_end_insert(void);
1030 void cache_start_insert(void);
1031 int cache_recv_insert(time_t now, int fd);
1032 -struct crec *cache_insert(char *name, struct all_addr *addr, unsigned short class,
1033 +struct crec *cache_insert(char *name, union all_addr *addr, unsigned short class,
1034 time_t now, unsigned long ttl, unsigned short flags);
1035 void cache_reload(void);
1036 -void cache_add_dhcp_entry(char *host_name, int prot, struct all_addr *host_address, time_t ttd);
1037 +void cache_add_dhcp_entry(char *host_name, int prot, union all_addr *host_address, time_t ttd);
1038 struct in_addr a_record_from_hosts(char *name, time_t now);
1039 void cache_unhash_dhcp(void);
1040 void dump_cache(time_t now);
1041 @@ -1170,8 +1171,8 @@ void blockdata_free(struct blockdata *bl
1042 /* domain.c */
1043 char *get_domain(struct in_addr addr);
1044 char *get_domain6(struct in6_addr *addr);
1045 -int is_name_synthetic(int flags, char *name, struct all_addr *addr);
1046 -int is_rev_synth(int flag, struct all_addr *addr, char *name);
1047 +int is_name_synthetic(int flags, char *name, union all_addr *addr);
1048 +int is_rev_synth(int flag, union all_addr *addr, char *name);
1049
1050 /* rfc1035.c */
1051 int extract_name(struct dns_header *header, size_t plen, unsigned char **pp,
1052 @@ -1182,7 +1183,7 @@ unsigned char *skip_section(unsigned cha
1053 unsigned int extract_request(struct dns_header *header, size_t qlen,
1054 char *name, unsigned short *typep);
1055 size_t setup_reply(struct dns_header *header, size_t qlen,
1056 - struct all_addr *addrp, unsigned int flags,
1057 + union all_addr *addrp, unsigned int flags,
1058 unsigned long ttl);
1059 int extract_addresses(struct dns_header *header, size_t qlen, char *name,
1060 time_t now, char **ipsets, int is_sign, int check_rebind,
1061 @@ -1203,7 +1204,7 @@ int add_resource_record(struct dns_heade
1062 unsigned char *skip_questions(struct dns_header *header, size_t plen);
1063 int extract_name(struct dns_header *header, size_t plen, unsigned char **pp,
1064 char *name, int isExtract, int extrabytes);
1065 -int in_arpa_name_2_addr(char *namein, struct all_addr *addrp);
1066 +int in_arpa_name_2_addr(char *namein, union all_addr *addrp);
1067 int private_net(struct in_addr addr, int ban_localhost);
1068
1069 /* auth.c */
1070 @@ -1302,7 +1303,7 @@ unsigned char *tcp_request(int confd, ti
1071 void server_gone(struct server *server);
1072 struct frec *get_new_frec(time_t now, int *wait, int force);
1073 int send_from(int fd, int nowild, char *packet, size_t len,
1074 - union mysockaddr *to, struct all_addr *source,
1075 + union mysockaddr *to, union all_addr *source,
1076 unsigned int iface);
1077 void resend_query(void);
1078 struct randfd *allocate_rfd(int family);
1079 @@ -1329,9 +1330,9 @@ void warn_bound_listeners(void);
1080 void warn_wild_labels(void);
1081 void warn_int_names(void);
1082 int is_dad_listeners(void);
1083 -int iface_check(int family, struct all_addr *addr, char *name, int *auth);
1084 -int loopback_exception(int fd, int family, struct all_addr *addr, char *name);
1085 -int label_exception(int index, int family, struct all_addr *addr);
1086 +int iface_check(int family, union all_addr *addr, char *name, int *auth);
1087 +int loopback_exception(int fd, int family, union all_addr *addr, char *name);
1088 +int label_exception(int index, int family, union all_addr *addr);
1089 int fix_fd(int fd);
1090 int tcp_interface(int fd, int af);
1091 int set_ipv6pktinfo(int fd);
1092 @@ -1461,7 +1462,7 @@ void ubus_event_bcast(const char *type,
1093 /* ipset.c */
1094 #ifdef HAVE_IPSET
1095 void ipset_init(void);
1096 -int add_to_ipset(const char *setname, const struct all_addr *ipaddr, int flags, int remove);
1097 +int add_to_ipset(const char *setname, const union all_addr *ipaddr, int flags, int remove);
1098 #endif
1099
1100 /* helper.c */
1101 @@ -1474,7 +1475,7 @@ void queue_script(int action, struct dhc
1102 void queue_tftp(off_t file_len, char *filename, union mysockaddr *peer);
1103 #endif
1104 void queue_arp(int action, unsigned char *mac, int maclen,
1105 - int family, struct all_addr *addr);
1106 + int family, union all_addr *addr);
1107 int helper_buf_empty(void);
1108 #endif
1109
1110 @@ -1487,7 +1488,7 @@ int do_tftp_script_run(void);
1111
1112 /* conntrack.c */
1113 #ifdef HAVE_CONNTRACK
1114 -int get_incoming_mark(union mysockaddr *peer_addr, struct all_addr *local_addr,
1115 +int get_incoming_mark(union mysockaddr *peer_addr, union all_addr *local_addr,
1116 int istcp, unsigned int *markp);
1117 #endif
1118
1119 --- a/src/dnssec.c
1120 +++ b/src/dnssec.c
1121 @@ -628,10 +628,10 @@ static int validate_rrset(time_t now, st
1122 {
1123 /* iterate through all possible keys 4035 5.3.1 */
1124 for (; crecp; crecp = cache_find_by_name(crecp, keyname, now, F_DNSKEY))
1125 - if (crecp->addr.addr.addr.key.algo == algo &&
1126 - crecp->addr.addr.addr.key.keytag == key_tag &&
1127 + if (crecp->addr.key.algo == algo &&
1128 + crecp->addr.key.keytag == key_tag &&
1129 crecp->uid == (unsigned int)class &&
1130 - verify(crecp->addr.addr.addr.key.keydata, crecp->addr.addr.addr.key.keylen, sig, sig_len, digest, hash->digest_size, algo))
1131 + verify(crecp->addr.key.keydata, crecp->addr.key.keylen, sig, sig_len, digest, hash->digest_size, algo))
1132 return (labels < name_labels) ? STAT_SECURE_WILDCARD : STAT_SECURE;
1133 }
1134 }
1135 @@ -655,7 +655,7 @@ int dnssec_validate_by_ds(time_t now, st
1136 struct crec *crecp, *recp1;
1137 int rc, j, qtype, qclass, ttl, rdlen, flags, algo, valid, keytag;
1138 struct blockdata *key;
1139 - struct all_addr a;
1140 + union all_addr a;
1141
1142 if (ntohs(header->qdcount) != 1 ||
1143 !extract_name(header, plen, &p, name, 1, 4))
1144 @@ -728,10 +728,10 @@ int dnssec_validate_by_ds(time_t now, st
1145 const struct nettle_hash *hash;
1146 int sigcnt, rrcnt;
1147
1148 - if (recp1->addr.addr.addr.ds.algo == algo &&
1149 - recp1->addr.addr.addr.ds.keytag == keytag &&
1150 + if (recp1->addr.ds.algo == algo &&
1151 + recp1->addr.ds.keytag == keytag &&
1152 recp1->uid == (unsigned int)class &&
1153 - (hash = hash_find(ds_digest_name(recp1->addr.addr.addr.ds.digest))) &&
1154 + (hash = hash_find(ds_digest_name(recp1->addr.ds.digest))) &&
1155 hash_init(hash, &ctx, &digest))
1156
1157 {
1158 @@ -746,9 +746,9 @@ int dnssec_validate_by_ds(time_t now, st
1159 from_wire(name);
1160
1161 if (!(recp1->flags & F_NEG) &&
1162 - recp1->addr.addr.addr.ds.keylen == (int)hash->digest_size &&
1163 - (ds_digest = blockdata_retrieve(recp1->addr.addr.addr.ds.keydata, recp1->addr.addr.addr.ds.keylen, NULL)) &&
1164 - memcmp(ds_digest, digest, recp1->addr.addr.addr.ds.keylen) == 0 &&
1165 + recp1->addr.ds.keylen == (int)hash->digest_size &&
1166 + (ds_digest = blockdata_retrieve(recp1->addr.ds.keydata, recp1->addr.ds.keylen, NULL)) &&
1167 + memcmp(ds_digest, digest, recp1->addr.ds.keylen) == 0 &&
1168 explore_rrset(header, plen, class, T_DNSKEY, name, keyname, &sigcnt, &rrcnt) &&
1169 sigcnt != 0 && rrcnt != 0 &&
1170 validate_rrset(now, header, plen, class, T_DNSKEY, sigcnt, rrcnt, name, keyname,
1171 @@ -800,11 +800,11 @@ int dnssec_validate_by_ds(time_t now, st
1172
1173 if ((key = blockdata_alloc((char*)p, rdlen - 4)))
1174 {
1175 - a.addr.key.keylen = rdlen - 4;
1176 - a.addr.key.keydata = key;
1177 - a.addr.key.algo = algo;
1178 - a.addr.key.keytag = keytag;
1179 - a.addr.key.flags = flags;
1180 + a.key.keylen = rdlen - 4;
1181 + a.key.keydata = key;
1182 + a.key.algo = algo;
1183 + a.key.keytag = keytag;
1184 + a.key.flags = flags;
1185
1186 if (!cache_insert(name, &a, class, now, ttl, F_FORWARD | F_DNSKEY | F_DNSSECOK))
1187 {
1188 @@ -813,8 +813,8 @@ int dnssec_validate_by_ds(time_t now, st
1189 }
1190 else
1191 {
1192 - a.addr.log.keytag = keytag;
1193 - a.addr.log.algo = algo;
1194 + a.log.keytag = keytag;
1195 + a.log.algo = algo;
1196 if (algo_digest_name(algo))
1197 log_query(F_NOEXTRA | F_KEYTAG | F_UPSTREAM, name, &a, "DNSKEY keytag %hu, algo %hu");
1198 else
1199 @@ -857,7 +857,7 @@ int dnssec_validate_ds(time_t now, struc
1200 int qtype, qclass, rc, i, neganswer, nons;
1201 int aclass, atype, rdlen;
1202 unsigned long ttl;
1203 - struct all_addr a;
1204 + union all_addr a;
1205
1206 if (ntohs(header->qdcount) != 1 ||
1207 !(p = skip_name(p, header, plen, 4)))
1208 @@ -925,11 +925,11 @@ int dnssec_validate_ds(time_t now, struc
1209
1210 if ((key = blockdata_alloc((char*)p, rdlen - 4)))
1211 {
1212 - a.addr.ds.digest = digest;
1213 - a.addr.ds.keydata = key;
1214 - a.addr.ds.algo = algo;
1215 - a.addr.ds.keytag = keytag;
1216 - a.addr.ds.keylen = rdlen - 4;
1217 + a.ds.digest = digest;
1218 + a.ds.keydata = key;
1219 + a.ds.algo = algo;
1220 + a.ds.keytag = keytag;
1221 + a.ds.keylen = rdlen - 4;
1222
1223 if (!cache_insert(name, &a, class, now, ttl, F_FORWARD | F_DS | F_DNSSECOK))
1224 {
1225 @@ -938,9 +938,9 @@ int dnssec_validate_ds(time_t now, struc
1226 }
1227 else
1228 {
1229 - a.addr.log.keytag = keytag;
1230 - a.addr.log.algo = algo;
1231 - a.addr.log.digest = digest;
1232 + a.log.keytag = keytag;
1233 + a.log.algo = algo;
1234 + a.log.digest = digest;
1235 if (ds_digest_name(digest) && algo_digest_name(algo))
1236 log_query(F_NOEXTRA | F_KEYTAG | F_UPSTREAM, name, &a, "DS keytag %hu, algo %hu, digest %hu");
1237 else
1238 @@ -1710,8 +1710,8 @@ static int zone_status(char *name, int c
1239 do
1240 {
1241 if (crecp->uid == (unsigned int)class &&
1242 - ds_digest_name(crecp->addr.addr.addr.ds.digest) &&
1243 - algo_digest_name(crecp->addr.addr.addr.ds.algo))
1244 + ds_digest_name(crecp->addr.ds.digest) &&
1245 + algo_digest_name(crecp->addr.ds.algo))
1246 break;
1247 }
1248 while ((crecp = cache_find_by_name(crecp, keyname, now, F_DS)));
1249 --- a/src/domain.c
1250 +++ b/src/domain.c
1251 @@ -21,7 +21,7 @@ static struct cond_domain *search_domain
1252 static struct cond_domain *search_domain6(struct in6_addr *addr, struct cond_domain *c);
1253
1254
1255 -int is_name_synthetic(int flags, char *name, struct all_addr *addr)
1256 +int is_name_synthetic(int flags, char *name, union all_addr *addr)
1257 {
1258 char *p;
1259 struct cond_domain *c = NULL;
1260 @@ -73,7 +73,7 @@ int is_name_synthetic(int flags, char *n
1261 if (!c->is6 &&
1262 index <= ntohl(c->end.s_addr) - ntohl(c->start.s_addr))
1263 {
1264 - addr->addr.addr4.s_addr = htonl(ntohl(c->start.s_addr) + index);
1265 + addr->addr4.s_addr = htonl(ntohl(c->start.s_addr) + index);
1266 found = 1;
1267 }
1268 }
1269 @@ -85,8 +85,8 @@ int is_name_synthetic(int flags, char *n
1270 index <= addr6part(&c->end6) - addr6part(&c->start6))
1271 {
1272 u64 start = addr6part(&c->start6);
1273 - addr->addr.addr6 = c->start6;
1274 - setaddr6part(&addr->addr.addr6, start + index);
1275 + addr->addr6 = c->start6;
1276 + setaddr6part(&addr->addr6, start + index);
1277 found = 1;
1278 }
1279 }
1280 @@ -139,16 +139,16 @@ int is_name_synthetic(int flags, char *n
1281 if (prot == AF_INET)
1282 {
1283 if (!c->is6 &&
1284 - ntohl(addr->addr.addr4.s_addr) >= ntohl(c->start.s_addr) &&
1285 - ntohl(addr->addr.addr4.s_addr) <= ntohl(c->end.s_addr))
1286 + ntohl(addr->addr4.s_addr) >= ntohl(c->start.s_addr) &&
1287 + ntohl(addr->addr4.s_addr) <= ntohl(c->end.s_addr))
1288 found = 1;
1289 }
1290 else
1291 {
1292 - u64 addrpart = addr6part(&addr->addr.addr6);
1293 + u64 addrpart = addr6part(&addr->addr6);
1294
1295 if (c->is6 &&
1296 - is_same_net6(&addr->addr.addr6, &c->start6, 64) &&
1297 + is_same_net6(&addr->addr6, &c->start6, 64) &&
1298 addrpart >= addr6part(&c->start6) &&
1299 addrpart <= addr6part(&c->end6))
1300 found = 1;
1301 @@ -173,18 +173,18 @@ int is_name_synthetic(int flags, char *n
1302 }
1303
1304
1305 -int is_rev_synth(int flag, struct all_addr *addr, char *name)
1306 +int is_rev_synth(int flag, union all_addr *addr, char *name)
1307 {
1308 struct cond_domain *c;
1309
1310 - if (flag & F_IPV4 && (c = search_domain(addr->addr.addr4, daemon->synth_domains)))
1311 + if (flag & F_IPV4 && (c = search_domain(addr->addr4, daemon->synth_domains)))
1312 {
1313 char *p;
1314
1315 *name = 0;
1316 if (c->indexed)
1317 {
1318 - unsigned int index = ntohl(addr->addr.addr4.s_addr) - ntohl(c->start.s_addr);
1319 + unsigned int index = ntohl(addr->addr4.s_addr) - ntohl(c->start.s_addr);
1320 snprintf(name, MAXDNAME, "%s%u", c->prefix ? c->prefix : "", index);
1321 }
1322 else
1323 @@ -192,7 +192,7 @@ int is_rev_synth(int flag, struct all_ad
1324 if (c->prefix)
1325 strncpy(name, c->prefix, MAXDNAME - ADDRSTRLEN);
1326
1327 - inet_ntop(AF_INET, &addr->addr.addr4, name + strlen(name), ADDRSTRLEN);
1328 + inet_ntop(AF_INET, &addr->addr4, name + strlen(name), ADDRSTRLEN);
1329 for (p = name; *p; p++)
1330 if (*p == '.')
1331 *p = '-';
1332 @@ -204,14 +204,14 @@ int is_rev_synth(int flag, struct all_ad
1333 return 1;
1334 }
1335
1336 - if ((flag & F_IPV6) && (c = search_domain6(&addr->addr.addr6, daemon->synth_domains)))
1337 + if ((flag & F_IPV6) && (c = search_domain6(&addr->addr6, daemon->synth_domains)))
1338 {
1339 char *p;
1340
1341 *name = 0;
1342 if (c->indexed)
1343 {
1344 - u64 index = addr6part(&addr->addr.addr6) - addr6part(&c->start6);
1345 + u64 index = addr6part(&addr->addr6) - addr6part(&c->start6);
1346 snprintf(name, MAXDNAME, "%s%llu", c->prefix ? c->prefix : "", index);
1347 }
1348 else
1349 @@ -219,14 +219,14 @@ int is_rev_synth(int flag, struct all_ad
1350 if (c->prefix)
1351 strncpy(name, c->prefix, MAXDNAME - ADDRSTRLEN);
1352
1353 - inet_ntop(AF_INET6, &addr->addr.addr6, name + strlen(name), ADDRSTRLEN);
1354 + inet_ntop(AF_INET6, &addr->addr6, name + strlen(name), ADDRSTRLEN);
1355
1356 /* IPv6 presentation address can start with ":", but valid domain names
1357 cannot start with "-" so prepend a zero in that case. */
1358 if (!c->prefix && *name == ':')
1359 {
1360 *name = '0';
1361 - inet_ntop(AF_INET6, &addr->addr.addr6, name+1, ADDRSTRLEN);
1362 + inet_ntop(AF_INET6, &addr->addr6, name+1, ADDRSTRLEN);
1363 }
1364
1365 /* V4-mapped have periods.... */
1366 --- a/src/forward.c
1367 +++ b/src/forward.c
1368 @@ -26,7 +26,7 @@ static void free_frec(struct frec *f);
1369 /* Send a UDP packet with its source address set as "source"
1370 unless nowild is true, when we just send it with the kernel default */
1371 int send_from(int fd, int nowild, char *packet, size_t len,
1372 - union mysockaddr *to, struct all_addr *source,
1373 + union mysockaddr *to, union all_addr *source,
1374 unsigned int iface)
1375 {
1376 struct msghdr msg;
1377 @@ -64,13 +64,13 @@ int send_from(int fd, int nowild, char *
1378 #if defined(HAVE_LINUX_NETWORK)
1379 struct in_pktinfo p;
1380 p.ipi_ifindex = 0;
1381 - p.ipi_spec_dst = source->addr.addr4;
1382 + p.ipi_spec_dst = source->addr4;
1383 memcpy(CMSG_DATA(cmptr), &p, sizeof(p));
1384 msg.msg_controllen = cmptr->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
1385 cmptr->cmsg_level = IPPROTO_IP;
1386 cmptr->cmsg_type = IP_PKTINFO;
1387 #elif defined(IP_SENDSRCADDR)
1388 - memcpy(CMSG_DATA(cmptr), &(source->addr.addr4), sizeof(source->addr.addr4));
1389 + memcpy(CMSG_DATA(cmptr), &(source->addr4), sizeof(source->addr4));
1390 msg.msg_controllen = cmptr->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
1391 cmptr->cmsg_level = IPPROTO_IP;
1392 cmptr->cmsg_type = IP_SENDSRCADDR;
1393 @@ -80,7 +80,7 @@ int send_from(int fd, int nowild, char *
1394 {
1395 struct in6_pktinfo p;
1396 p.ipi6_ifindex = iface; /* Need iface for IPv6 to handle link-local addrs */
1397 - p.ipi6_addr = source->addr.addr6;
1398 + p.ipi6_addr = source->addr6;
1399 memcpy(CMSG_DATA(cmptr), &p, sizeof(p));
1400 msg.msg_controllen = cmptr->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
1401 cmptr->cmsg_type = daemon->v6pktinfo;
1402 @@ -100,7 +100,7 @@ int send_from(int fd, int nowild, char *
1403 return 1;
1404 }
1405
1406 -static unsigned int search_servers(time_t now, struct all_addr **addrpp, unsigned int qtype,
1407 +static unsigned int search_servers(time_t now, union all_addr **addrpp, unsigned int qtype,
1408 char *qdomain, int *type, char **domain, int *norebind)
1409
1410 {
1411 @@ -112,7 +112,7 @@ static unsigned int search_servers(time_
1412 unsigned int matchlen = 0;
1413 struct server *serv;
1414 unsigned int flags = 0;
1415 - static struct all_addr zero;
1416 + static union all_addr zero;
1417
1418 for (serv = daemon->servers; serv; serv=serv->next)
1419 if (qtype == F_DNSSECOK && !(serv->flags & SERV_DO_DNSSEC))
1420 @@ -137,9 +137,9 @@ static unsigned int search_servers(time_
1421 {
1422 flags = sflag;
1423 if (serv->addr.sa.sa_family == AF_INET)
1424 - *addrpp = (struct all_addr *)&serv->addr.in.sin_addr;
1425 + *addrpp = (union all_addr *)&serv->addr.in.sin_addr;
1426 else
1427 - *addrpp = (struct all_addr *)&serv->addr.in6.sin6_addr;
1428 + *addrpp = (union all_addr *)&serv->addr.in6.sin6_addr;
1429 }
1430 else if (!flags || (flags & F_NXDOMAIN))
1431 flags = F_NOERR;
1432 @@ -195,9 +195,9 @@ static unsigned int search_servers(time_
1433 {
1434 flags = sflag;
1435 if (serv->addr.sa.sa_family == AF_INET)
1436 - *addrpp = (struct all_addr *)&serv->addr.in.sin_addr;
1437 + *addrpp = (union all_addr *)&serv->addr.in.sin_addr;
1438 else
1439 - *addrpp = (struct all_addr *)&serv->addr.in6.sin6_addr;
1440 + *addrpp = (union all_addr *)&serv->addr.in6.sin6_addr;
1441 }
1442 else if (!flags || (flags & F_NXDOMAIN))
1443 flags = F_NOERR;
1444 @@ -239,13 +239,13 @@ static unsigned int search_servers(time_
1445 }
1446
1447 static int forward_query(int udpfd, union mysockaddr *udpaddr,
1448 - struct all_addr *dst_addr, unsigned int dst_iface,
1449 + union all_addr *dst_addr, unsigned int dst_iface,
1450 struct dns_header *header, size_t plen, time_t now,
1451 struct frec *forward, int ad_reqd, int do_bit)
1452 {
1453 char *domain = NULL;
1454 int type = SERV_DO_DNSSEC, norebind = 0;
1455 - struct all_addr *addrp = NULL;
1456 + union all_addr *addrp = NULL;
1457 unsigned int flags = 0;
1458 struct server *start = NULL;
1459 #ifdef HAVE_DNSSEC
1460 @@ -289,9 +289,9 @@ static int forward_query(int udpfd, unio
1461 PUTSHORT(SAFE_PKTSZ, pheader);
1462
1463 if (forward->sentto->addr.sa.sa_family == AF_INET)
1464 - log_query(F_NOEXTRA | F_DNSSEC | F_IPV4, "retry", (struct all_addr *)&forward->sentto->addr.in.sin_addr, "dnssec");
1465 + log_query(F_NOEXTRA | F_DNSSEC | F_IPV4, "retry", (union all_addr *)&forward->sentto->addr.in.sin_addr, "dnssec");
1466 else
1467 - log_query(F_NOEXTRA | F_DNSSEC | F_IPV6, "retry", (struct all_addr *)&forward->sentto->addr.in6.sin6_addr, "dnssec");
1468 + log_query(F_NOEXTRA | F_DNSSEC | F_IPV6, "retry", (union all_addr *)&forward->sentto->addr.in6.sin6_addr, "dnssec");
1469
1470
1471 if (forward->sentto->sfd)
1472 @@ -523,10 +523,10 @@ static int forward_query(int udpfd, unio
1473 strcpy(daemon->namebuff, "query");
1474 if (start->addr.sa.sa_family == AF_INET)
1475 log_query(F_SERVER | F_IPV4 | F_FORWARD, daemon->namebuff,
1476 - (struct all_addr *)&start->addr.in.sin_addr, NULL);
1477 + (union all_addr *)&start->addr.in.sin_addr, NULL);
1478 else
1479 log_query(F_SERVER | F_IPV6 | F_FORWARD, daemon->namebuff,
1480 - (struct all_addr *)&start->addr.in6.sin6_addr, NULL);
1481 + (union all_addr *)&start->addr.in6.sin6_addr, NULL);
1482 start->queries++;
1483 forwarded = 1;
1484 forward->sentto = start;
1485 @@ -657,8 +657,8 @@ static size_t process_reply(struct dns_h
1486
1487 if (rcode != NOERROR && rcode != NXDOMAIN)
1488 {
1489 - struct all_addr a;
1490 - a.addr.log.rcode = rcode;
1491 + union all_addr a;
1492 + a.log.rcode = rcode;
1493 log_query(F_UPSTREAM | F_RCODE, "error", &a, NULL);
1494
1495 return resize_packet(header, n, pheader, plen);
1496 @@ -877,9 +877,9 @@ void reply_query(int fd, int family, tim
1497 sa_len(&start->addr))));
1498
1499 if (start->addr.sa.sa_family == AF_INET)
1500 - log_query(F_NOEXTRA | F_DNSSEC | F_IPV4, "retry", (struct all_addr *)&start->addr.in.sin_addr, "dnssec");
1501 + log_query(F_NOEXTRA | F_DNSSEC | F_IPV4, "retry", (union all_addr *)&start->addr.in.sin_addr, "dnssec");
1502 else
1503 - log_query(F_NOEXTRA | F_DNSSEC | F_IPV6, "retry", (struct all_addr *)&start->addr.in6.sin6_addr, "dnssec");
1504 + log_query(F_NOEXTRA | F_DNSSEC | F_IPV6, "retry", (union all_addr *)&start->addr.in6.sin6_addr, "dnssec");
1505
1506 return;
1507 }
1508 @@ -1094,10 +1094,10 @@ void reply_query(int fd, int family, tim
1509 daemon->keyname, forward->class, querytype, server->edns_pktsz);
1510
1511 if (server->addr.sa.sa_family == AF_INET)
1512 - log_query(F_NOEXTRA | F_DNSSEC | F_IPV4, daemon->keyname, (struct all_addr *)&(server->addr.in.sin_addr),
1513 + log_query(F_NOEXTRA | F_DNSSEC | F_IPV4, daemon->keyname, (union all_addr *)&(server->addr.in.sin_addr),
1514 querystr("dnssec-query", querytype));
1515 else
1516 - log_query(F_NOEXTRA | F_DNSSEC | F_IPV6, daemon->keyname, (struct all_addr *)&(server->addr.in6.sin6_addr),
1517 + log_query(F_NOEXTRA | F_DNSSEC | F_IPV6, daemon->keyname, (union all_addr *)&(server->addr.in6.sin6_addr),
1518 querystr("dnssec-query", querytype));
1519
1520 if ((hash = hash_questions(header, nn, daemon->namebuff)))
1521 @@ -1244,7 +1244,7 @@ void receive_query(struct listener *list
1522 union mysockaddr source_addr;
1523 unsigned char *pheader;
1524 unsigned short type, udp_size = PACKETSZ; /* default if no EDNS0 */
1525 - struct all_addr dst_addr;
1526 + union all_addr dst_addr;
1527 struct in_addr netmask, dst_addr_4;
1528 size_t m;
1529 ssize_t n;
1530 @@ -1274,7 +1274,7 @@ void receive_query(struct listener *list
1531 /* packet buffer overwritten */
1532 daemon->srv_save = NULL;
1533
1534 - dst_addr_4.s_addr = dst_addr.addr.addr4.s_addr = 0;
1535 + dst_addr_4.s_addr = dst_addr.addr4.s_addr = 0;
1536 netmask.s_addr = 0;
1537
1538 if (option_bool(OPT_NOWILD) && listen->iface)
1539 @@ -1283,7 +1283,7 @@ void receive_query(struct listener *list
1540
1541 if (listen->family == AF_INET)
1542 {
1543 - dst_addr_4 = dst_addr.addr.addr4 = listen->iface->addr.in.sin_addr;
1544 + dst_addr_4 = dst_addr.addr4 = listen->iface->addr.in.sin_addr;
1545 netmask = listen->iface->netmask;
1546 }
1547 }
1548 @@ -1337,7 +1337,7 @@ void receive_query(struct listener *list
1549 {
1550 for (addr = daemon->interface_addrs; addr; addr = addr->next)
1551 if ((addr->flags & ADDRLIST_IPV6) &&
1552 - is_same_net6(&addr->addr.addr.addr6, &source_addr.in6.sin6_addr, addr->prefixlen))
1553 + is_same_net6(&addr->addr.addr6, &source_addr.in6.sin6_addr, addr->prefixlen))
1554 break;
1555 }
1556 else
1557 @@ -1347,7 +1347,7 @@ void receive_query(struct listener *list
1558 {
1559 netmask.s_addr = htonl(~(in_addr_t)0 << (32 - addr->prefixlen));
1560 if (!(addr->flags & ADDRLIST_IPV6) &&
1561 - is_same_net(addr->addr.addr.addr4, source_addr.in.sin_addr, netmask))
1562 + is_same_net(addr->addr.addr4, source_addr.in.sin_addr, netmask))
1563 break;
1564 }
1565 }
1566 @@ -1380,7 +1380,7 @@ void receive_query(struct listener *list
1567 struct in_pktinfo *p;
1568 } p;
1569 p.c = CMSG_DATA(cmptr);
1570 - dst_addr_4 = dst_addr.addr.addr4 = p.p->ipi_spec_dst;
1571 + dst_addr_4 = dst_addr.addr4 = p.p->ipi_spec_dst;
1572 if_index = p.p->ipi_ifindex;
1573 }
1574 #elif defined(IP_RECVDSTADDR) && defined(IP_RECVIF)
1575 @@ -1398,7 +1398,7 @@ void receive_query(struct listener *list
1576 } p;
1577 p.c = CMSG_DATA(cmptr);
1578 if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVDSTADDR)
1579 - dst_addr_4 = dst_addr.addr.addr4 = *(p.a);
1580 + dst_addr_4 = dst_addr.addr4 = *(p.a);
1581 else if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
1582 #ifdef HAVE_SOLARIS_NETWORK
1583 if_index = *(p.i);
1584 @@ -1420,7 +1420,7 @@ void receive_query(struct listener *list
1585 } p;
1586 p.c = CMSG_DATA(cmptr);
1587
1588 - dst_addr.addr.addr6 = p.p->ipi6_addr;
1589 + dst_addr.addr6 = p.p->ipi6_addr;
1590 if_index = p.p->ipi6_ifindex;
1591 }
1592 }
1593 @@ -1486,10 +1486,10 @@ void receive_query(struct listener *list
1594
1595 if (listen->family == AF_INET)
1596 log_query(F_QUERY | F_IPV4 | F_FORWARD, daemon->namebuff,
1597 - (struct all_addr *)&source_addr.in.sin_addr, types);
1598 + (union all_addr *)&source_addr.in.sin_addr, types);
1599 else
1600 log_query(F_QUERY | F_IPV6 | F_FORWARD, daemon->namebuff,
1601 - (struct all_addr *)&source_addr.in6.sin6_addr, types);
1602 + (union all_addr *)&source_addr.in6.sin6_addr, types);
1603
1604 #ifdef HAVE_AUTH
1605 /* find queries for zones we're authoritative for, and answer them directly */
1606 @@ -1696,10 +1696,10 @@ static int tcp_key_recurse(time_t now, i
1607
1608
1609 if (server->addr.sa.sa_family == AF_INET)
1610 - log_query(F_NOEXTRA | F_DNSSEC | F_IPV4, keyname, (struct all_addr *)&(server->addr.in.sin_addr),
1611 + log_query(F_NOEXTRA | F_DNSSEC | F_IPV4, keyname, (union all_addr *)&(server->addr.in.sin_addr),
1612 querystr("dnssec-query", new_status == STAT_NEED_KEY ? T_DNSKEY : T_DS));
1613 else
1614 - log_query(F_NOEXTRA | F_DNSSEC | F_IPV6, keyname, (struct all_addr *)&(server->addr.in6.sin6_addr),
1615 + log_query(F_NOEXTRA | F_DNSSEC | F_IPV6, keyname, (union all_addr *)&(server->addr.in6.sin6_addr),
1616 querystr("dnssec-query", new_status == STAT_NEED_KEY ? T_DNSKEY : T_DS));
1617
1618 server->flags |= SERV_GOT_TCP;
1619 @@ -1764,12 +1764,12 @@ unsigned char *tcp_request(int confd, ti
1620 /* Get connection mark of incoming query to set on outgoing connections. */
1621 if (option_bool(OPT_CONNTRACK))
1622 {
1623 - struct all_addr local;
1624 + union all_addr local;
1625
1626 if (local_addr->sa.sa_family == AF_INET6)
1627 - local.addr.addr6 = local_addr->in6.sin6_addr;
1628 + local.addr6 = local_addr->in6.sin6_addr;
1629 else
1630 - local.addr.addr4 = local_addr->in.sin_addr;
1631 + local.addr4 = local_addr->in.sin_addr;
1632
1633 have_mark = get_incoming_mark(&peer_addr, &local, 1, &mark);
1634 }
1635 @@ -1784,7 +1784,7 @@ unsigned char *tcp_request(int confd, ti
1636 {
1637 for (addr = daemon->interface_addrs; addr; addr = addr->next)
1638 if ((addr->flags & ADDRLIST_IPV6) &&
1639 - is_same_net6(&addr->addr.addr.addr6, &peer_addr.in6.sin6_addr, addr->prefixlen))
1640 + is_same_net6(&addr->addr.addr6, &peer_addr.in6.sin6_addr, addr->prefixlen))
1641 break;
1642 }
1643 else
1644 @@ -1794,7 +1794,7 @@ unsigned char *tcp_request(int confd, ti
1645 {
1646 netmask.s_addr = htonl(~(in_addr_t)0 << (32 - addr->prefixlen));
1647 if (!(addr->flags & ADDRLIST_IPV6) &&
1648 - is_same_net(addr->addr.addr.addr4, peer_addr.in.sin_addr, netmask))
1649 + is_same_net(addr->addr.addr4, peer_addr.in.sin_addr, netmask))
1650 break;
1651 }
1652 }
1653 @@ -1841,10 +1841,10 @@ unsigned char *tcp_request(int confd, ti
1654
1655 if (peer_addr.sa.sa_family == AF_INET)
1656 log_query(F_QUERY | F_IPV4 | F_FORWARD, daemon->namebuff,
1657 - (struct all_addr *)&peer_addr.in.sin_addr, types);
1658 + (union all_addr *)&peer_addr.in.sin_addr, types);
1659 else
1660 log_query(F_QUERY | F_IPV6 | F_FORWARD, daemon->namebuff,
1661 - (struct all_addr *)&peer_addr.in6.sin6_addr, types);
1662 + (union all_addr *)&peer_addr.in6.sin6_addr, types);
1663
1664 #ifdef HAVE_AUTH
1665 /* find queries for zones we're authoritative for, and answer them directly */
1666 @@ -1900,7 +1900,7 @@ unsigned char *tcp_request(int confd, ti
1667 if (m == 0)
1668 {
1669 unsigned int flags = 0;
1670 - struct all_addr *addrp = NULL;
1671 + union all_addr *addrp = NULL;
1672 int type = SERV_DO_DNSSEC;
1673 char *domain = NULL;
1674 unsigned char *oph = find_pseudoheader(header, size, NULL, NULL, NULL, NULL);
1675 @@ -2019,10 +2019,10 @@ unsigned char *tcp_request(int confd, ti
1676
1677 if (last_server->addr.sa.sa_family == AF_INET)
1678 log_query(F_SERVER | F_IPV4 | F_FORWARD, daemon->namebuff,
1679 - (struct all_addr *)&last_server->addr.in.sin_addr, NULL);
1680 + (union all_addr *)&last_server->addr.in.sin_addr, NULL);
1681 else
1682 log_query(F_SERVER | F_IPV6 | F_FORWARD, daemon->namebuff,
1683 - (struct all_addr *)&last_server->addr.in6.sin6_addr, NULL);
1684 + (union all_addr *)&last_server->addr.in6.sin6_addr, NULL);
1685
1686 #ifdef HAVE_DNSSEC
1687 if (option_bool(OPT_DNSSEC_VALID) && !checking_disabled && (last_server->flags & SERV_DO_DNSSEC))
1688 --- a/src/helper.c
1689 +++ b/src/helper.c
1690 @@ -831,7 +831,7 @@ void queue_tftp(off_t file_len, char *fi
1691 }
1692 #endif
1693
1694 -void queue_arp(int action, unsigned char *mac, int maclen, int family, struct all_addr *addr)
1695 +void queue_arp(int action, unsigned char *mac, int maclen, int family, union all_addr *addr)
1696 {
1697 /* no script */
1698 if (daemon->helperfd == -1)
1699 @@ -844,9 +844,9 @@ void queue_arp(int action, unsigned char
1700 buf->hwaddr_len = maclen;
1701 buf->hwaddr_type = ARPHRD_ETHER;
1702 if ((buf->flags = family) == AF_INET)
1703 - buf->addr = addr->addr.addr4;
1704 + buf->addr = addr->addr4;
1705 else
1706 - buf->addr6 = addr->addr.addr6;
1707 + buf->addr6 = addr->addr6;
1708
1709 memcpy(buf->hwaddr, mac, maclen);
1710
1711 --- a/src/ipset.c
1712 +++ b/src/ipset.c
1713 @@ -114,7 +114,7 @@ void ipset_init(void)
1714 die (_("failed to create IPset control socket: %s"), NULL, EC_MISC);
1715 }
1716
1717 -static int new_add_to_ipset(const char *setname, const struct all_addr *ipaddr, int af, int remove)
1718 +static int new_add_to_ipset(const char *setname, const union all_addr *ipaddr, int af, int remove)
1719 {
1720 struct nlmsghdr *nlh;
1721 struct my_nfgenmsg *nfg;
1722 @@ -152,7 +152,7 @@ static int new_add_to_ipset(const char *
1723 nested[1]->nla_type = NLA_F_NESTED | IPSET_ATTR_IP;
1724 add_attr(nlh,
1725 (af == AF_INET ? IPSET_ATTR_IPADDR_IPV4 : IPSET_ATTR_IPADDR_IPV6) | NLA_F_NET_BYTEORDER,
1726 - addrsz, &ipaddr->addr);
1727 + addrsz, ipaddr);
1728 nested[1]->nla_len = (void *)buffer + NL_ALIGN(nlh->nlmsg_len) - (void *)nested[1];
1729 nested[0]->nla_len = (void *)buffer + NL_ALIGN(nlh->nlmsg_len) - (void *)nested[0];
1730
1731 @@ -163,7 +163,7 @@ static int new_add_to_ipset(const char *
1732 }
1733
1734
1735 -static int old_add_to_ipset(const char *setname, const struct all_addr *ipaddr, int remove)
1736 +static int old_add_to_ipset(const char *setname, const union all_addr *ipaddr, int remove)
1737 {
1738 socklen_t size;
1739 struct ip_set_req_adt_get {
1740 @@ -195,7 +195,7 @@ static int old_add_to_ipset(const char *
1741 return -1;
1742 req_adt.op = remove ? 0x102 : 0x101;
1743 req_adt.index = req_adt_get.set.index;
1744 - req_adt.ip = ntohl(ipaddr->addr.addr4.s_addr);
1745 + req_adt.ip = ntohl(ipaddr->addr4.s_addr);
1746 if (setsockopt(ipset_sock, SOL_IP, 83, &req_adt, sizeof(req_adt)) < 0)
1747 return -1;
1748
1749 @@ -204,7 +204,7 @@ static int old_add_to_ipset(const char *
1750
1751
1752
1753 -int add_to_ipset(const char *setname, const struct all_addr *ipaddr, int flags, int remove)
1754 +int add_to_ipset(const char *setname, const union all_addr *ipaddr, int flags, int remove)
1755 {
1756 int ret = 0, af = AF_INET;
1757
1758 --- a/src/lease.c
1759 +++ b/src/lease.c
1760 @@ -24,7 +24,7 @@ static int dns_dirty, file_dirty, leases
1761 static int read_leases(time_t now, FILE *leasestream)
1762 {
1763 unsigned long ei;
1764 - struct all_addr addr;
1765 + union all_addr addr;
1766 struct dhcp_lease *lease;
1767 int clid_len, hw_len, hw_type;
1768 int items;
1769 @@ -62,9 +62,9 @@ static int read_leases(time_t now, FILE
1770 daemon->namebuff, daemon->dhcp_buff, daemon->packet) != 3)
1771 return 0;
1772
1773 - if (inet_pton(AF_INET, daemon->namebuff, &addr.addr.addr4))
1774 + if (inet_pton(AF_INET, daemon->namebuff, &addr.addr4))
1775 {
1776 - if ((lease = lease4_allocate(addr.addr.addr4)))
1777 + if ((lease = lease4_allocate(addr.addr4)))
1778 domain = get_domain(lease->addr);
1779
1780 hw_len = parse_hex(daemon->dhcp_buff2, (unsigned char *)daemon->dhcp_buff2, DHCP_CHADDR_MAX, NULL, &hw_type);
1781 @@ -73,7 +73,7 @@ static int read_leases(time_t now, FILE
1782 hw_type = ARPHRD_ETHER;
1783 }
1784 #ifdef HAVE_DHCP6
1785 - else if (inet_pton(AF_INET6, daemon->namebuff, &addr.addr.addr6))
1786 + else if (inet_pton(AF_INET6, daemon->namebuff, &addr.addr6))
1787 {
1788 char *s = daemon->dhcp_buff2;
1789 int lease_type = LEASE_NA;
1790 @@ -84,7 +84,7 @@ static int read_leases(time_t now, FILE
1791 s++;
1792 }
1793
1794 - if ((lease = lease6_allocate(&addr.addr.addr6, lease_type)))
1795 + if ((lease = lease6_allocate(&addr.addr6, lease_type)))
1796 {
1797 lease_set_iaid(lease, strtoul(s, NULL, 10));
1798 domain = get_domain6(&lease->addr6);
1799 @@ -514,28 +514,28 @@ void lease_update_dns(int force)
1800 if (slaac->backoff == 0)
1801 {
1802 if (lease->fqdn)
1803 - cache_add_dhcp_entry(lease->fqdn, AF_INET6, (struct all_addr *)&slaac->addr, lease->expires);
1804 + cache_add_dhcp_entry(lease->fqdn, AF_INET6, (union all_addr *)&slaac->addr, lease->expires);
1805 if (!option_bool(OPT_DHCP_FQDN) && lease->hostname)
1806 - cache_add_dhcp_entry(lease->hostname, AF_INET6, (struct all_addr *)&slaac->addr, lease->expires);
1807 + cache_add_dhcp_entry(lease->hostname, AF_INET6, (union all_addr *)&slaac->addr, lease->expires);
1808 }
1809 }
1810
1811 if (lease->fqdn)
1812 cache_add_dhcp_entry(lease->fqdn, prot,
1813 - prot == AF_INET ? (struct all_addr *)&lease->addr : (struct all_addr *)&lease->addr6,
1814 + prot == AF_INET ? (union all_addr *)&lease->addr : (union all_addr *)&lease->addr6,
1815 lease->expires);
1816
1817 if (!option_bool(OPT_DHCP_FQDN) && lease->hostname)
1818 cache_add_dhcp_entry(lease->hostname, prot,
1819 - prot == AF_INET ? (struct all_addr *)&lease->addr : (struct all_addr *)&lease->addr6,
1820 + prot == AF_INET ? (union all_addr *)&lease->addr : (union all_addr *)&lease->addr6,
1821 lease->expires);
1822
1823 #else
1824 if (lease->fqdn)
1825 - cache_add_dhcp_entry(lease->fqdn, prot, (struct all_addr *)&lease->addr, lease->expires);
1826 + cache_add_dhcp_entry(lease->fqdn, prot, (union all_addr *)&lease->addr, lease->expires);
1827
1828 if (!option_bool(OPT_DHCP_FQDN) && lease->hostname)
1829 - cache_add_dhcp_entry(lease->hostname, prot, (struct all_addr *)&lease->addr, lease->expires);
1830 + cache_add_dhcp_entry(lease->hostname, prot, (union all_addr *)&lease->addr, lease->expires);
1831 #endif
1832 }
1833
1834 --- a/src/network.c
1835 +++ b/src/network.c
1836 @@ -109,7 +109,7 @@ int indextoname(int fd, int index, char
1837
1838 #endif
1839
1840 -int iface_check(int family, struct all_addr *addr, char *name, int *auth)
1841 +int iface_check(int family, union all_addr *addr, char *name, int *auth)
1842 {
1843 struct iname *tmp;
1844 int ret = 1, match_addr = 0;
1845 @@ -135,11 +135,11 @@ int iface_check(int family, struct all_a
1846 if (tmp->addr.sa.sa_family == family)
1847 {
1848 if (family == AF_INET &&
1849 - tmp->addr.in.sin_addr.s_addr == addr->addr.addr4.s_addr)
1850 + tmp->addr.in.sin_addr.s_addr == addr->addr4.s_addr)
1851 ret = match_addr = tmp->used = 1;
1852 else if (family == AF_INET6 &&
1853 IN6_ARE_ADDR_EQUAL(&tmp->addr.in6.sin6_addr,
1854 - &addr->addr.addr6))
1855 + &addr->addr6))
1856 ret = match_addr = tmp->used = 1;
1857 }
1858 }
1859 @@ -158,10 +158,10 @@ int iface_check(int family, struct all_a
1860 break;
1861 }
1862 else if (addr && tmp->addr.sa.sa_family == AF_INET && family == AF_INET &&
1863 - tmp->addr.in.sin_addr.s_addr == addr->addr.addr4.s_addr)
1864 + tmp->addr.in.sin_addr.s_addr == addr->addr4.s_addr)
1865 break;
1866 else if (addr && tmp->addr.sa.sa_family == AF_INET6 && family == AF_INET6 &&
1867 - IN6_ARE_ADDR_EQUAL(&tmp->addr.in6.sin6_addr, &addr->addr.addr6))
1868 + IN6_ARE_ADDR_EQUAL(&tmp->addr.in6.sin6_addr, &addr->addr6))
1869 break;
1870
1871 if (tmp && auth)
1872 @@ -179,7 +179,7 @@ int iface_check(int family, struct all_a
1873 an interface other than the loopback. Accept packet if it arrived via a loopback
1874 interface, even when we're not accepting packets that way, as long as the destination
1875 address is one we're believing. Interface list must be up-to-date before calling. */
1876 -int loopback_exception(int fd, int family, struct all_addr *addr, char *name)
1877 +int loopback_exception(int fd, int family, union all_addr *addr, char *name)
1878 {
1879 struct ifreq ifr;
1880 struct irec *iface;
1881 @@ -193,10 +193,10 @@ int loopback_exception(int fd, int famil
1882 {
1883 if (family == AF_INET)
1884 {
1885 - if (iface->addr.in.sin_addr.s_addr == addr->addr.addr4.s_addr)
1886 + if (iface->addr.in.sin_addr.s_addr == addr->addr4.s_addr)
1887 return 1;
1888 }
1889 - else if (IN6_ARE_ADDR_EQUAL(&iface->addr.in6.sin6_addr, &addr->addr.addr6))
1890 + else if (IN6_ARE_ADDR_EQUAL(&iface->addr.in6.sin6_addr, &addr->addr6))
1891 return 1;
1892 }
1893 }
1894 @@ -207,7 +207,7 @@ int loopback_exception(int fd, int famil
1895 on the relevant address, but the name of the arrival interface, derived from the
1896 index won't match the config. Check that we found an interface address for the arrival
1897 interface: daemon->interfaces must be up-to-date. */
1898 -int label_exception(int index, int family, struct all_addr *addr)
1899 +int label_exception(int index, int family, union all_addr *addr)
1900 {
1901 struct irec *iface;
1902
1903 @@ -217,7 +217,7 @@ int label_exception(int index, int famil
1904
1905 for (iface = daemon->interfaces; iface; iface = iface->next)
1906 if (iface->index == index && iface->addr.sa.sa_family == AF_INET &&
1907 - iface->addr.in.sin_addr.s_addr == addr->addr.addr4.s_addr)
1908 + iface->addr.in.sin_addr.s_addr == addr->addr4.s_addr)
1909 return 1;
1910
1911 return 0;
1912 @@ -282,12 +282,12 @@ static int iface_allowed(struct iface_pa
1913
1914 if (addr->sa.sa_family == AF_INET)
1915 {
1916 - al->addr.addr.addr4 = addr->in.sin_addr;
1917 + al->addr.addr4 = addr->in.sin_addr;
1918 al->flags = 0;
1919 }
1920 else
1921 {
1922 - al->addr.addr.addr6 = addr->in6.sin6_addr;
1923 + al->addr.addr6 = addr->in6.sin6_addr;
1924 al->flags = ADDRLIST_IPV6;
1925 }
1926 }
1927 @@ -321,7 +321,7 @@ static int iface_allowed(struct iface_pa
1928 al->next = zone->subnet;
1929 zone->subnet = al;
1930 al->prefixlen = prefixlen;
1931 - al->addr.addr.addr4 = addr->in.sin_addr;
1932 + al->addr.addr4 = addr->in.sin_addr;
1933 al->flags = 0;
1934 }
1935 }
1936 @@ -341,7 +341,7 @@ static int iface_allowed(struct iface_pa
1937 al->next = zone->subnet;
1938 zone->subnet = al;
1939 al->prefixlen = prefixlen;
1940 - al->addr.addr.addr6 = addr->in6.sin6_addr;
1941 + al->addr.addr6 = addr->in6.sin6_addr;
1942 al->flags = ADDRLIST_IPV6;
1943 }
1944 }
1945 @@ -369,12 +369,12 @@ static int iface_allowed(struct iface_pa
1946
1947 if (addr->sa.sa_family == AF_INET)
1948 {
1949 - al->addr.addr.addr4 = addr->in.sin_addr;
1950 + al->addr.addr4 = addr->in.sin_addr;
1951 al->flags = 0;
1952 }
1953 else
1954 {
1955 - al->addr.addr.addr6 = addr->in6.sin6_addr;
1956 + al->addr.addr6 = addr->in6.sin6_addr;
1957 al->flags = ADDRLIST_IPV6;
1958 /* Privacy addresses and addresses still undergoing DAD and deprecated addresses
1959 don't appear in forward queries, but will in reverse ones. */
1960 @@ -419,11 +419,11 @@ static int iface_allowed(struct iface_pa
1961 }
1962
1963 if (addr->sa.sa_family == AF_INET &&
1964 - !iface_check(AF_INET, (struct all_addr *)&addr->in.sin_addr, label, &auth_dns))
1965 + !iface_check(AF_INET, (union all_addr *)&addr->in.sin_addr, label, &auth_dns))
1966 return 1;
1967
1968 if (addr->sa.sa_family == AF_INET6 &&
1969 - !iface_check(AF_INET6, (struct all_addr *)&addr->in6.sin6_addr, label, &auth_dns))
1970 + !iface_check(AF_INET6, (union all_addr *)&addr->in6.sin6_addr, label, &auth_dns))
1971 return 1;
1972
1973 #ifdef HAVE_DHCP
1974 --- a/src/option.c
1975 +++ b/src/option.c
1976 @@ -2064,7 +2064,7 @@ static int one_opt(int option, char *arg
1977 int is_exclude = 0;
1978 char *prefix;
1979 struct addrlist *subnet = NULL;
1980 - struct all_addr addr;
1981 + union all_addr addr;
1982
1983 comma = split(arg);
1984 prefix = split_chr(arg, '/');
1985 @@ -2078,13 +2078,13 @@ static int one_opt(int option, char *arg
1986 arg = arg+8;
1987 }
1988
1989 - if (inet_pton(AF_INET, arg, &addr.addr.addr4))
1990 + if (inet_pton(AF_INET, arg, &addr.addr4))
1991 {
1992 subnet = opt_malloc(sizeof(struct addrlist));
1993 subnet->prefixlen = (prefixlen == 0) ? 24 : prefixlen;
1994 subnet->flags = ADDRLIST_LITERAL;
1995 }
1996 - else if (inet_pton(AF_INET6, arg, &addr.addr.addr6))
1997 + else if (inet_pton(AF_INET6, arg, &addr.addr6))
1998 {
1999 subnet = opt_malloc(sizeof(struct addrlist));
2000 subnet->prefixlen = (prefixlen == 0) ? 64 : prefixlen;
2001 @@ -4268,7 +4268,7 @@ err:
2002
2003 while (arg)
2004 {
2005 - struct all_addr addr;
2006 + union all_addr addr;
2007 char *dig;
2008
2009 for (dig = arg; *dig != 0; dig++)
2010 @@ -4276,10 +4276,10 @@ err:
2011 break;
2012 if (*dig == 0)
2013 new->ttl = atoi(arg);
2014 - else if (inet_pton(AF_INET, arg, &addr))
2015 - new->addr = addr.addr.addr4;
2016 - else if (inet_pton(AF_INET6, arg, &addr))
2017 - new->addr6 = addr.addr.addr6;
2018 + else if (inet_pton(AF_INET, arg, &addr.addr4))
2019 + new->addr = addr.addr4;
2020 + else if (inet_pton(AF_INET6, arg, &addr.addr6))
2021 + new->addr6 = addr.addr6;
2022 else
2023 {
2024 int nomem;
2025 --- a/src/rfc1035.c
2026 +++ b/src/rfc1035.c
2027 @@ -143,7 +143,7 @@ int extract_name(struct dns_header *head
2028
2029 /* Max size of input string (for IPv6) is 75 chars.) */
2030 #define MAXARPANAME 75
2031 -int in_arpa_name_2_addr(char *namein, struct all_addr *addrp)
2032 +int in_arpa_name_2_addr(char *namein, union all_addr *addrp)
2033 {
2034 int j;
2035 char name[MAXARPANAME+1], *cp1;
2036 @@ -153,7 +153,7 @@ int in_arpa_name_2_addr(char *namein, st
2037 if (strlen(namein) > MAXARPANAME)
2038 return 0;
2039
2040 - memset(addrp, 0, sizeof(struct all_addr));
2041 + memset(addrp, 0, sizeof(union all_addr));
2042
2043 /* turn name into a series of asciiz strings */
2044 /* j counts no. of labels */
2045 @@ -234,7 +234,7 @@ int in_arpa_name_2_addr(char *namein, st
2046 if (*(cp1+1) || !isxdigit((unsigned char)*cp1))
2047 return 0;
2048
2049 - for (j = sizeof(struct all_addr)-1; j>0; j--)
2050 + for (j = sizeof(struct in6_addr)-1; j>0; j--)
2051 addr[j] = (addr[j] >> 4) | (addr[j-1] << 4);
2052 addr[0] = (addr[0] >> 4) | (strtol(cp1, NULL, 16) << 4);
2053 }
2054 @@ -585,7 +585,7 @@ int extract_addresses(struct dns_header
2055 unsigned char *p, *p1, *endrr, *namep;
2056 int i, j, qtype, qclass, aqtype, aqclass, ardlen, res, searched_soa = 0;
2057 unsigned long ttl = 0;
2058 - struct all_addr addr;
2059 + union all_addr addr;
2060 #ifdef HAVE_IPSET
2061 char **ipsets_cur;
2062 #else
2063 @@ -808,14 +808,14 @@ int extract_addresses(struct dns_header
2064 if (check_rebind)
2065 {
2066 if ((flags & F_IPV4) &&
2067 - private_net(addr.addr.addr4, !option_bool(OPT_LOCAL_REBIND)))
2068 + private_net(addr.addr4, !option_bool(OPT_LOCAL_REBIND)))
2069 return 1;
2070
2071 if ((flags & F_IPV6) &&
2072 - IN6_IS_ADDR_V4MAPPED(&addr.addr.addr6))
2073 + IN6_IS_ADDR_V4MAPPED(&addr.addr6))
2074 {
2075 struct in_addr v4;
2076 - v4.s_addr = ((const uint32_t *) (&addr.addr.addr6))[3];
2077 + v4.s_addr = ((const uint32_t *) (&addr.addr6))[3];
2078 if (private_net(v4, !option_bool(OPT_LOCAL_REBIND)))
2079 return 1;
2080 }
2081 @@ -928,7 +928,7 @@ unsigned int extract_request(struct dns_
2082 }
2083
2084 size_t setup_reply(struct dns_header *header, size_t qlen,
2085 - struct all_addr *addrp, unsigned int flags, unsigned long ttl)
2086 + union all_addr *addrp, unsigned int flags, unsigned long ttl)
2087 {
2088 unsigned char *p;
2089
2090 @@ -949,8 +949,8 @@ size_t setup_reply(struct dns_header *he
2091 SET_RCODE(header, NXDOMAIN);
2092 else if (flags == F_SERVFAIL)
2093 {
2094 - struct all_addr a;
2095 - a.addr.log.rcode = SERVFAIL;
2096 + union all_addr a;
2097 + a.log.rcode = SERVFAIL;
2098 log_query(F_CONFIG | F_RCODE, "error", &a, NULL);
2099 SET_RCODE(header, SERVFAIL);
2100 }
2101 @@ -974,8 +974,8 @@ size_t setup_reply(struct dns_header *he
2102 }
2103 else /* nowhere to forward to */
2104 {
2105 - struct all_addr a;
2106 - a.addr.log.rcode = REFUSED;
2107 + union all_addr a;
2108 + a.log.rcode = REFUSED;
2109 log_query(F_CONFIG | F_RCODE, "error", &a, NULL);
2110 SET_RCODE(header, REFUSED);
2111 }
2112 @@ -1277,7 +1277,7 @@ size_t answer_request(struct dns_header
2113 char *name = daemon->namebuff;
2114 unsigned char *p, *ansp;
2115 unsigned int qtype, qclass;
2116 - struct all_addr addr;
2117 + union all_addr addr;
2118 int nameoffset;
2119 unsigned short flag;
2120 int q, ans, anscount = 0, addncount = 0;
2121 @@ -1374,7 +1374,7 @@ size_t answer_request(struct dns_header
2122 notimp = 1, auth = 0;
2123 if (!dryrun)
2124 {
2125 - addr.addr.log.rcode = NOTIMP;
2126 + addr.log.rcode = NOTIMP;
2127 log_query(F_CONFIG | F_RCODE, name, &addr, NULL);
2128 }
2129 ans = 1, sec_data = 0;
2130 @@ -1418,7 +1418,7 @@ size_t answer_request(struct dns_header
2131 struct addrlist *addrlist;
2132
2133 for (addrlist = intr->addr; addrlist; addrlist = addrlist->next)
2134 - if (!(addrlist->flags & ADDRLIST_IPV6) && addr.addr.addr4.s_addr == addrlist->addr.addr.addr4.s_addr)
2135 + if (!(addrlist->flags & ADDRLIST_IPV6) && addr.addr4.s_addr == addrlist->addr.addr4.s_addr)
2136 break;
2137
2138 if (addrlist)
2139 @@ -1433,7 +1433,7 @@ size_t answer_request(struct dns_header
2140 struct addrlist *addrlist;
2141
2142 for (addrlist = intr->addr; addrlist; addrlist = addrlist->next)
2143 - if ((addrlist->flags & ADDRLIST_IPV6) && IN6_ARE_ADDR_EQUAL(&addr.addr.addr6, &addrlist->addr.addr.addr6))
2144 + if ((addrlist->flags & ADDRLIST_IPV6) && IN6_ARE_ADDR_EQUAL(&addr.addr6, &addrlist->addr.addr6))
2145 break;
2146
2147 if (addrlist)
2148 @@ -1533,8 +1533,8 @@ size_t answer_request(struct dns_header
2149 }
2150 }
2151 else if (option_bool(OPT_BOGUSPRIV) && (
2152 - (is_arpa == F_IPV6 && private_net6(&addr.addr.addr6)) ||
2153 - (is_arpa == F_IPV4 && private_net(addr.addr.addr4, 1))))
2154 + (is_arpa == F_IPV6 && private_net6(&addr.addr6)) ||
2155 + (is_arpa == F_IPV4 && private_net(addr.addr4, 1))))
2156 {
2157 struct server *serv;
2158 unsigned int namelen = strlen(name);
2159 @@ -1600,7 +1600,7 @@ size_t answer_request(struct dns_header
2160 if (hostname_isequal(name, intr->name))
2161 for (addrlist = intr->addr; addrlist; addrlist = addrlist->next)
2162 if (!(addrlist->flags & ADDRLIST_IPV6) &&
2163 - is_same_net(*((struct in_addr *)&addrlist->addr), local_addr, local_netmask))
2164 + is_same_net(addrlist->addr.addr4, local_addr, local_netmask))
2165 {
2166 localise = 1;
2167 break;
2168 @@ -1613,7 +1613,7 @@ size_t answer_request(struct dns_header
2169 if (((addrlist->flags & ADDRLIST_IPV6) ? T_AAAA : T_A) == type)
2170 {
2171 if (localise &&
2172 - !is_same_net(*((struct in_addr *)&addrlist->addr), local_addr, local_netmask))
2173 + !is_same_net(addrlist->addr.addr4, local_addr, local_netmask))
2174 continue;
2175
2176 if (addrlist->flags & ADDRLIST_REVONLY)
2177 @@ -1651,7 +1651,7 @@ size_t answer_request(struct dns_header
2178 struct crec *save = crecp;
2179 do {
2180 if ((crecp->flags & F_HOSTS) &&
2181 - is_same_net(*((struct in_addr *)&crecp->addr), local_addr, local_netmask))
2182 + is_same_net(crecp->addr.addr4, local_addr, local_netmask))
2183 {
2184 localise = 1;
2185 break;
2186 @@ -1710,7 +1710,7 @@ size_t answer_request(struct dns_header
2187 filter here. */
2188 if (localise &&
2189 (crecp->flags & F_HOSTS) &&
2190 - !is_same_net(*((struct in_addr *)&crecp->addr), local_addr, local_netmask))
2191 + !is_same_net(crecp->addr.addr4, local_addr, local_netmask))
2192 continue;
2193
2194 if (!(crecp->flags & (F_HOSTS | F_DHCP)))
2195 @@ -1719,7 +1719,7 @@ size_t answer_request(struct dns_header
2196 ans = 1;
2197 if (!dryrun)
2198 {
2199 - log_query(crecp->flags & ~F_REVERSE, name, &crecp->addr.addr,
2200 + log_query(crecp->flags & ~F_REVERSE, name, &crecp->addr,
2201 record_source(crecp->uid));
2202
2203 if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
2204 --- a/src/rfc3315.c
2205 +++ b/src/rfc3315.c
2206 @@ -2120,7 +2120,7 @@ void relay_upstream6(struct dhcp_relay *
2207 {
2208 /* ->local is same value for all relays on ->current chain */
2209
2210 - struct all_addr from;
2211 + union all_addr from;
2212 unsigned char *header;
2213 unsigned char *inbuff = daemon->dhcp_packet.iov_base;
2214 int msg_type = *inbuff;
2215 @@ -2133,7 +2133,7 @@ void relay_upstream6(struct dhcp_relay *
2216 get_client_mac(peer_address, scope_id, mac, &maclen, &mactype, now);
2217
2218 /* source address == relay address */
2219 - from.addr.addr6 = relay->local.addr.addr6;
2220 + from.addr6 = relay->local.addr6;
2221
2222 /* Get hop count from nested relayed message */
2223 if (msg_type == DHCP6RELAYFORW)
2224 @@ -2153,7 +2153,7 @@ void relay_upstream6(struct dhcp_relay *
2225
2226 header[0] = DHCP6RELAYFORW;
2227 header[1] = hopcount;
2228 - memcpy(&header[2], &relay->local.addr.addr6, IN6ADDRSZ);
2229 + memcpy(&header[2], &relay->local.addr6, IN6ADDRSZ);
2230 memcpy(&header[18], peer_address, IN6ADDRSZ);
2231
2232 /* RFC-6939 */
2233 @@ -2174,12 +2174,12 @@ void relay_upstream6(struct dhcp_relay *
2234 union mysockaddr to;
2235
2236 to.sa.sa_family = AF_INET6;
2237 - to.in6.sin6_addr = relay->server.addr.addr6;
2238 + to.in6.sin6_addr = relay->server.addr6;
2239 to.in6.sin6_port = htons(DHCPV6_SERVER_PORT);
2240 to.in6.sin6_flowinfo = 0;
2241 to.in6.sin6_scope_id = 0;
2242
2243 - if (IN6_ARE_ADDR_EQUAL(&relay->server.addr.addr6, &multicast))
2244 + if (IN6_ARE_ADDR_EQUAL(&relay->server.addr6, &multicast))
2245 {
2246 int multicast_iface;
2247 if (!relay->interface || strchr(relay->interface, '*') ||
2248 @@ -2218,7 +2218,7 @@ unsigned short relay_reply6(struct socka
2249 memcpy(&link, &inbuff[2], IN6ADDRSZ);
2250
2251 for (relay = daemon->relay6; relay; relay = relay->next)
2252 - if (IN6_ARE_ADDR_EQUAL(&link, &relay->local.addr.addr6) &&
2253 + if (IN6_ARE_ADDR_EQUAL(&link, &relay->local.addr6) &&
2254 (!relay->interface || wildcard_match(relay->interface, arrival_interface)))
2255 break;
2256
2257 --- a/src/tables.c
2258 +++ b/src/tables.c
2259 @@ -62,7 +62,7 @@ void ipset_init(void)
2260 }
2261 }
2262
2263 -int add_to_ipset(const char *setname, const struct all_addr *ipaddr,
2264 +int add_to_ipset(const char *setname, const union all_addr *ipaddr,
2265 int flags, int remove)
2266 {
2267 struct pfr_addr addr;
2268 @@ -113,13 +113,13 @@ int add_to_ipset(const char *setname, co
2269 {
2270 addr.pfra_af = AF_INET6;
2271 addr.pfra_net = 0x80;
2272 - memcpy(&(addr.pfra_ip6addr), &(ipaddr->addr), sizeof(struct in6_addr));
2273 + memcpy(&(addr.pfra_ip6addr), ipaddr, sizeof(struct in6_addr));
2274 }
2275 else
2276 {
2277 addr.pfra_af = AF_INET;
2278 addr.pfra_net = 0x20;
2279 - addr.pfra_ip4addr.s_addr = ipaddr->addr.addr4.s_addr;
2280 + addr.pfra_ip4addr.s_addr = ipaddr->addr4.s_addr;
2281 }
2282
2283 bzero(&io, sizeof(io));
2284 --- a/src/tftp.c
2285 +++ b/src/tftp.c
2286 @@ -59,7 +59,7 @@ void tftp_request(struct listener *liste
2287 char *name = NULL;
2288 char *prefix = daemon->tftp_prefix;
2289 struct tftp_prefix *pref;
2290 - struct all_addr addra;
2291 + union all_addr addra;
2292 /* Can always get recvd interface for IPv6 */
2293 int check_dest = !option_bool(OPT_NOWILD) || listen->family == AF_INET6;
2294 union {
2295 @@ -189,10 +189,10 @@ void tftp_request(struct listener *liste
2296
2297 name = namebuff;
2298
2299 - addra.addr.addr4 = addr.in.sin_addr;
2300 + addra.addr4 = addr.in.sin_addr;
2301
2302 if (listen->family == AF_INET6)
2303 - addra.addr.addr6 = addr.in6.sin6_addr;
2304 + addra.addr6 = addr.in6.sin6_addr;
2305
2306 if (daemon->tftp_interfaces)
2307 {
2308 @@ -212,7 +212,7 @@ void tftp_request(struct listener *liste
2309 if (!option_bool(OPT_CLEVERBIND))
2310 enumerate_interfaces(0);
2311 if (!loopback_exception(listen->tftpfd, listen->family, &addra, name) &&
2312 - !label_exception(if_index, listen->family, &addra) )
2313 + !label_exception(if_index, listen->family, &addra))
2314 return;
2315 }
2316