diff --context --recurs m:\bind495t5b/CHANGES m:\bind495t6b/CHANGES
*** m:\bind495t5b/CHANGES	Sat Sep 28 15:24:14 1996
--- m:\bind495t6b/CHANGES	Tue Oct 08 12:55:55 1996
***************
*** 1,4 ****
! $Id: CHANGES,v 8.46 1996/09/28 06:50:55 vixie Exp $
  
  	--- 4.9.5-t5b released ---
  
--- 1,36 ----
! $Id: CHANGES,v 8.47 1996/10/08 04:50:57 vixie Exp $
! 
! 	--- 4.9.5-t6b released ---
! 
! 740. [bug]	dangling cname checking had a few memory leaks.
! 
! 739. [func]	SRV support made more complete; NAPTR support added.
! 
! 738. [protocol]	dangling CNAMEs are no longer considered format errors.
! 
! 737. [bug]	owner domain names like "*." were not considered valid.
! 
! 736. [contrib]	new version of contrib/host included.
! 
! 735. [doc]	added some text to shres/solaris/INSTALL.
! 
! 734. [bug]	loading a zone with a single line SOA RR killed following line.
! 
! 733. [bug]	priming could deadlock in odd cases.
! 
! 732. [bug]	SIGHUP now caught before initial zone load.
! 
! 731. [bug]	IP/TCP session logging now controlled by #ifdef DEBUG.
! 
! 730. [port]	untested HPUX 10 support added to top level Makefile.
! 
! 729. [port]	ultrix vs. _res_close(); ultrix wins.
! 
! 728. [bug]	several d_rcode references weren't #ifdef'd NCACHE.
! 
! 727. [bug]	SOA timer warnings now consistently logged at LOG_WARNING.
! 
! 726. [protocol]	added T_NAPTR as RR type 35, hoping the IANA concurs.
  
  	--- 4.9.5-t5b released ---
  
diff --context --recurs m:\bind495t5b/Makefile m:\bind495t6b/Makefile
*** m:\bind495t5b/Makefile	Sat Sep 28 15:24:13 1996
--- m:\bind495t6b/Makefile	Tue Oct 08 12:55:55 1996
***************
*** 1,16 ****
  # Makefile for BIND>=4.9 top level
  # vixie@decwrl December, 1992 [original]
  #
! # $Id: Makefile,v 8.45 1996/09/28 06:50:55 vixie Exp $
  
! ## ++Copyright++ 1989
  ## -
! ## Copyright (c) 1989
! ##    The Regents of the University of California.  All rights reserved.
  ## 
! ## Redistribution and use in source and binary forms, with or without
! ## modification, are permitted provided that the following conditions
! ## are met:
  ## 1. Redistributions of source code must retain the above copyright
  ##    notice, this list of conditions and the following disclaimer.
  ## 2. Redistributions in binary form must reproduce the above copyright
--- 1,16 ----
  # Makefile for BIND>=4.9 top level
  # vixie@decwrl December, 1992 [original]
  #
! # $Id: Makefile,v 8.46 1996/10/08 04:50:57 vixie Exp $
  
! ## ++Copyright++ 1989
  ## -
! ## Copyright (c) 1989
! ##    The Regents of the University of California.  All rights reserved.
  ## 
! ## Redistribution and use in source and binary forms, with or without
! ## modification, are permitted provided that the following conditions
! ## are met:
  ## 1. Redistributions of source code must retain the above copyright
  ##    notice, this list of conditions and the following disclaimer.
  ## 2. Redistributions in binary form must reproduce the above copyright
***************
*** 56,62 ****
  ## -
  ## --Copyright--
  
! VER = 4.9.5-T5B
  SHELL = /bin/sh
  MAKE = make
  DESTDIR =
--- 56,62 ----
  ## -
  ## --Copyright--
  
! VER = 4.9.5-T6B
  SHELL = /bin/sh
  MAKE = make
  DESTDIR =
***************
*** 361,366 ****
--- 361,385 ----
  #KSYMS = /hp-ux
  #KMEM = /dev/kmem
  #UDPSUM = udpcksum
+ #(bsdinstall.sh is in conf/)
+ 
+ #(hpux10.10)
+ #CC = cc $(CPPFLAGS)
+ #CDEBUG = -g
+ #CPPFLAGS =
+ #LEX = lex
+ #LIBS = -ll
+ #PIDDIR = /etc
+ #DESTSBIN = /usr/sbin
+ #DESTEXEC = /usr/sbin
+ #DESTMAN = /usr/man
+ #DESTHELP = /usr/lib
+ #LDS = :
+ #INSTALL = bsdinstall.sh
+ #RANLIB = :
+ #MANROFF = cat
+ #PS = ps -p
+ #INSTALL_COMPAT = install
  #(bsdinstall.sh is in conf/)
  
  #(apollo domainos)
Only in m:\bind495t5b: bind-4.9.5-T5B.tar
Only in m:\bind495t6b: bind-4.9.5-T6B.tar
Only in m:\bind495t6b/contrib/decwrl: gethost
diff --context --recurs m:\bind495t5b/contrib/decwrl/gethost.c m:\bind495t6b/contrib/decwrl/gethost.c
*** m:\bind495t5b/contrib/decwrl/gethost.c	Sat Sep 28 15:24:10 1996
--- m:\bind495t6b/contrib/decwrl/gethost.c	Tue Oct 08 12:55:50 1996
***************
*** 5,20 ****
  /* DECWRL Header: host.c,v 1.1 89/04/05 15:41:12 vixie Locked $ */
  
  #ifndef lint
! static char RcsId[] = "$Id: gethost.c,v 1.8 1996/05/21 07:04:29 vixie Exp $";
  #endif
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
! #include <stdio.h>
  #include <resolv.h>
  #include <netdb.h>
  #include <syslog.h>
--- 5,20 ----
  /* DECWRL Header: host.c,v 1.1 89/04/05 15:41:12 vixie Locked $ */
  
  #ifndef lint
! static char RcsId[] = "$Id: gethost.c,v 1.9 1996/10/08 04:51:00 vixie Exp $";
  #endif
  
! #include <sys/param.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
! #include <stdio.h>
  #include <resolv.h>
  #include <netdb.h>
  #include <syslog.h>
***************
*** 66,72 ****
  		goto usage;
  	arg = *argv++; argc--;
  
! 	if (inet_pton(af, arg, b_addr, sizeof b_addr)) {
  		char p[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
  
  		printf("[%s]\n", inet_ntop(af, b_addr, p, sizeof p));
--- 66,72 ----
  		goto usage;
  	arg = *argv++; argc--;
  
! 	if (inet_pton(af, arg, b_addr)) {
  		char p[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
  
  		printf("[%s]\n", inet_ntop(af, b_addr, p, sizeof p));
diff --context --recurs m:\bind495t5b/contrib/host/Makefile m:\bind495t6b/contrib/host/Makefile
*** m:\bind495t5b/contrib/host/Makefile	Wed Apr 17 08:08:08 1996
--- m:\bind495t6b/contrib/host/Makefile	Sun Sep 29 18:31:08 1996
***************
*** 1,13 ****
! #	@(#)Makefile            e07@nikhef.nl (Eric Wassenaar) 960417
  
  # ----------------------------------------------------------------------
! # Adapt the installation directories to your local standards.
  # ----------------------------------------------------------------------
  
! # This is where the host executable will go.
! DESTBIN = /usr/local/bin
  
! # This is where the host manual page will go.
  DESTMAN = /usr/local/man
  
  BINDIR = $(DESTBIN)
--- 1,13 ----
! #	@(#)Makefile            e07@nikhef.nl (Eric Wassenaar) 960929
  
  # ----------------------------------------------------------------------
! # Adapt the installation directories to your local standards.
  # ----------------------------------------------------------------------
  
! # This is where the host executable will go.
! DESTBIN = /usr/local/bin
  
! # This is where the host manual page will go.
  DESTMAN = /usr/local/man
  
  BINDIR = $(DESTBIN)
***************
*** 84,89 ****
--- 84,90 ----
  # Select your favorite compiler.
  CC = /usr/ucb/cc			#if defined(solaris) && BSD
  CC = /bin/cc -arch m68k -arch i386	#if defined(next)
+ CC = /bin/cc -Olimit 1000		#if defined(ultrix)
  CC = /bin/cc
  CC = cc
  
***************
*** 150,157 ****
  DOCS = RELEASE_NOTES
  
  UTILS = nslookup mxlookup
  
! FILES = Makefile $(DOCS) $(HDRS) $(SRCS) $(MANS) $(UTILS)
  
  PACKAGE = host
  TARFILE = $(PACKAGE).tar
--- 151,159 ----
  DOCS = RELEASE_NOTES
  
  UTILS = nslookup mxlookup
+ MISCS = malloc.c
  
! FILES = Makefile $(DOCS) $(HDRS) $(SRCS) $(MANS) $(UTILS) $(MISCS)
  
  PACKAGE = host
  TARFILE = $(PACKAGE).tar
***************
*** 187,193 ****
  ABBREVIATIONS = mb mg mr minfo				# deprecated
  ABBREVIATIONS = md mf null				# obsolete
  ABBREVIATIONS = rp afsdb x25 isdn rt nsap nsap-ptr	# new
! ABBREVIATIONS = sig key px gpos aaaa loc		# very new
  ABBREVIATIONS = uinfo uid gid unspec			# nonstandard
  ABBREVIATIONS = maila mailb any				# filters
  
--- 189,195 ----
  ABBREVIATIONS = mb mg mr minfo				# deprecated
  ABBREVIATIONS = md mf null				# obsolete
  ABBREVIATIONS = rp afsdb x25 isdn rt nsap nsap-ptr	# new
! ABBREVIATIONS = sig key px gpos aaaa loc nxt srv	# very new
  ABBREVIATIONS = uinfo uid gid unspec			# nonstandard
  ABBREVIATIONS = maila mailb any				# filters
  
diff --context --recurs m:\bind495t5b/contrib/host/RELEASE_NOTES m:\bind495t6b/contrib/host/RELEASE_NOTES
*** m:\bind495t5b/contrib/host/RELEASE_NOTES	Sat Aug 24 05:18:22 1996
--- m:\bind495t6b/contrib/host/RELEASE_NOTES	Sun Sep 29 21:24:10 1996
***************
*** 1,15 ****
! 	@(#)RELEASE_NOTES       e07@nikhef.nl (Eric Wassenaar) 960808
  
! yymmdd		Description of changes per release
! TODO		Things that still need to be done
! WISHLIST	Wishes expressed by various people
! NOTES		Important issues to keep in mind
! MISC		Miscellaneous reminders
  
  # ----------------------------------------------------------------------
! # Description of changes per release
  # ----------------------------------------------------------------------
  
  960808
  	Conform to BIND 4.9.5 interpretation of TXT strings.
  		When multiple strings are encoded, they are now treated
--- 1,92 ----
! 	@(#)RELEASE_NOTES       e07@nikhef.nl (Eric Wassenaar) 960929
  
! yymmdd		Description of changes per release
! TODO		Things that still need to be done
! WISHLIST	Wishes expressed by various people
! NOTES		Important issues to keep in mind
! MISC		Miscellaneous reminders
  
  # ----------------------------------------------------------------------
! # Description of changes per release
  # ----------------------------------------------------------------------
  
+ 960929
+ 	New resource records and query types.
+ 		Define the new IXFR type as per RFC 1995. No support
+ 		for this yet, however.
+ 		Add support for T_KEY and T_SIG resource records.
+ 		These require some new utility functions.
+ 		Recognize T_NXT and T_SRV which still have draft status.
+ 	Extra safety checks.
+ 		After a positive return from an ordinary gethostbyname
+ 		or gethostbyaddr we cannot be absolutely sure that the
+ 		size of the canonical h_name is within bounds.
+ 		Note that this is guaranteed by host's internal modules.
+ 	Minor fixes.
+ 		Be more restrictive with respect to wildcard checking.
+ 		Make sure it is really specified as the first label.
+ 		Construct reverse in-addr.arpa name without trailing dot
+ 		if we know that this is already an absolute name.
+ 	Miscellaneous changes.
+ 		Print also the input name we are going to hostalias().
+ 		Rename a few variables for better readability.
+ 		Add various definitions that might be missing in the
+ 		default include files on some weird platforms.
+ 		Use a configurable limit for the number of recursive
+ 		chain lookups.
+ 		Some cleanup to avoid lint warnings on some platforms.
+ 	Revised manual page.
+ 		Some items needed an update.
+ 		Extend the list of related RFCs.
+ 		Several layout changes, suggested by Greg Woods.
+ 
+ 960921
+ 	Extend functionality of -A option.
+ 		If the -A flag is specified along with any explicit
+ 		list mode option, it not only enables reversed address
+ 		checking, it also enables those special checks that are
+ 		normally suppressed during recursive listings, such as
+ 		checks for canonical host names and invalid underscores.
+ 	Revise -p option plus explicit server.
+ 		Consider the set of NS servers gotten from an explicit
+ 		server as authoritative if the -p option is also given.
+ 		This affects whether or not to print lame delegation
+ 		warnings in case the SOA record could not be retrieved.
+ 		Suppress lame delegation warnings in case the A records
+ 		for NS servers could not be retrieved and an explicit
+ 		server is specified. The latter was an oversight.
+ 		Indicated by Peter Koch <pk@TechFak.Uni-Bielefeld.DE>
+ 	Improve error reporting.
+ 		After a negative return from an ordinary gethostbyname
+ 		or gethostbyaddr we don't know whether or not the answer
+ 		was authoritative. Perform an extra lookup in some few
+ 		cases where we really want to distinguish between them.
+ 		This is kludgy, and needs improvement.
+ 	Revise additional checking during RR printout.
+ 		This prevents possible recursive loops in some cases.
+ 		Requires adapting the way state information is passed
+ 		via print_info() and print_rrec().
+ 	Make query section consistency checks.
+ 		When retrieving certain crucial information, such as
+ 		SOA or NS records, make sure the qdcount is exactly one
+ 		as it should be.
+ 		The values in the query section in a reply should match
+ 		those in the original query. This is already enforced
+ 		by the BIND 4.9 res_send(). An error is reported when a
+ 		mismatch is detected, but results are processed anyway.
+ 	Make sure response comes from a known server.
+ 		When using datagrams, compare the source address of the
+ 		response to the list of known servers. Ignore the answer	
+ 		if there is a mismatch. Was missing for HOST_RES_SEND.
+ 	Minor bug fixes.
+ 		When retrieving SOA records, make sure they belong to
+ 		the requested domain.
+ 		Must properly set h_errno in some obscure circumstances.
+ 	Miscellaneous changes.
+ 		Clear the entire sockaddr_in before filling in the
+ 		relevant entries. Some platforms seem to rely on
+ 		sin_zero being actually zero.
+ 
  960808
  	Conform to BIND 4.9.5 interpretation of TXT strings.
  		When multiple strings are encoded, they are now treated
***************
*** 731,736 ****
--- 808,822 ----
  		were encountered during the reverse lookup.
  		It is unclear what the official host name should be.
  		Should perhaps abandon the idea of official host name.
+ 		However, the PTR records are still exempt from the new
+ 		round-robin scheduling, and are returned in the order
+ 		in which they are defined in the zone file.
+ 
+ 	Enhance error reporting.
+ 		After a negative return from gethostbyname/gethostbyaddr
+ 		we want to know whether the answer was authoritative or
+ 		not. In a few places we are able to find out, but this
+ 		is a kludge and needs to be reimplemented.
  
  # ----------------------------------------------------------------------
  # WISHLIST
diff --context --recurs m:\bind495t5b/contrib/host/conf.h m:\bind495t6b/contrib/host/conf.h
*** m:\bind495t5b/contrib/host/conf.h	Sat May 11 22:39:34 1996
--- m:\bind495t6b/contrib/host/conf.h	Sun Sep 29 18:33:43 1996
***************
*** 1,15 ****
  /*
  ** Various configuration definitions.
  **
! **	@(#)conf.h              e07@nikhef.nl (Eric Wassenaar) 960512
! */
  
  /*
!  * A special version of res_send() is included, which returns additional
!  * errno statuses, and which corrects some flaws in the BIND 4.8 version.
   */
  
! #if !defined(HOST_RES_SEND) && !defined(BIND_RES_SEND)
  
  #if defined(BIND_49)
  #define BIND_RES_SEND		/* use the default BIND res_send() */
--- 1,15 ----
  /*
  ** Various configuration definitions.
  **
! **	@(#)conf.h              e07@nikhef.nl (Eric Wassenaar) 960929
! */
  
  /*
!  * A special version of res_send() is included, which returns additional
!  * errno statuses, and which corrects some flaws in the BIND 4.8 version.
   */
  
! #if !defined(HOST_RES_SEND) && !defined(BIND_RES_SEND)
  
  #if defined(BIND_49)
  #define BIND_RES_SEND		/* use the default BIND res_send() */
***************
*** 54,63 ****
  #define T_LOC_VERSION	0	/* must be zero */
  
  /*
   * Miscellaneous constants.
   */
  
! #define MAXADDRS	35	/* max address count from gethostnamadr.c */
  #define MAXNSNAME	16	/* maximum count of nameservers per zone */
  #define MAXIPADDR	10	/* maximum count of addresses per nameserver */
  
--- 54,81 ----
  #define T_LOC_VERSION	0	/* must be zero */
  
  /*
+  * Various constants related to MD5 signatures.
+  */
+ 
+ #define	MAXMD5BITS	2552
+ #define	MAXMD5SIZE	(2*((MAXMD5BITS+7)/8)+3)
+ #define	MAXB64SIZE	(4*((MAXMD5SIZE+2)/3))
+ 
+ /*
+  * The standard nameserver port.
+  */
+ 
+ #ifndef NAMESERVER_PORT
+ #define NAMESERVER_PORT	53
+ #endif
+ 
+ /*
   * Miscellaneous constants.
   */
  
! #define MAXCHAIN	10	/* maximum count of recursive chain lookups */
! #define MAXALIAS	35	/* max aliases count from gethnamaddr.c */
! #define MAXADDRS	35	/* max address count from gethnamaddr.c */
  #define MAXNSNAME	16	/* maximum count of nameservers per zone */
  #define MAXIPADDR	10	/* maximum count of addresses per nameserver */
  
diff --context --recurs m:\bind495t5b/contrib/host/defs.h m:\bind495t6b/contrib/host/defs.h
*** m:\bind495t5b/contrib/host/defs.h	Fri May 10 23:06:38 1996
--- m:\bind495t6b/contrib/host/defs.h	Sun Sep 29 19:00:20 1996
***************
*** 1,15 ****
  /*
  ** Declaration of functions.
  **
! **	@(#)defs.h              e07@nikhef.nl (Eric Wassenaar) 960511
  */
  
  /*
! ** Internal modules of the host utility
! ** ------------------------------------
  */
  
! 	/* main.c */
  
  int main		PROTO((int, char **));
  void set_defaults	PROTO((char *, int, char **));
--- 1,15 ----
  /*
  ** Declaration of functions.
  **
! **	@(#)defs.h              e07@nikhef.nl (Eric Wassenaar) 960929
  */
  
  /*
! ** Internal modules of the host utility
! ** ------------------------------------
  */
  
! 	/* main.c */
  
  int main		PROTO((int, char **));
  void set_defaults	PROTO((char *, int, char **));
***************
*** 31,40 ****
  bool get_hostinfo	PROTO((char *, bool));
  bool get_domaininfo	PROTO((char *, char *));
  int get_info		PROTO((querybuf *, char *, int, int));
! bool print_info		PROTO((querybuf *, int, char *, int, bool));
  void print_data		PROTO((char *, ...));
! u_char *print_rrec	PROTO((char *, u_char *, u_char *, u_char *, bool));
! u_char *skip_qrec	PROTO((char *, u_char *, u_char *, u_char *));
  bool get_recursive	PROTO((char *));
  
  
--- 31,40 ----
  bool get_hostinfo	PROTO((char *, bool));
  bool get_domaininfo	PROTO((char *, char *));
  int get_info		PROTO((querybuf *, char *, int, int));
! bool print_info		PROTO((querybuf *, int, char *, int, int, bool));
  void print_data		PROTO((char *, ...));
! u_char *print_rrec	PROTO((char *, int, int, u_char *, u_char *, u_char *, bool));
! u_char *skip_qrec	PROTO((char *, int, int, u_char *, u_char *, u_char *));
  bool get_recursive	PROTO((char *));
  
  
***************
*** 48,55 ****
  bool skip_transfer	PROTO((char *));
  void do_check		PROTO((char *));
  bool do_transfer	PROTO((char *));
! bool transfer_zone	PROTO((char *, int, struct in_addr, char *));
! bool get_zone		PROTO((char *, int, struct in_addr, char *));
  bool get_mxrec		PROTO((char *));
  char *get_primary	PROTO((char *));
  bool check_zone		PROTO((char *));
--- 48,55 ----
  bool skip_transfer	PROTO((char *));
  void do_check		PROTO((char *));
  bool do_transfer	PROTO((char *));
! bool transfer_zone	PROTO((char *, struct in_addr, char *));
! bool get_zone		PROTO((char *, struct in_addr, char *));
  bool get_mxrec		PROTO((char *));
  char *get_primary	PROTO((char *));
  bool check_zone		PROTO((char *));
***************
*** 71,76 ****
--- 71,82 ----
  bool check_name		PROTO((ipaddr_t));
  
  
+ 	/* geth.c */
+ 
+ struct hostent *geth_byname	PROTO((CONST char *));
+ struct hostent *geth_byaddr	PROTO((CONST char *, int, int));
+ 
+ 
  	/* util.c */
  
  int parse_type		PROTO((char *));
***************
*** 111,119 ****
--- 117,128 ----
  ptr_t *xalloc		PROTO((ptr_t *, siz_t));
  char *itoa		PROTO((int));
  char *utoa		PROTO((int));
+ char *xtoa		PROTO((int));
  char *stoa		PROTO((u_char *, int, bool));
+ char *base_ntoa		PROTO((u_char *, int));
  char *nsap_ntoa		PROTO((u_char *, int));
  char *ipng_ntoa		PROTO((u_char *));
+ char *pr_date		PROTO((int));
  char *pr_time		PROTO((int, bool));
  char *pr_spherical	PROTO((int, char *, char *));
  char *pr_vertical	PROTO((int, char *, char *));
***************
*** 140,148 ****
  ipaddr_t inet_addr	PROTO((CONST char *));
  char *inet_ntoa		PROTO((struct in_addr));
  char *hostalias		PROTO((CONST char *));
! char *index		PROTO((const char *, char));
! char *rindex		PROTO((const char *, char));
  char *strcpy		PROTO((char *, const char *));
  char *getenv		PROTO((const char *));
  ptr_t *malloc		PROTO((siz_t));
  ptr_t *realloc		PROTO((ptr_t *, siz_t));
--- 149,158 ----
  ipaddr_t inet_addr	PROTO((CONST char *));
  char *inet_ntoa		PROTO((struct in_addr));
  char *hostalias		PROTO((CONST char *));
! char *index		PROTO((const char *, int));
! char *rindex		PROTO((const char *, int));
  char *strcpy		PROTO((char *, const char *));
+ char *strncpy		PROTO((char *, const char *, siz_t));
  char *getenv		PROTO((const char *));
  ptr_t *malloc		PROTO((siz_t));
  ptr_t *realloc		PROTO((ptr_t *, siz_t));
diff --context --recurs m:\bind495t5b/contrib/host/host.1 m:\bind495t6b/contrib/host/host.1
*** m:\bind495t5b/contrib/host/host.1	Sat Aug 24 05:18:23 1996
--- m:\bind495t6b/contrib/host/host.1	Sun Sep 29 21:30:58 1996
***************
*** 1,13 ****
  .\"
! .\"	@(#)host.1              e07@nikhef.nl (Eric Wassenaar) 960808
! .\"
! .TH host 1 "960808"
! .SH NAME
! host \- query nameserver about domain names and zones
! .SH SYNOPSIS 
! .na
! .nf
! \fBhost\fP [\fB\-v\fP] [\fB\-a\fP] [\fB\-t\fP \fIquerytype\fP] [\fIoptions\fP]  \fIname\fP  [\fIserver\fP] 
  .br
  \fBhost\fP [\fB\-v\fP] [\fB\-a\fP] [\fB\-t\fP \fIquerytype\fP] [\fIoptions\fP]  \fB\-l\fP \fIzone\fP  [\fIserver\fP] 
  .br
--- 1,13 ----
  .\"
! .\"	@(#)host.1              e07@nikhef.nl (Eric Wassenaar) 960929
! .\"
! .TH host 1 "960929"
! .SH NAME
! host \- query nameserver about domain names and zones
! .SH SYNOPSIS 
! .na
! .nf
! \fBhost\fP [\fB\-v\fP] [\fB\-a\fP] [\fB\-t\fP \fIquerytype\fP] [\fIoptions\fP]  \fIname\fP  [\fIserver\fP] 
  .br
  \fBhost\fP [\fB\-v\fP] [\fB\-a\fP] [\fB\-t\fP \fIquerytype\fP] [\fIoptions\fP]  \fB\-l\fP \fIzone\fP  [\fIserver\fP] 
  .br
***************
*** 79,85 ****
  The second argument is optional. It allows you to specify a particular
  server to query.  If you don't specify this argument, default servers
  are used, as defined by the \fB/etc/resolv.conf\fP file.
! .SH EXTENDED SYNTAX
  If the \fB\-x\fP option is given, it extends the syntax in the sense
  that multiple arguments are allowed on the command line. An optional
  explicit server must now be specified using the \fB\-X\fP option as it
--- 79,85 ----
  The second argument is optional. It allows you to specify a particular
  server to query.  If you don't specify this argument, default servers
  are used, as defined by the \fB/etc/resolv.conf\fP file.
! .SS "EXTENDED SYNTAX"
  If the \fB\-x\fP option is given, it extends the syntax in the sense
  that multiple arguments are allowed on the command line. An optional
  explicit server must now be specified using the \fB\-X\fP option as it
***************
*** 92,98 ****
  these arguments are the names to be queried, and not command options.
  Everything that appears after a '#' or ';' on an input line will be
  skipped. Multiple arguments per line are allowed.
! .SH OPTIONS
  There are a number of options that can be used before the specified
  arguments.  Some of these options are meaningful only to the people
  who maintain the domain database zones.
--- 92,98 ----
  these arguments are the names to be queried, and not command options.
  Everything that appears after a '#' or ';' on an input line will be
  skipped. Multiple arguments per line are allowed.
! .SS OPTIONS
  There are a number of options that can be used before the specified
  arguments.  Some of these options are meaningful only to the people
  who maintain the domain database zones.
***************
*** 121,127 ****
  is equivalent to \fB\-t ANY\fP.
  Note that this gives you "anything available" (currently cached) and
  not "all defined data" if a non-authoritative server is queried.
! .SH SPECIAL MODES
  The following options put the program in a special mode.
  .TP 4
  .BI \-l " zone"
--- 121,127 ----
  is equivalent to \fB\-t ANY\fP.
  Note that this gives you "anything available" (currently cached) and
  not "all defined data" if a non-authoritative server is queried.
! .SS "SPECIAL MODES"
  The following options put the program in a special mode.
  .TP 4
  .BI \-l " zone"
***************
*** 207,213 ****
  a reverse lookup of the address in each encountered A record is performed,
  and it is checked whether it is registered and maps back to the name of
  the A record.
! .SH SPECIAL OPTIONS
  The following options apply only to the special zone listing modes.
  .TP 4
  .BI \-L " level"
--- 207,213 ----
  a reverse lookup of the address in each encountered A record is performed,
  and it is checked whether it is registered and maps back to the name of
  the A record.
! .SS "SPECIAL OPTIONS"
  The following options apply only to the special zone listing modes.
  .TP 4
  .BI \-L " level"
***************
*** 244,250 ****
  list \fIskipzone\fP. This may be used during recursive zone listings
  when certain zones are known to contain bogus information which
  should be excluded from further processing.
! .SH COMMON OPTIONS
  The following options can be used in both normal mode and domain
  listing mode.
  .TP 4
--- 244,250 ----
  list \fIskipzone\fP. This may be used during recursive zone listings
  when certain zones are known to contain bogus information which
  should be excluded from further processing.
! .SS "COMMON OPTIONS"
  The following options can be used in both normal mode and domain
  listing mode.
  .TP 4
***************
*** 299,305 ****
  .B \-Z
  prints the selected resource record output in full zone file format,
  including trailing dot in domain names, plus ttl value and class name.
! .SH OTHER OPTIONS
  The following options are used only in special circumstances.
  .TP 4
  .BI \-c " class"
--- 299,305 ----
  .B \-Z
  prints the selected resource record output in full zone file format,
  including trailing dot in domain names, plus ttl value and class name.
! .SS "OTHER OPTIONS"
  The following options are used only in special circumstances.
  .TP 4
  .BI \-c " class"
***************
*** 371,377 ****
  .TP
  .B \-V
  prints just the version number of the \fBhost\fP program, and exits.
! .SH DEFAULT OPTIONS
  Default options and parameters can be preset in an environment
  variable \fBHOST_DEFAULTS\fP using the same syntax as on the command
  line. They will be evaluated before the command line arguments.
--- 371,377 ----
  .TP
  .B \-V
  prints just the version number of the \fBhost\fP program, and exits.
! .SS "DEFAULT OPTIONS"
  Default options and parameters can be preset in an environment
  variable \fBHOST_DEFAULTS\fP using the same syntax as on the command
  line. They will be evaluated before the command line arguments.
***************
*** 470,478 ****
  .PP
  The following types have been defined in RFC 1348, but
  are not yet in general use. They are recognized by this program.
! RFC 1348 has already been obsoleted by RFC 1637, which defines
! a new experimental usage of NSAP records. This program has now
! hooks to manipulate them.
  .TP 10
  .B NSAP
  NSAP address (encoded address)
--- 470,478 ----
  .PP
  The following types have been defined in RFC 1348, but
  are not yet in general use. They are recognized by this program.
! RFC 1348 has already been obsoleted by RFC 1637 and RFC 1706,
! which defines a new experimental usage of NSAP records.
! This program has now hooks to manipulate them.
  .TP 10
  .B NSAP
  NSAP address (encoded address)
***************
*** 498,510 ****
  .TP
  .B KEY
  Security key
! .TP
  .B AAAA
! IP v6 address
! .TP
  .B LOC
! Geographical location
! .SH FAILURE MESSAGES
  The following messages are printed to show the reason
  of failure for a particular query. The name of an explicit
  server, if specified, may be included. If a special class
--- 498,530 ----
  .TP
  .B KEY
  Security key
! .PP
! The IP v6 address architecture and DNS extensions are defined in
! RFC 1884 and RFC 1886.
! .TP 10
  .B AAAA
! IP v6 address (address spec with colons)
! .PP
! The following type is documented in RFC 1876.
! .TP 10
  .B LOC
! Geographical location (latitude, longitude, altitude, precision)
! .PP
! The following types have been proposed, but are still in draft.
! .TP 10
! .B NXT
! Next valid record
! .TP
! .B SRV
! Internet service information
! .SH EXAMPLES
! A very good summary and validation of an entire zone can be obtained
! with the following command:
! .sp
! 	\fBhost \-G \-S \-C \-A \-L 1\fP \fIzone\fP
! .sp
! .SH DIAGNOSTICS
! .SS "FAILURE MESSAGES"
  The following messages are printed to show the reason
  of failure for a particular query. The name of an explicit
  server, if specified, may be included. If a special class
***************
*** 575,581 ****
  No nameservers for \fIzone\fP responded
  When trying all nameservers in succession to do a zone transfer,
  none of them were able or willing to provide it.
! .SH WARNING AND ERROR MESSAGES
  Miscellaneous warning messages may be generated.
  They are preceded by " !!! " and indicate some non-fatal condition,
  usually during the interpretation of the retrieved data.
--- 595,601 ----
  No nameservers for \fIzone\fP responded
  When trying all nameservers in succession to do a zone transfer,
  none of them were able or willing to provide it.
! .SS "WARNING AND ERROR MESSAGES"
  Miscellaneous warning messages may be generated.
  They are preceded by " !!! " and indicate some non-fatal condition,
  usually during the interpretation of the retrieved data.
***************
*** 733,758 ****
  \fIserver1\fP and \fIserver2\fP have different defttl for \fIzone\fP
  If the SOA record is different, the zone data is probably different
  as well. What you get depends on which server you happen to query.
! .SH EXIT STATUS
  The program returns a zero exit status if the requested information
  could be retrieved successfully, or in case zone listings or SOA
  checks were performed without any serious error.
  Otherwise it returns a non-zero exit status.
! .SH CUSTOMIZING HOST NAME LOOKUP
  In general, if the name supplied by the user does not have any dots
  in it, a default domain is appended to the end. This domain is usually
  defined in the \fB/etc/resolv.conf\fP file. If not, it is derived by
  taking the local hostname and taking everything after its first dot.
  .PP
  The user can override this, and specify a different default domain,
  by defining it in the environment variable \fILOCALDOMAIN\fP.
  .PP
  In addition, the user can supply his own single-word abbreviations
  for host names. They should be in a file consisting of one line per
  abbreviation. Each line contains an abbreviation, white space, and
  then the fully qualified host name. The name of this file must be
  specified in the environment variable \fIHOSTALIASES\fP.
! .SH SPECIAL CONSIDERATIONS
  The complete set of resource record information for a domain name
  is available from an authoritative nameserver only. Therefore,
  if you query another server with the "-a" option, only a subset
--- 753,781 ----
  \fIserver1\fP and \fIserver2\fP have different defttl for \fIzone\fP
  If the SOA record is different, the zone data is probably different
  as well. What you get depends on which server you happen to query.
! .SH "EXIT STATUS"
  The program returns a zero exit status if the requested information
  could be retrieved successfully, or in case zone listings or SOA
  checks were performed without any serious error.
  Otherwise it returns a non-zero exit status.
! .SH ENVIRONMENT
! .SS "CUSTOMIZING HOST NAME LOOKUP"
  In general, if the name supplied by the user does not have any dots
  in it, a default domain is appended to the end. This domain is usually
  defined in the \fB/etc/resolv.conf\fP file. If not, it is derived by
  taking the local hostname and taking everything after its first dot.
  .PP
+ .fw LOCALDOMAIN
  The user can override this, and specify a different default domain,
  by defining it in the environment variable \fILOCALDOMAIN\fP.
  .PP
+ .fw HOSTALIASES
  In addition, the user can supply his own single-word abbreviations
  for host names. They should be in a file consisting of one line per
  abbreviation. Each line contains an abbreviation, white space, and
  then the fully qualified host name. The name of this file must be
  specified in the environment variable \fIHOSTALIASES\fP.
! .SH "SPECIAL CONSIDERATIONS"
  The complete set of resource record information for a domain name
  is available from an authoritative nameserver only. Therefore,
  if you query another server with the "-a" option, only a subset
***************
*** 769,781 ****
  this option to work.
  This option should be used with caution. Servers may be configured
  to refuse zone transfers if they are flooded with requests.
! .SH RELATED DOCUMENTATION
! rfc920, rfc952, rfc974, rfc1032, rfc1033, rfc1034, rfc1035,
! rfc1101, rfc1183, rfc1348, rfc1535, rfc1536, rfc1537, rfc1637,
! rfc1664, rfc1712
  .SH AUTHOR
  This program is originally from Rutgers University.
  .br
! Rewritten by Eric Wassenaar, Nikhef-H, <e07@nikhef.nl>
  .SH "SEE ALSO"
  named(8), resolv.conf(5), resolver(3)
--- 792,860 ----
  this option to work.
  This option should be used with caution. Servers may be configured
  to refuse zone transfers if they are flooded with requests.
! .SH "RELATED DOCUMENTATION"
! rfc883, Domain names - implementation and specification
! .br
! rfc920, Domain requirements
! .br
! rfc952, DOD Internet host table specification
! .br
! rfc974, Mail routing and the domain system
! .br
! rfc1032, Domain administrators guide
! .br
! rfc1033, Domain administrators operations guide
! .br
! rfc1034, Domain names - concepts and facilities
! .br
! rfc1035, Domain names - implementation and specification
! .br
! rfc1101, DNS encoding of network names and other types
! .br
! rfc1123, Requirements for Internet hosts - application
! .br
! rfc1183, New DNS RR definitions
! .br
! rfc1348, DNS NSAP RRs
! .br
! rfc1535, A security problem and proposed correction
! .br
! rfc1536, Common DNS implementation errors
! .br
! rfc1537, Common DNS data file configuration errors
! .br
! rfc1591, Domain Name System structure and delegation
! .br
! rfc1637, DNS NSAP resource records
! .br
! rfc1664, Using DNS to distribute X.400 address mappings
! .br
! rfc1700, Assigned numbers
! .br
! rfc1706, DNS NSAP resource records
! .br
! rfc1712, DNS encoding of geographical location
! .br
! rfc1713, Tools for DNS debugging
! .br
! rfc1794, DNS support for load balancing
! .br
! rfc1876, Expressing location information in the DNS
! .br
! rfc1884, IP v6 addressing architecture
! .br
! rfc1886, DNS extensions to support IP v6
! .br
! rfc1912, Common DNS operational and configuration errors
! .br
! rfc1982, Serial number arithmetic
! .br
! rfc1995, Incremental zone transfer in DNS
! .br
! rfc1996, Prompt notification of zone changes
  .SH AUTHOR
  This program is originally from Rutgers University.
  .br
! Rewritten by Eric Wassenaar, NIKHEF, <e07@nikhef.nl>
  .SH "SEE ALSO"
  named(8), resolv.conf(5), resolver(3)
diff --context --recurs m:\bind495t5b/contrib/host/host.c m:\bind495t6b/contrib/host/host.c
*** m:\bind495t5b/contrib/host/host.c	Sat Aug 24 05:18:23 1996
--- m:\bind495t6b/contrib/host/host.c	Sun Sep 29 21:19:31 1996
***************
*** 36,51 ****
   */
  
  #ifndef lint
! static char Version[] = "@(#)host.c	e07@nikhef.nl (Eric Wassenaar) 960808";
  #endif
  
! #if defined(apollo) && defined(lint)
! #define __attribute(x)
  #endif
  
! #define justfun			/* this is only for fun */
! #undef  obsolete		/* old code left as a reminder */
! #undef  notyet			/* new code for possible future use */
  
  /*
   *			New features
--- 36,51 ----
   */
  
  #ifndef lint
! static char Version[] = "@(#)host.c	e07@nikhef.nl (Eric Wassenaar) 960929";
  #endif
  
! #if defined(apollo) && defined(lint)
! #define __attribute(x)
  #endif
  
! #define justfun			/* this is only for fun */
! #undef  obsolete		/* old code left as a reminder */
! #undef  notyet			/* new code for possible future use */
  
  /*
   *			New features
***************
*** 274,285 ****
  #include <ctype.h>
  #include <errno.h>
  #include <netdb.h>
  
  #include <sys/types.h>		/* not always automatically included */
  #include <sys/param.h>
  #include <sys/socket.h>
  #include <netinet/in.h>
- 
  #undef NOERROR			/* in <sys/streams.h> on solaris 2.x */
  #include <arpa/nameser.h>
  #include <resolv.h>
--- 274,285 ----
  #include <ctype.h>
  #include <errno.h>
  #include <netdb.h>
+ #include <time.h>
  
  #include <sys/types.h>		/* not always automatically included */
  #include <sys/param.h>
  #include <sys/socket.h>
  #include <netinet/in.h>
  #undef NOERROR			/* in <sys/streams.h> on solaris 2.x */
  #include <arpa/nameser.h>
  #include <resolv.h>
***************
*** 306,312 ****
  
  #define T_NONE	0		/* yet unspecified resource record type */
  #define T_FIRST	T_A		/* first possible type in resource record */
! #define T_LAST	(T_AXFR - 1)	/* last  possible type in resource record */
  
  #ifndef NOCHANGE
  #define NOCHANGE 0xf		/* compatibility with older BIND versions */
--- 306,312 ----
  
  #define T_NONE	0		/* yet unspecified resource record type */
  #define T_FIRST	T_A		/* first possible type in resource record */
! #define T_LAST	(T_IXFR - 1)	/* last  possible type in resource record */
  
  #ifndef NOCHANGE
  #define NOCHANGE 0xf		/* compatibility with older BIND versions */
***************
*** 349,355 ****
  #endif
  
  EXTERN int errno;
! EXTERN int h_errno;		/* defined in gethostnamadr.c */
  EXTERN res_state_t _res;	/* defined in res_init.c */
  extern char *dbprefix;		/* prefix for debug messages (send.c) */
  extern char *version;		/* program version number (vers.c) */
--- 349,355 ----
  #endif
  
  EXTERN int errno;
! EXTERN int h_errno;		/* defined in the resolver library */
  EXTERN res_state_t _res;	/* defined in res_init.c */
  extern char *dbprefix;		/* prefix for debug messages (send.c) */
  extern char *version;		/* program version number (vers.c) */
***************
*** 408,413 ****
--- 408,414 ----
  int recursive = 0;		/* recursive listmode maximum level */
  int recursion_level = 0;	/* current recursion level */
  int skip_level = 0;		/* level beyond which to skip checks */
+ int print_level = 0;		/* level below which to skip verbose output */
  
  bool quiet = FALSE;		/* suppress non-fatal warning messages */
  bool reverse = FALSE;		/* generate reverse in-addr.arpa queries */
***************
*** 849,855 ****
  	_res.options = new_res.options;
  
  	/* show the new resolver database */
! 	if (debug > 1 || verbose > 1)
  		show_res();
  
  	/* show customized default domain */
--- 850,856 ----
  	_res.options = new_res.options;
  
  	/* show the new resolver database */
! 	if (verbose > 1 || debug > 1)
  		show_res();
  
  	/* show customized default domain */
***************
*** 1106,1111 ****
--- 1107,1113 ----
   * The name can be an ordinary domain name, or an internet address
   * in dotted quad notation. If the -n option is given, the name is
   * supposed to be a dotted nsap address.
+  * Furthermore, an empty input name is treated as the root domain.
   */
  	queryname = name;
  	if (queryname[0] == '\0')
***************
*** 1123,1138 ****
  	if (reverse)
  	{
  		if (queryaddr == NOT_DOTTED_QUAD)
! 			name = queryname, queryname = NULL;
  		else
! 			queryname = in_addr_arpa(queryname);
  
! 		if (queryname == NULL)
  		{
! 			errmsg("Invalid dotted quad %s", name);
  			return(EX_USAGE);
  		}
  
  		queryaddr = NOT_DOTTED_QUAD;
  	}
  
--- 1125,1142 ----
  	if (reverse)
  	{
  		if (queryaddr == NOT_DOTTED_QUAD)
! 			name = NULL;
  		else
! 			name = in_addr_arpa(queryname);
  
! 		if (name == NULL)
  		{
! 			errmsg("Invalid dotted quad %s", queryname);
  			return(EX_USAGE);
  		}
  
+ 		/* redefine appropriately */
+ 		queryname = name;
  		queryaddr = NOT_DOTTED_QUAD;
  	}
  
***************
*** 1143,1159 ****
  	if (revnsap)
  	{
  		if (reverse)
! 			name = queryname, queryname = NULL;
  		else
! 			queryname = nsap_int(queryname);
  
! 		if (queryname == NULL)
  		{
! 			errmsg("Invalid nsap address %s", name);
  			return(EX_USAGE);
  		}
  
  		queryaddr = NOT_DOTTED_QUAD;
  		reverse = TRUE;
  	}
  
--- 1147,1167 ----
  	if (revnsap)
  	{
  		if (reverse)
! 			name = NULL;
  		else
! 			name = nsap_int(queryname);
  
! 		if (name == NULL)
  		{
! 			errmsg("Invalid nsap address %s", queryname);
  			return(EX_USAGE);
  		}
  
+ 		/* redefine appropriately */
+ 		queryname = name;
  		queryaddr = NOT_DOTTED_QUAD;
+ 
+ 		/* this is also a reversed mapping domain */
  		reverse = TRUE;
  	}
  
***************
*** 1294,1300 ****
  			{
  				newname = strcpy(newnamebuf, cname);
  
! 				if (++ncnames > 5)
  				{
  					errmsg("Possible CNAME loop");
  					return(FALSE);
--- 1302,1308 ----
  			{
  				newname = strcpy(newnamebuf, cname);
  
! 				if (ncnames++ > MAXCHAIN)
  				{
  					errmsg("Possible CNAME loop");
  					return(FALSE);
***************
*** 1307,1313 ****
  		}
  		else
  		{
! 			hp = gethostbyaddr((char *)&inaddr, INADDRSZ, AF_INET);
  			if (hp != NULL)
  			{
  				print_host("Name", hp);
--- 1315,1321 ----
  		}
  		else
  		{
! 			hp = geth_byaddr((char *)&inaddr, INADDRSZ, AF_INET);
  			if (hp != NULL)
  			{
  				print_host("Name", hp);
***************
*** 1365,1371 ****
  		}
  
  		/* cache the result */
! 		myname = strcpy(mynamebuf, hp->h_name);
  	}
  
  	return(myname);
--- 1373,1380 ----
  		}
  
  		/* cache the result */
! 		myname = strncpy(mynamebuf, hp->h_name, MAXDNAME);
! 		myname[MAXDNAME] = '\0';
  	}
  
  	return(myname);
***************
*** 1450,1462 ****
   */
  	if (hp != NULL)
  	{
! 		server = strcpy(serverbuf, hp->h_name);
  		if (verbose)
  			print_host("Server", hp);
  	}
  	else
  	{
  		server = strcpy(serverbuf, inet_ntoa(inaddr));
  		if (verbose)
  			printf("Server: %s\n\n", server);
  	}
--- 1459,1474 ----
   */
  	if (hp != NULL)
  	{
! 		server = strncpy(serverbuf, hp->h_name, MAXDNAME);
! 		server[MAXDNAME] = '\0';
! 
  		if (verbose)
  			print_host("Server", hp);
  	}
  	else
  	{
  		server = strcpy(serverbuf, inet_ntoa(inaddr));
+ 
  		if (verbose)
  			printf("Server: %s\n\n", server);
  	}
***************
*** 1617,1623 ****
  	if (dot == 0 && (cp = hostalias(name)) != NULL)
  	{
  		if (verbose)
! 			printf("Aliased to \"%s\"\n", cp);
  
  		result = get_domaininfo(cp, (char *)NULL);
  		return(result);
--- 1629,1635 ----
  	if (dot == 0 && (cp = hostalias(name)) != NULL)
  	{
  		if (verbose)
! 			printf("Aliased %s to %s\n", name, cp);
  
  		result = get_domaininfo(cp, (char *)NULL);
  		return(result);
***************
*** 1787,1793 ****
   * If we got a positive answer, the data may still be corrupted.
   */
  	if (result)
! 		result = print_info(&answer, n, name, querytype, FALSE);
  
  /*
   * Remember the actual name that was queried.
--- 1799,1805 ----
   * If we got a positive answer, the data may still be corrupted.
   */
  	if (result)
! 	    result = print_info(&answer, n, name, querytype, queryclass, TRUE);
  
  /*
   * Remember the actual name that was queried.
***************
*** 1863,1869 ****
  /*
   * Analyze the status of the answer from the nameserver.
   */
! 	if (debug || verbose)
  		print_status(answerbuf, n);
  
  	bp = (HEADER *)answerbuf;
--- 1875,1881 ----
  /*
   * Analyze the status of the answer from the nameserver.
   */
! 	if ((verbose > print_level) || debug)
  		print_status(answerbuf, n);
  
  	bp = (HEADER *)answerbuf;
***************
*** 1917,1928 ****
  */
  
  bool
! print_info(answerbuf, answerlen, name, type, listing)
  input querybuf *answerbuf;		/* location of answer buffer */
  input int answerlen;			/* length of answer buffer */
  input char *name;			/* full name we are querying about */
  input int type;				/* record type we are querying about */
! input bool listing;			/* set if this is a zone listing */
  {
  	HEADER *bp;
  	int qdcount, ancount, nscount, arcount;
--- 1929,1941 ----
  */
  
  bool
! print_info(answerbuf, answerlen, name, type, class, regular)
  input querybuf *answerbuf;		/* location of answer buffer */
  input int answerlen;			/* length of answer buffer */
  input char *name;			/* full name we are querying about */
  input int type;				/* record type we are querying about */
! input int class;			/* record class we are querying about */
! input bool regular;			/* set if this is a regular lookup */
  {
  	HEADER *bp;
  	int qdcount, ancount, nscount, arcount;
***************
*** 1944,1953 ****
   */
  	if (qdcount)
  	{
! 		while (qdcount > 0 && cp < eom)
  		{
! 			/* cp += dn_skipname(cp, eom) + QFIXEDSZ; */
! 			cp = skip_qrec(name, cp, msg, eom);
  			if (cp == NULL)
  				return(FALSE);
  			qdcount--;
--- 1957,1965 ----
   */
  	if (qdcount)
  	{
! 		while (qdcount > 0 && cp < eom)	/* process all records */
  		{
! 			cp = skip_qrec(name, type, class, cp, msg, eom);
  			if (cp == NULL)
  				return(FALSE);
  			qdcount--;
***************
*** 1965,1996 ****
  /*
   * Process the actual answer section in the response.
   * During zone transfers, this is the only section available.
   */
  	if (ancount)
  	{
! 		if (!listing && verbose && !bp->aa)
  			printf("The following answer is not authoritative:\n");
  
  		while (ancount > 0 && cp < eom)
  		{
! 			cp = print_rrec(name, cp, msg, eom, listing);
  			if (cp == NULL)
  				return(FALSE);
  			ancount--;
  
! 		/*
! 		 * When we ask for address and there is a CNAME, it returns
! 		 * both the CNAME and the address.  Since we trace down the
! 		 * CNAME chain ourselves, we don't really want to print the
! 		 * address at this point.
! 		 */
! 			if (!listmode && !verbose && cname)
  				return(TRUE);
  
! 		/*
! 		 * Recursively expand MR or MG records into MB records.
! 		 */
! 			if (!listmode && mailmode && mname)
  			{
  				char newnamebuf[MAXDNAME+1];
  				char *newname;
--- 1977,2004 ----
  /*
   * Process the actual answer section in the response.
   * During zone transfers, this is the only section available.
+  * Special processing is done for some records in regular mode.
   */
  	if (ancount)
  	{
! 		if ((type != T_AXFR) && verbose && !bp->aa)
  			printf("The following answer is not authoritative:\n");
  
  		while (ancount > 0 && cp < eom)
  		{
! 			print_level++;
! 			cp = print_rrec(name, type, class, cp, msg, eom, regular);
! 			print_level--;
  			if (cp == NULL)
  				return(FALSE);
  			ancount--;
  
! 			/* we trace down CNAME chains ourselves */
! 			if (regular && !verbose && cname)
  				return(TRUE);
  
! 			/* recursively expand MR/MG records into MB records */
! 			if (regular && mailmode && mname)
  			{
  				char newnamebuf[MAXDNAME+1];
  				char *newname;
***************
*** 2024,2030 ****
  
  		while (nscount > 0 && cp < eom)
  		{
! 			cp = print_rrec(name, cp, msg, eom, FALSE);
  			if (cp == NULL)
  				return(FALSE);
  			nscount--;
--- 2032,2040 ----
  
  		while (nscount > 0 && cp < eom)
  		{
! 			print_level++;
! 			cp = print_rrec(name, type, class, cp, msg, eom, FALSE);
! 			print_level--;
  			if (cp == NULL)
  				return(FALSE);
  			nscount--;
***************
*** 2045,2051 ****
  
  		while (arcount > 0 && cp < eom)
  		{
! 			cp = print_rrec(name, cp, msg, eom, FALSE);
  			if (cp == NULL)
  				return(FALSE);
  			arcount--;
--- 2055,2063 ----
  
  		while (arcount > 0 && cp < eom)
  		{
! 			print_level++;
! 			cp = print_rrec(name, type, class, cp, msg, eom, FALSE);
! 			print_level--;
  			if (cp == NULL)
  				return(FALSE);
  			arcount--;
***************
*** 2060,2065 ****
--- 2072,2078 ----
  		}
  	}
  
+ 	/* all sections were processed successfully */
  	return(TRUE);
  }
  
***************
*** 2128,2150 ****
  #define pr_name(x)	pr_domain(x, listing)
  
  /* check the LHS record name of these records for invalid characters */
! #define test_valid(t)	((t == T_A && !reverse) || t == T_MX || t == T_AAAA)
  
  /* check the RHS domain name of these records for canonical host names */
  #define test_canon(t)	(t == T_NS || t == T_MX)
  
  u_char *
! print_rrec(name, cp, msg, eom, listing)
  input char *name;			/* full name we are querying about */
  register u_char *cp;			/* current position in answer buf */
  input u_char *msg, *eom;		/* begin and end of answer buf */
! input bool listing;			/* set if this is a zone listing */
  {
  	char rname[MAXDNAME+1];		/* record name in LHS */
  	char dname[MAXDNAME+1];		/* domain name in RHS */
  	int type, class, ttl, dlen;	/* fixed values in every record */
  	u_char *eor;			/* predicted position of next record */
  	bool classmatch;		/* set if we want to see this class */
  	char *host = listhost;		/* contacted host for zone listings */
  	register int n, c;
  	struct in_addr inaddr;
--- 2141,2166 ----
  #define pr_name(x)	pr_domain(x, listing)
  
  /* check the LHS record name of these records for invalid characters */
! #define test_valid(t)	(((t == T_A) && !reverse) || t == T_MX || t == T_AAAA)
  
  /* check the RHS domain name of these records for canonical host names */
  #define test_canon(t)	(t == T_NS || t == T_MX)
  
  u_char *
! print_rrec(name, qtype, qclass, cp, msg, eom, regular)
  input char *name;			/* full name we are querying about */
+ input int qtype;			/* record type we are querying about */
+ input int qclass;			/* record class we are querying about */
  register u_char *cp;			/* current position in answer buf */
  input u_char *msg, *eom;		/* begin and end of answer buf */
! input bool regular;			/* set if this is a regular lookup */
  {
  	char rname[MAXDNAME+1];		/* record name in LHS */
  	char dname[MAXDNAME+1];		/* domain name in RHS */
  	int type, class, ttl, dlen;	/* fixed values in every record */
  	u_char *eor;			/* predicted position of next record */
  	bool classmatch;		/* set if we want to see this class */
+ 	bool listing;			/* set if this is a zone listing */
  	char *host = listhost;		/* contacted host for zone listings */
  	register int n, c;
  	struct in_addr inaddr;
***************
*** 2180,2185 ****
--- 2196,2203 ----
  /*
   * Decide whether or not to print this resource record.
   */
+ 	listing = (qtype == T_AXFR) ? TRUE : FALSE;
+ 
  	if (listing)
  	{
  		classmatch = want_class(class, queryclass);
***************
*** 2191,2200 ****
  		doprint = classmatch && want_type(type, T_ANY);
  	}
  
- #ifdef obsolete
- 	if (doprint && exclusive && !samedomain(rname, name, TRUE))
- 		doprint = FALSE;
- #endif
  	if (doprint && exclusive && !indomain(rname, name, TRUE))
  		doprint = FALSE;
  
--- 2209,2214 ----
***************
*** 2216,2222 ****
  	if (verbose || ttlprint)
  		doprintf(("\t%s", itoa(ttl)))
  
! 	if (verbose || classprint || (class != queryclass))
  		doprintf(("\t%s", pr_class(class)))
  
  	doprintf(("\t%s", pr_type(type)))
--- 2230,2236 ----
  	if (verbose || ttlprint)
  		doprintf(("\t%s", itoa(ttl)))
  
! 	if (verbose || classprint || (class != qclass))
  		doprintf(("\t%s", pr_class(class)))
  
  	doprintf(("\t%s", pr_type(type)))
***************
*** 2281,2287 ****
  			address = 0;
  			break;
  		}
- 
  		address = 0;
  		cp += dlen;
  		break;
--- 2295,2300 ----
***************
*** 2380,2385 ****
--- 2393,2399 ----
  		if (check_size(rname, type, cp, msg, eor, 1) < 0)
  			break;
  		n = *cp++;
+ 
  		protocol = getprotobynumber(n);
  		if (protocol != NULL)
  			doprintf((" %s", protocol->p_name))
***************
*** 2648,2658 ****
  		break;
  
  	    case T_SIG:
  	    case T_KEY:
! 		doprintf(("\t(not yet implemented)"))
! 		cp += dlen;
  		break;
  
  	    default:
  		doprintf(("\t???"))
  		cp += dlen;
--- 2662,2835 ----
  		break;
  
  	    case T_SIG:
+ 		if (check_size(rname, type, cp, msg, eor, INT16SZ) < 0)
+ 			break;
+ 		n = _getshort(cp);
+ 		doprintf(("\t%s", pr_type(n)))
+ 		cp += INT16SZ;
+ 
+ 		if (check_size(rname, type, cp, msg, eor, 1) < 0)
+ 			break;
+ 		n = *cp++;
+ 		doprintf((" %s", itoa(n)))
+ 
+ 		n = 1 + 3*INT32SZ + INT16SZ;
+ 		if (check_size(rname, type, cp, msg, eor, n) < 0)
+ 			break;
+ 		doprintf((" ("))
+ 
+ 		n = *cp++;
+ 		doprintf(("\n\t\t\t; %s", itoa(n)))
+ 		doprintf(("\t\t;labels"))
+ 
+ 		n = _getlong(cp);
+ 		doprintf(("\n\t\t\t%s", itoa(n)))
+ 		doprintf(("\t\t;original ttl"))
+ 		cp += INT32SZ;
+ 
+ 		n = _getlong(cp);
+ 		doprintf(("\n\t\t\t%s", pr_date(n)))
+ 		doprintf(("\t;signature expiration"))
+ 		cp += INT32SZ;
+ 
+ 		n = _getlong(cp);
+ 		doprintf(("\n\t\t\t%s", pr_date(n)))
+ 		doprintf(("\t;signature signed time"))
+ 		cp += INT32SZ;
+ 
+ 		n = _getshort(cp);
+ 		doprintf(("\n\t\t\t%s", itoa(n)))
+ 		doprintf(("\t\t;key footprint"))
+ 		cp += INT16SZ;
+ 
+ 		n = expand_name(rname, type, cp, msg, eom, dname);
+ 		if (n < 0)
+ 			break;
+ 		doprintf(("\n\t\t\t%s", pr_name(dname)))
+ 		cp += n;
+ 
+ 		if (cp < eor)
+ 		{
+ 			register char *buf;
+ 			register int size;
+ 
+ 			n = eor - cp;
+ 			buf = base_ntoa(cp, n);
+ 			size = strlength(buf);
+ 			cp += n;
+ 
+ 			while ((n = (size > 64) ? 64 : size) > 0)
+ 			{
+ 				doprintf(("\n\t%s", stoa((u_char *)buf, n, FALSE)))
+ 				buf += n; size -= n;
+ 			}
+ 		}
+ 
+ 		doprintf(("\n\t\t\t)"))
+ 		break;
+ 
  	    case T_KEY:
! 		if (check_size(rname, type, cp, msg, eor, INT16SZ) < 0)
! 			break;
! 		n = _getshort(cp);
! 		doprintf(("\t0x%s", xtoa(n)))
! 		cp += INT16SZ;
! 
! 		if (check_size(rname, type, cp, msg, eor, 1) < 0)
! 			break;
! 		n = *cp++;
! 		doprintf((" %s", itoa(n)))
! 
! 		if (check_size(rname, type, cp, msg, eor, 1) < 0)
! 			break;
! 		n = *cp++;
! 		doprintf((" %s", itoa(n)))
! 
! 		if (cp < eor)
! 		{
! 			register char *buf;
! 			register int size;
! 
! 			n = eor - cp;
! 			buf = base_ntoa(cp, n);
! 			size = strlength(buf);
! 			cp += n;
! 
! 			doprintf((" ("))
! 			while ((n = (size > 64) ? 64 : size) > 0)
! 			{
! 				doprintf(("\n\t%s", stoa((u_char *)buf, n, FALSE)))
! 				buf += n; size -= n;
! 			}
! 			doprintf(("\n\t\t\t)"))
! 		}
! 		break;
! 
! 	    case T_NXT:
! 		n = expand_name(rname, type, cp, msg, eom, dname);
! 		if (n < 0)
! 			break;
! 		doprintf(("\t%s", pr_name(dname)))
! 		cp += n;
! 
! 		n = 0;
! 		while (cp < eor)
! 		{
! 		    c = *cp++;
! 		    do
! 		    {
!  			if (c & 0200)
! 			{
! 			    doprintf((" %s", pr_type(n)))
! 			}
!  			c <<= 1;
! 		    } while (++n & 07);
! 		}
! 		break;
! 
! 	    case T_SRV:
! 		if (check_size(rname, type, cp, msg, eor, INT16SZ) < 0)
! 			break;
! 		n = _getshort(cp);
! 		doprintf(("\t%s", itoa(n)))
! 		cp += INT16SZ;
! 
! 		if (check_size(rname, type, cp, msg, eor, INT16SZ) < 0)
! 			break;
! 		n = _getshort(cp);
! 		doprintf((" %s", itoa(n)))
! 		cp += INT16SZ;
! 
! 		if (check_size(rname, type, cp, msg, eor, INT16SZ) < 0)
! 			break;
! 		n = _getshort(cp);
! 		doprintf((" %s", itoa(n)))
! 		cp += INT16SZ;
! 
! 		n = expand_name(rname, type, cp, msg, eom, dname);
! 		if (n < 0)
! 			break;
! 		doprintf((" %s", pr_name(dname)))
! 		cp += n;
  		break;
+ #ifdef notdef
+ 	    case T_TSIG:
+ 		if (check_size(rname, type, cp, msg, eor, 1) < 0)
+ 			break;
+ 		n = *cp++;
+ 		doprintf(("\t\"%s\"", stoa(cp, n, TRUE)))
+ 		cp += n;
  
+ 		while (cp < eor)
+ 		{
+ 			if (check_size(rname, type, cp, msg, eor, 1) < 0)
+ 				break;
+ 			n = *cp++;
+ 			doprintf((" \"%s\"", stoa(cp, n, TRUE)))
+ 			cp += n;
+ 		}
+ 		break;
+ #endif
  	    default:
  		doprintf(("\t???"))
  		cp += dlen;
***************
*** 2684,2690 ****
   * Save the MR or MG alias for MB chain tracing.
   * These features can be enabled only in normal mode.
   */
! 	if (!listmode && classmatch)
  	{
  		if (type == T_CNAME)
  			cname = strcpy(cnamebuf, dname);
--- 2861,2867 ----
   * Save the MR or MG alias for MB chain tracing.
   * These features can be enabled only in normal mode.
   */
! 	if (regular && classmatch)
  	{
  		if (type == T_CNAME)
  			cname = strcpy(cnamebuf, dname);
***************
*** 2734,2740 ****
   * i.e. it should exist and have an A record and not be a CNAME.
   * Currently this test is suppressed during deep recursive zone listings.
   */
! 	if (!recurskip && test_canon(type) && (n = check_canon(dname)) != 0)
  	{
  		/* only report definitive target host failures */
  		if (n == HOST_NOT_FOUND)
--- 2911,2917 ----
   * i.e. it should exist and have an A record and not be a CNAME.
   * Currently this test is suppressed during deep recursive zone listings.
   */
! 	if (!recurskip && test_canon(type) && ((n = check_canon(dname)) != 0))
  	{
  		/* only report definitive target host failures */
  		if (n == HOST_NOT_FOUND)
***************
*** 2761,2767 ****
   * it is registered and maps back to the name of the A record.
   * Currently this option has effect here only during zone listings.
   */
! 	if (addrmode && (type == T_A && !reverse) && !fakeaddr(address))
  	{
  		host = mapreverse(rname, inaddr);
  		if (host == NULL)
--- 2938,2944 ----
   * it is registered and maps back to the name of the A record.
   * Currently this option has effect here only during zone listings.
   */
! 	if (addrmode && ((type == T_A) && !reverse) && !fakeaddr(address))
  	{
  		host = mapreverse(rname, inaddr);
  		if (host == NULL)
***************
*** 2788,2795 ****
  */
  
  u_char *
! skip_qrec(name, cp, msg, eom)
  input char *name;			/* full name we are querying about */
  register u_char *cp;			/* current position in answer buf */
  input u_char *msg, *eom;		/* begin and end of answer buf */
  {
--- 2965,2974 ----
  */
  
  u_char *
! skip_qrec(name, qtype, qclass, cp, msg, eom)
  input char *name;			/* full name we are querying about */
+ input int qtype;			/* record type we are querying about */
+ input int qclass;			/* record class we are querying about */
  register u_char *cp;			/* current position in answer buf */
  input u_char *msg, *eom;		/* begin and end of answer buf */
  {
***************
*** 2797,2802 ****
--- 2976,2984 ----
  	int type, class;		/* fixed values in query record */
  	register int n;
  
+ /*
+  * Pickup the standard values present in the query section.
+  */
  	n = expand_name(name, T_NONE, cp, msg, eom, rname);
  	if (n < 0)
  		return(NULL);
***************
*** 2817,2822 ****
--- 2999,3022 ----
  		printf("%-20s\t%s\t%s\n",
  			rname, pr_class(class), pr_type(type));
  #endif
+ 
+ /*
+  * The values in the answer should match those in the query.
+  * If there is a mismatch, we just signal an error, but don't abort.
+  * For regular queries there is exactly one record in the query section.
+  */
+ 	if (!sameword(rname, name))
+ 		pr_error("invalid answer name %s after %s query for %s",
+ 			rname, pr_type(qtype), name);
+ 
+ 	if (type != qtype)
+ 		pr_error("invalid answer type %s after %s query for %s",
+ 			pr_type(type), pr_type(qtype), name);
+ 
+ 	if (class != qclass)
+ 		pr_error("invalid answer class %s after %s query for %s",
+ 			pr_class(class), pr_type(qtype), name);
+ 
  	return(cp);
  }
  
***************
*** 2838,2844 ****
  	int save_errno;
  	int save_herrno;
  
! 	if (level > 5)
  	{
  		errmsg("Recursion too deep");
  		return(FALSE);
--- 3038,3044 ----
  	int save_errno;
  	int save_herrno;
  
! 	if (level > MAXCHAIN)
  	{
  		errmsg("Recursion too deep");
  		return(FALSE);
***************
*** 3012,3018 ****
   * Suppress various checks if working beyond the recursion skip level.
   * This affects processing in print_rrec(). It may need refinement.
   */
! 	recurskip = (recursion_level > skip_level) ? TRUE : FALSE;
  
  /*
   * Find the nameservers for the given zone.
--- 3212,3218 ----
   * Suppress various checks if working beyond the recursion skip level.
   * This affects processing in print_rrec(). It may need refinement.
   */
! 	recurskip = ((recursion_level > skip_level) && !addrmode) ? TRUE : FALSE;
  
  /*
   * Find the nameservers for the given zone.
***************
*** 3042,3048 ****
   * Without an explicit server on the command line, the servers we
   * have looked up are supposed to be authoritative for the zone.
   */
! 	authserver = server ? FALSE : TRUE;
  
  /*
   * Check SOA records at each of the nameservers if so requested.
--- 3242,3248 ----
   * Without an explicit server on the command line, the servers we
   * have looked up are supposed to be authoritative for the zone.
   */
! 	authserver = (server && !primary) ? FALSE : TRUE;
  
  /*
   * Check SOA records at each of the nameservers if so requested.
***************
*** 3387,3393 ****
  			return(FALSE);
  		}
  
! 		hp = gethostbyname(primaryname);
  		if (hp == NULL)
  		{
  			ns_error(primaryname, T_A, C_IN, server);
--- 3587,3593 ----
  			return(FALSE);
  		}
  
! 		hp = geth_byname(primaryname);
  		if (hp == NULL)
  		{
  			ns_error(primaryname, T_A, C_IN, server);
***************
*** 3395,3401 ****
  			return(FALSE);
  		}
  
! 		(void) strcpy(nsname[0], hp->h_name);
  		for (i = 0; i < MAXIPADDR && hp->h_addr_list[i]; i++)
  			ipaddr[0][i] = incopy(hp->h_addr_list[i]);
  		naddrs[0] = i;
--- 3595,3602 ----
  			return(FALSE);
  		}
  
! 		primaryname = strncpy(nsname[0], hp->h_name, MAXDNAME);
! 		primaryname[MAXDNAME] = '\0';
  		for (i = 0; i < MAXIPADDR && hp->h_addr_list[i]; i++)
  			ipaddr[0][i] = incopy(hp->h_addr_list[i]);
  		naddrs[0] = i;
***************
*** 3412,3418 ****
   * Otherwise we have to find the nameservers for the zone.
   * These are supposed to be authoritative, but sometimes we
   * encounter lame delegations, perhaps due to misconfiguration.
-  * Retrieve the NS records for this zone.
   */
  	if (!get_servers(name))
  	{
--- 3613,3618 ----
***************
*** 3433,3439 ****
  	{
  	    if (naddrs[n] == 0)
  	    {
! 		hp = gethostbyname(nsname[n]);
  		if (hp != NULL)
  		{
  			for (i = 0; i < MAXIPADDR && hp->h_addr_list[i]; i++)
--- 3633,3639 ----
  	{
  	    if (naddrs[n] == 0)
  	    {
! 		hp = geth_byname(nsname[n]);
  		if (hp != NULL)
  		{
  			for (i = 0; i < MAXIPADDR && hp->h_addr_list[i]; i++)
***************
*** 3453,3460 ****
  			/* authoritative denial: probably misconfiguration */
  			if (h_errno == NO_DATA || h_errno == HOST_NOT_FOUND)
  			{
! 				errmsg("%s has lame delegation to %s",
! 					name, nsname[n]);
  			}
  		}
  
--- 3653,3661 ----
  			/* authoritative denial: probably misconfiguration */
  			if (h_errno == NO_DATA || h_errno == HOST_NOT_FOUND)
  			{
! 				if (server == NULL)
! 					errmsg("%s has lame delegation to %s",
! 						name, nsname[n]);
  			}
  		}
  
***************
*** 3512,3518 ****
  		return(FALSE);
  
  	if (verbose > 1)
! 		(void) print_info(&answer, n, name, T_NS, FALSE);
  
  	result = get_nsinfo(&answer, n, name);
  	return(result);
--- 3713,3719 ----
  		return(FALSE);
  
  	if (verbose > 1)
! 		(void) print_info(&answer, n, name, T_NS, queryclass, FALSE);
  
  	result = get_nsinfo(&answer, n, name);
  	return(result);
***************
*** 3523,3529 ****
  ** -------------------------------------------------------------------
  **
  **	Returns:
! **		TRUE if servers could be determined successfully.
  **		FALSE otherwise.
  **
  **	Outputs:
--- 3724,3730 ----
  ** -------------------------------------------------------------------
  **
  **	Returns:
! **		TRUE if the answer buffer was processed successfully.
  **		FALSE otherwise.
  **
  **	Outputs:
***************
*** 3557,3565 ****
  	eom = (u_char *)answerbuf + answerlen;
  	cp  = (u_char *)answerbuf + HFIXEDSZ;
  
! 	while (qdcount > 0 && cp < eom)
  	{
! 		cp = skip_qrec(name, cp, msg, eom);
  		if (cp == NULL)
  			return(FALSE);
  		qdcount--;
--- 3758,3766 ----
  	eom = (u_char *)answerbuf + answerlen;
  	cp  = (u_char *)answerbuf + HFIXEDSZ;
  
! 	if (qdcount > 0 && cp < eom)	/* should be exactly one record */
  	{
! 		cp = skip_qrec(name, T_NS, queryclass, cp, msg, eom);
  		if (cp == NULL)
  			return(FALSE);
  		qdcount--;
***************
*** 3634,3640 ****
  				nservers++;
  			}
  		}
! 		else if ((type == T_A) && dlen == INADDRSZ)
  		{
  			for (i = 0; i < nservers; i++)
  				if (sameword(nsname[i], rname))
--- 3835,3841 ----
  				nservers++;
  			}
  		}
! 		else if ((type == T_A) && (dlen == INADDRSZ))
  		{
  			for (i = 0; i < nservers; i++)
  				if (sameword(nsname[i], rname))
***************
*** 3650,3661 ****
--- 3851,3866 ----
  			cp += dlen;
  		}
  		else
+ 		{
+ 			/* just ignore other records */
  			cp += dlen;
+ 		}
  
  		if (cp != eor)
  		{
  			pr_error("size error in %s record for %s, off by %s",
  				pr_type(type), rname, itoa(cp - eor));
+ 			h_errno = NO_RECOVERY;
  			return(FALSE);
  		}
  
***************
*** 3670,3675 ****
--- 3875,3882 ----
  		return(FALSE);
  	}
  
+ 	/* set proper status if no answers found */
+ 	h_errno = (nservers > 0) ? 0 : TRY_AGAIN;
  	return(TRUE);
  }
  
***************
*** 3907,3913 ****
  			printf("Trying server %s (%s) ...\n",
  				inet_ntoa(ipaddr[n][i]), nsname[n]);
  
! 		if (transfer_zone(name, queryclass, ipaddr[n][i], nsname[n]))
  			goto done;	/* double break */
  
  		/* zone transfer failed */
--- 4114,4120 ----
  			printf("Trying server %s (%s) ...\n",
  				inet_ntoa(ipaddr[n][i]), nsname[n]);
  
! 		if (transfer_zone(name, ipaddr[n][i], nsname[n]))
  			goto done;	/* double break */
  
  		/* zone transfer failed */
***************
*** 3975,3983 ****
  */
  
  bool
! transfer_zone(name, class, inaddr, host)
  input char *name;			/* name of zone to do zone xfer for */
- input int class;			/* specific resource record class */
  input struct in_addr inaddr;		/* address of server to be queried */
  input char *host;			/* name of server to be queried */
  {
--- 4182,4189 ----
  */
  
  bool
! transfer_zone(name, inaddr, host)
  input char *name;			/* name of zone to do zone xfer for */
  input struct in_addr inaddr;		/* address of server to be queried */
  input char *host;			/* name of server to be queried */
  {
***************
*** 3998,4005 ****
  
  /*
   * Perform the actual zone transfer.
   */
! 	if (get_zone(name, class, inaddr, host))
  		return(TRUE);
  
  /*
--- 4204,4212 ----
  
  /*
   * Perform the actual zone transfer.
+  * All error reporting is done by get_zone().
   */
! 	if (get_zone(name, inaddr, host))
  		return(TRUE);
  
  /*
***************
*** 4040,4048 ****
  */
  
  bool
! get_zone(name, class, inaddr, host)
  input char *name;			/* name of zone to do zone xfer for */
- input int class;			/* specific resource record class */
  input struct in_addr inaddr;		/* address of server to be queried */
  input char *host;			/* name of server to be queried */
  {
--- 4247,4254 ----
  */
  
  bool
! get_zone(name, inaddr, host)
  input char *name;			/* name of zone to do zone xfer for */
  input struct in_addr inaddr;		/* address of server to be queried */
  input char *host;			/* name of server to be queried */
  {
***************
*** 4057,4062 ****
--- 4263,4269 ----
  	int nrecords = 0;		/* number of records processed */
  	int soacount = 0;		/* count of SOA records */
  
+ 	/* clear global counts */
  	zonecount = 0;			/* count of delegated zones */
  	hostcount = 0;			/* count of host names */
  
***************
*** 4065,4071 ****
   */
  	errno = 0;	/* reset before querying nameserver */
  
! 	n = res_mkquery(QUERY, name, class, T_AXFR, (qbuf_t *)NULL, 0,
  			(rrec_t *)NULL, (qbuf_t *)&query, sizeof(querybuf));
  	if (n < 0)
  	{
--- 4272,4278 ----
   */
  	errno = 0;	/* reset before querying nameserver */
  
! 	n = res_mkquery(QUERY, name, queryclass, T_AXFR, (qbuf_t *)NULL, 0,
  			(rrec_t *)NULL, (qbuf_t *)&query, sizeof(querybuf));
  	if (n < 0)
  	{
***************
*** 4081,4093 ****
  		pr_query((qbuf_t *)&query, n, stdout);
  	}
  
  	sin.sin_family = AF_INET;
  	sin.sin_port = htons(NAMESERVER_PORT);
  	sin.sin_addr = inaddr;
  
- 	/* add name and address to error messages */
- 	/* _res_setaddr(&sin, host); */
- 
  	sock = socket(AF_INET, SOCK_STREAM, 0);
  	if (sock < 0)
  	{
--- 4288,4300 ----
  		pr_query((qbuf_t *)&query, n, stdout);
  	}
  
+ 	/* setup destination address */
+ 	bzero((char *)&sin, sizeof(sin));
+ 
  	sin.sin_family = AF_INET;
  	sin.sin_port = htons(NAMESERVER_PORT);
  	sin.sin_addr = inaddr;
  
  	sock = socket(AF_INET, SOCK_STREAM, 0);
  	if (sock < 0)
  	{
***************
*** 4098,4104 ****
  
  	if (_res_connect(sock, &sin, sizeof(sin)) < 0)
  	{
! 		if (debug || verbose)
  			_res_perror(&sin, host, "connect");
  		(void) close(sock);
  		h_errno = TRY_AGAIN;
--- 4305,4311 ----
  
  	if (_res_connect(sock, &sin, sizeof(sin)) < 0)
  	{
! 		if (verbose || debug)
  			_res_perror(&sin, host, "connect");
  		(void) close(sock);
  		h_errno = TRY_AGAIN;
***************
*** 4158,4164 ****
  
  		if (bp->rcode != NOERROR || ancount == 0)
  		{
! 			if (debug || verbose)
  				print_status(&answer, n);
  
  			switch (bp->rcode)
--- 4365,4371 ----
  
  		if (bp->rcode != NOERROR || ancount == 0)
  		{
! 			if (verbose || debug)
  				print_status(&answer, n);
  
  			switch (bp->rcode)
***************
*** 4224,4230 ****
  
  		soaname = NULL, subname = NULL, adrname = NULL;
  		listhost = host;
! 		(void) print_info(&answer, n, name, T_AXFR, TRUE);
  
  	/*
  	 * Terminate upon the second SOA record for this zone.
--- 4431,4437 ----
  
  		soaname = NULL, subname = NULL, adrname = NULL;
  		listhost = host;
! 		(void) print_info(&answer, n, name, T_AXFR, queryclass, FALSE);
  
  	/*
  	 * Terminate upon the second SOA record for this zone.
***************
*** 4363,4369 ****
  	if (n < 0)
  		return(FALSE);
  
! 	(void) print_info(&answer, n, name, T_MX, FALSE);
  
  	return(TRUE);
  }
--- 4570,4576 ----
  	if (n < 0)
  		return(FALSE);
  
! 	(void) print_info(&answer, n, name, T_MX, queryclass, FALSE);
  
  	return(TRUE);
  }
***************
*** 4392,4398 ****
  		return(NULL);
  
  	if (verbose > 1)
! 		(void) print_info(&answer, n, name, T_SOA, FALSE);
  
  	soaname = NULL;
  	(void) get_soainfo(&answer, n, name);
--- 4599,4605 ----
  		return(NULL);
  
  	if (verbose > 1)
! 		(void) print_info(&answer, n, name, T_SOA, queryclass, FALSE);
  
  	soaname = NULL;
  	(void) get_soainfo(&answer, n, name);
***************
*** 4434,4440 ****
  		return(FALSE);
  
  	if (verbose > 1)
! 		(void) print_info(&answer, n, name, T_SOA, FALSE);
  
  	soaname = NULL;
  	(void) get_soainfo(&answer, n, name);
--- 4641,4647 ----
  		return(FALSE);
  
  	if (verbose > 1)
! 		(void) print_info(&answer, n, name, T_SOA, queryclass, FALSE);
  
  	soaname = NULL;
  	(void) get_soainfo(&answer, n, name);
***************
*** 4451,4464 ****
  ** -------------------------------------------------------------
  **
  **	Returns:
! **		TRUE if the SOA record was found successfully.
  **		FALSE otherwise.
  **
  **	Outputs:
  **		The global struct ``soa'' is filled with the soa data.
  **
  **	Side effects:
! **		Sets ``soaname'' if this is a valid SOA record.
  **		This variable must have been cleared before calling
  **		get_soainfo() and may be checked afterwards.
  */
--- 4658,4671 ----
  ** -------------------------------------------------------------
  **
  **	Returns:
! **		TRUE if the answer buffer was processed successfully.
  **		FALSE otherwise.
  **
  **	Outputs:
  **		The global struct ``soa'' is filled with the soa data.
  **
  **	Side effects:
! **		Sets ``soaname'' if there is a valid SOA record.
  **		This variable must have been cleared before calling
  **		get_soainfo() and may be checked afterwards.
  */
***************
*** 4482,4490 ****
  	eom = (u_char *)answerbuf + answerlen;
  	cp  = (u_char *)answerbuf + HFIXEDSZ;
  
! 	while (qdcount > 0 && cp < eom)
  	{
! 		cp = skip_qrec(name, cp, msg, eom);
  		if (cp == NULL)
  			return(FALSE);
  		qdcount--;
--- 4689,4697 ----
  	eom = (u_char *)answerbuf + answerlen;
  	cp  = (u_char *)answerbuf + HFIXEDSZ;
  
! 	if (qdcount > 0 && cp < eom)	/* should be exactly one record */
  	{
! 		cp = skip_qrec(name, T_SOA, queryclass, cp, msg, eom);
  		if (cp == NULL)
  			return(FALSE);
  		qdcount--;
***************
*** 4500,4505 ****
--- 4707,4713 ----
  
  /*
   * Check answer section only.
+  * Check that answers match the requested zone. Ignore other entries.
   * The nameserver section may contain the nameservers for the zone,
   * and the additional section their addresses, but not guaranteed.
   * Those sections are usually empty for authoritative answers.
***************
*** 4538,4546 ****
  			printf("%-20s\t%d\t%s\t%s\n",
  				rname, ttl, pr_class(class), pr_type(type));
  #endif
! 		switch (type)
  		{
- 		    case T_SOA:
  			n = expand_name(rname, type, cp, msg, eom, soa.primary);
  			if (n < 0)
  				return(FALSE);
--- 4746,4753 ----
  			printf("%-20s\t%d\t%s\t%s\n",
  				rname, ttl, pr_class(class), pr_type(type));
  #endif
! 		if ((type == T_SOA) && sameword(rname, name))
  		{
  			n = expand_name(rname, type, cp, msg, eom, soa.primary);
  			if (n < 0)
  				return(FALSE);
***************
*** 4567,4583 ****
  
  			/* valid complete soa record found */
  			soaname = strcpy(soanamebuf, rname);
! 			break;
! 
! 		    default:
  			cp += dlen;
- 			break;
  		}
  
  		if (cp != eor)
  		{
  			pr_error("size error in %s record for %s, off by %s",
  				pr_type(type), rname, itoa(cp - eor));
  			return(FALSE);
  		}
  
--- 4774,4791 ----
  
  			/* valid complete soa record found */
  			soaname = strcpy(soanamebuf, rname);
! 		}
! 		else
! 		{
! 			/* just ignore other records */
  			cp += dlen;
  		}
  
  		if (cp != eor)
  		{
  			pr_error("size error in %s record for %s, off by %s",
  				pr_type(type), rname, itoa(cp - eor));
+ 			h_errno = NO_RECOVERY;
  			return(FALSE);
  		}
  
***************
*** 4592,4597 ****
--- 4800,4807 ----
  		return(FALSE);
  	}
  
+ 	/* set proper status if no answers found */
+ 	h_errno = (soaname != NULL) ? 0 : TRY_AGAIN;
  	return(TRUE);
  }
  
***************
*** 5209,5215 ****
  	struct hostent *hp;
  	register int i;
  	struct in_addr inaddr[MAXADDRS];
! 	int naddr;
  	char hnamebuf[MAXDNAME+1];
  	char *hname;
  	char inamebuf[MAXDNAME+1];
--- 5419,5425 ----
  	struct hostent *hp;
  	register int i;
  	struct in_addr inaddr[MAXADDRS];
! 	int naddress;
  	char hnamebuf[MAXDNAME+1];
  	char *hname;
  	char inamebuf[MAXDNAME+1];
***************
*** 5226,5245 ****
  		return(FALSE);
  	}
  
! 	hname = strcpy(hnamebuf, hp->h_name);
  
  	for (i = 0; i < MAXADDRS && hp->h_addr_list[i]; i++)
  		inaddr[i] = incopy(hp->h_addr_list[i]);
! 	naddr = i;
  
  	if (verbose)
  		printf("Found %d address%s for %s\n",
! 			naddr, plurale(naddr), hname);
  
  /*
   * Map back the addresses found, and check whether they revert to host.
   */
! 	for (matched = 0, i = 0; i < naddr; i++)
  	{
  		iname = strcpy(inamebuf, inet_ntoa(inaddr[i]));
  
--- 5436,5456 ----
  		return(FALSE);
  	}
  
! 	hname = strncpy(hnamebuf, hp->h_name, MAXDNAME);
! 	hname[MAXDNAME] = '\0';
  
  	for (i = 0; i < MAXADDRS && hp->h_addr_list[i]; i++)
  		inaddr[i] = incopy(hp->h_addr_list[i]);
! 	naddress = i;
  
  	if (verbose)
  		printf("Found %d address%s for %s\n",
! 			naddress, plurale(naddress), hname);
  
  /*
   * Map back the addresses found, and check whether they revert to host.
   */
! 	for (matched = 0, i = 0; i < naddress; i++)
  	{
  		iname = strcpy(inamebuf, inet_ntoa(inaddr[i]));
  
***************
*** 5256,5262 ****
  			matched++;
  	}
  
! 	return((matched == naddr) ? TRUE : FALSE);
  }
  
  /*
--- 5467,5473 ----
  			matched++;
  	}
  
! 	return((matched == naddress) ? TRUE : FALSE);
  }
  
  /*
***************
*** 5294,5307 ****
  		return(FALSE);
  	}
  
! 	hname = strcpy(hnamebuf, hp->h_name);
  
  	if (verbose)
  		printf("Address %s maps to %s\n", iname, hname);
  
  /*
   * Lookup the host name found to fetch its addresses.
-  * Verify whether the mapped host name is canonical.
   */
  	hp = gethostbyname(hname);
  	if (hp == NULL)
--- 5505,5518 ----
  		return(FALSE);
  	}
  
! 	hname = strncpy(hnamebuf, hp->h_name, MAXDNAME);
! 	hname[MAXDNAME] = '\0';
  
  	if (verbose)
  		printf("Address %s maps to %s\n", iname, hname);
  
  /*
   * Lookup the host name found to fetch its addresses.
   */
  	hp = gethostbyname(hname);
  	if (hp == NULL)
***************
*** 5310,5315 ****
--- 5521,5529 ----
  		return(FALSE);
  	}
  
+ /*
+  * Verify whether the mapped host name is canonical.
+  */
  	if (!sameword(hp->h_name, hname))
  		pr_warning("%s host %s is not canonical (%s)",
  			iname, hname, hp->h_name);
***************
*** 5337,5342 ****
--- 5551,5645 ----
  }
  
  /*
+ ** GETH_BYNAME -- Wrapper for gethostbyname
+ ** ----------------------------------------
+ **
+ **	Returns:
+ **		Pointer to struct hostent if lookup was successful.
+ **		NULL otherwise.
+ **
+ **	Note. This routine works for fully qualified names only.
+ **	The entire special res_search() processing can be skipped.
+ */
+ 
+ struct hostent *
+ geth_byname(name)
+ input CONST char *name;			/* name to do forward lookup for */
+ {
+ 	querybuf answer;
+ 	struct hostent *hp;
+ 	register int n;
+ 
+ 	hp = gethostbyname(name);
+ 	if (hp != NULL)
+ 		return(hp);
+ 
+ 	if (verbose > print_level)
+ 		printf("Finding addresses for %s ...\n", name);
+ 
+ 	n = get_info(&answer, name, T_A, C_IN);
+ 	if (n < 0)
+ 		return(NULL);
+ 
+ 	if ((verbose > print_level + 1) && (print_level < 1))
+ 		(void) print_info(&answer, n, name, T_A, C_IN, FALSE);
+ 
+ 	hp = gethostbyname(name);
+ 	return(hp);
+ }
+ 
+ /*
+ ** GETH_BYADDR -- Wrapper for gethostbyaddr
+ ** ----------------------------------------
+ **
+ **	Returns:
+ **		Pointer to struct hostent if lookup was successful.
+ **		NULL otherwise.
+ */
+ 
+ struct hostent *
+ geth_byaddr(addr, size, family)
+ input CONST char *addr;			/* address to do reverse mapping for */
+ input int size;				/* size of the address */
+ input int family;			/* address family */
+ {
+ 	char addrbuf[4*4 + sizeof(ARPA_ROOT) + 1];
+ 	char *name = addrbuf;
+ 	u_char *a = (u_char *)addr;
+ 	querybuf answer;
+ 	struct hostent *hp;
+ 	register int n;
+ 
+ 	if (size != INADDRSZ || family != AF_INET)
+ 	{
+ 		hp = gethostbyaddr(addr, size, family);
+ 		return(hp);
+ 	}
+ 
+ 	hp = gethostbyaddr(addr, size, family);
+ 	if (hp != NULL)
+ 		return(hp);
+ 
+ 	/* construct absolute reverse name *without* trailing dot */
+ 	(void) sprintf(addrbuf, "%u.%u.%u.%u.%s",
+ 		a[3]&0xff, a[2]&0xff, a[1]&0xff, a[0]&0xff, ARPA_ROOT);
+ 
+ 	if (verbose > print_level)
+ 		printf("Finding reverse mapping for %s ...\n",
+ 			inet_ntoa(incopy(addr)));
+ 
+ 	n = get_info(&answer, name, T_PTR, C_IN);
+ 	if (n < 0)
+ 		return(NULL);
+ 
+ 	if ((verbose > print_level + 1) && (print_level < 1))
+ 		(void) print_info(&answer, n, name, T_PTR, C_IN, FALSE);
+ 
+ 	hp = gethostbyaddr(addr, size, family);
+ 	return(hp);
+ }
+ 
+ /*
  ** PARSE_TYPE -- Decode rr type from input string
  ** ----------------------------------------------
  **
***************
*** 5344,5351 ****
  **		Value of resource record type.
  **		-1 if specified record name is invalid.
  **
! **	Note.	T_MD, T_MF, T_MAILA are obsolete, but recognized.
! **		T_AXFR is not allowed to be specified as query type.
  */
  
  int
--- 5647,5654 ----
  **		Value of resource record type.
  **		-1 if specified record name is invalid.
  **
! **	Note.	Several types are deprecated or obsolete, but recognized.
! **		T_AXFR/T_IXFR is not allowed to be specified as query type.
  */
  
  int
***************
*** 5354,5376 ****
  {
  	register int type;
  
  	if (sameword(str, "A"))		return(T_A);
  	if (sameword(str, "NS"))	return(T_NS);
  	if (sameword(str, "MD"))	return(T_MD);		/* obsolete */
  	if (sameword(str, "MF"))	return(T_MF);		/* obsolete */
  	if (sameword(str, "CNAME"))	return(T_CNAME);
  	if (sameword(str, "SOA"))	return(T_SOA);
! 	if (sameword(str, "MB"))	return(T_MB);
! 	if (sameword(str, "MG"))	return(T_MG);
! 	if (sameword(str, "MR"))	return(T_MR);
! 	if (sameword(str, "NULL"))	return(T_NULL);
  	if (sameword(str, "WKS"))	return(T_WKS);
  	if (sameword(str, "PTR"))	return(T_PTR);
  	if (sameword(str, "HINFO"))	return(T_HINFO);
! 	if (sameword(str, "MINFO"))	return(T_MINFO);
  	if (sameword(str, "MX"))	return(T_MX);
  	if (sameword(str, "TXT"))	return(T_TXT);
  
  	if (sameword(str, "RP"))	return(T_RP);
  	if (sameword(str, "AFSDB"))	return(T_AFSDB);
  	if (sameword(str, "X25"))	return(T_X25);
--- 5657,5683 ----
  {
  	register int type;
  
+ 		/* standard types */
+ 
  	if (sameword(str, "A"))		return(T_A);
  	if (sameword(str, "NS"))	return(T_NS);
  	if (sameword(str, "MD"))	return(T_MD);		/* obsolete */
  	if (sameword(str, "MF"))	return(T_MF);		/* obsolete */
  	if (sameword(str, "CNAME"))	return(T_CNAME);
  	if (sameword(str, "SOA"))	return(T_SOA);
! 	if (sameword(str, "MB"))	return(T_MB);		/* deprecated */
! 	if (sameword(str, "MG"))	return(T_MG);		/* deprecated */
! 	if (sameword(str, "MR"))	return(T_MR);		/* deprecated */
! 	if (sameword(str, "NULL"))	return(T_NULL);		/* obsolete */
  	if (sameword(str, "WKS"))	return(T_WKS);
  	if (sameword(str, "PTR"))	return(T_PTR);
  	if (sameword(str, "HINFO"))	return(T_HINFO);
! 	if (sameword(str, "MINFO"))	return(T_MINFO);	/* deprecated */
  	if (sameword(str, "MX"))	return(T_MX);
  	if (sameword(str, "TXT"))	return(T_TXT);
  
+ 		/* new types */
+ 
  	if (sameword(str, "RP"))	return(T_RP);
  	if (sameword(str, "AFSDB"))	return(T_AFSDB);
  	if (sameword(str, "X25"))	return(T_X25);
***************
*** 5381,5401 ****
  	if (sameword(str, "SIG"))	return(T_SIG);
  	if (sameword(str, "KEY"))	return(T_KEY);
  	if (sameword(str, "PX"))	return(T_PX);
! 	if (sameword(str, "GPOS"))	return(T_GPOS);
  	if (sameword(str, "AAAA"))	return(T_AAAA);
  	if (sameword(str, "LOC"))	return(T_LOC);
  
  	if (sameword(str, "UINFO"))	return(T_UINFO);
  	if (sameword(str, "UID"))	return(T_UID);
  	if (sameword(str, "GID"))	return(T_GID);
  	if (sameword(str, "UNSPEC"))	return(T_UNSPEC);
  
  	if (sameword(str, "AXFR"))	return(-1);		/* illegal */
  	if (sameword(str, "MAILB"))	return(T_MAILB);
  	if (sameword(str, "MAILA"))	return(T_MAILA);	/* obsolete */
  	if (sameword(str, "ANY"))	return(T_ANY);
  	if (sameword(str, "*"))		return(T_ANY);
  
  	type = atoi(str);
  	if (type >= T_FIRST && type <= T_LAST)
  		return(type);
--- 5688,5717 ----
  	if (sameword(str, "SIG"))	return(T_SIG);
  	if (sameword(str, "KEY"))	return(T_KEY);
  	if (sameword(str, "PX"))	return(T_PX);
! 	if (sameword(str, "GPOS"))	return(T_GPOS);		/* withdrawn */
  	if (sameword(str, "AAAA"))	return(T_AAAA);
  	if (sameword(str, "LOC"))	return(T_LOC);
+ 	if (sameword(str, "NXT"))	return(T_NXT);
+ 	if (sameword(str, "SRV"))	return(T_SRV);
  
+ 		/* nonstandard types */
+ 
  	if (sameword(str, "UINFO"))	return(T_UINFO);
  	if (sameword(str, "UID"))	return(T_UID);
  	if (sameword(str, "GID"))	return(T_GID);
  	if (sameword(str, "UNSPEC"))	return(T_UNSPEC);
  
+ 		/* filters */
+ 
+ 	if (sameword(str, "IXFR"))	return(-1);		/* illegal */
  	if (sameword(str, "AXFR"))	return(-1);		/* illegal */
  	if (sameword(str, "MAILB"))	return(T_MAILB);
  	if (sameword(str, "MAILA"))	return(T_MAILA);	/* obsolete */
  	if (sameword(str, "ANY"))	return(T_ANY);
  	if (sameword(str, "*"))		return(T_ANY);
  
+ 		/* unknown types */
+ 
  	type = atoi(str);
  	if (type >= T_FIRST && type <= T_LAST)
  		return(type);
***************
*** 6308,6313 ****
--- 6624,6633 ----
  **
  **	Returns:
  **		Number of shared trailing components in both names.
+ **
+ **	Note. This routine is currently used only to compare nameserver
+ **	names in the RHS of NS records, so there is no need to check
+ **	for embedded quoted dots.
  */
  
  int
***************
*** 6474,6479 ****
--- 6794,6801 ----
  
  	switch (type)
  	{
+ 		/* standard types */
+ 
  	    case T_A:       return("A");	/* internet address */
  	    case T_NS:      return("NS");	/* authoritative server */
  	    case T_MD:      return("MD");	/* mail destination */
***************
*** 6491,6496 ****
--- 6813,6820 ----
  	    case T_MX:      return("MX");	/* mail routing info */
  	    case T_TXT:     return("TXT");	/* descriptive text */
  
+ 		/* new types */
+ 
  	    case T_RP:      return("RP");	/* responsible person */
  	    case T_AFSDB:   return("AFSDB");	/* afs database location */
  	    case T_X25:     return("X25");	/* x25 address */
***************
*** 6504,6515 ****
--- 6828,6846 ----
  	    case T_GPOS:    return("GPOS");	/* geographical position */
  	    case T_AAAA:    return("AAAA");	/* ip v6 address */
  	    case T_LOC:     return("LOC");	/* geographical location */
+ 	    case T_NXT:     return("NXT");	/* next valid name */
+ 	    case T_SRV:     return("SRV");	/* service info */
+ 
+ 		/* nonstandard types */
  
  	    case T_UINFO:   return("UINFO");	/* user information */
  	    case T_UID:     return("UID");	/* user ident */
  	    case T_GID:     return("GID");	/* group ident */
  	    case T_UNSPEC:  return("UNSPEC");	/* unspecified binary data */
  
+ 		/* filters */
+ 
+ 	    case T_IXFR:    return("IXFR");	/* incremental zone transfer */
  	    case T_AXFR:    return("AXFR");	/* zone transfer */
  	    case T_MAILB:   return("MAILB");	/* matches MB/MR/MG/MINFO */
  	    case T_MAILA:   return("MAILA");	/* matches MD/MF */
***************
*** 6518,6523 ****
--- 6849,6855 ----
  	    case T_NONE:    return("resource");	/* not yet determined */
  	}
  
+ 	/* unknown type */
  	(void) sprintf(buf, "%d", type);
  	return(buf);
  }
***************
*** 6545,6550 ****
--- 6877,6883 ----
  	    case C_ANY:     return("ANY");	/* any class */
  	}
  
+ 	/* unknown class */
  	(void) sprintf(buf, "%d", class);
  	return(buf);
  }
***************
*** 6557,6563 ****
  **		Number of bytes advanced in answer buffer.
  **		-1 if there was a format error.
  **
! **	It is assumed that the specified buffer is of sufficient size.
  */
  
  int
--- 6890,6897 ----
  **		Number of bytes advanced in answer buffer.
  **		-1 if there was a format error.
  **
! **	It is assumed that the specified buffer is of a fixed size
! **	MAXDNAME+1 that should be sufficient to store the data.
  */
  
  int
***************
*** 6579,6584 ****
--- 6913,6921 ----
  		return(-1);
  	}
  
+ 	/* should not be necessary, but who knows */
+ 	namebuf[MAXDNAME] = '\0';
+ 
  	/* change root to single dot */
  	if (namebuf[0] == '\0')
  	{
***************
*** 6704,6710 ****
  			continue;
  
  		/* allow '*' for use in wildcard names */
! 		if ((c == '*') && wildcard)
  			continue;
  
  		/* ignore underscore in certain circumstances */
--- 7041,7047 ----
  			continue;
  
  		/* allow '*' for use in wildcard names */
! 		if ((c == '*') && (p == name && p[1] == '.') && wildcard)
  			continue;
  
  		/* ignore underscore in certain circumstances */
***************
*** 6749,6755 ****
  	save_errno = errno;
  	save_herrno = h_errno;
  
! 	hp = gethostbyname(name);
  	status = h_errno;
  
  	errno = save_errno;
--- 7086,7092 ----
  	save_errno = errno;
  	save_herrno = h_errno;
  
! 	hp = geth_byname(name);
  	status = h_errno;
  
  	errno = save_errno;
***************
*** 6804,6810 ****
  	save_errno = errno;
  	save_herrno = h_errno;
  
! 	hp = gethostbyaddr((char *)&inaddr, INADDRSZ, AF_INET);
  	status = h_errno;
  
  	errno = save_errno;
--- 7141,7147 ----
  	save_errno = errno;
  	save_herrno = h_errno;
  
! 	hp = geth_byaddr((char *)&inaddr, INADDRSZ, AF_INET);
  	status = h_errno;
  
  	errno = save_errno;
***************
*** 6874,6881 ****
  }
  
  /*
! ** ITOA -- Convert integer value to ascii string
! ** ---------------------------------------------
  **
  **	Returns:
  **		Pointer to string.
--- 7211,7218 ----
  }
  
  /*
! ** ITOA -- Convert value to decimal integer ascii string
! ** -----------------------------------------------------
  **
  **	Returns:
  **		Pointer to string.
***************
*** 6891,6899 ****
  	return(buf);
  }
  
! 
! /*
! ** UTOA -- Convert unsigned integer value to ascii string
  ** ------------------------------------------------------
  **
  **	Returns:
--- 7228,7235 ----
  	return(buf);
  }
  
! /*
! ** UTOA -- Convert value to unsigned decimal ascii string
  ** ------------------------------------------------------
  **
  **	Returns:
***************
*** 6911,6916 ****
--- 7247,7270 ----
  }
  
  /*
+ ** XTOA -- Convert value to hexadecimal ascii string
+ ** -------------------------------------------------
+ **
+ **	Returns:
+ **		Pointer to string.
+ */
+ 
+ char *
+ xtoa(n)
+ input int n;				/* value to convert */
+ {
+ 	static char buf[17];		/* sufficient for 64-bit values */
+ 
+ 	(void) sprintf(buf, "%X", (unsigned)n);
+ 	return(buf);
+ }
+ 
+ /*
  ** STOA -- Extract partial ascii string, escape if necessary
  ** ---------------------------------------------------------
  **
***************
*** 6952,6957 ****
--- 7306,7376 ----
  }
  
  /*
+ ** BASE_NTOA -- Convert binary data to base64 ascii
+ ** ------------------------------------------------
+ **
+ **	Returns:
+ **		Pointer to string.
+ **
+ **	This routine is used to convert encoded keys and signatures
+ **	in T_KEY and T_SIG resource records.
+ */
+ 
+ char b64tab[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ 
+ char *
+ base_ntoa(cp, size)
+ input u_char *cp;			/* current position in answer buf */
+ input int size;				/* number of bytes to extract */
+ {
+ 	static char buf[MAXB64SIZE+1];
+ 	register char *p;
+ 	int c1, c2, c3, c4;
+ 
+ 	if (size > MAXMD5SIZE)
+ 		size = MAXMD5SIZE;
+ 
+ 	for (p = buf; size > 2; cp += 3, size -= 3)
+ 	{
+ 		c1 = (((int)cp[0] >> 2) & 0x3f);
+ 		c2 = (((int)cp[0] & 0x03) << 4) + (((int)cp[1] >> 4) & 0x0f);
+ 		c3 = (((int)cp[1] & 0x0f) << 2) + (((int)cp[2] >> 6) & 0x03);
+ 		c4 =  ((int)cp[2] & 0x3f);
+ 
+ 		*p++ = b64tab[c1];
+ 		*p++ = b64tab[c2];
+ 		*p++ = b64tab[c3];
+ 		*p++ = b64tab[c4];
+ 	}
+     
+ 	if (size == 2)
+ 	{
+ 		c1 = (((int)cp[0] >> 2) & 0x3f);
+ 		c2 = (((int)cp[0] & 0x03) << 4) + (((int)cp[1] >> 4) & 0x0f);
+ 		c3 = (((int)cp[1] & 0x0f) << 2);
+ 
+ 		*p++ = b64tab[c1];
+ 		*p++ = b64tab[c2];
+ 		*p++ = b64tab[c3];
+ 		*p++ = '=';
+ 	}
+ 	else if (size == 1)
+ 	{
+ 		c1 = (((int)cp[0] >> 2) & 0x3f);
+ 		c2 = (((int)cp[0] & 0x03) << 4);
+ 
+ 		*p++ = b64tab[c1];
+ 		*p++ = b64tab[c2];
+ 		*p++ = '=';
+ 		*p++ = '=';
+ 	}
+ 	*p = '\0';
+ 
+ 	return(buf);
+ }
+ 
+ /*
  ** NSAP_NTOA -- Convert binary nsap address to ascii
  ** -------------------------------------------------
  **
***************
*** 7027,7032 ****
--- 7446,7480 ----
  }
  
  /*
+ ** PR_DATE -- Produce printable version of a clock value
+ ** -----------------------------------------------------
+ **
+ **	Returns:
+ **		Pointer to string.
+ **
+ **	The value is a standard absolute clock value.
+ */
+ 
+ char *
+ pr_date(value)
+ input int value;			/* the clock value to be converted */
+ {
+ 	static char buf[sizeof("YYYYMMDDHHMMSS")+1];
+ 	time_t clocktime = value;
+ 	struct tm *t;
+ 	
+ 	t = gmtime(&clocktime);
+ 	t->tm_year += 1900;
+ 	t->tm_mon += 1;
+ 
+ 	(void) sprintf(buf, "%04d%02d%02d%02d%02d%02d",
+ 		t->tm_year, t->tm_mon, t->tm_mday,
+ 		t->tm_hour, t->tm_min, t->tm_sec);
+ 
+ 	return(buf);
+ }
+ 
+ /*
  ** PR_TIME -- Produce printable version of a time interval
  ** -------------------------------------------------------
  **
***************
*** 7139,7145 ****
  /*
   * Normalize.
   */
! 	value -= (1 << 31);
  
  	direction = pos;
  	if (value < 0)
--- 7587,7593 ----
  /*
   * Normalize.
   */
! 	value -= (int)((unsigned)1 << 31);
  
  	direction = pos;
  	if (value < 0)
Only in m:\bind495t6b/contrib/host: malloc.c
diff --context --recurs m:\bind495t5b/contrib/host/rrec.h m:\bind495t6b/contrib/host/rrec.h
*** m:\bind495t5b/contrib/host/rrec.h	Wed Apr 17 08:44:49 1996
--- m:\bind495t6b/contrib/host/rrec.h	Sun Sep 29 18:57:09 1996
***************
*** 4,23 ****
  **	These define the various resource record fields after decoding
  **	from the internal representation in the nameserver answer buffer.
  **
! **	@(#)rrec.h              e07@nikhef.nl (Eric Wassenaar) 960417
  */
  
! #define MAXSTRING 255		/* maximum size of single encoded string */
! #define MAXSTRLEN MAXDLEN	/* maximum size of total  encoded string */
  
! typedef struct rr_data {
! 	u_char databuf[MAXDLEN];	/* generic data buffer */
! } rr_data_t;
  
  /*
! ** Record-specific data fields.
  */
- 	/* traditional records */
  
  typedef struct a_data {
  	ipaddr_t address;		/* internet address of host */
--- 4,22 ----
  **	These define the various resource record fields after decoding
  **	from the internal representation in the nameserver answer buffer.
  **
! **	@(#)rrec.h              e07@nikhef.nl (Eric Wassenaar) 960929
  */
  
! #define MAXSTRING 255		/* maximum size of single encoded string */
! #define MAXSTRLEN MAXDLEN	/* maximum size of multiple substrings */
  
! typedef struct rr_data {
! 	u_char databuf[MAXDLEN];	/* generic data buffer */
! } rr_data_t;
  
  /*
! ** Record-specific data fields, traditional records.
  */
  
  typedef struct a_data {
  	ipaddr_t address;		/* internet address of host */
***************
*** 91,100 ****
  } mx_data_t;
  
  typedef struct txt_data {
! 	char text[MAXSTRLEN+1];		/* concatenated substrings */
  } txt_data_t;
  
! 	/* later additions */
  
  typedef struct rp_data {
  	char mailbox[MAXDNAME+1];	/* name of person mailbox */
--- 90,101 ----
  } mx_data_t;
  
  typedef struct txt_data {
! 	char text[MAXSTRLEN+1];		/* multiple substrings */
  } txt_data_t;
  
! /*
! ** Record-specific data fields, later additions.
! */
  
  typedef struct rp_data {
  	char mailbox[MAXDNAME+1];	/* name of person mailbox */
***************
*** 128,133 ****
--- 129,153 ----
  	char nsapdomain[MAXDNAME+1];	/* domain name of nsap pointer */
  } nsapptr_data_t;
  
+ typedef struct sig_data {
+ 	int sigtype;			/* resource record type covered */
+ 	int algorithm;			/* signature encoding algorithm */
+ 	int nlabels;			/* number of labels in SIG name */
+ 	int sigttl;			/* original ttl of SIG record */
+ 	time_t expiretime;		/* signature expiration time */
+ 	time_t sigtime;			/* time signature was signed */
+ 	int footprint;			/* key identification */
+ 	char signer[MAXDNAME+1];	/* signer's domain name */
+ 	u_char sig[MAXMD5SIZE];		/* encoded signature */
+ } sig_data_t;
+ 
+ typedef struct key_data {
+ 	int keyflags;			/* key description flags */
+ 	int protocol;			/* protocol suite */
+ 	int algorithm;			/* key encoding algorithm */
+ 	u_char key[MAXMD5SIZE];		/* encoded key */
+ } key_data_t;
+ 
  typedef struct px_data {
  	int mappref;			/* preference value */
  	char map822[MAXDNAME+1];	/* rfc822 domain name */
***************
*** 154,160 ****
  	int altitude;			/* geographical altitude */
  } loc_data_t;
  
! 	/* nonstandard records */
  
  typedef struct uinfo_data {
  	char userinfo[MAXSTRLEN+1];	/* user description */
--- 174,194 ----
  	int altitude;			/* geographical altitude */
  } loc_data_t;
  
! typedef struct nxt_data {
! 	char nxtdomain[MAXDNAME+1];	/* name of next domain in order */
! 	u_char typemap[32];		/* types 0-255 */
! } nxt_data_t;
! 
! typedef struct srv_data {
! 	int srvpref;			/* preference value */
! 	int srvweight;			/* load balancing weight */
! 	int srvport;			/* port of service */
! 	char srvhost[MAXDNAME+1];	/* name of service host */
! } srv_data_t;
! 
! /*
! ** Record-specific data fields, nonstandard types.
! */
  
  typedef struct uinfo_data {
  	char userinfo[MAXSTRLEN+1];	/* user description */
***************
*** 172,178 ****
  	u_char unspecbuf[MAXDLEN];	/* generic data buffer */
  } unspec_data_t;
  
! /*
  ** Generic resource record description.
  */
  
--- 206,212 ----
  	u_char unspecbuf[MAXDLEN];	/* generic data buffer */
  } unspec_data_t;
  
! /*
  ** Generic resource record description.
  */
  
***************
*** 206,215 ****
--- 240,253 ----
  		rt_data_t	data_rt;
  		nsap_data_t	data_nsap;
  		nsapptr_data_t	data_nsapptr;
+ 		sig_data_t	data_sig;
+ 		key_data_t	data_key;
  		px_data_t	data_px;
  		gpos_data_t	data_gpos;
  		aaaa_data_t	data_aaaa;
  		loc_data_t	data_loc;
+ 		nxt_data_t	data_nxt;
+ 		srv_data_t	data_srv;
  		uinfo_data_t	data_uinfo;
  		uid_data_t	data_uid;
  		gid_data_t	data_gid;
***************
*** 241,250 ****
--- 279,292 ----
  #define t_rt		data.data_rt
  #define t_nsap		data.data_nsap
  #define t_nsapptr	data.data_nsapptr
+ #define t_sig		data.data_sig
+ #define t_key		data.data_key
  #define t_px		data.data_px
  #define t_gpos		data.data_gpos
  #define t_aaaa		data.data_aaaa
  #define t_loc		data.data_loc
+ #define t_nxt		data.data_nxt
+ #define t_srv		data.data_srv
  #define t_uinfo		data.data_uinfo
  #define t_uid		data.data_uid
  #define t_gid		data.data_gid
diff --context --recurs m:\bind495t5b/contrib/host/send.c m:\bind495t6b/contrib/host/send.c
*** m:\bind495t5b/contrib/host/send.c	Sat May 11 00:25:51 1996
--- m:\bind495t6b/contrib/host/send.c	Tue Sep 24 22:47:09 1996
***************
*** 18,33 ****
   */
  
  #ifndef lint
! static char Version[] = "@(#)send.c	e07@nikhef.nl (Eric Wassenaar) 960511";
! #endif
  
! #if defined(apollo) && defined(lint)
! #define __attribute(x)
! #endif
! 
! #include <stdio.h>
! #include <errno.h>
! #include <setjmp.h>
  #include <signal.h>
  #include <sys/time.h>
  
--- 18,33 ----
   */
  
  #ifndef lint
! static char Version[] = "@(#)send.c	e07@nikhef.nl (Eric Wassenaar) 960925";
! #endif
  
! #if defined(apollo) && defined(lint)
! #define __attribute(x)
! #endif
! 
! #include <stdio.h>
! #include <errno.h>
! #include <setjmp.h>
  #include <signal.h>
  #include <sys/time.h>
  
***************
*** 58,70 ****
  static struct sockaddr_in from;	/* address of inbound packet */
  static struct sockaddr *from_sa = (struct sockaddr *)&from;
  
- /* extern */
  char *inet_ntoa		PROTO((struct in_addr));
  
- /* send.c */
  #ifdef HOST_RES_SEND
  int res_send		PROTO((CONST qbuf_t *, int, qbuf_t *, int));
  void _res_close		PROTO((void));
  static int send_stream	PROTO((struct sockaddr_in *, qbuf_t *, int, qbuf_t *, int));
  static int send_dgram	PROTO((struct sockaddr_in *, qbuf_t *, int, qbuf_t *, int));
  #endif /*HOST_RES_SEND*/
--- 58,70 ----
  static struct sockaddr_in from;	/* address of inbound packet */
  static struct sockaddr *from_sa = (struct sockaddr *)&from;
  
  char *inet_ntoa		PROTO((struct in_addr));
+ unsigned int alarm	PROTO((unsigned int));
  
  #ifdef HOST_RES_SEND
  int res_send		PROTO((CONST qbuf_t *, int, qbuf_t *, int));
  void _res_close		PROTO((void));
+ static int check_from	PROTO((void));
  static int send_stream	PROTO((struct sockaddr_in *, qbuf_t *, int, qbuf_t *, int));
  static int send_dgram	PROTO((struct sockaddr_in *, qbuf_t *, int, qbuf_t *, int));
  #endif /*HOST_RES_SEND*/
***************
*** 245,250 ****
--- 245,288 ----
  }
  
  /*
+ ** CHECK_FROM -- Make sure the response comes from a known server
+ ** --------------------------------------------------------------
+ **
+ **	Returns:
+ **		Nonzero if the source address is known.
+ **		Zero otherwise.
+ */
+ 
+ static int
+ check_from()
+ {
+ 	struct sockaddr_in *addr;
+ 	register int ns;
+ 
+ 	for (ns = 0; ns < _res.nscount; ns++)
+ 	{
+ 		/* fetch server address */
+ 		addr = &nslist(ns);
+ 
+ 		if (from.sin_family != addr->sin_family)
+ 			continue;
+ 
+ 		if (from.sin_port != addr->sin_port)
+ 			continue;
+ 
+ 		/* this allows a reply from any responding server */
+ 		if (addr->sin_addr.s_addr == INADDR_ANY)
+ 			return(1);
+ 
+ 		if (from.sin_addr.s_addr == addr->sin_addr.s_addr)
+ 			return(1);
+ 	}
+ 
+ 	/* matches none of the known addresses */
+ 	return(0);
+ }
+ 
+ /*
  ** SEND_STREAM -- Query nameserver via virtual circuit
  ** ---------------------------------------------------
  **
***************
*** 422,427 ****
--- 460,478 ----
  		if (bitset(RES_DEBUG, _res.options))
  		{
  			printf("%sold answer:\n", dbprefix);
+ 			pr_query(answer, (n > anslen) ? anslen : n, stdout);
+ 		}
+ 		goto wait;
+ 	}
+ 
+ /*
+  * Make sure it comes from a known server.
+  */
+ 	if (!check_from())
+ 	{
+ 		if (bitset(RES_DEBUG, _res.options))
+ 		{
+ 			printf("%sunknown server %s:\n", dbprefix, inet_ntoa(from.sin_addr));
  			pr_query(answer, (n > anslen) ? anslen : n, stdout);
  		}
  		goto wait;
diff --context --recurs m:\bind495t5b/contrib/host/type.h m:\bind495t6b/contrib/host/type.h
*** m:\bind495t5b/contrib/host/type.h	Wed Apr 17 10:43:18 1996
--- m:\bind495t6b/contrib/host/type.h	Sun Sep 29 18:34:12 1996
***************
*** 1,23 ****
  /*
  ** Various new resource record type and class values.
  **
! **	They belong in <arpa/nameser.h>
! **
! **	@(#)type.h              e07@nikhef.nl (Eric Wassenaar) 960417
! */
  
! /* never used in practice */
  
! #ifndef C_CSNET
! #define C_CSNET		2
  #endif
  
  /* missing in some old versions */
  
  #ifndef C_HS
  #define C_HS		4
  #endif
  
  /* missing in some old versions */
  
  #ifndef T_TXT
--- 1,57 ----
  /*
  ** Various new resource record type and class values.
  **
! **	These might be missing in the default files on old platforms.
! **	Also included are several definitions that might have been
! **	omitted because they are obsolete, or are otherwise missing.
! **
! **	They belong in <arpa/nameser.h>
! **
! **	@(#)type.h              e07@nikhef.nl (Eric Wassenaar) 960929
! */
  
! /* never used in practice */
  
! #ifndef C_CSNET
! #define C_CSNET		2
  #endif
  
+ /* missing on some platforms */
+ 
+ #ifndef C_CHAOS
+ #define C_CHAOS		3
+ #endif
+ 
  /* missing in some old versions */
  
  #ifndef C_HS
  #define C_HS		4
  #endif
  
+ /* obsolete/deprecated types already missing on some platforms */
+ 
+ #ifndef T_MD
+ #define T_MD		3
+ #endif
+ #ifndef T_MF
+ #define T_MF		4
+ #endif
+ #ifndef T_MB
+ #define T_MB		7
+ #endif
+ #ifndef T_MG
+ #define T_MG		8
+ #endif
+ #ifndef T_MR
+ #define T_MR		9
+ #endif
+ #ifndef T_NULL
+ #define T_NULL		10
+ #endif
+ #ifndef T_MINFO
+ #define T_MINFO		14
+ #endif
+ 
  /* missing in some old versions */
  
  #ifndef T_TXT
***************
*** 29,47 ****
  #ifndef T_RP
  #define T_RP		17
  #endif
- 
  #ifndef T_AFSDB
  #define T_AFSDB		18
  #endif
- 
  #ifndef T_X25
  #define T_X25		19
  #endif
- 
  #ifndef T_ISDN
  #define T_ISDN		20
  #endif
- 
  #ifndef T_RT
  #define T_RT		21
  #endif
--- 63,77 ----
***************
*** 51,67 ****
  #ifndef T_NSAP
  #define T_NSAP		22
  #endif
- 
  #ifndef T_NSAPPTR
  #define T_NSAPPTR	23
  #endif
  
! /* reserved per RFC 1700 */
  
  #ifndef T_SIG
  #define T_SIG		24
  #endif
- 
  #ifndef T_KEY
  #define T_KEY		25
  #endif
--- 81,95 ----
  #ifndef T_NSAP
  #define T_NSAP		22
  #endif
  #ifndef T_NSAPPTR
  #define T_NSAPPTR	23
  #endif
  
! /* reserved per RFC 1700, defined per RFC XXXX */
  
  #ifndef T_SIG
  #define T_SIG		24
  #endif
  #ifndef T_KEY
  #define T_KEY		25
  #endif
***************
*** 90,106 ****
--- 118,170 ----
  #define T_LOC		29
  #endif
  
+ /* defined per RFC XXXX */
+ 
+ #ifndef T_NXT
+ #define T_NXT		30
+ #endif
+ 
+ /* defined per RFC XXXX */
+ 
+ #ifndef T_SRV
+ #define T_SRV		33
+ #endif
+ 
  /* nonstandard types are threatened to become extinct */
  
  #ifndef T_UINFO
  #define T_UINFO		100
  #endif
+ 
  #ifndef T_UID
  #define T_UID		101
  #endif
+ 
  #ifndef T_GID
  #define T_GID		102
  #endif
+ 
  #ifndef T_UNSPEC
  #define T_UNSPEC	103
+ #endif
+ 
+ /* defined per RFC 1995 */
+ 
+ #ifndef T_IXFR
+ #define T_IXFR		251
+ #endif
+ 
+ /* really missing on some weird platforms, can you believe it */
+ 
+ #ifndef T_AXFR
+ #define T_AXFR		252
+ #endif
+ 
+ /* obsolete/deprecated types already missing on some platforms */
+ 
+ #ifndef T_MAILB
+ #define T_MAILB		253
+ #endif
+ #ifndef T_MAILA
+ #define T_MAILA		254
  #endif
diff --context --recurs m:\bind495t5b/contrib/host/vers.c m:\bind495t6b/contrib/host/vers.c
*** m:\bind495t5b/contrib/host/vers.c	Sat Aug 24 05:18:23 1996
--- m:\bind495t6b/contrib/host/vers.c	Sun Sep 29 18:23:43 1996
***************
*** 1,8 ****
  #ifndef lint
! static char Version[] = "@(#)vers.c	e07@nikhef.nl (Eric Wassenaar) 960808";
! #endif
! 
! char *version = "960808";
  
  #if defined(apollo)
  int h_errno = 0;
--- 1,8 ----
  #ifndef lint
! static char Version[] = "@(#)vers.c	e07@nikhef.nl (Eric Wassenaar) 960929";
! #endif
! 
! char *version = "960929";
  
  #if defined(apollo)
  int h_errno = 0;
Only in m:\bind495t6b/contrib: host.tar.Z
diff --context --recurs m:\bind495t5b/doc/bog/file.psf m:\bind495t6b/doc/bog/file.psf
*** m:\bind495t5b/doc/bog/file.psf	Sat Sep 28 06:52:57 1996
--- m:\bind495t6b/doc/bog/file.psf	Tue Oct 08 04:39:06 1996
***************
*** 1,6 ****
  %!PS-Adobe-3.0
  %%Creator: groff version 1.10
! %%CreationDate: Fri Sep 27 23:52:57 1996
  %%DocumentNeededResources: font Times-Bold
  %%+ font Times-Italic
  %%+ font Times-Roman
--- 1,6 ----
  %!PS-Adobe-3.0
  %%Creator: groff version 1.10
! %%CreationDate: Mon Oct  7 21:39:06 1996
  %%DocumentNeededResources: font Times-Bold
  %%+ font Times-Italic
  %%+ font Times-Roman
diff --context --recurs m:\bind495t5b/include/arpa/nameser.h m:\bind495t6b/include/arpa/nameser.h
*** m:\bind495t5b/include/arpa/nameser.h	Sat Sep 28 15:24:09 1996
--- m:\bind495t6b/include/arpa/nameser.h	Tue Oct 08 12:55:49 1996
***************
*** 77,92 ****
  
  /*
   *      @(#)nameser.h	8.1 (Berkeley) 6/2/93
!  *	$Id: nameser.h,v 8.10 1996/09/28 06:51:04 vixie Exp $
   */
  
! #ifndef _NAMESER_H_
! #define _NAMESER_H_
  
! #include <sys/param.h>
! #if (!defined(BSD)) || (BSD < 199306)
! # include <sys/bitypes.h>
! #else
  # include <sys/types.h>
  #endif
  #include <sys/cdefs.h>
--- 77,92 ----
  
  /*
   *      @(#)nameser.h	8.1 (Berkeley) 6/2/93
!  *	$Id: nameser.h,v 8.11 1996/10/08 04:51:02 vixie Exp $
   */
  
! #ifndef _NAMESER_H_
! #define _NAMESER_H_
  
! #include <sys/param.h>
! #if (!defined(BSD)) || (BSD < 199306)
! # include <sys/bitypes.h>
! #else
  # include <sys/types.h>
  #endif
  #include <sys/cdefs.h>
***************
*** 180,185 ****
--- 180,186 ----
  #define T_NIMLOC	32		/* Nimrod locator */
  #define T_SRV		33		/* Server selection */
  #define T_ATMA		34		/* ATM Address */
+ #define T_NAPTR		35		/* Naming Authority PoinTeR */
  	/* non standard */
  #define T_UINFO		100		/* user (finger) information */
  #define T_UID		101		/* user ID */
diff --context --recurs m:\bind495t5b/named/db_dump.c m:\bind495t6b/named/db_dump.c
*** m:\bind495t5b/named/db_dump.c	Sat Sep 28 15:24:09 1996
--- m:\bind495t6b/named/db_dump.c	Tue Oct 08 12:55:49 1996
***************
*** 1,15 ****
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)db_dump.c	4.33 (Berkeley) 3/3/91";
! static char rcsid[] = "$Id: db_dump.c,v 8.18 1996/08/27 17:53:21 vixie Exp $";
! #endif /* not lint */
  
  /*
!  * ++Copyright++ 1986, 1988, 1990
   * -
!  * Copyright (c) 1986, 1988, 1990
!  *    The Regents of the University of California.  All rights reserved.
   * 
!  * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
--- 1,15 ----
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)db_dump.c	4.33 (Berkeley) 3/3/91";
! static char rcsid[] = "$Id: db_dump.c,v 8.19 1996/10/08 04:51:03 vixie Exp $";
! #endif /* not lint */
  
  /*
!  * ++Copyright++ 1986, 1988, 1990
   * -
!  * Copyright (c) 1986, 1988, 1990
!  *    The Regents of the University of California.  All rights reserved.
   * 
!  * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
***************
*** 587,592 ****
--- 587,619 ----
  				break;
  			}
  #endif /* LOC_RR */
+ 
+ 			case T_NAPTR: {
+ 				u_int order, preference;
+ 
+ 				GETSHORT(order, cp);
+ 				fprintf(fp, "%lu", (u_long)order);
+  
+ 				GETSHORT(preference, cp);
+ 				fprintf(fp, "%lu", (u_long)preference);
+ 
+ 				if (n = *cp++) {
+ 					fprintf(fp, "\"%.*s\"", (int)n, cp);
+ 					cp += n;
+ 				}
+ 				if (n = *cp++) {
+ 					fprintf(fp, "\"%.*s\"", (int)n, cp);
+ 					cp += n;
+ 				}
+ 				if (n = *cp++) {
+ 					fprintf(fp, " \"%.*s\"", (int)n, cp);
+ 					cp += n;
+ 				}
+ 				fprintf(fp, " %s.", cp);
+ 
+ 				break;
+ 			}
+ 
  			case T_SRV: {
  				u_int priority, weight, port;
  
diff --context --recurs m:\bind495t5b/named/db_load.c m:\bind495t6b/named/db_load.c
*** m:\bind495t5b/named/db_load.c	Sat Sep 28 15:24:09 1996
--- m:\bind495t6b/named/db_load.c	Tue Oct 08 12:55:49 1996
***************
*** 1,15 ****
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)db_load.c	4.38 (Berkeley) 3/2/91";
! static char rcsid[] = "$Id: db_load.c,v 8.28 1996/09/28 06:51:05 vixie Exp $";
! #endif /* not lint */
  
  /*
!  * ++Copyright++ 1986, 1988, 1990
   * -
!  * Copyright (c) 1986, 1988, 1990
!  *    The Regents of the University of California.  All rights reserved.
   * 
!  * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
--- 1,15 ----
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)db_load.c	4.38 (Berkeley) 3/2/91";
! static char rcsid[] = "$Id: db_load.c,v 8.29 1996/10/08 04:51:03 vixie Exp $";
! #endif /* not lint */
  
  /*
!  * ++Copyright++ 1986, 1988, 1990
   * -
!  * Copyright (c) 1986, 1988, 1990
!  *    The Regents of the University of California.  All rights reserved.
   * 
!  * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
***************
*** 518,529 ****
  				if (multiline) {
  					if (getnonblank(fp, filename) != ')')
  						goto err;
  				}
                                  read_soa++;
! 				if (zp->z_type != Z_PRIMARY) {
! 					endline(fp);
  					break;
- 				}
  				/* sanity checks PRIMARY ONLY */
  				/*
  				 * sanity: give enough time for the
--- 518,528 ----
  				if (multiline) {
  					if (getnonblank(fp, filename) != ')')
  						goto err;
+ 					endline(fp);
  				}
                                  read_soa++;
! 				if (zp->z_type != Z_PRIMARY)
  					break;
  				/* sanity checks PRIMARY ONLY */
  				/*
  				 * sanity: give enough time for the
***************
*** 531,544 ****
  				 */
  				if (zp->z_expire < 
  					(zp->z_refresh+zp->z_retry)) {
! 				    syslog(LOG_ERR,
      "%s: WARNING SOA expire value is less then SOA refresh + retry (%lu < %lu + %lu)",
  				    filename, zp->z_expire, zp->z_refresh,
  				    zp->z_retry);
  				}
  				/* BIND specific */
  				if (zp->z_expire < maint_interval) {
! 				    syslog(LOG_ERR,
      "%s: WARNING SOA expire value is less then maintainance interval (%lu < %lu)",
  				    filename, zp->z_expire, maint_interval);
  				}
--- 530,543 ----
  				 */
  				if (zp->z_expire < 
  					(zp->z_refresh+zp->z_retry)) {
! 				    syslog(LOG_NOTICE,
      "%s: WARNING SOA expire value is less then SOA refresh + retry (%lu < %lu + %lu)",
  				    filename, zp->z_expire, zp->z_refresh,
  				    zp->z_retry);
  				}
  				/* BIND specific */
  				if (zp->z_expire < maint_interval) {
! 				    syslog(LOG_NOTICE,
      "%s: WARNING SOA expire value is less then maintainance interval (%lu < %lu)",
  				    filename, zp->z_expire, maint_interval);
  				}
***************
*** 590,596 ****
      "%s: WARNING SOA refresh value is less than 2 * retry (%lu < %lu * 2)",
  				    filename, zp->z_refresh, zp->z_retry);
  				}
- 				endline(fp);
  				break;
  
  			case T_UID:
--- 589,594 ----
***************
*** 659,664 ****
--- 657,718 ----
  					    (char *)buf);
  				n = strlen((char *)data) + 1;
  				break;
+ 
+ 			case T_NAPTR:
+ 			/* Order Preference Flags Service Replacement Regexp */
+ 				n = 0;
+ 				cp = buf;
+ 				/* Order */
+ 				while (isdigit(*cp))
+ 					n = n * 10 + (*cp++ - '0');
+ 				/* catch bad values */
+ 				if ((cp == buf) || (n > 65535))
+ 					goto err;
+ 				cp = data;
+ 				PUTSHORT((u_int16_t)n, cp);
+ 				/* Preference */
+ 				n = getnum(fp, filename, GETNUM_NONE);
+ 				if (getnum_error || n > 65536)
+ 					goto err;
+ 				PUTSHORT((u_int16_t)n, cp);
+ 
+                                 /* Flags */
+                                 if (!getword((char *)buf, sizeof(buf), fp, 0))
+                                         goto err;
+                                 n = strlen((char *)buf);
+                                 *cp++ = n;
+                                 bcopy(buf, (char *)cp, (int)n);
+                                 cp += n;
+  
+                                 /* Service Classes */
+                                 if (!getword((char *)buf, sizeof(buf), fp, 0))
+                                         goto err;
+                                 n = strlen((char *)buf);
+                                 *cp++ = n;
+                                 bcopy(buf, (char *)cp, (int)n);
+                                 cp += n;
+  
+                                 /* Pattern */
+                                 if (!getword((char *)buf, sizeof(buf), fp, 0))
+                                         goto err;
+                                 n = strlen((char *)buf);
+                                 *cp++ = n;
+                                 bcopy(buf, (char *)cp, (int)n);
+                                 cp += n;
+ 
+ 				/* Replacement */
+ 				if (!getword((char *)buf, sizeof(buf), fp, 1))
+ 					goto err;
+ 				(void) strcpy((char *)cp, (char *)buf);
+ 				context = hostname_ctx;
+ 				MAKENAME_OK(cp);
+ 				/* advance pointer to end of data */
+ 				cp += strlen((char *)cp) +1;
+ 
+ 				/* now save length */
+ 				n = (cp - data);
+ 				break;
+ 
  			case T_MX:
  			case T_AFSDB:
  			case T_RT:
diff --context --recurs m:\bind495t5b/named/db_update.c m:\bind495t6b/named/db_update.c
*** m:\bind495t5b/named/db_update.c	Sat Sep 28 15:24:09 1996
--- m:\bind495t6b/named/db_update.c	Tue Oct 08 12:55:49 1996
***************
*** 1,15 ****
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)db_update.c	4.28 (Berkeley) 3/21/91";
! static char rcsid[] = "$Id: db_update.c,v 8.17 1996/09/22 00:13:10 vixie Exp $";
! #endif /* not lint */
  
  /*
!  * ++Copyright++ 1986, 1990
   * -
!  * Copyright (c) 1986, 1990
!  *    The Regents of the University of California.  All rights reserved.
   * 
!  * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
--- 1,15 ----
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)db_update.c	4.28 (Berkeley) 3/21/91";
! static char rcsid[] = "$Id: db_update.c,v 8.18 1996/10/08 04:51:03 vixie Exp $";
! #endif /* not lint */
  
  /*
!  * ++Copyright++ 1986, 1990
   * -
!  * Copyright (c) 1986, 1990
!  *    The Regents of the University of California.  All rights reserved.
   * 
!  * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
***************
*** 734,739 ****
--- 734,783 ----
  		cp2 += strlen((char *)cp2) + 1;
  		return (bcmp(cp1, cp2, INT32SZ * 5));
  	
+ 	case T_NAPTR: {
+ 		int t1,t2;
+ 
+ 		if (dp1->d_size != dp2->d_size)
+ 			return (1);
+ 		cp1 = dp1->d_data;
+ 		cp2 = dp2->d_data;
+ 
+ 		/* Order */
+ 		if (*cp1++ != *cp2++ || *cp1++ != *cp2++)	
+ 			return (1);
+ 
+ 		/* Preference */
+ 		if (*cp1++ != *cp2++ || *cp1++ != *cp2++)	
+ 			return (1);
+ 
+ 		/* Flags */
+ 		t1 = *cp1++; t2 = *cp2++;
+ 		if (t1 != t2 || bcmp(cp1, cp2, t1))
+ 			return (1);
+ 		cp1 += t1; cp2 += t2;
+ 
+ 		/* Services */
+ 		t1 = *cp1++; t2 = *cp2++;
+ 		if (t1 != t2 || bcmp(cp1, cp2, t1))
+ 			return (1);
+ 		cp1 += t1; cp2 += t2;
+ 
+ 		/* Regexp */
+ 		t1 = *cp1++; t2 = *cp2++;
+ 		if (t1 != t2 || bcmp(cp1, cp2, t1))
+ 			return (1);
+ 		cp1 += t1; cp2 += t2;
+ 
+ 		/* Replacement */
+ 		t1 = strlen((char *)cp1); t2 = strlen((char *)cp2);
+ 		if (t1 != t2 || bcmp(cp1, cp2, t1))
+ 			return (1);
+ 		cp1 += t1 + 1; cp2 += t2 + 1;
+ 
+ 		/* they all checked out! */
+ 		return (0);
+ 	    }
+ 
  	case T_MX:
  	case T_AFSDB:
  	case T_RT:
diff --context --recurs m:\bind495t5b/named/named-xfer.c m:\bind495t6b/named/named-xfer.c
*** m:\bind495t5b/named/named-xfer.c	Sat Sep 28 15:24:09 1996
--- m:\bind495t6b/named/named-xfer.c	Tue Oct 08 12:55:49 1996
***************
*** 92,107 ****
  
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)named-xfer.c	4.18 (Berkeley) 3/7/91";
! static char rcsid[] = "$Id: named-xfer.c,v 8.18 1996/09/22 00:13:10 vixie Exp $";
! #endif /* not lint */
  
! #include <sys/types.h>
! #include <sys/param.h>
! #include <sys/file.h>
! #include <sys/stat.h>
! #include <sys/socket.h>
  
! #include <netinet/in.h>
  #if defined(__osf__)
  # include <sys/mbuf.h>
  # include <net/route.h>
--- 92,107 ----
  
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)named-xfer.c	4.18 (Berkeley) 3/7/91";
! static char rcsid[] = "$Id: named-xfer.c,v 8.19 1996/10/08 04:51:03 vixie Exp $";
! #endif /* not lint */
  
! #include <sys/types.h>
! #include <sys/param.h>
! #include <sys/file.h>
! #include <sys/stat.h>
! #include <sys/socket.h>
  
! #include <netinet/in.h>
  #if defined(__osf__)
  # include <sys/mbuf.h>
  # include <net/route.h>
***************
*** 1310,1315 ****
--- 1310,1353 ----
  		cp1 = (u_char *)data;
  		break;
  
+ 	case T_NAPTR:
+ 		/* Grab weight and port. */
+ 		bcopy(cp, data, INT16SZ*2);
+ 		cp1 = data + INT16SZ*2;
+ 		cp += INT16SZ*2;
+  
+ 		/* Flags */
+ 		n = *cp++;
+ 		*cp1++ = n;
+ 		bcopy(cp, cp1, n);
+ 		cp += n; cp1 += n;
+  
+ 		/* Service */
+ 		n = *cp++;
+ 		*cp1++ = n;
+ 		bcopy(cp, cp1, n);
+ 		cp += n; cp1 += n;
+  
+ 		/* Regexp */
+ 		n = *cp++;
+ 		*cp1++ = n;
+ 		bcopy(cp, cp1, n);
+ 		cp += n; cp1 += n;
+  
+ 		/* Replacement */
+ 		n1 = (u_char *)data - cp1;
+ 		n = dn_expand(msg, msg + msglen, cp, (char *)cp1, n1);
+ 		if (n < 0)
+ 			return (-1);
+ 		cp += n;
+  
+ 		/* compute end of data */
+ 		cp1 += strlen((char *)cp1) + 1;
+ 		/* compute size of data */
+ 		n = cp1 - (u_char *)data;
+ 		cp1 = (u_char *)data;
+ 		break;
+ 
  	case T_MX:
  	case T_AFSDB:
  	case T_RT:
***************
*** 1649,1655 ****
  
  		fprintf(dbfp, "%s\n", inet_ntop(AF_INET6, cp, t, sizeof t));
  		break;
! 	}
  	case T_UINFO:
  		(void) fprintf(dbfp, "\"%s\"\n", cp);
  		break;
--- 1687,1693 ----
  
  		fprintf(dbfp, "%s\n", inet_ntop(AF_INET6, cp, t, sizeof t));
  		break;
! 	    }
  	case T_UINFO:
  		(void) fprintf(dbfp, "\"%s\"\n", cp);
  		break;
***************
*** 1660,1668 ****
  
  		(void) fprintf(dbfp, "%s\n", loc_ntoa(cp, t));
  		break;
! 	}
  #endif /* LOC_RR */
  
  	case T_SRV: {
  		u_int priority, weight, port;
  
--- 1698,1740 ----
  
  		(void) fprintf(dbfp, "%s\n", loc_ntoa(cp, t));
  		break;
! 	    }
  #endif /* LOC_RR */
  
+ 	case T_NAPTR: {
+                 u_int order, preference;
+ 
+ 		/* Order */
+ 		GETSHORT(order, cp);
+ 		fprintf(fp, "%lu", (u_long)order);
+  
+ 		/* Preference */
+ 		GETSHORT(preference, cp);
+ 		fprintf(fp, " %lu", (u_long)preference);
+  
+ 		/* Flags */
+ 		if (n = *cp++) {
+ 			fprintf(fp, " \"%.*s\"", (int)n, cp);
+ 			cp += n;
+ 		}
+ 
+ 		/* Service */
+ 		if (n = *cp++) {
+ 			fprintf(fp, " \"%.*s\"", (int)n, cp);
+ 			cp += n;
+ 		}
+ 
+ 		/* Regexp */
+ 		if (n = *cp++) {
+ 			fprintf(fp, " \"%.*s\"", (int)n, cp);
+ 			cp += n;
+ 		}
+ 
+ 		/* Replacement */
+ 		fprintf(fp, " %s.\n", cp);
+  
+ 		break;
+ 	    }
  	case T_SRV: {
  		u_int priority, weight, port;
  
***************
*** 1672,1678 ****
  		fprintf(dbfp, "\t%u %u %u %s.\n",
  			priority, weight, port, cp);
  		break;
! 	}
  
  	case T_UID:
  	case T_GID:
--- 1744,1750 ----
  		fprintf(dbfp, "\t%u %u %u %s.\n",
  			priority, weight, port, cp);
  		break;
! 	    }
  
  	case T_UID:
  	case T_GID:
diff --context --recurs m:\bind495t5b/named/ns_forw.c m:\bind495t6b/named/ns_forw.c
*** m:\bind495t5b/named/ns_forw.c	Sat Sep 28 15:24:09 1996
--- m:\bind495t6b/named/ns_forw.c	Tue Oct 08 12:55:49 1996
***************
*** 1,15 ****
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)ns_forw.c	4.32 (Berkeley) 3/3/91";
! static char rcsid[] = "$Id: ns_forw.c,v 8.17 1996/09/22 00:13:10 vixie Exp $";
! #endif /* not lint */
  
  /*
!  * ++Copyright++ 1986
   * -
!  * Copyright (c) 1986
!  *    The Regents of the University of California.  All rights reserved.
   * 
!  * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
--- 1,15 ----
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)ns_forw.c	4.32 (Berkeley) 3/3/91";
! static char rcsid[] = "$Id: ns_forw.c,v 8.18 1996/10/08 04:51:03 vixie Exp $";
! #endif /* not lint */
  
  /*
!  * ++Copyright++ 1986
   * -
!  * Copyright (c) 1986
!  *    The Regents of the University of California.  All rights reserved.
   * 
!  * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
***************
*** 964,969 ****
--- 964,970 ----
  	while (nsqhead)
  		qremove(nsqhead);
  	nsqhead = QINFO_NULL;
+ 	priming = 0;
  }
  
  void
diff --context --recurs m:\bind495t5b/named/ns_main.c m:\bind495t6b/named/ns_main.c
*** m:\bind495t5b/named/ns_main.c	Sat Sep 28 15:24:09 1996
--- m:\bind495t6b/named/ns_main.c	Tue Oct 08 12:55:49 1996
***************
*** 1,15 ****
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)ns_main.c	4.55 (Berkeley) 7/1/91";
! static char rcsid[] = "$Id: ns_main.c,v 8.21 1996/09/28 06:51:05 vixie Exp $";
  #endif /* not lint */
  
  /*
!  * ++Copyright++ 1986, 1989, 1990
   * -
!  * Copyright (c) 1986, 1989, 1990
!  *    The Regents of the University of California.  All rights reserved.
   * 
!  * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
--- 1,15 ----
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)ns_main.c	4.55 (Berkeley) 7/1/91";
! static char rcsid[] = "$Id: ns_main.c,v 8.22 1996/10/08 04:51:03 vixie Exp $";
  #endif /* not lint */
  
  /*
!  * ++Copyright++ 1986, 1989, 1990
   * -
!  * Copyright (c) 1986, 1989, 1990
!  *    The Regents of the University of California.  All rights reserved.
   * 
!  * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
***************
*** 410,415 ****
--- 410,416 ----
  	setsignal(SIGIOT, -1, setstatsflg);
  	setsignal(SIGUSR1, -1, setIncrDbgFlg);
  	setsignal(SIGUSR2, -1, setNoDbgFlg);
+ 	setsignal(SIGHUP, -1, onhup);
  
  #if defined(SIGWINCH) && defined(QRYLOG)
  	setsignal(SIGWINCH, -1, setQrylogFlg);
***************
*** 442,448 ****
  	setsignal(SIGALRM, SIGCHLD, maint_alarm);
  	setsignal(SIGCHLD, SIGALRM, reapchild);
  	setsignal(SIGPIPE, -1, (SIG_FN (*)())SIG_IGN);
- 	setsignal(SIGHUP, -1, onhup);
  
  #if defined(SIGXFSZ)
  	/* Wierd DEC Hesiodism, harmless. */
--- 443,448 ----
***************
*** 785,793 ****
  			sp->s_bufp = (u_char *)&sp->s_tempsize;
  			FD_SET(rfd, &mask);
  			FD_SET(rfd, &tmpmask);
! 			syslog(LOG_DEBUG,
! 			       "IP/TCP connection from %s (fd %d)\n",
! 			       sin_ntoa(&sp->s_from), rfd);
  		}
  		if (streamq)
  			dprintf(3, (ddt, "streamq = 0x%lx\n",
--- 785,796 ----
  			sp->s_bufp = (u_char *)&sp->s_tempsize;
  			FD_SET(rfd, &mask);
  			FD_SET(rfd, &tmpmask);
! #ifdef DEBUG
! 			if (debug)
! 				syslog(LOG_DEBUG,
! 				       "IP/TCP connection from %s (fd %d)\n",
! 				       sin_ntoa(&sp->s_from), rfd);
! #endif
  		}
  		if (streamq)
  			dprintf(3, (ddt, "streamq = 0x%lx\n",
diff --context --recurs m:\bind495t5b/named/ns_req.c m:\bind495t6b/named/ns_req.c
*** m:\bind495t5b/named/ns_req.c	Sat Sep 28 15:24:09 1996
--- m:\bind495t6b/named/ns_req.c	Tue Oct 08 12:55:49 1996
***************
*** 1,15 ****
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)ns_req.c	4.47 (Berkeley) 7/1/91";
! static char rcsid[] = "$Id: ns_req.c,v 8.26 1996/09/28 06:51:05 vixie Exp $";
! #endif /* not lint */
  
  /*
!  * ++Copyright++ 1986, 1988, 1990
   * -
!  * Copyright (c) 1986, 1988, 1990
!  *    The Regents of the University of California.  All rights reserved.
   * 
!  * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
--- 1,15 ----
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)ns_req.c	4.47 (Berkeley) 7/1/91";
! static char rcsid[] = "$Id: ns_req.c,v 8.27 1996/10/08 04:51:03 vixie Exp $";
! #endif /* not lint */
  
  /*
!  * ++Copyright++ 1986, 1988, 1990
   * -
!  * Copyright (c) 1986, 1988, 1990
!  *    The Regents of the University of California.  All rights reserved.
   * 
!  * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
***************
*** 1320,1325 ****
--- 1320,1389 ----
  		}
  		n = (u_int16_t)((cp - sp) - INT16SZ);
  		PUTSHORT((u_int16_t)n, sp);
+ 		break;
+ 
+ 	case T_NAPTR:
+ 		/* cp1 == our data/ cp == data of RR */
+ 		cp1 = dp->d_data;
+ 
+  		if ((buflen -= INT16SZ) < 0)
+ 			return (-1);
+ 
+  		/* copy order */
+  		bcopy(cp1, cp, INT16SZ);
+  		cp += INT16SZ;
+  		cp1 += INT16SZ;
+ 		n = (u_int16_t)((cp - sp) - INT16SZ);
+ 		dprintf(1, (ddt, "current size n = %u\n", n));
+ 
+ 		/* copy preference */
+ 		bcopy(cp1, cp, INT16SZ);
+ 		cp += INT16SZ;
+ 		cp1 += INT16SZ;
+ 		n = (u_int16_t)((cp - sp) - INT16SZ);
+ 		dprintf(1, (ddt, "current size n = %u\n", n));
+ 
+ 		/* Flags */
+ 		n = *cp1++;
+ 		dprintf(1, (ddt, "size of n at flags = %d\n", n));
+ 		*cp++ = n;
+ 		bcopy(cp1,cp,n);
+ 		cp += n;
+ 		cp1 += n;
+ 		n = (u_int16_t)((cp - sp) - INT16SZ);
+ 		dprintf(1, (ddt, "current size n = %u\n", n));
+ 		
+ 		/* Service */
+ 		n = *cp1++;
+ 		*cp++ = n;
+ 		bcopy(cp1,cp,n);
+ 		cp += n;
+ 		cp1 += n;
+ 		n = (u_int16_t)((cp - sp) - INT16SZ);
+ 		dprintf(1, (ddt, "current size n = %u\n", n));
+ 
+ 		/* Regexp */
+ 		n = *cp1++;
+ 		*cp++ = n;
+ 		bcopy(cp1,cp,n);
+ 		cp += n;
+ 		cp1 += n;
+ 		n = (u_int16_t)((cp - sp) - INT16SZ);
+ 		dprintf(1, (ddt, "current size n = %u\n", n));
+ 
+ 		/* Replacement */
+ 		dprintf(1, (ddt, "Replacement = %s\n", cp1));
+ 		n = dn_comp((char *)cp1, cp, buflen, dnptrs, edp);
+ 		dprintf(1, (ddt, "dn_comp's n = %u\n", n));
+ 		if (n < 0)
+ 			return (-1);
+ 		cp += n;
+ 
+ 		/* save data length */
+ 		n = (u_int16_t)((cp - sp) - INT16SZ);
+ 		dprintf(1, (ddt, "saved size n = %u\n", n));
+ 		PUTSHORT((u_int16_t)n, sp);
+ 
  		break;
  
  	case T_MX:
diff --context --recurs m:\bind495t5b/named/ns_resp.c m:\bind495t6b/named/ns_resp.c
*** m:\bind495t5b/named/ns_resp.c	Sat Sep 28 15:24:09 1996
--- m:\bind495t6b/named/ns_resp.c	Tue Oct 08 12:55:49 1996
***************
*** 1,15 ****
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)ns_resp.c	4.65 (Berkeley) 3/3/91";
! static char rcsid[] = "$Id: ns_resp.c,v 8.34 1996/09/28 06:51:05 vixie Exp $";
! #endif /* not lint */
  
  /*
!  * ++Copyright++ 1986, 1988, 1990
   * -
!  * Copyright (c) 1986, 1988, 1990
!  *    The Regents of the University of California.  All rights reserved.
   * 
!  * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
--- 1,15 ----
  #if !defined(lint) && !defined(SABER)
  static char sccsid[] = "@(#)ns_resp.c	4.65 (Berkeley) 3/3/91";
! static char rcsid[] = "$Id: ns_resp.c,v 8.35 1996/10/08 04:51:03 vixie Exp $";
! #endif /* not lint */
  
  /*
!  * ++Copyright++ 1986, 1988, 1990
   * -
!  * Copyright (c) 1986, 1988, 1990
!  *    The Regents of the University of California.  All rights reserved.
   * 
!  * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
***************
*** 782,787 ****
--- 782,788 ----
  			if (strcasecmp(name, aname) != 0) {
  				syslog(LOG_DEBUG, "wrong ans. name (%s != %s)",
  				       name, aname);
+ 				db_free(dp);
  				continue;
  			}
  			if (type == T_CNAME &&
***************
*** 800,807 ****
  		} else {
  			/* After answer section. */
  			if (lastwascname) {
! 				syslog(LOG_DEBUG, "dangling cname (%s)",
! 				       aname);
  				break;
  			}
  			if (i < ancount + aucount && type == T_NS) {
--- 801,807 ----
  		} else {
  			/* After answer section. */
  			if (lastwascname) {
! 				db_free(dp);
  				break;
  			}
  			if (i < ancount + aucount && type == T_NS) {
***************
*** 812,817 ****
--- 812,818 ----
  					syslog(LOG_DEBUG,
  					       "bad referral (%s !< %s)",
  					       name, qp->q_domain);
+ 					db_free(dp);
  					continue;
  				}
  				nscount++;
***************
*** 829,839 ****
  				free(flushset[i].fs_name);
  		free((char*)flushset);
  	}
! 	if (lastwascname) {
! 		syslog(LOG_DEBUG, "dangling cname (%s)", aname);
! 		formerrmsg = danglingCname;
! 		goto formerr;
! 	}
  
  	if (cp > eom) {
  		formerrmsg = outofDataAFinal;
--- 830,837 ----
  				free(flushset[i].fs_name);
  		free((char*)flushset);
  	}
! 	if (lastwascname)
! 		syslog(LOG_DEBUG, "%s (%s)", danglingCname, aname);
  
  	if (cp > eom) {
  		formerrmsg = outofDataAFinal;
***************
*** 1410,1415 ****
--- 1408,1458 ----
  		cp1 = data;
  		break;
  
+ 	case T_NAPTR:
+ 		/* Grab weight and port. */
+ 		bcopy(cp, data, INT16SZ*2);
+ 		cp1 = data + INT16SZ*2;
+ 		cp += INT16SZ*2;
+ 
+ 		/* Flags */
+ 		n = *cp++;
+ 		*cp1++ = n;
+ 		bcopy(cp, cp1, n);
+ 		cp += n; cp1 += n;
+ 
+ 		/* Service */
+ 		n = *cp++;
+ 		*cp1++ = n;
+ 		bcopy(cp, cp1, n);
+ 		cp += n; cp1 += n;
+ 
+ 		/* Regexp */
+ 		n = *cp++;
+ 		*cp1++ = n;
+ 		bcopy(cp, cp1, n);
+ 		cp += n; cp1 += n;
+ 
+ 		/* Replacement */
+ 		n = dn_expand(msg, msg + msglen, cp, (char *)cp1,
+ 			      sizeof data - (cp1 - data));
+ 		if (n < 0) {
+ 			hp->rcode = FORMERR;
+ 			return (-1);
+ 		}
+ 		if (!ns_nameok((char *)cp1, class, response_trans,
+ 			       hostname_ctx)) {
+ 			hp->rcode = FORMERR;
+ 			return (-1);
+ 		}
+ 		cp += n;
+ 
+ 		/* compute end of data */
+ 		cp1 += strlen((char *)cp1) + 1;
+ 		/* compute size of data */
+ 		n = cp1 - data;
+ 		cp1 = data;
+ 		break;
+ 
  	case T_MX:
  	case T_AFSDB:
  	case T_RT:
***************
*** 2164,2171 ****
--- 2207,2216 ----
  		for (dp = np->n_data; dp != NULL; dp = dp->d_next) {
  			int cnames = 0;
  
+ #ifdef NCACHE
  			if (dp->d_rcode)
  				continue;
+ #endif
  			if (dp->d_type != T_NS)
  				continue;
  
***************
*** 2189,2196 ****
--- 2234,2243 ----
  			for (tdp = tnp->n_data;
  			     tdp != NULL;
  			     tdp = tdp->d_next) {
+ #ifdef NCACHE
  				if (tdp->d_rcode)
  					continue;
+ #endif
  				if (tdp->d_type == T_CNAME)
  					cnames++;
  				if (tdp->d_type != T_A ||
diff --context --recurs m:\bind495t5b/res/res_comp.c m:\bind495t6b/res/res_comp.c
*** m:\bind495t5b/res/res_comp.c	Sat Sep 28 15:24:09 1996
--- m:\bind495t6b/res/res_comp.c	Tue Oct 08 12:55:49 1996
***************
*** 55,70 ****
  
  #if defined(LIBC_SCCS) && !defined(lint)
  static char sccsid[] = "@(#)res_comp.c	8.1 (Berkeley) 6/4/93";
! static char rcsid[] = "$Id: res_comp.c,v 8.9 1996/09/22 00:13:28 vixie Exp $";
! #endif /* LIBC_SCCS and not lint */
  
! #include <sys/types.h>
! #include <sys/param.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
  
! #include <stdio.h>
! #include <resolv.h>
  #include <ctype.h>
  
  #if defined(BSD) && (BSD >= 199103)
--- 55,70 ----
  
  #if defined(LIBC_SCCS) && !defined(lint)
  static char sccsid[] = "@(#)res_comp.c	8.1 (Berkeley) 6/4/93";
! static char rcsid[] = "$Id: res_comp.c,v 8.10 1996/10/08 04:51:06 vixie Exp $";
! #endif /* LIBC_SCCS and not lint */
  
! #include <sys/types.h>
! #include <sys/param.h>
! #include <netinet/in.h>
! #include <arpa/nameser.h>
  
! #include <stdio.h>
! #include <resolv.h>
  #include <ctype.h>
  
  #if defined(BSD) && (BSD >= 199103)
***************
*** 394,401 ****
  res_ownok(dn)
  	const char *dn;
  {
! 	if (asterchar(dn[0]) && periodchar(dn[1]))
! 		dn += 2;
  	return (res_hnok(dn));
  }
  
--- 394,405 ----
  res_ownok(dn)
  	const char *dn;
  {
! 	if (asterchar(dn[0])) {
! 		if (periodchar(dn[1]))
! 			return (res_hnok(dn+2));
! 		if (dn[1] == '\0')
! 			return (1);
! 	}
  	return (res_hnok(dn));
  }
  
diff --context --recurs m:\bind495t5b/res/res_debug.c m:\bind495t6b/res/res_debug.c
*** m:\bind495t5b/res/res_debug.c	Sat Sep 28 15:24:09 1996
--- m:\bind495t6b/res/res_debug.c	Tue Oct 08 12:55:49 1996
***************
*** 77,91 ****
  
  #if defined(LIBC_SCCS) && !defined(lint)
  static char sccsid[] = "@(#)res_debug.c	8.1 (Berkeley) 6/4/93";
! static char rcsid[] = "$Id: res_debug.c,v 8.16 1996/09/22 00:13:28 vixie Exp $";
! #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <sys/types.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
  #include <ctype.h>
  #include <netdb.h>
--- 77,91 ----
  
  #if defined(LIBC_SCCS) && !defined(lint)
  static char sccsid[] = "@(#)res_debug.c	8.1 (Berkeley) 6/4/93";
! static char rcsid[] = "$Id: res_debug.c,v 8.17 1996/10/08 04:51:06 vixie Exp $";
! #endif /* LIBC_SCCS and not lint */
  
! #include <sys/param.h>
! #include <sys/types.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
  #include <ctype.h>
  #include <netdb.h>
***************
*** 671,677 ****
  		fprintf(file, "\t%s", inet_ntop(AF_INET6, cp, t, sizeof t));
  		cp += dlen;
  		break;
! 	}
  
  	case T_LOC: {
  		char t[255];
--- 671,677 ----
  		fprintf(file, "\t%s", inet_ntop(AF_INET6, cp, t, sizeof t));
  		cp += dlen;
  		break;
! 	    }
  
  	case T_LOC: {
  		char t[255];
***************
*** 679,686 ****
  		fprintf(file, "\t%s", loc_ntoa(cp, t));
  		cp += dlen;
  		break;
! 	}
  
  	case T_SRV: {
  		u_int priority, weight, port;
  
--- 679,709 ----
  		fprintf(file, "\t%s", loc_ntoa(cp, t));
  		cp += dlen;
  		break;
! 	    }
  
+ 	case T_NAPTR: {
+ 		u_int order, preference;
+ 
+ 		order = _getshort(cp);  cp += INT16SZ;
+ 		preference   = _getshort(cp);  cp += INT16SZ;
+ 		fprintf(file, "\t%u %u ",order, preference);
+ 		/* Flags */
+ 		n = *cp++;
+ 		fprintf(file,"\"%.*s\" ", (int)n, cp);
+ 		cp += n;
+ 		/* Service */
+ 		n = *cp++;
+ 		fprintf(file,"\"%.*s\" ", (int)n, cp);
+ 		cp += n;
+ 		/* Regexp */
+ 		n = *cp++;
+ 		fprintf(file,"\"%.*s\" ", (int)n, cp);
+ 		cp += n;
+ 		if ((cp = p_fqname(cp, msg, file)) == NULL)
+ 			return (NULL);
+ 		break;
+ 	    }
+ 
  	case T_SRV: {
  		u_int priority, weight, port;
  
***************
*** 691,697 ****
  		if ((cp = p_fqname(cp, msg, file)) == NULL)
  			return (NULL);
  		break;
! 	}
  
  	case T_MINFO:
  	case T_RP:
--- 714,720 ----
  		if ((cp = p_fqname(cp, msg, file)) == NULL)
  			return (NULL);
  		break;
! 	    }
  
  	case T_MINFO:
  	case T_RP:
***************
*** 907,912 ****
--- 930,936 ----
  	{T_UINFO,	"UINFO",	"user information (nonstandard)"},
  	{T_UID,		"UID",		"user ID (nonstandard)"},
  	{T_GID,		"GID",		"group ID (nonstandard)"},
+ 	{T_NAPTR,	"NAPTR",	"URN Naming Authority"},
  #ifdef ALLOW_T_UNSPEC
  	{T_UNSPEC,	"UNSPEC",	"unspecified data (nonstandard)"},
  #endif /* ALLOW_T_UNSPEC */
diff --context --recurs m:\bind495t5b/res/res_send.c m:\bind495t6b/res/res_send.c
*** m:\bind495t5b/res/res_send.c	Sat Sep 28 15:24:09 1996
--- m:\bind495t6b/res/res_send.c	Tue Oct 08 12:55:49 1996
***************
*** 55,69 ****
  
  #if defined(LIBC_SCCS) && !defined(lint)
  static char sccsid[] = "@(#)res_send.c	8.1 (Berkeley) 6/4/93";
! static char rcsid[] = "$Id: res_send.c,v 8.11 1996/09/28 06:51:07 vixie Exp $";
! #endif /* LIBC_SCCS and not lint */
  
! 	/* change this to "0"
! 	 * if you talk to a lot
! 	 * of multi-homed SunOS
! 	 * ("broken") name servers.
  	 */
! #define	CHECK_SRVR_ADDR	1	/* XXX - should be in options.h */
  
  /*
   * Send query to name server and wait for reply.
--- 55,69 ----
  
  #if defined(LIBC_SCCS) && !defined(lint)
  static char sccsid[] = "@(#)res_send.c	8.1 (Berkeley) 6/4/93";
! static char rcsid[] = "$Id: res_send.c,v 8.12 1996/10/08 04:51:06 vixie Exp $";
! #endif /* LIBC_SCCS and not lint */
  
! 	/* change this to "0"
! 	 * if you talk to a lot
! 	 * of multi-homed SunOS
! 	 * ("broken") name servers.
  	 */
! #define	CHECK_SRVR_ADDR	1	/* XXX - should be in options.h */
  
  /*
   * Send query to name server and wait for reply.
***************
*** 784,789 ****
--- 784,795 ----
  /* ultrix 4.0 had some icky packaging in its libc.a.  alias for it here.
   * there is more gunk of this kind over in res_debug.c.
   */
+ 
+ void
+ _res_close()
+ {
+ 	res_close();
+ }
  
  #undef res_send
  int
diff --context --recurs m:\bind495t5b/shres/solaris/INSTALL m:\bind495t6b/shres/solaris/INSTALL
*** m:\bind495t5b/shres/solaris/INSTALL	Sat Sep 28 15:24:13 1996
--- m:\bind495t6b/shres/solaris/INSTALL	Tue Oct 08 12:55:54 1996
***************
*** 1,15 ****
  Installing BIND 4.9.3 resolver code in Solaris 2.x shared libraries
  ===================================================================
  
! $Id: INSTALL,v 1.4 1995/12/29 07:16:24 vixie Exp $
  
! by Alexander Dupuy <dupuy@smarts.com>
  
! Note that if you wish to modify this process, you should read and understand
! all of the file shres/solaris/ISSUES.  In any case, you should read the first
! six items in shres/solaris/ISSUES.
  
! * The Solaris name service switch
  
    This explains why you might not need to install the resolver shared
    library at all.
--- 1,15 ----
  Installing BIND 4.9.3 resolver code in Solaris 2.x shared libraries
  ===================================================================
  
! $Id: INSTALL,v 1.5 1996/10/08 04:51:07 vixie Exp $
  
! by Alexander Dupuy <dupuy@smarts.com>
  
! Note that if you wish to modify this process, you should read and understand
! all of the file shres/solaris/ISSUES.  In any case, you should read the first
! six items in shres/solaris/ISSUES.
  
! * The Solaris name service switch
  
    This explains why you might not need to install the resolver shared
    library at all.
***************
*** 128,133 ****
--- 128,145 ----
      copy of the original file in case something goes wrong, and don't let
      the editor append a newline at the end of the file (emacs can be told
      not to do this).
+ 
+     As of Solaris2.5 you have the further complication of the name
+     service cache daemon nscd(1m). If this is running then the
+     nsswitch code diverts the enquiry to nscd using the as yet
+     undocumented doors interface rather than calling the resolver
+     directly. You therefore need to do the same to /usr/sbin/nscd as
+     described above for /usr/lib/nss_dns.so.1. You may find it easier
+     to bite this off separately, first testing with nscd stopped,
+     e.g. by "/etc/init.d/nscd stop", so that nss_dns calls the
+     resolver directly. However, nscd caches more than just dns data
+     and significantly improves overall efficiency, so you want it back
+     up for production work.
  
      Once you have made these changes, you can test them as follows:
  
diff --context --recurs m:\bind495t5b/tools/host.c m:\bind495t6b/tools/host.c
*** m:\bind495t5b/tools/host.c	Sat Sep 28 15:24:10 1996
--- m:\bind495t6b/tools/host.c	Tue Oct 08 12:55:50 1996
***************
*** 67,82 ****
   */
  
  #ifndef lint
! static char rcsid[] = "$Id: host.c,v 8.11 1996/09/22 00:13:34 vixie Exp $";
! #endif /* not lint */
! 
! #include <sys/types.h>
! #include <sys/param.h>
! #include <sys/socket.h>
  
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
  #include <stdio.h>
  #include <netdb.h>
--- 67,82 ----
   */
  
  #ifndef lint
! static char rcsid[] = "$Id: host.c,v 8.12 1996/10/08 04:51:07 vixie Exp $";
! #endif /* not lint */
  
! #include <sys/types.h>
! #include <sys/param.h>
! #include <sys/socket.h>
! 
! #include <netinet/in.h>
! #include <arpa/inet.h>
! #include <arpa/nameser.h>
  
  #include <stdio.h>
  #include <netdb.h>
***************
*** 392,397 ****
--- 392,403 ----
  			case T_GID:
  				fprintf(stderr,"a Group ID.\n");
  				break;
+ 			case T_SRV:
+ 				fprintf(stderr,"a Server Selector.\n");
+ 				break;
+ 			case T_NAPTR:
+ 				fprintf(stderr,"a URN Naming Authority.\n");
+ 				break;
  			case T_UNSPEC:
  				fprintf(stderr,"any Unspecified Format data.\n");
  				break;
***************
*** 779,784 ****
--- 785,848 ----
  		cp = (u_char *)pr_cdname(cp, msg, name, sizeof(name));
  		if (doprint)
  		  fprintf(file, "%s", name);
+ 		break;
+ 
+ 	case T_SRV:
+ 		/* priority */
+ 		if (doprint)
+ 			fprintf(file," %d", _getshort(cp));
+ 		cp += sizeof(u_short);
+ 		/* weight */
+ 		if (doprint)
+ 			fprintf(file," %d", _getshort(cp));
+ 		cp += sizeof(u_short);
+ 		/* port */
+ 		if (doprint)
+ 			fprintf(file," %d", _getshort(cp));
+ 		cp += sizeof(u_short);
+ 		/* target */
+ 		cp = (u_char *)pr_cdname(cp, msg, name, sizeof(name));
+ 		if (doprint)
+ 			fprintf(file,"%s",name);
+ 		break;
+ 
+ 	case T_NAPTR:
+ 		/* order */
+ 		if (doprint)
+ 			fprintf(file," %d", _getshort(cp));
+ 		cp += sizeof(u_short);
+ 		/* preference */
+ 		if (doprint)
+ 			fprintf(file," %d", _getshort(cp));
+ 		cp += sizeof(u_short);
+ 		/* Flags */
+ 		n = *cp++;
+ 		if (doprint)
+ 		  if(n)
+ 		     fprintf(file,"%c%.*s", punc, n, cp);
+ 		  else 
+ 		     fprintf(file,"%c\"\"",punc);
+ 		cp += n;
+ 		/* Service */
+ 		n = *cp++;
+ 		if (doprint)
+ 		  if(n)
+ 		     fprintf(file,"%c%.*s", punc, n, cp);
+ 		  else 
+ 		     fprintf(file,"%c\"\"",punc);
+ 		cp += n;
+ 		/* Regexp  */
+ 		n = *cp++;
+ 		if (doprint)
+ 		  if(n)
+ 		     fprintf(file,"%c%.*s", punc, n, cp);
+ 		  else 
+ 		     fprintf(file,"%c\"\"",punc);
+ 		cp += n;
+ 		/* replacement  */
+ 		cp = (u_char *)pr_cdname(cp, msg, name, sizeof(name));
+ 		if (doprint)
+ 			fprintf(file,"%s",name);
  		break;
  
  	case T_MINFO:
diff --context --recurs m:\bind495t5b/tools/nslookup/debug.c m:\bind495t6b/tools/nslookup/debug.c
*** m:\bind495t5b/tools/nslookup/debug.c	Sat Sep 28 15:24:10 1996
--- m:\bind495t6b/tools/nslookup/debug.c	Tue Oct 08 12:55:50 1996
***************
*** 55,69 ****
  
  #ifndef lint
  static char sccsid[] = "@(#)debug.c	5.26 (Berkeley) 3/21/91";
! static char rcsid[] = "$Id: debug.c,v 8.7 1996/09/22 00:13:36 vixie Exp $";
! #endif /* not lint */
  
  /*
   *******************************************************************************
   *
!  *  debug.c --
   *
!  *	Routines to print out packets received from a name server query.
   *
   *      Modified version of 4.3BSD BIND res_debug.c 5.30 6/27/90
   *
--- 55,69 ----
  
  #ifndef lint
  static char sccsid[] = "@(#)debug.c	5.26 (Berkeley) 3/21/91";
! static char rcsid[] = "$Id: debug.c,v 8.8 1996/10/08 04:51:08 vixie Exp $";
! #endif /* not lint */
  
  /*
   *******************************************************************************
   *
!  *  debug.c --
   *
!  *	Routines to print out packets received from a name server query.
   *
   *      Modified version of 4.3BSD BIND res_debug.c 5.30 6/27/90
   *
***************
*** 339,344 ****
--- 339,383 ----
  		cp += INT16SZ;
  		fprintf(file,", mail exchanger = ");
  		goto doname;
+ 
+ 	case T_NAPTR: 
+ 		fprintf(file, "\torder = %u",_getshort((u_char*)cp));
+ 		cp += INT16SZ;
+ 		fprintf(file,", preference = %u\n", _getshort((u_char*)cp));
+ 		cp += INT16SZ;
+ 		/* Flags */
+ 		n = *cp++;
+ 		fprintf(file,"\tflags = \"%.*s\"\n", (int)n, cp);
+ 		cp += n;
+ 		/* Service */
+ 		n = *cp++;
+ 		fprintf(file,"\tservices = \"%.*s\"\n", (int)n, cp);
+ 		cp += n;
+ 		/* Regexp */
+ 		n = *cp++;
+ 		fprintf(file,"\trule = \"%.*s\"\n", (int)n, cp);
+ 		cp += n;
+ 		/* Replacement */
+ 		fprintf(file,"\treplacement = ");
+                 cp = Print_cdname(cp, msg, eom, file);
+ 		if (cp == NULL) {
+ 			fprintf(file, "(replacement truncated?)\n");
+ 			return (NULL);			/* compression error */
+ 		}
+                 (void) putc('\n', file);
+ 
+ 		break;
+ 	case T_SRV: 
+ 		fprintf(file, "\tpriority = %u",_getshort((u_char*)cp));
+ 		cp += INT16SZ;
+ 		fprintf(file,", weight = %u", _getshort((u_char*)cp));
+ 		cp += INT16SZ;
+ 		fprintf(file,", port= %u\n", _getshort((u_char*)cp));
+ 		cp += INT16SZ;
+ 
+ 		fprintf(file,"\thost = ");
+ 		goto doname;
+ 
          case T_PX:
                  fprintf(file,"\tpreference = %u",_getshort((u_char*)cp));
                  cp += INT16SZ;
diff --context --recurs m:\bind495t5b/tools/nslookup/list.c m:\bind495t6b/tools/nslookup/list.c
*** m:\bind495t5b/tools/nslookup/list.c	Sat Sep 28 15:24:10 1996
--- m:\bind495t6b/tools/nslookup/list.c	Tue Oct 08 12:55:50 1996
***************
*** 55,69 ****
  
  #ifndef lint
  static char sccsid[] = "@(#)list.c	5.23 (Berkeley) 3/21/91";
! static char rcsid[] = "$Id: list.c,v 8.7 1996/08/08 22:49:50 vixie Exp $";
! #endif /* not lint */
  
  /*
   *******************************************************************************
   *
!  *  list.c --
   *
!  *	Routines to obtain info from name and finger servers.
   *
   *	Adapted from 4.3BSD BIND ns_init.c and from finger.c.
   *
--- 55,69 ----
  
  #ifndef lint
  static char sccsid[] = "@(#)list.c	5.23 (Berkeley) 3/21/91";
! static char rcsid[] = "$Id: list.c,v 8.8 1996/10/08 04:51:08 vixie Exp $";
! #endif /* not lint */
  
  /*
   *******************************************************************************
   *
!  *  list.c --
   *
!  *	Routines to obtain info from name and finger servers.
   *
   *	Adapted from 4.3BSD BIND ns_init.c and from finger.c.
   *
***************
*** 209,214 ****
--- 209,216 ----
  		qtype = T_WKS;
  	    } else if (strcmp("-d", option) == 0) {
  		qtype = T_ANY;
+ 	    } else if (strcmp("-n", option) == 0) {
+ 		qtype = T_NAPTR;
  	    } else {
  		qtype = T_A;
  	    }
***************
*** 777,782 ****
--- 779,810 ----
  		if ((cp = (u_char *)Print_cdname(cp, msg, eom, file)) == NULL)
  			return (NULL);
  		break;
+ 	    }
+ 
+ 	    case T_NAPTR: {
+ 		u_int order, preference;
+ 
+                 GETSHORT(order, cp);
+                 fprintf(file, "\t%u", order);
+ 
+                 GETSHORT(preference, cp);
+                 fprintf(file, " %u", preference);
+ 
+                 if (n = *cp++) {
+                      fprintf(file, " \"%.*s\"", (int)n, cp);
+                      cp += n;
+                 }
+                 if (n = *cp++) {
+                      fprintf(file, " \"%.*s\"", (int)n, cp);
+                      cp += n;
+                 }
+                 if (n = *cp++) {
+                      fprintf(file, " \"%.*s\"", (int)n, cp);
+                      cp += n;
+                 }
+ 		if ((cp = (u_char *)Print_cdname(cp, msg, eom, file)) == NULL)
+ 			return (NULL);
+                 break;
  	    }
  
  	    case T_MINFO:
diff --context --recurs m:\bind495t5b/tools/nslookup/nslookup.help m:\bind495t6b/tools/nslookup/nslookup.help
*** m:\bind495t5b/tools/nslookup/nslookup.help	Sat Sep 28 15:24:10 1996
--- m:\bind495t6b/tools/nslookup/nslookup.help	Tue Oct 08 12:55:50 1996
***************
*** 1,13 ****
! $Id: nslookup.help,v 8.3 1996/08/05 08:31:39 vixie Exp $
! 
! Commands: 	(identifiers are shown in uppercase, [] means optional)
! NAME		- print info about the host/domain NAME using default server
! NAME1 NAME2	- as above, but use NAME2 as server
! help or ?	- print info on common commands; see nslookup(1) for details
! set OPTION	- set an option
!     all		- print options, current server and host
!     [no]debug	- print debugging information
!     [no]d2	- print exhaustive debugging information
      [no]defname	- append domain name to each query 
      [no]recurse	- ask for recursive answer to query
      [no]vc	- always use a virtual circuit
--- 1,13 ----
! $Id: nslookup.help,v 8.4 1996/10/08 04:51:08 vixie Exp $
! 
! Commands: 	(identifiers are shown in uppercase, [] means optional)
! NAME		- print info about the host/domain NAME using default server
! NAME1 NAME2	- as above, but use NAME2 as server
! help or ?	- print info on common commands; see nslookup(1) for details
! set OPTION	- set an option
!     all		- print options, current server and host
!     [no]debug	- print debugging information
!     [no]d2	- print exhaustive debugging information
      [no]defname	- append domain name to each query 
      [no]recurse	- ask for recursive answer to query
      [no]vc	- always use a virtual circuit
***************
*** 16,22 ****
      root=NAME	- set root server to NAME
      retry=X	- set number of retries to X
      timeout=X	- set initial time-out interval to X seconds
!     querytype=X	- set query type, e.g., A,ANY,CNAME,HINFO,MX,PX,NS,PTR,SOA,TXT,WKS
      port=X	- set port number to send query on
      type=X	- synonym for querytype
      class=X	- set query class to one of IN (Internet), CHAOS, HESIOD or ANY
--- 16,22 ----
      root=NAME	- set root server to NAME
      retry=X	- set number of retries to X
      timeout=X	- set initial time-out interval to X seconds
!     querytype=X	- set query type, e.g., A,ANY,CNAME,HINFO,MX,PX,NS,PTR,SOA,TXT,WKS,SRV,NAPTR
      port=X	- set port number to send query on
      type=X	- synonym for querytype
      class=X	- set query class to one of IN (Internet), CHAOS, HESIOD or ANY
