diff options
author | nectar <nectar@FreeBSD.org> | 2002-05-13 19:31:58 +0000 |
---|---|---|
committer | nectar <nectar@FreeBSD.org> | 2002-05-13 19:31:58 +0000 |
commit | e044c1fb924b46fc1bd38b298ebea9ff73ea93a8 (patch) | |
tree | ad4e7f0a2c657d90248bf0c8bd8fac9e5f66a622 /contrib | |
parent | ebeabb1ba32f14e308ae9aff9a2a7151265259cf (diff) | |
download | FreeBSD-src-e044c1fb924b46fc1bd38b298ebea9ff73ea93a8.zip FreeBSD-src-e044c1fb924b46fc1bd38b298ebea9ff73ea93a8.tar.gz |
Import of ISC BIND 8.3.2-T1B.
Diffstat (limited to 'contrib')
42 files changed, 3436 insertions, 2267 deletions
diff --git a/contrib/bind/CHANGES b/contrib/bind/CHANGES index 80fb7bc..768e601 100644 --- a/contrib/bind/CHANGES +++ b/contrib/bind/CHANGES @@ -1,6 +1,92 @@ + --- 8.3.2-T1B released --- (Tue May 7 18:49:58 PDT 2002) + +1263. [bug] gethostans() could get out of sync parsing the + response if there was a very long CNAME chain. + +1262. [bug] winnt: dumpdb and stats should now work reliably. + +1261. [bug] using a valid TSIG with a compressed ownername could + result a INSIST() failure. + +1260. [func] "notify explicit;" from BIND 9. + +1259. [misc] leave the verification of the OPT options to the + caller. + +1258. [func] accept SOA MNAME field as legitimate additional + data. + +1257. [bug] malformed response to query w/ tsig + edns. + +1256. [port] darwin: probe for IPv6 support. + +1255. [bug] xfers_running could become out of sync if a zone + was removed while it was being transfered. + +1254. [func] nsupdate can now update IPv6 servers. + +1253. [func] host now accepts IPv6 addresses. + +1253. [bug] reserve space for the signature when performing a + zone transfer. + +1252. [func] dnsquery now accepts IPv6 addresses. + +1251. [bug] win32: it was possible to call RegCloseKey() on a + invalid key. + +1250 [func] nslookup now accepts IPv6 addresses. + +1249. [func] dig now accepts IPv6 addresses. + +1248. [doc] correct some typos in named.conf.5 and corresponding + html. + +1247. [bug] get_salen() IPv6 support was broken for OSs w/o sa_len. + +1246. [support] add highly dangerous compile time option + NXDOMAIN_ON_DENIAL. it should not be used + except in testing. + +1245. [bug] if we don't have enough file descriptors to open + a socket attempt to close a idle tcp client. + +1244. [port] bsdi: 4.3 has struct sockaddr_storage. + +1243. [bug] SERVFAIL can have too many other causes to be used + say whether a server supports EDNS or not. + +1242. [port] 64k answer buffers were causing stack space to be + exceeded for certian OS. Use heap space instead. + +1241. [bug] getnameinfo() failed to lookup IPv4 mapped / + compatible addresses. + +1340. [bug] reference after free for included conf file name. + +1339. [bug] doaddinfo would not always attempt to fetch missing + glue when it should have. + +1338. [bug] an IPv6 only nameserver could generate spurious + sysquery errors. + +1337. [port] linux: IN6ADDR_LOOPBACK_INIT, IN6ADDR_ANY_INIT and + sockaddr_storage not declared by early kernels. + +1336. [bug] getaddrinfo() could call freeaddrinfo() with an + invalid pointer. + +1335. [bug] res_nupdate() failed to update the name servers + addresses before sending the update. + +1334. [bug] A6 is expected in the additional section. + --- 8.3.1-REL released --- (Thu Jan 31 21:28:59 PST 2002) +1333. [bug] cached NXDOMAIN/NODATA responses were being ignored + when when fetching missing additional data. + 1332. [func] "allow-query" is now supported for forward zones. #define FORWARD_ALLOWS in bin/named/named.h to enable. @@ -24,10 +110,6 @@ 1324. [bug] certian bad delegations could result in a DNS storm. -1323. [bug] cached NXDOMAIN/NODATA responses were being ignored - when when fetching missing additional data. - - --- 8.3.0-REL released --- (Fri Jan 11 04:00:00 PST 2002) 1323. [bug] don't assume statp->_u._ext.ext is valid unless diff --git a/contrib/bind/README b/contrib/bind/README index 45f37a4..344a3ef 100644 --- a/contrib/bind/README +++ b/contrib/bind/README @@ -10,6 +10,9 @@ artifacts including BIND, INN, and DHCP. Note that BIND 8 is in "end-of-life", having been replaced by BIND 9. See http://www.isc.org/ for more details. +BIND 8.3.2 Highlights + dig, nslookup, host and nsupdate have improved IPv6 support. + BIND 8.3.1 Highlights Critical bug fix to prevent DNS storms. If you have BIND 8.3.0 you need to upgrade. diff --git a/contrib/bind/Version b/contrib/bind/Version index 067312ac..96227ce 100644 --- a/contrib/bind/Version +++ b/contrib/bind/Version @@ -1 +1 @@ -8.3.1-REL +8.3.2-T1B diff --git a/contrib/bind/bin/dig/dig.c b/contrib/bind/bin/dig/dig.c index 037a495..2054258 100644 --- a/contrib/bind/bin/dig/dig.c +++ b/contrib/bind/bin/dig/dig.c @@ -1,5 +1,5 @@ #ifndef lint -static const char rcsid[] = "$Id: dig.c,v 8.51 2001/12/19 02:25:17 marka Exp $"; +static const char rcsid[] = "$Id: dig.c,v 8.54 2002/04/24 00:38:08 marka Exp $"; #endif /* @@ -172,7 +172,6 @@ static const char rcsid[] = "$Id: dig.c,v 8.51 2001/12/19 02:25:17 marka Exp $"; #include <errno.h> #include <fcntl.h> #include <netdb.h> -#include <resolv.h> #include <setjmp.h> #include <stdio.h> #include <stdlib.h> @@ -181,6 +180,8 @@ static const char rcsid[] = "$Id: dig.c,v 8.51 2001/12/19 02:25:17 marka Exp $"; #include "port_after.h" +#include <resolv.h> + #include "../nslookup/res.h" /* Global. */ @@ -209,9 +210,10 @@ static int eecode = 0; static FILE * qfp; static char *defsrv, *srvmsg; static char defbuf[40] = "default -- "; -static char srvbuf[60]; +static char srvbuf[1024]; static char myhostname[MAXHOSTNAMELEN]; static struct sockaddr_in myaddress; +static struct sockaddr_in6 myaddress6; static u_int32_t ixfr_serial; /* stuff for nslookup modules */ @@ -248,8 +250,8 @@ static void stackarg(char *, char **); int main(int argc, char **argv) { - struct hostent *hp; short port = htons(NAMESERVER_PORT); + short lport; /* Wierd stuff for SPARC alignment, hurts nothing else. */ union { HEADER header_; @@ -302,6 +304,14 @@ main(int argc, char **argv) { myaddress.sin_family = AF_INET; myaddress.sin_addr.s_addr = INADDR_ANY; myaddress.sin_port = 0; /*INPORT_ANY*/; + +#ifdef HAVE_SA_LEN + myaddress6.sin6_len = sizeof(struct sockaddr_in6); +#endif + myaddress6.sin6_family = AF_INET6; + myaddress6.sin6_addr = in6addr_any; + myaddress6.sin6_port = 0; /*INPORT_ANY*/; + defsrv = strcat(defbuf, inet_ntoa(res.nsaddr.sin_addr)); res_x = res; @@ -498,7 +508,7 @@ main(int argc, char **argv) { break; case 'p': if (argv[0][2] != '\0') - port = ntohs(atoi(argv[0]+2)); + port = htons(atoi(argv[0]+2)); else if (*++argv == NULL) printf("; no arg for -p?\n"); else @@ -530,14 +540,19 @@ main(int argc, char **argv) { a = *argv; if ((p = strchr(a, ':')) != NULL) { *p++ = '\0'; - myaddress.sin_port = - ntohs(atoi(p)); - } - if (!inet_aton(a,&myaddress.sin_addr)){ + lport = htons(atoi(p)); + } else + lport = htons(0); + if (inet_pton(AF_INET6, a, + &myaddress6.sin6_addr) == 1) { + myaddress6.sin6_port = lport; + } else if (!inet_aton(a, + &myaddress.sin_addr)) { fprintf(stderr, ";; bad -b addr\n"); exit(1); - } + } else + myaddress.sin_port = lport; } break; case 'k': @@ -749,82 +764,113 @@ main(int argc, char **argv) { srvbuf[0] = 0; srvmsg = defsrv; if (srv != NULL) { - struct in_addr addr; - - if (inet_aton(srv, &addr)) { - res.nscount = 1; - res.nsaddr.sin_addr = addr; - srvmsg = strcat(srvbuf, srv); - } else { - res_t = res; - res_ninit(&res); - res.pfcode = 0; - res.options = RES_DEFAULT; - hp = gethostbyname(srv); + int nscount = 0; + union res_sockaddr_union u[MAXNS]; + struct addrinfo *answer = NULL; + struct addrinfo *cur = NULL; + struct addrinfo hint; + + memset(u, 0, sizeof(u)); + res_t = res; + res_ninit(&res); + res.pfcode = 0; + res.options = RES_DEFAULT; + memset(&hint, 0, sizeof(hint)); + hint.ai_socktype = SOCK_DGRAM; + if (!getaddrinfo(srv, NULL, &hint, &answer)) { res = res_t; - if (hp == NULL - || hp->h_addr_list == NULL - || *hp->h_addr_list == NULL) { - fflush(stdout); - fprintf(stderr, - "; Bad server: %s -- using default server and timer opts\n", - srv); - fflush(stderr); - srvmsg = defsrv; - srv = NULL; - } else { - u_int32_t **addr; - - res.nscount = 0; - for (addr = (u_int32_t**)hp->h_addr_list; - *addr && (res.nscount < MAXNS); - addr++) { - res.nsaddr_list[ - res.nscount++ - ].sin_addr.s_addr = **addr; + cur = answer; + for (cur = answer; + cur != NULL; + cur = cur->ai_next) { + if (nscount == MAXNS) + break; + switch (cur->ai_addr->sa_family) { + case AF_INET6: + u[nscount].sin6 = + *(struct sockaddr_in6*)cur->ai_addr; + u[nscount++].sin6.sin6_port = + port; + break; + case AF_INET: + u[nscount].sin = + *(struct sockaddr_in*)cur->ai_addr; + u[nscount++].sin6.sin6_port = + port; + break; } - - srvmsg = strcat(srvbuf,srv); + } + if (nscount != 0) { + char buf[80]; + res_setservers(&res, u, nscount); + srvmsg = strcat(srvbuf, srv); strcat(srvbuf, " "); - strcat(srvmsg, - inet_ntoa(res.nsaddr.sin_addr)); + buf[0] = '\0'; + switch (u[0].sin.sin_family) { + case AF_INET: + inet_ntop(AF_INET, + &u[0].sin.sin_addr, + buf, sizeof(buf)); + break; + case AF_INET6: + inet_ntop(AF_INET, + &u[0].sin6.sin6_addr, + buf, sizeof(buf)); + break; + } + strcat(srvbuf, buf); } + freeaddrinfo(answer); + } else { + res = res_t; + fflush(stdout); + fprintf(stderr, + "; Bad server: %s -- using default server and timer opts\n", + srv); + fflush(stderr); + srvmsg = defsrv; + srv = NULL; } printf("; (%d server%s found)\n", res.nscount, (res.nscount==1)?"":"s"); res.id += res.retry; } - { - int i; - - for (i = 0; i < res.nscount; i++) { - res.nsaddr_list[i].sin_family = AF_INET; - res.nsaddr_list[i].sin_port = port; - } - res.id += res.retry; - } - if (ns_t_xfr_p(xfr)) { int i; - + int nscount; + union res_sockaddr_union u[MAXNS]; + nscount = res_getservers(&res, u, MAXNS); for (i = 0; i < res.nscount; i++) { int x; if (keyfile) x = printZone(xfr, domain, - &res.nsaddr_list[i], + &u[i].sin, &key); else x = printZone(xfr, domain, - &res.nsaddr_list[i], + &u[i].sin, NULL); if (res.pfcode & RES_PRF_STATS) { + char buf[80]; exectime = time(NULL); + buf[0] = '\0'; + switch (u[i].sin.sin_family) { + case AF_INET: + inet_ntop(AF_INET, + &u[i].sin.sin_addr, + buf, sizeof(buf)); + break; + case AF_INET6: + inet_ntop(AF_INET6, + &u[i].sin6.sin6_addr, + buf, sizeof(buf)); + break; + } printf(";; FROM: %s to SERVER: %s\n", myhostname, - inet_ntoa(res.nsaddr_list[i] - .sin_addr)); + buf); printf(";; WHEN: %s", ctime(&exectime)); } if (!x) @@ -984,7 +1030,7 @@ where: server,\n\ fputs("\ notes: defname and search don't work; use fully-qualified names.\n\ this is DiG version " VSTRING "\n\ - $Id: dig.c,v 8.51 2001/12/19 02:25:17 marka Exp $\n\ + $Id: dig.c,v 8.54 2002/04/24 00:38:08 marka Exp $\n\ ", stderr); } @@ -1322,24 +1368,56 @@ printZone(ns_type xfr, const char *zone, const struct sockaddr_in *sin, perror(";; socket"); return (e); } - if (bind(sockFD, (struct sockaddr *)&myaddress, sizeof myaddress) < 0){ - int e = errno; + + switch (sin->sin_family) { + case AF_INET: + if (bind(sockFD, (struct sockaddr *)&myaddress, + sizeof myaddress) < 0){ + int e = errno; - fprintf(stderr, ";; bind(%s:%u): %s\n", - inet_ntoa(myaddress.sin_addr), - ntohs(myaddress.sin_port), - strerror(e)); - (void) close(sockFD); - sockFD = -1; - return (e); - } - if (connect(sockFD, (const struct sockaddr *)sin, sizeof *sin) < 0) { - int e = errno; + fprintf(stderr, ";; bind(%s:%u): %s\n", + inet_ntoa(myaddress.sin_addr), + ntohs(myaddress.sin_port), + strerror(e)); + (void) close(sockFD); + sockFD = -1; + return (e); + } + if (connect(sockFD, (const struct sockaddr *)sin, + sizeof *sin) < 0) { + int e = errno; - perror(";; connect"); - (void) close(sockFD); - sockFD = -1; - return (e); + perror(";; connect"); + (void) close(sockFD); + sockFD = -1; + return (e); + } + break; + case AF_INET6: + if (bind(sockFD, (struct sockaddr *)&myaddress6, + sizeof myaddress6) < 0){ + int e = errno; + char buf[80]; + + fprintf(stderr, ";; bind(%s:%u): %s\n", + inet_ntop(AF_INET6, &myaddress6.sin6_addr, + buf, sizeof(buf)), + ntohs(myaddress6.sin6_port), + strerror(e)); + (void) close(sockFD); + sockFD = -1; + return (e); + } + if (connect(sockFD, (const struct sockaddr *)sin, + sizeof(struct sockaddr_in6)) < 0) { + int e = errno; + + perror(";; connect"); + (void) close(sockFD); + sockFD = -1; + return (e); + } + break; } /* diff --git a/contrib/bind/bin/dnsquery/dnsquery.c b/contrib/bind/bin/dnsquery/dnsquery.c index c9fed3c..cbc1e85 100644 --- a/contrib/bind/bin/dnsquery/dnsquery.c +++ b/contrib/bind/bin/dnsquery/dnsquery.c @@ -1,5 +1,5 @@ #if !defined(lint) && !defined(SABER) -static const char rcsid[] = "$Id: dnsquery.c,v 8.16 2001/09/25 04:50:15 marka Exp $"; +static const char rcsid[] = "$Id: dnsquery.c,v 8.19 2002/04/12 03:03:48 marka Exp $"; #endif /* not lint */ /* @@ -30,7 +30,6 @@ static const char rcsid[] = "$Id: dnsquery.c,v 8.16 2001/09/25 04:50:15 marka Ex #include <errno.h> #include <netdb.h> -#include <resolv.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -38,21 +37,54 @@ static const char rcsid[] = "$Id: dnsquery.c,v 8.16 2001/09/25 04:50:15 marka Ex #include "port_after.h" +#include <resolv.h> + extern int errno; extern int h_errno; extern char *h_errlist[]; struct __res_state res; +static int +newserver(char *srv, union res_sockaddr_union *u, int ns, int max) { + struct addrinfo *answer = NULL; + struct addrinfo *cur = NULL; + struct addrinfo hint; + short port = htons(NAMESERVER_PORT); + + memset(&hint, 0, sizeof(hint)); + hint.ai_socktype = SOCK_DGRAM; + if (!getaddrinfo(srv, NULL, &hint, &answer)) { + for (cur = answer; cur != NULL; cur = cur->ai_next) { + if (ns >= max) + break; + switch (cur->ai_addr->sa_family) { + case AF_INET6: + u[ns].sin6 = + *(struct sockaddr_in6*)cur->ai_addr; + u[ns++].sin6.sin6_port = port; + break; + case AF_INET: + u[ns].sin = *(struct sockaddr_in*)cur->ai_addr; + u[ns++].sin6.sin6_port = port; + break; + } + } + freeaddrinfo(answer); + } else { + fprintf(stderr, "Bad nameserver (%s)\n", srv); + exit(1); + } + return (ns); +} + int main(int argc, char *argv[]) { char name[MAXDNAME]; u_char answer[8*1024]; - int c, n, i = 0; - u_int32_t ul; + int c, n; int nameservers = 0, class, type, len; - struct in_addr q_nsaddr[MAXNS]; - struct hostent *q_nsname; + union res_sockaddr_union q_nsaddr[MAXNS]; extern int optind, opterr; extern char *optarg; int stream = 0, debug = 0; @@ -137,23 +169,8 @@ main(int argc, char *argv[]) { ); exit(1); } - if (nameservers >= MAXNS) break; - (void) inet_aton(optarg, - &q_nsaddr[nameservers]); - if (!inet_aton(optarg, (struct in_addr *)&ul)){ - q_nsname = gethostbyname(optarg); - if (q_nsname == 0) { - fprintf(stderr, - "Bad nameserver (%s)\n", - optarg); - exit(1); - } - memcpy(&q_nsaddr[nameservers], - q_nsname->h_addr, INADDRSZ); - } - else - q_nsaddr[nameservers].s_addr = ul; - nameservers++; + nameservers = newserver(optarg, q_nsaddr, + nameservers, MAXNS); break; default : fprintf(stderr, @@ -189,14 +206,8 @@ main(int argc, char *argv[]) { res.options |= RES_USEVC; /* if the -n flag was used, add them to the resolver's list */ - if (nameservers != 0) { - res.nscount = nameservers; - for (i = nameservers - 1; i >= 0; i--) { - res.nsaddr_list[i].sin_addr.s_addr = q_nsaddr[i].s_addr; - res.nsaddr_list[i].sin_family = AF_INET; - res.nsaddr_list[i].sin_port = htons(NAMESERVER_PORT); - } - } + if (nameservers != 0) + res_setservers(&res, q_nsaddr, nameservers); /* * if the -h arg is fully-qualified, use res_query() since diff --git a/contrib/bind/bin/host/host.c b/contrib/bind/bin/host/host.c index eb28564..84b3621 100644 --- a/contrib/bind/bin/host/host.c +++ b/contrib/bind/bin/host/host.c @@ -1,5 +1,5 @@ #ifndef lint -static const char rcsid[] = "$Id: host.c,v 8.49 2001/12/17 04:24:37 marka Exp $"; +static const char rcsid[] = "$Id: host.c,v 8.52 2002/04/28 01:34:52 marka Exp $"; #endif /* not lint */ /* @@ -100,7 +100,6 @@ static const char copyright[] = #include <ctype.h> #include <netdb.h> -#include <resolv.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -113,6 +112,8 @@ static const char copyright[] = #include "port_after.h" +#include <resolv.h> + /* Global. */ #ifndef PATH_SEP @@ -185,9 +186,8 @@ static char getdomain[NS_MAXDNAME]; static int parsetype(const char *s); static int parseclass(const char *s); -static void printanswer(const struct hostent *hp); static void hperror(int errnum); -static int addrinfo(struct in_addr addr); +static int addrinfo(struct sockaddr_storage *addr); static int gethostinfo(char *name); static int getdomaininfo(const char *name, const char *domain); static int getinfo(const char *name, const char *domain, @@ -225,12 +225,16 @@ Usage: %s [-adlrwv] [-t querytype] [-c class] host [server]\n\ int main(int argc, char **argv) { - struct in_addr addr; + struct sockaddr_storage addr; struct hostent *hp; char *s; int waitmode = 0; int ncnames, ch; int nkeychains; + struct addrinfo *answer = NULL; + struct addrinfo *cur = NULL; + struct addrinfo hint; + int ip = 0; dst_init(); @@ -292,33 +296,93 @@ main(int argc, char **argv) { if (argc > 1) usage("extra undefined arguments"); if (argc == 1) { + union res_sockaddr_union u[MAXNS]; + int nscount; + s = *argv++; argc--; server_specified++; + memset(&hint, 0, sizeof(hint)); + hint.ai_flags = AI_CANONNAME; + hint.ai_family = PF_UNSPEC; + hint.ai_socktype = SOCK_DGRAM; - if (!inet_aton(s, &addr)) { - hp = gethostbyname(s); - if (hp == NULL) { - fprintf(stderr, - "Error in looking up server name:\n"); - hperror(res.res_h_errno); - exit(1); + if (!getaddrinfo(s, NULL, &hint, &answer)) { + nscount = 0; + if (answer->ai_canonname != NULL) { + printf("Using domain server:\n"); + printf("Name: %s\n", answer->ai_canonname); + printf("Addresses:"); + } else + printf("Using domain server"); + + for (cur = answer; cur != NULL; cur = cur->ai_next) { + char buf[80]; + struct sockaddr_in6 *sin6; + struct sockaddr_in *sin; + + switch (cur->ai_addr->sa_family) { + case AF_INET6: + sin6 = + (struct sockaddr_in6 *)cur->ai_addr; + inet_ntop(cur->ai_addr->sa_family, + &sin6->sin6_addr, + buf, sizeof(buf)); + printf(" %s", buf); + if (nscount >= MAXNS) + break; + u[nscount].sin6 = *sin6; + u[nscount++].sin6.sin6_port = + htons(NAMESERVER_PORT); + break; + case AF_INET: + sin = + (struct sockaddr_in*)cur->ai_addr; + inet_ntop(cur->ai_addr->sa_family, + &sin->sin_addr, + buf, sizeof(buf)); + printf(" %s", buf); + if (nscount >= MAXNS) + break; + u[nscount].sin = *sin; + u[nscount++].sin6.sin6_port = + htons(NAMESERVER_PORT); + break; + } } - memcpy(&res.nsaddr.sin_addr, hp->h_addr, NS_INADDRSZ); - printf("Using domain server:\n"); - printanswer(hp); + if (nscount != 0) { + res_setservers(&res, u, nscount); + } + if (answer->ai_canonname != NULL) + printf("\n\n"); + else + printf(":\n\n"); + freeaddrinfo(answer); } else { - res.nsaddr.sin_family = AF_INET; - res.nsaddr.sin_addr = addr; - res.nsaddr.sin_port = htons(NAMESERVER_PORT); - printf("Using domain server %s:\n", - inet_ntoa(res.nsaddr.sin_addr)); + fprintf(stderr, "Error in looking up server name:\n"); + exit(1); } - res.nscount = 1; res.retry = 2; } - if (strcmp(getdomain, ".") == 0 || !inet_aton(getdomain, &addr)) - addr.s_addr = INADDR_NONE; + memset(&hint, 0, sizeof(hint)); + hint.ai_flags = AI_NUMERICHOST; + hint.ai_socktype = SOCK_DGRAM; + if(!getaddrinfo(getdomain, NULL, &hint, &answer)) { + memset(&addr, 0, sizeof(addr)); + switch (answer->ai_family) { + case AF_INET: + memcpy(&addr, answer->ai_addr, + sizeof(struct sockaddr_in)); + ip = 1; + break; + case AF_INET6: + memcpy(&addr, answer->ai_addr, + sizeof(struct sockaddr_in6)); + ip = 1; + break; + } + freeaddrinfo(answer); + } hp = NULL; res.res_h_errno = TRY_AGAIN; /* @@ -330,7 +394,7 @@ main(int argc, char **argv) { exit(ListHosts(getdomain, querytype ? querytype : ns_t_a)); ncnames = 5; nkeychains = 18; while (hp == NULL && res.res_h_errno == TRY_AGAIN) { - if (addr.s_addr == INADDR_NONE) { + if (!ip) { cname = NULL; hp = (struct hostent *)gethostinfo(getdomain); getdomain[0] = 0; /* clear this query */ @@ -378,7 +442,7 @@ main(int argc, char **argv) { continue; } } else { - if (addrinfo(addr) == 0) + if (addrinfo(&addr) == 0) hp = NULL; else hp = (struct hostent *)1; /* XXX */ @@ -428,21 +492,6 @@ parseclass(const char *s) { } static void -printanswer(const struct hostent *hp) { - struct in_addr **hptr; - char **cp; - - printf("Name: %s\n", hp->h_name); - printf("Address:"); - for (hptr = (struct in_addr **)hp->h_addr_list; *hptr; hptr++) - printf(" %s", inet_ntoa(**hptr)); - printf("\nAliases:"); - for (cp = hp->h_aliases; cp && *cp && **cp; cp++) - printf(" %s", *cp); - printf("\n\n"); -} - -static void hperror(int errnum) { switch(errnum) { case HOST_NOT_FOUND: @@ -525,15 +574,50 @@ hperror(int errnum) { } static int -addrinfo(struct in_addr addr) { - u_int32_t ha = ntohl(addr.s_addr); +addrinfo(struct sockaddr_storage *addr) { char name[NS_MAXDNAME]; - - sprintf(name, "%u.%u.%u.%u.IN-ADDR.ARPA.", - (ha) & 0xff, - (ha >> 8) & 0xff, - (ha >> 16) & 0xff, - (ha >> 24) & 0xff); + unsigned char *p; + struct in6_addr *addr6; + + switch(addr->ss_family) { + case AF_INET: + p = (unsigned char*)&((struct sockaddr_in *)addr)->sin_addr; + mapped: + sprintf(name, "%u.%u.%u.%u.IN-ADDR.ARPA.", + p[3], p[2], p[1], p[0]); + break; + case AF_INET6: + addr6 = &((struct sockaddr_in6 *)addr)->sin6_addr; + p = (unsigned char *)addr6; + if (IN6_IS_ADDR_V4MAPPED(addr6) || + IN6_IS_ADDR_V4COMPAT(addr6)) { + p += 12; + goto mapped; + } + sprintf(name, + "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x." + "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x." + "IP6.ARPA", + p[15] & 0xf, (p[15] >> 4) & 0xf, + p[14] & 0xf, (p[14] >> 4) & 0xf, + p[13] & 0xf, (p[13] >> 4) & 0xf, + p[12] & 0xf, (p[12] >> 4) & 0xf, + p[11] & 0xf, (p[11] >> 4) & 0xf, + p[10] & 0xf, (p[10] >> 4) & 0xf, + p[9] & 0xf, (p[9] >> 4) & 0xf, + p[8] & 0xf, (p[8] >> 4) & 0xf, + p[7] & 0xf, (p[7] >> 4) & 0xf, + p[6] & 0xf, (p[6] >> 4) & 0xf, + p[5] & 0xf, (p[5] >> 4) & 0xf, + p[4] & 0xf, (p[4] >> 4) & 0xf, + p[3] & 0xf, (p[3] >> 4) & 0xf, + p[2] & 0xf, (p[2] >> 4) & 0xf, + p[1] & 0xf, (p[1] >> 4) & 0xf, + p[0] & 0xf, (p[0] >> 4) & 0xf); + break; + default: + abort(); + } return (getinfo(name, NULL, ns_t_ptr)); } @@ -1552,12 +1636,44 @@ pr_cdname(const u_char *cp, const u_char *msg, char *name, int namelen) { return (cp + n); } +static void +add(union res_sockaddr_union *u, int type, void *p) { + memset(u, 0, sizeof(*u)); + switch (type) { + case ns_t_a: + memcpy(&u->sin.sin_addr, p, NS_INADDRSZ); + u->sin.sin_family = AF_INET; + u->sin.sin_port = htons(NAMESERVER_PORT); +#ifdef HAVE_SA_LEN + u->sin.sin_len = sizeof(u->sin); +#endif + break; + + case ns_t_aaaa: + memcpy(&u->sin6.sin6_addr, p, 16); + u->sin6.sin6_family = AF_INET6; + u->sin6.sin6_port = htons(NAMESERVER_PORT); +#ifdef HAVE_SA_LEN + u->sin6.sin6_len = sizeof(u->sin6); +#endif + break; + } +} + +static int +salen(union res_sockaddr_union *u) { + switch (u->sin.sin_family) { + case AF_INET6: return (sizeof(u->sin6)); + case AF_INET: return (sizeof(u->sin)); + } + return (0); +} + static int ListHosts(char *namePtr, int queryType) { querybuf buf, answer; struct sockaddr_in sin; const HEADER *headerPtr; - const struct hostent *hp; enum { NO_ERRORS, ERR_READING_LEN, ERR_READING_MSG, ERR_PRINTING } error = NO_ERRORS; @@ -1570,7 +1686,7 @@ ListHosts(char *namePtr, int queryType) { /* Names and addresses of name servers to try. */ char nsname[NUMNS][NS_MAXDNAME]; int nshaveaddr[NUMNS]; - struct in_addr nsipaddr[NUMNSADDR]; + union res_sockaddr_union nsipaddr[NUMNSADDR]; int numns, numnsaddr, thisns; int qdcount, ancount; @@ -1582,10 +1698,9 @@ ListHosts(char *namePtr, int queryType) { if (namePtr[i-1] == '.') namePtr[i-1] = 0; - if (server_specified) { - memcpy(&nsipaddr[0], &res.nsaddr.sin_addr, NS_INADDRSZ); - numnsaddr = 1; - } else { + if (server_specified) + numnsaddr = res_getservers(&res, nsipaddr, NUMNSADDR); + else { /* * First we have to find out where to look. This needs a NS * query, possibly followed by looking up addresses for some @@ -1703,20 +1818,17 @@ ListHosts(char *namePtr, int queryType) { } } } - } else if (type == ns_t_a) { - if (numnsaddr < NUMNSADDR) - for (i = 0; i < numns; i++) { - if (ns_samename(nsname[i], + } else if ((type == ns_t_a || type == ns_t_aaaa) && + numnsaddr < NUMNSADDR) { + for (i = 0; i < numns; i++) { + if (ns_samename(nsname[i], (char *)domain) - == 1) { - nshaveaddr[i]++; - memcpy( - &nsipaddr[numnsaddr], - cp, NS_INADDRSZ); - numnsaddr++; - break; - } - } + != 1) + continue; + nshaveaddr[i]++; + add(&nsipaddr[numnsaddr++], type, cp); + break; + } } cp += dlen; } @@ -1728,28 +1840,50 @@ ListHosts(char *namePtr, int queryType) { */ for (i = 0; i < numns; i++) { - if (nshaveaddr[i] == 0) { - struct in_addr **hptr; - int numaddrs = 0; + struct addrinfo *answer = NULL; + struct addrinfo *cur = NULL; + struct addrinfo hint; - hp = gethostbyname(nsname[i]); - if (hp) { - for (hptr = (struct in_addr **) - hp->h_addr_list; - *hptr != NULL; - hptr++) - if (numnsaddr < NUMNSADDR) { - memcpy( - &nsipaddr[numnsaddr], - *hptr, NS_INADDRSZ); - numnsaddr++; - numaddrs++; - } + memset(&hint, 0, sizeof(hint)); + hint.ai_family = PF_UNSPEC; + hint.ai_socktype = SOCK_STREAM; + + if (nshaveaddr[i] == 0 && + !getaddrinfo(nsname[i], NULL, &hint, &answer)) { + int numaddrs = 0; + for (cur = answer; + cur != NULL; + cur = cur->ai_next) { + union res_sockaddr_union *u; + + if (numnsaddr >= NUMNSADDR) + break; + + u = &nsipaddr[numnsaddr]; + switch (cur->ai_addr->sa_family) { + case AF_INET6: + u->sin6 = + *(struct sockaddr_in6 *)cur->ai_addr; + u->sin6.sin6_port = + htons(NAMESERVER_PORT); + numnsaddr++; + numaddrs++; + break; + case AF_INET: + u->sin = + *(struct sockaddr_in*)cur->ai_addr; + u->sin6.sin6_port = + htons(NAMESERVER_PORT); + numnsaddr++; + numaddrs++; + break; + } } if (res.options & RES_DEBUG || verbose) printf( "Found %d addresses for %s by extra query\n", numaddrs, nsname[i]); + freeaddrinfo(answer); } else if (res.options & RES_DEBUG || verbose) printf("Found %d addresses for %s\n", nshaveaddr[i], nsname[i]); @@ -1786,14 +1920,31 @@ ListHosts(char *namePtr, int queryType) { */ for ((void)NULL; thisns < numnsaddr; thisns++) { - if ((sockFD = socket(AF_INET, SOCK_STREAM, 0)) < 0) { + if ((sockFD = socket(nsipaddr[thisns].sin.sin_family, + SOCK_STREAM, 0)) < 0) { + if (errno == EPROTONOSUPPORT) + continue; perror("ListHosts"); return (ERROR); } - memcpy(&sin.sin_addr, &nsipaddr[thisns], NS_INADDRSZ); - if (res.options & RES_DEBUG || verbose) - printf("Trying %s\n", inet_ntoa(sin.sin_addr)); - if (connect(sockFD, (struct sockaddr *)&sin, sizeof(sin)) >= 0) + if (res.options & RES_DEBUG || verbose) { + char buf[80]; + switch (nsipaddr[thisns].sin.sin_family) { + case AF_INET: + inet_ntop(nsipaddr[thisns].sin.sin_family, + &nsipaddr[thisns].sin.sin_addr, + buf, sizeof(buf)); + break; + case AF_INET6: + inet_ntop(nsipaddr[thisns].sin6.sin6_family, + &nsipaddr[thisns].sin6.sin6_addr, + buf, sizeof(buf)); + break; + } + printf("Trying %s\n", buf); + } + if (connect(sockFD, (struct sockaddr *)&nsipaddr[thisns], + salen(&nsipaddr[thisns])) >= 0) break; if (verbose) perror("Connection failed, trying next server"); diff --git a/contrib/bind/bin/named/named.conf b/contrib/bind/bin/named/named.conf index 08ef27d..d0d2996 100644 --- a/contrib/bind/bin/named/named.conf +++ b/contrib/bind/bin/named/named.conf @@ -52,6 +52,8 @@ options { // notify on a zone-by-zone // basis in the "zone" statement // see (below) + // notify explicit; // only sent the notifies to the + // also-notify list serial-queries 4; // number of parallel SOA queries // we can have outstanding for master // zone change testing purposes @@ -193,6 +195,8 @@ zone "master.demo.zone" { // zone? The global option is used // if "notify" is not specified // here. + // notify explicit; // only sent the notifies to the + // also-notify list also-notify { }; // don't notify any nameservers other // than those on the NS list for this // zone diff --git a/contrib/bind/bin/named/named.h b/contrib/bind/bin/named/named.h index 023767c..a9d6088 100644 --- a/contrib/bind/bin/named/named.h +++ b/contrib/bind/bin/named/named.h @@ -16,10 +16,11 @@ */ /* - * $Id: named.h,v 8.31 2002/02/01 00:05:38 marka Exp $ + * $Id: named.h,v 8.32 2002/03/15 00:58:16 vixie Exp $ */ /* Options. Change them at your peril. */ +#undef NXDOMAIN_ON_DENIAL #define DEBUG #define ADDAUTH #define STUBS diff --git a/contrib/bind/bin/named/ns_config.c b/contrib/bind/bin/named/ns_config.c index 2d59a62..1680d91 100644 --- a/contrib/bind/bin/named/ns_config.c +++ b/contrib/bind/bin/named/ns_config.c @@ -1,5 +1,5 @@ #if !defined(lint) && !defined(SABER) -static const char rcsid[] = "$Id: ns_config.c,v 8.133 2002/02/01 00:05:39 marka Exp $"; +static const char rcsid[] = "$Id: ns_config.c,v 8.134 2002/04/25 05:27:04 marka Exp $"; #endif /* not lint */ /* @@ -317,7 +317,7 @@ validate_zone(struct zoneinfo *zp) { #ifdef BIND_NOTIFY /* Check notify */ - if (zp->z_notify != znotify_use_default) { + if (zp->z_notify != notify_use_default) { if (zp->z_type != z_master && zp->z_type != z_slave) { ns_error(ns_log_config, "'notify' given for non-master, non-slave zone '%s'", @@ -872,7 +872,7 @@ set_zone_dialup(zone_config zh, int value) { if (value) { zp->z_dialup = zdialup_yes; #ifdef BIND_NOTIFY - zp->z_notify = znotify_yes; + zp->z_notify = notify_yes; #endif } else zp->z_dialup = zdialup_no; @@ -881,17 +881,14 @@ set_zone_dialup(zone_config zh, int value) { } int -set_zone_notify(zone_config zh, int value) { +set_zone_notify(zone_config zh, enum notify value) { #ifdef BIND_NOTIFY struct zoneinfo *zp; zp = zh.opaque; INSIST(zp != NULL); - if (value) - zp->z_notify = znotify_yes; - else - zp->z_notify = znotify_no; + zp->z_notify = value; #endif return (1); } @@ -1150,6 +1147,9 @@ new_options() { op->max_log_size_ixfr = 0; op->minroots = MINROOTS; op->preferred_glue = 0; +#ifdef BIND_NOTIFY + op->notify = notify_yes; +#endif return (op); } @@ -1210,7 +1210,6 @@ set_boolean_option(u_int *op_flags, int bool_opt, int value) { case OPTION_NOFETCHGLUE: case OPTION_FORWARD_ONLY: case OPTION_FAKE_IQUERY: - case OPTION_NONOTIFY: case OPTION_SUPNOTIFY_INITIAL: case OPTION_NONAUTH_NXDOMAIN: case OPTION_MULTIPLE_CNAMES: diff --git a/contrib/bind/bin/named/ns_defs.h b/contrib/bind/bin/named/ns_defs.h index 86a81b6..3474550 100644 --- a/contrib/bind/bin/named/ns_defs.h +++ b/contrib/bind/bin/named/ns_defs.h @@ -1,6 +1,6 @@ /* * from ns.h 4.33 (Berkeley) 8/23/90 - * $Id: ns_defs.h,v 8.115 2002/01/29 03:59:35 marka Exp $ + * $Id: ns_defs.h,v 8.118 2002/04/25 05:27:06 marka Exp $ */ /* @@ -170,10 +170,11 @@ typedef enum need { main_need_qrylog, /* toggle_qrylog() needed. */ main_need_debug, /* use_desired_debug() needed. */ main_need_restart, /* exec() needed. */ - main_need_reap, /* need to reap dead children */ - main_need_noexpired, /* ns_reconfig() needed w/ noexpired set */ + main_need_reap, /* need to reap dead children. */ + main_need_noexpired, /* ns_reconfig() needed w/ noexpired set. */ main_need_num, /* number of needs, used for array bound. */ - main_need_tick /* tick every second to poll for cleanup (NT)*/ + main_need_tick, /* tick every second to poll for cleanup (NT) */ + main_need_tryxfer /* attemt to start a zone transfer. */ } main_need; /* What global options are set? */ @@ -182,7 +183,7 @@ typedef enum need { #define OPTION_FORWARD_ONLY 0x00000004 /* Don't use NS RR's, just forward. */ #define OPTION_FAKE_IQUERY 0x00000008 /* Fake up bogus response to IQUERY. */ #ifdef BIND_NOTIFY -#define OPTION_NONOTIFY 0x00000010 /* Turn off notify */ +/* #define OPTION_NONOTIFY 0x00000010 */ /* Turn off notify */ #define OPTION_SUPNOTIFY_INITIAL 0x00000020 /* Supress initial notify */ #endif #define OPTION_NONAUTH_NXDOMAIN 0x00000040 /* Generate non-auth NXDOMAINs? */ @@ -272,7 +273,7 @@ typedef enum need { enum severity { ignore, warn, fail, not_set }; #ifdef BIND_NOTIFY -enum znotify { znotify_use_default=0, znotify_yes, znotify_no }; +enum notify { notify_use_default=0, notify_yes, notify_no, notify_explicit }; #endif enum zdialup { zdialup_use_default=0, zdialup_yes, zdialup_no }; @@ -368,7 +369,7 @@ struct zoneinfo { from us */ long z_max_transfer_time_in; /* max num seconds for AXFR */ #ifdef BIND_NOTIFY - enum znotify z_notify; /* Notify mode */ + enum notify z_notify; /* Notify mode */ struct in_addr *z_also_notify; /* More nameservers to notify */ int z_notify_count; #endif @@ -496,7 +497,7 @@ struct qinfo { u_int16_t q_class; /* class of query */ u_int16_t q_type; /* type of query */ #ifdef BIND_NOTIFY - int q_notifyzone; /* zone which needs another znotify() + int q_notifyzone; /* zone which needs another notify() * when the reply to this comes in. */ #endif @@ -610,6 +611,8 @@ struct qstream { ns_tcp_tsig_state *tsig_state; /* used by ns_sign_tcp */ int tsig_skip; /* skip calling ns_sign_tcp * during the next flush */ + int tsig_size; /* need to reserve this space + * for the tsig. */ struct qs_x_lev { /* decompose the recursion. */ enum {sxl_ns, sxl_all, sxl_sub} state; /* what's this level doing? */ @@ -790,6 +793,7 @@ typedef struct options { u_int lame_ttl; int minroots; u_int16_t preferred_glue; + enum notify notify; } *options; typedef struct key_list_element { diff --git a/contrib/bind/bin/named/ns_forw.c b/contrib/bind/bin/named/ns_forw.c index f62ba20..494a96a 100644 --- a/contrib/bind/bin/named/ns_forw.c +++ b/contrib/bind/bin/named/ns_forw.c @@ -1,6 +1,6 @@ #if !defined(lint) && !defined(SABER) static const char sccsid[] = "@(#)ns_forw.c 4.32 (Berkeley) 3/3/91"; -static const char rcsid[] = "$Id: ns_forw.c,v 8.89 2002/01/29 03:59:36 marka Exp $"; +static const char rcsid[] = "$Id: ns_forw.c,v 8.90 2002/02/22 05:12:35 marka Exp $"; #endif /* not lint */ /* @@ -467,6 +467,7 @@ nslookup(struct databuf *nsp[], struct qinfo *qp, const char *fname; int oldn, naddr, class, found_arr, potential_ns, lame_ns; time_t curtime; + int found_auth6; ns_debug(ns_log_default, 3, "nslookup(nsp=%p, qp=%p, \"%s\", d=%d)", nsp, qp, syslogdname, qp->q_distance); @@ -503,19 +504,17 @@ nslookup(struct databuf *nsp[], struct qinfo *qp, } } + found_arr = 0; + found_auth6 = 0; tmphtp = ((nsdp->d_flags & DB_F_HINT) ?fcachetab :hashtab); np = nlookup(dname, &tmphtp, &fname, 0); if (np == NULL) { ns_debug(ns_log_default, 3, "%s: not found %s %p", dname, fname, np); - found_arr = 0; goto need_sysquery; } - if (fname != dname) { - found_arr = 0; + if (fname != dname) goto need_sysquery; - } - found_arr = 0; oldn = n; /* look for name server addresses */ @@ -534,6 +533,13 @@ nslookup(struct databuf *nsp[], struct qinfo *qp, } if (dp->d_rcode == NXDOMAIN && dp->d_class == class) goto skipserver; + if (dp->d_class == class && + (dp->d_type == T_AAAA || dp->d_type == ns_t_a6) && + (zones[dp->d_zone].z_type == z_master || + zones[dp->d_zone].z_type == z_slave)) { + found_auth6++; + continue; + } if (dp->d_type != T_A || dp->d_class != class) continue; if (dp->d_rcode) { @@ -683,7 +689,7 @@ nslookup(struct databuf *nsp[], struct qinfo *qp, } ns_debug(ns_log_default, 8, "nslookup: %d ns addrs", n); need_sysquery: - if (found_arr == 0) { + if (found_arr == 0 && found_auth6 == 0) { potential_ns++; if (qp->q_distance < NS_MAX_DISTANCE) (void) sysquery(dname, class, T_A, NULL, NULL, diff --git a/contrib/bind/bin/named/ns_func.h b/contrib/bind/bin/named/ns_func.h index 501aa01..e035d93 100644 --- a/contrib/bind/bin/named/ns_func.h +++ b/contrib/bind/bin/named/ns_func.h @@ -90,7 +90,7 @@ /* ns_func.h - declarations for ns_*.c's externally visible functions * - * $Id: ns_func.h,v 8.115 2002/01/29 03:59:38 marka Exp $ + * $Id: ns_func.h,v 8.117 2002/04/25 05:27:07 marka Exp $ */ /* ++from ns_glue.c++ */ @@ -313,6 +313,7 @@ void qserial_answer(struct qinfo *); void printzoneinfo(int, int, int); #endif void endxfer(void); +void tryxfer(void); void addxfer(struct zoneinfo *); void ns_zreload(void); void ns_reload(void); @@ -421,7 +422,7 @@ int set_zone_type(zone_config, int); int set_zone_filename(zone_config, char *); int set_zone_checknames(zone_config, enum severity); #ifdef BIND_NOTIFY -int set_zone_notify(zone_config, int value); +int set_zone_notify(zone_config, enum notify value); #endif int set_zone_maintain_ixfr_base(zone_config, int value); int set_zone_update_acl(zone_config, ip_match_list); diff --git a/contrib/bind/bin/named/ns_lexer.c b/contrib/bind/bin/named/ns_lexer.c index 4a6f820..b10219a 100644 --- a/contrib/bind/bin/named/ns_lexer.c +++ b/contrib/bind/bin/named/ns_lexer.c @@ -1,5 +1,5 @@ #if !defined(lint) && !defined(SABER) -static const char rcsid[] = "$Id: ns_lexer.c,v 8.28 2001/12/28 04:07:47 marka Exp $"; +static const char rcsid[] = "$Id: ns_lexer.c,v 8.30 2002/04/25 05:27:08 marka Exp $"; #endif /* not lint */ /* @@ -57,7 +57,7 @@ typedef enum lexer_state { #define LEXER_MAX_PUSHBACK 2 typedef struct lexer_file_context { - const char * name; + char * name; FILE * stream; int line_number; LexerState state; @@ -251,6 +251,7 @@ static struct keyword keywords[] = { {"directory", T_DIRECTORY}, {"dump-file", T_DUMP_FILE}, {"dynamic", T_DYNAMIC}, + {"explicit", T_EXPLICIT}, {"fail", T_FAIL}, {"fake-iquery", T_FAKE_IQUERY}, {"false", T_FALSE}, @@ -400,7 +401,7 @@ lexer_begin_file(const char *filename, FILE *stream) { panic("memget failed in lexer_begin_file", NULL); INSIST(stream != NULL); lf->stream = stream; - lf->name = filename; /* note copy by reference */ + lf->name = savestr(filename, 1); lf->line_number = 1; lf->state = scan; lf->flags = 0; @@ -419,6 +420,7 @@ lexer_end_file(void) { lf = current_file; current_file = lf->next; fclose(lf->stream); + freestr(lf->name); memput(lf, sizeof *lf); } diff --git a/contrib/bind/bin/named/ns_main.c b/contrib/bind/bin/named/ns_main.c index 23cf249..d839387 100644 --- a/contrib/bind/bin/named/ns_main.c +++ b/contrib/bind/bin/named/ns_main.c @@ -1,6 +1,6 @@ #if !defined(lint) && !defined(SABER) static const char sccsid[] = "@(#)ns_main.c 4.55 (Berkeley) 7/1/91"; -static const char rcsid[] = "$Id: ns_main.c,v 8.155 2001/11/16 05:37:27 marka Exp $"; +static const char rcsid[] = "$Id: ns_main.c,v 8.157 2002/04/13 23:26:16 marka Exp $"; #endif /* not lint */ /* @@ -570,18 +570,46 @@ main(int argc, char *argv[]) { } static int +sq_closeone(void) { + struct qstream *sp, *nextsp; + struct qstream *candidate = NULL; + time_t lasttime, maxctime = 0; + int result = 0; + + gettime(&tt); + + for (sp = streamq; sp; sp = nextsp) { + nextsp = sp->s_next; + if (sp->s_refcnt) + continue; + lasttime = tt.tv_sec - sp->s_time; + if (lasttime >= VQEXPIRY) { + sq_remove(sp); + result = 1; + } else if (lasttime > maxctime) { + candidate = sp; + maxctime = lasttime; + } + } + if (candidate) { + sq_remove(candidate); + result = 1; + } + return (result); +} + +static int ns_socket(int domain, int type, int protocol) { - int fd; + int fd, tmp; + again: fd = socket(domain, type, protocol); - if (fd == -1) - return (-1); #ifdef F_DUPFD /* XXX */ /* * Leave a space for stdio to work in. */ if (fd >= 0 && fd <= 20) { - int new, tmp; + int new; if ((new = fcntl(fd, F_DUPFD, 20)) == -1) ns_notice(ns_log_default, "fcntl(fd, F_DUPFD, 20): %s", strerror(errno)); @@ -591,6 +619,11 @@ ns_socket(int domain, int type, int protocol) { fd = new; } #endif + tmp = errno; + if (errno == EMFILE) + if (sq_closeone()) + goto again; + errno = tmp; return (fd); } @@ -680,25 +713,7 @@ stream_accept(evContext lev, void *uap, int rfd, * eventlib which will call us right back. */ if (streamq) { - struct qstream *nextsp; - struct qstream *candidate = NULL; - time_t lasttime, maxctime = 0; - - for (sp = streamq; sp; sp = nextsp) { - nextsp = sp->s_next; - if (sp->s_refcnt) - continue; - gettime(&tt); - lasttime = tt.tv_sec - sp->s_time; - if (lasttime >= VQEXPIRY) - sq_remove(sp); - else if (lasttime > maxctime) { - candidate = sp; - maxctime = lasttime; - } - } - if (candidate) - sq_remove(candidate); + (void)sq_closeone(); return; } /* fall through */ @@ -808,19 +823,20 @@ tcp_send(struct qinfo *qp) { struct qstream *sp; struct sockaddr_in src; int on = 1, n; + int fd; ns_debug(ns_log_default, 1, "tcp_send"); - if ((sp = sq_add()) == NULL) { + if ((fd = ns_socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == -1) return (SERVFAIL); - } - if ((sp->s_rfd = ns_socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) == -1) { - sq_remove(sp); + if (fd > evHighestFD(ev)) { + close(fd); return (SERVFAIL); } - if (sp->s_rfd > evHighestFD(ev)) { - sq_remove(sp); + if ((sp = sq_add()) == NULL) { + close(fd); return (SERVFAIL); } + sp->s_rfd = fd; if (setsockopt(sp->s_rfd, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof(on)) < 0) ns_info(ns_log_default, @@ -2837,6 +2853,7 @@ init_needs(void) { handlers[main_need_restart] = ns_restart; handlers[main_need_reap] = reapchild; handlers[main_need_noexpired] = ns_noexpired; + handlers[main_need_tryxfer] = tryxfer; } static void diff --git a/contrib/bind/bin/named/ns_maint.c b/contrib/bind/bin/named/ns_maint.c index 0408936..82df685 100644 --- a/contrib/bind/bin/named/ns_maint.c +++ b/contrib/bind/bin/named/ns_maint.c @@ -1,6 +1,6 @@ #if !defined(lint) && !defined(SABER) static const char sccsid[] = "@(#)ns_maint.c 4.39 (Berkeley) 3/2/91"; -static const char rcsid[] = "$Id: ns_maint.c,v 8.131 2001/11/12 04:49:32 marka Exp $"; +static const char rcsid[] = "$Id: ns_maint.c,v 8.135 2002/04/25 05:27:10 marka Exp $"; #endif /* not lint */ /* @@ -132,7 +132,6 @@ static int nxfers(struct zoneinfo *), static void startxfer(struct zoneinfo *), abortxfer(struct zoneinfo *), - tryxfer(void), purge_z_2(struct hashbuf *, int); static int purge_nonglue_2(const char *, struct hashbuf *, int, int, int); @@ -453,9 +452,10 @@ ns_heartbeat(evContext ctx, void *uap, struct timespec due, * Trigger a refresh query while the link is up by * sending a notify. */ - if (((zp->z_notify == znotify_yes) || - ((zp->z_notify == znotify_use_default) && - !NS_OPTION_P(OPTION_NONOTIFY))) && + if (((zp->z_notify == notify_yes) || + (zp->z_notify == notify_explicit) || + ((zp->z_notify == notify_use_default) && + server_options->notify != notify_no)) && (zt == z_master || zt == z_slave) && !loading && ((zp->z_flags & Z_AUTH) != 0)) ns_notify(zp->z_origin, zp->z_class, ns_t_soa); @@ -1199,6 +1199,22 @@ remove_zone(struct zoneinfo *zp, const char *verb) { xfers_deferred--; } ns_stopxfrs(zp); + if ((zp->z_flags & Z_XFER_RUNNING) != 0) { + int i; + /* Kill and abandon the current transfer. */ + for (i = 0; i < MAX_XFERS_RUNNING; i++) { + if (xferstatus[i].xfer_pid == zp->z_xferpid) { + xferstatus[i].xfer_pid = 0; + xferstatus[i].xfer_state = XFER_IDLE; + xfers_running--; + break; + } + } + (void)kill(zp->z_xferpid, SIGTERM); + zp->z_flags &= ~(Z_XFER_RUNNING|Z_XFER_ABORTED|Z_XFER_GONE); + zp->z_xferpid = 0; + ns_need(main_need_tryxfer); + } do_reload(zp->z_origin, zp->z_type, zp->z_class, 1); ns_notice(ns_log_config, "%s zone \"%s\" (%s) %s", zoneTypeString(zp->z_type), zp->z_origin, @@ -1692,7 +1708,7 @@ endxfer() { /* * Try to start some xfers - new "fair scheduler" by Bob Halley @DEC (1995) */ -static void +void tryxfer() { static struct zoneinfo *zp = NULL; static struct zoneinfo *lastzones = NULL; diff --git a/contrib/bind/bin/named/ns_notify.c b/contrib/bind/bin/named/ns_notify.c index cde636a..286b3eb 100644 --- a/contrib/bind/bin/named/ns_notify.c +++ b/contrib/bind/bin/named/ns_notify.c @@ -1,5 +1,5 @@ #if !defined(lint) && !defined(SABER) -static const char rcsid[] = "$Id: ns_notify.c,v 8.18 2001/11/12 04:49:33 marka Exp $"; +static const char rcsid[] = "$Id: ns_notify.c,v 8.20 2002/04/25 05:27:12 marka Exp $"; #endif /* not lint */ /* @@ -56,12 +56,12 @@ static const char rcsid[] = "$Id: ns_notify.c,v 8.18 2001/11/12 04:49:33 marka E /* Types. */ -struct notify { +struct pnotify { char * name; ns_class class; ns_type type; evTimerID timer; - LINK(struct notify) link; + LINK(struct pnotify) link; }; /* Forward. */ @@ -71,14 +71,14 @@ static void sysnotify_slaves(const char *, const char *, ns_class, ns_type, int, int *, int *); static void sysnotify_ns(const char *, const char *, ns_class, ns_type, int, int *, int *); -static void free_notify(struct notify *); +static void free_notify(struct pnotify *); static void notify_timer(evContext, void *, struct timespec, struct timespec); /* Local. */ -static LIST(struct notify) pending_notifies; -static LIST(struct notify) loading_notifies; +static LIST(struct pnotify) pending_notifies; +static LIST(struct pnotify) loading_notifies; /* Public. */ @@ -91,7 +91,7 @@ ns_notify(const char *dname, ns_class class, ns_type type) { static const char no_room[] = "%s failed, cannot notify for zone %s"; int delay, max_delay; struct zoneinfo *zp; - struct notify *ni; + struct pnotify *ni; zp = find_auth_zone(dname, class); if (zp == NULL) { @@ -162,7 +162,7 @@ ns_notify(const char *dname, ns_class class, ns_type type) { void notify_afterload() { - struct notify *ni; + struct pnotify *ni; INSIST(loading == 0); while ((ni = HEAD(loading_notifies)) != NULL) { @@ -180,7 +180,7 @@ notify_afterload() { void ns_unnotify(void) { while (!EMPTY(pending_notifies)) { - struct notify *ni = HEAD(pending_notifies); + struct pnotify *ni = HEAD(pending_notifies); INSIST(LINKED(ni, link)); UNLINK(pending_notifies, ni, link); @@ -194,7 +194,7 @@ ns_unnotify(void) { */ void ns_stopnotify(const char *dname, ns_class class) { - struct notify *ni; + struct pnotify *ni; ni = HEAD(pending_notifies); while (ni != NULL && @@ -235,9 +235,9 @@ sysnotify(const char *dname, ns_class class, ns_type type) { dname); return; } - if (zp->z_notify == znotify_no || - (zp->z_notify == znotify_use_default && - NS_OPTION_P(OPTION_NONOTIFY))) + if (zp->z_notify == notify_no || + (zp->z_notify == notify_use_default && + server_options->notify == notify_no)) return; if (zp->z_type != z_master && zp->z_type != z_slave) { ns_warning(ns_log_notify, "sysnotify: %s not master or slave", @@ -247,7 +247,11 @@ sysnotify(const char *dname, ns_class class, ns_type type) { zname = zp->z_origin; zserial = zp->z_serial; nns = na = 0; - sysnotify_slaves(dname, zname, class, type, zp - zones, &nns, &na); + if (zp->z_notify == notify_yes || + (zp->z_notify == notify_use_default && + server_options->notify == notify_yes)) + sysnotify_slaves(dname, zname, class, type, + zp - zones, &nns, &na); /* * Handle any global or zone-specific also-notify clauses @@ -351,18 +355,26 @@ sysnotify_ns(const char *dname, const char *aname, const char *fname; struct in_addr nss[NSMAX]; struct hashbuf *htp; - int is_us, nsc; + int is_us, nsc, auth6, neg; int cname = 0; htp = hashtab; anp = nlookup(aname, &htp, &fname, 0); nsc = 0; is_us = 0; + auth6 = 0; + neg = 0; if (anp != NULL) for (adp = anp->n_data; adp; adp = adp->d_next) { struct in_addr ina; - if (match(adp, class, T_CNAME)) { + if (adp->d_class != class) + continue; + if (adp->d_rcode == NXDOMAIN) { + neg = 1; + break; + } + if (adp->d_type == T_CNAME && adp->d_rcode == 0) { cname = 1; ns_error(ns_log_notify, "NS '%s' for '%s/%s' is a CNAME", @@ -371,8 +383,18 @@ sysnotify_ns(const char *dname, const char *aname, p_class(class)); break; } + if ((adp->d_type == T_AAAA || adp->d_type == ns_t_a6) && + (zones[adp->d_class].z_type == z_master || + zones[adp->d_class].z_type == z_slave)) { + auth6 = 1; + continue; + } if (!match(adp, class, T_A)) continue; + if (adp->d_rcode) { + neg = 1; + continue; + } if (adp->d_type == ns_t_sig) continue; ina = ina_get(adp->d_data); @@ -384,7 +406,8 @@ sysnotify_ns(const char *dname, const char *aname, nss[nsc++] = ina; } /*next A*/ if (nsc == 0) { - if (!is_us && !cname && !NS_OPTION_P(OPTION_NOFETCHGLUE)) { + if (!is_us && !cname && !auth6 && !neg && + !NS_OPTION_P(OPTION_NOFETCHGLUE)) { struct qinfo *qp; qp = sysquery(aname, class, ns_t_a, NULL, NULL, 0, @@ -400,7 +423,7 @@ sysnotify_ns(const char *dname, const char *aname, } static void -free_notify(struct notify *ni) { +free_notify(struct pnotify *ni) { struct zoneinfo *zp; INSIST(!LINKED(ni, link)); @@ -422,7 +445,7 @@ notify_timer(evContext ctx, void *uap, struct timespec due, struct timespec inter) { - struct notify *ni = uap; + struct pnotify *ni = uap; UNUSED(ctx); UNUSED(due); diff --git a/contrib/bind/bin/named/ns_parser.c b/contrib/bind/bin/named/ns_parser.c index 03d0a84..28f5f70 100644 --- a/contrib/bind/bin/named/ns_parser.c +++ b/contrib/bind/bin/named/ns_parser.c @@ -1,23 +1,30 @@ #ifndef lint -static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93 (BSDI)"; +static char const yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; #endif #include <stdlib.h> #define YYBYACC 1 #define YYMAJOR 1 #define YYMINOR 9 -#define YYEMPTY (-1) #define YYLEX yylex() -#define yyclearin (yychar=YYEMPTY) +#define YYEMPTY -1 +#define yyclearin (yychar=(YYEMPTY)) #define yyerrok (yyerrflag=0) #define YYRECOVERING (yyerrflag!=0) +#if defined(c_plusplus) || defined(__cplusplus) +#include <stdlib.h> +#else +extern char *getenv(); +extern void *realloc(); +#endif +static int yygrowstack(); #define YYPREFIX "yy" #line 2 "ns_parser.y" #if !defined(lint) && !defined(SABER) -static char rcsid[] = "$Id: ns_parser.y,v 8.51 1999/11/12 05:29:18 vixie Exp $"; +static char rcsid[] = "$Id: ns_parser.y,v 8.79 2002/04/25 05:27:13 marka Exp $"; #endif /* not lint */ /* - * Copyright (c) 1996-1999 by Internet Software Consortium. + * Copyright (c) 1996-2000 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -38,6 +45,7 @@ static char rcsid[] = "$Id: ns_parser.y,v 8.51 1999/11/12 05:29:18 vixie Exp $"; #include "port_before.h" #include <sys/types.h> +#include <sys/stat.h> #include <sys/socket.h> #include <sys/un.h> @@ -77,16 +85,17 @@ static symbol_table symtab; #define AUTH_TABLE_SIZE 397 /* should always be prime */ static symbol_table authtab = NULL; +static symbol_table channeltab = NULL; static zone_config current_zone; static int should_install; static options current_options; static int seen_options; +static int logged_options_error; static controls current_controls; -static topology_config current_topology; static int seen_topology; static server_config current_server; @@ -106,12 +115,12 @@ static int chan_versions; static u_long chan_max_size; static log_channel lookup_channel(char *); -static void define_channel(char *, log_channel); +static void define_channel(const char *, log_channel); static char *canonical_name(char *); int yyparse(); -#line 103 "ns_parser.y" +#line 105 "ns_parser.y" typedef union { char * cp; int s_int; @@ -126,7 +135,7 @@ typedef union { struct dst_key * keyi; enum axfr_format axfr_fmt; } YYSTYPE; -#line 130 "y.tab.c" +#line 139 "y.tab.c" #define L_EOS 257 #define L_IPADDR 258 #define L_NUMBER 259 @@ -144,320 +153,338 @@ typedef union { #define T_FAKE_IQUERY 271 #define T_RECURSION 272 #define T_FETCH_GLUE 273 -#define T_QUERY_SOURCE 274 -#define T_LISTEN_ON 275 -#define T_PORT 276 -#define T_ADDRESS 277 -#define T_RRSET_ORDER 278 -#define T_ORDER 279 -#define T_NAME 280 -#define T_CLASS 281 -#define T_CONTROLS 282 -#define T_INET 283 -#define T_UNIX 284 -#define T_PERM 285 -#define T_OWNER 286 -#define T_GROUP 287 -#define T_ALLOW 288 -#define T_DATASIZE 289 -#define T_STACKSIZE 290 -#define T_CORESIZE 291 -#define T_DEFAULT 292 -#define T_UNLIMITED 293 -#define T_FILES 294 -#define T_VERSION 295 -#define T_HOSTSTATS 296 -#define T_DEALLOC_ON_EXIT 297 -#define T_TRANSFERS_IN 298 -#define T_TRANSFERS_OUT 299 -#define T_TRANSFERS_PER_NS 300 -#define T_TRANSFER_FORMAT 301 -#define T_MAX_TRANSFER_TIME_IN 302 -#define T_SERIAL_QUERIES 303 -#define T_ONE_ANSWER 304 -#define T_MANY_ANSWERS 305 -#define T_NOTIFY 306 -#define T_AUTH_NXDOMAIN 307 -#define T_MULTIPLE_CNAMES 308 -#define T_USE_IXFR 309 -#define T_MAINTAIN_IXFR_BASE 310 -#define T_CLEAN_INTERVAL 311 -#define T_INTERFACE_INTERVAL 312 -#define T_STATS_INTERVAL 313 -#define T_MAX_LOG_SIZE_IXFR 314 -#define T_HEARTBEAT 315 -#define T_USE_ID_POOL 316 -#define T_MAX_NCACHE_TTL 317 -#define T_HAS_OLD_CLIENTS 318 -#define T_RFC2308_TYPE1 319 -#define T_LAME_TTL 320 -#define T_MIN_ROOTS 321 -#define T_TREAT_CR_AS_SPACE 322 -#define T_LOGGING 323 -#define T_CATEGORY 324 -#define T_CHANNEL 325 -#define T_SEVERITY 326 -#define T_DYNAMIC 327 -#define T_FILE 328 -#define T_VERSIONS 329 -#define T_SIZE 330 -#define T_SYSLOG 331 -#define T_DEBUG 332 -#define T_NULL_OUTPUT 333 -#define T_PRINT_TIME 334 -#define T_PRINT_CATEGORY 335 -#define T_PRINT_SEVERITY 336 -#define T_SORTLIST 337 -#define T_TOPOLOGY 338 -#define T_SERVER 339 -#define T_LONG_AXFR 340 -#define T_BOGUS 341 -#define T_TRANSFERS 342 -#define T_KEYS 343 -#define T_SUPPORT_IXFR 344 -#define T_ZONE 345 -#define T_IN 346 -#define T_CHAOS 347 -#define T_HESIOD 348 -#define T_TYPE 349 -#define T_MASTER 350 -#define T_SLAVE 351 -#define T_STUB 352 -#define T_RESPONSE 353 -#define T_HINT 354 -#define T_MASTERS 355 -#define T_TRANSFER_SOURCE 356 -#define T_PUBKEY 357 -#define T_ALSO_NOTIFY 358 -#define T_DIALUP 359 -#define T_FILE_IXFR 360 -#define T_IXFR_TMP 361 -#define T_TRUSTED_KEYS 362 -#define T_ACL 363 -#define T_ALLOW_UPDATE 364 -#define T_ALLOW_QUERY 365 -#define T_ALLOW_TRANSFER 366 -#define T_ALLOW_RECURSION 367 -#define T_BLACKHOLE 368 -#define T_SEC_KEY 369 -#define T_ALGID 370 -#define T_SECRET 371 -#define T_CHECK_NAMES 372 -#define T_WARN 373 -#define T_FAIL 374 -#define T_IGNORE 375 -#define T_FORWARD 376 -#define T_FORWARDERS 377 -#define T_ONLY 378 -#define T_FIRST 379 -#define T_IF_NO_ANSWER 380 -#define T_IF_NO_DOMAIN 381 -#define T_YES 382 -#define T_TRUE 383 -#define T_NO 384 -#define T_FALSE 385 +#define T_HITCOUNT 274 +#define T_PREFERRED_GLUE 275 +#define T_QUERY_SOURCE 276 +#define T_LISTEN_ON 277 +#define T_PORT 278 +#define T_ADDRESS 279 +#define T_RRSET_ORDER 280 +#define T_ORDER 281 +#define T_NAME 282 +#define T_CLASS 283 +#define T_CONTROLS 284 +#define T_INET 285 +#define T_UNIX 286 +#define T_PERM 287 +#define T_OWNER 288 +#define T_GROUP 289 +#define T_ALLOW 290 +#define T_DATASIZE 291 +#define T_STACKSIZE 292 +#define T_CORESIZE 293 +#define T_DEFAULT 294 +#define T_UNLIMITED 295 +#define T_FILES 296 +#define T_VERSION 297 +#define T_HOSTNAME 298 +#define T_HOSTSTATS 299 +#define T_HOSTSTATSMAX 300 +#define T_DEALLOC_ON_EXIT 301 +#define T_TRANSFERS_IN 302 +#define T_TRANSFERS_OUT 303 +#define T_TRANSFERS_PER_NS 304 +#define T_TRANSFER_FORMAT 305 +#define T_MAX_TRANSFER_TIME_IN 306 +#define T_SERIAL_QUERIES 307 +#define T_ONE_ANSWER 308 +#define T_MANY_ANSWERS 309 +#define T_NOTIFY 310 +#define T_EXPLICIT 311 +#define T_NOTIFY_INITIAL 312 +#define T_AUTH_NXDOMAIN 313 +#define T_MULTIPLE_CNAMES 314 +#define T_USE_IXFR 315 +#define T_MAINTAIN_IXFR_BASE 316 +#define T_CLEAN_INTERVAL 317 +#define T_INTERFACE_INTERVAL 318 +#define T_STATS_INTERVAL 319 +#define T_MAX_LOG_SIZE_IXFR 320 +#define T_HEARTBEAT 321 +#define T_USE_ID_POOL 322 +#define T_MAX_NCACHE_TTL 323 +#define T_HAS_OLD_CLIENTS 324 +#define T_RFC2308_TYPE1 325 +#define T_LAME_TTL 326 +#define T_MIN_ROOTS 327 +#define T_TREAT_CR_AS_SPACE 328 +#define T_LOGGING 329 +#define T_CATEGORY 330 +#define T_CHANNEL 331 +#define T_SEVERITY 332 +#define T_DYNAMIC 333 +#define T_FILE 334 +#define T_VERSIONS 335 +#define T_SIZE 336 +#define T_SYSLOG 337 +#define T_DEBUG 338 +#define T_NULL_OUTPUT 339 +#define T_PRINT_TIME 340 +#define T_PRINT_CATEGORY 341 +#define T_PRINT_SEVERITY 342 +#define T_SORTLIST 343 +#define T_TOPOLOGY 344 +#define T_SERVER 345 +#define T_LONG_AXFR 346 +#define T_BOGUS 347 +#define T_TRANSFERS 348 +#define T_KEYS 349 +#define T_SUPPORT_IXFR 350 +#define T_ZONE 351 +#define T_IN 352 +#define T_CHAOS 353 +#define T_HESIOD 354 +#define T_TYPE 355 +#define T_MASTER 356 +#define T_SLAVE 357 +#define T_STUB 358 +#define T_RESPONSE 359 +#define T_HINT 360 +#define T_MASTERS 361 +#define T_TRANSFER_SOURCE 362 +#define T_PUBKEY 363 +#define T_ALSO_NOTIFY 364 +#define T_DIALUP 365 +#define T_FILE_IXFR 366 +#define T_IXFR_TMP 367 +#define T_TRUSTED_KEYS 368 +#define T_ACL 369 +#define T_ALLOW_UPDATE 370 +#define T_ALLOW_QUERY 371 +#define T_ALLOW_TRANSFER 372 +#define T_ALLOW_RECURSION 373 +#define T_BLACKHOLE 374 +#define T_SEC_KEY 375 +#define T_ALGID 376 +#define T_SECRET 377 +#define T_CHECK_NAMES 378 +#define T_WARN 379 +#define T_FAIL 380 +#define T_IGNORE 381 +#define T_FORWARD 382 +#define T_FORWARDERS 383 +#define T_ONLY 384 +#define T_FIRST 385 +#define T_IF_NO_ANSWER 386 +#define T_IF_NO_DOMAIN 387 +#define T_YES 388 +#define T_TRUE 389 +#define T_NO 390 +#define T_FALSE 391 #define YYERRCODE 256 -short yylhs[] = { -1, +const short yylhs[] = { -1, 0, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 42, 34, 43, 43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 44, 46, 44, 44, 44, 44, 44, - 44, 44, 49, 44, 44, 44, 44, 44, 44, 44, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 46, + 44, 44, 44, 44, 44, 44, 44, 49, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 35, 53, 53, 54, 54, 54, 54, - 15, 15, 12, 12, 13, 13, 14, 14, 16, 6, - 6, 5, 5, 4, 4, 55, 56, 48, 48, 48, - 48, 2, 2, 3, 3, 29, 29, 29, 29, 29, - 27, 27, 27, 28, 28, 28, 45, 45, 45, 45, - 51, 51, 51, 51, 26, 26, 26, 26, 52, 52, - 52, 47, 47, 57, 57, 58, 50, 50, 59, 59, - 60, 61, 36, 62, 62, 62, 64, 63, 66, 63, - 68, 68, 68, 68, 69, 69, 70, 71, 71, 71, - 71, 71, 72, 10, 10, 11, 11, 73, 74, 74, - 74, 74, 74, 74, 74, 67, 67, 67, 9, 9, - 75, 65, 65, 65, 8, 8, 8, 7, 76, 37, - 77, 77, 78, 78, 78, 78, 78, 78, 20, 20, - 18, 18, 18, 17, 17, 17, 17, 17, 19, 23, - 80, 79, 79, 79, 81, 41, 82, 82, 82, 24, - 25, 40, 84, 38, 83, 83, 21, 21, 22, 22, - 22, 22, 22, 85, 85, 86, 86, 86, 86, 86, - 86, 86, 86, 86, 86, 86, 89, 86, 86, 86, - 86, 86, 86, 86, 86, 86, 86, 87, 87, 92, - 91, 91, 93, 93, 94, 88, 88, 90, 90, 95, - 95, 96, 39, 97, 97, 98, 98, 1, 30, 30, + 44, 44, 44, 44, 44, 44, 44, 44, 44, 35, + 53, 53, 54, 54, 54, 54, 54, 54, 15, 15, + 12, 12, 13, 13, 14, 14, 16, 6, 6, 5, + 5, 4, 4, 56, 57, 48, 48, 48, 48, 2, + 2, 3, 3, 29, 29, 29, 29, 29, 27, 27, + 27, 28, 28, 28, 45, 45, 45, 45, 51, 51, + 51, 51, 26, 26, 26, 26, 52, 52, 52, 47, + 47, 58, 58, 59, 50, 50, 60, 60, 61, 62, + 36, 63, 63, 63, 65, 64, 67, 64, 69, 69, + 69, 69, 70, 70, 71, 72, 72, 72, 72, 72, + 73, 10, 10, 11, 11, 74, 75, 75, 75, 75, + 75, 75, 75, 68, 68, 68, 9, 9, 76, 66, + 66, 66, 8, 8, 8, 7, 77, 37, 78, 78, + 79, 79, 79, 79, 79, 79, 20, 20, 18, 18, + 18, 17, 17, 17, 17, 17, 19, 23, 81, 80, + 80, 80, 82, 55, 55, 55, 83, 41, 84, 84, + 84, 24, 25, 40, 86, 38, 85, 85, 21, 21, + 22, 22, 22, 22, 22, 87, 87, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 91, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 89, 89, 94, 94, 93, 93, 95, 95, 96, 90, + 90, 92, 92, 97, 97, 98, 39, 99, 99, 100, + 100, 1, 30, 30, }; -short yylen[] = { 2, +const short yylen[] = { 2, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 3, 0, 5, 2, 3, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, - 2, 2, 5, 2, 0, 5, 2, 2, 4, 4, - 4, 4, 0, 5, 4, 4, 1, 1, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, - 2, 2, 1, 4, 2, 3, 0, 8, 8, 1, - 2, 3, 0, 2, 0, 2, 0, 2, 5, 1, - 1, 1, 1, 1, 1, 2, 2, 1, 1, 2, - 2, 0, 2, 0, 2, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, - 2, 0, 1, 2, 3, 1, 0, 1, 2, 3, - 1, 0, 5, 2, 3, 1, 0, 6, 0, 6, - 1, 1, 2, 1, 2, 2, 2, 0, 1, 1, - 2, 2, 3, 1, 1, 0, 1, 2, 1, 1, - 1, 2, 2, 2, 2, 2, 3, 1, 1, 1, - 1, 2, 3, 1, 1, 1, 1, 1, 0, 6, - 2, 3, 2, 2, 2, 2, 4, 1, 2, 3, - 1, 2, 2, 1, 3, 3, 1, 3, 1, 1, - 1, 2, 3, 1, 0, 6, 2, 2, 1, 3, - 3, 5, 0, 5, 0, 3, 0, 1, 1, 1, - 1, 1, 1, 2, 3, 2, 2, 2, 2, 5, - 2, 2, 4, 4, 4, 2, 0, 5, 2, 2, - 2, 2, 5, 5, 4, 2, 1, 2, 3, 1, - 0, 1, 2, 3, 1, 1, 1, 0, 1, 2, - 3, 1, 4, 2, 3, 5, 5, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 3, 2, 2, 5, 2, 0, + 5, 2, 2, 4, 4, 4, 4, 0, 5, 4, + 4, 1, 1, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 4, 2, 2, 1, 4, + 2, 3, 0, 8, 10, 12, 8, 1, 2, 3, + 0, 2, 0, 2, 0, 2, 5, 1, 1, 1, + 1, 1, 1, 2, 2, 1, 1, 2, 2, 0, + 2, 0, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, + 2, 2, 1, 1, 1, 1, 2, 2, 2, 0, + 1, 2, 3, 1, 0, 1, 2, 3, 1, 0, + 5, 2, 3, 1, 0, 6, 0, 6, 1, 1, + 2, 1, 2, 2, 2, 0, 1, 1, 2, 2, + 3, 1, 1, 0, 1, 2, 1, 1, 1, 2, + 2, 2, 2, 2, 3, 1, 1, 1, 1, 2, + 3, 1, 1, 1, 1, 1, 0, 6, 2, 3, + 2, 2, 2, 2, 4, 1, 2, 3, 1, 2, + 2, 1, 3, 3, 1, 3, 1, 1, 1, 2, + 3, 1, 1, 2, 3, 1, 0, 6, 2, 2, + 1, 3, 3, 5, 0, 5, 0, 3, 0, 1, + 1, 1, 1, 1, 1, 2, 3, 2, 2, 2, + 2, 5, 2, 2, 4, 4, 4, 2, 0, 5, + 2, 2, 2, 2, 2, 5, 5, 4, 2, 1, + 2, 3, 1, 3, 0, 1, 2, 3, 1, 1, + 1, 0, 1, 2, 3, 1, 4, 2, 3, 5, + 5, 1, 1, 1, }; -short yydefred[] = { 0, - 0, 13, 0, 17, 0, 142, 0, 0, 0, 0, - 215, 0, 0, 2, 4, 0, 0, 0, 0, 0, - 0, 0, 0, 14, 15, 0, 0, 0, 0, 189, - 0, 0, 279, 280, 0, 0, 3, 5, 6, 7, - 8, 9, 10, 11, 12, 16, 0, 80, 0, 0, - 0, 0, 0, 0, 223, 228, 0, 0, 0, 0, - 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, +const short yydefred[] = { 0, + 0, 13, 0, 17, 0, 150, 0, 0, 0, 0, + 227, 0, 0, 2, 4, 0, 0, 0, 0, 0, + 0, 0, 0, 14, 15, 0, 0, 0, 0, 197, + 0, 0, 293, 294, 0, 0, 3, 5, 6, 7, + 8, 9, 10, 11, 12, 16, 0, 88, 0, 0, + 0, 0, 0, 0, 235, 240, 0, 0, 0, 0, + 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, - 0, 0, 0, 0, 0, 45, 0, 0, 57, 58, - 92, 93, 0, 0, 74, 0, 75, 146, 0, 0, - 0, 0, 0, 0, 0, 0, 273, 0, 274, 0, - 0, 0, 0, 0, 201, 0, 207, 0, 209, 0, - 23, 25, 24, 28, 26, 27, 110, 106, 107, 108, - 109, 29, 30, 31, 0, 0, 47, 0, 0, 0, - 0, 0, 126, 127, 128, 121, 125, 122, 123, 124, - 22, 33, 34, 129, 130, 131, 90, 91, 59, 60, - 61, 32, 38, 39, 35, 36, 62, 63, 64, 65, - 68, 41, 66, 37, 42, 67, 72, 71, 0, 0, - 48, 0, 69, 0, 0, 0, 0, 111, 112, 113, - 0, 117, 118, 119, 120, 44, 0, 18, 0, 19, - 0, 0, 76, 186, 187, 147, 188, 185, 180, 149, - 179, 143, 0, 144, 198, 0, 0, 0, 0, 0, - 0, 0, 0, 224, 0, 0, 275, 0, 0, 203, - 0, 202, 199, 222, 0, 219, 0, 0, 0, 0, - 0, 278, 95, 94, 97, 96, 100, 101, 103, 0, + 0, 0, 58, 0, 0, 0, 0, 0, 0, 0, + 50, 0, 0, 62, 63, 100, 101, 0, 0, 80, + 0, 81, 154, 0, 0, 0, 0, 0, 0, 0, + 0, 287, 0, 288, 0, 0, 0, 0, 0, 209, + 0, 215, 0, 217, 0, 24, 26, 25, 29, 27, + 28, 118, 114, 115, 116, 117, 31, 32, 33, 34, + 30, 0, 0, 52, 0, 0, 0, 0, 0, 134, + 135, 136, 129, 133, 130, 131, 132, 23, 22, 38, + 70, 39, 137, 138, 139, 98, 99, 64, 65, 66, + 35, 36, 37, 43, 44, 40, 41, 67, 68, 69, + 71, 74, 46, 72, 42, 47, 73, 78, 77, 0, + 0, 53, 0, 75, 0, 0, 0, 0, 119, 120, + 121, 0, 125, 126, 127, 128, 49, 0, 18, 0, + 19, 0, 0, 0, 82, 194, 195, 155, 196, 193, + 188, 157, 187, 151, 0, 152, 206, 0, 0, 0, + 0, 0, 0, 0, 0, 236, 0, 0, 289, 0, + 0, 211, 0, 210, 207, 234, 0, 231, 0, 0, + 0, 0, 0, 292, 103, 102, 105, 104, 108, 109, + 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 122, 123, 124, 45, 0, 20, 0, + 0, 0, 0, 0, 153, 204, 201, 203, 0, 202, + 198, 0, 199, 270, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 114, 115, 116, 40, 0, 20, 0, 0, 0, - 0, 145, 196, 193, 195, 0, 194, 190, 0, 191, - 257, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 247, - 0, 0, 0, 0, 205, 206, 208, 200, 0, 0, - 217, 218, 216, 0, 84, 0, 0, 70, 0, 81, - 52, 56, 141, 0, 0, 0, 49, 51, 50, 55, - 136, 0, 0, 0, 0, 0, 0, 0, 214, 211, - 210, 0, 0, 192, 249, 251, 252, 250, 237, 229, - 230, 232, 231, 233, 236, 0, 0, 241, 0, 0, - 0, 256, 238, 239, 0, 0, 0, 242, 266, 267, - 246, 0, 226, 0, 234, 276, 277, 220, 221, 43, - 86, 0, 0, 82, 54, 0, 139, 46, 0, 134, - 0, 0, 184, 181, 0, 0, 178, 0, 0, 0, - 171, 0, 0, 0, 0, 169, 170, 0, 197, 0, - 212, 105, 0, 0, 0, 265, 0, 0, 0, 0, - 0, 0, 0, 235, 88, 0, 140, 135, 0, 0, - 148, 0, 182, 154, 0, 151, 172, 0, 165, 167, - 168, 164, 173, 174, 175, 150, 0, 176, 213, 260, - 0, 0, 0, 0, 255, 0, 263, 243, 244, 245, - 272, 0, 0, 0, 89, 78, 79, 183, 153, 0, - 0, 0, 0, 163, 177, 240, 0, 258, 253, 254, - 264, 248, 0, 270, 155, 156, 157, 161, 162, 259, - 271, + 0, 0, 259, 0, 0, 0, 0, 213, 214, 216, + 208, 0, 0, 229, 230, 228, 0, 92, 0, 0, + 76, 0, 89, 57, 61, 149, 0, 0, 0, 54, + 56, 55, 60, 144, 0, 0, 0, 0, 0, 0, + 0, 0, 222, 219, 218, 0, 0, 200, 261, 263, + 264, 265, 262, 249, 241, 242, 244, 243, 245, 248, + 0, 0, 253, 0, 0, 0, 269, 250, 251, 0, + 0, 0, 254, 280, 281, 258, 0, 238, 0, 246, + 290, 291, 232, 233, 48, 94, 0, 0, 90, 59, + 0, 147, 51, 0, 142, 0, 0, 0, 192, 189, + 0, 0, 186, 0, 0, 0, 179, 0, 0, 0, + 0, 177, 178, 0, 205, 0, 220, 113, 0, 0, + 0, 279, 0, 0, 0, 0, 0, 0, 0, 247, + 96, 0, 148, 143, 0, 0, 0, 156, 0, 190, + 162, 0, 159, 180, 0, 173, 175, 176, 172, 181, + 182, 183, 158, 0, 184, 221, 0, 0, 0, 0, + 0, 268, 0, 277, 255, 256, 257, 286, 0, 0, + 0, 97, 0, 0, 87, 191, 161, 0, 0, 0, + 0, 171, 185, 0, 252, 0, 271, 266, 267, 278, + 260, 0, 284, 0, 226, 223, 0, 0, 163, 164, + 165, 169, 170, 274, 272, 285, 0, 85, 0, 224, + 0, 225, 86, }; -short yydgoto[] = { 12, - 274, 171, 387, 275, 123, 189, 236, 237, 424, 470, - 471, 282, 347, 413, 283, 284, 145, 146, 147, 148, - 55, 385, 370, 269, 270, 176, 221, 295, 162, 149, +const short yydgoto[] = { 12, + 286, 178, 402, 287, 128, 198, 248, 249, 440, 487, + 488, 294, 360, 428, 295, 296, 150, 151, 152, 153, + 55, 400, 536, 281, 282, 183, 232, 307, 167, 154, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 27, 117, 118, 226, 227, 362, 167, 212, 354, - 119, 120, 51, 52, 168, 169, 363, 364, 355, 356, - 29, 131, 132, 300, 425, 301, 435, 467, 502, 503, - 504, 436, 437, 438, 426, 54, 251, 252, 372, 373, - 36, 271, 254, 134, 331, 332, 481, 401, 402, 492, - 447, 482, 448, 449, 493, 494, 58, 59, + 23, 27, 122, 123, 237, 238, 375, 174, 223, 367, + 124, 125, 51, 52, 537, 175, 176, 376, 377, 368, + 369, 29, 136, 137, 313, 441, 314, 451, 484, 520, + 521, 522, 452, 453, 454, 442, 54, 263, 264, 386, + 387, 538, 36, 283, 266, 139, 344, 345, 498, 416, + 417, 509, 463, 499, 464, 465, 510, 511, 58, 59, }; -short yysindex[] = { 419, - -172, 0, -236, 0, -91, 0, -224, -211, -71, -178, - 0, 0, 419, 0, 0, -166, -160, -158, -156, -154, - -144, -139, -128, 0, 0, -126, -49, -195, 10, 0, - -178, -198, 0, 0, 12, -178, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 349, 0, -7, -123, - -112, -115, -238, 23, 0, 0, -189, -110, -105, 43, - 31, 0, -98, -96, -94, -85, -76, -73, -190, -190, - -190, -86, -106, 33, -81, -81, -81, -81, -58, -190, - -190, -59, -50, -45, -121, -34, -32, -190, -190, -190, - -190, -190, 51, 56, 63, 64, 66, -190, 68, -190, - -190, 69, 71, -190, 123, 136, -7, 0, -190, 212, - 219, 220, 222, -258, -182, 0, 168, 89, 0, 0, - 0, 0, 73, 62, 0, 93, 0, 0, -181, -216, - -69, 94, -220, 230, 95, 96, 0, 99, 0, 312, - 313, 104, 43, -100, 0, 108, 0, -29, 0, -196, +const short yysindex[] = { 148, + -173, 0, -245, 0, -82, 0, -202, -214, -65, -180, + 0, 0, 148, 0, 0, -193, -183, -179, -170, -159, + -154, -150, -143, 0, 0, -120, 18, -151, 20, 0, + -180, -108, 0, 0, 41, -180, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 414, 0, -25, -93, + -102, -85, -218, 51, 0, 0, -139, -90, -71, 66, + 55, 0, -47, -42, -34, 10, 33, 53, -123, -123, + -123, -123, -62, -67, -17, 196, 56, 56, 56, 56, + 73, 82, -123, 88, -123, 89, 99, 100, -92, 102, + 103, -182, -123, -123, -123, -123, -123, 104, 105, 107, + 56, 118, -123, 119, -123, -123, 121, 122, -123, 259, + 260, -25, 0, -123, 261, 265, 266, 268, -162, -56, + 0, 295, 136, 0, 0, 0, 0, -181, 108, 0, + 139, 0, 0, -134, -200, -72, 140, -217, 275, 141, + 143, 0, 142, 0, 356, 359, 149, 66, -79, 0, + 150, 0, -29, 0, -219, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -31, -7, 0, 100, 92, 111, - 254, 98, 0, 0, 0, 0, 0, 0, 0, 0, + 0, -31, -25, 0, 130, 137, 159, 299, 145, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 43, 43, - 0, 257, 0, 43, 43, 43, 43, 0, 0, 0, - -68, 0, 0, 0, 0, 0, 258, 0, 127, 0, - 111, 126, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 129, 0, 0, -121, -190, 130, 265, -190, - -120, 133, 374, 0, 134, 135, 0, 137, 138, 0, - -25, 0, 0, 0, 141, 0, -178, -178, 21, 32, - 275, 0, 0, 0, 0, 0, 0, 0, 0, 43, - -178, 52, -108, 146, -21, -17, 147, -11, 5, 9, - 14, 0, 0, 0, 0, 148, 0, 116, 121, 286, - 287, 0, 0, 0, 0, -151, 0, 0, 154, 0, - 0, 155, -190, -190, 157, 152, -13, 143, -7, 35, - 294, -190, 160, 161, 300, 302, 304, -68, -70, 0, - 236, 171, 169, 170, 0, 0, 0, 0, 172, 175, - 0, 0, 0, 18, 0, -178, 164, 0, 188, 0, - 0, 0, 0, 322, 147, 191, 0, 0, 0, 0, - 0, 324, 148, 193, 328, 194, -207, -2, 0, 0, - 0, -92, 195, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 111, 331, 0, 196, 197, - 202, 0, 0, 0, 43, 43, 43, 0, 0, 0, - 0, 338, 0, 215, 0, 0, 0, 0, 0, 0, - 0, 232, 216, 0, 0, 237, 0, 0, 239, 0, - 43, 186, 0, 0, -41, 243, 0, -145, 240, -183, - 0, -190, -190, -190, -118, 0, 0, 245, 0, 246, - 0, 0, 249, 250, 251, 0, 379, 202, 255, 22, - 26, 30, 253, 0, 0, 248, 0, 0, 39, 256, - 0, 259, 0, 0, 260, 0, 0, -16, 0, 0, - 0, 0, 0, 0, 0, 0, 261, 0, 0, 0, - -101, 263, 252, 264, 0, 271, 0, 0, 0, 0, - 0, 389, 253, 272, 0, 0, 0, 0, 0, -218, - -81, 187, 192, 0, 0, 0, 273, 0, 0, 0, - 0, 0, 274, 0, 0, 0, 0, 0, 0, 0, - 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 66, + 66, 0, 300, 0, 66, 66, 66, 66, 0, 0, + 0, -177, 0, 0, 0, 0, 0, 301, 0, 169, + 0, 159, 307, 174, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 178, 0, 0, -92, -123, 179, + 317, -123, -100, 187, 439, 0, 186, 188, 0, 190, + 191, 0, -23, 0, 0, 0, 195, 0, -180, -180, + 80, 83, 335, 0, 0, 0, 0, 0, 0, 0, + 0, 66, -180, 106, -110, 205, -19, -15, 207, -6, + 15, 19, 26, 0, 0, 0, 0, 208, 0, 173, + 66, 180, 344, 346, 0, 0, 0, 0, -145, 0, + 0, 221, 0, 0, 223, -49, -123, 56, 222, -3, + 206, -25, 22, 362, -123, 225, 227, 366, 367, 371, + -177, -128, 0, 109, 238, 235, 236, 0, 0, 0, + 0, 241, 243, 0, 0, 0, 30, 0, -180, 224, + 0, 248, 0, 0, 0, 0, 382, 207, 251, 0, + 0, 0, 0, 0, 386, 208, 255, 390, 38, 256, + -211, 114, 0, 0, 0, -70, 262, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 159, 395, 0, 263, 267, 270, 0, 0, 0, 66, + 66, 66, 0, 0, 0, 0, 397, 0, 264, 0, + 0, 0, 0, 0, 0, 0, 269, 244, 0, 0, + 272, 0, 0, 274, 0, 66, 175, 245, 0, 0, + -113, 276, 0, -188, 271, -178, 0, -123, -123, -123, + -119, 0, 0, 278, 0, 279, 0, 0, 280, 281, + 283, 0, 418, 270, 282, 42, 46, 52, 286, 0, + 0, 285, 0, 0, 62, 423, 288, 0, 291, 0, + 0, 290, 0, 0, -43, 0, 0, 0, 0, 0, + 0, 0, 0, 293, 0, 0, 177, -112, 296, 294, + 312, 0, 297, 0, 0, 0, 0, 0, 431, 286, + 319, 0, 228, -138, 0, 0, 0, -205, 56, 242, + 239, 0, 0, -180, 0, 322, 0, 0, 0, 0, + 0, 323, 0, 458, 0, 0, -68, 325, 0, 0, + 0, 0, 0, 0, 0, 0, -138, 0, 327, 0, + -60, 0, 0, }; -short yyrindex[] = { 0, +const short yyrindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 585, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 332, 0, 0, + -95, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 333, 0, 0, 0, + 332, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 480, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 522, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 280, 0, 0, - -117, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 282, 0, 0, 0, - 280, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 409, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 333, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 347, 0, + 0, 0, 0, 0, 349, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 282, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 284, 0, 0, 0, 0, 0, 290, + 0, 0, 0, 0, 368, 369, 0, 0, -189, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 291, 292, 0, - 0, -222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -467,215 +494,226 @@ short yyrindex[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 63, -189, 0, 0, 0, 499, 0, + 0, 0, 0, 0, 0, 0, 0, 502, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 41, -222, 0, 0, 0, 418, 0, 0, 0, - 0, 0, 0, 0, 0, 426, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 429, 0, 0, + 505, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 348, + 0, 0, 0, 0, 0, 0, 0, 506, 0, 0, + 0, 0, 0, 0, 0, 507, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 276, 0, 0, 0, - 0, 0, 0, 0, 428, 0, 0, 0, 0, 0, - 0, 0, 431, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 508, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 432, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 297, + 0, 0, 0, 0, 0, 373, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 433, 0, 0, - 0, 0, 434, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 303, 0, 0, 305, 0, 0, + 0, 0, 0, 509, 0, 0, 0, 0, 510, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 379, 0, 0, 380, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 383, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 516, + 0, 0, 385, 0, 0, 0, 0, 0, 0, 387, + 388, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 436, 0, 0, 0, 0, 0, 0, 0, - 0, 306, 308, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, + 0, 0, 0, }; -short yygindex[] = { 0, - -124, 0, 0, 0, -93, 320, 0, 0, 437, 0, - 0, 0, 0, 0, 0, 285, 425, -84, 0, 102, - 0, 0, 0, 301, 307, -75, 0, 242, -61, -10, - 0, 559, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 456, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 523, 406, 410, 0, 214, 0, 224, - 0, 0, 449, 0, 0, 0, 0, 0, 78, 80, - 0, 0, 0, 149, 158, 0, 0, 335, 0, 217, - 0, 0, 0, 0, 0, 267, 0, 0, 0, 0, - 0, 106, 0, 140, 0, 97, 0, 541, +const short yygindex[] = { 0, + -141, 0, 0, 0, -107, 389, 0, 0, 511, 0, + 0, 0, 0, 0, 0, 353, 494, 35, 0, 147, + 0, 0, -300, 370, 372, -77, 0, 308, -63, -10, + 0, 637, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 529, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 603, 111, 479, 481, 0, 287, 0, + 303, 0, 0, 525, 0, 0, 0, 0, 0, 144, + 152, 0, 0, 0, 211, 233, 0, 0, 401, 0, + 289, -475, 0, 0, 0, 0, 0, 352, 0, 0, + 0, 0, 0, 194, 0, 212, 0, 183, 0, 639, }; -#define YYTABLESIZE 788 -short yytable[] = { 35, - 178, 179, 180, 144, 308, 227, 476, 144, 163, 164, - 273, 144, 125, 211, 137, 144, 348, 128, 182, 183, - 56, 144, 143, 506, 26, 61, 192, 193, 194, 195, - 196, 28, 439, 30, 122, 245, 202, 144, 204, 205, - 515, 144, 208, 33, 34, 279, 144, 213, 423, 31, - 144, 32, 33, 34, 144, 242, 83, 83, 144, 266, - 48, 57, 144, 265, 177, 177, 177, 177, 157, 135, - 136, 144, 276, 47, 516, 144, 33, 34, 33, 34, - 246, 33, 34, 461, 24, 129, 130, 49, 50, 25, - 38, 218, 219, 143, 220, 264, 39, 143, 40, 337, - 41, 143, 42, 351, 369, 143, 298, 352, 33, 34, - 234, 143, 43, 357, 33, 34, 239, 44, 238, 241, - 247, 248, 249, 250, 235, 239, 83, 143, 45, 358, - 46, 143, 53, 359, 60, 245, 143, 124, 360, 227, - 143, 127, 410, 48, 143, 133, 488, 469, 143, 57, - 489, 139, 143, 150, 490, 172, 480, 140, 141, 33, - 34, 143, 151, 496, 152, 143, 153, 33, 34, 170, - 49, 50, 281, 267, 268, 154, 265, 173, 33, 34, - 246, 464, 187, 188, 155, 304, 465, 156, 307, 165, - 166, 158, 159, 160, 161, 222, 223, 224, 225, 184, - 265, 265, 181, 265, 265, 265, 265, 428, 185, 429, - 174, 175, 430, 186, 431, 432, 433, 434, 33, 34, - 247, 248, 249, 250, 190, 388, 191, 272, 140, 141, - 33, 34, 140, 141, 33, 34, 140, 141, 33, 34, - 140, 141, 33, 34, 261, 209, 140, 141, 33, 34, - 121, 376, 377, 427, 129, 130, 339, 340, 210, 265, - 392, 442, 140, 141, 33, 34, 140, 141, 33, 34, - 345, 140, 141, 33, 34, 140, 141, 33, 34, 140, - 141, 33, 34, 140, 141, 33, 34, 140, 141, 33, - 34, 239, 228, 389, 390, 371, 140, 141, 33, 34, - 140, 141, 33, 34, 292, 293, 294, 399, 400, 197, - 285, 286, 500, 501, 198, 288, 289, 290, 291, 85, - 85, 199, 200, 428, 201, 429, 203, 206, 430, 207, - 431, 432, 433, 434, 214, 411, 380, 381, 382, 142, - 383, 215, 216, 142, 217, 230, 232, 142, 231, 233, - 244, 142, 253, 255, 256, 257, 241, 142, 258, 259, - 403, 371, 384, 260, 263, 265, 265, 265, 166, 272, - 473, 474, 475, 142, 265, 165, 280, 142, 281, 287, - 296, 344, 142, 297, 299, 302, 142, 306, 305, 310, - 142, 268, 333, 334, 142, 335, 336, 338, 142, 343, - 346, 267, 350, 365, 353, 361, 366, 142, 367, 368, - 374, 142, 379, 375, 241, 378, 391, 466, 386, 472, - 393, 394, 395, 62, 396, 517, 397, 405, 408, 406, - 407, 409, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 412, 414, 74, 415, 417, 418, 420, - 421, 441, 422, 443, 444, 445, 75, 76, 77, 446, - 453, 78, 79, 80, 81, 82, 83, 84, 85, 86, - 87, 454, 460, 88, 89, 90, 91, 92, 93, 94, - 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 177, 311, 455, 457, 456, 458, 450, 451, 452, 463, - 468, 478, 479, 485, 105, 106, 480, 495, 483, 484, - 491, 487, 509, 512, 497, 498, 501, 505, 499, 508, - 500, 1, 459, 107, 510, 108, 109, 511, 514, 520, - 521, 102, 110, 111, 112, 113, 77, 312, 21, 114, - 225, 313, 137, 115, 116, 314, 204, 98, 99, 315, - 132, 104, 138, 166, 87, 133, 261, 262, 268, 152, - 269, 158, 159, 316, 160, 303, 240, 349, 262, 398, - 342, 37, 229, 126, 278, 341, 419, 277, 416, 243, - 519, 518, 462, 477, 317, 309, 507, 486, 440, 513, - 318, 319, 320, 321, 322, 323, 324, 404, 138, 325, - 326, 327, 0, 0, 62, 0, 0, 328, 0, 0, - 0, 329, 330, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 0, 0, 74, 0, 0, 311, - 0, 0, 0, 0, 0, 0, 0, 75, 76, 77, - 0, 0, 78, 79, 80, 81, 82, 83, 84, 85, - 86, 87, 0, 0, 88, 89, 90, 91, 92, 93, - 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, - 104, 0, 0, 0, 1, 312, 0, 0, 0, 313, - 2, 3, 4, 314, 0, 105, 106, 315, 0, 0, +#define YYTABLESIZE 822 +const short yytable[] = { 35, + 185, 186, 187, 149, 222, 493, 168, 169, 170, 149, + 285, 478, 525, 149, 361, 26, 127, 149, 384, 190, + 56, 192, 130, 211, 321, 61, 149, 239, 202, 203, + 204, 205, 206, 207, 142, 291, 278, 133, 257, 213, + 28, 215, 216, 148, 439, 219, 31, 149, 33, 34, + 224, 149, 254, 539, 455, 30, 548, 32, 149, 33, + 34, 549, 149, 38, 553, 288, 184, 184, 184, 184, + 149, 33, 34, 39, 149, 549, 162, 40, 149, 33, + 34, 33, 34, 24, 149, 384, 41, 258, 25, 540, + 184, 91, 91, 148, 149, 276, 242, 42, 149, 148, + 310, 350, 43, 148, 48, 364, 44, 148, 243, 365, + 383, 134, 135, 45, 33, 34, 148, 535, 370, 140, + 141, 33, 34, 250, 253, 33, 34, 251, 201, 259, + 260, 261, 262, 49, 50, 162, 46, 148, 251, 371, + 47, 148, 53, 372, 481, 497, 33, 34, 148, 482, + 373, 57, 148, 48, 425, 257, 279, 280, 486, 246, + 148, 239, 437, 60, 148, 91, 505, 129, 148, 57, + 506, 132, 293, 138, 148, 247, 507, 155, 145, 146, + 33, 34, 49, 50, 148, 144, 513, 277, 148, 33, + 34, 33, 34, 229, 230, 317, 231, 171, 320, 33, + 34, 304, 305, 306, 258, 163, 164, 165, 166, 162, + 172, 173, 444, 156, 445, 196, 197, 446, 157, 447, + 448, 449, 450, 544, 403, 251, 158, 284, 145, 146, + 33, 34, 126, 418, 145, 146, 33, 34, 145, 146, + 33, 34, 145, 146, 33, 34, 259, 260, 261, 262, + 393, 145, 146, 33, 34, 414, 415, 134, 135, 458, + 177, 390, 391, 392, 163, 164, 165, 166, 352, 353, + 159, 407, 145, 146, 33, 34, 145, 146, 33, 34, + 404, 405, 358, 145, 146, 33, 34, 145, 146, 33, + 34, 518, 519, 160, 273, 145, 146, 33, 34, 145, + 146, 33, 34, 145, 146, 33, 34, 277, 385, 145, + 146, 33, 34, 161, 180, 33, 34, 184, 179, 145, + 146, 33, 34, 145, 146, 33, 34, 233, 234, 235, + 236, 277, 277, 188, 277, 277, 277, 277, 163, 164, + 165, 166, 189, 93, 93, 147, 191, 193, 426, 181, + 182, 147, 395, 396, 397, 147, 398, 194, 195, 147, + 199, 200, 208, 209, 324, 210, 297, 298, 147, 443, + 253, 300, 301, 302, 303, 385, 212, 214, 399, 217, + 218, 220, 221, 225, 490, 491, 492, 226, 227, 147, + 228, 277, 241, 147, 244, 245, 256, 265, 269, 267, + 147, 268, 270, 1, 147, 271, 275, 172, 272, 2, + 3, 4, 147, 277, 325, 173, 147, 284, 326, 239, + 147, 292, 299, 308, 327, 309, 147, 293, 328, 311, + 253, 5, 312, 483, 315, 489, 147, 318, 357, 319, + 147, 541, 329, 323, 346, 444, 347, 445, 348, 349, + 446, 351, 447, 448, 449, 450, 280, 379, 279, 356, + 359, 363, 378, 330, 366, 374, 381, 380, 382, 331, + 332, 333, 334, 335, 336, 337, 6, 388, 338, 339, + 340, 389, 394, 401, 406, 408, 341, 409, 410, 411, + 342, 343, 7, 412, 420, 421, 422, 423, 8, 424, + 277, 277, 277, 385, 429, 427, 430, 432, 184, 277, + 433, 435, 436, 385, 438, 9, 10, 459, 457, 469, + 470, 460, 11, 476, 472, 461, 385, 462, 473, 471, + 474, 485, 480, 477, 495, 496, 385, 497, 504, 500, + 385, 501, 502, 508, 512, 514, 515, 516, 517, 523, + 62, 524, 527, 530, 528, 531, 466, 467, 468, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 529, 518, 76, 533, 534, 519, 545, 546, + 547, 550, 475, 552, 1, 77, 78, 79, 83, 21, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 110, 237, 92, 212, 93, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, + 107, 108, 109, 145, 106, 107, 140, 112, 95, 174, + 146, 141, 275, 276, 282, 160, 166, 110, 111, 273, + 283, 84, 274, 167, 168, 252, 316, 362, 413, 37, + 240, 355, 354, 131, 290, 289, 112, 551, 113, 114, + 255, 494, 434, 322, 543, 115, 116, 117, 118, 62, + 431, 542, 119, 479, 456, 503, 120, 121, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 526, 532, 76, 324, 419, 143, 0, 0, 0, + 0, 0, 0, 0, 77, 78, 79, 0, 0, 80, + 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, + 91, 0, 0, 92, 0, 93, 94, 95, 96, 97, + 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 0, 0, 325, 0, 0, 0, 326, 0, + 0, 0, 0, 0, 327, 0, 110, 111, 328, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 5, 316, 0, 0, 107, 0, 108, 109, 0, 0, - 0, 0, 0, 110, 111, 112, 113, 0, 0, 0, - 114, 0, 317, 0, 115, 116, 0, 0, 318, 319, - 320, 321, 322, 323, 324, 0, 0, 325, 326, 327, - 0, 6, 0, 0, 0, 328, 0, 0, 0, 329, - 330, 0, 0, 0, 0, 0, 0, 7, 0, 0, - 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 9, 10, 0, 0, 0, 0, 0, 11, + 0, 0, 329, 0, 0, 112, 0, 113, 114, 0, + 0, 0, 0, 0, 115, 116, 117, 118, 0, 0, + 0, 119, 0, 330, 0, 120, 121, 0, 0, 331, + 332, 333, 334, 335, 336, 337, 0, 0, 338, 339, + 340, 0, 0, 0, 0, 0, 341, 0, 0, 0, + 342, 343, }; -short yycheck[] = { 10, - 76, 77, 78, 33, 125, 123, 125, 33, 70, 71, - 42, 33, 125, 107, 125, 33, 125, 256, 80, 81, - 31, 33, 123, 125, 261, 36, 88, 89, 90, 91, - 92, 123, 125, 258, 42, 256, 98, 33, 100, 101, - 259, 33, 104, 260, 261, 170, 33, 109, 256, 261, - 33, 123, 260, 261, 33, 125, 279, 280, 33, 256, - 256, 260, 33, 148, 75, 76, 77, 78, 259, 259, - 260, 33, 166, 123, 293, 33, 260, 261, 260, 261, - 301, 260, 261, 125, 257, 324, 325, 283, 284, 262, - 257, 350, 351, 123, 353, 125, 257, 123, 257, 125, - 257, 123, 257, 125, 256, 123, 231, 125, 260, 261, - 292, 123, 257, 125, 260, 261, 333, 257, 129, 130, - 341, 342, 343, 344, 306, 333, 349, 123, 257, 125, - 257, 123, 123, 125, 123, 256, 123, 261, 125, 257, - 123, 257, 125, 256, 123, 123, 125, 331, 123, 260, - 125, 257, 123, 123, 125, 123, 258, 258, 259, 260, - 261, 123, 261, 125, 261, 123, 261, 260, 261, 276, - 283, 284, 281, 370, 371, 261, 261, 259, 260, 261, - 301, 327, 304, 305, 261, 247, 332, 261, 250, 276, - 277, 382, 383, 384, 385, 378, 379, 380, 381, 259, - 285, 286, 261, 288, 289, 290, 291, 326, 259, 328, - 292, 293, 331, 259, 333, 334, 335, 336, 260, 261, - 341, 342, 343, 344, 259, 319, 259, 259, 258, 259, - 260, 261, 258, 259, 260, 261, 258, 259, 260, 261, - 258, 259, 260, 261, 143, 123, 258, 259, 260, 261, - 258, 313, 314, 256, 324, 325, 267, 268, 123, 344, - 322, 386, 258, 259, 260, 261, 258, 259, 260, 261, - 281, 258, 259, 260, 261, 258, 259, 260, 261, 258, - 259, 260, 261, 258, 259, 260, 261, 258, 259, 260, - 261, 333, 125, 259, 260, 306, 258, 259, 260, 261, - 258, 259, 260, 261, 373, 374, 375, 378, 379, 259, - 209, 210, 329, 330, 259, 214, 215, 216, 217, 279, - 280, 259, 259, 326, 259, 328, 259, 259, 331, 259, - 333, 334, 335, 336, 123, 346, 350, 351, 352, 369, - 354, 123, 123, 369, 123, 257, 285, 369, 276, 257, - 257, 369, 123, 259, 259, 257, 367, 369, 47, 47, - 125, 372, 376, 260, 257, 450, 451, 452, 277, 259, - 432, 433, 434, 369, 459, 276, 123, 369, 281, 123, - 123, 280, 369, 257, 259, 257, 369, 123, 259, 257, - 369, 371, 259, 259, 369, 259, 259, 257, 369, 125, - 349, 370, 257, 288, 258, 258, 286, 369, 123, 123, - 257, 369, 261, 259, 425, 259, 123, 428, 276, 430, - 261, 261, 123, 256, 123, 501, 123, 257, 257, 261, - 261, 257, 265, 266, 267, 268, 269, 270, 271, 272, - 273, 274, 275, 280, 257, 278, 125, 257, 125, 257, - 123, 257, 259, 123, 259, 259, 289, 290, 291, 258, - 123, 294, 295, 296, 297, 298, 299, 300, 301, 302, - 303, 257, 287, 306, 307, 308, 309, 310, 311, 312, - 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, - 501, 256, 261, 257, 279, 257, 395, 396, 397, 257, - 261, 257, 257, 125, 337, 338, 258, 260, 259, 259, - 258, 257, 261, 125, 259, 257, 330, 257, 259, 257, - 329, 0, 421, 356, 261, 358, 359, 257, 257, 257, - 257, 123, 365, 366, 367, 368, 257, 302, 257, 372, - 257, 306, 125, 376, 377, 310, 257, 257, 257, 314, - 125, 123, 125, 257, 279, 125, 125, 125, 125, 257, - 125, 257, 257, 328, 257, 246, 130, 283, 144, 328, - 270, 13, 117, 51, 169, 269, 363, 168, 355, 131, - 503, 502, 425, 435, 349, 251, 481, 448, 372, 493, - 355, 356, 357, 358, 359, 360, 361, 331, 58, 364, - 365, 366, -1, -1, 256, -1, -1, 372, -1, -1, - -1, 376, 377, 265, 266, 267, 268, 269, 270, 271, - 272, 273, 274, 275, -1, -1, 278, -1, -1, 256, - -1, -1, -1, -1, -1, -1, -1, 289, 290, 291, - -1, -1, 294, 295, 296, 297, 298, 299, 300, 301, - 302, 303, -1, -1, 306, 307, 308, 309, 310, 311, - 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, - 322, -1, -1, -1, 256, 302, -1, -1, -1, 306, - 262, 263, 264, 310, -1, 337, 338, 314, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 282, 328, -1, -1, 356, -1, 358, 359, -1, -1, - -1, -1, -1, 365, 366, 367, 368, -1, -1, -1, - 372, -1, 349, -1, 376, 377, -1, -1, 355, 356, - 357, 358, 359, 360, 361, -1, -1, 364, 365, 366, - -1, 323, -1, -1, -1, 372, -1, -1, -1, 376, - 377, -1, -1, -1, -1, -1, -1, 339, -1, -1, - -1, -1, -1, 345, -1, -1, -1, -1, -1, -1, +const short yycheck[] = { 10, + 78, 79, 80, 33, 112, 125, 70, 71, 72, 33, + 42, 125, 125, 33, 125, 261, 42, 33, 319, 83, + 31, 85, 125, 101, 125, 36, 33, 123, 92, 93, + 94, 95, 96, 97, 125, 177, 256, 256, 256, 103, + 123, 105, 106, 123, 256, 109, 261, 33, 260, 261, + 114, 33, 125, 259, 125, 258, 125, 123, 33, 260, + 261, 537, 33, 257, 125, 173, 77, 78, 79, 80, + 33, 260, 261, 257, 33, 551, 259, 257, 33, 260, + 261, 260, 261, 257, 33, 386, 257, 305, 262, 295, + 101, 281, 282, 123, 33, 125, 278, 257, 33, 123, + 242, 125, 257, 123, 256, 125, 257, 123, 290, 125, + 256, 330, 331, 257, 260, 261, 123, 256, 125, 259, + 260, 260, 261, 134, 135, 260, 261, 339, 311, 347, + 348, 349, 350, 285, 286, 259, 257, 123, 339, 125, + 123, 123, 123, 125, 333, 258, 260, 261, 123, 338, + 125, 260, 123, 256, 125, 256, 376, 377, 337, 294, + 123, 257, 125, 123, 123, 355, 125, 261, 123, 260, + 125, 257, 283, 123, 123, 310, 125, 123, 258, 259, + 260, 261, 285, 286, 123, 257, 125, 153, 123, 260, + 261, 260, 261, 356, 357, 259, 359, 260, 262, 260, + 261, 379, 380, 381, 305, 388, 389, 390, 391, 259, + 278, 279, 332, 261, 334, 308, 309, 337, 261, 339, + 340, 341, 342, 524, 332, 339, 261, 259, 258, 259, + 260, 261, 258, 125, 258, 259, 260, 261, 258, 259, + 260, 261, 258, 259, 260, 261, 347, 348, 349, 350, + 328, 258, 259, 260, 261, 384, 385, 330, 331, 401, + 278, 311, 326, 327, 388, 389, 390, 391, 279, 280, + 261, 335, 258, 259, 260, 261, 258, 259, 260, 261, + 259, 260, 293, 258, 259, 260, 261, 258, 259, 260, + 261, 335, 336, 261, 148, 258, 259, 260, 261, 258, + 259, 260, 261, 258, 259, 260, 261, 273, 319, 258, + 259, 260, 261, 261, 259, 260, 261, 328, 123, 258, + 259, 260, 261, 258, 259, 260, 261, 384, 385, 386, + 387, 297, 298, 261, 300, 301, 302, 303, 388, 389, + 390, 391, 261, 281, 282, 375, 259, 259, 359, 294, + 295, 375, 356, 357, 358, 375, 360, 259, 259, 375, + 259, 259, 259, 259, 256, 259, 220, 221, 375, 256, + 381, 225, 226, 227, 228, 386, 259, 259, 382, 259, + 259, 123, 123, 123, 448, 449, 450, 123, 123, 375, + 123, 357, 257, 375, 287, 257, 257, 123, 257, 259, + 375, 259, 47, 256, 375, 47, 257, 278, 260, 262, + 263, 264, 375, 379, 306, 279, 375, 259, 310, 125, + 375, 123, 123, 123, 316, 257, 375, 283, 320, 123, + 441, 284, 259, 444, 257, 446, 375, 259, 292, 123, + 375, 519, 334, 257, 259, 332, 259, 334, 259, 259, + 337, 257, 339, 340, 341, 342, 377, 311, 376, 125, + 355, 257, 290, 355, 258, 258, 123, 288, 123, 361, + 362, 363, 364, 365, 366, 367, 329, 257, 370, 371, + 372, 259, 261, 278, 123, 261, 378, 261, 123, 123, + 382, 383, 345, 123, 257, 261, 261, 257, 351, 257, + 466, 467, 468, 514, 257, 282, 125, 257, 519, 475, + 125, 257, 123, 524, 259, 368, 369, 123, 257, 123, + 257, 259, 375, 349, 281, 259, 537, 258, 257, 261, + 257, 261, 257, 289, 257, 257, 547, 258, 257, 259, + 551, 259, 125, 258, 260, 123, 259, 257, 259, 257, + 256, 375, 257, 257, 261, 125, 410, 411, 412, 265, + 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, + 276, 277, 261, 335, 280, 257, 349, 336, 257, 257, + 123, 257, 436, 257, 0, 291, 292, 293, 257, 257, + 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, + 306, 307, 123, 257, 310, 257, 312, 313, 314, 315, + 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, + 326, 327, 328, 125, 257, 257, 125, 123, 281, 257, + 125, 125, 125, 125, 125, 257, 257, 343, 344, 257, + 125, 257, 149, 257, 257, 135, 258, 295, 341, 13, + 122, 282, 281, 51, 176, 175, 362, 547, 364, 365, + 136, 451, 376, 263, 521, 371, 372, 373, 374, 256, + 368, 520, 378, 441, 386, 464, 382, 383, 265, 266, + 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, + 277, 498, 510, 280, 256, 344, 58, -1, -1, -1, + -1, -1, -1, -1, 291, 292, 293, -1, -1, 296, + 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, + 307, -1, -1, 310, -1, 312, 313, 314, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, + 327, 328, -1, -1, 306, -1, -1, -1, 310, -1, + -1, -1, -1, -1, 316, -1, 343, 344, 320, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 362, 363, -1, -1, -1, -1, -1, 369, + -1, -1, 334, -1, -1, 362, -1, 364, 365, -1, + -1, -1, -1, -1, 371, 372, 373, 374, -1, -1, + -1, 378, -1, 355, -1, 382, 383, -1, -1, 361, + 362, 363, 364, 365, 366, 367, -1, -1, 370, 371, + 372, -1, -1, -1, -1, -1, 378, -1, -1, -1, + 382, 383, }; #define YYFINAL 12 #ifndef YYDEBUG #define YYDEBUG 0 +#elif YYDEBUG +#include <stdio.h> #endif -#define YYMAXTOKEN 385 +#define YYMAXTOKEN 391 #if YYDEBUG -char *yyname[] = { +const char * const yyname[] = { "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, "'!'",0,0,0,0,0,0,0,0,"'*'",0,0,0,0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -686,19 +724,20 @@ char *yyname[] = { "L_IPADDR","L_NUMBER","L_STRING","L_QSTRING","L_END_INCLUDE","T_INCLUDE", "T_OPTIONS","T_DIRECTORY","T_PIDFILE","T_NAMED_XFER","T_DUMP_FILE", "T_STATS_FILE","T_MEMSTATS_FILE","T_FAKE_IQUERY","T_RECURSION","T_FETCH_GLUE", -"T_QUERY_SOURCE","T_LISTEN_ON","T_PORT","T_ADDRESS","T_RRSET_ORDER","T_ORDER", -"T_NAME","T_CLASS","T_CONTROLS","T_INET","T_UNIX","T_PERM","T_OWNER","T_GROUP", -"T_ALLOW","T_DATASIZE","T_STACKSIZE","T_CORESIZE","T_DEFAULT","T_UNLIMITED", -"T_FILES","T_VERSION","T_HOSTSTATS","T_DEALLOC_ON_EXIT","T_TRANSFERS_IN", +"T_HITCOUNT","T_PREFERRED_GLUE","T_QUERY_SOURCE","T_LISTEN_ON","T_PORT", +"T_ADDRESS","T_RRSET_ORDER","T_ORDER","T_NAME","T_CLASS","T_CONTROLS","T_INET", +"T_UNIX","T_PERM","T_OWNER","T_GROUP","T_ALLOW","T_DATASIZE","T_STACKSIZE", +"T_CORESIZE","T_DEFAULT","T_UNLIMITED","T_FILES","T_VERSION","T_HOSTNAME", +"T_HOSTSTATS","T_HOSTSTATSMAX","T_DEALLOC_ON_EXIT","T_TRANSFERS_IN", "T_TRANSFERS_OUT","T_TRANSFERS_PER_NS","T_TRANSFER_FORMAT", "T_MAX_TRANSFER_TIME_IN","T_SERIAL_QUERIES","T_ONE_ANSWER","T_MANY_ANSWERS", -"T_NOTIFY","T_AUTH_NXDOMAIN","T_MULTIPLE_CNAMES","T_USE_IXFR", -"T_MAINTAIN_IXFR_BASE","T_CLEAN_INTERVAL","T_INTERFACE_INTERVAL", -"T_STATS_INTERVAL","T_MAX_LOG_SIZE_IXFR","T_HEARTBEAT","T_USE_ID_POOL", -"T_MAX_NCACHE_TTL","T_HAS_OLD_CLIENTS","T_RFC2308_TYPE1","T_LAME_TTL", -"T_MIN_ROOTS","T_TREAT_CR_AS_SPACE","T_LOGGING","T_CATEGORY","T_CHANNEL", -"T_SEVERITY","T_DYNAMIC","T_FILE","T_VERSIONS","T_SIZE","T_SYSLOG","T_DEBUG", -"T_NULL_OUTPUT","T_PRINT_TIME","T_PRINT_CATEGORY","T_PRINT_SEVERITY", +"T_NOTIFY","T_EXPLICIT","T_NOTIFY_INITIAL","T_AUTH_NXDOMAIN", +"T_MULTIPLE_CNAMES","T_USE_IXFR","T_MAINTAIN_IXFR_BASE","T_CLEAN_INTERVAL", +"T_INTERFACE_INTERVAL","T_STATS_INTERVAL","T_MAX_LOG_SIZE_IXFR","T_HEARTBEAT", +"T_USE_ID_POOL","T_MAX_NCACHE_TTL","T_HAS_OLD_CLIENTS","T_RFC2308_TYPE1", +"T_LAME_TTL","T_MIN_ROOTS","T_TREAT_CR_AS_SPACE","T_LOGGING","T_CATEGORY", +"T_CHANNEL","T_SEVERITY","T_DYNAMIC","T_FILE","T_VERSIONS","T_SIZE","T_SYSLOG", +"T_DEBUG","T_NULL_OUTPUT","T_PRINT_TIME","T_PRINT_CATEGORY","T_PRINT_SEVERITY", "T_SORTLIST","T_TOPOLOGY","T_SERVER","T_LONG_AXFR","T_BOGUS","T_TRANSFERS", "T_KEYS","T_SUPPORT_IXFR","T_ZONE","T_IN","T_CHAOS","T_HESIOD","T_TYPE", "T_MASTER","T_SLAVE","T_STUB","T_RESPONSE","T_HINT","T_MASTERS", @@ -709,7 +748,7 @@ char *yyname[] = { "T_FORWARDERS","T_ONLY","T_FIRST","T_IF_NO_ANSWER","T_IF_NO_DOMAIN","T_YES", "T_TRUE","T_NO","T_FALSE", }; -char *yyrule[] = { +const char * const yyrule[] = { "$accept : config_file", "config_file : statement_list", "statement_list : statement", @@ -732,6 +771,7 @@ char *yyrule[] = { "options : option L_EOS", "options : options option L_EOS", "option :", +"option : T_HOSTNAME L_QSTRING", "option : T_VERSION L_QSTRING", "option : T_DIRECTORY L_QSTRING", "option : T_NAMED_XFER L_QSTRING", @@ -739,10 +779,14 @@ char *yyrule[] = { "option : T_STATS_FILE L_QSTRING", "option : T_MEMSTATS_FILE L_QSTRING", "option : T_DUMP_FILE L_QSTRING", +"option : T_PREFERRED_GLUE L_STRING", "option : T_FAKE_IQUERY yea_or_nay", "option : T_RECURSION yea_or_nay", "option : T_FETCH_GLUE yea_or_nay", +"option : T_HITCOUNT yea_or_nay", +"option : T_NOTIFY T_EXPLICIT", "option : T_NOTIFY yea_or_nay", +"option : T_NOTIFY_INITIAL yea_or_nay", "option : T_HOSTSTATS yea_or_nay", "option : T_DEALLOC_ON_EXIT yea_or_nay", "option : T_USE_IXFR yea_or_nay", @@ -775,7 +819,8 @@ char *yyrule[] = { "option : T_CLEAN_INTERVAL L_NUMBER", "option : T_INTERFACE_INTERVAL L_NUMBER", "option : T_STATS_INTERVAL L_NUMBER", -"option : T_MAX_LOG_SIZE_IXFR L_NUMBER", +"option : T_HOSTSTATSMAX L_NUMBER", +"option : T_MAX_LOG_SIZE_IXFR size_spec", "option : T_MAX_NCACHE_TTL L_NUMBER", "option : T_LAME_TTL L_NUMBER", "option : T_HEARTBEAT L_NUMBER", @@ -789,6 +834,8 @@ char *yyrule[] = { "controls : controls control L_EOS", "control :", "control : T_INET maybe_wild_addr T_PORT in_port T_ALLOW '{' address_match_list '}'", +"control : T_INET maybe_wild_addr T_ALLOW '{' address_match_list '}' T_KEYS '{' dummy_key_list '}'", +"control : T_INET maybe_wild_addr T_PORT in_port T_ALLOW '{' address_match_list '}' T_KEYS '{' dummy_key_list '}'", "control : T_UNIX L_QSTRING T_PERM L_NUMBER T_OWNER L_NUMBER T_GROUP L_NUMBER", "control : error", "rrset_ordering_list : rrset_ordering_element L_EOS", @@ -925,6 +972,10 @@ char *yyrule[] = { "key_list : key_list_element L_EOS", "key_list : key_list key_list_element L_EOS", "key_list : error", +"dummy_key_list_element : key_ref", +"dummy_key_list : dummy_key_list_element L_EOS", +"dummy_key_list : dummy_key_list dummy_key_list_element L_EOS", +"dummy_key_list : error", "$$8 :", "key_stmt : T_SEC_KEY $$8 any_string '{' key_definition '}'", "key_definition : algorithm_id secret", @@ -960,7 +1011,8 @@ char *yyrule[] = { "$$10 :", "zone_option : T_FORWARDERS $$10 '{' opt_zone_forwarders_list '}'", "zone_option : T_MAX_TRANSFER_TIME_IN L_NUMBER", -"zone_option : T_MAX_LOG_SIZE_IXFR L_NUMBER", +"zone_option : T_MAX_LOG_SIZE_IXFR size_spec", +"zone_option : T_NOTIFY T_EXPLICIT", "zone_option : T_NOTIFY yea_or_nay", "zone_option : T_MAINTAIN_IXFR_BASE yea_or_nay", "zone_option : T_PUBKEY L_NUMBER L_NUMBER L_NUMBER L_QSTRING", @@ -971,6 +1023,7 @@ char *yyrule[] = { "master_in_addr_list : master_in_addr L_EOS", "master_in_addr_list : master_in_addr_list master_in_addr L_EOS", "master_in_addr : L_IPADDR", +"master_in_addr : L_IPADDR T_SEC_KEY key_ref", "opt_notify_in_addr_list :", "opt_notify_in_addr_list : notify_in_addr_list", "notify_in_addr_list : notify_in_addr L_EOS", @@ -1007,18 +1060,17 @@ char *yyrule[] = { #define YYINITSTACKSIZE 200 int yydebug; int yynerrs; -struct yystack { - short *ssp; - YYSTYPE *vsp; - short *ss; - YYSTYPE *vs; - int stacksize; - short *sslim; -}; -int yychar; /* some people use this, so we copy it in & out */ -int yyerrflag; /* must be global for yyerrok & YYRECOVERING */ +int yyerrflag; +int yychar; +short *yyssp; +YYSTYPE *yyvsp; +YYSTYPE yyval; YYSTYPE yylval; -#line 1776 "ns_parser.y" +short *yyss; +short *yysslim; +YYSTYPE *yyvs; +int yystacksize; +#line 1857 "ns_parser.y" static char * canonical_name(char *name) { @@ -1046,26 +1098,26 @@ init_acls() { ime = new_ip_match_pattern(address, 0); iml = new_ip_match_list(); add_to_ip_match_list(iml, ime); - define_acl(savestr("any", 1), iml); + define_acl("any", iml); /* ACL "none" */ ime = new_ip_match_pattern(address, 0); ip_match_negate(ime); iml = new_ip_match_list(); add_to_ip_match_list(iml, ime); - define_acl(savestr("none", 1), iml); + define_acl("none", iml); /* ACL "localhost" */ ime = new_ip_match_localhost(); iml = new_ip_match_list(); add_to_ip_match_list(iml, ime); - define_acl(savestr("localhost", 1), iml); + define_acl("localhost", iml); /* ACL "localnets" */ ime = new_ip_match_localnets(); iml = new_ip_match_list(); add_to_ip_match_list(iml, ime); - define_acl(savestr("localnets", 1), iml); + define_acl("localnets", iml); } static void @@ -1080,6 +1132,9 @@ free_sym_value(int type, void *value) { case SYM_KEY: free_key_info(value); break; + case SYM_CHANNEL: + INSIST(log_free_channel(value) == 0); + break; default: ns_panic(ns_log_parser, 1, "unhandled case in free_sym_value()"); @@ -1092,35 +1147,40 @@ static log_channel lookup_channel(char *name) { symbol_value value; - if (lookup_symbol(symtab, name, SYM_CHANNEL, &value)) + if (lookup_symbol(channeltab, name, SYM_CHANNEL, &value)) return ((log_channel)(value.pointer)); return (NULL); } static void -define_channel(char *name, log_channel channel) { +define_channel(const char *name, log_channel channel) { symbol_value value; value.pointer = channel; - define_symbol(symtab, name, SYM_CHANNEL, value, SYMBOL_FREE_KEY); + INSIST(log_inc_references(channel) == 0); + define_symbol(channeltab, name, SYM_CHANNEL, value, SYMBOL_FREE_VALUE); } static void define_builtin_channels() { - define_channel(savestr("default_syslog", 1), syslog_channel); - define_channel(savestr("default_debug", 1), debug_channel); - define_channel(savestr("default_stderr", 1), stderr_channel); - define_channel(savestr("null", 1), null_channel); + define_channel("default_syslog", syslog_channel); + define_channel("default_debug", debug_channel); + define_channel("default_stderr", stderr_channel); + define_channel("null", null_channel); } static void parser_setup() { seen_options = 0; + logged_options_error = 0; seen_topology = 0; symtab = new_symbol_table(SYMBOL_TABLE_SIZE, NULL); if (authtab != NULL) free_symbol_table(authtab); authtab = new_symbol_table(AUTH_TABLE_SIZE, free_sym_value); + if (channeltab != NULL) + free_symbol_table(channeltab); + channeltab = new_symbol_table(AUTH_TABLE_SIZE, free_sym_value); init_acls(); define_builtin_channels(); INIT_LIST(current_controls); @@ -1142,7 +1202,7 @@ parser_cleanup() { */ ip_match_list -lookup_acl(char *name) { +lookup_acl(const char *name) { symbol_value value; if (lookup_symbol(authtab, name, SYM_ACL, &value)) @@ -1151,15 +1211,14 @@ lookup_acl(char *name) { } void -define_acl(char *name, ip_match_list iml) { +define_acl(const char *name, ip_match_list iml) { symbol_value value; INSIST(name != NULL); INSIST(iml != NULL); value.pointer = iml; - define_symbol(authtab, name, SYM_ACL, value, - SYMBOL_FREE_KEY|SYMBOL_FREE_VALUE); + define_symbol(authtab, name, SYM_ACL, value, SYMBOL_FREE_VALUE); ns_debug(ns_log_parser, 7, "acl %s", name); dprint_ip_match_list(ns_log_parser, iml, 2, "allow ", "deny "); } @@ -1174,7 +1233,7 @@ lookup_key(char *name) { } void -define_key(char *name, struct dst_key *dst_key) { +define_key(const char *name, struct dst_key *dst_key) { symbol_value value; INSIST(name != NULL); @@ -1185,13 +1244,16 @@ define_key(char *name, struct dst_key *dst_key) { dprint_key_info(dst_key); } -void +time_t parse_configuration(const char *filename) { FILE *config_stream; + struct stat sb; config_stream = fopen(filename, "r"); if (config_stream == NULL) ns_panic(ns_log_parser, 0, "can't open '%s'", filename); + if (fstat(fileno(config_stream), &sb) == -1) + ns_panic(ns_log_parser, 0, "can't stat '%s'", filename); lexer_setup(); parser_setup(); @@ -1199,6 +1261,7 @@ parse_configuration(const char *filename) { (void)yyparse(); lexer_end_file(); parser_cleanup(); + return (sb.st_mtime); } void @@ -1210,78 +1273,51 @@ void parser_shutdown(void) { if (authtab != NULL) free_symbol_table(authtab); + if (channeltab != NULL) + free_symbol_table(channeltab); lexer_shutdown(); } -#line 1216 "y.tab.c" -/* allocate initial stack */ -#if defined(__STDC__) || defined(__cplusplus) -static int yyinitstack(struct yystack *sp) -#else -static int yyinitstack(sp) - struct yystack *sp; -#endif -{ - int newsize; - short *newss; - YYSTYPE *newvs; - - newsize = YYINITSTACKSIZE; - newss = (short *)malloc(newsize * sizeof *newss); - newvs = (YYSTYPE *)malloc(newsize * sizeof *newvs); - sp->ss = sp->ssp = newss; - sp->vs = sp->vsp = newvs; - if (newss == NULL || newvs == NULL) return -1; - sp->stacksize = newsize; - sp->sslim = newss + newsize - 1; - return 0; -} - -/* double stack size, up to YYMAXDEPTH */ -#if defined(__STDC__) || defined(__cplusplus) -static int yygrowstack(struct yystack *sp) -#else -static int yygrowstack(sp) - struct yystack *sp; -#endif +#line 1279 "y.tab.c" +/* allocate initial stack or double stack size, up to YYMAXDEPTH */ +static int yygrowstack() { int newsize, i; short *newss; YYSTYPE *newvs; - if ((newsize = sp->stacksize) >= YYMAXDEPTH) return -1; - if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH; - i = sp->ssp - sp->ss; - if ((newss = (short *)realloc(sp->ss, newsize * sizeof *newss)) == NULL) + if ((newsize = yystacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) return -1; - sp->ss = newss; - sp->ssp = newss + i; - if ((newvs = (YYSTYPE *)realloc(sp->vs, newsize * sizeof *newvs)) == NULL) + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + i = yyssp - yyss; + if ((newss = (short *)realloc(yyss, newsize * sizeof *newss)) == NULL) return -1; - sp->vs = newvs; - sp->vsp = newvs + i; - sp->stacksize = newsize; - sp->sslim = newss + newsize - 1; + yyss = newss; + yyssp = newss + i; + if ((newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs)) == NULL) + return -1; + yyvs = newvs; + yyvsp = newvs + i; + yystacksize = newsize; + yysslim = yyss + newsize - 1; return 0; } -#define YYFREESTACK(sp) { free((sp)->ss); free((sp)->vs); } - #define YYABORT goto yyabort #define YYREJECT goto yyabort #define YYACCEPT goto yyaccept #define YYERROR goto yyerrlab + int yyparse() { - register int yym, yyn, yystate, yych; - register YYSTYPE *yyvsp; - YYSTYPE yyval; - struct yystack yystk; + register int yym, yyn, yystate; #if YYDEBUG - register char *yys; - extern char *getenv(); + register const char *yys; - if (yys = getenv("YYDEBUG")) + if ((yys = getenv("YYDEBUG"))) { yyn = *yys; if (yyn >= '0' && yyn <= '9') @@ -1291,57 +1327,60 @@ yyparse() yynerrs = 0; yyerrflag = 0; - yychar = yych = YYEMPTY; + yychar = (-1); - if (yyinitstack(&yystk)) goto yyoverflow; - *yystk.ssp = yystate = 0; + if (yyss == NULL && yygrowstack()) goto yyoverflow; + yyssp = yyss; + yyvsp = yyvs; + *yyssp = yystate = 0; yyloop: - if (yyn = yydefred[yystate]) goto yyreduce; - if (yych < 0) + if ((yyn = yydefred[yystate])) goto yyreduce; + if (yychar < 0) { - if ((yych = YYLEX) < 0) yych = 0; - yychar = yych; + if ((yychar = yylex()) < 0) yychar = 0; #if YYDEBUG if (yydebug) { yys = 0; - if (yych <= YYMAXTOKEN) yys = yyname[yych]; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, yystate, yych, yys); + YYPREFIX, yystate, yychar, yys); } #endif } - if ((yyn = yysindex[yystate]) && (yyn += yych) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yych) + if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, shifting to state %d\n", YYPREFIX, yystate, yytable[yyn]); #endif - if (yystk.ssp >= yystk.sslim && yygrowstack(&yystk)) + if (yyssp >= yysslim && yygrowstack()) + { goto yyoverflow; - *++yystk.ssp = yystate = yytable[yyn]; - *++yystk.vsp = yylval; - yychar = yych = YYEMPTY; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + yychar = (-1); if (yyerrflag > 0) --yyerrflag; goto yyloop; } - if ((yyn = yyrindex[yystate]) && (yyn += yych) >= 0 && - yyn <= YYTABLESIZE && yycheck[yyn] == yych) + if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) { yyn = yytable[yyn]; goto yyreduce; } if (yyerrflag) goto yyinrecovery; -#ifdef lint +#if defined(lint) || defined(__GNUC__) goto yynewerror; #endif yynewerror: yyerror("syntax error"); -#ifdef lint +#if defined(lint) || defined(__GNUC__) goto yyerrlab; #endif yyerrlab: @@ -1352,19 +1391,20 @@ yyinrecovery: yyerrflag = 3; for (;;) { - if ((yyn = yysindex[*yystk.ssp]) && - (yyn += YYERRCODE) >= 0 && + if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) { #if YYDEBUG if (yydebug) printf("%sdebug: state %d, error recovery shifting\ - to state %d\n", YYPREFIX, *yystk.ssp, yytable[yyn]); + to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); #endif - if (yystk.ssp >= yystk.sslim && yygrowstack(&yystk)) + if (yyssp >= yysslim && yygrowstack()) + { goto yyoverflow; - *++yystk.ssp = yystate = yytable[yyn]; - *++yystk.vsp = yylval; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; goto yyloop; } else @@ -1372,28 +1412,28 @@ yyinrecovery: #if YYDEBUG if (yydebug) printf("%sdebug: error recovery discarding state %d\n", - YYPREFIX, *yystk.ssp); + YYPREFIX, *yyssp); #endif - if (yystk.ssp <= yystk.ss) goto yyabort; - --yystk.ssp; - --yystk.vsp; + if (yyssp <= yyss) goto yyabort; + --yyssp; + --yyvsp; } } } else { - if (yych == 0) goto yyabort; + if (yychar == 0) goto yyabort; #if YYDEBUG if (yydebug) { yys = 0; - if (yych <= YYMAXTOKEN) yys = yyname[yych]; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("%sdebug: state %d, error recovery discards token %d (%s)\n", - YYPREFIX, yystate, yych, yys); + YYPREFIX, yystate, yychar, yys); } #endif - yychar = yych = YYEMPTY; + yychar = (-1); goto yyloop; } yyreduce: @@ -1403,12 +1443,11 @@ yyreduce: YYPREFIX, yystate, yyn, yyrule[yyn]); #endif yym = yylen[yyn]; - yyvsp = yystk.vsp; /* for speed in code under switch() */ yyval = yyvsp[1-yym]; switch (yyn) { case 1: -#line 241 "ns_parser.y" +#line 246 "ns_parser.y" { if (EMPTY(current_controls)) ns_ctl_defaults(¤t_controls); @@ -1416,11 +1455,14 @@ case 1: } break; case 16: -#line 266 "ns_parser.y" -{ lexer_begin_file(yyvsp[-1].cp, NULL); } +#line 272 "ns_parser.y" +{ + lexer_begin_file(yyvsp[-1].cp, NULL); + (void)freestr(yyvsp[-1].cp); + } break; case 17: -#line 274 "ns_parser.y" +#line 283 "ns_parser.y" { if (seen_options) parser_error(0, "cannot redefine options"); @@ -1428,7 +1470,7 @@ case 17: } break; case 18: -#line 280 "ns_parser.y" +#line 289 "ns_parser.y" { if (!seen_options) set_options(current_options, 0); @@ -1439,163 +1481,201 @@ case 18: } break; case 22: -#line 296 "ns_parser.y" +#line 305 "ns_parser.y" +{ + if (current_options->hostname != NULL) + (void)freestr(current_options->hostname); + current_options->hostname = yyvsp[0].cp; + } +break; +case 23: +#line 311 "ns_parser.y" { if (current_options->version != NULL) - freestr(current_options->version); + (void)freestr(current_options->version); current_options->version = yyvsp[0].cp; } break; -case 23: -#line 302 "ns_parser.y" +case 24: +#line 317 "ns_parser.y" { if (current_options->directory != NULL) - freestr(current_options->directory); + (void)freestr(current_options->directory); current_options->directory = yyvsp[0].cp; } break; -case 24: -#line 308 "ns_parser.y" +case 25: +#line 323 "ns_parser.y" { if (current_options->named_xfer != NULL) - freestr(current_options->named_xfer); + (void)freestr(current_options->named_xfer); current_options->named_xfer = yyvsp[0].cp; } break; -case 25: -#line 314 "ns_parser.y" +case 26: +#line 329 "ns_parser.y" { if (current_options->pid_filename != NULL) - freestr(current_options->pid_filename); + (void)freestr(current_options->pid_filename); current_options->pid_filename = yyvsp[0].cp; } break; -case 26: -#line 320 "ns_parser.y" +case 27: +#line 335 "ns_parser.y" { if (current_options->stats_filename != NULL) - freestr(current_options->stats_filename); + (void)freestr(current_options->stats_filename); current_options->stats_filename = yyvsp[0].cp; } break; -case 27: -#line 326 "ns_parser.y" +case 28: +#line 341 "ns_parser.y" { if (current_options->memstats_filename != NULL) - freestr(current_options->memstats_filename); + (void)freestr(current_options->memstats_filename); current_options->memstats_filename = yyvsp[0].cp; } break; -case 28: -#line 332 "ns_parser.y" +case 29: +#line 347 "ns_parser.y" { if (current_options->dump_filename != NULL) - freestr(current_options->dump_filename); + (void)freestr(current_options->dump_filename); current_options->dump_filename = yyvsp[0].cp; } break; -case 29: -#line 338 "ns_parser.y" +case 30: +#line 353 "ns_parser.y" +{ + current_options->preferred_glue = + strcasecmp(yyvsp[0].cp, "aaaa") ? T_A : T_AAAA; + } +break; +case 31: +#line 358 "ns_parser.y" { set_global_boolean_option(current_options, OPTION_FAKE_IQUERY, yyvsp[0].num); } break; -case 30: -#line 343 "ns_parser.y" +case 32: +#line 363 "ns_parser.y" { set_global_boolean_option(current_options, OPTION_NORECURSE, !yyvsp[0].num); } break; -case 31: -#line 348 "ns_parser.y" +case 33: +#line 368 "ns_parser.y" { set_global_boolean_option(current_options, OPTION_NOFETCHGLUE, !yyvsp[0].num); } break; -case 32: -#line 353 "ns_parser.y" +case 34: +#line 373 "ns_parser.y" { set_global_boolean_option(current_options, - OPTION_NONOTIFY, !yyvsp[0].num); + OPTION_HITCOUNT, yyvsp[0].num); } break; -case 33: -#line 358 "ns_parser.y" +case 35: +#line 378 "ns_parser.y" +{ + current_options->notify = notify_explicit; + } +break; +case 36: +#line 382 "ns_parser.y" +{ + if (yyvsp[0].num) + current_options->notify = notify_yes; + else + current_options->notify = notify_no; + } +break; +case 37: +#line 389 "ns_parser.y" +{ + if (initial_configuration && yyvsp[0].num) + ns_notice(ns_log_default, + "suppressing initial notifies"); + set_global_boolean_option(current_options, + OPTION_SUPNOTIFY_INITIAL, yyvsp[0].num); + } +break; +case 38: +#line 397 "ns_parser.y" { set_global_boolean_option(current_options, OPTION_HOSTSTATS, yyvsp[0].num); } break; -case 34: -#line 363 "ns_parser.y" +case 39: +#line 402 "ns_parser.y" { set_global_boolean_option(current_options, OPTION_DEALLOC_ON_EXIT, yyvsp[0].num); } break; -case 35: -#line 368 "ns_parser.y" +case 40: +#line 407 "ns_parser.y" { set_global_boolean_option(current_options, OPTION_USE_IXFR, yyvsp[0].num); } break; -case 36: -#line 372 "ns_parser.y" +case 41: +#line 411 "ns_parser.y" { set_global_boolean_option(current_options, OPTION_MAINTAIN_IXFR_BASE, yyvsp[0].num); } break; -case 37: -#line 377 "ns_parser.y" +case 42: +#line 416 "ns_parser.y" { set_global_boolean_option(current_options, - OPTION_MAINTAIN_IXFR_BASE, yyvsp[0].num); - set_global_boolean_option(current_options, OPTION_NORFC2308_TYPE1, yyvsp[0].num); set_global_boolean_option(current_options, OPTION_NONAUTH_NXDOMAIN, !yyvsp[0].num); } break; -case 38: -#line 386 "ns_parser.y" +case 43: +#line 423 "ns_parser.y" { set_global_boolean_option(current_options, OPTION_NONAUTH_NXDOMAIN, !yyvsp[0].num); } break; -case 39: -#line 391 "ns_parser.y" +case 44: +#line 428 "ns_parser.y" { set_global_boolean_option(current_options, OPTION_MULTIPLE_CNAMES, yyvsp[0].num); } break; -case 40: -#line 396 "ns_parser.y" +case 45: +#line 433 "ns_parser.y" { current_options->check_names[yyvsp[-1].s_int] = (enum severity)yyvsp[0].s_int; } break; -case 41: -#line 400 "ns_parser.y" +case 46: +#line 437 "ns_parser.y" { set_global_boolean_option(current_options, OPTION_USE_ID_POOL, yyvsp[0].num); } break; -case 42: -#line 405 "ns_parser.y" +case 47: +#line 442 "ns_parser.y" { set_global_boolean_option(current_options, OPTION_NORFC2308_TYPE1, !yyvsp[0].num); } break; -case 43: -#line 410 "ns_parser.y" +case 48: +#line 447 "ns_parser.y" { char port_string[10]; symbol_value value; @@ -1608,14 +1688,13 @@ case 43: else { add_listen_on(current_options, yyvsp[-3].us_int, yyvsp[-1].iml); value.pointer = NULL; - define_symbol(symtab, savestr(port_string, 1), - SYM_PORT, value, SYMBOL_FREE_KEY); + define_symbol(symtab, port_string, SYM_PORT, value, 0); } } break; -case 45: -#line 429 "ns_parser.y" +case 50: +#line 465 "ns_parser.y" { if (current_options->fwdtab) { free_forwarders(current_options->fwdtab); @@ -1623,14 +1702,14 @@ case 45: } } break; -case 48: -#line 438 "ns_parser.y" +case 53: +#line 474 "ns_parser.y" { current_options->axfr_src = yyvsp[0].ip_addr; } break; -case 49: -#line 442 "ns_parser.y" +case 54: +#line 478 "ns_parser.y" { if (current_options->query_acl) { parser_warning(0, @@ -1640,8 +1719,8 @@ case 49: current_options->query_acl = yyvsp[-1].iml; } break; -case 50: -#line 451 "ns_parser.y" +case 55: +#line 487 "ns_parser.y" { if (current_options->recursion_acl) { parser_warning(0, @@ -1651,8 +1730,8 @@ case 50: current_options->recursion_acl = yyvsp[-1].iml; } break; -case 51: -#line 460 "ns_parser.y" +case 56: +#line 496 "ns_parser.y" { if (current_options->transfer_acl) { parser_warning(0, @@ -1662,8 +1741,8 @@ case 51: current_options->transfer_acl = yyvsp[-1].iml; } break; -case 52: -#line 469 "ns_parser.y" +case 57: +#line 505 "ns_parser.y" { if (current_options->sortlist) { parser_warning(0, @@ -1673,8 +1752,8 @@ case 52: current_options->sortlist = yyvsp[-1].iml; } break; -case 53: -#line 478 "ns_parser.y" +case 58: +#line 514 "ns_parser.y" { if (current_options->also_notify) { parser_warning(0, @@ -1684,8 +1763,8 @@ case 53: } } break; -case 55: -#line 488 "ns_parser.y" +case 60: +#line 524 "ns_parser.y" { if (current_options->blackhole_acl) { parser_warning(0, @@ -1695,8 +1774,8 @@ case 55: current_options->blackhole_acl = yyvsp[-1].iml; } break; -case 56: -#line 497 "ns_parser.y" +case 61: +#line 533 "ns_parser.y" { if (current_options->topology) { parser_warning(0, @@ -1706,115 +1785,138 @@ case 56: current_options->topology = yyvsp[-1].iml; } break; -case 57: -#line 506 "ns_parser.y" +case 62: +#line 542 "ns_parser.y" { /* To get around the $$ = $1 default rule. */ } break; -case 59: -#line 511 "ns_parser.y" +case 64: +#line 547 "ns_parser.y" { current_options->transfer_format = yyvsp[0].axfr_fmt; } break; -case 60: -#line 515 "ns_parser.y" +case 65: +#line 551 "ns_parser.y" { current_options->max_transfer_time_in = yyvsp[0].num * 60; } break; -case 61: -#line 519 "ns_parser.y" +case 66: +#line 555 "ns_parser.y" { current_options->serial_queries = yyvsp[0].num; } break; -case 62: -#line 523 "ns_parser.y" +case 67: +#line 559 "ns_parser.y" { current_options->clean_interval = yyvsp[0].num * 60; } break; -case 63: -#line 527 "ns_parser.y" +case 68: +#line 563 "ns_parser.y" { current_options->interface_interval = yyvsp[0].num * 60; } break; -case 64: -#line 531 "ns_parser.y" +case 69: +#line 567 "ns_parser.y" { current_options->stats_interval = yyvsp[0].num * 60; } break; -case 65: -#line 535 "ns_parser.y" +case 70: +#line 571 "ns_parser.y" { - current_options->max_log_size_ixfr = yyvsp[0].num; + current_options->max_host_stats = yyvsp[0].num; } break; -case 66: -#line 539 "ns_parser.y" +case 71: +#line 575 "ns_parser.y" +{ + current_options->max_log_size_ixfr = yyvsp[0].ul_int; + } +break; +case 72: +#line 579 "ns_parser.y" { current_options->max_ncache_ttl = yyvsp[0].num; } break; -case 67: -#line 543 "ns_parser.y" +case 73: +#line 583 "ns_parser.y" { current_options->lame_ttl = yyvsp[0].num; } break; -case 68: -#line 547 "ns_parser.y" +case 74: +#line 587 "ns_parser.y" { current_options->heartbeat_interval = yyvsp[0].num * 60; } break; -case 69: -#line 551 "ns_parser.y" +case 75: +#line 591 "ns_parser.y" { set_global_boolean_option(current_options, OPTION_NODIALUP, !yyvsp[0].num); } break; -case 70: -#line 556 "ns_parser.y" +case 76: +#line 596 "ns_parser.y" { if (current_options->ordering) free_rrset_order_list(current_options->ordering); current_options->ordering = yyvsp[-1].rol; } break; -case 71: -#line 562 "ns_parser.y" +case 77: +#line 602 "ns_parser.y" { set_global_boolean_option(current_options, OPTION_TREAT_CR_AS_SPACE, yyvsp[0].num); } break; -case 72: -#line 567 "ns_parser.y" +case 78: +#line 607 "ns_parser.y" { if (yyvsp[0].num >= 1) current_options->minroots = yyvsp[0].num; } break; -case 78: -#line 587 "ns_parser.y" +case 84: +#line 627 "ns_parser.y" { ns_ctl_add(¤t_controls, ns_ctl_new_inet(yyvsp[-6].ip_addr, yyvsp[-4].us_int, yyvsp[-1].iml)); } break; -case 79: -#line 591 "ns_parser.y" +case 85: +#line 633 "ns_parser.y" { + parser_warning(0, "Ignoring BIND 9 inet control clause"); + free_ip_match_list(yyvsp[-5].iml); + } +break; +case 86: +#line 640 "ns_parser.y" +{ + parser_warning(0, "Ignoring BIND 9 inet control clause"); + free_ip_match_list(yyvsp[-5].iml); + } +break; +case 87: +#line 645 "ns_parser.y" +{ +#ifndef NO_SOCKADDR_UN ns_ctl_add(¤t_controls, ns_ctl_new_unix(yyvsp[-6].cp, yyvsp[-4].num, yyvsp[-2].num, yyvsp[0].num)); +#endif + freestr(yyvsp[-6].cp); } break; -case 81: -#line 598 "ns_parser.y" +case 89: +#line 655 "ns_parser.y" { rrset_order_list rol; @@ -1826,8 +1928,8 @@ case 81: yyval.rol = rol; } break; -case 82: -#line 609 "ns_parser.y" +case 90: +#line 666 "ns_parser.y" { if (yyvsp[-1].roe != NULL) { add_to_rrset_order_list(yyvsp[-2].rol, yyvsp[-1].roe); @@ -1835,14 +1937,14 @@ case 82: yyval.rol = yyvsp[-2].rol; } break; -case 83: -#line 618 "ns_parser.y" +case 91: +#line 675 "ns_parser.y" { yyval.s_int = C_ANY; } break; -case 84: -#line 622 "ns_parser.y" +case 92: +#line 679 "ns_parser.y" { symbol_value value; @@ -1852,17 +1954,17 @@ case 84: parser_error(0, "unknown class '%s'; using ANY", yyvsp[0].cp); yyval.s_int = C_ANY; } - freestr(yyvsp[0].cp); + (void)freestr(yyvsp[0].cp); } break; -case 85: -#line 636 "ns_parser.y" +case 93: +#line 693 "ns_parser.y" { yyval.s_int = ns_t_any; } break; -case 86: -#line 640 "ns_parser.y" +case 94: +#line 697 "ns_parser.y" { int success; @@ -1877,29 +1979,29 @@ case 86: yyvsp[0].cp); } } - freestr(yyvsp[0].cp); + (void)freestr(yyvsp[0].cp); } break; -case 87: -#line 658 "ns_parser.y" +case 95: +#line 715 "ns_parser.y" { yyval.cp = savestr("*", 1); } break; -case 88: -#line 662 "ns_parser.y" +case 96: +#line 719 "ns_parser.y" { if (strcmp(".",yyvsp[0].cp) == 0 || strcmp("*.",yyvsp[0].cp) == 0) { yyval.cp = savestr("*", 1); - freestr(yyvsp[0].cp); + (void)freestr(yyvsp[0].cp); } else { yyval.cp = yyvsp[0].cp ; } /* XXX Should do any more name validation here? */ } break; -case 89: -#line 674 "ns_parser.y" +case 97: +#line 731 "ns_parser.y" { enum ordering o; @@ -1915,94 +2017,94 @@ case 89: yyvsp[0].cp, p_order(o)); } - freestr(yyvsp[0].cp); + (void)freestr(yyvsp[0].cp); yyval.roe = new_rrset_order_element(yyvsp[-4].s_int, yyvsp[-3].s_int, yyvsp[-2].cp, o); } } break; -case 90: -#line 697 "ns_parser.y" +case 98: +#line 754 "ns_parser.y" { yyval.axfr_fmt = axfr_one_answer; } break; -case 91: -#line 701 "ns_parser.y" +case 99: +#line 758 "ns_parser.y" { yyval.axfr_fmt = axfr_many_answers; } break; -case 92: -#line 706 "ns_parser.y" +case 100: +#line 763 "ns_parser.y" { yyval.ip_addr = yyvsp[0].ip_addr; } break; -case 93: -#line 707 "ns_parser.y" +case 101: +#line 764 "ns_parser.y" { yyval.ip_addr.s_addr = htonl(INADDR_ANY); } break; -case 94: -#line 710 "ns_parser.y" +case 102: +#line 767 "ns_parser.y" { yyval.us_int = yyvsp[0].us_int; } break; -case 95: -#line 711 "ns_parser.y" +case 103: +#line 768 "ns_parser.y" { yyval.us_int = htons(0); } break; -case 96: -#line 715 "ns_parser.y" +case 104: +#line 772 "ns_parser.y" { current_options->query_source.sin_addr = yyvsp[0].ip_addr; } break; -case 97: -#line 721 "ns_parser.y" +case 105: +#line 778 "ns_parser.y" { current_options->query_source.sin_port = yyvsp[0].us_int; } break; -case 102: -#line 732 "ns_parser.y" +case 110: +#line 789 "ns_parser.y" { yyval.us_int = htons(NS_DEFAULTPORT); } break; -case 103: -#line 733 "ns_parser.y" +case 111: +#line 790 "ns_parser.y" { yyval.us_int = yyvsp[0].us_int; } break; -case 104: -#line 736 "ns_parser.y" +case 112: +#line 793 "ns_parser.y" { yyval.us_int = htons(0); } break; -case 105: -#line 737 "ns_parser.y" +case 113: +#line 794 "ns_parser.y" { yyval.us_int = yyvsp[0].us_int; } break; -case 106: -#line 742 "ns_parser.y" +case 114: +#line 799 "ns_parser.y" { yyval.num = 1; } break; -case 107: -#line 746 "ns_parser.y" +case 115: +#line 803 "ns_parser.y" { yyval.num = 1; } break; -case 108: -#line 750 "ns_parser.y" +case 116: +#line 807 "ns_parser.y" { yyval.num = 0; } break; -case 109: -#line 754 "ns_parser.y" +case 117: +#line 811 "ns_parser.y" { yyval.num = 0; } break; -case 110: -#line 758 "ns_parser.y" +case 118: +#line 815 "ns_parser.y" { if (yyvsp[0].num == 1 || yyvsp[0].num == 0) { yyval.num = yyvsp[0].num; @@ -2013,94 +2115,94 @@ case 110: } } break; -case 111: -#line 770 "ns_parser.y" +case 119: +#line 827 "ns_parser.y" { yyval.s_int = primary_trans; } break; -case 112: -#line 774 "ns_parser.y" +case 120: +#line 831 "ns_parser.y" { yyval.s_int = secondary_trans; } break; -case 113: -#line 778 "ns_parser.y" +case 121: +#line 835 "ns_parser.y" { yyval.s_int = response_trans; } break; -case 114: -#line 784 "ns_parser.y" +case 122: +#line 841 "ns_parser.y" { yyval.s_int = warn; } break; -case 115: -#line 788 "ns_parser.y" +case 123: +#line 845 "ns_parser.y" { yyval.s_int = fail; } break; -case 116: -#line 792 "ns_parser.y" +case 124: +#line 849 "ns_parser.y" { yyval.s_int = ignore; } break; -case 117: -#line 798 "ns_parser.y" +case 125: +#line 855 "ns_parser.y" { set_global_boolean_option(current_options, OPTION_FORWARD_ONLY, 1); } break; -case 118: -#line 803 "ns_parser.y" +case 126: +#line 860 "ns_parser.y" { set_global_boolean_option(current_options, OPTION_FORWARD_ONLY, 0); } break; -case 119: -#line 808 "ns_parser.y" +case 127: +#line 865 "ns_parser.y" { parser_warning(0, "forward if-no-answer is unimplemented"); } break; -case 120: -#line 812 "ns_parser.y" +case 128: +#line 869 "ns_parser.y" { parser_warning(0, "forward if-no-domain is unimplemented"); } break; -case 121: -#line 818 "ns_parser.y" +case 129: +#line 875 "ns_parser.y" { current_options->data_size = yyvsp[0].ul_int; } break; -case 122: -#line 822 "ns_parser.y" +case 130: +#line 879 "ns_parser.y" { current_options->stack_size = yyvsp[0].ul_int; } break; -case 123: -#line 826 "ns_parser.y" +case 131: +#line 883 "ns_parser.y" { current_options->core_size = yyvsp[0].ul_int; } break; -case 124: -#line 830 "ns_parser.y" +case 132: +#line 887 "ns_parser.y" { current_options->files = yyvsp[0].ul_int; } break; -case 125: -#line 836 "ns_parser.y" +case 133: +#line 893 "ns_parser.y" { u_long result; @@ -2111,116 +2213,115 @@ case 125: /* 0 means "use default" */ yyval.ul_int = 0; } - freestr(yyvsp[0].cp); + (void)freestr(yyvsp[0].cp); } break; -case 126: -#line 849 "ns_parser.y" +case 134: +#line 906 "ns_parser.y" { yyval.ul_int = (u_long)yyvsp[0].num; } break; -case 127: -#line 853 "ns_parser.y" +case 135: +#line 910 "ns_parser.y" { yyval.ul_int = 0; } break; -case 128: -#line 857 "ns_parser.y" +case 136: +#line 914 "ns_parser.y" { yyval.ul_int = ULONG_MAX; } break; -case 129: -#line 863 "ns_parser.y" +case 137: +#line 920 "ns_parser.y" { current_options->transfers_in = (u_long) yyvsp[0].num; } break; -case 130: -#line 867 "ns_parser.y" +case 138: +#line 924 "ns_parser.y" { current_options->transfers_out = (u_long) yyvsp[0].num; } break; -case 131: -#line 871 "ns_parser.y" +case 139: +#line 928 "ns_parser.y" { current_options->transfers_per_ns = (u_long) yyvsp[0].num; } break; -case 134: -#line 881 "ns_parser.y" +case 142: +#line 938 "ns_parser.y" { /* nothing */ } break; -case 135: -#line 885 "ns_parser.y" +case 143: +#line 942 "ns_parser.y" { /* nothing */ } break; -case 136: -#line 891 "ns_parser.y" +case 144: +#line 948 "ns_parser.y" { add_global_forwarder(current_options, yyvsp[0].ip_addr); } break; -case 139: -#line 901 "ns_parser.y" +case 147: +#line 958 "ns_parser.y" { /* nothing */ } break; -case 140: -#line 905 "ns_parser.y" +case 148: +#line 962 "ns_parser.y" { /* nothing */ } break; -case 141: -#line 911 "ns_parser.y" +case 149: +#line 968 "ns_parser.y" { add_global_also_notify(current_options, yyvsp[0].ip_addr); } break; -case 142: -#line 921 "ns_parser.y" +case 150: +#line 978 "ns_parser.y" { current_logging = begin_logging(); } break; -case 143: -#line 925 "ns_parser.y" +case 151: +#line 982 "ns_parser.y" { end_logging(current_logging, 1); current_logging = NULL; } break; -case 147: -#line 937 "ns_parser.y" +case 155: +#line 994 "ns_parser.y" { current_category = yyvsp[0].s_int; } break; -case 149: -#line 942 "ns_parser.y" +case 157: +#line 999 "ns_parser.y" { chan_type = log_null; chan_flags = 0; chan_level = log_info; } break; -case 150: -#line 948 "ns_parser.y" +case 158: +#line 1005 "ns_parser.y" { log_channel current_channel = NULL; if (lookup_channel(yyvsp[-4].cp) != NULL) { parser_error(0, "can't redefine channel '%s'", yyvsp[-4].cp); - freestr(yyvsp[-4].cp); } else { switch (chan_type) { case log_file: @@ -2230,8 +2331,9 @@ case 150: chan_name, NULL, chan_versions, chan_max_size); - freestr(chan_name); - chan_name = NULL; + log_set_file_owner(current_channel, + user_id, group_id); + chan_name = freestr(chan_name); break; case log_syslog: current_channel = @@ -2252,10 +2354,11 @@ case 150: "couldn't create channel"); define_channel(yyvsp[-4].cp, current_channel); } + (void)freestr(yyvsp[-4].cp); } break; -case 151: -#line 989 "ns_parser.y" +case 159: +#line 1047 "ns_parser.y" { symbol_value value; @@ -2265,87 +2368,87 @@ case 151: parser_error(0, "unknown severity '%s'", yyvsp[0].cp); chan_level = log_debug(99); } - freestr(yyvsp[0].cp); + (void)freestr(yyvsp[0].cp); } break; -case 152: -#line 1001 "ns_parser.y" +case 160: +#line 1059 "ns_parser.y" { chan_level = log_debug(1); } break; -case 153: -#line 1005 "ns_parser.y" +case 161: +#line 1063 "ns_parser.y" { chan_level = yyvsp[0].num; } break; -case 154: -#line 1009 "ns_parser.y" +case 162: +#line 1067 "ns_parser.y" { chan_level = 0; chan_flags |= LOG_USE_CONTEXT_LEVEL|LOG_REQUIRE_DEBUG; } break; -case 155: -#line 1016 "ns_parser.y" +case 163: +#line 1074 "ns_parser.y" { chan_versions = yyvsp[0].num; } break; -case 156: -#line 1020 "ns_parser.y" +case 164: +#line 1078 "ns_parser.y" { chan_versions = LOG_MAX_VERSIONS; } break; -case 157: -#line 1026 "ns_parser.y" +case 165: +#line 1084 "ns_parser.y" { chan_max_size = yyvsp[0].ul_int; } break; -case 158: -#line 1032 "ns_parser.y" +case 166: +#line 1090 "ns_parser.y" { chan_versions = 0; chan_max_size = ULONG_MAX; } break; -case 159: -#line 1037 "ns_parser.y" +case 167: +#line 1095 "ns_parser.y" { chan_max_size = ULONG_MAX; } break; -case 160: -#line 1041 "ns_parser.y" +case 168: +#line 1099 "ns_parser.y" { chan_versions = 0; } break; -case 163: -#line 1049 "ns_parser.y" +case 171: +#line 1107 "ns_parser.y" { chan_flags |= LOG_CLOSE_STREAM; chan_type = log_file; chan_name = yyvsp[-1].cp; } break; -case 164: -#line 1057 "ns_parser.y" +case 172: +#line 1115 "ns_parser.y" { yyval.cp = yyvsp[0].cp; } break; -case 165: -#line 1058 "ns_parser.y" +case 173: +#line 1116 "ns_parser.y" { yyval.cp = savestr("syslog", 1); } break; -case 166: -#line 1061 "ns_parser.y" +case 174: +#line 1119 "ns_parser.y" { yyval.s_int = LOG_DAEMON; } break; -case 167: -#line 1063 "ns_parser.y" +case 175: +#line 1121 "ns_parser.y" { symbol_value value; @@ -2355,36 +2458,36 @@ case 167: parser_error(0, "unknown facility '%s'", yyvsp[0].cp); yyval.s_int = LOG_DAEMON; } - freestr(yyvsp[0].cp); + (void)freestr(yyvsp[0].cp); } break; -case 168: -#line 1077 "ns_parser.y" +case 176: +#line 1135 "ns_parser.y" { chan_type = log_syslog; chan_facility = yyvsp[0].s_int; } break; -case 169: -#line 1083 "ns_parser.y" +case 177: +#line 1141 "ns_parser.y" { /* nothing to do */ } break; -case 170: -#line 1084 "ns_parser.y" +case 178: +#line 1142 "ns_parser.y" { /* nothing to do */ } break; -case 171: -#line 1086 "ns_parser.y" +case 179: +#line 1144 "ns_parser.y" { chan_type = log_null; } break; -case 172: -#line 1089 "ns_parser.y" +case 180: +#line 1147 "ns_parser.y" { /* nothing to do */ } break; -case 173: -#line 1091 "ns_parser.y" +case 181: +#line 1149 "ns_parser.y" { if (yyvsp[0].num) chan_flags |= LOG_TIMESTAMP; @@ -2392,8 +2495,8 @@ case 173: chan_flags &= ~LOG_TIMESTAMP; } break; -case 174: -#line 1098 "ns_parser.y" +case 182: +#line 1156 "ns_parser.y" { if (yyvsp[0].num) chan_flags |= LOG_PRINT_CATEGORY; @@ -2401,8 +2504,8 @@ case 174: chan_flags &= ~LOG_PRINT_CATEGORY; } break; -case 175: -#line 1105 "ns_parser.y" +case 183: +#line 1163 "ns_parser.y" { if (yyvsp[0].num) chan_flags |= LOG_PRINT_LEVEL; @@ -2410,15 +2513,14 @@ case 175: chan_flags &= ~LOG_PRINT_LEVEL; } break; -case 180: -#line 1119 "ns_parser.y" +case 188: +#line 1177 "ns_parser.y" { yyval.cp = savestr("null", 1); } break; -case 181: -#line 1123 "ns_parser.y" +case 189: +#line 1181 "ns_parser.y" { log_channel channel; - symbol_value value; if (current_category >= 0) { channel = lookup_channel(yyvsp[0].cp); @@ -2428,19 +2530,19 @@ case 181: } else parser_error(0, "unknown channel '%s'", yyvsp[0].cp); } - freestr(yyvsp[0].cp); + (void)freestr(yyvsp[0].cp); } break; -case 186: -#line 1145 "ns_parser.y" +case 194: +#line 1202 "ns_parser.y" { yyval.cp = savestr("default", 1); } break; -case 187: -#line 1146 "ns_parser.y" +case 195: +#line 1203 "ns_parser.y" { yyval.cp = savestr("notify", 1); } break; -case 188: -#line 1150 "ns_parser.y" +case 196: +#line 1207 "ns_parser.y" { symbol_value value; @@ -2451,11 +2553,11 @@ case 188: yyvsp[0].cp); yyval.s_int = -1; } - freestr(yyvsp[0].cp); + (void)freestr(yyvsp[0].cp); } break; -case 189: -#line 1169 "ns_parser.y" +case 197: +#line 1226 "ns_parser.y" { const char *ip_printable; symbol_value value; @@ -2470,44 +2572,43 @@ case 189: parser_error(0, "cannot redefine server '%s'", ip_printable); else - define_symbol(symtab, savestr(ip_printable, 1), - SYM_SERVER, value, - SYMBOL_FREE_KEY); + define_symbol(symtab, ip_printable, SYM_SERVER, value, + 0); current_server = begin_server(yyvsp[0].ip_addr); } break; -case 190: -#line 1189 "ns_parser.y" +case 198: +#line 1245 "ns_parser.y" { end_server(current_server, !seen_server); } break; -case 193: -#line 1199 "ns_parser.y" +case 201: +#line 1255 "ns_parser.y" { set_server_option(current_server, SERVER_INFO_BOGUS, yyvsp[0].num); } break; -case 194: -#line 1203 "ns_parser.y" +case 202: +#line 1259 "ns_parser.y" { set_server_option(current_server, SERVER_INFO_SUPPORT_IXFR, yyvsp[0].num); } break; -case 195: -#line 1207 "ns_parser.y" +case 203: +#line 1263 "ns_parser.y" { set_server_transfers(current_server, (int)yyvsp[0].num); } break; -case 196: -#line 1211 "ns_parser.y" +case 204: +#line 1267 "ns_parser.y" { set_server_transfer_format(current_server, yyvsp[0].axfr_fmt); } break; -case 199: -#line 1223 "ns_parser.y" +case 207: +#line 1279 "ns_parser.y" { ip_match_list iml; @@ -2517,24 +2618,24 @@ case 199: yyval.iml = iml; } break; -case 200: -#line 1232 "ns_parser.y" +case 208: +#line 1288 "ns_parser.y" { if (yyvsp[-1].ime != NULL) add_to_ip_match_list(yyvsp[-2].iml, yyvsp[-1].ime); yyval.iml = yyvsp[-2].iml; } break; -case 202: -#line 1241 "ns_parser.y" +case 210: +#line 1297 "ns_parser.y" { if (yyvsp[0].ime != NULL) ip_match_negate(yyvsp[0].ime); yyval.ime = yyvsp[0].ime; } break; -case 203: -#line 1247 "ns_parser.y" +case 211: +#line 1303 "ns_parser.y" { char *key_name; struct dst_key *dst_key; @@ -2552,16 +2653,18 @@ case 203: } else yyval.ime = new_ip_match_key(dst_key); + (void)freestr(key_name); + freestr(yyvsp[0].cp); } break; -case 204: -#line 1268 "ns_parser.y" +case 212: +#line 1326 "ns_parser.y" { yyval.ime = new_ip_match_pattern(yyvsp[0].ip_addr, 32); } break; -case 205: -#line 1272 "ns_parser.y" +case 213: +#line 1330 "ns_parser.y" { if (yyvsp[0].num < 0 || yyvsp[0].num > 32) { parser_error(0, "mask bits out of range; skipping"); @@ -2574,8 +2677,8 @@ case 205: } } break; -case 206: -#line 1284 "ns_parser.y" +case 214: +#line 1342 "ns_parser.y" { struct in_addr ia; @@ -2597,8 +2700,8 @@ case 206: } } break; -case 208: -#line 1306 "ns_parser.y" +case 216: +#line 1364 "ns_parser.y" { char name[256]; @@ -2607,12 +2710,12 @@ case 208: * we give it a name and treat it like any other acl. */ sprintf(name, "__internal_%p", yyvsp[-1].iml); - define_acl(savestr(name, 1), yyvsp[-1].iml); + define_acl(name, yyvsp[-1].iml); yyval.ime = new_ip_match_indirect(yyvsp[-1].iml); } break; -case 209: -#line 1320 "ns_parser.y" +case 217: +#line 1378 "ns_parser.y" { ip_match_list iml; @@ -2622,11 +2725,11 @@ case 209: yyval.ime = NULL; } else yyval.ime = new_ip_match_indirect(iml); - freestr(yyvsp[0].cp); + (void)freestr(yyvsp[0].cp); } break; -case 210: -#line 1338 "ns_parser.y" +case 218: +#line 1396 "ns_parser.y" { struct dst_key *dst_key; char *key_name; @@ -2643,13 +2746,13 @@ case 210: yyval.keyi = NULL; } else yyval.keyi = dst_key; - freestr(key_name); + key_name = freestr(key_name); } - freestr(yyvsp[0].cp); + (void)freestr(yyvsp[0].cp); } break; -case 211: -#line 1361 "ns_parser.y" +case 219: +#line 1419 "ns_parser.y" { if (yyvsp[0].keyi == NULL) parser_error(0, "empty key not added to server list "); @@ -2657,15 +2760,15 @@ case 211: add_server_key_info(current_server, yyvsp[0].keyi); } break; -case 215: -#line 1375 "ns_parser.y" +case 227: +#line 1440 "ns_parser.y" { current_algorithm = NULL; current_secret = NULL; } break; -case 216: -#line 1380 "ns_parser.y" +case 228: +#line 1445 "ns_parser.y" { struct dst_key *dst_key; char *key_name; @@ -2676,13 +2779,11 @@ case 216: yyvsp[-3].cp); } else if (lookup_key(key_name) != NULL) { parser_error(0, "can't redefine key '%s'", key_name); - freestr(key_name); } else { if (current_algorithm == NULL || current_secret == NULL) { parser_error(0, "skipping bad key '%s'", key_name); - freestr(key_name); } else { dst_key = new_key_info(key_name, current_algorithm, @@ -2697,58 +2798,66 @@ case 216: } } } - freestr(yyvsp[-3].cp); + if (key_name != NULL) + key_name = freestr(key_name); + if (current_algorithm != NULL) + current_algorithm = freestr(current_algorithm); + if (current_secret != NULL) + current_secret = freestr(current_secret); + (void)freestr(yyvsp[-3].cp); } break; -case 217: -#line 1416 "ns_parser.y" +case 229: +#line 1485 "ns_parser.y" { current_algorithm = yyvsp[-1].cp; current_secret = yyvsp[0].cp; } break; -case 218: -#line 1421 "ns_parser.y" +case 230: +#line 1490 "ns_parser.y" { current_algorithm = yyvsp[0].cp; current_secret = yyvsp[-1].cp; } break; -case 219: -#line 1426 "ns_parser.y" +case 231: +#line 1495 "ns_parser.y" { current_algorithm = NULL; current_secret = NULL; } break; -case 220: -#line 1432 "ns_parser.y" +case 232: +#line 1501 "ns_parser.y" { yyval.cp = yyvsp[-1].cp; } break; -case 221: -#line 1435 "ns_parser.y" +case 233: +#line 1504 "ns_parser.y" { yyval.cp = yyvsp[-1].cp; } break; -case 222: -#line 1443 "ns_parser.y" +case 234: +#line 1512 "ns_parser.y" { if (lookup_acl(yyvsp[-3].cp) != NULL) { parser_error(0, "can't redefine ACL '%s'", yyvsp[-3].cp); - freestr(yyvsp[-3].cp); } else define_acl(yyvsp[-3].cp, yyvsp[-1].iml); + (void)freestr(yyvsp[-3].cp); } break; -case 223: -#line 1457 "ns_parser.y" +case 235: +#line 1526 "ns_parser.y" { int sym_type; symbol_value value; char *zone_name; - if (!seen_options) + if (!seen_options && !logged_options_error) { parser_error(0, "no options statement before first zone; using previous/default"); + logged_options_error = 1; + } sym_type = SYM_ZONE | (yyvsp[0].num & 0xffff); value.pointer = NULL; zone_name = canonical_name(yyvsp[-1].cp); @@ -2766,29 +2875,28 @@ case 223: p_class(yyvsp[0].num)); } else { should_install = 1; - define_symbol(symtab, savestr(zone_name, 1), - sym_type, value, - SYMBOL_FREE_KEY); + define_symbol(symtab, zone_name, sym_type, + value, 0); } } - freestr(yyvsp[-1].cp); + (void)freestr(yyvsp[-1].cp); current_zone = begin_zone(zone_name, yyvsp[0].num); } break; -case 224: -#line 1491 "ns_parser.y" +case 236: +#line 1561 "ns_parser.y" { end_zone(current_zone, should_install); } break; -case 227: -#line 1501 "ns_parser.y" +case 239: +#line 1571 "ns_parser.y" { yyval.num = C_IN; } break; -case 228: -#line 1505 "ns_parser.y" +case 240: +#line 1575 "ns_parser.y" { symbol_value value; @@ -2798,116 +2906,116 @@ case 228: /* the zone validator will give the error */ yyval.num = C_NONE; } - freestr(yyvsp[0].cp); + (void)freestr(yyvsp[0].cp); } break; -case 229: -#line 1519 "ns_parser.y" +case 241: +#line 1589 "ns_parser.y" { yyval.s_int = Z_MASTER; } break; -case 230: -#line 1523 "ns_parser.y" +case 242: +#line 1593 "ns_parser.y" { yyval.s_int = Z_SLAVE; } break; -case 231: -#line 1527 "ns_parser.y" +case 243: +#line 1597 "ns_parser.y" { yyval.s_int = Z_HINT; } break; -case 232: -#line 1531 "ns_parser.y" +case 244: +#line 1601 "ns_parser.y" { yyval.s_int = Z_STUB; } break; -case 233: -#line 1535 "ns_parser.y" +case 245: +#line 1605 "ns_parser.y" { yyval.s_int = Z_FORWARD; } break; -case 236: -#line 1545 "ns_parser.y" +case 248: +#line 1615 "ns_parser.y" { if (!set_zone_type(current_zone, yyvsp[0].s_int)) parser_warning(0, "zone type already set; skipping"); } break; -case 237: -#line 1550 "ns_parser.y" +case 249: +#line 1620 "ns_parser.y" { if (!set_zone_filename(current_zone, yyvsp[0].cp)) parser_warning(0, "zone filename already set; skipping"); } break; -case 238: -#line 1556 "ns_parser.y" +case 250: +#line 1626 "ns_parser.y" { - if (!set_zone_ixfr_file(current_zone, yyvsp[0].cp)) - parser_warning(0, - "zone ixfr data base already set; skipping"); - } + if (!set_zone_ixfr_file(current_zone, yyvsp[0].cp)) + parser_warning(0, + "zone ixfr data base already set; skipping"); + } break; -case 239: -#line 1562 "ns_parser.y" +case 251: +#line 1632 "ns_parser.y" { - if (!set_zone_ixfr_tmp(current_zone, yyvsp[0].cp)) - parser_warning(0, - "zone ixfr temp filename already set; skipping"); - } + if (!set_zone_ixfr_tmp(current_zone, yyvsp[0].cp)) + parser_warning(0, + "zone ixfr temp filename already set; skipping"); + } break; -case 240: -#line 1568 "ns_parser.y" +case 252: +#line 1638 "ns_parser.y" { set_zone_master_port(current_zone, yyvsp[-3].us_int); } break; -case 241: -#line 1572 "ns_parser.y" +case 253: +#line 1642 "ns_parser.y" { set_zone_transfer_source(current_zone, yyvsp[0].ip_addr); } break; -case 242: -#line 1576 "ns_parser.y" +case 254: +#line 1646 "ns_parser.y" { if (!set_zone_checknames(current_zone, (enum severity)yyvsp[0].s_int)) parser_warning(0, "zone checknames already set; skipping"); } break; -case 243: -#line 1582 "ns_parser.y" +case 255: +#line 1652 "ns_parser.y" { if (!set_zone_update_acl(current_zone, yyvsp[-1].iml)) parser_warning(0, "zone update acl already set; skipping"); } break; -case 244: -#line 1588 "ns_parser.y" +case 256: +#line 1658 "ns_parser.y" { if (!set_zone_query_acl(current_zone, yyvsp[-1].iml)) parser_warning(0, "zone query acl already set; skipping"); } break; -case 245: -#line 1594 "ns_parser.y" +case 257: +#line 1664 "ns_parser.y" { if (!set_zone_transfer_acl(current_zone, yyvsp[-1].iml)) parser_warning(0, "zone transfer acl already set; skipping"); } break; -case 247: -#line 1601 "ns_parser.y" +case 259: +#line 1671 "ns_parser.y" { struct zoneinfo *zp = current_zone.opaque; if (zp->z_fwdtab) { @@ -2917,41 +3025,50 @@ case 247: } break; -case 249: -#line 1611 "ns_parser.y" +case 261: +#line 1681 "ns_parser.y" { if (!set_zone_transfer_time_in(current_zone, yyvsp[0].num*60)) parser_warning(0, "zone max transfer time (in) already set; skipping"); } break; -case 250: -#line 1617 "ns_parser.y" +case 262: +#line 1687 "ns_parser.y" { - set_zone_max_log_size_ixfr(current_zone, yyvsp[0].num); + set_zone_max_log_size_ixfr(current_zone, yyvsp[0].ul_int); } break; -case 251: -#line 1621 "ns_parser.y" +case 263: +#line 1691 "ns_parser.y" { - set_zone_notify(current_zone, yyvsp[0].num); + set_zone_notify(current_zone, notify_explicit); } break; -case 252: -#line 1625 "ns_parser.y" +case 264: +#line 1695 "ns_parser.y" +{ + if (yyvsp[0].num) + set_zone_notify(current_zone, notify_yes); + else + set_zone_notify(current_zone, notify_no); + } +break; +case 265: +#line 1702 "ns_parser.y" { set_zone_maintain_ixfr_base(current_zone, yyvsp[0].num); } break; -case 253: -#line 1629 "ns_parser.y" +case 266: +#line 1706 "ns_parser.y" { /* flags proto alg key */ set_zone_pubkey(current_zone, yyvsp[-3].num, yyvsp[-2].num, yyvsp[-1].num, yyvsp[0].cp); } break; -case 254: -#line 1634 "ns_parser.y" +case 267: +#line 1711 "ns_parser.y" { /* flags proto alg key */ char *endp; @@ -2963,110 +3080,116 @@ case 254: } break; -case 256: -#line 1646 "ns_parser.y" +case 269: +#line 1723 "ns_parser.y" { set_zone_dialup(current_zone, yyvsp[0].num); } break; -case 258: -#line 1653 "ns_parser.y" +case 271: +#line 1730 "ns_parser.y" { /* nothing */ } break; -case 259: -#line 1657 "ns_parser.y" +case 272: +#line 1734 "ns_parser.y" { /* nothing */ } break; -case 260: -#line 1663 "ns_parser.y" +case 273: +#line 1740 "ns_parser.y" { - add_zone_master(current_zone, yyvsp[0].ip_addr); + add_zone_master(current_zone, yyvsp[0].ip_addr, NULL); } break; -case 263: -#line 1673 "ns_parser.y" +case 274: +#line 1744 "ns_parser.y" +{ + add_zone_master(current_zone, yyvsp[-2].ip_addr, yyvsp[0].keyi); + } +break; +case 277: +#line 1754 "ns_parser.y" { /* nothing */ } break; -case 264: -#line 1677 "ns_parser.y" +case 278: +#line 1758 "ns_parser.y" { /* nothing */ } break; -case 265: -#line 1683 "ns_parser.y" +case 279: +#line 1764 "ns_parser.y" { add_zone_notify(current_zone, yyvsp[0].ip_addr); } break; -case 266: -#line 1689 "ns_parser.y" +case 280: +#line 1770 "ns_parser.y" { set_zone_boolean_option(current_zone, OPTION_FORWARD_ONLY, 1); } break; -case 267: -#line 1693 "ns_parser.y" +case 281: +#line 1774 "ns_parser.y" { set_zone_boolean_option(current_zone, OPTION_FORWARD_ONLY, 0); } break; -case 268: -#line 1699 "ns_parser.y" +case 282: +#line 1780 "ns_parser.y" { set_zone_forward(current_zone); } break; -case 270: -#line 1706 "ns_parser.y" +case 284: +#line 1787 "ns_parser.y" { /* nothing */ } break; -case 271: -#line 1710 "ns_parser.y" +case 285: +#line 1791 "ns_parser.y" { /* nothing */ } break; -case 272: -#line 1716 "ns_parser.y" +case 286: +#line 1797 "ns_parser.y" { add_zone_forwarder(current_zone, yyvsp[0].ip_addr); } break; -case 273: -#line 1726 "ns_parser.y" +case 287: +#line 1807 "ns_parser.y" { } break; -case 274: -#line 1730 "ns_parser.y" +case 288: +#line 1811 "ns_parser.y" { /* nothing */ } break; -case 275: -#line 1734 "ns_parser.y" +case 289: +#line 1815 "ns_parser.y" { /* nothing */ } break; -case 276: -#line 1739 "ns_parser.y" +case 290: +#line 1820 "ns_parser.y" { /* name flags proto alg key */ set_trusted_key(yyvsp[-4].cp, yyvsp[-3].num, yyvsp[-2].num, yyvsp[-1].num, yyvsp[0].cp); } break; -case 277: -#line 1744 "ns_parser.y" +case 291: +#line 1825 "ns_parser.y" { /* name flags proto alg key */ char *endp; @@ -3077,25 +3200,24 @@ case 277: set_trusted_key(yyvsp[-4].cp, flags, yyvsp[-2].num, yyvsp[-1].num, yyvsp[0].cp); } break; -case 278: -#line 1760 "ns_parser.y" +case 292: +#line 1841 "ns_parser.y" { if (yyvsp[0].num < 0 || yyvsp[0].num > 65535) { parser_warning(0, "invalid IP port number '%d'; setting port to 0", - yyvsp[0].num); + (int)yyvsp[0].num); yyvsp[0].num = 0; } else yyval.us_int = htons(yyvsp[0].num); } break; -#line 3093 "y.tab.c" +#line 3214 "y.tab.c" } - yystk.ssp -= yym; - yystate = *yystk.ssp; - yystk.vsp -= yym; + yyssp -= yym; + yystate = *yyssp; + yyvsp -= yym; yym = yylhs[yyn]; - yych = yychar; if (yystate == 0 && yym == 0) { #if YYDEBUG @@ -3104,24 +3226,23 @@ break; state %d\n", YYPREFIX, YYFINAL); #endif yystate = YYFINAL; - *++yystk.ssp = YYFINAL; - *++yystk.vsp = yyval; - if (yych < 0) + *++yyssp = YYFINAL; + *++yyvsp = yyval; + if (yychar < 0) { - if ((yych = YYLEX) < 0) yych = 0; - yychar = yych; + if ((yychar = yylex()) < 0) yychar = 0; #if YYDEBUG if (yydebug) { yys = 0; - if (yych <= YYMAXTOKEN) yys = yyname[yych]; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; if (!yys) yys = "illegal-symbol"; printf("%sdebug: state %d, reading %d (%s)\n", - YYPREFIX, YYFINAL, yych, yys); + YYPREFIX, YYFINAL, yychar, yys); } #endif } - if (yych == 0) goto yyaccept; + if (yychar == 0) goto yyaccept; goto yyloop; } if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && @@ -3132,19 +3253,19 @@ break; #if YYDEBUG if (yydebug) printf("%sdebug: after reduction, shifting from state %d \ -to state %d\n", YYPREFIX, *yystk.ssp, yystate); +to state %d\n", YYPREFIX, *yyssp, yystate); #endif - if (yystk.ssp >= yystk.sslim && yygrowstack(&yystk)) + if (yyssp >= yysslim && yygrowstack()) + { goto yyoverflow; - *++yystk.ssp = yystate; - *++yystk.vsp = yyval; + } + *++yyssp = yystate; + *++yyvsp = yyval; goto yyloop; yyoverflow: yyerror("yacc stack overflow"); yyabort: - YYFREESTACK(&yystk); return (1); yyaccept: - YYFREESTACK(&yystk); return (0); } diff --git a/contrib/bind/bin/named/ns_parser.h b/contrib/bind/bin/named/ns_parser.h index 571fb47..80dceab 100644 --- a/contrib/bind/bin/named/ns_parser.h +++ b/contrib/bind/bin/named/ns_parser.h @@ -1,4 +1,3 @@ -#define YYEMPTY (-1) #define L_EOS 257 #define L_IPADDR 258 #define L_NUMBER 259 @@ -16,118 +15,124 @@ #define T_FAKE_IQUERY 271 #define T_RECURSION 272 #define T_FETCH_GLUE 273 -#define T_QUERY_SOURCE 274 -#define T_LISTEN_ON 275 -#define T_PORT 276 -#define T_ADDRESS 277 -#define T_RRSET_ORDER 278 -#define T_ORDER 279 -#define T_NAME 280 -#define T_CLASS 281 -#define T_CONTROLS 282 -#define T_INET 283 -#define T_UNIX 284 -#define T_PERM 285 -#define T_OWNER 286 -#define T_GROUP 287 -#define T_ALLOW 288 -#define T_DATASIZE 289 -#define T_STACKSIZE 290 -#define T_CORESIZE 291 -#define T_DEFAULT 292 -#define T_UNLIMITED 293 -#define T_FILES 294 -#define T_VERSION 295 -#define T_HOSTSTATS 296 -#define T_DEALLOC_ON_EXIT 297 -#define T_TRANSFERS_IN 298 -#define T_TRANSFERS_OUT 299 -#define T_TRANSFERS_PER_NS 300 -#define T_TRANSFER_FORMAT 301 -#define T_MAX_TRANSFER_TIME_IN 302 -#define T_SERIAL_QUERIES 303 -#define T_ONE_ANSWER 304 -#define T_MANY_ANSWERS 305 -#define T_NOTIFY 306 -#define T_AUTH_NXDOMAIN 307 -#define T_MULTIPLE_CNAMES 308 -#define T_USE_IXFR 309 -#define T_MAINTAIN_IXFR_BASE 310 -#define T_CLEAN_INTERVAL 311 -#define T_INTERFACE_INTERVAL 312 -#define T_STATS_INTERVAL 313 -#define T_MAX_LOG_SIZE_IXFR 314 -#define T_HEARTBEAT 315 -#define T_USE_ID_POOL 316 -#define T_MAX_NCACHE_TTL 317 -#define T_HAS_OLD_CLIENTS 318 -#define T_RFC2308_TYPE1 319 -#define T_LAME_TTL 320 -#define T_MIN_ROOTS 321 -#define T_TREAT_CR_AS_SPACE 322 -#define T_LOGGING 323 -#define T_CATEGORY 324 -#define T_CHANNEL 325 -#define T_SEVERITY 326 -#define T_DYNAMIC 327 -#define T_FILE 328 -#define T_VERSIONS 329 -#define T_SIZE 330 -#define T_SYSLOG 331 -#define T_DEBUG 332 -#define T_NULL_OUTPUT 333 -#define T_PRINT_TIME 334 -#define T_PRINT_CATEGORY 335 -#define T_PRINT_SEVERITY 336 -#define T_SORTLIST 337 -#define T_TOPOLOGY 338 -#define T_SERVER 339 -#define T_LONG_AXFR 340 -#define T_BOGUS 341 -#define T_TRANSFERS 342 -#define T_KEYS 343 -#define T_SUPPORT_IXFR 344 -#define T_ZONE 345 -#define T_IN 346 -#define T_CHAOS 347 -#define T_HESIOD 348 -#define T_TYPE 349 -#define T_MASTER 350 -#define T_SLAVE 351 -#define T_STUB 352 -#define T_RESPONSE 353 -#define T_HINT 354 -#define T_MASTERS 355 -#define T_TRANSFER_SOURCE 356 -#define T_PUBKEY 357 -#define T_ALSO_NOTIFY 358 -#define T_DIALUP 359 -#define T_FILE_IXFR 360 -#define T_IXFR_TMP 361 -#define T_TRUSTED_KEYS 362 -#define T_ACL 363 -#define T_ALLOW_UPDATE 364 -#define T_ALLOW_QUERY 365 -#define T_ALLOW_TRANSFER 366 -#define T_ALLOW_RECURSION 367 -#define T_BLACKHOLE 368 -#define T_SEC_KEY 369 -#define T_ALGID 370 -#define T_SECRET 371 -#define T_CHECK_NAMES 372 -#define T_WARN 373 -#define T_FAIL 374 -#define T_IGNORE 375 -#define T_FORWARD 376 -#define T_FORWARDERS 377 -#define T_ONLY 378 -#define T_FIRST 379 -#define T_IF_NO_ANSWER 380 -#define T_IF_NO_DOMAIN 381 -#define T_YES 382 -#define T_TRUE 383 -#define T_NO 384 -#define T_FALSE 385 +#define T_HITCOUNT 274 +#define T_PREFERRED_GLUE 275 +#define T_QUERY_SOURCE 276 +#define T_LISTEN_ON 277 +#define T_PORT 278 +#define T_ADDRESS 279 +#define T_RRSET_ORDER 280 +#define T_ORDER 281 +#define T_NAME 282 +#define T_CLASS 283 +#define T_CONTROLS 284 +#define T_INET 285 +#define T_UNIX 286 +#define T_PERM 287 +#define T_OWNER 288 +#define T_GROUP 289 +#define T_ALLOW 290 +#define T_DATASIZE 291 +#define T_STACKSIZE 292 +#define T_CORESIZE 293 +#define T_DEFAULT 294 +#define T_UNLIMITED 295 +#define T_FILES 296 +#define T_VERSION 297 +#define T_HOSTNAME 298 +#define T_HOSTSTATS 299 +#define T_HOSTSTATSMAX 300 +#define T_DEALLOC_ON_EXIT 301 +#define T_TRANSFERS_IN 302 +#define T_TRANSFERS_OUT 303 +#define T_TRANSFERS_PER_NS 304 +#define T_TRANSFER_FORMAT 305 +#define T_MAX_TRANSFER_TIME_IN 306 +#define T_SERIAL_QUERIES 307 +#define T_ONE_ANSWER 308 +#define T_MANY_ANSWERS 309 +#define T_NOTIFY 310 +#define T_EXPLICIT 311 +#define T_NOTIFY_INITIAL 312 +#define T_AUTH_NXDOMAIN 313 +#define T_MULTIPLE_CNAMES 314 +#define T_USE_IXFR 315 +#define T_MAINTAIN_IXFR_BASE 316 +#define T_CLEAN_INTERVAL 317 +#define T_INTERFACE_INTERVAL 318 +#define T_STATS_INTERVAL 319 +#define T_MAX_LOG_SIZE_IXFR 320 +#define T_HEARTBEAT 321 +#define T_USE_ID_POOL 322 +#define T_MAX_NCACHE_TTL 323 +#define T_HAS_OLD_CLIENTS 324 +#define T_RFC2308_TYPE1 325 +#define T_LAME_TTL 326 +#define T_MIN_ROOTS 327 +#define T_TREAT_CR_AS_SPACE 328 +#define T_LOGGING 329 +#define T_CATEGORY 330 +#define T_CHANNEL 331 +#define T_SEVERITY 332 +#define T_DYNAMIC 333 +#define T_FILE 334 +#define T_VERSIONS 335 +#define T_SIZE 336 +#define T_SYSLOG 337 +#define T_DEBUG 338 +#define T_NULL_OUTPUT 339 +#define T_PRINT_TIME 340 +#define T_PRINT_CATEGORY 341 +#define T_PRINT_SEVERITY 342 +#define T_SORTLIST 343 +#define T_TOPOLOGY 344 +#define T_SERVER 345 +#define T_LONG_AXFR 346 +#define T_BOGUS 347 +#define T_TRANSFERS 348 +#define T_KEYS 349 +#define T_SUPPORT_IXFR 350 +#define T_ZONE 351 +#define T_IN 352 +#define T_CHAOS 353 +#define T_HESIOD 354 +#define T_TYPE 355 +#define T_MASTER 356 +#define T_SLAVE 357 +#define T_STUB 358 +#define T_RESPONSE 359 +#define T_HINT 360 +#define T_MASTERS 361 +#define T_TRANSFER_SOURCE 362 +#define T_PUBKEY 363 +#define T_ALSO_NOTIFY 364 +#define T_DIALUP 365 +#define T_FILE_IXFR 366 +#define T_IXFR_TMP 367 +#define T_TRUSTED_KEYS 368 +#define T_ACL 369 +#define T_ALLOW_UPDATE 370 +#define T_ALLOW_QUERY 371 +#define T_ALLOW_TRANSFER 372 +#define T_ALLOW_RECURSION 373 +#define T_BLACKHOLE 374 +#define T_SEC_KEY 375 +#define T_ALGID 376 +#define T_SECRET 377 +#define T_CHECK_NAMES 378 +#define T_WARN 379 +#define T_FAIL 380 +#define T_IGNORE 381 +#define T_FORWARD 382 +#define T_FORWARDERS 383 +#define T_ONLY 384 +#define T_FIRST 385 +#define T_IF_NO_ANSWER 386 +#define T_IF_NO_DOMAIN 387 +#define T_YES 388 +#define T_TRUE 389 +#define T_NO 390 +#define T_FALSE 391 typedef union { char * cp; int s_int; diff --git a/contrib/bind/bin/named/ns_parser.y b/contrib/bind/bin/named/ns_parser.y index 0fe9dc7..8e62962 100644 --- a/contrib/bind/bin/named/ns_parser.y +++ b/contrib/bind/bin/named/ns_parser.y @@ -1,6 +1,6 @@ %{ #if !defined(lint) && !defined(SABER) -static char rcsid[] = "$Id: ns_parser.y,v 8.78 2001/12/28 04:07:48 marka Exp $"; +static char rcsid[] = "$Id: ns_parser.y,v 8.79 2002/04/25 05:27:13 marka Exp $"; #endif /* not lint */ /* @@ -150,7 +150,7 @@ int yyparse(); %token T_TRANSFER_FORMAT T_MAX_TRANSFER_TIME_IN %token T_SERIAL_QUERIES T_ONE_ANSWER T_MANY_ANSWERS %type <axfr_fmt> transfer_format -%token T_NOTIFY T_NOTIFY_INITIAL T_AUTH_NXDOMAIN +%token T_NOTIFY T_EXPLICIT T_NOTIFY_INITIAL T_AUTH_NXDOMAIN %token T_MULTIPLE_CNAMES T_USE_IXFR T_MAINTAIN_IXFR_BASE %token T_CLEAN_INTERVAL T_INTERFACE_INTERVAL T_STATS_INTERVAL %token T_MAX_LOG_SIZE_IXFR @@ -374,10 +374,16 @@ option: /* Empty */ set_global_boolean_option(current_options, OPTION_HITCOUNT, $2); } + | T_NOTIFY T_EXPLICIT + { + current_options->notify = notify_explicit; + } | T_NOTIFY yea_or_nay { - set_global_boolean_option(current_options, - OPTION_NONOTIFY, !$2); + if ($2) + current_options->notify = notify_yes; + else + current_options->notify = notify_no; } | T_NOTIFY_INITIAL yea_or_nay { @@ -1681,9 +1687,16 @@ zone_option: T_TYPE zone_type { set_zone_max_log_size_ixfr(current_zone, $2); } + | T_NOTIFY T_EXPLICIT + { + set_zone_notify(current_zone, notify_explicit); + } | T_NOTIFY yea_or_nay { - set_zone_notify(current_zone, $2); + if ($2) + set_zone_notify(current_zone, notify_yes); + else + set_zone_notify(current_zone, notify_no); } | T_MAINTAIN_IXFR_BASE yea_or_nay { diff --git a/contrib/bind/bin/named/ns_req.c b/contrib/bind/bin/named/ns_req.c index 6695881..1a1d756 100644 --- a/contrib/bind/bin/named/ns_req.c +++ b/contrib/bind/bin/named/ns_req.c @@ -1,6 +1,6 @@ #if !defined(lint) && !defined(SABER) static const char sccsid[] = "@(#)ns_req.c 4.47 (Berkeley) 7/1/91"; -static const char rcsid[] = "$Id: ns_req.c,v 8.162 2002/02/01 00:05:36 marka Exp $"; +static const char rcsid[] = "$Id: ns_req.c,v 8.168 2002/04/30 03:43:52 marka Exp $"; #endif /* not lint */ /* @@ -231,24 +231,10 @@ ns_get_opt(u_char *msg, u_char *eom, version = *cp++; GETSHORT(flags, cp); GETSHORT(rdlen, cp); - /* ensure options are well formed */ + if (cp + rdlen > eom) + return (-1); options = cp; optsize = rdlen; - while (rdlen != 0) { - u_int16_t code; - u_int16_t len; - - if (rdlen < 4) - return (-1); - GETSHORT(code, cp); - GETSHORT(len, cp); - rdlen -= 4; - if (len > rdlen) - return (-1); - cp += len; - rdlen -= len; - } - /* Everything checks out. */ if (versionp != NULL) *versionp = version; if (rcodep != NULL) @@ -315,6 +301,7 @@ ns_req(u_char *msg, int msglen, int buflen, struct qstream *qsp, u_int16_t rcode = ns_r_noerror; u_int16_t udpsize = 0; int drop; + int tsig_adjust = 0; #ifdef DEBUG if (debug > 3) { @@ -332,9 +319,18 @@ ns_req(u_char *msg, int msglen, int buflen, struct qstream *qsp, has_tsig = 0; else { char buf[MAXDNAME]; + u_char tmp[NS_MAXCDNAME]; has_tsig = 1; - n = dn_expand(msg, msg + msglen, tsigstart, buf, sizeof buf); + n = ns_name_unpack(msg, msg + msglen, tsigstart, + tmp, sizeof tmp); + if (n > 0) { + tsig_adjust = dn_skipname(tmp, tmp + sizeof(tmp)) - n; + if (ns_name_ntop(tmp, buf, sizeof buf) == -1) + n = -1; + else if (buf[0] == '.') + buf[0] = '\0'; + } if (n < 0) { ns_debug(ns_log_default, 1, "ns_req: bad TSIG key name"); @@ -395,7 +391,8 @@ ns_req(u_char *msg, int msglen, int buflen, struct qstream *qsp, in_tsig->siglen = siglen; memcpy(in_tsig->sig, sig, siglen); tsig_size = msglen_orig - msglen; - in_tsig->tsig_size = tsig_size; + /* AXFR/IXFR need the uncompressed tsig size. */ + in_tsig->tsig_size = tsig_size + tsig_adjust; } else if (has_tsig) { action = Finish; in_tsig = memget(sizeof(struct tsig_record)); @@ -576,8 +573,9 @@ ns_req(u_char *msg, int msglen, int buflen, struct qstream *qsp, sig2len = sizeof sig2; msglen = cp - msg; buflen = buflen_orig - msglen; - n = ns_sign(msg, &msglen, msglen + buflen, error, key, - sig, siglen, sig2, &sig2len, tsig_time); + n = ns_sign2(msg, &msglen, msglen + buflen, error, key, + sig, siglen, sig2, &sig2len, tsig_time, + dnptrs, dnptrs_end); if (n == NS_TSIG_ERROR_NO_SPACE && ntohs(hp->qdcount) != 0) { hp->qdcount = htons(0); @@ -609,12 +607,14 @@ ns_req(u_char *msg, int msglen, int buflen, struct qstream *qsp, INSIST(n > 0); cp += n; buflen -= n; + msglen += n; } if (has_tsig > 0) { buflen += tsig_size; sig2len = sizeof sig2; - n = ns_sign(msg, &msglen, msglen + buflen, error, key, - sig, siglen, sig2, &sig2len, tsig_time); + n = ns_sign2(msg, &msglen, msglen + buflen, error, key, + sig, siglen, sig2, &sig2len, tsig_time, + dnptrs, dnptrs_end); if (n != 0) { INSIST(0); } @@ -1218,12 +1218,17 @@ req_query(HEADER *hp, u_char **cpp, u_char *eom, struct qstream *qsp, goto fetchns; } } +#ifdef NXDOMAIN_ON_DENIAL + hp->rcode = ns_r_nxdomain; + return (Finish); +#else ns_notice(ns_log_security, "denied query from %s for \"%s\" %s/%s", sin_ntoa(from), *dname ? dname : ".", p_type(type), p_class(class)); nameserIncr(from.sin_addr, nssRcvdUQ); return (Refuse); +#endif } } else { ip_match_list transfer_acl; @@ -2315,7 +2320,10 @@ doaddinfo(HEADER *hp, u_char *msg, int msglen) { cp = msg; loop: for (ap = addinfo, i = 0; i < addcount; ap++, i++) { - int foundany = 0, + int auth = 0, + founda = 0, + foundaaaa = 0, + founda6 = 0, foundcname = 0, save_count = count, save_msglen = msglen; @@ -2340,16 +2348,27 @@ loop: /* look for the data */ (void)delete_stale(np); for (dp = np->n_data; dp != NULL; dp = dp->d_next) { + if (dp->d_class != ap->a_class) + continue; if (dp->d_rcode == NXDOMAIN) { - if (dp->d_class == ap->a_class) - foundany++; + founda = founda6 = foundaaaa = 1; continue; } - if ((match(dp, (int)ap->a_class, T_CNAME) && - dp->d_type == T_CNAME)) { + switch (dp->d_type) { + case ns_t_a: founda = 1; break; + case ns_t_a6: founda6 = 1; break; + case ns_t_aaaa: foundaaaa = 1; break; + } + if (!dp->d_rcode && dp->d_type == T_CNAME) { foundcname++; break; } + if (auth == 0 && ap->a_type == T_A && + (dp->d_type == ns_t_a || dp->d_type == ns_t_a6 || + dp->d_type == ns_t_aaaa) && + (zones[dp->d_zone].z_type == z_master || + zones[dp->d_zone].z_type == z_slave)) + auth = 1; if (pass == 0 && ap->a_type == T_A && server_options->preferred_glue != 0 && !match(dp, (int)ap->a_class, @@ -2374,8 +2393,6 @@ loop: if (ap->a_type == T_SRV && !match(dp, (int)ap->a_class, T_SRV)) continue; - - foundany++; if (dp->d_rcode) continue; /* @@ -2417,12 +2434,20 @@ loop: } next_rr: if (!NS_OPTION_P(OPTION_NOFETCHGLUE) && - !foundcname && !foundany && - (ap->a_type == T_A || ap->a_type == T_AAAA)) { + !foundcname && ap->a_type == T_A) { /* ask a real server for this info */ - (void) sysquery(ap->a_dname, (int)ap->a_class, - ap->a_type, NULL, NULL, 0, ns_port, - QUERY, 0); + if (!founda && !auth) + (void) sysquery(ap->a_dname, (int)ap->a_class, + ns_t_a, NULL, NULL, 0, ns_port, + QUERY, 0); + if (!foundaaaa && !auth) + (void) sysquery(ap->a_dname, (int)ap->a_class, + ns_t_aaaa, NULL, NULL, 0, + ns_port, QUERY, 0); + if (!founda6 && !auth) + (void) sysquery(ap->a_dname, (int)ap->a_class, + ns_t_a6, NULL, NULL, 0, ns_port, + QUERY, 0); } if (foundcname) { if (!haveComplained(nhash(ap->a_dname), diff --git a/contrib/bind/bin/named/ns_resp.c b/contrib/bind/bin/named/ns_resp.c index ea62674..5be0038 100644 --- a/contrib/bind/bin/named/ns_resp.c +++ b/contrib/bind/bin/named/ns_resp.c @@ -1,6 +1,6 @@ #if !defined(lint) && !defined(SABER) static const char sccsid[] = "@(#)ns_resp.c 4.65 (Berkeley) 3/3/91"; -static const char rcsid[] = "$Id: ns_resp.c,v 8.172 2002/01/31 00:06:41 marka Exp $"; +static const char rcsid[] = "$Id: ns_resp.c,v 8.176 2002/04/17 07:10:10 marka Exp $"; #endif /* not lint */ /* @@ -182,7 +182,8 @@ static int rrsetcmp(char *, struct db_list *, struct hashbuf *), struct sockaddr_in, char **); static void mark_bad(struct qinfo *qp, struct sockaddr_in from); static void mark_lame(struct qinfo *qp, struct sockaddr_in from); -static int mark_noedns(struct qinfo *qp, struct sockaddr_in from); +static int mark_noedns(struct qinfo *qp, struct sockaddr_in from, + int cache); static void fast_retry(struct qinfo *qp, struct sockaddr_in from, int samehost); static void add_related_additional(char *); @@ -417,15 +418,15 @@ ns_resp(u_char *msg, int msglen, struct sockaddr_in from, struct qstream *qsp) switch (hp->rcode) { case SERVFAIL: nameserIncr(from.sin_addr, nssRcvdFail); - noedns = mark_noedns(qp, from); + noedns = mark_noedns(qp, from, 0); break; case FORMERR: nameserIncr(from.sin_addr, nssRcvdFErr); - noedns = mark_noedns(qp, from); + noedns = mark_noedns(qp, from, 1); break; case NOTIMP: nameserIncr(from.sin_addr, nssRcvdErr); - noedns = mark_noedns(qp, from); + noedns = mark_noedns(qp, from, 1); break; default: nameserIncr(from.sin_addr, nssRcvdErr); @@ -1059,6 +1060,7 @@ tcp_retry: /* Additional section. */ switch (type) { case T_A: + case ns_t_a6: case T_AAAA: case T_SRV: if (externalcname || @@ -1778,6 +1780,7 @@ rrextract(u_char *msg, int msglen, u_char *rrp, struct databuf **dpp, case T_LOC: case T_KEY: case ns_t_cert: + case ns_t_opt: cp1 = cp; n = dlen; cp += n; @@ -1859,6 +1862,8 @@ rrextract(u_char *msg, int msglen, u_char *rrp, struct databuf **dpp, } n = cp1 - data; cp1 = data; + if (tnamep != NULL && type == T_SOA) + *tnamep = savestr((char *)cp1, 1); break; case T_NAPTR: @@ -3933,14 +3938,14 @@ trunc_adjust(u_char *msg, int msglen, int outlen) { * mark the server "from" bad in the qp structure so it won't be retried. */ static int -mark_noedns(struct qinfo *qp, struct sockaddr_in from) { +mark_noedns(struct qinfo *qp, struct sockaddr_in from, int cache) { int i; for (i = 0; i < (int)qp->q_naddr; i++) if (ina_equal(qp->q_addr[i].ns_addr.sin_addr, from.sin_addr)) { if (qp->q_addr[i].noedns) return (1); - if (qp->q_addr[i].nsdata) + if (qp->q_addr[i].nsdata && cache) qp->q_addr[i].nsdata->d_noedns = 1; qp->q_addr[i].noedns = 1; break; diff --git a/contrib/bind/bin/named/ns_xfr.c b/contrib/bind/bin/named/ns_xfr.c index ab23b6b..d7a8505 100644 --- a/contrib/bind/bin/named/ns_xfr.c +++ b/contrib/bind/bin/named/ns_xfr.c @@ -1,5 +1,5 @@ #if !defined(lint) && !defined(SABER) -static const char rcsid[] = "$Id: ns_xfr.c,v 8.67 2001/07/10 05:06:50 marka Exp $"; +static const char rcsid[] = "$Id: ns_xfr.c,v 8.68 2002/04/11 05:19:06 marka Exp $"; #endif /* not lint */ /* @@ -180,13 +180,15 @@ ns_xfr(struct qstream *qsp, struct namebuf *znp, qsp->xfr.transfer_format = si->transfer_format; else qsp->xfr.transfer_format = server_options->transfer_format; - if (in_tsig == NULL) + if (in_tsig == NULL) { qsp->xfr.tsig_state = NULL; - else { + qsp->xfr.tsig_size = 0; + } else { qsp->xfr.tsig_state = memget(sizeof(ns_tcp_tsig_state)); ns_sign_tcp_init(in_tsig->key, in_tsig->sig, in_tsig->siglen, qsp->xfr.tsig_state); qsp->xfr.tsig_skip = 0; + qsp->xfr.tsig_size = in_tsig->tsig_size; } if (type == ns_t_ixfr) { @@ -393,14 +395,15 @@ sx_addrr(struct qstream *qsp, const char *dname, struct databuf *dp) { } } - n = make_rr(dname, dp, qsp->xfr.cp, qsp->xfr.eom - qsp->xfr.cp, - 0, qsp->xfr.ptrs, edp, 0); + n = make_rr(dname, dp, qsp->xfr.cp, qsp->xfr.eom - qsp->xfr.cp - + qsp->xfr.tsig_size, 0, qsp->xfr.ptrs, edp, 0); if (n < 0) { if (sx_flush(qsp) < 0) return (-1); if (qsp->xfr.cp == NULL) sx_newmsg(qsp); - n = make_rr(dname, dp, qsp->xfr.cp, qsp->xfr.eom - qsp->xfr.cp, + n = make_rr(dname, dp, qsp->xfr.cp, qsp->xfr.eom - + qsp->xfr.cp - qsp->xfr.tsig_size, 0, qsp->xfr.ptrs, edp, 0); INSIST(n >= 0); } diff --git a/contrib/bind/bin/nslookup/commands.c b/contrib/bind/bin/nslookup/commands.c index fead60f..298eda7 100644 --- a/contrib/bind/bin/nslookup/commands.c +++ b/contrib/bind/bin/nslookup/commands.c @@ -1,7 +1,7 @@ /* A lexical scanner generated by flex */ /* Scanner skeleton version: - * /master/usr.bin/lex/skel.c,v 1.2 1996/05/30 12:31:07 bostic Exp + * $FreeBSD$ */ #define FLEX_SCANNER @@ -236,7 +236,7 @@ void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); static void *yy_flex_alloc YY_PROTO(( yy_size_t )); @@ -282,28 +282,27 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); *yy_cp = '\0'; \ yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 22 -#define YY_END_OF_BUFFER 23 -static yyconst short int yy_accept[171] = +#define YY_NUM_RULES 21 +#define YY_END_OF_BUFFER 22 +static yyconst short int yy_accept[158] = { 0, - 0, 0, 23, 22, 21, 22, 22, 19, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 0, 20, 0, - 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 16, 0, 0, 14, 0, 0, 0, 0, 0, + 0, 0, 22, 21, 20, 21, 21, 18, 21, 21, + 21, 21, 21, 21, 21, 21, 0, 19, 0, 18, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, + 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, + 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 14, 0, 3, 0, + 0, 12, 0, 8, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 15, 0, 3, 0, 0, 13, 0, 9, 0, - 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, - - 0, 0, 12, 0, 0, 0, 17, 0, 6, 0, - 0, 0, 0, 0, 0, 0, 7, 0, 0, 7, - 0, 0, 0, 0, 9, 0, 0, 11, 0, 0, - 0, 0, 6, 0, 0, 0, 0, 0, 8, 0, - 0, 0, 0, 0, 1, 0, 0, 0, 5, 0, - 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, - 0, 0, 0, 0, 5, 0, 8, 0, 10, 0 + 0, 0, 0, 11, 0, 0, 11, 0, 16, 0, + + 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 8, 0, 0, 10, 0, 0, 0, 0, 6, + 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 5, 0, 0, 0, 0, + 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, + 0, 5, 0, 7, 0, 9, 0 } ; static yyconst int yy_ec[256] = @@ -313,14 +312,14 @@ static yyconst int yy_ec[256] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 5, 4, 6, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, + 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 6, 7, 8, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 1, 9, 1, 1, 10, 1, 11, 4, 4, 12, + 1, 9, 1, 1, 4, 1, 10, 4, 4, 11, - 13, 14, 15, 16, 17, 4, 4, 18, 19, 20, - 21, 22, 4, 23, 24, 25, 4, 26, 27, 28, + 12, 13, 14, 15, 16, 4, 4, 17, 18, 19, + 20, 21, 4, 22, 23, 24, 4, 25, 4, 26, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -338,217 +337,199 @@ static yyconst int yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst int yy_meta[29] = +static yyconst int yy_meta[27] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1, 1 } ; -static yyconst short int yy_base[203] = +static yyconst short int yy_base[187] = { 0, - 504, 0, 497, 626, 626, 484, 28, 626, 56, 58, - 65, 52, 49, 47, 55, 57, 61, 477, 626, 0, - 626, 451, 79, 0, 62, 71, 63, 67, 73, 75, - 103, 626, 450, 94, 626, 90, 74, 96, 113, 95, - 94, 107, 141, 150, 100, 106, 105, 159, 108, 104, - 72, 128, 110, 168, 626, 175, 184, 137, 0, 144, - 160, 152, 193, 200, 153, 187, 185, 225, 195, 235, - 202, 626, 244, 626, 186, 204, 626, 215, 626, 254, - 218, 237, 245, 257, 626, 241, 273, 282, 291, 301, - 263, 0, 284, 265, 312, 322, 283, 277, 331, 626, - - 338, 268, 626, 347, 356, 275, 626, 365, 626, 375, - 466, 384, 393, 314, 402, 411, 626, 418, 333, 626, - 427, 436, 445, 448, 626, 455, 464, 626, 474, 483, - 493, 496, 626, 503, 512, 341, 0, 349, 626, 515, - 522, 525, 532, 535, 626, 542, 551, 358, 626, 560, - 377, 563, 570, 579, 386, 582, 626, 589, 598, 395, - 0, 607, 616, 413, 626, 420, 626, 429, 626, 626, - 460, 459, 458, 448, 441, 440, 439, 432, 423, 416, - 405, 398, 389, 380, 368, 361, 352, 336, 325, 306, - 294, 287, 267, 247, 240, 228, 209, 207, 198, 173, - - 162, 144 + 445, 0, 447, 565, 565, 443, 26, 565, 52, 54, + 61, 49, 46, 48, 47, 54, 433, 565, 0, 565, + 401, 74, 0, 62, 67, 58, 63, 70, 96, 565, + 394, 83, 565, 74, 87, 90, 106, 89, 88, 132, + 141, 68, 97, 96, 150, 69, 95, 99, 128, 124, + 565, 159, 168, 126, 0, 161, 153, 170, 196, 203, + 111, 181, 162, 227, 236, 143, 565, 245, 565, 156, + 178, 565, 183, 565, 254, 189, 191, 183, 198, 565, + 186, 263, 272, 281, 208, 0, 214, 213, 290, 299, + 197, 223, 307, 565, 314, 239, 565, 256, 565, 323, + + 565, 332, 417, 341, 350, 285, 359, 368, 377, 386, + 389, 565, 396, 405, 565, 414, 423, 432, 435, 565, + 442, 451, 265, 0, 274, 565, 454, 461, 464, 471, + 474, 565, 481, 490, 283, 565, 499, 310, 502, 509, + 518, 316, 521, 565, 528, 537, 334, 0, 546, 555, + 343, 565, 352, 565, 370, 565, 565, 417, 408, 401, + 400, 399, 389, 382, 381, 380, 373, 362, 355, 346, + 337, 326, 319, 302, 293, 277, 268, 259, 230, 223, + 221, 201, 188, 146, 137, 119 } ; -static yyconst short int yy_def[203] = +static yyconst short int yy_def[187] = { 0, - 171, 170, 170, 170, 170, 172, 170, 170, 173, 172, - 173, 11, 11, 11, 11, 11, 11, 172, 170, 7, - 170, 11, 172, 11, 11, 11, 11, 11, 11, 11, - 174, 170, 11, 172, 170, 11, 11, 11, 11, 11, - 11, 11, 175, 176, 11, 11, 11, 177, 11, 11, - 11, 11, 11, 172, 170, 175, 176, 57, 57, 11, - 11, 11, 178, 172, 11, 11, 11, 179, 11, 180, - 172, 170, 174, 170, 11, 73, 170, 172, 170, 178, - 172, 172, 11, 73, 170, 11, 181, 182, 183, 180, - 90, 90, 11, 90, 184, 185, 11, 11, 172, 170, - - 181, 172, 170, 186, 187, 172, 170, 188, 170, 189, - 90, 190, 191, 11, 192, 172, 170, 186, 172, 170, - 193, 194, 189, 172, 170, 190, 195, 170, 191, 196, - 197, 172, 170, 193, 194, 135, 135, 172, 170, 172, - 198, 172, 199, 172, 170, 197, 200, 172, 170, 201, - 172, 172, 198, 202, 172, 172, 170, 199, 200, 159, - 159, 201, 202, 172, 170, 172, 170, 172, 170, 0, - 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, - 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, - 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, - - 170, 170 + 158, 157, 157, 157, 157, 159, 157, 157, 160, 159, + 160, 11, 11, 11, 11, 11, 159, 157, 7, 157, + 11, 159, 11, 11, 11, 11, 11, 11, 161, 157, + 11, 159, 157, 11, 11, 11, 11, 11, 11, 162, + 163, 11, 11, 11, 164, 11, 11, 11, 11, 159, + 157, 162, 163, 53, 53, 11, 11, 11, 165, 159, + 11, 11, 11, 166, 167, 159, 157, 161, 157, 11, + 68, 157, 159, 157, 165, 159, 159, 11, 68, 157, + 11, 168, 169, 167, 84, 84, 11, 84, 170, 171, + 11, 11, 159, 157, 168, 159, 157, 159, 157, 172, + + 157, 173, 84, 174, 175, 11, 176, 177, 178, 173, + 159, 157, 174, 179, 157, 175, 180, 181, 159, 157, + 177, 178, 122, 122, 159, 157, 159, 182, 159, 183, + 159, 157, 181, 184, 159, 157, 185, 159, 159, 182, + 186, 159, 159, 157, 183, 184, 146, 146, 185, 186, + 159, 157, 159, 157, 159, 157, 0, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157 } ; -static yyconst short int yy_nxt[655] = +static yyconst short int yy_nxt[592] = { 0, 6, 7, 8, 9, 6, 6, 6, 10, 9, 9, - 9, 9, 11, 12, 9, 13, 9, 14, 9, 9, - 9, 9, 15, 16, 9, 17, 9, 9, 18, 20, - 21, 22, 18, 18, 18, 23, 22, 22, 22, 22, - 24, 25, 22, 26, 22, 27, 22, 22, 22, 22, - 28, 29, 22, 30, 22, 22, 18, 31, 32, 34, - 35, 38, 18, 18, 18, 18, 31, 32, 37, 41, - 39, 18, 18, 18, 33, 40, 33, 42, 37, 33, - 34, 35, 33, 38, 33, 41, 39, 40, 33, 33, - 33, 42, 36, 46, 33, 34, 35, 67, 33, 33, - - 33, 33, 33, 18, 31, 32, 45, 18, 18, 44, - 18, 18, 18, 47, 48, 50, 51, 33, 52, 53, - 61, 33, 33, 33, 60, 49, 62, 33, 66, 68, - 65, 33, 33, 33, 33, 33, 69, 33, 71, 72, - 33, 18, 54, 55, 163, 73, 74, 18, 18, 18, - 18, 57, 19, 76, 77, 33, 59, 18, 18, 18, - 48, 32, 162, 64, 18, 44, 18, 18, 18, 54, - 55, 33, 75, 160, 70, 18, 54, 55, 83, 33, - 33, 18, 18, 18, 18, 57, 19, 33, 84, 85, - 18, 18, 18, 18, 78, 79, 89, 86, 158, 18, - - 18, 18, 19, 71, 72, 76, 77, 153, 93, 146, - 81, 81, 33, 33, 33, 81, 78, 79, 81, 95, - 19, 94, 33, 81, 82, 18, 68, 32, 143, 88, - 88, 44, 18, 18, 88, 18, 90, 19, 96, 19, - 141, 92, 18, 18, 18, 73, 74, 136, 18, 18, - 44, 18, 18, 18, 18, 78, 79, 97, 84, 85, - 18, 18, 18, 98, 106, 107, 110, 134, 33, 102, - 103, 111, 33, 18, 99, 100, 106, 107, 115, 18, - 18, 18, 18, 102, 103, 108, 109, 131, 18, 18, - 18, 18, 89, 32, 129, 105, 105, 44, 18, 18, - - 105, 18, 90, 19, 33, 114, 126, 18, 18, 18, - 33, 33, 18, 95, 19, 130, 18, 18, 18, 18, - 18, 18, 18, 96, 19, 123, 18, 18, 18, 18, - 18, 18, 99, 100, 119, 120, 121, 70, 18, 99, - 100, 33, 148, 149, 18, 18, 18, 18, 116, 117, - 138, 139, 105, 18, 18, 18, 18, 119, 120, 148, - 149, 118, 18, 18, 18, 18, 108, 109, 113, 18, - 18, 122, 18, 18, 18, 18, 110, 19, 150, 19, - 112, 18, 18, 18, 18, 124, 125, 154, 19, 104, - 18, 18, 18, 18, 127, 128, 164, 165, 88, 18, - - 18, 18, 18, 115, 32, 101, 18, 18, 44, 18, - 18, 18, 116, 117, 164, 165, 91, 70, 18, 116, - 117, 166, 167, 87, 18, 18, 18, 18, 132, 133, - 168, 169, 80, 18, 18, 18, 18, 135, 19, 63, - 58, 56, 137, 18, 18, 18, 138, 139, 43, 124, - 125, 18, 18, 18, 140, 18, 124, 125, 33, 18, - 4, 18, 18, 18, 18, 127, 128, 110, 18, 18, - 142, 18, 18, 18, 18, 127, 128, 33, 33, 19, - 18, 18, 18, 18, 130, 32, 19, 18, 18, 44, - 18, 18, 18, 18, 144, 145, 170, 132, 133, 18, - - 18, 18, 147, 18, 132, 133, 5, 170, 170, 18, - 18, 18, 18, 135, 19, 170, 150, 19, 18, 18, - 18, 151, 18, 152, 128, 170, 154, 19, 18, 18, - 18, 155, 18, 156, 157, 170, 144, 145, 18, 18, - 18, 70, 18, 144, 145, 170, 170, 170, 18, 18, - 18, 18, 159, 19, 170, 170, 170, 161, 18, 18, - 18, 150, 19, 170, 152, 128, 18, 18, 18, 142, - 18, 152, 128, 170, 170, 170, 18, 18, 18, 18, - 154, 19, 170, 156, 157, 18, 18, 18, 70, 18, - 156, 157, 170, 170, 170, 18, 18, 18, 18, 159, - - 19, 170, 170, 170, 18, 18, 18, 18, 166, 167, - 170, 170, 170, 18, 18, 18, 18, 168, 169, 170, - 170, 170, 18, 18, 18, 3, 170, 170, 170, 170, - 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, - 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, - 170, 170, 170, 170 + 9, 11, 12, 9, 13, 9, 14, 9, 9, 9, + 9, 15, 16, 9, 9, 9, 17, 19, 20, 21, + 17, 17, 17, 22, 21, 21, 21, 23, 24, 21, + 25, 21, 26, 21, 21, 21, 21, 27, 28, 21, + 21, 21, 17, 29, 30, 32, 33, 36, 17, 17, + 17, 17, 29, 30, 35, 39, 38, 17, 17, 17, + 37, 31, 31, 31, 31, 32, 33, 35, 36, 31, + 37, 39, 38, 31, 32, 33, 34, 31, 31, 42, + 61, 56, 31, 31, 31, 31, 17, 29, 30, 31, + + 17, 17, 41, 17, 17, 43, 44, 45, 47, 48, + 57, 49, 31, 31, 31, 31, 58, 46, 62, 150, + 31, 31, 31, 63, 31, 50, 51, 66, 67, 64, + 65, 31, 17, 50, 51, 78, 31, 149, 17, 17, + 17, 17, 53, 18, 66, 67, 147, 55, 17, 17, + 17, 45, 30, 31, 60, 17, 41, 17, 17, 17, + 50, 51, 68, 69, 70, 17, 17, 17, 17, 53, + 18, 71, 72, 81, 17, 17, 17, 87, 31, 71, + 72, 31, 79, 80, 73, 74, 31, 31, 145, 88, + 89, 18, 90, 18, 91, 31, 17, 73, 74, 79, + + 80, 140, 17, 17, 17, 18, 31, 92, 31, 98, + 99, 31, 76, 76, 102, 100, 101, 76, 106, 103, + 76, 133, 31, 130, 107, 76, 77, 17, 64, 30, + 128, 83, 83, 41, 17, 17, 17, 84, 18, 31, + 96, 97, 86, 17, 17, 17, 68, 69, 31, 17, + 17, 41, 17, 17, 17, 73, 74, 98, 99, 123, + 17, 17, 17, 17, 93, 94, 135, 136, 121, 17, + 17, 17, 17, 96, 97, 125, 126, 118, 17, 17, + 17, 17, 84, 18, 135, 136, 117, 17, 17, 17, + 17, 89, 18, 116, 17, 17, 17, 17, 17, 17, + + 90, 18, 113, 17, 17, 17, 17, 17, 93, 94, + 31, 137, 18, 65, 17, 93, 94, 141, 18, 110, + 17, 17, 17, 17, 100, 101, 108, 17, 17, 109, + 17, 17, 17, 102, 18, 151, 152, 105, 17, 17, + 17, 17, 111, 112, 151, 152, 104, 17, 17, 17, + 17, 114, 115, 153, 154, 83, 17, 17, 17, 17, + 107, 30, 95, 17, 17, 41, 17, 17, 17, 119, + 120, 155, 156, 85, 17, 17, 17, 17, 122, 18, + 82, 75, 59, 124, 17, 17, 17, 125, 126, 54, + 111, 112, 17, 17, 17, 127, 17, 111, 112, 52, + + 40, 31, 17, 17, 17, 17, 114, 115, 17, 17, + 17, 129, 17, 17, 17, 114, 115, 4, 102, 31, + 17, 17, 17, 17, 117, 30, 31, 17, 17, 41, + 17, 17, 17, 131, 132, 18, 119, 120, 17, 17, + 17, 134, 17, 119, 120, 18, 157, 5, 17, 17, + 17, 17, 122, 18, 157, 137, 18, 17, 17, 17, + 138, 17, 139, 115, 157, 141, 18, 17, 17, 17, + 142, 17, 143, 144, 157, 131, 132, 17, 17, 17, + 65, 17, 131, 132, 157, 157, 157, 17, 17, 17, + 17, 146, 18, 157, 157, 157, 148, 17, 17, 17, + + 137, 18, 157, 139, 115, 17, 17, 17, 129, 17, + 139, 115, 157, 157, 157, 17, 17, 17, 17, 141, + 18, 157, 143, 144, 17, 17, 17, 65, 17, 143, + 144, 157, 157, 157, 17, 17, 17, 17, 146, 18, + 157, 157, 157, 17, 17, 17, 17, 153, 154, 157, + 157, 157, 17, 17, 17, 17, 155, 156, 157, 157, + 157, 17, 17, 17, 3, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157 + } ; -static yyconst short int yy_chk[655] = +static yyconst short int yy_chk[592] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 7, 7, + 2, 2, 2, 2, 2, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 9, 9, 9, 10, - 10, 13, 9, 9, 9, 11, 11, 11, 12, 16, - 14, 11, 11, 11, 14, 15, 13, 17, 25, 12, - 23, 23, 15, 26, 16, 29, 27, 28, 17, 25, - 27, 30, 11, 37, 28, 34, 34, 51, 26, 51, - - 29, 37, 30, 31, 31, 31, 36, 31, 31, 31, - 31, 31, 31, 38, 39, 40, 41, 36, 41, 42, - 46, 41, 40, 38, 45, 39, 47, 45, 50, 52, - 49, 50, 47, 46, 42, 49, 53, 53, 58, 58, - 39, 43, 43, 43, 202, 60, 60, 43, 43, 43, - 44, 44, 44, 62, 62, 52, 44, 44, 44, 48, - 48, 48, 201, 48, 48, 48, 48, 48, 48, 54, - 54, 60, 61, 200, 54, 56, 56, 56, 65, 62, - 65, 56, 56, 56, 57, 57, 57, 61, 66, 66, - 57, 57, 57, 63, 63, 63, 69, 67, 199, 63, - - 63, 63, 64, 71, 71, 76, 76, 198, 75, 197, - 64, 64, 67, 75, 66, 64, 78, 78, 64, 81, - 81, 78, 69, 64, 64, 68, 68, 68, 196, 68, - 68, 68, 68, 68, 68, 70, 70, 70, 82, 82, - 195, 70, 70, 70, 73, 73, 73, 194, 73, 73, - 73, 73, 73, 73, 80, 80, 80, 83, 84, 84, - 80, 80, 80, 86, 91, 91, 94, 193, 86, 102, - 102, 94, 83, 87, 87, 87, 106, 106, 98, 87, - 87, 87, 88, 88, 88, 93, 93, 192, 88, 88, - 88, 89, 89, 89, 191, 89, 89, 89, 89, 89, - - 89, 90, 90, 90, 98, 97, 190, 90, 90, 90, - 97, 93, 95, 95, 95, 114, 95, 95, 95, 95, - 95, 95, 96, 96, 96, 189, 96, 96, 96, 96, - 96, 96, 99, 99, 119, 119, 188, 99, 101, 101, - 101, 114, 136, 136, 101, 101, 101, 104, 104, 104, - 138, 138, 187, 104, 104, 104, 105, 105, 105, 148, - 148, 186, 105, 105, 105, 108, 108, 108, 185, 108, - 108, 108, 108, 108, 108, 110, 110, 110, 151, 151, - 184, 110, 110, 110, 112, 112, 112, 155, 155, 183, - 112, 112, 112, 113, 113, 113, 160, 160, 182, 113, - - 113, 113, 115, 115, 115, 181, 115, 115, 115, 115, - 115, 115, 116, 116, 164, 164, 180, 116, 118, 118, - 118, 166, 166, 179, 118, 118, 118, 121, 121, 121, - 168, 168, 178, 121, 121, 121, 122, 122, 122, 177, - 176, 175, 122, 122, 122, 123, 123, 123, 174, 124, - 124, 123, 123, 123, 124, 126, 126, 126, 173, 172, - 171, 126, 126, 126, 127, 127, 127, 111, 127, 127, - 127, 127, 127, 127, 129, 129, 129, 33, 22, 18, - 129, 129, 129, 130, 130, 130, 6, 130, 130, 130, - 130, 130, 130, 131, 131, 131, 3, 132, 132, 131, - - 131, 131, 132, 134, 134, 134, 1, 0, 0, 134, - 134, 134, 135, 135, 135, 0, 140, 140, 135, 135, - 135, 140, 141, 141, 141, 0, 142, 142, 141, 141, - 141, 142, 143, 143, 143, 0, 144, 144, 143, 143, - 143, 144, 146, 146, 146, 0, 0, 0, 146, 146, - 146, 147, 147, 147, 0, 0, 0, 147, 147, 147, - 150, 150, 150, 0, 152, 152, 150, 150, 150, 152, - 153, 153, 153, 0, 0, 0, 153, 153, 153, 154, - 154, 154, 0, 156, 156, 154, 154, 154, 156, 158, - 158, 158, 0, 0, 0, 158, 158, 158, 159, 159, - - 159, 0, 0, 0, 159, 159, 159, 162, 162, 162, - 0, 0, 0, 162, 162, 162, 163, 163, 163, 0, - 0, 0, 163, 163, 163, 170, 170, 170, 170, 170, - 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, - 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, - 170, 170, 170, 170 + 7, 7, 9, 9, 9, 10, 10, 13, 9, 9, + 9, 11, 11, 11, 12, 16, 15, 11, 11, 11, + 14, 13, 15, 14, 12, 22, 22, 24, 25, 16, + 26, 28, 27, 26, 32, 32, 11, 24, 27, 34, + 46, 42, 25, 42, 46, 28, 29, 29, 29, 34, + + 29, 29, 29, 29, 29, 35, 36, 37, 38, 39, + 43, 39, 35, 39, 38, 36, 44, 37, 47, 186, + 47, 44, 43, 48, 48, 50, 50, 54, 54, 49, + 50, 37, 40, 40, 40, 61, 61, 185, 40, 40, + 40, 41, 41, 41, 66, 66, 184, 41, 41, 41, + 45, 45, 45, 49, 45, 45, 45, 45, 45, 52, + 52, 52, 56, 56, 57, 52, 52, 52, 53, 53, + 53, 58, 58, 63, 53, 53, 53, 70, 57, 71, + 71, 70, 62, 62, 73, 73, 56, 63, 183, 73, + 76, 76, 77, 77, 78, 58, 59, 59, 59, 79, + + 79, 182, 59, 59, 59, 60, 62, 81, 78, 85, + 85, 81, 60, 60, 88, 87, 87, 60, 91, 88, + 60, 181, 91, 180, 92, 60, 60, 64, 64, 64, + 179, 64, 64, 64, 64, 64, 65, 65, 65, 87, + 96, 96, 65, 65, 65, 68, 68, 68, 92, 68, + 68, 68, 68, 68, 75, 75, 75, 98, 98, 178, + 75, 75, 75, 82, 82, 82, 123, 123, 177, 82, + 82, 82, 83, 83, 83, 125, 125, 176, 83, 83, + 83, 84, 84, 84, 135, 135, 106, 84, 84, 84, + 89, 89, 89, 175, 89, 89, 89, 89, 89, 90, + + 90, 90, 174, 90, 90, 90, 90, 90, 93, 93, + 106, 138, 138, 93, 95, 95, 95, 142, 142, 173, + 95, 95, 95, 100, 100, 100, 172, 100, 100, 100, + 100, 100, 102, 102, 102, 147, 147, 171, 102, 102, + 102, 104, 104, 104, 151, 151, 170, 104, 104, 104, + 105, 105, 105, 153, 153, 169, 105, 105, 105, 107, + 107, 107, 168, 107, 107, 107, 107, 107, 108, 108, + 108, 155, 155, 167, 108, 108, 108, 109, 109, 109, + 166, 165, 164, 109, 109, 109, 110, 110, 110, 163, + 111, 111, 110, 110, 110, 111, 113, 113, 113, 162, + + 161, 160, 113, 113, 113, 114, 114, 114, 159, 114, + 114, 114, 114, 114, 116, 116, 116, 158, 103, 31, + 116, 116, 116, 117, 117, 117, 21, 117, 117, 117, + 117, 117, 118, 118, 118, 17, 119, 119, 118, 118, + 118, 119, 121, 121, 121, 6, 3, 1, 121, 121, + 121, 122, 122, 122, 0, 127, 127, 122, 122, 122, + 127, 128, 128, 128, 0, 129, 129, 128, 128, 128, + 129, 130, 130, 130, 0, 131, 131, 130, 130, 130, + 131, 133, 133, 133, 0, 0, 0, 133, 133, 133, + 134, 134, 134, 0, 0, 0, 134, 134, 134, 137, + + 137, 137, 0, 139, 139, 137, 137, 137, 139, 140, + 140, 140, 0, 0, 0, 140, 140, 140, 141, 141, + 141, 0, 143, 143, 141, 141, 141, 143, 145, 145, + 145, 0, 0, 0, 145, 145, 145, 146, 146, 146, + 0, 0, 0, 146, 146, 146, 149, 149, 149, 0, + 0, 0, 149, 149, 149, 150, 150, 150, 0, 0, + 0, 150, 150, 150, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157 + } ; static yy_state_type yy_last_accepting_state; @@ -661,7 +642,9 @@ static char sccsid[] = "@(#)commands.l 5.13 (Berkeley) 7/24/90"; #include "port_before.h" #include <sys/types.h> +#include <netinet/in.h> #include "port_after.h" +#include <resolv.h> #include "res.h" extern char rootServerName[]; @@ -821,9 +804,11 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 110 "commands.l" +#line 112 "commands.l" + yy_cp = yy_bp = NULL; + if ( yy_init ) { yy_init = 0; @@ -874,13 +859,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 171 ) + if ( yy_current_state >= 158 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 626 ); + while ( yy_base[yy_current_state] != 565 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -911,7 +896,7 @@ case 1: yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 111 "commands.l" +#line 113 "commands.l" { /* * 0 == use current server to find @@ -928,7 +913,7 @@ case 2: yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 121 "commands.l" +#line 123 "commands.l" { SetDefaultServer(yytext, 1); return(1); @@ -939,7 +924,7 @@ case 3: yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 125 "commands.l" +#line 127 "commands.l" { return(0); } @@ -949,7 +934,7 @@ case 4: yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 128 "commands.l" +#line 130 "commands.l" { SetDefaultServer(rootServerName, 1); return(1); @@ -960,7 +945,7 @@ case 5: yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 132 "commands.l" +#line 134 "commands.l" { /* * 2nd arg. @@ -976,7 +961,7 @@ case 6: yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 141 "commands.l" +#line 143 "commands.l" { Finger(yytext, 0); return(1); @@ -987,18 +972,7 @@ case 7: yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 145 "commands.l" -{ - ViewList((char *)yytext); - return(1); - } - YY_BREAK -case 8: -*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ -yy_c_buf_p = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up yytext again */ -YY_RULE_SETUP -#line 149 "commands.l" +#line 147 "commands.l" { /* * 2nd arg. @@ -1009,23 +983,23 @@ YY_RULE_SETUP return(1); } YY_BREAK -case 9: +case 8: *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 158 "commands.l" +#line 156 "commands.l" { ListHosts(yytext, 0); return(1); } YY_BREAK -case 10: +case 9: *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 162 "commands.l" +#line 160 "commands.l" { /* * 2nd arg. @@ -1036,45 +1010,45 @@ YY_RULE_SETUP return(1); } YY_BREAK -case 11: +case 10: *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 171 "commands.l" +#line 169 "commands.l" { ListHostsByType(yytext, 0); return(1); } YY_BREAK -case 12: +case 11: *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 175 "commands.l" +#line 173 "commands.l" { SetOption(yytext); return(1); } YY_BREAK -case 13: +case 12: *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 179 "commands.l" +#line 177 "commands.l" { PrintHelp(); return(1); } YY_BREAK -case 14: +case 13: *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 183 "commands.l" +#line 181 "commands.l" { extern void PrintHelp(); @@ -1082,12 +1056,12 @@ YY_RULE_SETUP return(1); } YY_BREAK -case 15: +case 14: *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 189 "commands.l" +#line 187 "commands.l" { /* * 0 == output to stdout @@ -1097,23 +1071,23 @@ YY_RULE_SETUP return(1); } YY_BREAK -case 16: +case 15: *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 197 "commands.l" +#line 195 "commands.l" { LookupHost(yytext, 0); return(1); } YY_BREAK -case 17: +case 16: *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 201 "commands.l" +#line 199 "commands.l" { /* * 0 == output to stdout @@ -1123,41 +1097,41 @@ YY_RULE_SETUP return(1); } YY_BREAK -case 18: +case 17: *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 209 "commands.l" +#line 207 "commands.l" { LookupHostWithServer(yytext, 0); return(1); } YY_BREAK -case 19: +case 18: YY_RULE_SETUP -#line 213 "commands.l" +#line 211 "commands.l" { return(1); } YY_BREAK -case 20: +case 19: YY_RULE_SETUP -#line 216 "commands.l" +#line 214 "commands.l" { printf("Unrecognized command: %s", yytext); return(1); } YY_BREAK -case 21: +case 20: YY_RULE_SETUP -#line 221 "commands.l" +#line 219 "commands.l" { ; } YY_BREAK -case 22: +case 21: YY_RULE_SETUP -#line 222 "commands.l" +#line 220 "commands.l" ECHO; YY_BREAK case YY_STATE_EOF(INITIAL): @@ -1343,7 +1317,7 @@ static int yy_get_next_buffer() /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ - yy_n_chars = 0; + yy_current_buffer->yy_n_chars = yy_n_chars = 0; else { @@ -1398,6 +1372,8 @@ static int yy_get_next_buffer() /* Read in more data. */ YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; } if ( yy_n_chars == 0 ) @@ -1450,7 +1426,7 @@ static yy_state_type yy_get_previous_state() while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 171 ) + if ( yy_current_state >= 158 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1485,11 +1461,11 @@ yy_state_type yy_current_state; while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 171 ) + if ( yy_current_state >= 158 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 170); + yy_is_jam = (yy_current_state == 157); return yy_is_jam ? 0 : yy_current_state; } @@ -1523,7 +1499,8 @@ register char *yy_bp; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); - yy_n_chars = yy_current_buffer->yy_buf_size; + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); @@ -1566,13 +1543,26 @@ static int input() switch ( yy_get_next_buffer() ) { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /* fall through */ + case EOB_ACT_END_OF_FILE: { if ( yywrap() ) - { - yy_c_buf_p = yytext_ptr + offset; return EOF; - } if ( ! yy_did_buffer_switch_on_eof ) YY_NEW_FILE; @@ -1586,15 +1576,6 @@ static int input() case EOB_ACT_CONTINUE_SCAN: yy_c_buf_p = yytext_ptr + offset; break; - - case EOB_ACT_LAST_MATCH: -#ifdef __cplusplus - YY_FATAL_ERROR( - "unexpected last match in yyinput()" ); -#else - YY_FATAL_ERROR( - "unexpected last match in input()" ); -#endif } } } @@ -1759,6 +1740,9 @@ YY_BUFFER_STATE b; #endif { + if ( ! b ) + return; + b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes @@ -1818,17 +1802,17 @@ yy_size_t size; #ifndef YY_NO_SCAN_STRING #ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *str ) +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) #else -YY_BUFFER_STATE yy_scan_string( str ) -yyconst char *str; +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; #endif { int len; - for ( len = 0; str[len]; ++len ) + for ( len = 0; yy_str[len]; ++len ) ; - return yy_scan_bytes( str, len ); + return yy_scan_bytes( yy_str, len ); } #endif @@ -2037,5 +2021,5 @@ int main() return 0; } #endif -#line 222 "commands.l" +#line 220 "commands.l" diff --git a/contrib/bind/bin/nslookup/commands.l b/contrib/bind/bin/nslookup/commands.l index ff0d19b..f086118 100644 --- a/contrib/bind/bin/nslookup/commands.l +++ b/contrib/bind/bin/nslookup/commands.l @@ -97,6 +97,7 @@ static char sccsid[] = "@(#)commands.l 5.13 (Berkeley) 7/24/90"; #include <sys/types.h> #include <netinet/in.h> #include "port_after.h" +#include <resolv.h> #include "res.h" extern char rootServerName[]; @@ -105,9 +106,9 @@ extern void ViewList(char *); %} WS [ \t] -FLET [A-Za-z0-9.*\\_] -LET [A-Za-z0-9.*_] -NAME [A-Za-z0-9.*=_/-] +FLET [:A-Za-z0-9.*\\_] +LET [:A-Za-z0-9.*_] +NAME [:A-Za-z0-9.*=_/-] %% ^{WS}*server{WS}+{LET}{NAME}*{WS}*$ { /* diff --git a/contrib/bind/bin/nslookup/getinfo.c b/contrib/bind/bin/nslookup/getinfo.c index 68e3d75..e4fbb51 100644 --- a/contrib/bind/bin/nslookup/getinfo.c +++ b/contrib/bind/bin/nslookup/getinfo.c @@ -53,7 +53,7 @@ #ifndef lint static const char sccsid[] = "@(#)getinfo.c 5.26 (Berkeley) 3/21/91"; -static const char rcsid[] = "$Id: getinfo.c,v 8.20 2001/06/20 12:30:33 marka Exp $"; +static const char rcsid[] = "$Id: getinfo.c,v 8.23 2002/04/29 01:11:52 marka Exp $"; #endif /* not lint */ /* @@ -79,16 +79,19 @@ static const char rcsid[] = "$Id: getinfo.c,v 8.20 2001/06/20 12:30:33 marka Exp #include <arpa/inet.h> #include <ctype.h> -#include <resolv.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "port_after.h" +#include <resolv.h> + #include "res.h" static char *addr_list[MAXADDRS + 1]; +static int addr_len[MAXADDRS + 1]; +static int addr_type[MAXADDRS + 1]; static char *host_aliases[MAXALIASES]; static int host_aliases_len[MAXALIASES]; @@ -99,6 +102,8 @@ typedef struct { char *domain[MAXDOMAINS]; int numDomains; char *address[MAXADDRS]; + char len[MAXADDRS]; + char type[MAXADDRS]; int numAddresses; } ServerTable; @@ -136,14 +141,16 @@ typedef union { */ static int -GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer) - struct in_addr *nsAddrPtr; +GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer, + merge) + union res_sockaddr_union *nsAddrPtr; char *msg; int queryType; int msglen; Boolean iquery; register HostInfo *hostPtr; Boolean isServer; + Boolean merge; { register HEADER *headerPtr; register const u_char *cp; @@ -151,6 +158,8 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer) char **aliasPtr; u_char *eom, *bp; char **addrPtr; + int *lenPtr; + int *typePtr; char *namePtr; char *dnamePtr; int type, class; @@ -158,19 +167,26 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer) int origClass = 0; int numAliases = 0; int numAddresses = 0; - int n, i, j; + int n, i, j, k, l, m; int dlen; int status; int numServers; size_t s; Boolean haveAnswer; Boolean printedAnswers = FALSE; + int oldAliases; + char **newAliases; + int oldServers; + ServerInfo **newServers; + int oldAddresses; + AddrInfo **newAddresses; /* * If the hostPtr was used before, free up the calloc'd areas. */ - FreeHostInfoPtr(hostPtr); + if (!merge) + FreeHostInfoPtr(hostPtr); status = SendRequest(nsAddrPtr, (u_char *)msg, msglen, (u_char *) &answer, sizeof(answer), &n); @@ -218,6 +234,8 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer) aliasPtr = host_aliases; addrPtr = addr_list; + lenPtr = addr_len; + typePtr = addr_type; haveAnswer = FALSE; /* @@ -234,7 +252,8 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer) printf("Non-authoritative answer:\n"); } - if (queryType != T_A && !(iquery && queryType == T_PTR)) { + if (queryType != T_A && queryType != T_AAAA && /* A6? */ + !(iquery && queryType == T_PTR)) { while (--ancount >= 0 && cp < eom) { if ((cp = Print_rr(cp, (u_char *)&answer, eom, stdout)) == NULL) { @@ -286,36 +305,34 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer) memcpy(hostPtr->name, bp, s); haveAnswer = TRUE; break; - } else if (type != T_A) { + } else if (type != T_A && type != T_AAAA) { cp += dlen; continue; } - if (dlen != INADDRSZ) + if (type == T_A && dlen != INADDRSZ) + return (ERROR); + if (type == T_AAAA && dlen != 16) return (ERROR); if (haveAnswer) { /* * If we've already got 1 address, we aren't interested - * in addresses with a different length or class. + * in addresses with a different class. */ - if (dlen != hostPtr->addrLen) { - cp += dlen; - continue; - } if (class != origClass) { cp += dlen; continue; } } else { /* - * First address: record its length and class so we - * only save additonal ones with the same attributes. + * First address: record its class so we only save + * additonal ones with the same attributes. */ - hostPtr->addrLen = dlen; origClass = class; - hostPtr->addrType = (class == C_IN) ? AF_INET : AF_UNSPEC; - s = strlen((char *)bp) + 1; - hostPtr->name = Calloc(1, s); - memcpy(hostPtr->name, bp, s); + if (hostPtr->name == NULL) { + s = strlen((char *)bp) + 1; + hostPtr->name = Calloc(1, s); + memcpy(hostPtr->name, bp, s); + } } bp += (((u_int32_t)bp) % sizeof(align)); @@ -331,6 +348,10 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer) continue; } memcpy(*addrPtr++ = (char *)bp, cp, dlen); + *lenPtr++ = dlen; + *typePtr++ = (class == C_IN) ? + ((type == T_A) ? AF_INET : AF_INET6) : + AF_UNSPEC; bp += dlen; cp += dlen; numAddresses++; @@ -346,24 +367,70 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer) * in the hostPtr variable. */ + oldAliases = 0; + if (merge && hostPtr->aliases != NULL) { + while (hostPtr->aliases[oldAliases] != NULL) + oldAliases++; + } if (numAliases > 0) { - hostPtr->aliases = - (char **) Calloc(1 + numAliases, sizeof(char *)); + newAliases = + (char **) Calloc(1 + numAliases + oldAliases, sizeof(char *)); + if (merge && hostPtr->aliases != NULL) { + memcpy(newAliases, hostPtr->aliases, + oldAliases * sizeof(char *)); + free(hostPtr->aliases); + } + hostPtr->aliases = newAliases; + k = oldAliases; for (i = 0; i < numAliases; i++) { - hostPtr->aliases[i] = Calloc(1, host_aliases_len[i]); - memcpy(hostPtr->aliases[i], host_aliases[i], + for (l = 0; l < k; l++) + if (!strcasecmp(hostPtr->aliases[l], host_aliases[i])) + break; + if (l < k) { + free(host_aliases[i]); + continue; + } + hostPtr->aliases[k] = Calloc(1, host_aliases_len[i]); + memcpy(hostPtr->aliases[k], host_aliases[i], host_aliases_len[i]); + k++; } - hostPtr->aliases[i] = NULL; + hostPtr->aliases[k] = NULL; + } + oldAddresses = 0; + if (merge && hostPtr->addrList != NULL) { + while (hostPtr->addrList[oldAddresses] != NULL) + oldAddresses++; } if (numAddresses > 0) { - hostPtr->addrList = - (char **)Calloc(1+numAddresses, sizeof(char *)); + newAddresses = + (AddrInfo **)Calloc(1+numAddresses, sizeof(AddrInfo *)); + if (merge && hostPtr->addrList != NULL) { + memcpy(newAddresses, hostPtr->addrList, + oldAddresses * sizeof(char *)); + free(hostPtr->addrList); + } + hostPtr->addrList = newAddresses; + k = oldAddresses; for (i = 0; i < numAddresses; i++) { - hostPtr->addrList[i] = Calloc(1, hostPtr->addrLen); - memcpy(hostPtr->addrList[i], addr_list[i], hostPtr->addrLen); + for (l = 0; l < k; l++) + if (hostPtr->addrList[l]->addrType == addr_type[i] && + hostPtr->addrList[l]->addrLen == addr_len[i] && + !memcmp(hostPtr->addrList[l]->addr, addr_list[i], + addr_len[i])) + break; + if (l < k) { + free(addr_list[i]); + continue; + } + hostPtr->addrList[k] = (AddrInfo*)Calloc(1, sizeof(AddrInfo)); + hostPtr->addrList[k]->addr = Calloc(1, addr_len[i]); + hostPtr->addrList[k]->addrType = addr_type[i]; + hostPtr->addrList[k]->addrLen = addr_len[i]; + memcpy(hostPtr->addrList[k]->addr, addr_list[i], addr_len[i]); + k++; } - hostPtr->addrList[i] = NULL; + hostPtr->addrList[k] = NULL; } #ifdef verbose if (headerPtr->aa || nscount == 0) { @@ -382,7 +449,8 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer) * in the additional resource records part. */ - if (!headerPtr->aa && (queryType != T_A) && (nscount > 0 || arcount > 0)) { + if (!headerPtr->aa && (queryType != T_A) && (queryType != T_AAAA) && + (nscount > 0 || arcount > 0)) { if (printedAnswers) { putchar('\n'); } @@ -392,7 +460,7 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer) cp = res_skip((u_char *)&answer, 2, eom); numServers = 0; - if (queryType != T_A) { + if (queryType != T_A && queryType != T_AAAA) { /* * If we don't need to save the record, just print it. */ @@ -446,7 +514,7 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer) */ found = FALSE; for (j = 0; j < numServers; j++) { - if (strcmp(namePtr, server[j].name) == 0) { + if (strcasecmp(namePtr, server[j].name) == 0) { found = TRUE; free(namePtr); break; @@ -502,20 +570,25 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer) if (cp + dlen > eom) return (ERROR); - if (type != T_A) { + if (type != T_A && type != T_AAAA) { cp += dlen; continue; } else { - if (dlen != INADDRSZ) + if (type == T_A && dlen != INADDRSZ) + return (ERROR); + if (type == T_AAAA && dlen != 16) return (ERROR); for (j = 0; j < numServers; j++) { - if (strcmp((char *)bp, server[j].name) == 0) { + if (strcasecmp((char *)bp, server[j].name) == 0) { server[j].numAddresses++; if (server[j].numAddresses <= MAXADDRS) { server[j].address[server[j].numAddresses-1] = Calloc(1,dlen); memcpy(server[j].address[server[j].numAddresses-1], cp, dlen); + server[j].len[server[j].numAddresses-1] = dlen; + server[j].type[server[j].numAddresses-1] = + (type == T_A) ? AF_INET : AF_INET6; break; } } @@ -528,35 +601,88 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer) /* * If we are returning name server info, transfer it to the hostPtr. */ + oldServers = 0; + if (merge && hostPtr->servers != NULL) { + while (hostPtr->servers[oldServers] != NULL) + oldServers++; + } if (numServers > 0) { - hostPtr->servers = (ServerInfo **) - Calloc(numServers+1, sizeof(ServerInfo *)); - + newServers = (ServerInfo **) Calloc(numServers+oldServers+1, + sizeof(ServerInfo *)); + if (merge && hostPtr->servers != NULL) { + memcpy(newServers, hostPtr->servers, + oldServers * sizeof(ServerInfo *)); + free(hostPtr->servers); + } + hostPtr->servers = newServers; + k = oldServers; for (i = 0; i < numServers; i++) { - hostPtr->servers[i] = (ServerInfo *) Calloc(1, sizeof(ServerInfo)); - hostPtr->servers[i]->name = server[i].name; - + for (l = 0; l < k; l++) + if (!strcasecmp(hostPtr->servers[l]->name, server[i].name)) + break; + if (l < k) { + free(server[i].name); + for (j = 0; j < server[i].numDomains; j++) + free(server[i].domain[j]); + } else { + hostPtr->servers[l] = (ServerInfo *) + Calloc(1, sizeof(ServerInfo)); + hostPtr->servers[l]->name = server[i].name; + k++; - hostPtr->servers[i]->domains = (char **) + hostPtr->servers[l]->domains = (char **) Calloc(server[i].numDomains+1,sizeof(char *)); - for (j = 0; j < server[i].numDomains; j++) { - hostPtr->servers[i]->domains[j] = server[i].domain[j]; + for (j = 0; j < server[i].numDomains; j++) { + hostPtr->servers[l]->domains[j] = server[i].domain[j]; + } + hostPtr->servers[l]->domains[j] = NULL; } - hostPtr->servers[i]->domains[j] = NULL; - hostPtr->servers[i]->addrList = (char **) - Calloc(server[i].numAddresses+1,sizeof(char *)); - for (j = 0; j < server[i].numAddresses; j++) { - hostPtr->servers[i]->addrList[j] = server[i].address[j]; + oldAddresses = 0; + if (merge && hostPtr->servers[l]->addrList != NULL) + while (hostPtr->servers[l]->addrList[oldAddresses] != NULL) + oldAddresses++; + newAddresses = (AddrInfo **) + Calloc(server[i].numAddresses+oldAddresses+1, + sizeof(AddrInfo *)); + if (merge && hostPtr->servers[l]->addrList != NULL) { + memcpy(newAddresses, hostPtr->servers[l]->addrList, + sizeof(AddrInfo *) * oldAddresses); + free(hostPtr->servers[l]->addrList); } - hostPtr->servers[i]->addrList[j] = NULL; - + hostPtr->servers[l]->addrList = newAddresses; + m = oldAddresses; + for (j = 0; j < server[l].numAddresses; j++) { + for (n = 0; n < m; n++) + if (hostPtr->servers[l]->addrList[n]->addrType == + server[i].type[j] && + hostPtr->servers[l]->addrList[n]->addrLen == + server[i].len[j] && + !memcmp(hostPtr->servers[l]->addrList[n]->addr, + server[i].address[j], server[i].len[j])) + break; + if (n < m) { + free(server[i].address[j]); + continue; + } + hostPtr->servers[l]->addrList[m] = + (AddrInfo*)Calloc(1, sizeof(AddrInfo)); + hostPtr->servers[l]->addrList[m]->addr = + server[i].address[j]; + hostPtr->servers[l]->addrList[m]->addrType = + server[i].type[j]; + hostPtr->servers[l]->addrList[m]->addrLen = + server[i].len[j]; + m++; + } + hostPtr->servers[l]->addrList[m] = NULL; } - hostPtr->servers[i] = NULL; + hostPtr->servers[k] = NULL; } switch (queryType) { + case T_AAAA: case T_A: return NONAUTH; case T_PTR: @@ -586,20 +712,22 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer) */ int -GetHostInfoByName(nsAddrPtr, queryClass, queryType, name, hostPtr, isServer) - struct in_addr *nsAddrPtr; +GetHostInfoByName(nsAddrPtr, queryClass, queryType, name, hostPtr, isServer, + merge) + union res_sockaddr_union *nsAddrPtr; int queryClass; int queryType; const char *name; HostInfo *hostPtr; Boolean isServer; + Boolean merge; { int n; register int result; register char **domain; const char *cp; Boolean got_nodata = FALSE; - struct in_addr ina; + union res_sockaddr_union ina; Boolean tried_as_is = FALSE; char tmp[NS_MAXDNAME]; @@ -607,14 +735,30 @@ GetHostInfoByName(nsAddrPtr, queryClass, queryType, name, hostPtr, isServer) if ((queryType == T_A) && IsAddr(name, &ina)) { hostPtr->name = Calloc(strlen(name)+3, 1); (void)sprintf(hostPtr->name,"[%s]",name); - hostPtr->aliases = NULL; - hostPtr->servers = NULL; - hostPtr->addrType = AF_INET; - hostPtr->addrLen = INADDRSZ; - hostPtr->addrList = (char **)Calloc(2, sizeof(char *)); - hostPtr->addrList[0] = Calloc(INT32SZ, sizeof(char)); - memcpy(hostPtr->addrList[0], &ina, INADDRSZ); - hostPtr->addrList[1] = NULL; + switch (ina.sin.sin_family) { + case AF_INET: + hostPtr->aliases = NULL; + hostPtr->servers = NULL; + hostPtr->addrList = (AddrInfo **)Calloc(2, sizeof(AddrInfo *)); + hostPtr->addrList[0] = (AddrInfo *)Calloc(1, sizeof(AddrInfo)); + hostPtr->addrList[0]->addr = Calloc(INT32SZ, sizeof(char)); + memcpy(hostPtr->addrList[0]->addr, &ina.sin.sin_addr, INADDRSZ); + hostPtr->addrList[0]->addrType = AF_INET; + hostPtr->addrList[0]->addrLen = INADDRSZ; + hostPtr->addrList[1] = NULL; + break; + case AF_INET6: + hostPtr->aliases = NULL; + hostPtr->servers = NULL; + hostPtr->addrList = (AddrInfo **)Calloc(2, sizeof(AddrInfo *)); + hostPtr->addrList[0] = (AddrInfo *)Calloc(1, sizeof(AddrInfo)); + hostPtr->addrList[0]->addr = Calloc(1, 16); + memcpy(hostPtr->addrList[0]->addr, &ina.sin6.sin6_addr, 16); + hostPtr->addrList[0]->addrType = AF_INET6; + hostPtr->addrList[0]->addrLen = 16; + hostPtr->addrList[1] = NULL; + break; + } return(SUCCESS); } @@ -625,7 +769,7 @@ GetHostInfoByName(nsAddrPtr, queryClass, queryType, name, hostPtr, isServer) if (n == 0 && (cp = res_hostalias(&res, name, tmp, sizeof tmp))) { printf("Aliased to \"%s\"\n\n", cp); return (GetHostDomain(nsAddrPtr, queryClass, queryType, - cp, (char *)NULL, hostPtr, isServer)); + cp, (char *)NULL, hostPtr, isServer, merge)); } /* @@ -634,7 +778,8 @@ GetHostInfoByName(nsAddrPtr, queryClass, queryType, name, hostPtr, isServer) */ if (n >= (int)res.ndots) { result = GetHostDomain(nsAddrPtr, queryClass, queryType, - name, (char *)NULL, hostPtr, isServer); + name, (char *)NULL, hostPtr, isServer, + merge); if (result == SUCCESS) return (result); if (result == NO_INFO) @@ -652,7 +797,8 @@ GetHostInfoByName(nsAddrPtr, queryClass, queryType, name, hostPtr, isServer) (n != 0 && *--cp != '.' && (res.options & RES_DNSRCH) != 0)) for (domain = res.dnsrch; *domain != NULL; domain++) { result = GetHostDomain(nsAddrPtr, queryClass, queryType, - name, *domain, hostPtr, isServer); + name, *domain, hostPtr, isServer, + merge); /* * If no server present, give up. * If name isn't found in this domain, @@ -679,7 +825,7 @@ GetHostInfoByName(nsAddrPtr, queryClass, queryType, name, hostPtr, isServer) */ if (!tried_as_is && (result = GetHostDomain(nsAddrPtr, queryClass, queryType, - name, (char *)NULL, hostPtr, isServer) + name, (char *)NULL, hostPtr, isServer, merge) ) == SUCCESS) return (result); if (got_nodata) @@ -692,14 +838,16 @@ GetHostInfoByName(nsAddrPtr, queryClass, queryType, name, hostPtr, isServer) * removing a trailing dot from name if domain is NULL. */ int -GetHostDomain(nsAddrPtr, queryClass, queryType, name, domain, hostPtr, isServer) - struct in_addr *nsAddrPtr; +GetHostDomain(nsAddrPtr, queryClass, queryType, name, domain, hostPtr, + isServer, merge) + union res_sockaddr_union *nsAddrPtr; int queryClass; int queryType; const char *name; char *domain; HostInfo *hostPtr; Boolean isServer; + Boolean merge; { querybuf buf; char nbuf[2*MAXDNAME+2]; @@ -731,7 +879,8 @@ GetHostDomain(nsAddrPtr, queryClass, queryType, name, domain, hostPtr, isServer) return (ERROR); } - n = GetAnswer(nsAddrPtr, queryType, (char *)&buf, n, 0, hostPtr, isServer); + n = GetAnswer(nsAddrPtr, queryType, (char *)&buf, n, 0, hostPtr, + isServer, merge); /* * GetAnswer didn't find a name, so set it to the specified one. @@ -764,21 +913,76 @@ GetHostDomain(nsAddrPtr, queryClass, queryType, name, domain, hostPtr, isServer) */ int -GetHostInfoByAddr(nsAddrPtr, address, hostPtr) - struct in_addr *nsAddrPtr; - struct in_addr *address; - HostInfo *hostPtr; +GetHostInfoByAddr(union res_sockaddr_union *nsAddrPtr, + union res_sockaddr_union *address, + HostInfo * hostPtr) { int n; querybuf buf; char qbuf[MAXDNAME]; - char *p = (char *) &address->s_addr; - - (void)sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa", - ((unsigned)p[3] & 0xff), - ((unsigned)p[2] & 0xff), - ((unsigned)p[1] & 0xff), - ((unsigned)p[0] & 0xff)); + char qbuf2[MAXDNAME]; + char *p = NULL; + int ismapped = 0; + + switch (address->sin.sin_family) { + case AF_INET: + p = (char *) &address->sin.sin_addr.s_addr; + mapped: + (void)sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa", + ((unsigned)p[3 + (ismapped ? 12 : 0)] & 0xff), + ((unsigned)p[2 + (ismapped ? 12 : 0)] & 0xff), + ((unsigned)p[1 + (ismapped ? 12 : 0)] & 0xff), + ((unsigned)p[0 + (ismapped ? 12 : 0)] & 0xff)); + break; + case AF_INET6: + p = (char *)address->sin6.sin6_addr.s6_addr; + if (IN6_IS_ADDR_V4MAPPED(&address->sin6.sin6_addr) || + IN6_IS_ADDR_V4COMPAT(&address->sin6.sin6_addr)) { + ismapped = 1; + goto mapped; + } + (void)sprintf(qbuf, + "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x." + "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x." + "ip6.arpa", + p[15] & 0xf, (p[15] >> 4) & 0xf, + p[14] & 0xf, (p[14] >> 4) & 0xf, + p[13] & 0xf, (p[13] >> 4) & 0xf, + p[12] & 0xf, (p[12] >> 4) & 0xf, + p[11] & 0xf, (p[11] >> 4) & 0xf, + p[10] & 0xf, (p[10] >> 4) & 0xf, + p[9] & 0xf, (p[9] >> 4) & 0xf, + p[8] & 0xf, (p[8] >> 4) & 0xf, + p[7] & 0xf, (p[7] >> 4) & 0xf, + p[6] & 0xf, (p[4] >> 4) & 0xf, + p[5] & 0xf, (p[5] >> 4) & 0xf, + p[4] & 0xf, (p[4] >> 4) & 0xf, + p[3] & 0xf, (p[3] >> 4) & 0xf, + p[2] & 0xf, (p[2] >> 4) & 0xf, + p[1] & 0xf, (p[1] >> 4) & 0xf, + p[0] & 0xf, (p[0] >> 4) & 0xf); + (void)sprintf(qbuf2, + "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x." + "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x." + "ip6.int", + p[15] & 0xf, (p[15] >> 4) & 0xf, + p[14] & 0xf, (p[14] >> 4) & 0xf, + p[13] & 0xf, (p[13] >> 4) & 0xf, + p[12] & 0xf, (p[12] >> 4) & 0xf, + p[11] & 0xf, (p[11] >> 4) & 0xf, + p[10] & 0xf, (p[10] >> 4) & 0xf, + p[9] & 0xf, (p[9] >> 4) & 0xf, + p[8] & 0xf, (p[8] >> 4) & 0xf, + p[7] & 0xf, (p[7] >> 4) & 0xf, + p[6] & 0xf, (p[4] >> 4) & 0xf, + p[5] & 0xf, (p[5] >> 4) & 0xf, + p[4] & 0xf, (p[4] >> 4) & 0xf, + p[3] & 0xf, (p[3] >> 4) & 0xf, + p[2] & 0xf, (p[2] >> 4) & 0xf, + p[1] & 0xf, (p[1] >> 4) & 0xf, + p[0] & 0xf, (p[0] >> 4) & 0xf); + break; + } n = res_nmkquery(&res, QUERY, qbuf, C_IN, T_PTR, NULL, 0, NULL, buf.qb2, sizeof buf); if (n < 0) { @@ -787,13 +991,47 @@ GetHostInfoByAddr(nsAddrPtr, address, hostPtr) } return (ERROR); } - n = GetAnswer(nsAddrPtr, T_PTR, (char *) &buf, n, 1, hostPtr, 1); + n = GetAnswer(nsAddrPtr, T_PTR, (char *) &buf, n, 1, hostPtr, 1, 0); + if (n == SUCCESS) { + switch (address->sin.sin_family) { + case AF_INET: + hostPtr->addrList = (AddrInfo **)Calloc(2, sizeof(AddrInfo *)); + hostPtr->addrList[0] = (AddrInfo *)Calloc(1, sizeof(AddrInfo)); + hostPtr->addrList[0]->addr = Calloc(INT32SZ, sizeof(char)); + memcpy(hostPtr->addrList[0]->addr, p, INADDRSZ); + hostPtr->addrList[0]->addrType = AF_INET; + hostPtr->addrList[0]->addrLen = 4; + hostPtr->addrList[1] = NULL; + break; + case AF_INET6: + hostPtr->addrList = (AddrInfo **)Calloc(2, sizeof(AddrInfo *)); + hostPtr->addrList[0] = (AddrInfo *)Calloc(1, sizeof(AddrInfo)); + hostPtr->addrList[0]->addr = Calloc(16, sizeof(char)); + memcpy(hostPtr->addrList[0]->addr, p, 16); + hostPtr->addrList[0]->addrType = AF_INET6; + hostPtr->addrList[0]->addrLen = 16; + hostPtr->addrList[1] = NULL; + break; + } + } + if (n == SUCCESS || ismapped || address->sin.sin_family != AF_INET6) + return n; + n = res_nmkquery(&res, QUERY, qbuf2, C_IN, T_PTR, NULL, 0, NULL, + buf.qb2, sizeof buf); + if (n < 0) { + if (res.options & RES_DEBUG) { + printf("res_nmkquery() failed\n"); + } + return (ERROR); + } + n = GetAnswer(nsAddrPtr, T_PTR, (char *) &buf, n, 1, hostPtr, 1, 0); if (n == SUCCESS) { - hostPtr->addrType = AF_INET; - hostPtr->addrLen = 4; - hostPtr->addrList = (char **)Calloc(2, sizeof(char *)); - hostPtr->addrList[0] = Calloc(INT32SZ, sizeof(char)); - memcpy(hostPtr->addrList[0], p, INADDRSZ); + hostPtr->addrList = (AddrInfo **)Calloc(2, sizeof(AddrInfo *)); + hostPtr->addrList[0] = (AddrInfo *)Calloc(1, sizeof(AddrInfo *)); + hostPtr->addrList[0]->addr = Calloc(16, sizeof(char)); + memcpy(hostPtr->addrList[0]->addr, p, 16); + hostPtr->addrList[0]->addrType = AF_INET6; + hostPtr->addrList[0]->addrLen = 16; hostPtr->addrList[1] = NULL; } return n; @@ -833,6 +1071,7 @@ FreeHostInfoPtr(hostPtr) if (hostPtr->addrList != NULL) { i = 0; while (hostPtr->addrList[i] != NULL) { + free(hostPtr->addrList[i]->addr); free(hostPtr->addrList[i]); i++; } @@ -860,6 +1099,7 @@ FreeHostInfoPtr(hostPtr) if (hostPtr->servers[i]->addrList != NULL) { j = 0; while (hostPtr->servers[i]->addrList[j] != NULL) { + free(hostPtr->servers[i]->addrList[j]->addr); free(hostPtr->servers[i]->addrList[j]); j++; } diff --git a/contrib/bind/bin/nslookup/list.c b/contrib/bind/bin/nslookup/list.c index c910230..3255a19 100644 --- a/contrib/bind/bin/nslookup/list.c +++ b/contrib/bind/bin/nslookup/list.c @@ -53,7 +53,7 @@ #ifndef lint static const char sccsid[] = "@(#)list.c 5.23 (Berkeley) 3/21/91"; -static const char rcsid[] = "$Id: list.c,v 8.26 2001/06/18 14:43:38 marka Exp $"; +static const char rcsid[] = "$Id: list.c,v 8.27 2002/04/09 05:55:17 marka Exp $"; #endif /* not lint */ /* @@ -258,7 +258,9 @@ ListSubr(int qtype, char *domain, char *cmd) { ns_msg handle; querybuf buf; - struct sockaddr_in sin; + struct sockaddr_storage sa; + struct sockaddr_in *sin; + struct sockaddr_in6 *sin6; HEADER *headerPtr; int msglen, amtToRead, numRead, soacnt; u_int len; @@ -269,6 +271,8 @@ ListSubr(int qtype, char *domain, char *cmd) { enum { NO_ERRORS, ERR_READING_LEN, ERR_READING_MSG, ERR_PRINTING } error = NO_ERRORS; struct iovec iov[2]; + AddrInfo *AddrPtr; + int salen = 0; /* * Create a query packet for the requested domain name. @@ -281,10 +285,6 @@ ListSubr(int qtype, char *domain, char *cmd) { return (ERROR); } - memset(&sin, 0, sizeof sin); - sin.sin_family = AF_INET; - sin.sin_port = htons(nsport); - /* * Check to see if we have the address of the server or the * address of a server who knows about this domain. @@ -293,20 +293,44 @@ ListSubr(int qtype, char *domain, char *cmd) { */ if (defaultPtr->addrList != NULL) - sin.sin_addr = *(struct in_addr *) defaultPtr->addrList[0]; + AddrPtr = defaultPtr->addrList[0]; else - sin.sin_addr = *(struct in_addr *) - defaultPtr->servers[0]->addrList[0]; + AddrPtr = defaultPtr->servers[0]->addrList[0]; + + memset(&sa, 0, sizeof sa); + switch (AddrPtr->addrType) { + case AF_INET: + sin = (struct sockaddr_in *)&sa; + sin->sin_family = AddrPtr->addrType; + sin->sin_port = htons(nsport); + memcpy(&sin->sin_addr, AddrPtr->addr, AddrPtr->addrLen); +#ifdef HAVE_SA_LEN + sin->sin_len = sizeof(*sin); +#endif + salen = sizeof(struct sockaddr_in); + break; + + case AF_INET6: + sin6 = (struct sockaddr_in6 *)&sa; + sin6->sin6_family = AddrPtr->addrType; + sin6->sin6_port = htons(nsport); + memcpy(&sin6->sin6_addr, AddrPtr->addr, AddrPtr->addrLen); +#ifdef HAVE_SA_LEN + sin6->sin6_len = sizeof(*sin6); +#endif + salen = sizeof(struct sockaddr_in6); + break; + } /* * Set up a virtual circuit to the server. */ - sockFD = socket(AF_INET, SOCK_STREAM, 0); + sockFD = socket(AddrPtr->addrType, SOCK_STREAM, 0); if (sockFD < 0) { perror("ls: socket"); return (ERROR); } - if (connect(sockFD, (struct sockaddr *)&sin, sizeof(sin)) < 0) { + if (connect(sockFD, (struct sockaddr *)&sa, salen) < 0) { int e; if (errno == ECONNREFUSED) @@ -530,13 +554,16 @@ Finger(string, putToFile) int putToFile; { struct servent *sp; - struct sockaddr_in sin; + struct sockaddr_storage sa; + struct sockaddr_in *sin; + struct sockaddr_in6 *sin6; FILE *f; int c; int lastc; char name[NAME_LEN]; char file[PATH_MAX]; int i; + int salen = 0; /* * We need a valid current host info to get an inet address. @@ -573,23 +600,45 @@ Finger(string, putToFile) return (ERROR); } - memset(&sin, 0, sizeof sin); - sin.sin_family = curHostInfo.addrType; - sin.sin_port = sp->s_port; - memcpy(&sin.sin_addr, curHostInfo.addrList[0], curHostInfo.addrLen); + memset(&sa, 0, sizeof sa); + switch (curHostInfo.addrList[0]->addrType) { + case AF_INET: + sin = (struct sockaddr_in *)&sa; + sin->sin_family = curHostInfo.addrList[0]->addrType; + sin->sin_port = sp->s_port; + memcpy(&sin->sin_addr, curHostInfo.addrList[0]->addr, + curHostInfo.addrList[0]->addrLen); +#ifdef HAVE_SA_LEN + sin->sin_len = sizeof(*sin); +#endif + salen = sizeof(struct sockaddr_in); + break; + + case AF_INET6: + sin6 = (struct sockaddr_in6 *)&sa; + sin6->sin6_family = curHostInfo.addrList[0]->addrType; + sin6->sin6_port = sp->s_port; + memcpy(&sin6->sin6_addr, curHostInfo.addrList[0]->addr, + curHostInfo.addrList[0]->addrLen); +#ifdef HAVE_SA_LEN + sin6->sin6_len = sizeof(*sin6); +#endif + salen = sizeof(struct sockaddr_in6); + break; + } /* * Set up a virtual circuit to the host. */ - sockFD = socket(curHostInfo.addrType, SOCK_STREAM, 0); + sockFD = socket(curHostInfo.addrList[0]->addrType, SOCK_STREAM, 0); if (sockFD < 0) { fflush(stdout); perror("finger: socket"); return (ERROR); } - if (connect(sockFD, (struct sockaddr *)&sin, sizeof (sin)) < 0) { + if (connect(sockFD, (struct sockaddr *)&sa, salen) < 0) { fflush(stdout); perror("finger: connect"); close(sockFD); diff --git a/contrib/bind/bin/nslookup/main.c b/contrib/bind/bin/nslookup/main.c index 6827c09..38e1014 100644 --- a/contrib/bind/bin/nslookup/main.c +++ b/contrib/bind/bin/nslookup/main.c @@ -77,7 +77,7 @@ char copyright[] = #ifndef lint static const char sccsid[] = "@(#)main.c 5.42 (Berkeley) 3/3/91"; -static const char rcsid[] = "$Id: main.c,v 8.20 2001/06/20 12:40:06 marka Exp $"; +static const char rcsid[] = "$Id: main.c,v 8.22 2002/04/12 03:03:49 marka Exp $"; #endif /* not lint */ /* @@ -108,7 +108,6 @@ static const char rcsid[] = "$Id: main.c,v 8.20 2001/06/20 12:40:06 marka Exp $" #include <errno.h> #include <limits.h> #include <netdb.h> -#include <resolv.h> #include <setjmp.h> #include <signal.h> #include <stdio.h> @@ -118,6 +117,8 @@ static const char rcsid[] = "$Id: main.c,v 8.20 2001/06/20 12:40:06 marka Exp $" #include "port_after.h" +#include <resolv.h> + #include "res.h" #include "pathnames.h" @@ -154,7 +155,7 @@ int curHostValid = FALSE; HostInfo *defaultPtr = NULL; char defaultServer[NAME_LEN]; -struct in_addr defaultAddr; +union res_sockaddr_union defaultAddr; /* @@ -189,6 +190,31 @@ static void res_re_init(void); static void res_dnsrch(char *cp); static void Usage(void); static void ShowOptions(void); + +static void +UnionFromAddr(union res_sockaddr_union *u, int family, void *addr) { + memset(u, 0, sizeof *u); + switch (family) { + case AF_INET: + u->sin.sin_family = AF_INET; + u->sin.sin_port = htons(nsport); + memcpy(&u->sin.sin_addr, addr, 4); +#ifdef HAVE_SA_LEN + u->sin.sin_len = sizeof(u->sin); +#endif + break; + case AF_INET6: + u->sin6.sin6_family = AF_INET6; + u->sin6.sin6_port = htons(nsport); + memcpy(&u->sin6.sin6_addr, addr, 16); +#ifdef HAVE_SA_LEN + u->sin6.sin6_len = sizeof(u->sin6); +#endif + break; + default: + abort(); + } +} /* ****************************************************************************** @@ -208,7 +234,6 @@ main(int argc, char **argv) { Boolean useLocalServer; int result; int i; - struct hostent *hp; /* * Initialize the resolver library routines. @@ -264,30 +289,38 @@ main(int argc, char **argv) { useLocalServer = FALSE; if (argc == 2) { - struct in_addr addr; + int nscount = 0; + union res_sockaddr_union u[MAXNS]; + struct addrinfo *answer = NULL; + struct addrinfo *cur = NULL; + struct addrinfo hint; /* * Use an explicit name server. If the hostname lookup fails, * default to the server(s) in resolv.conf. */ - if (inet_aton(*++argv, &addr)) { - res.nscount = 1; - res.nsaddr.sin_addr = addr; - } else { - hp = gethostbyname(*argv); - if (hp == NULL) { - fprintf(stderr, "*** Can't find server address for '%s': ", - *argv); - herror((char *)NULL); - fputc('\n', stderr); - } else { - for (i = 0; i < MAXNS && hp->h_addr_list[i] != NULL; i++) { - memcpy(&res.nsaddr_list[i].sin_addr, hp->h_addr_list[i], - hp->h_length); + memset(u, 0, sizeof(u)); + memset(&hint, 0, sizeof(hint)); + hint.ai_socktype = SOCK_DGRAM; + if (!getaddrinfo(*++argv, NULL, &hint, &answer)) { + for (cur = answer; cur != NULL; cur = cur->ai_next) { + if (nscount == MAXNS) + break; + switch (cur->ai_addr->sa_family) { + case AF_INET6: + u[nscount].sin6 = *(struct sockaddr_in6*)cur->ai_addr; + u[nscount++].sin6.sin6_port = htons(nsport); + break; + case AF_INET: + u[nscount].sin = *(struct sockaddr_in*)cur->ai_addr; + u[nscount++].sin.sin_port = htons(nsport); + break; } - res.nscount = i; - } + } + if (nscount != 0) + res_setservers(&res, u, nscount); + freeaddrinfo(answer);; } } @@ -295,21 +328,24 @@ main(int argc, char **argv) { if (res.nscount == 0 || useLocalServer) { LocalServer(defaultPtr); } else { - for (i = 0; i < res.nscount; i++) { - if (res.nsaddr_list[i].sin_addr.s_addr == INADDR_ANY) { + int nscount = 0; + union res_sockaddr_union u[MAXNS]; + + nscount = res_getservers(&res, u, MAXNS); + for (i = 0; i < nscount; i++) { + if (u[i].sin.sin_family == AF_INET && + u[i].sin.sin_addr.s_addr == INADDR_ANY) { LocalServer(defaultPtr); break; } else { - result = GetHostInfoByAddr(&(res.nsaddr_list[i].sin_addr), - &(res.nsaddr_list[i].sin_addr), - defaultPtr); + result = GetHostInfoByAddr(&u[i], &u[i], defaultPtr); if (result != SUCCESS) { fprintf(stderr, "*** Can't find server name for address %s: %s\n", inet_ntoa(res.nsaddr_list[i].sin_addr), DecodeError(result)); } else { - defaultAddr = res.nsaddr_list[i].sin_addr; + defaultAddr = u[i]; break; } } @@ -390,9 +426,15 @@ LocalServer(defaultPtr) (void) gethostname(hostName, sizeof(hostName)); - defaultAddr.s_addr = htonl(INADDR_ANY); + memset(&defaultAddr, 0, sizeof(defaultAddr)); + defaultAddr.sin.sin_addr.s_addr = htonl(INADDR_ANY); + defaultAddr.sin.sin_family = AF_INET; + defaultAddr.sin.sin_port = htons(nsport); +#ifdef HAVE_SA_LEN + defaultAddr.sin.sin_len = sizeof(defaultAddr.sin); +#endif (void) GetHostInfoByName(&defaultAddr, C_IN, T_A, - "0.0.0.0", defaultPtr, 1); + "0.0.0.0", defaultPtr, 1, 0); free(defaultPtr->name); defaultPtr->name = Calloc(1, sizeof(hostName)+1); strcpy(defaultPtr->name, hostName); @@ -438,22 +480,24 @@ Usage(void) { Boolean IsAddr(host, addrPtr) const char *host; - struct in_addr *addrPtr; /* If return TRUE, contains IP address */ + union res_sockaddr_union *addrPtr; + /* If return TRUE, contains IP address */ { - register const char *cp; - - if (isdigit(host[0])) { - /* Make sure it has only digits and dots. */ - for (cp = host; *cp; ++cp) { - if (!isdigit(*cp) && *cp != '.') - return FALSE; - } - /* If it has a trailing dot, don't treat it as an address. */ - if (*--cp != '.') { - return inet_aton(host, addrPtr); - } - } - return FALSE; + if (inet_pton(AF_INET6, host, &addrPtr->sin6.sin6_addr) == 1) { + addrPtr->sin6.sin6_family = AF_INET6; + addrPtr->sin6.sin6_port = htons(nsport); +#ifdef HAVE_SA_LEN + addrPtr->sin6.sin6_len = sizeof(addrPtr->sin6); +#endif + } else if (inet_pton(AF_INET, host, &addrPtr->sin.sin_addr) == 1) { + addrPtr->sin.sin_family = AF_INET; + addrPtr->sin.sin_port = htons(nsport); +#ifdef HAVE_SA_LEN + addrPtr->sin.sin_len = sizeof(addrPtr->sin); +#endif + } else + return FALSE; + return TRUE; } @@ -487,10 +531,11 @@ SetDefaultServer(string, local) Boolean local; { register HostInfo *newDefPtr; - struct in_addr *servAddrPtr; - struct in_addr addr; + union res_sockaddr_union servAddr; + union res_sockaddr_union addr; char newServer[NAME_LEN]; int result; + int tresult; int i; int j; @@ -550,21 +595,28 @@ SetDefaultServer(string, local) */ if (local) { - servAddrPtr = &defaultAddr; + servAddr = defaultAddr; } else if (defaultPtr->addrList != NULL) { - servAddrPtr = (struct in_addr *) defaultPtr->addrList[0]; + UnionFromAddr(&servAddr, defaultPtr->addrList[0]->addrType, + defaultPtr->addrList[0]->addr); } else { - servAddrPtr = (struct in_addr *) defaultPtr->servers[0]->addrList[0]; + UnionFromAddr(&servAddr, defaultPtr->addrList[0]->addrType, + defaultPtr->servers[0]->addrList[0]->addr); } result = ERROR; if (IsAddr(newServer, &addr)) { - result = GetHostInfoByAddr(servAddrPtr, &addr, newDefPtr); + result = GetHostInfoByAddr(&servAddr, &addr, newDefPtr); /* If we can't get the name, fall through... */ } if (result != SUCCESS && result != NONAUTH) { - result = GetHostInfoByName(servAddrPtr, C_IN, T_A, - newServer, newDefPtr, 1); + result = GetHostInfoByName(&servAddr, C_IN, T_A, + newServer, newDefPtr, 1, 0); + if (result == SUCCESS || result == NONAUTH || result == NO_INFO) + tresult = GetHostInfoByName(&servAddr, C_IN, T_AAAA, + newServer, newDefPtr, 1, 1); + if (result == NO_INFO) + result = tresult; } /* If we ask for an A record and get none back, but get an NS @@ -616,8 +668,8 @@ DoLookup(host, servPtr, serverName) char *serverName; { int result; - struct in_addr *servAddrPtr; - struct in_addr addr; + union res_sockaddr_union servAddr; + union res_sockaddr_union addr; /* Skip escape character */ if (host[0] == '\\') @@ -634,9 +686,11 @@ DoLookup(host, servPtr, serverName) */ if (servPtr->addrList != NULL) { - servAddrPtr = (struct in_addr *) servPtr->addrList[0]; + UnionFromAddr(&servAddr, servPtr->addrList[0]->addrType, + servPtr->addrList[0]->addr); } else { - servAddrPtr = (struct in_addr *) servPtr->servers[0]->addrList[0]; + UnionFromAddr(&servAddr, servPtr->servers[0]->addrList[0]->addrType, + servPtr->servers[0]->addrList[0]->addr); } /* @@ -644,13 +698,13 @@ DoLookup(host, servPtr, serverName) * dotted-decimal number before looking it up [...]" (p. 13). */ if (queryType == T_A && IsAddr(host, &addr)) { - result = GetHostInfoByAddr(servAddrPtr, &addr, &curHostInfo); + result = GetHostInfoByAddr(&servAddr, &addr, &curHostInfo); } else { if (queryType == T_PTR) { CvtAddrToPtr(host); } - result = GetHostInfoByName(servAddrPtr, queryClass, queryType, host, - &curHostInfo, 0); + result = GetHostInfoByName(&servAddr, queryClass, queryType, host, + &curHostInfo, 0, 0); } switch (result) { @@ -792,6 +846,7 @@ LookupHostWithServer(char *string, Boolean putToFile) { static HostInfo serverInfo; int i; int j; + union res_sockaddr_union u; curHostValid = FALSE; @@ -818,11 +873,16 @@ LookupHostWithServer(char *string, Boolean putToFile) { fprintf(filePtr,"> %s\n", string); } - result = GetHostInfoByName( - defaultPtr->addrList ? - (struct in_addr *) defaultPtr->addrList[0] : - (struct in_addr *) defaultPtr->servers[0]->addrList[0], - C_IN, T_A, server, &serverInfo, 1); + if (defaultPtr->addrList != NULL) + UnionFromAddr(&u, defaultPtr->addrList[0]->addrType, + defaultPtr->addrList[0]->addr); + else + UnionFromAddr(&u, defaultPtr->servers[0]->addrList[0]->addrType, + defaultPtr->servers[0]->addrList[0]->addr); + result = GetHostInfoByName(&u, C_IN, T_A, server, &serverInfo, 1, 0); + if (result == NO_INFO) + result = GetHostInfoByName(&u, C_IN, T_AAAA, server, + &serverInfo, 1, 1); if (result != SUCCESS) { fprintf(stderr,"*** Can't find address for server %s: %s\n", server, @@ -1172,13 +1232,54 @@ CvtAddrToPtr(name) { const char *p; int ip[4]; - struct in_addr addr; + union res_sockaddr_union addr; if (IsAddr(name, &addr)) { - p = inet_ntoa(addr); - if (sscanf(p, "%d.%d.%d.%d", &ip[0], &ip[1], &ip[2], &ip[3]) == 4) { - sprintf(name, "%d.%d.%d.%d.in-addr.arpa.", - ip[3], ip[2], ip[1], ip[0]); + switch (addr.sin.sin_family) { + case AF_INET: + p = inet_ntoa(addr.sin.sin_addr); + if (sscanf(p, "%d.%d.%d.%d", &ip[0], &ip[1], &ip[2], &ip[3]) == 4) + sprintf(name, "%d.%d.%d.%d.in-addr.arpa.", + ip[3], ip[2], ip[1], ip[0]); + break; + case AF_INET6: + sprintf(name, + "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x." + "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x." + "ip6.arpa", + addr.sin6.sin6_addr.s6_addr[15] & 0xf, + (addr.sin6.sin6_addr.s6_addr[15] >> 4) & 0xf, + addr.sin6.sin6_addr.s6_addr[14] & 0xf, + (addr.sin6.sin6_addr.s6_addr[14] >> 4) & 0xf, + addr.sin6.sin6_addr.s6_addr[13] & 0xf, + (addr.sin6.sin6_addr.s6_addr[13] >> 4) & 0xf, + addr.sin6.sin6_addr.s6_addr[12] & 0xf, + (addr.sin6.sin6_addr.s6_addr[12] >> 4) & 0xf, + addr.sin6.sin6_addr.s6_addr[11] & 0xf, + (addr.sin6.sin6_addr.s6_addr[11] >> 4) & 0xf, + addr.sin6.sin6_addr.s6_addr[10] & 0xf, + (addr.sin6.sin6_addr.s6_addr[10] >> 4) & 0xf, + addr.sin6.sin6_addr.s6_addr[9] & 0xf, + (addr.sin6.sin6_addr.s6_addr[9] >> 4) & 0xf, + addr.sin6.sin6_addr.s6_addr[8] & 0xf, + (addr.sin6.sin6_addr.s6_addr[8] >> 4) & 0xf, + addr.sin6.sin6_addr.s6_addr[7] & 0xf, + (addr.sin6.sin6_addr.s6_addr[7] >> 4) & 0xf, + addr.sin6.sin6_addr.s6_addr[6] & 0xf, + (addr.sin6.sin6_addr.s6_addr[6] >> 4) & 0xf, + addr.sin6.sin6_addr.s6_addr[5] & 0xf, + (addr.sin6.sin6_addr.s6_addr[5] >> 4) & 0xf, + addr.sin6.sin6_addr.s6_addr[4] & 0xf, + (addr.sin6.sin6_addr.s6_addr[4] >> 4) & 0xf, + addr.sin6.sin6_addr.s6_addr[3] & 0xf, + (addr.sin6.sin6_addr.s6_addr[3] >> 4) & 0xf, + addr.sin6.sin6_addr.s6_addr[2] & 0xf, + (addr.sin6.sin6_addr.s6_addr[2] >> 4) & 0xf, + addr.sin6.sin6_addr.s6_addr[1] & 0xf, + (addr.sin6.sin6_addr.s6_addr[1] >> 4) & 0xf, + addr.sin6.sin6_addr.s6_addr[0] & 0xf, + (addr.sin6.sin6_addr.s6_addr[0] >> 4) & 0xf); + break; } } } diff --git a/contrib/bind/bin/nslookup/res.h b/contrib/bind/bin/nslookup/res.h index 79f8633..fe9241d 100644 --- a/contrib/bind/bin/nslookup/res.h +++ b/contrib/bind/bin/nslookup/res.h @@ -55,7 +55,7 @@ /* * @(#)res.h 5.10 (Berkeley) 6/1/90 - * $Id: res.h,v 8.9 2001/06/20 12:30:34 marka Exp $ + * $Id: res.h,v 8.10 2002/04/09 05:55:22 marka Exp $ */ /* @@ -131,18 +131,22 @@ typedef int Boolean; * for use in system calls)." */ +typedef struct { + int addrType; + int addrLen; + char *addr; +} AddrInfo; + typedef struct { char *name; /* official name of host */ char **domains; /* domains it serves */ - char **addrList; /* list of addresses from name server */ + AddrInfo **addrList; /* list of addresses from name server */ } ServerInfo; typedef struct { char *name; /* official name of host */ char **aliases; /* alias list */ - char **addrList; /* list of addresses from name server */ - int addrType; /* host address type */ - int addrLen; /* length of address */ + AddrInfo **addrList; /* list of addresses from name server */ ServerInfo **servers; } HostInfo; @@ -188,15 +192,14 @@ extern void PrintHostInfo(); extern void FreeHostInfoPtr(); extern FILE *OpenFile(); extern int pickString(const char *, char *, size_t); -extern int GetHostInfoByName(struct in_addr *, int, int, const char *, - HostInfo *, Boolean); -extern int GetHostInfoByAddr(); -extern int GetHostDomain(struct in_addr *, int, int, const char *, char *, - HostInfo *, Boolean); +extern int GetHostInfoByName(union res_sockaddr_union *, int, int, + const char *, HostInfo *, Boolean, Boolean); +extern int GetHostDomain(union res_sockaddr_union *, int, int, + const char *, char *, HostInfo *, Boolean, Boolean); extern int matchString(const char *, const char *); extern int StringToType(char *, int, FILE *); extern int StringToClass(char *, int, FILE *); -extern int SendRequest(struct in_addr *, const u_char *, int, +extern int SendRequest(union res_sockaddr_union *, const u_char *, int, u_char *, u_int, int *); extern void SendRequest_close(void); extern int SetDefaultServer(char *, Boolean); @@ -217,7 +220,8 @@ SIG_FN IntrHandler(int); int ListSubr(int, char *, char *); void FreeHostInfoPtr(HostInfo *); unsigned char * res_skip(unsigned char *, int, unsigned char *); -extern Boolean IsAddr(const char *, struct in_addr *); +extern Boolean IsAddr(const char *, union res_sockaddr_union *); void PrintHelp(void); -int GetHostInfoByAddr(struct in_addr *, struct in_addr *, HostInfo *); +int GetHostInfoByAddr(union res_sockaddr_union *, union res_sockaddr_union *, + HostInfo *); diff --git a/contrib/bind/bin/nslookup/send.c b/contrib/bind/bin/nslookup/send.c index ecbd75d..de60d21 100644 --- a/contrib/bind/bin/nslookup/send.c +++ b/contrib/bind/bin/nslookup/send.c @@ -53,7 +53,7 @@ #ifndef lint static const char sccsid[] = "@(#)send.c 5.18 (Berkeley) 3/2/91"; -static const char rcsid[] = "$Id: send.c,v 8.12 2001/07/03 06:27:12 marka Exp $"; +static const char rcsid[] = "$Id: send.c,v 8.13 2002/04/09 05:55:23 marka Exp $"; #endif /* not lint */ /* @@ -120,8 +120,8 @@ unsigned short nsport = NAMESERVER_PORT; */ int -SendRequest(struct in_addr *nsAddrPtr, const u_char *buf, int buflen, - u_char *answer, u_int anslen, int *trueLenPtr) +SendRequest(union res_sockaddr_union *nsAddrPtr, const u_char *buf, + int buflen, u_char *answer, u_int anslen, int *trueLenPtr) { int n, try, v_circuit, resplen; ISC_SOCKLEN_T salen; @@ -136,15 +136,15 @@ SendRequest(struct in_addr *nsAddrPtr, const u_char *buf, int buflen, struct iovec iov[2]; int terrno = ETIMEDOUT; char junk[512]; - struct sockaddr_in sin, sa; + struct sockaddr_storage sa; + int family = nsAddrPtr->sin.sin_family; + int clen = (family == AF_INET) ? sizeof(struct sockaddr_in) : + sizeof(struct sockaddr_in6); if (res.options & RES_DEBUG2) { printf("------------\nSendRequest(), len %d\n", buflen); Print_query(buf, buf + buflen, 1); } - sin.sin_family = AF_INET; - sin.sin_port = htons(nsport); - sin.sin_addr = *nsAddrPtr; v_circuit = (res.options & RES_USEVC) || buflen > PACKETSZ; id = hp->id; /* @@ -161,15 +161,15 @@ SendRequest(struct in_addr *nsAddrPtr, const u_char *buf, int buflen, */ try = res.retry; if (s < 0) { - s = socket(AF_INET, SOCK_STREAM, 0); + s = socket(family, SOCK_STREAM, 0); if (s < 0) { terrno = errno; if (res.options & RES_DEBUG) perror("socket (vc) failed"); continue; } - if (connect(s, (struct sockaddr *)&sin, - sizeof(struct sockaddr)) < 0) { + if (connect(s, (struct sockaddr *)nsAddrPtr, + clen) < 0) { terrno = errno; if (res.options & RES_DEBUG) perror("connect failed"); @@ -266,7 +266,7 @@ SendRequest(struct in_addr *nsAddrPtr, const u_char *buf, int buflen, * Use datagrams. */ if (s < 0) { - s = socket(AF_INET, SOCK_DGRAM, 0); + s = socket(family, SOCK_DGRAM, 0); if (s < 0) { terrno = errno; if (res.options & RES_DEBUG) @@ -276,8 +276,8 @@ SendRequest(struct in_addr *nsAddrPtr, const u_char *buf, int buflen, } #if BSD >= 43 if (connected == 0) { - if (connect(s, (struct sockaddr *)&sin, - sizeof sin) < 0) { + if (connect(s, (struct sockaddr *)nsAddrPtr, + clen) < 0) { if (res.options & RES_DEBUG) perror("connect"); continue; @@ -291,8 +291,8 @@ SendRequest(struct in_addr *nsAddrPtr, const u_char *buf, int buflen, } #else /* BSD */ if (sendto(s, (const char *)buf, buflen, 0, - (struct sockaddr *) &sin, - sizeof sin) != buflen) { + (struct sockaddr *) &nsAddrPtr, + clen) != buflen) { if (res.options & RES_DEBUG) perror("sendto"); continue; diff --git a/contrib/bind/bin/nslookup/subr.c b/contrib/bind/bin/nslookup/subr.c index 854e090..ff9f1e9 100644 --- a/contrib/bind/bin/nslookup/subr.c +++ b/contrib/bind/bin/nslookup/subr.c @@ -53,7 +53,7 @@ #ifndef lint static const char sccsid[] = "@(#)subr.c 5.24 (Berkeley) 3/2/91"; -static const char rcsid[] = "$Id: subr.c,v 8.15 2001/06/18 14:43:45 marka Exp $"; +static const char rcsid[] = "$Id: subr.c,v 8.16 2002/04/09 05:55:24 marka Exp $"; #endif /* not lint */ /* @@ -238,10 +238,12 @@ PrintHostInfo(file, title, hp) const char *title; register HostInfo *hp; { + register AddrInfo **ap; register char **cp; register ServerInfo **sp; char comma; int i; + char buf[80]; fprintf(file, "%-7s %s", title, hp->name); @@ -253,14 +255,18 @@ PrintHostInfo(file, title, hp) } comma = ' '; i = 0; - for (cp = hp->addrList; cp && *cp; cp++) { + for (ap = hp->addrList; ap && *ap; ap++) { i++; if (i > 4) { fprintf(file, "\n\t"); comma = ' '; i = 0; } - fprintf(file,"%c %s", comma, inet_ntoa(*(struct in_addr *)*cp)); + if (inet_ntop((*ap)->addrType, (*ap)->addr, + buf, sizeof(buf)) != NULL) { + fprintf(file,"%c %s", comma, buf); + } else + fprintf(file,"%c <UNKNOWN>", comma); comma = ','; } } @@ -289,15 +295,18 @@ PrintHostInfo(file, title, hp) comma = ' '; i = 0; - for (cp = (*sp)->addrList; cp && *cp && **cp; cp++) { + for (ap = (*sp)->addrList; ap && *ap; ap++) { i++; if (i > 4) { fprintf(file, "\n\t"); comma = ' '; i = 0; } - fprintf(file, - "%c %s", comma, inet_ntoa(*(struct in_addr *)*cp)); + if (inet_ntop((*ap)->addrType, (*ap)->addr, + buf, sizeof(buf)) != NULL) + fprintf(file,"%c %s", comma, buf); + else + fprintf(file,"%c <UNKNOWN>", comma); comma = ','; } fprintf(file, "\n\t"); diff --git a/contrib/bind/include/arpa/nameser.h b/contrib/bind/include/arpa/nameser.h index 955719a..58bc702 100644 --- a/contrib/bind/include/arpa/nameser.h +++ b/contrib/bind/include/arpa/nameser.h @@ -49,7 +49,7 @@ */ /* - * $Id: nameser.h,v 8.46 2001/11/16 05:37:33 marka Exp $ + * $Id: nameser.h,v 8.47 2002/04/30 03:43:53 marka Exp $ */ #ifndef _ARPA_NAMESER_H_ @@ -497,7 +497,9 @@ typedef enum __ns_cert_types { #define ns_name_skip __ns_name_skip #define ns_name_rollback __ns_name_rollback #define ns_sign __ns_sign +#define ns_sign2 __ns_sign2 #define ns_sign_tcp __ns_sign_tcp +#define ns_sign_tcp2 __ns_sign_tcp2 #define ns_sign_tcp_init __ns_sign_tcp_init #define ns_find_tsig __ns_find_tsig #define ns_verify __ns_verify @@ -542,8 +544,14 @@ void ns_name_rollback __P((const u_char *, const u_char **, const u_char **)); int ns_sign __P((u_char *, int *, int, int, void *, const u_char *, int, u_char *, int *, time_t)); +int ns_sign2 __P((u_char *, int *, int, int, void *, + const u_char *, int, u_char *, int *, time_t, + u_char **, u_char **)); int ns_sign_tcp __P((u_char *, int *, int, int, ns_tcp_tsig_state *, int)); +int ns_sign_tcp2 __P((u_char *, int *, int, int, + ns_tcp_tsig_state *, int, + u_char **, u_char **)); int ns_sign_tcp_init __P((void *, const u_char *, int, ns_tcp_tsig_state *)); u_char *ns_find_tsig __P((u_char *, u_char *)); diff --git a/contrib/bind/include/resolv.h b/contrib/bind/include/resolv.h index fb5185e..ff3c01f 100644 --- a/contrib/bind/include/resolv.h +++ b/contrib/bind/include/resolv.h @@ -50,7 +50,7 @@ /* * @(#)resolv.h 8.1 (Berkeley) 6/2/93 - * $Id: resolv.h,v 8.44 2001/12/19 01:44:19 marka Exp $ + * $Id: resolv.h,v 8.45 2002/04/12 06:27:48 marka Exp $ */ #ifndef _RESOLV_H_ @@ -211,8 +211,10 @@ union res_sockaddr_union { #define RES_F_CONN 0x00000002 /* socket is connected */ #define RES_F_EDNS0ERR 0x00000004 /* EDNS0 caused errors */ -/* res_findzonecut() options */ +/* res_findzonecut2() options */ #define RES_EXHAUSTIVE 0x00000001 /* always do all queries */ +#define RES_IPV4ONLY 0x00000002 /* IPv4 only */ +#define RES_IPV6ONLY 0x00000004 /* IPv6 only */ /* * Resolver options (keep these in synch with res_debug.c, please) @@ -353,6 +355,7 @@ extern const struct res_sym __p_rcode_syms[]; #define putshort __putshort #define res_dnok __res_dnok #define res_findzonecut __res_findzonecut +#define res_findzonecut2 __res_findzonecut2 #define res_hnok __res_hnok #define res_hostalias __res_hostalias #define res_mailok __res_mailok @@ -443,6 +446,9 @@ int res_nsendsigned __P((res_state, const u_char *, int, ns_tsig_key *, u_char *, int)); int res_findzonecut __P((res_state, const char *, ns_class, int, char *, size_t, struct in_addr *, int)); +int res_findzonecut2 __P((res_state, const char *, ns_class, int, + char *, size_t, + union res_sockaddr_union *, int)); void res_nclose __P((res_state)); int res_nopt __P((res_state, int, u_char *, int, int)); void res_send_setqhook __P((res_send_qhook hook)); diff --git a/contrib/bind/lib/irs/dns_ho.c b/contrib/bind/lib/irs/dns_ho.c index e340f02..7d64e53 100644 --- a/contrib/bind/lib/irs/dns_ho.c +++ b/contrib/bind/lib/irs/dns_ho.c @@ -52,7 +52,7 @@ /* BIND Id: gethnamaddr.c,v 8.15 1996/05/22 04:56:30 vixie Exp $ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: dns_ho.c,v 1.33 2001/10/05 04:30:21 marka Exp $"; +static const char rcsid[] = "$Id: dns_ho.c,v 1.35 2002/05/08 01:49:27 marka Exp $"; #endif /* LIBC_SCCS and not lint */ /* Imports. */ @@ -256,47 +256,55 @@ ho_byname2(struct irs_ho *this, const char *name, int af) char tmp[NS_MAXDNAME]; const char *cp; struct addrinfo ai; - struct dns_res_target q, q2, *p; + struct dns_res_target *q, *q2, *p; int querystate = RESQRY_FAIL; if (init(this) == -1) return (NULL); - memset(&q, 0, sizeof(q2)); - memset(&q2, 0, sizeof(q2)); + q = memget(sizeof(*q)); + q2 = memget(sizeof(*q2)); + if (q == NULL || q2 == NULL) { + RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL); + errno = ENOMEM; + goto cleanup; + } + memset(q, 0, sizeof(q)); + memset(q2, 0, sizeof(q2)); switch (af) { case AF_INET: size = INADDRSZ; - q.qclass = C_IN; - q.qtype = T_A; - q.answer = q.qbuf.buf; - q.anslen = sizeof(q.qbuf); - q.action = RESTGT_DOALWAYS; + q->qclass = C_IN; + q->qtype = T_A; + q->answer = q->qbuf.buf; + q->anslen = sizeof(q->qbuf); + q->action = RESTGT_DOALWAYS; break; case AF_INET6: size = IN6ADDRSZ; - q.qclass = C_IN; - q.qtype = ns_t_a6; - q.answer = q.qbuf.buf; - q.anslen = sizeof(q.qbuf); - q.next = &q2; + q->qclass = C_IN; + q->qtype = ns_t_a6; + q->answer = q->qbuf.buf; + q->anslen = sizeof(q->qbuf); + q->next = q2; #ifdef RES_USE_A6 if ((pvt->res->options & RES_USE_A6) == 0) - q.action = RESTGT_IGNORE; + q->action = RESTGT_IGNORE; else #endif - q.action = RESTGT_DOALWAYS; - q2.qclass = C_IN; - q2.qtype = T_AAAA; - q2.answer = q2.qbuf.buf; - q2.anslen = sizeof(q2.qbuf); - q2.action = RESTGT_AFTERFAILURE; + q->action = RESTGT_DOALWAYS; + q2->qclass = C_IN; + q2->qtype = T_AAAA; + q2->answer = q2->qbuf.buf; + q2->anslen = sizeof(q2->qbuf); + q2->action = RESTGT_AFTERFAILURE; break; default: RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL); errno = EAFNOSUPPORT; - return (NULL); + hp = NULL; + goto cleanup; } /* @@ -308,7 +316,7 @@ ho_byname2(struct irs_ho *this, const char *name, int af) tmp, sizeof tmp))) name = cp; - for (p = &q; p; p = p->next) { + for (p = q; p; p = p->next) { switch(p->action) { case RESTGT_DOALWAYS: break; @@ -331,13 +339,18 @@ ho_byname2(struct irs_ho *this, const char *name, int af) if ((hp = gethostans(this, p->answer, n, name, p->qtype, af, size, NULL, (const struct addrinfo *)&ai)) != NULL) - return(hp); /* no more loop is necessary */ + goto cleanup; /* no more loop is necessary */ querystate = RESQRY_FAIL; continue; } - return(hp); /* should be NULL */ + cleanup: + if (q != NULL) + memput(q, sizeof(*q)); + if (q2 != NULL) + memput(q2, sizeof(*q2)); + return(hp); } static struct hostent * @@ -346,17 +359,24 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af) struct pvt *pvt = (struct pvt *)this->private; const u_char *uaddr = addr; char *qp; - struct hostent *hp; + struct hostent *hp = NULL; struct addrinfo ai; - struct dns_res_target q, q2, *p; + struct dns_res_target *q, *q2, *p; int n, size; int querystate = RESQRY_FAIL; if (init(this) == -1) return (NULL); - memset(&q, 0, sizeof(q2)); - memset(&q2, 0, sizeof(q2)); + q = memget(sizeof(*q)); + q2 = memget(sizeof(*q2)); + if (q == NULL || q2 == NULL) { + RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL); + errno = ENOMEM; + goto cleanup; + } + memset(q, 0, sizeof(q)); + memset(q2, 0, sizeof(q2)); if (af == AF_INET6 && len == IN6ADDRSZ && (!memcmp(uaddr, mapped, sizeof mapped) || @@ -371,45 +391,47 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af) switch (af) { case AF_INET: size = INADDRSZ; - q.qclass = C_IN; - q.qtype = T_PTR; - q.answer = q.qbuf.buf; - q.anslen = sizeof(q.qbuf); - q.action = RESTGT_DOALWAYS; + q->qclass = C_IN; + q->qtype = T_PTR; + q->answer = q->qbuf.buf; + q->anslen = sizeof(q->qbuf); + q->action = RESTGT_DOALWAYS; break; case AF_INET6: size = IN6ADDRSZ; - q.qclass = C_IN; - q.qtype = T_PTR; - q.answer = q.qbuf.buf; - q.anslen = sizeof(q.qbuf); - q.next = &q2; + q->qclass = C_IN; + q->qtype = T_PTR; + q->answer = q->qbuf.buf; + q->anslen = sizeof(q->qbuf); + q->next = q2; if ((pvt->res->options & RES_NO_BITSTRING) != 0) - q.action = RESTGT_IGNORE; + q->action = RESTGT_IGNORE; else - q.action = RESTGT_DOALWAYS; - q2.qclass = C_IN; - q2.qtype = T_PTR; - q2.answer = q2.qbuf.buf; - q2.anslen = sizeof(q2.qbuf); + q->action = RESTGT_DOALWAYS; + q2->qclass = C_IN; + q2->qtype = T_PTR; + q2->answer = q2->qbuf.buf; + q2->anslen = sizeof(q2->qbuf); if ((pvt->res->options & RES_NO_NIBBLE) != 0) - q2.action = RESTGT_IGNORE; + q2->action = RESTGT_IGNORE; else - q2.action = RESTGT_AFTERFAILURE; + q2->action = RESTGT_AFTERFAILURE; break; default: errno = EAFNOSUPPORT; RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL); - return (NULL); + hp = NULL; + goto cleanup; } if (size > len) { errno = EINVAL; RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL); - return (NULL); + hp = NULL; + goto cleanup; } switch (af) { case AF_INET: - qp = q.qname; + qp = q->qname; (void) sprintf(qp, "%u.%u.%u.%u.in-addr.arpa", (uaddr[3] & 0xff), (uaddr[2] & 0xff), @@ -417,16 +439,16 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af) (uaddr[0] & 0xff)); break; case AF_INET6: - if (q.action != RESTGT_IGNORE) { - qp = q.qname; + if (q->action != RESTGT_IGNORE) { + qp = q->qname; qp += SPRINTF((qp, "\\[x")); for (n = 0; n < IN6ADDRSZ; n++) qp += SPRINTF((qp, "%02x", uaddr[n])); SPRINTF((qp, "/128].%s", res_get_bitstringsuffix(pvt->res))); } - if (q2.action != RESTGT_IGNORE) { - qp = q2.qname; + if (q2->action != RESTGT_IGNORE) { + qp = q2->qname; for (n = IN6ADDRSZ - 1; n >= 0; n--) { qp += SPRINTF((qp, "%x.%x.", uaddr[n] & 0xf, @@ -439,7 +461,7 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af) abort(); } - for (p = &q; p; p = p->next) { + for (p = q; p; p = p->next) { switch(p->action) { case RESTGT_DOALWAYS: break; @@ -477,10 +499,16 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af) } RES_SET_H_ERRNO(pvt->res, NETDB_SUCCESS); - return (hp); /* no more loop is necessary. */ + goto cleanup; /* no more loop is necessary. */ } - - return(NULL); /* H_ERRNO was set by subroutines */ + hp = NULL; /* H_ERRNO was set by subroutines */ + + cleanup: + if (q != NULL) + memput(q, sizeof(*q)); + if (q2 != NULL) + memput(q2, sizeof(*q2)); + return(hp); } static struct hostent * @@ -536,74 +564,83 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai) int n; char tmp[NS_MAXDNAME]; const char *cp; - struct dns_res_target q, q2, q3, *p; + struct dns_res_target *q, *q2, *q3, *p; struct addrinfo sentinel, *cur; int querystate = RESQRY_FAIL; if (init(this) == -1) return (NULL); - memset(&q, 0, sizeof(q2)); - memset(&q2, 0, sizeof(q2)); - memset(&q3, 0, sizeof(q3)); memset(&sentinel, 0, sizeof(sentinel)); cur = &sentinel; + q = memget(sizeof(*q)); + q2 = memget(sizeof(*q2)); + q3 = memget(sizeof(*q3)); + if (q == NULL || q2 == NULL || q3 == NULL) { + RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL); + errno = ENOMEM; + goto cleanup; + } + memset(q, 0, sizeof(q2)); + memset(q2, 0, sizeof(q2)); + memset(q3, 0, sizeof(q3)); + switch (pai->ai_family) { case AF_UNSPEC: /* prefer IPv6 */ - q.qclass = C_IN; - q.qtype = ns_t_a6; - q.answer = q.qbuf.buf; - q.anslen = sizeof(q.qbuf); - q.next = &q2; + q->qclass = C_IN; + q->qtype = ns_t_a6; + q->answer = q->qbuf.buf; + q->anslen = sizeof(q->qbuf); + q->next = q2; #ifdef RES_USE_A6 if ((pvt->res->options & RES_USE_A6) == 0) - q.action = RESTGT_IGNORE; + q->action = RESTGT_IGNORE; else #endif - q.action = RESTGT_DOALWAYS; - q2.qclass = C_IN; - q2.qtype = T_AAAA; - q2.answer = q2.qbuf.buf; - q2.anslen = sizeof(q2.qbuf); - q2.next = &q3; + q->action = RESTGT_DOALWAYS; + q2->qclass = C_IN; + q2->qtype = T_AAAA; + q2->answer = q2->qbuf.buf; + q2->anslen = sizeof(q2->qbuf); + q2->next = q3; /* try AAAA only when A6 query fails */ - q2.action = RESTGT_AFTERFAILURE; - q3.qclass = C_IN; - q3.qtype = T_A; - q3.answer = q3.qbuf.buf; - q3.anslen = sizeof(q3.qbuf); - q3.action = RESTGT_DOALWAYS; + q2->action = RESTGT_AFTERFAILURE; + q3->qclass = C_IN; + q3->qtype = T_A; + q3->answer = q3->qbuf.buf; + q3->anslen = sizeof(q3->qbuf); + q3->action = RESTGT_DOALWAYS; break; case AF_INET: - q.qclass = C_IN; - q.qtype = T_A; - q.answer = q.qbuf.buf; - q.anslen = sizeof(q.qbuf); - q.action = RESTGT_DOALWAYS; + q->qclass = C_IN; + q->qtype = T_A; + q->answer = q->qbuf.buf; + q->anslen = sizeof(q->qbuf); + q->action = RESTGT_DOALWAYS; break; case AF_INET6: - q.qclass = C_IN; - q.qtype = ns_t_a6; - q.answer = q.qbuf.buf; - q.anslen = sizeof(q.qbuf); - q.next = &q2; + q->qclass = C_IN; + q->qtype = ns_t_a6; + q->answer = q->qbuf.buf; + q->anslen = sizeof(q->qbuf); + q->next = q2; #ifdef RES_USE_A6 if ((pvt->res->options & RES_USE_A6) == 0) - q.action = RESTGT_IGNORE; + q->action = RESTGT_IGNORE; else #endif - q.action = RESTGT_DOALWAYS; - q2.qclass = C_IN; - q2.qtype = T_AAAA; - q2.answer = q2.qbuf.buf; - q2.anslen = sizeof(q2.qbuf); - q2.action = RESTGT_AFTERFAILURE; + q->action = RESTGT_DOALWAYS; + q2->qclass = C_IN; + q2->qtype = T_AAAA; + q2->answer = q2->qbuf.buf; + q2->anslen = sizeof(q2->qbuf); + q2->action = RESTGT_AFTERFAILURE; break; default: RES_SET_H_ERRNO(pvt->res, NO_RECOVERY); /* better error? */ - return(NULL); + goto cleanup; } /* @@ -615,7 +652,7 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai) tmp, sizeof tmp))) name = cp; - for (p = &q; p; p = p->next) { + for (p = q; p; p = p->next) { struct addrinfo *ai; switch(p->action) { @@ -647,6 +684,13 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai) querystate = RESQRY_FAIL; } + cleanup: + if (q != NULL) + memput(q, sizeof(*q)); + if (q2 != NULL) + memput(q2, sizeof(*q2)); + if (q3 != NULL) + memput(q3, sizeof(*q3)); return(sentinel.ai_next); } @@ -1153,8 +1197,6 @@ gethostans(struct irs_ho *this, eor = cp + n; if ((qtype == T_A || qtype == T_AAAA || qtype == ns_t_a6 || qtype == T_ANY) && type == T_CNAME) { - if (ap >= &pvt->host_aliases[MAXALIASES-1]) - continue; n = dn_expand(ansbuf, eor, cp, tbuf, sizeof tbuf); if (n < 0 || !maybe_ok(pvt->res, tbuf, name_ok)) { had_error++; @@ -1162,6 +1204,8 @@ gethostans(struct irs_ho *this, } cp += n; /* Store alias. */ + if (ap >= &pvt->host_aliases[MAXALIASES-1]) + continue; *ap++ = bp; n = strlen(bp) + 1; /* for the \0 */ bp += n; diff --git a/contrib/bind/lib/irs/dns_nw.c b/contrib/bind/lib/irs/dns_nw.c index 8e0e965..fbc613f 100644 --- a/contrib/bind/lib/irs/dns_nw.c +++ b/contrib/bind/lib/irs/dns_nw.c @@ -16,7 +16,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: dns_nw.c,v 1.21 2001/11/30 00:36:53 marka Exp $"; +static const char rcsid[] = "$Id: dns_nw.c,v 1.22 2002/02/27 03:50:10 marka Exp $"; #endif /* LIBC_SCCS and not lint */ /* Imports. */ @@ -240,22 +240,33 @@ nw_res_set(struct irs_nw *this, struct __res_state *res, static struct nwent * get1101byname(struct irs_nw *this, const char *name) { struct pvt *pvt = (struct pvt *)this->private; - u_char ansbuf[MAXPACKET]; + u_char *ansbuf; int anslen; + struct nwent *result; - anslen = res_nsearch(pvt->res, name, C_IN, T_PTR, - ansbuf, sizeof ansbuf); - if (anslen < 0) + ansbuf = memget(MAXPACKET); + if (ansbuf == NULL) { + errno = ENOMEM; + RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL); return (NULL); - return (get1101mask(this, get1101answer(this, ansbuf, anslen, by_name, - AF_INET, name, NULL, 0))); + } + anslen = res_nsearch(pvt->res, name, C_IN, T_PTR, ansbuf, MAXPACKET); + if (anslen < 0) { + memput(ansbuf, MAXPACKET); + return (NULL); + } + result = get1101mask(this, get1101answer(this, ansbuf, anslen, by_name, + AF_INET, name, NULL, 0)); + memput(ansbuf, MAXPACKET); + return (result); } static struct nwent * get1101byaddr(struct irs_nw *this, u_char *net, int len) { struct pvt *pvt = (struct pvt *)this->private; char qbuf[sizeof "255.255.255.255.in-addr.arpa"]; - u_char ansbuf[MAXPACKET]; + struct nwent *result; + u_char *ansbuf; int anslen; if (len < 1 || len > 32) { @@ -265,12 +276,21 @@ get1101byaddr(struct irs_nw *this, u_char *net, int len) { } if (make1101inaddr(net, len, qbuf, sizeof qbuf) < 0) return (NULL); - anslen = res_nquery(pvt->res, qbuf, C_IN, T_PTR, - ansbuf, sizeof ansbuf); - if (anslen < 0) + ansbuf = memget(MAXPACKET); + if (ansbuf == NULL) { + errno = ENOMEM; + RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL); + return (NULL); + } + anslen = res_nquery(pvt->res, qbuf, C_IN, T_PTR, ansbuf, MAXPACKET); + if (anslen < 0) { + memput(ansbuf, MAXPACKET); return (NULL); - return (get1101mask(this, get1101answer(this, ansbuf, anslen, by_addr, - AF_INET, NULL, net, len))); + } + result = get1101mask(this, get1101answer(this, ansbuf, anslen, by_addr, + AF_INET, NULL, net, len)); + memput(ansbuf, MAXPACKET); + return (result); } static struct nwent * @@ -430,7 +450,7 @@ get1101mask(struct irs_nw *this, struct nwent *nwent) { struct pvt *pvt = (struct pvt *)this->private; char qbuf[sizeof "255.255.255.255.in-addr.arpa"], owner[MAXDNAME]; int anslen, type, class, ancount, qdcount; - u_char ansbuf[MAXPACKET], *cp, *eom; + u_char *ansbuf, *cp, *eom; HEADER *hp; if (!nwent) @@ -441,10 +461,18 @@ get1101mask(struct irs_nw *this, struct nwent *nwent) { return (nwent); } + ansbuf = memget(MAXPACKET); + if (ansbuf == NULL) { + errno = ENOMEM; + RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL); + return (NULL); + } /* Query for the A RR that would hold this network's mask. */ - anslen = res_nquery(pvt->res, qbuf, C_IN, T_A, ansbuf, sizeof ansbuf); - if (anslen < HFIXEDSZ) + anslen = res_nquery(pvt->res, qbuf, C_IN, T_A, ansbuf, MAXPACKET); + if (anslen < HFIXEDSZ) { + memput(ansbuf, MAXPACKET); return (nwent); + } /* Initialize, and parse header. */ hp = (HEADER *)ansbuf; @@ -454,8 +482,10 @@ get1101mask(struct irs_nw *this, struct nwent *nwent) { while (qdcount-- > 0) { int n = dn_skipname(cp, eom); cp += n + QFIXEDSZ; - if (n < 0 || cp > eom) + if (n < 0 || cp > eom) { + memput(ansbuf, MAXPACKET); return (nwent); + } } ancount = ntohs(hp->ancount); @@ -489,6 +519,7 @@ get1101mask(struct irs_nw *this, struct nwent *nwent) { } cp += n; /* RDATA */ } + memput(ansbuf, MAXPACKET); return (nwent); } diff --git a/contrib/bind/lib/irs/getaddrinfo.c b/contrib/bind/lib/irs/getaddrinfo.c index f2c533d..243f106 100644 --- a/contrib/bind/lib/irs/getaddrinfo.c +++ b/contrib/bind/lib/irs/getaddrinfo.c @@ -172,13 +172,6 @@ static const struct explore explore[] = { #define PTON_MAX 16 -#define MAXPACKET (1024*64) - -typedef union { - HEADER hdr; - u_char buf[MAXPACKET]; -} querybuf; - static int str_isnumber __P((const char *)); static int explore_fqdn __P((const struct addrinfo *, const char *, const char *, struct addrinfo **)); @@ -320,7 +313,7 @@ getaddrinfo(hostname, servname, hints, res) struct addrinfo sentinel; struct addrinfo *cur; int error = 0; - struct addrinfo ai, ai0, *afai; + struct addrinfo ai, ai0, *afai = NULL; struct addrinfo *pai; const struct explore *ex; diff --git a/contrib/bind/lib/irs/getnameinfo.c b/contrib/bind/lib/irs/getnameinfo.c index 0e86cc1..9b26c64 100644 --- a/contrib/bind/lib/irs/getnameinfo.c +++ b/contrib/bind/lib/irs/getnameinfo.c @@ -105,9 +105,9 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) int family, i; const char *addr; char *p; - u_char pfx; char numserv[512]; char numaddr[512]; + const struct sockaddr_in6 *sin6; if (sa == NULL) return EAI_FAIL; @@ -157,9 +157,23 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) flags |= NI_NUMERICHOST; break; case AF_INET6: - pfx = *addr; - if (pfx == 0 || pfx == 0xfe || pfx == 0xff) - flags |= NI_NUMERICHOST; + sin6 = (const struct sockaddr_in6 *)sa; + switch (sin6->sin6_addr.s6_addr[0]) { + case 0x00: + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) + ; + else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr)) + ; + else + flags |= NI_NUMERICHOST; + break; + default: + if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) + flags |= NI_NUMERICHOST; + else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) + flags |= NI_NUMERICHOST; + break; + } break; } if (host == NULL || hostlen == 0) { diff --git a/contrib/bind/lib/nameser/ns_sign.c b/contrib/bind/lib/nameser/ns_sign.c index d811411..8c5fe1d 100644 --- a/contrib/bind/lib/nameser/ns_sign.c +++ b/contrib/bind/lib/nameser/ns_sign.c @@ -16,7 +16,7 @@ */ #ifndef lint -static const char rcsid[] = "$Id: ns_sign.c,v 8.10 2001/05/29 05:49:39 marka Exp $"; +static const char rcsid[] = "$Id: ns_sign.c,v 8.11 2002/04/30 03:43:55 marka Exp $"; #endif /* Import. */ @@ -76,6 +76,16 @@ ns_sign(u_char *msg, int *msglen, int msgsize, int error, void *k, const u_char *querysig, int querysiglen, u_char *sig, int *siglen, time_t in_timesigned) { + return(ns_sign2(msg, msglen, msgsize, error, k, + querysig, querysiglen, sig, siglen, + in_timesigned, NULL, NULL)); +} + +int +ns_sign2(u_char *msg, int *msglen, int msgsize, int error, void *k, + const u_char *querysig, int querysiglen, u_char *sig, int *siglen, + time_t in_timesigned, u_char **dnptrs, u_char **lastdnptr) +{ HEADER *hp = (HEADER *)msg; DST_KEY *key = (DST_KEY *)k; u_char *cp = msg + *msglen, *eob = msg + msgsize; @@ -90,7 +100,7 @@ ns_sign(u_char *msg, int *msglen, int msgsize, int error, void *k, /* Name. */ if (key != NULL && error != ns_r_badsig && error != ns_r_badkey) - n = dn_comp(key->dk_key_name, cp, eob - cp, NULL, NULL); + n = dn_comp(key->dk_key_name, cp, eob - cp, dnptrs, lastdnptr); else n = dn_comp("", cp, eob - cp, NULL, NULL); if (n < 0) @@ -244,6 +254,15 @@ int ns_sign_tcp(u_char *msg, int *msglen, int msgsize, int error, ns_tcp_tsig_state *state, int done) { + return (ns_sign_tcp2(msg, msglen, msgsize, error, state, + done, NULL, NULL)); +} + +int +ns_sign_tcp2(u_char *msg, int *msglen, int msgsize, int error, + ns_tcp_tsig_state *state, int done, + u_char **dnptrs, u_char **lastdnptr) +{ u_char *cp, *eob, *lenp; u_char buf[MAXDNAME], *cp2; HEADER *hp = (HEADER *)msg; @@ -255,9 +274,10 @@ ns_sign_tcp(u_char *msg, int *msglen, int msgsize, int error, state->counter++; if (state->counter == 0) - return (ns_sign(msg, msglen, msgsize, error, state->key, - state->sig, state->siglen, - state->sig, &state->siglen, 0)); + return (ns_sign2(msg, msglen, msgsize, error, state->key, + state->sig, state->siglen, + state->sig, &state->siglen, 0, + dnptrs, lastdnptr)); if (state->siglen > 0) { u_int16_t siglen_n = htons(state->siglen); @@ -280,7 +300,7 @@ ns_sign_tcp(u_char *msg, int *msglen, int msgsize, int error, eob = msg + msgsize; /* Name. */ - n = dn_comp(state->key->dk_key_name, cp, eob - cp, NULL, NULL); + n = dn_comp(state->key->dk_key_name, cp, eob - cp, dnptrs, lastdnptr); if (n < 0) return (NS_TSIG_ERROR_NO_SPACE); cp += n; diff --git a/contrib/bind/lib/resolv/res_findzonecut.c b/contrib/bind/lib/resolv/res_findzonecut.c index 02a28da..a82c3f1 100644 --- a/contrib/bind/lib/resolv/res_findzonecut.c +++ b/contrib/bind/lib/resolv/res_findzonecut.c @@ -1,5 +1,5 @@ #if !defined(lint) && !defined(SABER) -static const char rcsid[] = "$Id: res_findzonecut.c,v 8.15 2001/11/01 05:21:22 marka Exp $"; +static const char rcsid[] = "$Id: res_findzonecut.c,v 8.16 2002/04/12 06:27:46 marka Exp $"; #endif /* not lint */ /* @@ -34,7 +34,6 @@ static const char rcsid[] = "$Id: res_findzonecut.c,v 8.15 2001/11/01 05:21:22 m #include <errno.h> #include <limits.h> #include <netdb.h> -#include <resolv.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> @@ -44,35 +43,40 @@ static const char rcsid[] = "$Id: res_findzonecut.c,v 8.15 2001/11/01 05:21:22 m #include "port_after.h" +#include <resolv.h> + /* Data structures. */ typedef struct rr_a { LINK(struct rr_a) link; - struct in_addr addr; + union res_sockaddr_union addr; } rr_a; typedef LIST(rr_a) rrset_a; typedef struct rr_ns { LINK(struct rr_ns) link; const char * name; + int have_v4; + int have_v6; rrset_a addrs; } rr_ns; typedef LIST(rr_ns) rrset_ns; /* Forward. */ -static int satisfy(res_state, - const char *, rrset_ns *, struct in_addr *, int); -static int add_addrs(res_state, rr_ns *, struct in_addr *, int); -static int get_soa(res_state, const char *, ns_class, +static int satisfy(res_state, const char *, rrset_ns *, + union res_sockaddr_union *, int); +static int add_addrs(res_state, rr_ns *, + union res_sockaddr_union *, int); +static int get_soa(res_state, const char *, ns_class, int, char *, size_t, char *, size_t, rrset_ns *); -static int get_ns(res_state, const char *, ns_class, rrset_ns *); -static int get_glue(res_state, ns_class, rrset_ns *); +static int get_ns(res_state, const char *, ns_class, int, rrset_ns *); +static int get_glue(res_state, ns_class, int, rrset_ns *); static int save_ns(res_state, ns_msg *, ns_sect, - const char *, ns_class, rrset_ns *); + const char *, ns_class, int, rrset_ns *); static int save_a(res_state, ns_msg *, ns_sect, - const char *, ns_class, rrset_a *); + const char *, ns_class, int, rr_ns *); static void free_nsrrset(rrset_ns *); static void free_nsrr(rrset_ns *, rr_ns *); static rr_ns * find_ns(rrset_ns *, const char *); @@ -145,7 +149,32 @@ static void res_dprintf(const char *, ...) ISC_FORMAT_PRINTF(1, 2); int res_findzonecut(res_state statp, const char *dname, ns_class class, int opts, - char *zname, size_t zsize, struct in_addr *addrs, int naddrs) + char *zname, size_t zsize, struct in_addr *addrs, int naddrs) { + int result, i; + union res_sockaddr_union *u; + + + opts |= RES_IPV4ONLY; + opts &= ~RES_IPV6ONLY; + + u = calloc(naddrs, sizeof(*u)); + if (u == NULL) + return(-1); + + result = res_findzonecut2(statp, dname, class, opts, zname, zsize, + u, naddrs); + + for (i = 0; i < result; i++) { + addrs[i] = u[i].sin.sin_addr; + } + free(u); + return (result); +} + +int +res_findzonecut2(res_state statp, const char *dname, ns_class class, int opts, + char *zname, size_t zsize, union res_sockaddr_union *addrs, + int naddrs) { char mname[NS_MAXDNAME]; u_long save_pfcode; @@ -161,20 +190,20 @@ res_findzonecut(res_state statp, const char *dname, ns_class class, int opts, INIT_LIST(nsrrs); DPRINTF(("get the soa, and see if it has enough glue")); - if ((n = get_soa(statp, dname, class, zname, zsize, + if ((n = get_soa(statp, dname, class, opts, zname, zsize, mname, sizeof mname, &nsrrs)) < 0 || ((opts & RES_EXHAUSTIVE) == 0 && (n = satisfy(statp, mname, &nsrrs, addrs, naddrs)) > 0)) goto done; DPRINTF(("get the ns rrset and see if it has enough glue")); - if ((n = get_ns(statp, zname, class, &nsrrs)) < 0 || + if ((n = get_ns(statp, zname, class, opts, &nsrrs)) < 0 || ((opts & RES_EXHAUSTIVE) == 0 && (n = satisfy(statp, mname, &nsrrs, addrs, naddrs)) > 0)) goto done; DPRINTF(("get the missing glue and see if it's finally enough")); - if ((n = get_glue(statp, class, &nsrrs)) >= 0) + if ((n = get_glue(statp, class, opts, &nsrrs)) >= 0) n = satisfy(statp, mname, &nsrrs, addrs, naddrs); done: @@ -187,8 +216,8 @@ res_findzonecut(res_state statp, const char *dname, ns_class class, int opts, /* Private. */ static int -satisfy(res_state statp, - const char *mname, rrset_ns *nsrrsp, struct in_addr *addrs, int naddrs) +satisfy(res_state statp, const char *mname, rrset_ns *nsrrsp, + union res_sockaddr_union *addrs, int naddrs) { rr_ns *nsrr; int n, x; @@ -215,7 +244,9 @@ satisfy(res_state statp, } static int -add_addrs(res_state statp, rr_ns *nsrr, struct in_addr *addrs, int naddrs) { +add_addrs(res_state statp, rr_ns *nsrr, + union res_sockaddr_union *addrs, int naddrs) +{ rr_a *arr; int n = 0; @@ -231,7 +262,7 @@ add_addrs(res_state statp, rr_ns *nsrr, struct in_addr *addrs, int naddrs) { } static int -get_soa(res_state statp, const char *dname, ns_class class, +get_soa(res_state statp, const char *dname, ns_class class, int opts, char *zname, size_t zsize, char *mname, size_t msize, rrset_ns *nsrrsp) { @@ -332,7 +363,7 @@ get_soa(res_state statp, const char *dname, ns_class class, return (-1); } if (save_ns(statp, &msg, ns_s_ns, - zname, class, nsrrsp) < 0) { + zname, class, opts, nsrrsp) < 0) { DPRINTF(("get_soa: save_ns failed")); return (-1); } @@ -359,7 +390,9 @@ get_soa(res_state statp, const char *dname, ns_class class, } static int -get_ns(res_state statp, const char *zname, ns_class class, rrset_ns *nsrrsp) { +get_ns(res_state statp, const char *zname, ns_class class, int opts, + rrset_ns *nsrrsp) +{ u_char resp[NS_PACKETSZ]; ns_msg msg; int n; @@ -373,7 +406,7 @@ get_ns(res_state statp, const char *zname, ns_class class, rrset_ns *nsrrsp) { } /* Remember the NS RRs and associated A RRs that came back. */ - if (save_ns(statp, &msg, ns_s_an, zname, class, nsrrsp) < 0) { + if (save_ns(statp, &msg, ns_s_an, zname, class, opts, nsrrsp) < 0) { DPRINTF(("get_ns save_ns('%s', %s) failed", zname, p_class(class))); return (-1); @@ -383,7 +416,7 @@ get_ns(res_state statp, const char *zname, ns_class class, rrset_ns *nsrrsp) { } static int -get_glue(res_state statp, ns_class class, rrset_ns *nsrrsp) { +get_glue(res_state statp, ns_class class, int opts, rrset_ns *nsrrsp) { rr_ns *nsrr, *nsrr_n; /* Go and get the A RRs for each empty NS RR on our list. */ @@ -394,7 +427,7 @@ get_glue(res_state statp, ns_class class, rrset_ns *nsrrsp) { nsrr_n = NEXT(nsrr, link); - if (EMPTY(nsrr->addrs)) { + if (!nsrr->have_v4) { n = do_query(statp, nsrr->name, class, ns_t_a, resp, &msg); if (n < 0) { @@ -408,25 +441,47 @@ get_glue(res_state statp, ns_class class, rrset_ns *nsrrsp) { nsrr->name, p_class(class))); } if (save_a(statp, &msg, ns_s_an, nsrr->name, class, - &nsrr->addrs) < 0) { + opts, nsrr) < 0) { DPRINTF(("get_glue: save_r('%s', %s) failed", nsrr->name, p_class(class))); return (-1); } - /* If it's still empty, it's just chaff. */ - if (EMPTY(nsrr->addrs)) { - DPRINTF(("get_glue: removing empty '%s' NS", - nsrr->name)); - free_nsrr(nsrrsp, nsrr); + } + + if (!nsrr->have_v6) { + n = do_query(statp, nsrr->name, class, ns_t_aaaa, + resp, &msg); + if (n < 0) { + DPRINTF(("get_glue: do_query('%s', %s') failed", + nsrr->name, p_class(class))); + return (-1); + } + if (n > 0) { + DPRINTF(( + "get_glue: do_query('%s', %s') CNAME or DNAME found", + nsrr->name, p_class(class))); + } + if (save_a(statp, &msg, ns_s_an, nsrr->name, class, + opts, nsrr) < 0) { + DPRINTF(("get_glue: save_r('%s', %s) failed", + nsrr->name, p_class(class))); + return (-1); } } + + /* If it's still empty, it's just chaff. */ + if (EMPTY(nsrr->addrs)) { + DPRINTF(("get_glue: removing empty '%s' NS", + nsrr->name)); + free_nsrr(nsrrsp, nsrr); + } } return (0); } static int save_ns(res_state statp, ns_msg *msg, ns_sect sect, - const char *owner, ns_class class, + const char *owner, ns_class class, int opts, rrset_ns *nsrrsp) { int i; @@ -471,10 +526,12 @@ save_ns(res_state statp, ns_msg *msg, ns_sect sect, } INIT_LINK(nsrr, link); INIT_LIST(nsrr->addrs); + nsrr->have_v4 = 0; + nsrr->have_v6 = 0; APPEND(*nsrrsp, nsrr, link); } if (save_a(statp, msg, ns_s_ar, - nsrr->name, class, &nsrr->addrs) < 0) { + nsrr->name, class, opts, nsrr) < 0) { DPRINTF(("save_ns: save_r('%s', %s) failed", nsrr->name, p_class(class))); return (-1); @@ -485,8 +542,8 @@ save_ns(res_state statp, ns_msg *msg, ns_sect sect, static int save_a(res_state statp, ns_msg *msg, ns_sect sect, - const char *owner, ns_class class, - rrset_a *arrsp) + const char *owner, ns_class class, int opts, + rr_ns *nsrr) { int i; @@ -499,19 +556,46 @@ save_a(res_state statp, ns_msg *msg, ns_sect sect, p_section(sect, ns_o_query), i)); return (-1); } - if (ns_rr_type(rr) != ns_t_a || + if ((ns_rr_type(rr) != ns_t_a && ns_rr_type(rr) != ns_t_aaaa) || ns_rr_class(rr) != class || ns_samename(ns_rr_name(rr), owner) != 1 || ns_rr_rdlen(rr) != NS_INADDRSZ) continue; + if ((opts & RES_IPV6ONLY) != 0 && ns_rr_type(rr) != ns_t_aaaa) + continue; + if ((opts & RES_IPV4ONLY) != 0 && ns_rr_type(rr) != ns_t_a) + continue; arr = malloc(sizeof *arr); if (arr == NULL) { DPRINTF(("save_a: malloc failed")); return (-1); } INIT_LINK(arr, link); - memcpy(&arr->addr, ns_rr_rdata(rr), NS_INADDRSZ); - APPEND(*arrsp, arr, link); + memset(&arr->addr, 0, sizeof(arr->addr)); + switch (ns_rr_type(rr)) { + case ns_t_a: + arr->addr.sin.sin_family = AF_INET; +#ifdef HAVE_SA_LEN + arr->addr.sin.sin_len = sizeof(arr->addr.sin); +#endif + memcpy(&arr->addr.sin.sin_addr, ns_rr_rdata(rr), + NS_INADDRSZ); + arr->addr.sin.sin_port = htons(NAMESERVER_PORT); + nsrr->have_v4 = 1; + break; + case ns_t_aaaa: + arr->addr.sin6.sin6_family = AF_INET6; +#ifdef HAVE_SA_LEN + arr->addr.sin6.sin6_len = sizeof(arr->addr.sin6); +#endif + memcpy(&arr->addr.sin6.sin6_addr, ns_rr_rdata(rr), 16); + arr->addr.sin.sin_port = htons(NAMESERVER_PORT); + nsrr->have_v6 = 1; + break; + default: + abort(); + } + APPEND(nsrr->addrs, arr, link); } return (0); } diff --git a/contrib/bind/lib/resolv/res_send.c b/contrib/bind/lib/resolv/res_send.c index 6dfea59..6f0e430 100644 --- a/contrib/bind/lib/resolv/res_send.c +++ b/contrib/bind/lib/resolv/res_send.c @@ -70,7 +70,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "$Id: res_send.c,v 8.48 2001/07/03 06:27:17 marka Exp $"; +static const char rcsid[] = "$Id: res_send.c,v 8.49 2002/03/29 21:50:51 marka Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -521,17 +521,17 @@ get_salen(sa) { #ifdef HAVE_SA_LEN - /* there are people do not set sa_len. be forgibing to them */ + /* There are people do not set sa_len. Be forgiving to them. */ if (sa->sa_len) - return sa->sa_len; + return (sa->sa_len); #endif if (sa->sa_family == AF_INET) - return sizeof(struct sockaddr_in); - else if (sa->sa_family == AF_INET) - return sizeof(struct sockaddr_in6); + return (sizeof(struct sockaddr_in)); + else if (sa->sa_family == AF_INET6) + return (sizeof(struct sockaddr_in6)); else - return 0; /* unknown, die on connect */ + return (0); /* unknown, die on connect */ } /* diff --git a/contrib/bind/lib/resolv/res_update.c b/contrib/bind/lib/resolv/res_update.c index 54d3b15..12ee326 100644 --- a/contrib/bind/lib/resolv/res_update.c +++ b/contrib/bind/lib/resolv/res_update.c @@ -1,5 +1,5 @@ #if !defined(lint) && !defined(SABER) -static const char rcsid[] = "$Id: res_update.c,v 1.31 2001/11/01 05:21:23 marka Exp $"; +static const char rcsid[] = "$Id: res_update.c,v 1.34 2002/04/12 06:28:52 marka Exp $"; #endif /* not lint */ /* @@ -77,8 +77,6 @@ struct zonegrp { /* Forward. */ -static int nscopy(union res_sockaddr_union *, - const union res_sockaddr_union *, int); static void res_dprintf(const char *, ...); /* Macros. */ @@ -102,29 +100,21 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) { /* Thread all of the updates onto a list of groups. */ INIT_LIST(zgrps); + memset(&tgrp, 0, sizeof (tgrp)); for (rrecp = rrecp_in; rrecp; rrecp = LINKED(rrecp, r_link) ? NEXT(rrecp, r_link) : NULL) { - struct in_addr nsaddrs[MAXNS]; - int i; - /* XXX need to rewrite res_findzonecut */ - for (i = 0; i < MAXNS; i++) { - nsaddrs[i].s_addr = 0; - if (tgrp.z_nsaddrs[i].sin.sin_family == AF_INET) - nsaddrs[i] = tgrp.z_nsaddrs[i].sin.sin_addr; - } + int nscnt; /* Find the origin for it if there is one. */ tgrp.z_class = rrecp->r_class; - tgrp.z_nscount = - res_findzonecut(statp, rrecp->r_dname, tgrp.z_class, - RES_EXHAUSTIVE, - tgrp.z_origin, - sizeof tgrp.z_origin, - nsaddrs, MAXNS); - if (tgrp.z_nscount <= 0) { - DPRINTF(("res_findzonecut failed (%d)", - tgrp.z_nscount)); + nscnt = res_findzonecut2(statp, rrecp->r_dname, tgrp.z_class, + RES_EXHAUSTIVE, tgrp.z_origin, + sizeof tgrp.z_origin, + tgrp.z_nsaddrs, MAXNS); + if (nscnt <= 0) { + DPRINTF(("res_findzonecut failed (%d)", nscnt)); goto done; } + tgrp.z_nscount = nscnt; /* Find the group for it if there is one. */ for (zptr = HEAD(zgrps); zptr != NULL; zptr = NEXT(zptr, z_link)) if (ns_samename(tgrp.z_origin, zptr->z_origin) == 1 && @@ -166,9 +156,8 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) { goto done; /* Temporarily replace the resolver's nameserver set. */ - nscount = nscopy(nsaddrs, statp->_u._ext.ext->nsaddrs, statp->nscount); - statp->nscount = nscopy(statp->_u._ext.ext->nsaddrs, - zptr->z_nsaddrs, zptr->z_nscount); + nscount = res_getservers(statp, nsaddrs, MAXNS); + res_setservers(statp, zptr->z_nsaddrs, zptr->z_nscount); /* Send the update and remember the result. */ if (key != NULL) @@ -185,7 +174,7 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) { nzones++; /* Restore resolver's nameserver set. */ - statp->nscount = nscopy(statp->_u._ext.ext->nsaddrs, nsaddrs, nscount); + res_setservers(statp, nsaddrs, nscount); nscount = 0; } done: @@ -197,24 +186,13 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) { free(zptr); } if (nscount != 0) - statp->nscount = nscopy(statp->_u._ext.ext->nsaddrs, nsaddrs, nscount); + res_setservers(statp, nsaddrs, nscount); return (nzones); } /* Private. */ -static int -nscopy(union res_sockaddr_union *dst, const union res_sockaddr_union *src, - int n) -{ - int i; - - for (i = 0; i < n; i++) - dst[i] = src[i]; - return (n); -} - static void res_dprintf(const char *fmt, ...) { va_list ap; diff --git a/contrib/bind/port/freebsd/Makefile.set b/contrib/bind/port/freebsd/Makefile.set index c1c9bcf..acf7a56 100644 --- a/contrib/bind/port/freebsd/Makefile.set +++ b/contrib/bind/port/freebsd/Makefile.set @@ -1,5 +1,5 @@ 'CC=cc' -'CDEBUG=-O2 -g -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat' +'CDEBUG=-O2 -g -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -DMEMCLUSTER_RECORD=1' 'DESTBIN=/usr/bin' 'DESTSBIN=/usr/sbin' 'DESTEXEC=/usr/libexec' diff --git a/contrib/bind/port/freebsd/include/port_after.h b/contrib/bind/port/freebsd/include/port_after.h index 4d92355..6207f82 100644 --- a/contrib/bind/port/freebsd/include/port_after.h +++ b/contrib/bind/port/freebsd/include/port_after.h @@ -12,7 +12,6 @@ #define USE_LOG_CONS #define HAVE_CHROOT #define CAN_CHANGE_ID -#define MISSING_IN6ADDR_ANY #define _TIMEZONE timezone @@ -120,11 +119,45 @@ extern const struct in6_addr in6addr_any; IN6_ARE_ADDR_EQUAL(a, &in6addr_any) #endif +#ifndef IN6_IS_ADDR_LOOPBACK +extern const struct in6_addr isc_in6addr_loopback; +#define IN6_IS_ADDR_LOOPBACK(a) \ + IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback) +#endif + +#ifndef IN6_IS_ADDR_V4COMPAT +#define IN6_IS_ADDR_V4COMPAT(a) \ + ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \ + (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \ + (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \ + (a)->s6_addr[6] == 0x00 && (a)->s6_addr[7] == 0x00 && \ + (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \ + (a)->s6_addr[10] == 0x00 && (a)->s6_addr[11] == 0x00 && \ + ((a)->s6_addr[12] != 0x00 || (a)->s6_addr[13] != 0x00 || \ + (a)->s6_addr[14] != 0x00 || \ + ((a)->s6_addr[15] != 0x00 && (a)->s6_addr[15] != 1))) +#endif + +#ifndef IN6_IS_ADDR_V4MAPPED +#define IN6_IS_ADDR_V4MAPPED(a) \ + ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \ + (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \ + (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \ + (a)->s6_addr[6] == 0x00 && (a)->s6_addr[7] == 0x00 && \ + (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \ + (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff) +#endif + #ifndef IN6_IS_ADDR_SITELOCAL #define IN6_IS_ADDR_SITELOCAL(a) \ (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) #endif +#ifndef IN6_IS_ADDR_LINKLOCAL +#define IN6_IS_ADDR_LINKLOCAL(a) \ + (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) +#endif + #ifndef IN6_IS_ADDR_MULTICAST #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) #endif |