Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/dist/bind Pull up revisions 1.4-1.5 (requested by itojun):



details:   https://anonhg.NetBSD.org/src/rev/5b61d4df86ba
branches:  netbsd-1-5
changeset: 493176:5b61d4df86ba
user:      he <he%NetBSD.org@localhost>
date:      Mon Jul 01 17:13:43 2002 +0000

description:
Pull up revisions 1.4-1.5 (requested by itojun):
  Update BIND to version 8.3.3.

diffstat:

 dist/bind/bin/dig/dig.c           |  350 ++++++++++++++------
 dist/bind/bin/named/db_load.c     |  171 +++++++--
 dist/bind/bin/named/db_update.c   |   79 ++-
 dist/bind/bin/named/ns_ixfr.c     |   95 ++--
 dist/bind/bin/named/ns_notify.c   |   97 +++-
 dist/bind/bin/named/ns_parser.y   |  208 ++++++++---
 dist/bind/bin/named/ns_req.c      |  641 +++++++++++++++++++++++++++++--------
 dist/bind/bin/named/ns_update.c   |  218 ++++++------
 dist/bind/bin/nslookup/getinfo.c  |  461 ++++++++++++++++++++------
 dist/bind/lib/dst/dst_api.c       |   69 ++-
 dist/bind/lib/isc/ev_timers.c     |   19 +-
 dist/bind/lib/resolv/res_debug.c  |  225 +++++++++----
 dist/bind/lib/resolv/res_send.c   |  289 +++++++++++++---
 dist/bind/lib/resolv/res_update.c |   72 +--
 14 files changed, 2096 insertions(+), 898 deletions(-)

diffs (truncated from 6284 to 300 lines):

diff -r 821a383a1d87 -r 5b61d4df86ba dist/bind/bin/dig/dig.c
--- a/dist/bind/bin/dig/dig.c   Mon Jul 01 17:13:08 2002 +0000
+++ b/dist/bind/bin/dig/dig.c   Mon Jul 01 17:13:43 2002 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: dig.c,v 1.1.1.1.8.3 2001/01/28 15:52:36 he Exp $       */
+/*     $NetBSD: dig.c,v 1.1.1.1.8.4 2002/07/01 17:13:43 he Exp $       */
 
 #ifndef lint
-static const char rcsid[] = "Id: dig.c,v 8.44 2000/12/23 08:14:31 vixie Exp";
+static const char rcsid[] = "Id: dig.c,v 8.57 2002/06/18 02:26:49 marka Exp";
 #endif
 
 /*
@@ -174,7 +174,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <netdb.h>
-#include <resolv.h>
 #include <setjmp.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -183,6 +182,8 @@
 
 #include "port_after.h"
 
+#include <resolv.h>
+
 #include "../nslookup/res.h"
 
 /* Global. */
@@ -190,9 +191,15 @@
 #define VERSION 83
 #define VSTRING "8.3"
 
-#define PRF_DEF                0x2ff9
-#define PRF_MIN                0xA930
-#define PRF_ZONE        0x24f9
+#define PRF_DEF                (RES_PRF_STATS | RES_PRF_CMD | RES_PRF_QUES | \
+                        RES_PRF_ANS | RES_PRF_AUTH | RES_PRF_ADD | \
+                        RES_PRF_HEAD1 | RES_PRF_HEAD2 | RES_PRF_TTLID | \
+                        RES_PRF_HEADX | RES_PRF_REPLY | RES_PRF_TRUNC)
+#define PRF_MIN                (RES_PRF_QUES | RES_PRF_ANS | RES_PRF_HEAD1 | \
+                        RES_PRF_HEADX | RES_PRF_REPLY | RES_PRF_TRUNC)
+#define PRF_ZONE        (RES_PRF_STATS | RES_PRF_CMD | RES_PRF_QUES | \
+                        RES_PRF_ANS | RES_PRF_AUTH | RES_PRF_ADD | \
+                        RES_PRF_TTLID | RES_PRF_REPLY | RES_PRF_TRUNC)
 
 #ifndef MAXHOSTNAMELEN
 #define MAXHOSTNAMELEN 256
@@ -205,9 +212,10 @@
 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 */
@@ -221,7 +229,7 @@
 extern int     StringToClass(), StringToType();        /* subr.c */
 #if defined(BSD) && BSD >= 199006 && !defined(RISCOS_BSD)
 FILE           *yyin = NULL;
-void           yyrestart(FILE *f) { }
+void           yyrestart(FILE *f) { UNUSED(f); }
 #endif
 char           *pager = NULL;
 /* end of nslookup stuff */
@@ -239,13 +247,14 @@
 static struct timeval  difftv(struct timeval, struct timeval);
 static void            prnttime(struct timeval);
 static void            stackarg(char *, char **);
+static void            reverse6(char *, struct in6_addr *);
 
 /* Public. */
 
 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_;
@@ -283,6 +292,8 @@
        int wait=0, delay;
        int envset=0, envsave=0;
        struct __res_state res_x, res_t;
+       int r;
+       struct in6_addr in6;
 
        ns_tsig_key key;
        char *keyfile = NULL, *keyname = NULL;
@@ -298,6 +309,14 @@
        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;
 
@@ -348,7 +367,6 @@
 
        res.id = 1;
        gettimeofday(&tv1, NULL);
-       assert(tv1.tv_usec >= 0 && tv1.tv_usec < 1000000);
 
 /*
  * Main section: once if cmd-line query
@@ -451,13 +469,21 @@
                                                printf("; no arg for -t?\n");
                                        else if ((tmp = atoi(*argv))
                                            || *argv[0]=='0') {
-                                               queryType = tmp;
-                                               qtypeSet++;
+                                               if (ns_t_xfr_p(tmp)) {
+                                                       xfr = tmp;
+                                               } else {
+                                                       queryType = tmp;
+                                                       qtypeSet++;
+                                               }
                                        } else if ((tmp = StringToType(*argv,
                                                                      0, NULL)
                                                   ) != 0) {
-                                               queryType = tmp;
-                                               qtypeSet++;
+                                               if (ns_t_xfr_p(tmp)) {
+                                                       xfr = tmp;
+                                               } else {
+                                                       queryType = tmp;
+                                                       qtypeSet++;
+                                               }
                                        } else {
                                                printf(
                                                   "; invalid type specified\n"
@@ -473,6 +499,11 @@
                                                printf("; no arg for -x?\n");
                                                break;
                                        }
+                                       r = inet_pton(AF_INET6, addrc, &in6);
+                                       if (r > 0) {
+                                               reverse6(domain, &in6);
+                                               break;
+                                       }
                                        addrend = addrc + strlen(addrc);
                                        if (*addrend == '.')
                                                *addrend = '\0';
@@ -487,7 +518,7 @@
                                        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
@@ -519,14 +550,19 @@
                                                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':
@@ -738,82 +774,113 @@
                srvbuf[0] = 0;
                srvmsg = defsrv;
                if (srv != NULL) {
-                       struct in_addr addr;
+                       int nscount = 0;
+                       union res_sockaddr_union u[MAXNS];
+                       struct addrinfo *answer = NULL;
+                       struct addrinfo *cur = NULL;
+                       struct addrinfo hint;
 
-                       if (inet_aton(srv, &addr)) {
-                               res.nscount = 1;
-                               res.nsaddr.sin_addr = addr;
-                               srvmsg = strcat(srvbuf, srv);
+                       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;
+                               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;
+                                       }
+                               }
+                               if (nscount != 0) {
+                                       char buf[80];
+                                       res_setservers(&res, u, nscount);
+                                       srvmsg = strcat(srvbuf, srv);
+                                       strcat(srvbuf, "  ");
+                                       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_INET6,
+                                                         &u[0].sin6.sin6_addr,
+                                                         buf, sizeof(buf));
+                                               break;
+                                       }
+                                       strcat(srvbuf, buf);
+                               }
+                               freeaddrinfo(answer);
                        } else {
-                               res_t = res;
-                               res_ninit(&res);
-                               res.pfcode = 0;
-                               res.options = RES_DEFAULT;
-                               hp = gethostbyname(srv);
                                res = res_t;
-                               if (hp == NULL
-                                   || hp->h_addr_list == NULL
-                                   || *hp->h_addr_list == NULL) {
-                                       fflush(stdout);
-                                       fprintf(stderr,
+                               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;
-                                       }
-
-                                       srvmsg = strcat(srvbuf,srv);
-                                       strcat(srvbuf, "  ");
-                                       strcat(srvmsg,
-                                              inet_ntoa(res.nsaddr.sin_addr));
-                               }
+                               fflush(stderr);
+                               srvmsg = defsrv;
+                               srv = NULL;
                        }
                        printf("; (%d server%s found)\n",
                               res.nscount, (res.nscount==1)?"":"s");
                        res.id += res.retry;
                }



Home | Main Index | Thread Index | Old Index