diff options
author | asmodai <asmodai@FreeBSD.org> | 2000-05-26 07:17:19 +0000 |
---|---|---|
committer | asmodai <asmodai@FreeBSD.org> | 2000-05-26 07:17:19 +0000 |
commit | 3f83b2963e3f1302f6507d3968aa3bfc93d7472d (patch) | |
tree | 58c578d1f5a84acb9535b8fc95abe2637662f30f /contrib/bind/lib/irs | |
parent | 08dfda8209739c209911999e8c76d369945766ed (diff) | |
download | FreeBSD-src-3f83b2963e3f1302f6507d3968aa3bfc93d7472d.zip FreeBSD-src-3f83b2963e3f1302f6507d3968aa3bfc93d7472d.tar.gz |
Virgin import of BIND v8.2.3-T5B
Diffstat (limited to 'contrib/bind/lib/irs')
-rw-r--r-- | contrib/bind/lib/irs/Makefile | 15 | ||||
-rw-r--r-- | contrib/bind/lib/irs/dns.c | 4 | ||||
-rw-r--r-- | contrib/bind/lib/irs/dns_ho.c | 21 | ||||
-rw-r--r-- | contrib/bind/lib/irs/dns_sv.c | 21 | ||||
-rw-r--r-- | contrib/bind/lib/irs/gethostent.c | 85 | ||||
-rw-r--r-- | contrib/bind/lib/irs/getnameinfo.c | 9 | ||||
-rw-r--r-- | contrib/bind/lib/irs/getpwent.c | 4 | ||||
-rw-r--r-- | contrib/bind/lib/irs/hesiod.c | 3 | ||||
-rw-r--r-- | contrib/bind/lib/irs/irp.c | 11 | ||||
-rw-r--r-- | contrib/bind/lib/irs/lcl.c | 4 | ||||
-rw-r--r-- | contrib/bind/lib/irs/nis.c | 4 | ||||
-rw-r--r-- | contrib/bind/lib/irs/util.c | 8 |
12 files changed, 118 insertions, 71 deletions
diff --git a/contrib/bind/lib/irs/Makefile b/contrib/bind/lib/irs/Makefile index 3421b8b..2c50e62 100644 --- a/contrib/bind/lib/irs/Makefile +++ b/contrib/bind/lib/irs/Makefile @@ -13,7 +13,7 @@ # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS # SOFTWARE. -# $Id: Makefile,v 8.16 1999/02/22 02:47:58 vixie Exp $ +# $Id: Makefile,v 8.19 2000/02/29 03:38:22 vixie Exp $ # these are only appropriate for BSD 4.4 or derivatives, and are used in # development. normal builds will be done in the top level directory and @@ -82,14 +82,15 @@ ${LIBBIND}: ${OBJS} ${RANLIB} ${LIBBIND} .c.${O}: - if test ! -d ${THREADED} ; then mkdir ${THREADED} ; fi + if test ! -d ${THREADED} ; then mkdir ${THREADED} ; else true ; fi -(${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} ${REENTRANT} -c $*.c \ -o ${THREADED}/$*.${O} ; \ - ${LDS} ${LD} ${LD_LIBFLAGS} ${THREADED}/$*.${O} && \ - ${LDS} mv a.out ${THREADED}/$*.${O}) + ${LDS} ${LD} ${LD_LIBFLAGS} ${THREADED}/$*.${O} \ + -o ${THREADED}/$*.out && \ + ${LDS} mv ${THREADED}/$*.out ${THREADED}/$*.${O}) ${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c - -${LDS} ${LD} ${LD_LIBFLAGS} $*.${O} -o a.out && \ - ${LDS} mv a.out $*.${O} + -${LDS} ${LD} ${LD_LIBFLAGS} $*.${O} -o $*.out && \ + ${LDS} mv $*.out $*.${O} distclean: clean @@ -97,7 +98,7 @@ clean: FRC rm -f .depend a.out core ${LIB} tags rm -f *.${O} *.BAK *.CKP *~ rm -f ${THREADED}/*.${O} - -rmdir ${THREADED} + -if test -d ${THREADED} ; then rmdir ${THREADED}; else true; fi depend: FRC mkdep -I${INCL} -I${PORTINCL} ${CPPFLAGS} ${SRCS} diff --git a/contrib/bind/lib/irs/dns.c b/contrib/bind/lib/irs/dns.c index 7ba7eec..66bdbf5 100644 --- a/contrib/bind/lib/irs/dns.c +++ b/contrib/bind/lib/irs/dns.c @@ -16,7 +16,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: dns.c,v 1.14 1999/01/18 07:46:47 vixie Exp $"; +static const char rcsid[] = "$Id: dns.c,v 1.15 2000/02/28 07:52:16 vixie Exp $"; #endif /* @@ -116,7 +116,7 @@ dns_res_get(struct irs_acc *this) { dns_res_set(this, res, free); } - if ((dns->res->options | RES_INIT) == 0 && + if ((dns->res->options & RES_INIT) == 0 && res_ninit(dns->res) < 0) return (NULL); diff --git a/contrib/bind/lib/irs/dns_ho.c b/contrib/bind/lib/irs/dns_ho.c index e319f96..8b2df77 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.26 1999/10/15 19:49:09 vixie Exp $"; +static const char rcsid[] = "$Id: dns_ho.c,v 1.28 2000/04/20 07:47:54 vixie Exp $"; #endif /* LIBC_SCCS and not lint */ /* Imports. */ @@ -394,7 +394,7 @@ gethostans(struct irs_ho *this, const HEADER *hp; const u_char *eom; const u_char *cp; - const char *tname; + const char *tname, **tap; char *bp, **ap, **hap; char tbuf[MAXDNAME+1]; @@ -583,9 +583,9 @@ gethostans(struct irs_ho *this, bp += nn; buflen -= nn; } - + /* Ensure alignment. */ bp += sizeof(align) - ((u_long)bp % sizeof(align)); - + /* Avoid overflows. */ if (bp + n >= &pvt->hostbuf[sizeof pvt->hostbuf]) { had_error++; continue; @@ -594,7 +594,19 @@ gethostans(struct irs_ho *this, cp += n; continue; } + /* Suppress duplicates. */ + for (tap = (const char **)pvt->h_addr_ptrs; + *tap != NULL; + tap++) + if (memcmp(*tap, cp, n) == 0) + break; + if (*tap != NULL) { + cp += n; + continue; + } + /* Store address. */ memcpy(*hap++ = bp, cp, n); + *hap = NULL; bp += n; cp += n; break; @@ -606,7 +618,6 @@ gethostans(struct irs_ho *this, } if (haveanswer) { *ap = NULL; - *hap = NULL; if (pvt->res->nsort && haveanswer > 1 && qtype == T_A) addrsort(pvt->res, pvt->h_addr_ptrs, haveanswer); diff --git a/contrib/bind/lib/irs/dns_sv.c b/contrib/bind/lib/irs/dns_sv.c index ea0ba70..e6cb2df 100644 --- a/contrib/bind/lib/irs/dns_sv.c +++ b/contrib/bind/lib/irs/dns_sv.c @@ -16,7 +16,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: dns_sv.c,v 1.17 1999/09/04 22:06:14 vixie Exp $"; +static const char rcsid[] = "$Id: dns_sv.c,v 1.19 2000/03/30 22:53:56 vixie Exp $"; #endif /* Imports */ @@ -105,8 +105,8 @@ irs_dns_sv(struct irs_acc *this) { sv->rewind = sv_rewind; sv->close = sv_close; sv->minimize = sv_minimize; - sv->res_get = sv_res_get; - sv->res_set = sv_res_set; + sv->res_get = NULL; /* sv_res_get; */ + sv->res_set = NULL; /* sv_res_set; */ return (sv); } @@ -150,7 +150,7 @@ sv_byport(struct irs_sv *this, int port, const char *proto) { char portstr[16]; char **hes_list; - sprintf(portstr, "%d", port); + sprintf(portstr, "%d", ntohs(port)); if (!(hes_list = hesiod_resolve(dns->hes_ctx, portstr, "port"))) return (NULL); @@ -193,12 +193,13 @@ parse_hes_list(struct irs_sv *this, char **hes_list, const char *proto) { p++; if (!*p) continue; - proto_len = strlen(proto); - if (strncasecmp(++p, proto, proto_len) != 0) - continue; - if (p[proto_len] && !isspace(p[proto_len])) - continue; - + if (proto) { + proto_len = strlen(proto); + if (strncasecmp(++p, proto, proto_len) != 0) + continue; + if (p[proto_len] && !isspace(p[proto_len])) + continue; + } /* OK, we've got a live one. Let's parse it for real. */ if (pvt->svbuf) free(pvt->svbuf); diff --git a/contrib/bind/lib/irs/gethostent.c b/contrib/bind/lib/irs/gethostent.c index ac66520..5d316c8 100644 --- a/contrib/bind/lib/irs/gethostent.c +++ b/contrib/bind/lib/irs/gethostent.c @@ -16,7 +16,7 @@ */ #if !defined(LINT) && !defined(CODECENTER) -static const char rcsid[] = "$Id: gethostent.c,v 1.25 1999/10/19 22:27:20 cyarnell Exp $"; +static const char rcsid[] = "$Id: gethostent.c,v 1.27 2000/04/20 07:10:33 vixie Exp $"; #endif /* Imports */ @@ -461,8 +461,32 @@ freehostent(struct hostent *he) { static int scan_interfaces(int *have_v4, int *have_v6) { - struct ifconf ifc; - struct ifreq ifreq; +#ifndef SIOCGLIFCONF +/* map new to old */ +#define SIOCGLIFCONF SIOCGIFCONF +#define lifc_len ifc_len +#define lifc_buf ifc_buf + struct ifconf lifc; +#else +#define SETFAMILYFLAGS + struct lifconf lifc; +#endif + +#ifndef SIOCGLIFADDR +/* map new to old */ +#define SIOCGLIFADDR SIOCGIFADDR +#endif + +#ifndef SIOCGLIFFLAGS +#define SIOCGLIFFLAGS SIOCGIFFLAGS +#define lifr_addr ifr_addr +#define lifr_name ifr_name +#define lifr_flags ifr_flags +#define ss_family sa_family + struct ifreq lifreq; +#else + struct lifreq lifreq; +#endif struct in_addr in4; struct in6_addr in6; char *buf = NULL, *cp, *cplim; @@ -484,27 +508,31 @@ scan_interfaces(int *have_v4, int *have_v6) { buf = memget(bufsiz); if (buf == NULL) goto err_ret; - ifc.ifc_len = bufsiz; - ifc.ifc_buf = buf; +#ifdef SETFAMILYFLAGS + lifc.lifc_family = AF_UNSPEC; + lifc.lifc_flags = 0; +#endif + lifc.lifc_len = bufsiz; + lifc.lifc_buf = buf; #ifdef IRIX_EMUL_IOCTL_SIOCGIFCONF /* * This is a fix for IRIX OS in which the call to ioctl with * the flag SIOCGIFCONF may not return an entry for all the * interfaces like most flavors of Unix. */ - if (emul_ioctl(&ifc) >= 0) + if (emul_ioctl(&lifc) >= 0) break; #else - if ((n = ioctl(s, SIOCGIFCONF, (char *)&ifc)) != -1) { + if ((n = ioctl(s, SIOCGLIFCONF, (char *)&lifc)) != -1) { /* * Some OS's just return what will fit rather * than set EINVAL if the buffer is too small * to fit all the interfaces in. If - * ifc.ifc_len is too near to the end of the + * lifc.lifc_len is too near to the end of the * buffer we will grow it just in case and * retry. */ - if (ifc.ifc_len + 2 * sizeof(ifreq) < bufsiz) + if (lifc.lifc_len + 2 * sizeof(lifreq) < bufsiz) break; } #endif @@ -519,44 +547,45 @@ scan_interfaces(int *have_v4, int *have_v6) { } /* Parse system's interface list. */ - cplim = buf + ifc.ifc_len; /* skip over if's with big ifr_addr's */ + cplim = buf + lifc.lifc_len; /* skip over if's with big ifr_addr's */ for (cp = buf; (*have_v4 == 0 || *have_v6 == 0) && cp < cplim; cp += cpsize) { - memcpy(&ifreq, cp, sizeof ifreq); + memcpy(&lifreq, cp, sizeof lifreq); #ifdef HAVE_SA_LEN #ifdef FIX_ZERO_SA_LEN - if (ifreq.ifr_addr.sa_len == 0) - ifreq.ifr_addr.sa_len = 16; + if (lifreq.lifr_addr.sa_len == 0) + lifreq.lifr_addr.sa_len = 16; #endif #ifdef HAVE_MINIMUM_IFREQ - cpsize = sizeof ifreq; - if (ifreq.ifr_addr.sa_len > sizeof (struct sockaddr)) - cpsize += (int)ifreq.ifr_addr.sa_len - + cpsize = sizeof lifreq; + if (lifreq.lifr_addr.sa_len > sizeof (struct sockaddr)) + cpsize += (int)lifreq.lifr_addr.sa_len - (int)(sizeof (struct sockaddr)); #else - cpsize = sizeof ifreq.ifr_name + ifreq.ifr_addr.sa_len; + cpsize = sizeof lifreq.lifr_name + lifreq.lifr_addr.sa_len; #endif /* HAVE_MINIMUM_IFREQ */ #elif defined SIOCGIFCONF_ADDR - cpsize = sizeof ifreq; + cpsize = sizeof lifreq; #else - cpsize = sizeof ifreq.ifr_name; + cpsize = sizeof lifreq.lifr_name; /* XXX maybe this should be a hard error? */ - if (ioctl(s, SIOCGIFADDR, (char *)&ifreq) < 0) + if (ioctl(s, SOICGLIFADDR, (char *)&lifreq) < 0) continue; #endif - switch (ifreq.ifr_addr.sa_family) { + switch (lifreq.lifr_addr.ss_family) { case AF_INET: if (*have_v4 == 0) { memcpy(&in4, &((struct sockaddr_in *) - &ifreq.ifr_addr)->sin_addr, sizeof in4); + &lifreq.lifr_addr)->sin_addr, + sizeof in4); if (in4.s_addr == INADDR_ANY) break; - n = ioctl(s, SIOCGIFFLAGS, (char *)&ifreq); + n = ioctl(s, SIOCGLIFFLAGS, (char *)&lifreq); if (n < 0) break; - if ((ifreq.ifr_flags & IFF_UP) == 0) + if ((lifreq.lifr_flags & IFF_UP) == 0) break; *have_v4 = 1; } @@ -565,13 +594,13 @@ scan_interfaces(int *have_v4, int *have_v6) { if (*have_v6 == 0) { memcpy(&in6, &((struct sockaddr_in6 *) - &ifreq.ifr_addr)->sin6_addr, sizeof in6); + &lifreq.lifr_addr)->sin6_addr, sizeof in6); if (memcmp(&in6, &in6addr_any, sizeof in6) == 0) break; - n = ioctl(s, SIOCGIFFLAGS, (char *)&ifreq); + n = ioctl(s, SIOCGLIFFLAGS, (char *)&lifreq); if (n < 0) break; - if ((ifreq.ifr_flags & IFF_UP) == 0) + if ((lifreq.lifr_flags & IFF_UP) == 0) break; *have_v6 = 1; } @@ -581,12 +610,14 @@ scan_interfaces(int *have_v4, int *have_v6) { if (buf != NULL) memput(buf, bufsiz); close(s); + /* printf("scan interface -> 4=%d 6=%d\n", *have_v4, *have_v6); */ return (0); err_ret: if (buf != NULL) memput(buf, bufsiz); if (s != -1) close(s); + /* printf("scan interface -> 4=%d 6=%d\n", *have_v4, *have_v6); */ return (-1); } diff --git a/contrib/bind/lib/irs/getnameinfo.c b/contrib/bind/lib/irs/getnameinfo.c index 3157c66..7bd30ae 100644 --- a/contrib/bind/lib/irs/getnameinfo.c +++ b/contrib/bind/lib/irs/getnameinfo.c @@ -110,7 +110,6 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) #endif int family, i; char *addr, *p; - u_long v4a; u_char pfx; static int firsttime = 1; static char numserv[512]; @@ -182,15 +181,11 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) switch (sa->sa_family) { case AF_INET: - v4a = ((struct sockaddr_in *)sa)->sin_addr.s_addr; - if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) - flags |= NI_NUMERICHOST; - v4a >>= IN_CLASSA_NSHIFT; - if (v4a == 0 || v4a == IN_LOOPBACKNET) + if (ntohl(*(u_long *)addr) >> IN_CLASSA_NSHIFT == 0) flags |= NI_NUMERICHOST; break; case AF_INET6: - pfx = ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr[0]; + pfx = *addr; if (pfx == 0 || pfx == 0xfe || pfx == 0xff) flags |= NI_NUMERICHOST; break; diff --git a/contrib/bind/lib/irs/getpwent.c b/contrib/bind/lib/irs/getpwent.c index 94f2df5..7f536a4 100644 --- a/contrib/bind/lib/irs/getpwent.c +++ b/contrib/bind/lib/irs/getpwent.c @@ -16,7 +16,7 @@ */ #if !defined(LINT) && !defined(CODECENTER) -static const char rcsid[] = "$Id: getpwent.c,v 1.20 1999/10/13 16:39:31 vixie Exp $"; +static const char rcsid[] = "$Id: getpwent.c,v 1.21 2000/02/21 21:40:56 vixie Exp $"; #endif /* Imports */ @@ -97,7 +97,7 @@ void endpwent() { struct net_data *net_data = init(); - return (endpwent_p(net_data)); + endpwent_p(net_data); } /* Shared private. */ diff --git a/contrib/bind/lib/irs/hesiod.c b/contrib/bind/lib/irs/hesiod.c index 54a6657..40826eb 100644 --- a/contrib/bind/lib/irs/hesiod.c +++ b/contrib/bind/lib/irs/hesiod.c @@ -1,5 +1,5 @@ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: hesiod.c,v 1.20 1999/02/22 04:09:06 vixie Exp $"; +static const char rcsid[] = "$Id: hesiod.c,v 1.21 2000/02/28 14:51:08 vixie Exp $"; #endif /* @@ -85,6 +85,7 @@ hesiod_init(void **context) { ctx->LHS = NULL; ctx->RHS = NULL; + ctx->res = NULL; if (parse_config_file(ctx, _PATH_HESIOD_CONF) < 0) { #ifdef DEF_RHS diff --git a/contrib/bind/lib/irs/irp.c b/contrib/bind/lib/irs/irp.c index c2b64ab..a6c8f4f 100644 --- a/contrib/bind/lib/irs/irp.c +++ b/contrib/bind/lib/irs/irp.c @@ -16,7 +16,7 @@ */ #if !defined(LINT) && !defined(CODECENTER) -static const char rcsid[] = "$Id: irp.c,v 8.5 1999/10/13 17:11:18 vixie Exp $"; +static const char rcsid[] = "$Id: irp.c,v 8.6 2000/02/04 08:28:33 vixie Exp $"; #endif /* Imports */ @@ -151,7 +151,9 @@ irs_irp_connect(struct irp_p *pvt) { int flags; struct sockaddr *addr; struct sockaddr_in iaddr; +#ifndef NO_SOCKADDR_UN struct sockaddr_un uaddr; +#endif long ipaddr; const char *irphost; int code; @@ -163,7 +165,9 @@ irs_irp_connect(struct irp_p *pvt) { return (-1); } +#ifndef NO_SOCKADDR_UN memset(&uaddr, 0, sizeof uaddr); +#endif memset(&iaddr, 0, sizeof iaddr); irphost = getenv(IRPD_HOST_ENV); @@ -171,6 +175,7 @@ irs_irp_connect(struct irp_p *pvt) { irphost = "127.0.0.1"; } +#ifndef NO_SOCKADDR_UN if (irphost[0] == '/') { addr = (struct sockaddr *)&uaddr; strncpy(uaddr.sun_path, irphost, sizeof uaddr.sun_path); @@ -179,7 +184,9 @@ irs_irp_connect(struct irp_p *pvt) { #ifdef HAVE_SA_LEN uaddr.sun_len = socklen; #endif - } else { + } else +#endif + { if (inet_pton(AF_INET, irphost, &ipaddr) != 1) { errno = EADDRNOTAVAIL; perror("inet_pton"); diff --git a/contrib/bind/lib/irs/lcl.c b/contrib/bind/lib/irs/lcl.c index 46c7743..16e167f 100644 --- a/contrib/bind/lib/irs/lcl.c +++ b/contrib/bind/lib/irs/lcl.c @@ -16,7 +16,7 @@ */ #if !defined(LINT) && !defined(CODECENTER) -static const char rcsid[] = "$Id: lcl.c,v 1.15 1999/10/13 16:39:32 vixie Exp $"; +static const char rcsid[] = "$Id: lcl.c,v 1.16 2000/02/28 07:52:16 vixie Exp $"; #endif /* Imports */ @@ -104,7 +104,7 @@ lcl_res_get(struct irs_acc *this) { lcl_res_set(this, res, free); } - if ((lcl->res->options | RES_INIT) == 0 && + if ((lcl->res->options & RES_INIT) == 0 && res_ninit(lcl->res) < 0) return (NULL); diff --git a/contrib/bind/lib/irs/nis.c b/contrib/bind/lib/irs/nis.c index fcd9b79..e19068a 100644 --- a/contrib/bind/lib/irs/nis.c +++ b/contrib/bind/lib/irs/nis.c @@ -16,7 +16,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: nis.c,v 1.13 1999/01/18 07:46:58 vixie Exp $"; +static const char rcsid[] = "$Id: nis.c,v 1.14 2000/02/28 07:52:16 vixie Exp $"; #endif /* Imports */ @@ -114,7 +114,7 @@ nis_res_get(struct irs_acc *this) { nis_res_set(this, res, free); } - if ((nis->res->options | RES_INIT) == 0 && + if ((nis->res->options & RES_INIT) == 0 && res_ninit(nis->res) < 0) return (NULL); diff --git a/contrib/bind/lib/irs/util.c b/contrib/bind/lib/irs/util.c index 8965af5..1d097c6 100644 --- a/contrib/bind/lib/irs/util.c +++ b/contrib/bind/lib/irs/util.c @@ -16,7 +16,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: util.c,v 1.10 1999/01/08 19:25:11 vixie Exp $"; +static const char rcsid[] = "$Id: util.c,v 1.11 2000/02/04 08:28:33 vixie Exp $"; #endif #include "port_before.h" @@ -48,18 +48,18 @@ static const char rcsid[] = "$Id: util.c,v 1.10 1999/01/08 19:25:11 vixie Exp $" void map_v4v6_address(const char *src, char *dst) { u_char *p = (u_char *)dst; - char tmp[INADDRSZ]; + char tmp[NS_INADDRSZ]; int i; /* Stash a temporary copy so our caller can update in place. */ - memcpy(tmp, src, INADDRSZ); + memcpy(tmp, src, NS_INADDRSZ); /* Mark this ipv6 addr as a mapped ipv4. */ for (i = 0; i < 10; i++) *p++ = 0x00; *p++ = 0xff; *p++ = 0xff; /* Retrieve the saved copy and we're done. */ - memcpy((void*)p, tmp, INADDRSZ); + memcpy((void*)p, tmp, NS_INADDRSZ); } int |