Home | History | Annotate | only in /src/lib/libc/net
History log of /src/lib/libc/net
RevisionDateAuthorComments
 1.5 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.4 22-Aug-2001  itojun branches: 1.4.112;
sync argument/return type of [hn]to[nh][ls] to XNET 5.2 (uint{16,32}_t).
as discussed on tech-net.
 1.3 14-Jun-2000  cgd branches: 1.3.4;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.2 03-May-1999  christos branches: 1.2.6;
Make these work again, by undef'ing the macro that could cause syntax errors.
Also add NOSTRICT in the {h,n}to{n,h}s() cases where the prototype would get
widened...
 1.1 06-Nov-1997  cgd branches: 1.1.2;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_htonl.c was added on branch netbsd-1-3 on 1997-11-08 21:59:05 +0000
 1.2.6.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.4.1 08-Oct-2001  nathanw Catch up to -current.
 1.4.112.1 02-Aug-2025  perseant Sync with HEAD
 1.5 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.4 22-Aug-2001  itojun branches: 1.4.112;
sync argument/return type of [hn]to[nh][ls] to XNET 5.2 (uint{16,32}_t).
as discussed on tech-net.
 1.3 14-Jun-2000  cgd branches: 1.3.4;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.2 03-May-1999  christos branches: 1.2.6;
Make these work again, by undef'ing the macro that could cause syntax errors.
Also add NOSTRICT in the {h,n}to{n,h}s() cases where the prototype would get
widened...
 1.1 06-Nov-1997  cgd branches: 1.1.2;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_htons.c was added on branch netbsd-1-3 on 1997-11-08 21:59:06 +0000
 1.2.6.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.4.1 08-Oct-2001  nathanw Catch up to -current.
 1.4.112.1 02-Aug-2025  perseant Sync with HEAD
 1.5 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.4 22-Aug-2001  itojun branches: 1.4.112;
sync argument/return type of [hn]to[nh][ls] to XNET 5.2 (uint{16,32}_t).
as discussed on tech-net.
 1.3 14-Jun-2000  cgd branches: 1.3.4;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.2 03-May-1999  christos branches: 1.2.6;
Make these work again, by undef'ing the macro that could cause syntax errors.
Also add NOSTRICT in the {h,n}to{n,h}s() cases where the prototype would get
widened...
 1.1 06-Nov-1997  cgd branches: 1.1.2;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_ntohl.c was added on branch netbsd-1-3 on 1997-11-08 21:59:07 +0000
 1.2.6.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.4.1 08-Oct-2001  nathanw Catch up to -current.
 1.4.112.1 02-Aug-2025  perseant Sync with HEAD
 1.5 01-Dec-2024  rillig libc: modernize lint stubs

Use prototype function definitions instead of identifier lists, as C23
does not support the latter.

Remove redundant /*ARGSUSED*/ comments and parentheses.
 1.4 22-Aug-2001  itojun branches: 1.4.112;
sync argument/return type of [hn]to[nh][ls] to XNET 5.2 (uint{16,32}_t).
as discussed on tech-net.
 1.3 14-Jun-2000  cgd branches: 1.3.4;
fix up NetBSD RCS Ids to match the standard, and the leading comment as
to match as well. No functional changes.
 1.2 03-May-1999  christos branches: 1.2.6;
Make these work again, by undef'ing the macro that could cause syntax errors.
Also add NOSTRICT in the {h,n}to{n,h}s() cases where the prototype would get
widened...
 1.1 06-Nov-1997  cgd branches: 1.1.2;
lint stubs for functions which ports use assembly versions. When using
an assembly version of a function, add the right lint stub to the Makefile.inc
which specifies the source to build the function (see the
arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
functions, because some of them don't _have_ normal C versions and if
that were done dependencies would get messed up.
 1.1.2.2 08-Nov-1997  veego pull up changes from the trunk (approved by perry) from cgd:
>lint stubs for functions which ports use assembly versions. When using
>an assembly version of a function, add the right lint stub to the Makefile.inc
>which specifies the source to build the function (see the
>arch/i386/*/Makefile.inc). Can't just lint the normal C versions of these
>functions, because some of them don't _have_ normal C versions and if
>that were done dependencies would get messed up.
 1.1.2.1 06-Nov-1997  veego file Lint_ntohs.c was added on branch netbsd-1-3 on 1997-11-08 21:59:08 +0000
 1.2.6.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.3.4.1 08-Oct-2001  nathanw Catch up to -current.
 1.4.112.1 02-Aug-2025  perseant Sync with HEAD
 1.96 03-Aug-2023  rin Revert CC_WNO_USE_AFTER_FREE from Makefile's (thanks uwe@)
 1.95 03-Aug-2023  rin Sprinkle CC_WNO_USE_AFTER_FREE for GCC 12

All of them are blamed for idiom equivalent to:
newbuf = realloc(buf, size);
p = newbuf + (p - buf);
 1.94 03-Jun-2023  lukem bsd.own.mk: rename GCC_NO_* to CC_WNO_*

Rename compiler-warning-disable variables from
GCC_NO_warning
to
CC_WNO_warning
where warning is the full warning name as used by the compiler.

GCC_NO_IMPLICIT_FALLTHRU is CC_WNO_IMPLICIT_FALLTHROUGH

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
 1.93 03-Jun-2023  lukem bsd.own.mk: rename to CC_WNO_ADDRESS_OF_PACKED_MEMBER

Provide a single variable
CC_WNO_ADDRESS_OF_PACKED_MEMBER
with options for both clang and gcc, to replace
CLANG_NO_ADDR_OF_PACKED_MEMBER
CC_NO_ADDR_OF_PACKED_MEMBER
GCC_NO_ADDR_OF_PACKED_MEMBER

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
 1.92 12-Apr-2021  mrg new GCC_NO_* uses for warning issues. most of the users of the new
GCC_NO_RETURN_LOCAL_ADDR are bugs in GCC itself, not the code.
 1.91 13-Oct-2019  mrg introduce some common variables for use in GCC warning disables:

GCC_NO_FORMAT_TRUNCATION -Wno-format-truncation (GCC 7/8)
GCC_NO_STRINGOP_TRUNCATION -Wno-stringop-truncation (GCC 8)
GCC_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow (GCC 8)
GCC_NO_CAST_FUNCTION_TYPE -Wno-cast-function-type (GCC 8)

use these to turn off warnings for most GCC-8 complaints. many
of these are false positives, most of the real bugs are already
commited, or are yet to come.


we plan to introduce versions of (some?) of these that use the
"-Wno-error=" form, which still displays the warnings but does
not make it an error, and all of the above will be re-considered
as either being "fix me" (warning still displayed) or "warning
is wrong."
 1.90 10-Oct-2019  kre More cases to disable gcc-8 warnings only when we're using gcc>=8
 1.89 09-Oct-2019  christos Add -Wno-error for gcc-8 warnings
 1.88 02-Aug-2018  rjs Add userland support for SCTP and manpages.
 1.87 18-Jun-2017  manu branches: 1.87.4; 1.87.6;
Include IPv6 global variable in USE_INET6=no libc

This ensures a binary built with USE_INET6=yes libc can still link at
runtime with a USE_INET6=no libc. Of course IPv6 functionnality is not
available, but dynamic linking is not killed by missing symbols such
as in6addr_any.
 1.86 15-Apr-2015  mrg branches: 1.86.8;
remove various HAVE_GCC=45 fragments.
 1.85 19-Oct-2013  christos branches: 1.85.4;
document the scopeid functions
 1.84 19-Oct-2013  christos add inet6_scopeid
 1.83 01-Mar-2013  joerg Retire OSI network stack. OK core@
 1.82 27-Dec-2012  martin Avoid gcc 4.5.3 compiler bug on ia64 by compiling hesiod.c with -O1 only.
 1.81 20-Jan-2012  joerg branches: 1.81.6;
Change CMSG_SPACE and CMSG_LEN to provide Integer Constant Expressions
again. This was changed in sys/socket.h r1.51 to work around fallout
from the IPv6 aux data migration. It broke the historic ABI on some
platforms. This commit restores compatibility for netbsd32 code on such
platforms and provides a template for future changes to the CMSG_*
alignment. Revert PCC/Clang workarounds in postfix and tmux.
 1.80 25-Dec-2011  tsutsui Apply fix for previous changes per request from joerg@:
http://mail-index.NetBSD.org/source-changes-d/2011/12/25/msg004454.html

XXX1: More Makefiles should be fixed otherwise they will be
copy-and-pasted blindly again and again.
XXX2: Probably we need more explicit and simple macro to check active CC.
 1.79 24-Dec-2011  tsutsui Specify "-fno-tree-ter" to getaddrinfo.c and gethnamaddr.c on arm and gcc45
for workaround of a possible optimazation bug.

On my W-ZERO3 and Zaurus, hostname lookup against CNAME by some commands
(ping(8), ftp(1) etc.) fails even though nslookup(8) returns a proper name
against the same CNAME, after NetBSD/arm ports has been switched to
gcc 4.5 since 201110311420Z (i.e 201110310000Z binaries worked but
201111010000Z ones not).

Building getaddrinfo.c and gethnamaddr.c in libc with "-O2 -fno-tree-ter"
(or using objects built by old gcc 4.1) seems to fix this issue.

Accroding to nonaka@, the following gcc bugzilla test case also fails
with -O2 but works with -O2 -fno-tree-ter on NetBSD/zaurus 5.99.57:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48863#c4
but CNAME lookup didn't fail on his environment even without this workaround.
 1.78 02-Oct-2009  tsarna branches: 1.78.6;
Introduce allocaddrinfo(3) to make writing getaddrinfo() nss plugins easier.
Discussed on tech-net.
 1.77 08-Jun-2009  christos another missing \
 1.76 08-Jun-2009  christos remove duplicated line
 1.75 08-Jun-2009  christos missing \
 1.74 08-Jun-2009  christos sort, add missing, fix section
 1.73 08-Jun-2009  christos new resolver functions.
 1.72 09-Aug-2007  he Add a new socket option for unix domain sockets: LOCAL_PEEREID, to make
it possible to get the pid, euid and egid of the process at the remote
end at the time it did bind() or connect().

Add a new libc function, getpeereid() to easily get at the euid and egid.
As a consequence, bump libc's minor number.

Document the LOCAL_PEEREID socket option in unix(4).

Based on contribution by Arne H. Juul, minor modifications by myself.
 1.71 26-Aug-2006  matt Remove the XNS man pages.
 1.70 26-Aug-2006  matt Move ns_addr and ns_ntoa to compat libc. Add a stripped version of
<netns/ns.h> which only include struct ns_addr and the ns_addr and ns_ntoa
function prototypes.
 1.69 05-May-2006  rpaulo Add support for RFC 3542 Adv. Socket API for IPv6 (which obsoletes 2292).
* RFC 3542 isn't binary compatible with RFC 2292.
* RFC 2292 support is on by default but can be disabled.
* update ping6, telnet and traceroute6 to the new API.

From the KAME project (www.kame.net).
Reviewed by core.
 1.68 11-Jan-2005  itojun replace with written-from-scratch manpage. (fixes ISOC copyright issue)
 1.67 10-Jan-2005  lukem Only compile in IPv6 support if ${USE_INET6} != "no"

MKINET6 is for providing IPv6 infrastructure.
USE_INET6 is for compiling IPv6 support into the programs (needs MKINET6).
 1.66 20-Dec-2004  christos revert previous change while discussion is in progress.
 1.65 20-Dec-2004  itojun RFC cannot be used as manpage regarding to the ISOC copyright boilerplate.
remove it until someone writes it up from scratch/freely-redistributable
text is found.
 1.64 24-Aug-2004  ginsbach Add MLINK for gethostent as suggested by Matthias Drochner.
 1.63 21-May-2004  christos Finish bind9 resolver merge.
 1.62 19-Feb-2004  christos branches: 1.62.2;
getservent_r/getprotoent_r
 1.61 07-Dec-2003  matt Make building IPv6 support controllable by MKINET6
 1.60 04-Dec-2003  lukem MAKEVERBOSE tweaks
 1.59 22-Mar-2002  thorpej Split the notion of building Hesiod, Kerberos, S/key, and YP
infrastructure and using that infrastructure in programs.

* MKHESIOD, MKKERBEROS, MKSKEY, and MKYP control building
of the infratsructure (libraries, support programs, etc.)

* USE_HESIOD, USE_KERBEROS, USE_SKEY, and USE_YP control
building of support for using the corresponding API
in various libraries/programs that can use it.

As discussed on tech-toolchain.
 1.58 22-Oct-2001  kleink Add a sockatmark(3), the 1003.1g wrapper around SIOCATMARK.
 1.57 29-Apr-2001  itojun remove obsolete MAN lines for getipnodeby* (has been comented out)
 1.56 28-Feb-2001  itojun branches: 1.56.2;
it seems that gethostent(3) is no longer supplied in libc.
couple of wording corrections.
From: Hubert Feyrer <hubert.feyrer@informatik.fh-regensburg.de>
 1.55 07-Jul-2000  cgd to get (f)lex output to go to stdout, use -t (a flag supported by
flex) rather than -o/dev/stdout which uses a flex feature (-o isn't
in vendor lex, at least on solaris 7) and also requires that
"/dev/stdout" function in the expected manner.
 1.54 24-Apr-2000  itojun use BSDI-origin if_{index,name}* functions. they use getifaddrs(3) as
backend and are more robust against SIOCGIFCONF alignment issue.
now getifaddrs always takes care of the issue. (sync with kame tree)
use weak symbol just in case.
 1.53 14-Mar-2000  sjg Listing generated files nslexer.c nsparser.c in SRCS breaks make depend
in a clean dir. Put the actual src files nslexer.l nsparser.y there.
 1.52 02-Mar-2000  itojun make CMSG_ALIGN always synchronize with kernel's idea of ALIGNBYTES.
ancillary data alignment will be ALIGNBYTES, not sizeof(long) - 1, from now.

CMSG_xx will NOT resolve into constant. if you use CMSG_xx to allocate
arrays, you'll lose.

bump shlib minor for libc.

NOTE: if you are on top of arch with ALIGNBYTES != sizeof(long) - 1,
you need to recompile IPv6-related binaries. there is no way to guarantee
backward compat in this aspect. sorry for this. this should be the last
backward compat breakage for IPv6-related ancillary data manipulation.
(we still have PR 9516 for unix-domain sockets...)
 1.51 23-Feb-2000  itojun add freeifaddrs.3 as MLINKS.
 1.50 23-Feb-2000  itojun add getifaddrs(3) from bsdi4, as mentioned in tech-net (in SIOCGIFCONF
related thread).
this will save future apps from complexity of SIOCGIFCONF.

getifaddrs(3) does not use SIOCGIFCONF internally, it uses sysctl.
 1.49 09-Feb-2000  itojun add missing manpage, gethostbyname2(3).
 1.48 27-Jan-2000  itojun add IPv6 support to rcmd() and friends.
rcmd() and iruserok(): unchanged
ruserok(): became address family independent
rcmd_af(), iruesrok_sa(): address family independent
 1.47 26-Jan-2000  itojun move -DINET6 upwards, into lib/libc/Makefile.
- we need it for lib/libc/rpc soon
- this is not clear to add CPPFLAGS in subdir/Makefile.inc (as it affect other
subdirs as well)
 1.46 12-Dec-1999  itojun add manpage for inet6_{option,rthdr}_*.
 1.45 10-Nov-1999  jdolecek add freeaddrinfo(3) and gai_strerror(3) as links to getaddrinfo(3)
 1.44 15-Sep-1999  kleink branches: 1.44.4;
Add indirect reference stubs for inet_[ap]ton() for environments not supporting
weak aliases; addresses PR lib/7435 but leaves the original file intact.
 1.43 01-Jul-1999  itojun add IPv6 support functions.

get{addr,name} info are implemented to have as little impact to existing
resolver code as possible, so they are NOT the optimal implementation.
They are at this moment not very thread safe (as they call
gethostby{name,addr}).

(shlib minor version)++, as new interfaces are added.

TODO: getipnodeby{name,addr} - which needs total reimplementation of
gethostby{name,addr}.
upgrade rcmd.c for multiple af support (needed for IPv6-ready rsh/rlogin)
 1.42 22-Apr-1999  mycroft Do a lame hack to reduce the size of the lexer state buffer, which reduces
memory consumption substantially. The buffer is only used to print line
numbers...
 1.41 24-Feb-1999  drochner branches: 1.41.2;
use ${ARCHDIR} instead of ${.CURDIR}/arch/${MACHINE_ARCH} where appropriate
libc builds on pmax again
 1.40 25-Jan-1999  lukem add hesiod(3) et al
 1.39 16-Jan-1999  lukem pull nsswitch up to main branch
convert getnetby*() to nsswitch (from resolv.conf lookup)
 1.38 15-Jan-1999  lukem merge nsswitch into main branch
 1.37 12-Mar-1998  lukem install links for inet_ntop(3) and inet_pton(3)
 1.36 04-Feb-1998  christos Add sorting of resolved addresses.
 1.35 14-Nov-1997  mrg add missing .Nm entries. from spz@serpens.swb.de.
 1.34 26-Aug-1997  kleink branches: 1.34.2;
Make linkntoa.3 a link to linkaddr.3 again; fixes PR lib/4017 from maximum
entropy <entropy@tardis.bernstein.com>.
 1.33 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.32 07-Jul-1997  christos inet_pton4() did not handle
- incompletely specified ip addresses
- ip addresses specified in hex
like inet_aton() and inet_addr(). This broke parsing of /etc/hosts
(127.1 localhost stopped working before the resolver is started).
The fix is to use the inet_aton() code to implement inet_pton4(), and
then use the new inet_pton4() code to implement inet_aton() and inet_addr().
At that point inet_addr.c is empty and has been removed.
 1.31 18-Jun-1997  lukem * add man page for inet_net_ntop(3) and inet_net_pton(3)
* xref them in inet(3)
* use Va instead of Fn for 'errno' in inet(3)
 1.30 28-May-1997  mrg install a man page (link) for orcmd(3).
 1.29 22-Apr-1997  mrg branches: 1.29.2;
create indirect references (or function stubs) to dn_comp(), res_close()
and res_send(), as required.
 1.28 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.27 17-Nov-1996  mikel Add iso_addr.3 to MAN. Fixes misc/2942.
 1.26 10-Jul-1996  jtc branches: 1.26.4;
Install linkaddr.3 as link_addr.3 and link_ntoa.3 too.
 1.25 30-Mar-1996  jtc Added explicit return types to all functions in SYNOPSIS section.
Added documentation to hstrerror() function.
Added hstrerror MLINK.
 1.24 02-Feb-1996  mrg merge with the resolver in bind 4.9.3-P1.
 1.23 02-Mar-1995  chopps include proper links to ethers.3
 1.22 25-Feb-1995  cgd mention the functions that need to be provided, instead of providing dflts.
 1.21 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.20 10-Feb-1995  cgd list the files needed on the alpha.
 1.19 22-Dec-1994  cgd specify man pages the new way.
 1.18 18-Dec-1994  cgd make sure link for inet_aton is in alphabetical order in MLINKS.
 1.17 14-Nov-1994  dean Include files for pmax
 1.16 31-Oct-1994  glass link inet.3 for inet_aton()
 1.15 28-Oct-1994  cgd fix bug 535, reported by Brian Moore.
 1.14 16-Dec-1993  deraadt ethers(3) man page by Roland McGrath <roland@frob.com>
 1.13 16-Dec-1993  deraadt ethers(3) sunos-like support from Roland McGrath <roland@frob.com>
YP code fixed by myself (looked in wrong maps, didn't free things :-)
used by rarpd & friends.
 1.12 08-Dec-1993  pk Added some Sparc sources.
 1.11 05-Dec-1993  briggs Changed occurance of MACHINE_ARCH == "hp300" to MACHINE_ARCH == "m68k"
 1.10 05-Dec-1993  cgd get pc532 moved into ns32k; that's is MACHINE_ARCH
 1.9 05-Dec-1993  cgd split up the {ntoh,hton}[ls] functions
 1.8 04-Dec-1993  cgd update for .S and MACHINE_ARCH
 1.7 07-Oct-1993  cgd make an arch directory in libc, and move all machine dirs into it
 1.6 17-Sep-1993  phil pc532 specifics.
 1.5 31-Aug-1993  jtc Provide C language versions of the netorder functions.
These may be "good enough" for big-endian systems that do not have assembly
language versions of their own. A compiler should be able to do a fairly
good job optimising them, it probably won't be smart enough to omit the
stack frame, but then again, these functions won't be called unless the
macro versions are undef'd.
On the other hand, they are only intended for bootstrap purposes on little-
endian systems. They should be replaced with assembly language versions as
soon as possible.
 1.4 01-Aug-1993  mycroft Add RCS identifiers.
 1.3 21-May-1993  cgd Needed for netstat to compile, add iso_addr &c
(from Havard Eidnes <Havard.Eidnes@runit.sintef.no>)
 1.2 25-Apr-1993  mycroft Compile {iso,ns}_{addr,ntoa}.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.26.4.1 06-Nov-1996  lukem initial nsswitch implementation
 1.29.2.2 02-Nov-1998  lukem sync with current, assign my copyrights to TNF
 1.29.2.1 23-May-1997  lukem * Add nsdispatch(3) implementation
* Deprecate support for "lookup" in resolv.conf
 1.34.2.1 14-Nov-1997  mrg pull up from trunk: add missing .Nm entries. from spz@serpens.swb.de.
 1.41.2.1 29-Apr-1999  perry pullup 1.41->1.42 (mycroft) -- thought I'd done this days ago
 1.44.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.56.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.56.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.56.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.62.2.1 11-Sep-2004  he Pull up revision 1.64 (requested by ginsbach in ticket #834):
Restore gethostent() as a supported interface. Yes, it
may be obsolete, but it is specified by IEEE Std 1003.1,
2004 Edition (POSIX) and the X/Open standards (Issue 66
and XNS 5.2).
 1.78.6.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.78.6.2 23-Jan-2013  yamt sync with head
 1.78.6.1 17-Apr-2012  yamt sync with head
 1.81.6.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.81.6.2 23-Jun-2013  tls resync from head
 1.81.6.1 25-Feb-2013  tls resync with head
 1.85.4.1 23-Jul-2017  snj Pull up following revision(s) (requested by manu in ticket #1439):
lib/libc/net/Makefile.inc: revision 1.87
Include IPv6 global variable in USE_INET6=no libc
This ensures a binary built with USE_INET6=yes libc can still link at
runtime with a USE_INET6=no libc. Of course IPv6 functionnality is not
available, but dynamic linking is not killed by missing symbols such
as in6addr_any.
 1.86.8.1 04-Jul-2017  martin Pull up following revision(s) (requested by manu in ticket #78):
lib/libc/net/Makefile.inc: revision 1.87
Include IPv6 global variable in USE_INET6=no libc
This ensures a binary built with USE_INET6=yes libc can still link at
runtime with a USE_INET6=no libc. Of course IPv6 functionnality is not
available, but dynamic linking is not killed by missing symbols such
as in6addr_any.
 1.87.6.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.87.6.1 10-Jun-2019  christos Sync with HEAD
 1.87.4.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.7 20-Dec-2005  christos Use reach-over sources from common/lib/libc
 1.6 09-Feb-2005  kleink A little libc namespace housekeeping exercise:
* Make vfprintf_unlocked() an internal function, c.f. __svfscanf_unlocked().
* Add internal names for arc4random(), endnetpath(), fhstatvfs(),
fstatvfs(), mkstemp(), shquote(), statvfs(), taddr2uaddr(), uaddr2taddr(),
uuid_create_nil(), uuid_is_nil(), and wcwidth().
* Include namespace.h where supposed to.
 1.5 29-Jan-2004  itojun whitespace KNF
 1.4 21-Mar-2003  ross LP64 warnings
 1.3 24-Apr-2000  itojun add __RCSID().
 1.2 19-Apr-2000  itojun change copyright notice from 3-clause TNF -> 4-clause TNF.
not sure if which we prefer, but the point is to use exactly the same
copyright. From: matthew green <mrg@eterna.com.au>
 1.1 02-Mar-2000  itojun make CMSG_ALIGN always synchronize with kernel's idea of ALIGNBYTES.
ancillary data alignment will be ALIGNBYTES, not sizeof(long) - 1, from now.

CMSG_xx will NOT resolve into constant. if you use CMSG_xx to allocate
arrays, you'll lose.

bump shlib minor for libc.

NOTE: if you are on top of arch with ALIGNBYTES != sizeof(long) - 1,
you need to recompile IPv6-related binaries. there is no way to guarantee
backward compat in this aspect. sorry for this. this should be the last
backward compat breakage for IPv6-related ancillary data manipulation.
(we still have PR 9516 for unix-domain sockets...)
 1.5 21-May-2004  christos Finish bind9 resolver merge.
 1.4 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.3 17-Jul-1997  thorpej branches: 1.3.2;
Do the non-__indr_reference verions of thse like the cat*(3) functions,
modulo a slight kludge to get around the namespace trickery played
in <resolv.h>.
 1.2 22-Apr-1997  cgd pull in <netinet/in.h>, s/#Include/#include, and fix up __dn_comp() prototype,
so that this compiles.
 1.1 22-Apr-1997  mrg create indirect references (or function stubs) to dn_comp(), res_close()
and res_send(), as required.
 1.3.2.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.6 21-May-2004  christos Finish bind9 resolver merge.
 1.5 17-Aug-1999  mycroft This file was incorrect. The indirect name is res_close(),
not _res_close()!
 1.4 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.3 17-Jul-1997  thorpej branches: 1.3.2;
Do the non-__indr_reference verions of thse like the cat*(3) functions,
modulo a slight kludge to get around the namespace trickery played
in <resolv.h>.
 1.2 22-Apr-1997  cgd pull in <netinet/in.h> so that these compile
 1.1 22-Apr-1997  mrg create indirect references (or function stubs) to dn_comp(), res_close()
and res_send(), as required.
 1.3.2.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.5 21-May-2004  christos Finish bind9 resolver merge.
 1.4 04-Nov-1997  thorpej __warn_references and __indr_reference semicolon fixups. From
Chris Demetriou <cgd@pa.dec.com>.
 1.3 17-Jul-1997  thorpej branches: 1.3.2;
Do the non-__indr_reference verions of thse like the cat*(3) functions,
modulo a slight kludge to get around the namespace trickery played
in <resolv.h>.
 1.2 22-Apr-1997  cgd pull in <netinet/in.h> so that these compile
 1.1 22-Apr-1997  mrg create indirect references (or function stubs) to dn_comp(), res_close()
and res_send(), as required.
 1.3.2.1 04-Nov-1997  thorpej Pull up from trunk: __warn_references and __indr_reference semicolon fixups.
 1.2 21-May-2004  christos Finish bind9 resolver merge.
 1.1 15-Sep-1999  kleink Add indirect reference stubs for inet_[ap]ton() for environments not supporting
weak aliases; addresses PR lib/7435 but leaves the original file intact.
 1.2 21-May-2004  christos Finish bind9 resolver merge.
 1.1 15-Sep-1999  kleink Add indirect reference stubs for inet_[ap]ton() for environments not supporting
weak aliases; addresses PR lib/7435 but leaves the original file intact.
 1.17 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.16 24-Nov-2014  christos knf, no functional change.
 1.15 24-Nov-2014  christos Don't read past the end when the data is exactly the right size. Reported
by tedu @ openbsd in tech-userlevel. Thanks!
 1.14 25-Jun-2012  abs branches: 1.14.10;
Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.13 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.12 12-Apr-2009  christos branches: 1.12.6;
merge libbind and bump.
 1.11 21-Jun-2008  christos branches: 1.11.4; 1.11.6; 1.11.8; 1.11.10; 1.11.14;
updates from bind-9-5-0
 1.10 30-Mar-2007  ghen branches: 1.10.12;
Resolve conflicts.
 1.9 27-Jan-2007  christos merge in resolver portion of bind-9.4.0-rc2
 1.8 11-Nov-2002  thorpej branches: 1.8.16; 1.8.18;
Fix signed/unsigned comparison warnings.
 1.7 07-Jul-2000  itohy branches: 1.7.2;
Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.
 1.6 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.5 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.4 13-Nov-1998  christos delint
 1.3 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.2 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.1 13-Apr-1997  mrg branches: 1.1.1;
Initial revision
 1.1.1.4 12-Apr-2009  christos libc portion of libbind from external/bsd/libbind
 1.1.1.3 30-Mar-2007  ghen Import bind 9.4.0.
 1.1.1.2 27-Jan-2007  christos add base64.c
 1.1.1.1 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.7.2.1 11-Nov-2002  nathanw Catch up to -current
 1.8.18.1 03-Jun-2007  wrstuden Catch up with now-somewhat-dated netbsd-4. These changes took longer
than expected for me to actually get around to merging.
 1.8.16.2 17-May-2007  jdc Add missing BIND 9.4.x include file and library changes (requested by
tron in ticket #662).
 1.8.16.1 17-May-2007  jdc Update BIND to version 9.4.1 (requested by christos in ticket #602).
Thanks to tron for the patches, upgrade script and testing.
 1.10.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.11.14.1 09-Jan-2011  riz Apply patches (requested by spz in ticket #1517):

Update bind to 9.7.2-P3.
 1.11.10.1 10-Jan-2011  riz Apply patches (requested by spz in ticket #1517):

Update bind to 9.7.2-P3.
 1.11.8.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.11.6.2 21-Jun-2008  christos updates from bind-9-5-0
 1.11.6.1 21-Jun-2008  christos file base64.c was added on branch christos-time_t on 2008-06-21 20:41:49 +0000
 1.11.4.1 06-Jan-2011  riz Apply patches (requested by spz in ticket #1517):

Update bind to 9.7.2-P3.
 1.12.6.2 30-Oct-2012  yamt sync with head
 1.12.6.1 17-Apr-2012  yamt sync with head
 1.14.10.1 25-Nov-2014  martin Pull up following revision(s) (requested by christos in ticket #264):
lib/libc/net/base64.c: revision 1.15
lib/libc/net/base64.c: revision 1.16
Don't read past the end when the data is exactly the right size. Reported
by tedu @ openbsd in tech-userlevel. Thanks!
knf, no functional change.
 1.15 03-May-2011  jruoho Xref bswap(3). Simplify STANDARDS.
 1.14 04-Feb-2006  uwe Use different wording as "null macro" is too ambiguous.
 1.13 11-Sep-2005  soda typo - s/intger/integer/
 1.12 10-Jun-2004  kleink Update for use of uint{16,32}_t.
 1.11 07-Aug-2003  agc branches: 1.11.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 29-Nov-2001  ross Delete the old BUGS section entry:
> On the VAX bytes are handled backwards from most everyone else in
> the world. This is not expected to be fixed in the near future.

Multiple levels of irony there...
 1.7 16-Sep-2001  wiz Boring whitespace fixes.
 1.6 22-Mar-1999  garbled branches: 1.6.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.5 05-Feb-1998  perry add LIBRARY section to man page
 1.4 13-Oct-1996  christos in_addr_t and in_port_t changes
 1.3 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.12.4 22-Mar-2002  nathanw Catch up to -current.
 1.6.12.3 08-Mar-2002  nathanw Catch up to -current.
 1.6.12.2 28-Jan-2002  nathanw Catch up to -current.
 1.6.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.11.2.1 14-Jun-2004  jmc Pullup rev 1.12 (requested by kleink in ticket #465)

Update for use of uint{16,32}_t.
 1.15 30-Oct-2017  wiz Fix Bl argument.
 1.14 25-Oct-2017  abhinav Remove comma after last Nm entry.
New sentence, new line
 1.13 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.12 16-Sep-2002  tron Use "const" for all input parameters of ethers(3) functions.
 1.11 06-Aug-2002  soren Make SYNOPSIS accurate about required headers.
Fixes PR lib/11021 from wiz.
 1.10 07-Feb-2002  ross Generate <>& symbolically.
 1.9 16-Sep-2001  wiz Boring whitespace fixes.
 1.8 22-Mar-1999  garbled branches: 1.8.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.7 06-Feb-1998  perry macroize BSD, NetBSD, FreeBSD and misc cleanup
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 14-Nov-1997  mrg add missing .Nm entries. from spz@serpens.swb.de.
 1.4 02-Nov-1997  lukem * fix ether_line to limit size of parsed hostname to MAXHOSTNAMELEN
* modify ether_aton, ether_hostton, and ether_line to take 'const char *'
arguments as appropriate
* document the above in ethers(3)
 1.3 13-Apr-1997  mrg branches: 1.3.2;
merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.2 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.1 16-Dec-1993  deraadt branches: 1.1.14;
ethers(3) man page by Roland McGrath <roland@frob.com>
 1.1.14.1 11-Mar-1997  is Convert to new ARP.
 1.3.2.2 14-Nov-1997  mrg pull up from trunk: add missing .Nm entries. from spz@serpens.swb.de.
 1.3.2.1 10-Nov-1997  thorpej Sync w/ trunk.
 1.8.12.5 18-Oct-2002  nathanw Catch up to -current.
 1.8.12.4 13-Aug-2002  nathanw Catch up to -current.
 1.8.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.8.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.8.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.25 18-Sep-2014  christos make more descriptors that we open as close-on-exec
 1.24 19-Jun-2014  christos use fparseln() instead of fgetln() for consistency (this was the last fgetln()
using parser in net/.
cVS: ----------------------------------------------------------------------
 1.23 20-Mar-2012  matt branches: 1.23.2; 1.23.8;
Use C89 Prototypes.
Remove use of __P
 1.22 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.21 15-Oct-2006  martin branches: 1.21.42;
PR lib/34801 from David A. Holland: "static" comes first in declaration.
 1.20 16-Sep-2002  tron Use "const" for all input parameters of ethers(3) functions.
 1.19 04-Oct-2000  sommerfeld branches: 1.19.2;
Avoid run-time construction of format string we can build at compile time
 1.18 24-Apr-2000  itojun branches: 1.18.4;
add __RCSID().
 1.17 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.16 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.15 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.14 13-Nov-1998  christos branches: 1.14.2;
delint
 1.13 26-Jul-1998  mycroft Move an output buffer into the BSS.
 1.12 12-Nov-1997  mjacob Fix compile problem.
 1.11 02-Nov-1997  lukem * fix ether_line to limit size of parsed hostname to MAXHOSTNAMELEN
* modify ether_aton, ether_hostton, and ether_line to take 'const char *'
arguments as appropriate
* document the above in ethers(3)
 1.10 21-Jul-1997  jtc branches: 1.10.2;
If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.9 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.8 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.7 23-Jan-1997  mrg branches: 1.7.2;
- convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.6 17-Jan-1997  mikel explicitly type ether_{hostton,ntohost,line}(). all return int.
 1.5 25-Feb-1995  cgd branches: 1.5.4;
clean up import. also convert everything to new Id format.
 1.4 30-Dec-1993  deraadt "struct ether_addr" is in netinet/if_ether.h (as in SunOS)
 1.3 28-Dec-1993  jtc #include <stdlib.h> & <string.h> to bring function prototypes into scope.
 1.2 16-Dec-1993  deraadt small bug fixed
 1.1 16-Dec-1993  deraadt ethers(3) sunos-like support from Roland McGrath <roland@frob.com>
YP code fixed by myself (looked in wrong maps, didn't free things :-)
used by rarpd & friends.
 1.5.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.7.2.1 11-Mar-1997  is Convert to new ARP.
 1.10.2.2 11-Nov-1997  mjacob fix compilation problem
 1.10.2.1 10-Nov-1997  thorpej Sync w/ trunk.
 1.14.2.2 13-Mar-2001  he Apply patch (requested by kristerw):
Correct error in pull-up to 1.4.3 which prevents rarpd
from working.
 1.14.2.1 19-Oct-2000  he Pull up revision 1.19 (via patch, requested by is):
Construct format string at compile time.
 1.18.4.1 19-Oct-2000  he Pull up revision 1.19 (requested by is):
Construct format string at compile-time.
 1.19.2.1 18-Oct-2002  nathanw Catch up to -current.
 1.21.42.1 17-Apr-2012  yamt sync with head
 1.23.8.1 10-Aug-2014  tls Rebase.
 1.23.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.4 24-Feb-2006  wiz We have 2006.
 1.3 22-Feb-2006  ginsbach Add EAI_OVERFLOW per RFC3493, POSIX and XPG6.
 1.2 12-Jan-2005  wiz Use .In for including header files, remove some unnecessary quotes.
 1.1 11-Jan-2005  itojun written-from-scratch manpage (fixes ISOC copyright violation)
 1.61 09-May-2024  wiz Document that freeaddrinfo(NULL) dumps core.

A source code comment already said this, but it's easier to
find in a man page.
 1.60 04-Jun-2020  nia branches: 1.60.6;
getaddrinfo.3: order of the struct members is wrong, correct it
 1.59 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.58 13-Dec-2015  christos mention ip6addrctl
 1.57 03-May-2013  wiz New sentence, new line.
 1.56 03-May-2013  christos document AI_SRV
 1.55 17-Apr-2010  wiz branches: 1.55.6; 1.55.12;
Join URL.
 1.54 17-Apr-2010  jruoho Use the common template for the USENIX paper. Add URL.
 1.53 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.52 14-Dec-2009  wiz Bump date for previous.
 1.51 14-Dec-2009  dholland getaddrinfo is defined to use the AF_* constants, even though perhaps its
interface ought to have been defined in terms of PF_*. Add a note about
how the distinction has been lost anyway. Fixes PR lib/42384.
 1.50 02-Oct-2009  wiz Revert a -> an changes: Adding an 'n' follows pronunciation, not writing.
 1.49 02-Oct-2009  wiz Bump date for new allocaddrinfo.
 1.48 02-Oct-2009  cegger fix grammar: a -> an
 1.47 02-Oct-2009  tsarna Introduce allocaddrinfo(3) to make writing getaddrinfo() nss plugins easier.
Discussed on tech-net.
 1.46 23-Dec-2006  wiz Add missing article.
 1.45 24-Nov-2006  reed Document AI_NUMERICSERV.

(When manpage was rewritten some docs were lost.)
 1.44 18-Jul-2006  christos Remove comments that do not reflect reality anymore.
 1.43 21-Mar-2005  kleink Only name <netdb.h> in the synopsis, like the old manual page used to.
 1.42 21-Mar-2005  kleink Add restrict qualifiers to getaddrinfo() and getnameinfo() arguments.
 1.41 28-Jan-2005  wiz branches: 1.41.2;
Use In instead of Fd; use \*[Am]\*[Lt]\*[Gt] for html output. Uppercase FREENIX.
 1.40 28-Jan-2005  itojun title was backwards. djm@openbsd
 1.39 11-Jan-2005  itojun replace with written-from-scratch manpage. (fixes ISOC copyright issue)
 1.38 20-Dec-2004  christos revert previous change while discussion is in progress.
 1.37 20-Dec-2004  itojun RFC cannot be used as manpage regarding to the ISOC copyright boilerplate.
remove it until someone writes it up from scratch/freely-redistributable
text is found.
 1.36 14-Apr-2004  wiz Add missing "-".
 1.35 14-Apr-2004  itojun remove unneeded refs to rfc2553. jmc
 1.34 14-Apr-2004  itojun document AI_NUMERICSERV
 1.33 01-Mar-2004  itojun use "%s" for err(), do not pass pointer directly. Pedro Martelletto
 1.32 07-Sep-2003  wiz Consistently use 'RFC 1234' instead of 'RFC1234' or 'RFC-1234'.
From jmc@openbsd.
 1.31 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.30 30-Apr-2003  itojun english grammer. by Jason McIntyre via kame
 1.29 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.28 15-Jun-2002  itojun refer nsswitch.conf(5). From: Jim Bernard <jbernard@mines.edu>
 1.27 14-May-2002  kleink ai_addrlen: size_t -> socklen_t.
 1.26 10-May-2002  kleink Rip out <sys/types.h> and <sys/socket.h> inclusions: there are no
pre-requisites for <netdb.h>.
 1.25 10-May-2002  kleink In the examples, initialize struct addrinfo explicitly to either 0 or a
NULL pointer; from der Mouse in PR lib/16634.
 1.24 07-Feb-2002  ross generate & symbolically
 1.23 07-Feb-2002  ross Generate <>& symbolically.
 1.22 16-Sep-2001  wiz Sort sections, sort SEE ALSO, and misc. fixes.
 1.21 16-Sep-2001  wiz Boring whitespace fixes.
 1.20 05-Aug-2001  itojun there's no host.conf in netbsd. pointed out by smb
 1.19 12-Feb-2001  itojun branches: 1.19.2;
fix listener side example. from deraadt, sync with kame
 1.18 26-Jan-2001  itojun - scope separater is percentage, not atmark.
- typo in example. s/err1/errx/.
- some wording improvements.
sync with kame.
 1.17 16-Nov-2000  lukem english fixup
 1.16 09-Aug-2000  itojun mention that current get{addr,name}info implementation are not thread-safe.
(sync with kame)
From: Greg Thompson
 1.15 25-Jul-2000  itojun typo. s/Fa getaddrinfo/Fn getaddrinfo/. sync with kame.
 1.14 25-Jul-2000  itojun move pitfall example to downwards. wording fixes. sync with kame.
 1.13 25-Jul-2000  itojun give pitfall examples.
in response to couple of PRs including 10666. sync with kame.
 1.12 30-Jun-2000  itojun typo in RFC number. KAME PR 263
 1.11 22-Jun-2000  itojun add cmetz paper, correct example
 1.10 11-May-2000  itojun branches: 1.10.4;
$NetBSD$
 1.9 11-May-2000  itojun update internet draft #. correct samples.
sync getnameinfo function prototype with /usr/include/netdb.h (not
standard conformant yet, needs update - will do soon)
 1.8 20-Feb-2000  itojun getaddrinfo(3) now obeys nsswitch.conf correctly.
 1.7 14-Feb-2000  itojun in BUGS section, document that it can behave differently from nsswitch.conf(5)
suggests.
NetBSD PR: 9413
 1.6 19-Jan-2000  itojun cosmetic (last dot in SEE ALSO section)
 1.5 17-Jan-2000  itojun sync with latest KAME tree.
add example section to get{addr,name}info.
s/\.Os KAME/.Os/.
 1.4 07-Jan-2000  itojun need sys/types.h before sys/socket.h
 1.3 13-Dec-1999  itojun bring in latest KAME get{addr,name}info(3).
getnameinfo(3) globs ai_socktype and ai_protocol correctly.
KAME scopeid extension is implemented.
(draft-ietf-ipngwg-scopedaddr-format-00.txt)

bump up shlib minor
(may not be necessary, but rather big difference in behavior - especially
ai_flags)
 1.2 03-Jul-1999  kleink branches: 1.2.4;
Add missing LIBRARY sections.
 1.1 01-Jul-1999  itojun add IPv6 support functions.

get{addr,name} info are implemented to have as little impact to existing
resolver code as possible, so they are NOT the optimal implementation.
They are at this moment not very thread safe (as they call
gethostby{name,addr}).

(shlib minor version)++, as new interfaces are added.

TODO: getipnodeby{name,addr} - which needs total reimplementation of
gethostby{name,addr}.
upgrade rcmd.c for multiple af support (needed for IPv6-ready rsh/rlogin)
 1.2.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.10.4.4 10-Aug-2000  itojun pullup (approved by releng-1-5)
mention that current implementation is not thread-safe. (sync with kame)
From: Greg Thompson

getaddrinfo.3 1.15 -> 1.16
getnameinfo.3 1.10 -> 1.11
 1.10.4.3 28-Jul-2000  itojun pullup 1.12 -> 1.15 (approved by releng-1-5)
give pitfall examples.
in response to couple of PRs including 10666. sync with kame.
 1.10.4.2 03-Jul-2000  thorpej Pull up rev. 1.12:
typo in RFC number. KAME PR 263
 1.10.4.1 27-Jun-2000  thorpej Pull up rev. 1.11:
add cmetz paper, correct example
 1.19.2.4 21-Jun-2002  nathanw Catch up to -current.
 1.19.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.19.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.19.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.41.2.2 21-Mar-2005  tron Pull up revision 1.43 (requested by kleink in ticket #41):
Only name <netdb.h> in the synopsis, like the old manual page used to.
 1.41.2.1 21-Mar-2005  tron Pull up revision 1.42 (requested by kleink in ticket #40):
Add restrict qualifiers to getaddrinfo() and getnameinfo() arguments.
 1.55.12.1 23-Jun-2013  tls resync from head
 1.55.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.60.6.1 20-Jul-2024  martin Pull up following revision(s) (requested by rin in ticket #753):

lib/libc/net/getaddrinfo.3: revision 1.61

Document that freeaddrinfo(NULL) dumps core.

A source code comment already said this, but it's easier to
find in a man page.
 1.127 21-Jan-2024  kre Unwrap a line which wasn't wrapped before it had an __UNCONST() added
to it, and now that that is gone again, doesn't need wrapping any more.

That line is now unaltered from what it was 3 revs ago (bit for bit).

NFC.
 1.126 20-Jan-2024  christos Make the first argument of ip6_str2scopeid const, instead of __UNCONST.
Thanks kre@. While here s/u_int32_t/uint32_t/
 1.125 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.124 01-Aug-2023  mrg convert explicit length check before unchecked snprintf() with just a
overflow checked snprintf(). for res_debug.c and res_query.c, convert
from sprintf() to snprintf().

tested scp and rcp fail properly with too-long paths.
tested getaddrinfo fails as expected for too-long domains.
tested dig and ping for similar (res_debug.c/res_query.c).
created a temporary fs with quotas to test edquota with a long EDITOR.
did not test ypserv directly, but it's the same pattern.

avoids GCC 12 snprintf() warnings, and reduces total code size.
 1.123 19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.122 28-Oct-2021  riastradh Fix typo in comment: allows, not alows.

I don't know what an alow is, maybe some cousin of the alot.
Awaiting a nature documentary by Allie Brosh about these perhaps more
elusive beasts.

PR misc/56473, from jschauma
 1.121 27-Oct-2021  nia getaddrinfo(3): malloc + memset -> calloc
 1.120 18-Nov-2020  is Don't complain about additional DNAME records received when resolving A or
AAAA (like already done for SIG/KEY and CNAME).
 1.119 13-Dec-2018  dholland branches: 1.119.2;
Adjust English usage in message for EAI_NONAME.
 1.118 13-Dec-2018  dholland Return EAI_NODATA, not EAI_NONAME, for nonexistent hosts.

This causes e.g. "ssh nosuchname" to print "No address associated with
hostname", which is correct, rather than "hostname nor servname
provided, or not known", which is not.
 1.117 28-Dec-2017  christos branches: 1.117.2; 1.117.4;
PR/52837: Michael Kaufmann: getaddrinfo() resolves "127.0.0.1 www.example.com"
to 127.0.0.1. Apply the patch from FreeBSD and explain the rationale.
 1.116 29-Sep-2017  christos PR/52578: Benjamin M. Schwartz: sync the internal copy of res_nquery for
getaddrinfo, with the real version so that we handle EDNS fallback.
 1.115 10-Jan-2017  christos branches: 1.115.6;
KNF, simplify expressions for readability.
 1.114 06-Feb-2016  riastradh branches: 1.114.2;
Avoid shadowing global.
 1.113 14-Dec-2015  christos PR/50552: Kyle Amon: RFC3493 section 6.1 wants us to accept non-dotted-quad
INET4 addresses.
XXX: pullup-7
 1.112 13-Dec-2015  christos Implement the address selection policy; from FreeBSD
 1.111 02-Dec-2015  christos PR/44915: Havard Eidnes:
- Convert NS_NOTFOUND to EAI_NONAME instead
of EAI_NODATA which more inline with what other OS's do.
- Convert NO_DATA to NS_NOTFOUND since there is no equivalent mapping
for nsswitch (perhaps we could add one so what we could recover the exact
error and return EAI_NODATA?)
- If we end up following a CNAME chain that does not find any data return that
instead of internal error.

XXX: pullup-7
 1.110 26-Oct-2015  christos PR/50367: Stefan Schaeckeler: libc resolver library does not resolve host
names with underscores ("_"). According to resolv.conf(5) RES_NOCHECKNAME
is on by default; well, it is and gethostbyname(3) obeys it
(gethnamaddr.c:maybe_ok), but getaddrinfo(3) up till this commit not.
XXX: pullup-7, pullup-6
 1.109 10-Sep-2015  christos namespace protect allocaddrinfo
 1.108 10-Sep-2015  christos mke allocaddrinfo static.
 1.107 09-Sep-2015  ozaki-r Include several libc functions in rump.ping6

We need getaddrinfo, getifaddrs, if_indextoname and if_nametoindex
in addition to getnameinfo.
 1.106 22-Dec-2013  christos branches: 1.106.4; 1.106.6;
this is supposed to be re-entrant, call don't call __hostalias that uses
a static buffer.
 1.105 13-May-2013  christos CVE 1020946: Fix res leak.
 1.104 13-May-2013  christos CVE 1020938: Fix memory leak
 1.103 03-May-2013  christos PR/32373, PR/25827: Add SRV lookup in getaddrinfo(3)
Per DNS-SD (RFC 2782), but only enabled if AI_SRV is set.
 1.102 03-May-2013  christos KNF, whitespace police -- no code changes
 1.101 08-Jun-2012  martin branches: 1.101.2;
Henning Petersen in PR lib/46561: cosmetic change: avoid self assignement.
 1.100 20-Mar-2012  kardel PR pkg/46206
re-establish fqdn lookup when AI_ADDRCONFIG is used in hints
AI_ADDRCONFIG led to fqdn lookup being skipped as the systems didn't
configure any PF_UNSPEC addresses - check was too strict here.
Thnaks to Ryo ONODERA for testing.
 1.99 20-Mar-2012  kardel PR 46206: fix programmed SIGSEGV
more work is needed as tests seem to indicate that name resolution now
does no seem to work (firefox reports Server not found)
thanks to Ryo ONODERA for testing.
 1.98 17-Mar-2012  christos Add AI_ADDRCONFIG, which makes getaddrinfo() return only address with families
that are already configured in the system.
 1.97 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.96 15-Oct-2011  christos branches: 1.96.2; 1.96.4;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.95 02-Oct-2009  wiz Revert a -> an changes: Adding an 'n' follows pronunciation, not writing.
 1.94 02-Oct-2009  cegger fix grammar: a -> an
 1.93 02-Oct-2009  tsarna Introduce allocaddrinfo(3) to make writing getaddrinfo() nss plugins easier.
Discussed on tech-net.
 1.92 23-Jan-2009  tls Cause getaddrinfo() without socktype specification to work correctly for
numeric addresses. The documentation appears to say this works, and some
other systems support it -- more importantly, why should it _not_ work? If
it does not, getaddrinfo() cannot be used as a general-purpose textual to
binary address conversion utility function; yet it is the only such function
we have in the system, since inet_pton() requires a priori knowledge of the
address family.

This change also causes getaddrinfo() with NULL hint (expressly documented
as working) to work properly for numeric addresses.
 1.91 19-Apr-2008  lukem branches: 1.91.6; 1.91.8;
Add a missing const.
 1.90 29-Jun-2007  christos branches: 1.90.10;
make this compile without INET6 (Scott Ellis)
 1.89 23-Jun-2007  christos Since we are going to be looking for ports many times, use a centralized
servent data structure and pass the stayopen hint.
 1.88 10-May-2007  christos use syslog_r, from OpenBSD
 1.87 15-Oct-2006  christos branches: 1.87.2;
fix incomplete initializers
 1.86 14-Oct-2006  christos memset the whole struct addrinfo, instead of trying to figure out if we
have a pad member or not.
 1.85 19-Jul-2006  christos Call endservent_r. From Hajimu UMEMOTO
 1.84 18-Jul-2006  christos use getservbyname_r.
 1.83 18-Jul-2006  christos Remove comments that do not reflect reality anymore.
 1.82 25-Mar-2006  rpaulo Make macros more readable. No functional change.
 1.81 21-Mar-2006  christos Coverity CID 2363: cur is known not to be NULL.
 1.80 21-Mar-2006  christos Coverity CID 2364: cur is known not to be NULL.
 1.79 21-Mar-2006  christos Coverity CID 2430: cur is known not to be NULL.
 1.78 21-Mar-2006  mjl Correct obvious typo
 1.77 17-Feb-2006  ginsbach Add EAI_OVERFLOW as specified in RFC3493, POSIX and XPG6.
 1.76 13-Feb-2006  ginsbach Fix spelling mistake in comment. From OpenBSD.
 1.75 02-Dec-2005  yamt constify and remove an unnecessary __UNCONST.
 1.74 29-Nov-2005  christos WARNS=4
 1.73 15-Sep-2005  tsarna Rest of fix for PR#31184: getaddrinfo() now honors resolv.conf sortlist
directive for dns answers.

Also, unifdef the RESLVSORT (non-)option sillyness.

Reviewed by christos.
 1.72 27-May-2004  christos make yp stuff re-entrant.
 1.71 23-May-2004  christos centralize res_*init() calls in __res_get_state()
 1.70 21-May-2004  christos Finish bind9 resolver merge.
 1.69 14-Apr-2004  itojun remove prototype decl for removed function
 1.68 14-Apr-2004  itojun remove unused code
 1.67 14-Apr-2004  itojun implement AI_NUMERICSERV (as defined in RFC3493)
 1.66 17-May-2003  itojun bound copies
 1.65 08-May-2003  itojun fill ai_canonname field for numeric hostname, by the given hostname.
folows new recommendation in RFC3493
 1.64 17-Mar-2003  itojun From: "Jason L. Wright" <jason@thought.net>

The man page for getaddrinfo() and RFC2553 says it should return EAI_NONAME
for the case where hostname != NULL, hostname is not a numeric string and
ai_flags has the AI_NUMERICHOST bit set. Instead, it returns EAI_NODATA
for this case. The diff below makes it return EAI_NONAME for this case.

This is why ntpq and ntpdc from ntp-4.1.74 can't resolve hostnames,
but work fine with numeric strings like ::1 or 127.0.0.1.
 1.63 27-Aug-2002  itojun allocate 64K recieve buffer for DNS responses.
 1.62 22-Aug-2002  itojun drop AAAA reply with IPv4 mapped address. sync w/kame
draft-itojun-v6ops-v4mapped-harmful-00.txt
 1.61 01-Jul-2002  itojun pacify lint. from he@netbsd
 1.60 01-Jul-2002  itojun lint clean. from martin husemann
 1.59 01-Jul-2002  itojun make more pedantic check on strtoul. from deraadt, sync w/kame
 1.58 29-Jun-2002  itojun correct port range check. from deraadt, sync w/kame, diff sent to bind-bugs
 1.57 27-Jun-2002  itojun correct %d/%u mixup.
 1.56 26-Jun-2002  itojun correct bad practice in the code - it uses two changing variables
to manage buffer (buf and buflen). we eliminate buflen and use
fixed point (ep) as the ending pointer.

this fix is NOT critical.
 1.55 14-May-2002  kleink branches: 1.55.2;
struct addrinfo.ai_addrlen used to be a size_t, per RFC 2553.

In XNS5.2, and subsequently in POSIX-2001 and draft-ietf-ipngwg-rfc2553bis-02
it was changed to a socklen_t.

To accomodate for this while preserving binary compatibility with the
old interface, prepend or append 32 bits of padding, depending on
the (LP64 data model) architecture's endianness.

This should be deleted the next time the libc major number is
incremented.
 1.54 20-Aug-2001  itojun use snprintf, not sprintf. sync with kame.
 1.53 25-Jan-2001  jdolecek branches: 1.53.2;
make local constant arrays const
 1.52 24-Jan-2001  itojun make sure "qname" argument to getanswer() is properly given. from lukem
 1.51 04-Jan-2001  lukem sprinkle _DIAGASSERT() around
 1.50 10-Dec-2000  christos remove redundant declarations of h_errno and __hostalias
 1.49 23-Sep-2000  lukem don't bother declaring in6_addrany[] and in6_loopback #ifndef INET6
 1.48 31-Aug-2000  itojun on /etc/hosts lookup, set "official host name" (the leftmost hostname)
into ai_canonname. this is to synchronize with practice in gethostby*.
comment from ume@mahoroba.org. sync with kame.
 1.47 09-Aug-2000  itojun implement EDNS0 support, as EDNS0 support will be made mandatory for
IPv6 transport-ready resolvers/DNS servers. need careful configuration
when enable it. (default config is not affected).
see manpage for details.

XXX visible symbol __res_opt() is added, however, it is not supposed to be
called from outside, libc minor is not bumped.
 1.46 09-Jul-2000  itojun reject empty scopeid/numeric portname explicitly. sync with kame.
 1.45 09-Jul-2000  itojun use strtoul() to check for all-digit string, not isdigit(). sync with kame.
 1.44 07-Jul-2000  itohy Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.
 1.43 05-Jul-2000  itojun return EAI_NODATA, instead of EAI_NONAME, on name resolution errors.
EAI_NONAME does not make sense in these situations. from kame.
From: enami@netbsd.org
 1.42 27-Apr-2000  itojun branches: 1.42.4;
remove unused struct def. more sanity check for NULL.
 1.41 26-Apr-2000  itojun add $KAME$
 1.40 26-Apr-2000  itojun disable AI_ADDRCONFIG (post RFC2553 specification),
it has bug in PF_UNSPEC caes. From: ume
fix boundary check which was broken by delint in the past.
 1.39 24-Apr-2000  itojun add __RCSID().
 1.38 24-Apr-2000  itojun supply weak alias for IPv6-related library additions. sorry to be late.
 1.37 03-Apr-2000  itojun in yphostent, initialize res0 when getaddrinfo fails.
 1.36 02-Apr-2000  christos Delint:
- add notreached comment
- remove unused variables
- cast to void * first to avoid casting warnings
- fix bug in _yphostent where cur and sentinel were not
being initialized.
 1.35 16-Mar-2000  itojun visit all requests even if we get errors from name server.
this will solve name query failures for IPv4-only node, when
the DNS server returns SERVFAIL or NXDOMAIN (should success with an == 0).
PR: 9621
 1.34 22-Feb-2000  itojun avoid memory leak on valid FQDN + invalid port name.
 1.33 20-Feb-2000  itojun query NIS hosts.byname only when necessary (= PF_UNSPEC of PF_INET queries).
 1.32 20-Feb-2000  itojun to honor the search order defined by nsswitch.conf,
getaddrinfo(3) now calls lower-layer resolver functions directly.

XXX code duplicate with gethnamaddr.c/res_search.c - future code
maintenance issue? Since BIND[89] does not address this issue either at
this moment, switching to BIND[89] does not help.
 1.31 17-Feb-2000  itojun to synchronize with progress of discussion for post
draft-ietf-ipngwg-scopedaddr-format-00.txt (will be 01),
use "address%interface" notation for extended scoped IPv6 address.

NOTE: the change affects link-local addresses only. I hope it to be
the final change on it.....
 1.30 16-Feb-2000  itojun preparation to flip extended scoped address syntax.

the specification is still under debate; there is high possibility that
"fe80::1%de0" will be the finalist but i'm not sure yet.
 1.29 15-Feb-2000  itojun make it possible to compile it without -DINET6
From: "Castor Fu" <castor@geocast.com>
 1.28 10-Feb-2000  itojun sa_len was not properly set due to autoconf #ifdef.
(mistake in yesterday's upgrade)
 1.27 09-Feb-2000  itojun revise extended scoped address format support. delimiter and the order
is changed, based on discussion in ipngwg scoped address cabal.
past code: fe80::1@de0
now: de0%fe80::1
this will be in sync with next extended address format proposal
(which should be final - I don't want to make this kind of change again).
 1.26 28-Jan-2000  itojun backout previous commit - freeaddrinfo(NULL) issue.
 1.25 27-Jan-2000  itojun allow freeaddrinfo(NULL). nothing is talked in RFC2553 (maybe in X/Open?).
however, since NRL freeaddrinfo permits it, we need to.
 1.24 26-Jan-2000  itojun fix RFC2553 conformance. AI_CANONNAME does not mean reverse query.
 1.23 24-Jan-2000  itojun fix comment.
better sync with kame tree.
 1.22 23-Jan-2000  itojun remove #if 0'ed portion (AF filtering in normal name resolution)
add comment to the fragment which confused mycroft
 1.21 23-Jan-2000  mycroft Doh. I'm a dork.
 1.20 22-Jan-2000  mycroft Partially delint.
 1.19 17-Jan-2000  itojun do not filter address families that are not supported by kernel.
the behavior was introduced in 1.8 -> 1.9, by itojun, and it was
not a correct behavior.

even if we may be able to connect to the the returned addresses,
filtering them out is not a correct thing to do. for example, even if
you have partial unreachablility in IPv4, gethostbyname(3) will return
IPv4 addresses in the unreachable network nonetheless.
 1.18 17-Jan-2000  itojun remove #if 0'ed sections.
 1.17 27-Dec-1999  itojun properly check the error result from if_nametoindex(), to disallow
bogus interface index specification like fe80::1@bogus.
(sync with kame)
 1.16 13-Dec-1999  itojun more complete solution for gethostby*() buffer overwrite issue.
(we need thread-safe gethostby*...)
 1.15 13-Dec-1999  itojun fix getaddrinfo(3) and getnameinfo(3).

getaddrinfo(3): result from gethostby* will be broken if we call it again.
deep-copy them. we have sa_len so configure them.
getnameinfo(3): we have sa_len so configure them.
 1.14 13-Dec-1999  itojun bring in latest KAME get{addr,name}info(3).
getnameinfo(3) globs ai_socktype and ai_protocol correctly.
KAME scopeid extension is implemented.
(draft-ietf-ipngwg-scopedaddr-format-00.txt)

bump up shlib minor
(may not be necessary, but rather big difference in behavior - especially
ai_flags)
 1.13 20-Sep-1999  lukem branches: 1.13.4;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.12 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.11 22-Aug-1999  kleink Need "namespace.h".
 1.10 13-Aug-1999  itojun pacify too-picky compiler.

From: onoe@sm.sony.co.jp
 1.9 14-Jul-1999  itojun - do not make query for AFs that are not supported by kernel.
i.e. do not make query for IPv6 addresses, when running on non-IPv6 kernel,
or, do not query for IPv4 address on IPv6-only kernel :-)

This kind of behavior is not very well documented in RFC2553. This
may violate the spec.

- on EAI_AGAIN, only retry 3 times (3 is a magic number). Previous code
made retries forever. This solves situation where name server is wrongly
configured and nameserver:53 returns icmp port unreach.

The only proper fix for all getaddrinfo() related twists would be to
implement getipnodebyname() and get rid of wacky get_addr().
We need to contribute bind8 development for this.
 1.8 06-Jul-1999  itojun fix name resolution problem when you have "hosts: files dns" on
/etc/nsswitch.conf.

This was because of two reasons:
- /etc/hosts lookup code damaged some of internal
state used by gethostbyname2().
- getaddrinfo() was not persistent enough against errors.

Sorry for the delay, and hope this fix all the following PRs
(I checked in my environment immitating those PRs and it worked for me)
PR: 7901, 7912, 7921
 1.7 04-Jul-1999  lukem capitalize the first word of most error strings except those words that are
argument names to the function. e.g, if `const char *servname' is an argument
name, keep using "servname invalid [...]" instead of "Servname invalid [...]"
 1.6 04-Jul-1999  itojun add NetBSD RCSID on top.
 1.5 04-Jul-1999  itojun fix USE_GETIPNODEBY case.
 1.4 04-Jul-1999  itojun fix behavior when there's dangling CNAME on specific AF.
TODO: have getipnodeby{name,addr} and let them do the trick.
 1.3 03-Jul-1999  itojun improve lint friendliness on USE_GETIPNODEBY case.
(no change in behavior)
 1.2 03-Jul-1999  lukem remove trailing `.' on error messages, since messages from strerror() and
h_strerror() don't return messages with a trailing `.' (and the `.' looks
ugly when using warnx() with the error message).
 1.1 01-Jul-1999  itojun add IPv6 support functions.

get{addr,name} info are implemented to have as little impact to existing
resolver code as possible, so they are NOT the optimal implementation.
They are at this moment not very thread safe (as they call
gethostby{name,addr}).

(shlib minor version)++, as new interfaces are added.

TODO: getipnodeby{name,addr} - which needs total reimplementation of
gethostby{name,addr}.
upgrade rcmd.c for multiple af support (needed for IPv6-ready rsh/rlogin)
 1.13.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.42.4.5 04-Sep-2002  itojun lib/libc/net/getaddrinfo.c 1.56
lib/libc/net/res_mkquery.c 1.22
correct bad practice in the code - it uses two changing variables
to manage buffer (buf and buflen). we eliminate buflen and use
fixed point (ep) as the ending pointer.

lib/libc/net/getaddrinfo.c 1.50
remove redundant declarations of h_errno and __hostalias

lib/libc/net/getaddrinfo.c 1.52
make sure "qname" argument to getanswer() is properly given. from lukem

lib/libc/net/getaddrinfo.c 1.54
lib/libc/net/gethnamaddr.c 1.43,1.49-1.50
lib/libc/net/getnetnamadr.c 1.23
use snprintf, string manipulation cleanups

lib/libc/net/getaddrinfo.c 1.57-1.59
correct port range check and signed/unsigned mixup

lib/libc/net/getaddrinfo.c 1.60-1.61
lint clean

lib/libc/net/getaddrinfo.c 1.62
lib/libc/net/gethnamaddr.c 1.51
drop AAAA reply with IPv4 mapped address. sync w/kame
draft-itojun-v6ops-v4mapped-harmful-00.txt

lib/libc/net/getaddrinfo.c 1.63
lib/libc/net/gethnamaddr.c 1.52
lib/libc/net/getnetnamadr.c 1.24
allocate 64K recieve buffer for DNS responses.

lib/libc/net/gethnamaddr.c 1.38
Varargsify dprintf to allow for format string checking

lib/libc/net/gethnamaddr.c 1.39
lib/libc/net/getnetnamadr.c 1.20
remove redundant declarations.

lib/libc/net/gethnamaddr.c 1.41
do not reverse-lookup scoped IPv6 address. it does not make sense as
there's no way to give scope identifier. sync w/kame

lib/libc/net/gethnamaddr.c 1.42
style

lib/libc/net/gethnamaddr.c 1.45
do not pass uninitialized variable to nsdispatch().

lib/libc/net/gethnamaddr.c 1.48
query ip6.arpa then ip6.int for IPv6 reverse lookup. follows RFC3152.
 1.42.4.4 01-Jul-2002  he Pull up revision 1.58 (requested by itojun):
Correct port range check.
 1.42.4.3 31-Aug-2000  itojun pullup 1.47 -> 1.48 (approved by releng-1-5)

> on /etc/hosts lookup, set "official host name" (the leftmost hostname)
> into ai_canonname. this is to synchronize with practice in gethostby*.
> comment from ume@mahoroba.org. sync with kame.
 1.42.4.2 13-Jul-2000  itojun pullup 1.42 -> 1.43: (approved by releng-1-5)
return EAI_NODATA, instead of EAI_NONAME, on name resolution errors.
EAI_NONAME does not make sense in these situations. from kame.
From: enami@netbsd.org
 1.42.4.1 13-Jul-2000  thorpej Pull up rev. 1.45 (itojun):
use strtoul() to check for all-digit string, not isdigit(). sync with kame.
 1.53.2.4 27-Aug-2002  nathanw Catch up to -current.
 1.53.2.3 01-Aug-2002  nathanw Catch up to -current.
 1.53.2.2 21-Jun-2002  nathanw Catch up to -current.
 1.53.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.55.2.6 27-Aug-2002  lukem Pull up revision 1.63 (requested by itojun in ticket #735):
allocate 64K recieve buffer for DNS responses.
 1.55.2.5 24-Aug-2002  lukem Pull up revision 1.62 (requested by itojun in ticket #718):
drop AAAA reply with IPv4 mapped address. sync w/kame
draft-itojun-v6ops-v4mapped-harmful-00.txt
 1.55.2.4 17-Aug-2002  lukem Pull up revision 1.56 (requested by itojun in ticket #693):
correct bad practice in the code - it uses two changing variables
to manage buffer (buf and buflen). we eliminate buflen and use
fixed point (ep) as the ending pointer.
this fix is NOT critical.
 1.55.2.3 02-Jul-2002  lukem Pull up revision 1.60 (requested by itojun in ticket #417):
lint clean. from martin husemann
 1.55.2.2 02-Jul-2002  lukem Pull up revision 1.59 (requested by itojun in ticket #417):
make more pedantic check on strtoul. from deraadt, sync w/kame
 1.55.2.1 29-Jun-2002  lukem Pull up revision 1.58 (requested by itojun in ticket #401):
correct port range check. from deraadt, sync w/kame, diff sent to bind-bugs
 1.87.2.1 31-Jan-2009  bouyer Pull up following revision(s) (requested by tls in ticket #1267):
lib/libc/net/getaddrinfo.c: revision 1.92
Cause getaddrinfo() without socktype specification to work correctly for
numeric addresses. The documentation appears to say this works, and some
other systems support it -- more importantly, why should it _not_ work? If
it does not, getaddrinfo() cannot be used as a general-purpose textual to
binary address conversion utility function; yet it is the only such function
we have in the system, since inet_pton() requires a priori knowledge of the
address family.
This change also causes getaddrinfo() with NULL hint (expressly documented
as working) to work properly for numeric addresses.
 1.90.10.1 18-May-2008  yamt sync with head.
 1.91.8.2 19-Apr-2008  lukem Add a missing const.
 1.91.8.1 19-Apr-2008  lukem file getaddrinfo.c was added on branch christos-time_t on 2008-04-19 07:56:35 +0000
 1.91.6.2 23-Dec-2013  riz Apply patch (requested by bad in ticket #1887):

src/lib/libc/net/getaddrinfo.c r1.106:
this is supposed to be re-entrant, call don't call __hostalias that uses
a static buffer.

src/lib/libc/net/gethnamaddr.c r1.85:
- don't clobber hp in the RES_USE_INET6 case
- increment naddrs in the yp case
- don't use __hostalias(), it is not thread-safe.

This should finish addressing PR lib/46454
 1.91.6.1 26-Jan-2009  snj Pull up following revision(s) (requested by tls in ticket #306):
lib/libc/net/getaddrinfo.c: revision 1.92
Cause getaddrinfo() without socktype specification to work correctly for
numeric addresses. The documentation appears to say this works, and some
other systems support it -- more importantly, why should it _not_ work? If
it does not, getaddrinfo() cannot be used as a general-purpose textual to
binary address conversion utility function; yet it is the only such function
we have in the system, since inet_pton() requires a priori knowledge of the
address family.
This change also causes getaddrinfo() with NULL hint (expressly documented
as working) to work properly for numeric addresses.
 1.96.4.3 17-Nov-2015  bouyer Pull up following revision(s) (requested by christos in ticket #1340):
lib/libc/net/getnetnamadr.c: revision 1.43 via patch
lib/libc/net/getnetnamadr.c: revision 1.44 via patch
put the state back after it is used.
PR/50367: Stefan Schaeckeler: Apply fix to obey RES_CHECKNAME to getnetbyaddr
and getnetbyname.
 1.96.4.2 23-Dec-2013  riz Apply additional patches (requested by bad in ticket #975):

src/lib/libc/net/getaddrinfo.c r1.106:
this is supposed to be re-entrant, call don't call __hostalias that uses
a static buffer.

src/lib/libc/net/gethnamaddr.c r1.85:
- don't clobber hp in the RES_USE_INET6 case
- increment naddrs in the yp case
- don't use __hostalias(), it is not thread-safe.

Fixes additional issues in PR lib/46454
 1.96.4.1 03-Jun-2012  jdc Pull up revisions:
src/lib/libc/net/getaddrinfo.c revision 1.98 - 1.100
src/include/netdb.h revision 1.65
(requested by khorben in ticket #278).

Add AI_ADDRCONFIG, which makes getaddrinfo() return only address with
families
that are already configured in the system.

PR 46206: fix programmed SIGSEGV
more work is needed as tests seem to indicate that name resolution now
does no seem to work (firefox reports Server not found)
thanks to Ryo ONODERA for testing.

PR pkg/46206
re-establish fqdn lookup when AI_ADDRCONFIG is used in hints
AI_ADDRCONFIG led to fqdn lookup being skipped as the systems didn't
configure any PF_UNSPEC addresses - check was too strict here.
Thnaks to Ryo ONODERA for testing.
 1.96.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.96.2.2 30-Oct-2012  yamt sync with head
 1.96.2.1 17-Apr-2012  yamt sync with head
 1.101.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.101.2.1 23-Jun-2013  tls resync from head
 1.106.6.1 15-Jan-2016  sborrill Pull up to netbsd-7 (missing part of ticket #1012):
lib/libc/net/getaddrinfo.c 1.110
 1.106.4.1 15-Jan-2016  sborrill Pull up to netbsd-7 (missing part of ticket #1012):
lib/libc/net/getaddrinfo.c 1.110
 1.114.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.115.6.2 29-Nov-2020  martin Pull up following revision(s) (requested by is in ticket #1625):

lib/libc/net/getaddrinfo.c: revision 1.120
lib/libc/net/gethnamaddr.c: revision 1.93
include/arpa/nameser_compat.h: revision 1.8

Don't complain about additional DNAME records received when resolving A or
AAAA (like already done for SIG/KEY and CNAME).
 1.115.6.1 25-Oct-2017  snj Pull up following revision(s) (requested by jdolecek in ticket #317):
lib/libc/net/getaddrinfo.c: revision 1.116
lib/libc/resolv/res_mkquery.c: revision 1.16
PR/52578: Benjamin M. Schwartz Set the AD bit when DNSSEC is enabled
(RFC 6840 Section 5.7).
--
PR/52578: Benjamin M. Schwartz: sync the internal copy of res_nquery for
getaddrinfo, with the real version so that we handle EDNS fallback.
 1.117.4.1 10-Jun-2019  christos Sync with HEAD
 1.117.2.1 26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.119.2.1 29-Nov-2020  martin Pull up following revision(s) (requested by is in ticket #1135):

lib/libc/net/getaddrinfo.c: revision 1.120
lib/libc/net/gethnamaddr.c: revision 1.93
include/arpa/nameser_compat.h: revision 1.8

Don't complain about additional DNAME records received when resolving A or
AAAA (like already done for SIG/KEY and CNAME).
 1.95 10-Aug-2023  mrg avoid various use-after-free issues.

create a ptrdiff_t offset between the start of an allocation region and
some interesting pointer, so it can be adjusted with this offset after
realloc() returns.

found by GCC 12.
 1.94 19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.93 18-Nov-2020  is Don't complain about additional DNAME records received when resolving A or
AAAA (like already done for SIG/KEY and CNAME).
 1.92 22-Sep-2015  christos branches: 1.92.8; 1.92.18;
- fix various leaks on error
- don't use the wrong error variable in switch
- always set the error return code
- return consistent errors when the input data cannot be handled.
 1.91 19-Jun-2014  christos use fparseln() instead of abusing fgetln(), so that the last line that
might not have a terminating newline is processed.
 1.90 24-Jan-2014  christos branches: 1.90.2;
CID 1163170, 1164171, resource leak
CID 1161172 double free
 1.89 17-Jan-2014  drochner fix memory allocation, and an off-by-one
 1.88 17-Jan-2014  christos the addition is handled in the alias.
 1.87 17-Jan-2014  christos Move more code into the macro, and fix the bug where realloc would cause
a dangling pointer and memory corruption.
 1.86 16-Jan-2014  christos Remove MAXALIASES limit
 1.85 22-Dec-2013  christos - don't clobber hp in the RES_USE_INET6 case
- increment naddrs in the yp case
- don't use __hostalias(), it is not thread-safe.
 1.84 27-Aug-2013  christos move the host file getbyname and getbyaddr functions to sethostent.c so
that they are in a separate file from the dns ones in order for libhack
to use them.
 1.83 22-Aug-2013  christos get rid of bogus + 1
 1.82 19-Aug-2013  christos fix gethostbyaddr prototype per TOG.
 1.81 18-Aug-2013  christos appease lint.
 1.80 16-Aug-2013  christos Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3) so it is re-entrant (ahem __ypdomain). These
are not being advertised because there is a bunch of different
implementation of them that have a variety of type signatures.

If people want to follow someone's implementation, it is now easy.
 1.79 09-Sep-2012  christos branches: 1.79.2;
implement no-check-names
 1.78 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.77 15-Oct-2011  christos branches: 1.77.2; 1.77.4;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.76 29-Aug-2010  christos dprintf is claimed by posix.
 1.75 02-Oct-2009  wiz Revert a -> an changes: Adding an 'n' follows pronunciation, not writing.
 1.74 02-Oct-2009  cegger fix grammar: a -> an
 1.73 27-Jan-2007  christos branches: 1.73.18;
Appropriate versions are not supplied by bind anymore.
 1.72 27-Jan-2007  christos merge in resolver portion of bind-9.4.0-rc2
 1.71 15-Oct-2006  christos branches: 1.71.2; 1.71.4;
fix incomplete initializers
 1.70 22-Mar-2006  christos Coverity CID 2279: Plug memory leak.
 1.69 22-Mar-2006  christos Coverity CID 2280: Plug memory leak.
 1.68 24-Jan-2006  christos PR/32616: Yves-Emmanuel JUTARD: Fix compilation with -DDEBUG
 1.67 15-Sep-2005  tsarna Rest of fix for PR#31184: getaddrinfo() now honors resolv.conf sortlist
directive for dns answers.

Also, unifdef the RESLVSORT (non-)option sillyness.

Reviewed by christos.
 1.66 15-Sep-2005  tsarna Re-enable resolv.conf sortlist support in gethostbyname().

Fixes first part of PR#31184. addrsort() was not exposed to the rest of
libc as it turns out not to be usable for getaddrinfo(), so a different
sorter will be implemented for that.
 1.65 01-Jun-2005  lukem appease gcc -Wuninitialized
 1.64 23-Nov-2004  lukem Fix gethostent(3) (which was reenabled in rev 1.63) so that it actually
works by allowing _gethtent() to treat host.h_addrtype==0 && host.h_length==0
as "any address family" when parsing.
 1.63 17-Aug-2004  ginsbach Restore gethostent() as a supported interface. Yes, it maybe obsolete
but it is specified by IEEE Std 1003.1, 2004 Edition (POSIX) and
the X/Open standards (Issue 6 and XNS 5.2).

* revert change removing gethostent() from gethostbyname(3) man page
* delete kruft from gethnamaddr.c leaving only gethostent() as a
wrapper around _gethtent().
* revert recent changes to <netdb.h>
+ restore gethostent() prototype
+ restore freehostent() prototype; handle similar to non-shipped
getipnodby*() prototypes
+ use correct XOPEN_SOURCE version (520 not 500) for freeaddrinfo()
prototype; interface specified by XNS5.2 not XNS5

Reviewd by <christos> and <drochner>.
 1.62 21-Jul-2004  itojun now that e.f.f.3.ip6.arpa is ready, we no longer need to query ip6.int
 1.61 04-Jun-2004  ginsbach Change remaining K&R style function definition to ANSI; Reviewd by <christos>.
 1.60 23-May-2004  christos centralize res_*init() calls in __res_get_state()
 1.59 21-May-2004  christos Finish bind9 resolver merge.
 1.58 11-Oct-2003  enami branches: 1.58.2;
Back out rev. 1.56; `pointer points the byte just after the valid region'
is normal case. If the parser wants something more, there should be
another bounds check for it.
 1.57 03-Oct-2003  itojun paren around macro arg
 1.56 03-Oct-2003  itojun off-by-one. from millert@openbsd
 1.55 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.54 17-May-2003  itojun bound copies
 1.53 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.52 27-Aug-2002  itojun allocate 64K recieve buffer for DNS responses.
 1.51 22-Aug-2002  itojun drop AAAA reply with IPv4 mapped address. sync w/kame
draft-itojun-v6ops-v4mapped-harmful-00.txt
 1.50 16-Aug-2002  itojun set h_errno properly if internal string manipulation fails.
 1.49 16-Aug-2002  itojun eliminate sprintf, use snprintf. check strlcat error.
 1.48 29-Jul-2002  itojun query ip6.arpa then ip6.int for IPv6 reverse lookup. follows RFC3152.
 1.47 26-Jun-2002  itojun correct DIAGASSERT
 1.46 26-Jun-2002  itojun avoid remote buffer overrun on hostbuf[]. From: Joost Pol <joost@pine.nl>

correct bad practice in the code - it uses two changing variables
to manage buffer (buf and buflen). we eliminate buflen and use
fixed point (ep) as the ending pointer.

this fix is critical.
 1.45 26-Jun-2002  itojun do not pass uninitialized variable to nsdispatch().
 1.44 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.43 22-May-2002  itojun be picky about string manipulation in reverse lookups
 1.42 18-May-2002  itojun branches: 1.42.2;
style
 1.41 17-May-2002  itojun do not reverse-lookup scoped IPv6 address. it does not make sense as
there's no way to give scope identifier. sync w/kame
 1.40 26-Apr-2001  kleink Change the `len' arguemtn to gethostbyaddr(3) from int to socklen_t in
accordance with XNS5.2; fixes PR standards/12703.
 1.39 20-Dec-2000  christos branches: 1.39.2;
remove redundant declarations.
 1.38 04-Oct-2000  sommerfeld Varargsify dprintf to allow for format string checking
 1.37 30-Jul-2000  itojun on gethostby* with NIS backend, make a lookup against ipnodes.{byname,byaddr}
for non-IPv4 address. obeys solaris8 practice.

XXX does not support scoped address extension, as gethostby* are not
scope-aware. always use getaddrinfo/getnameinfo.
XXX it is not very useful at this moment, if you define multiple entries for
single hostname. see PR 10713 for detail.
 1.36 30-Jul-2000  itojun plug host_addrs overrun. rogue NIS server can transmit tons of lines,
effectively overrun host_addrs buffer.
 1.35 07-Jul-2000  itohy Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.
 1.34 06-Jul-2000  christos add CONSTCOND where appropriate
 1.33 23-May-2000  tron branches: 1.33.4;
Fix an alignment problem introduced by the patch for PR lib/8032.
Fixes PR lib/10048 by J.T. Conklin.
 1.32 25-Apr-2000  itojun sync with BIND 4.9.7. strict boundary checking.
 1.31 02-Apr-2000  christos Try to silence some of the lint warnings. Unfortunately we cannot fix
them all right now until we fix the ALIGN() macro to return u_long in
all the ports.
 1.30 22-Jan-2000  mycroft Delint.
 1.29 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.28 28-Dec-1999  assar ignore KEY and SIG records when matching responses to the query. we
get those as extras from DNSsec-enabled name servers.
 1.27 24-Oct-1999  lukem change default nsswitch.conf entry for `hosts' from:
hosts: dns files
to
hosts: files dns

this should speed things up a lot at boot if hostnames that are in
/etc/hosts are used for ifconfig, route, etc.
 1.26 20-Sep-1999  lukem branches: 1.26.2;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.25 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.24 09-Aug-1999  itojun do not make reverse query against IPv6 unspecified, or loopback addresses.

From: ume@mahoroba.org
 1.23 19-Jul-1999  christos - make sure that host_addr is suitably aligned
- add appropriate casts
- take out & in from array; it is meaningless
 1.22 19-Jul-1999  tron Make sure that "h_addr_list" pointers are longword aligned because some
broken applications depend on it. Fixes PR lib/8032 by David K Brownlee.
 1.21 06-Jul-1999  itojun fix name resolution problem when you have "hosts: files dns" on
/etc/nsswitch.conf.

This was because of two reasons:
- /etc/hosts lookup code damaged some of internal
state used by gethostbyname2().
- getaddrinfo() was not persistent enough against errors.

Sorry for the delay, and hope this fix all the following PRs
(I checked in my environment immitating those PRs and it worked for me)
PR: 7901, 7912, 7921
 1.20 04-Jul-1999  itojun check address family on getting entries from /etc/hosts.
 1.19 01-Jul-1999  itojun fix hardcoded T_A.
this fixes gethostbyname2(host, AF_INET6) to actually work.
 1.18 02-Jun-1999  tron As discussed on "tech-net@netbsd.org":
Enhance the file resolver to return all IP addresses of a host on a
call to gethostbyname().
 1.17 04-May-1999  christos Remove unused 'len' and the relevant gcc kludges.
 1.16 03-May-1999  christos Don't bother de-linting inside __GNUC__ ifdefs.
 1.15 18-Apr-1999  lukem specifically include stdarg/varargs.h
 1.14 20-Jan-1999  lukem branches: 1.14.2;
minor knf; don't exceed 80 columns ;)
 1.13 20-Jan-1999  christos add ARGSUSED
 1.12 19-Jan-1999  lukem constify ns_dtab defs
 1.11 19-Jan-1999  lukem convert to new nsdispatch(3). lookup defaults back to "dns files"
 1.10 18-Jan-1999  lukem before each call to nsdispatch(), set h_errno to NETDB_INTERNAL, and only
change to NETDB_SUCCESS if nsdispatch() returns NS_SUCCESS. it is up to the
internal methods to change h_errno from NETDB_INTERNAL to a more appropriate
value when an error is detected.
 1.9 16-Jan-1999  lukem pull nsswitch up to main branch
convert getnetby*() to nsswitch (from resolv.conf lookup)
 1.8 13-Nov-1998  christos delint
 1.7 15-Oct-1998  kleink branches: 1.7.2;
(bcmp(), bcopy(), bzero()) -> (memcmp(), memcpy(), memset())
 1.6 14-Oct-1998  kleink Since these files are shared with parts of the BIND-4 userland (outside libc),
do the internal symbol renaming dance only if inside the libc build environment.
 1.5 13-Oct-1998  kleink Need internal names for gethostby{addr,name}().
 1.4 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.3 31-Jul-1997  thorpej Bring over changes where were mistakenly committed to gethostnamadr.c:

date: 1997/07/21 14:07:54; author: jtc; state: Exp; lines: +3 -2
If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.2 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.1 20-Jul-1997  mrg branches: 1.1.1;
Initial revision
 1.1.1.2 25-Apr-2000  itojun BIND 4.9.7
 1.1.1.1 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.7.2.3 14-Jan-1999  lukem use new ns_dtab structure
 1.7.2.2 02-Nov-1998  lukem sync with current, assign my copyrights to TNF
 1.7.2.1 15-Oct-1998  lukem file gethnamaddr.c was added on branch lukem-nsswitch2 on 1998-11-02 03:29:36 +0000
 1.14.2.3 26-Jun-2002  he Pull up revisions 1.45-1.46 (via patch, requested by he):
Fix remote buffer overrun on hostbuf[]. Also fix up logic of
buffer handling.
 1.14.2.2 04-Aug-2000  he Pull up revision 1.36 (requested by itojun):
Prevent host_addrs overrun, possibly provoked by rogue NIS server.
 1.14.2.1 08-Jan-2000  he Pull up revision 1.28 (requested by assar):
Reduce superfluous warnings on replies from DNSSEC-enabled name
servers. Fixes PR#8779.
 1.26.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.33.4.9 25-Aug-2004  he Pull up revision 1.62 (via patch, requested by itojun in ticket #156):
No longer query ip6.int, since e.f.f.3.ip6.arpa is ready too.
 1.33.4.8 15-Apr-2004  msaitoh Pullup rev. 1.58 (requested by itojun in ticket #141):

Back out rev. 1.56; `pointer points the byte just after the valid
region' is normal case. If the parser wants something more, there
should be another bounds check for it.
 1.33.4.7 07-Apr-2004  jmc Pullup revs 1.56-1.57 (requested by itojun in ticket #102)

Fix off by one and other cleanups
 1.33.4.6 05-Sep-2002  itojun make diff smaller to 1.39
 1.33.4.5 05-Sep-2002  itojun backout change which shouldn't be committed (int/socklen_t change)
 1.33.4.4 04-Sep-2002  itojun lib/libc/net/getaddrinfo.c 1.56
lib/libc/net/res_mkquery.c 1.22
correct bad practice in the code - it uses two changing variables
to manage buffer (buf and buflen). we eliminate buflen and use
fixed point (ep) as the ending pointer.

lib/libc/net/getaddrinfo.c 1.50
remove redundant declarations of h_errno and __hostalias

lib/libc/net/getaddrinfo.c 1.52
make sure "qname" argument to getanswer() is properly given. from lukem

lib/libc/net/getaddrinfo.c 1.54
lib/libc/net/gethnamaddr.c 1.43,1.49-1.50
lib/libc/net/getnetnamadr.c 1.23
use snprintf, string manipulation cleanups

lib/libc/net/getaddrinfo.c 1.57-1.59
correct port range check and signed/unsigned mixup

lib/libc/net/getaddrinfo.c 1.60-1.61
lint clean

lib/libc/net/getaddrinfo.c 1.62
lib/libc/net/gethnamaddr.c 1.51
drop AAAA reply with IPv4 mapped address. sync w/kame
draft-itojun-v6ops-v4mapped-harmful-00.txt

lib/libc/net/getaddrinfo.c 1.63
lib/libc/net/gethnamaddr.c 1.52
lib/libc/net/getnetnamadr.c 1.24
allocate 64K recieve buffer for DNS responses.

lib/libc/net/gethnamaddr.c 1.38
Varargsify dprintf to allow for format string checking

lib/libc/net/gethnamaddr.c 1.39
lib/libc/net/getnetnamadr.c 1.20
remove redundant declarations.

lib/libc/net/gethnamaddr.c 1.41
do not reverse-lookup scoped IPv6 address. it does not make sense as
there's no way to give scope identifier. sync w/kame

lib/libc/net/gethnamaddr.c 1.42
style

lib/libc/net/gethnamaddr.c 1.45
do not pass uninitialized variable to nsdispatch().

lib/libc/net/gethnamaddr.c 1.48
query ip6.arpa then ip6.int for IPv6 reverse lookup. follows RFC3152.
 1.33.4.3 26-Jun-2002  he Pull up revision 1.47 (requested by itojun):
Correct usage of DIAGASSERT after recent change.
 1.33.4.2 26-Jun-2002  he Pull up revisions 1.45-1.46 (requested by itojun):
Fix remote buffer overrun on hostbuf[]. Also fix up logic of
buffer handling.
 1.33.4.1 30-Jul-2000  itojun pullup 1.35 -> 1.36 (approved by releng-1-5)

> plug host_addrs overrun. rogue NIS server can transmit tons of lines,
> effectively overrun host_addrs buffer.
 1.39.2.5 11-Nov-2002  nathanw Catch up to -current
 1.39.2.4 27-Aug-2002  nathanw Catch up to -current.
 1.39.2.3 01-Aug-2002  nathanw Catch up to -current.
 1.39.2.2 21-Jun-2002  nathanw Catch up to -current.
 1.39.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.42.2.13 22-Aug-2004  tron Pull up revision 1.62 via patch (requested by itojun in ticket #1731):
now that e.f.f.3.ip6.arpa is ready, we no longer need to query ip6.int
 1.42.2.12 11-Oct-2003  tron Pull up revision 1.58 (requested by bad in ticket #1521):
Back out rev. 1.56; `pointer points the byte just after the valid region'
is normal case. If the parser wants something more, there should be
another bounds check for it.
 1.42.2.11 04-Oct-2003  tron Pull up revision 1.57 (requested by itojun in ticket #1509):
paren around macro arg
 1.42.2.10 04-Oct-2003  tron Pull up revision 1.56 (requested by itojun in ticket #1509):
off-by-one. from millert@openbsd
 1.42.2.9 27-Aug-2002  lukem Pull up revision 1.52 (requested by itojun in ticket #735):
allocate 64K recieve buffer for DNS responses.
 1.42.2.8 24-Aug-2002  lukem Pull up revision 1.51 (requested by itojun in ticket #718):
drop AAAA reply with IPv4 mapped address. sync w/kame
draft-itojun-v6ops-v4mapped-harmful-00.txt
 1.42.2.7 17-Aug-2002  lukem Pull up revision 1.50 (requested by itojun in ticket #694):
set h_errno properly if internal string manipulation fails.
 1.42.2.6 17-Aug-2002  lukem Pull up revision 1.49 (requested by itojun in ticket #694):
eliminate sprintf, use snprintf. check strlcat error.
 1.42.2.5 29-Jul-2002  lukem Pull up revision 1.48 (requested by itojun in ticket #569):
query ip6.arpa then ip6.int for IPv6 reverse lookup. follows RFC3152.
 1.42.2.4 29-Jul-2002  lukem Pull up revision 1.43 (requested by lukem as a prerequisite for ticket #569):
be picky about string manipulation in reverse lookups
 1.42.2.3 26-Jun-2002  lukem Pull up revision 1.47 (requested by itojun in ticket #376):
correct DIAGASSERT
 1.42.2.2 26-Jun-2002  lukem Pull up revision 1.46 (requested by itojun in ticket #371):
avoid remote buffer overrun on hostbuf[]. From: Joost Pol <joost@pine.nl>
correct bad practice in the code - it uses two changing variables
to manage buffer (buf and buflen). we eliminate buflen and use
fixed point (ep) as the ending pointer.
this fix is critical.
 1.42.2.1 26-Jun-2002  lukem Pull up revision 1.45 (requested by itojun in ticket #371):
do not pass uninitialized variable to nsdispatch().
 1.58.2.3 29-Nov-2004  jmc Pullup rev 1.64 (requested by lukem in ticket #998)

Fix gethostent(3) (which was reenabled in rev 1.63) so that it actually
works by allowing _gethtent() to treat host.h_addrtype==0 && host.h_length==0
as "any address family" when parsing.
 1.58.2.2 11-Sep-2004  he Pull up revision 1.63 (via patch, requested by ginsbach in ticket #834):
Restore gethostent() as a supported interface. Yes, it
may be obsolete, but it is specified by IEEE Std 1003.1,
2004 Edition (POSIX) and the X/Open standards (Issue 66
and XNS 5.2).
 1.58.2.1 22-Aug-2004  tron Pull up revision 1.62 via patch (requested by itojun in ticket #775):
now that e.f.f.3.ip6.arpa is ready, we no longer need to query ip6.int
 1.71.4.1 03-Jun-2007  wrstuden Catch up with now-somewhat-dated netbsd-4. These changes took longer
than expected for me to actually get around to merging.
 1.71.2.1 17-May-2007  jdc Add missing BIND 9.4.x include file and library changes (requested by
tron in ticket #662).
 1.73.18.3 23-Dec-2013  riz Apply patch (requested by bad in ticket #1887):

src/lib/libc/net/getaddrinfo.c r1.106:
this is supposed to be re-entrant, call don't call __hostalias that uses
a static buffer.

src/lib/libc/net/gethnamaddr.c r1.85:
- don't clobber hp in the RES_USE_INET6 case
- increment naddrs in the yp case
- don't use __hostalias(), it is not thread-safe.

This should finish addressing PR lib/46454
 1.73.18.2 19-Dec-2013  bouyer Fix ticket 1887: fix gethostbyaddr prototype, second argument is socklen_t
not size_t.
 1.73.18.1 18-Dec-2013  bouyer Apply patch, requested by bad in ticket #1887:
lib/libc/net/gethnamaddr.c 1.79-1.82 via patch
lib/libc/net/getnameinfo.3 1.37-1.40 via patch
lib/libc/net/getnameinfo.c 1.4 via patch
lib/libc/net/hostent.h 1.1, 1.2 via patch
lib/libc/net/sethostent.c 1.17-1.19 via patch

Make getnameinfo(3) re-entrant (ahem __ypdomain).
Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3).
Implement no-check-names.
 1.77.4.3 21-Jun-2016  snj Pull up following revision(s) (requested by buhrow in ticket #1085):
src/lib/libc/net/gethnamaddr.c: patch
Fix parsing of /etc/hosts. PR lib/48926.
 1.77.4.2 23-Dec-2013  riz Apply additional patches (requested by bad in ticket #975):

src/lib/libc/net/getaddrinfo.c r1.106:
this is supposed to be re-entrant, call don't call __hostalias that uses
a static buffer.

src/lib/libc/net/gethnamaddr.c r1.85:
- don't clobber hp in the RES_USE_INET6 case
- increment naddrs in the yp case
- don't use __hostalias(), it is not thread-safe.

Fixes additional issues in PR lib/46454
 1.77.4.1 18-Dec-2013  bouyer Pullup the following revisions, requested by bad in ticket 975:
lib/libc/net/gethnamaddr.c 1.79-1.81, 1.84
lib/libc/net/getnameinfo.3 1.37-1.40
lib/libc/net/getnameinfo.c 1.51, 1.52, 1.54
lib/libc/net/hostent.h 1.1, 1.2
lib/libc/net/sethostent.c 1.17-1.19

Make getnameinfo(3) re-entrant (ahem __ypdomain).
Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3).
Implement no-check-names.
 1.77.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.77.2.2 30-Oct-2012  yamt sync with head
 1.77.2.1 17-Apr-2012  yamt sync with head
 1.79.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.90.2.1 10-Aug-2014  tls Rebase.
 1.92.18.1 29-Nov-2020  martin Pull up following revision(s) (requested by is in ticket #1135):

lib/libc/net/getaddrinfo.c: revision 1.120
lib/libc/net/gethnamaddr.c: revision 1.93
include/arpa/nameser_compat.h: revision 1.8

Don't complain about additional DNAME records received when resolving A or
AAAA (like already done for SIG/KEY and CNAME).
 1.92.8.1 29-Nov-2020  martin Pull up following revision(s) (requested by is in ticket #1625):

lib/libc/net/getaddrinfo.c: revision 1.120
lib/libc/net/gethnamaddr.c: revision 1.93
include/arpa/nameser_compat.h: revision 1.8

Don't complain about additional DNAME records received when resolving A or
AAAA (like already done for SIG/KEY and CNAME).
 1.30 04-Dec-2022  uwe Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.29 19-Aug-2013  christos fix gethostbyaddr prototype per TOG.
 1.28 07-Oct-2006  apb branches: 1.28.42; 1.28.48;
Clarify that gethostbyname and gethostbyname2 can deal with
string representations of numeric addresses. PR 28667
 1.27 17-Aug-2004  wiz Add commas in enumerations; drop trailing whitespace; bump date for previous.
 1.26 17-Aug-2004  ginsbach Restore gethostent() as a supported interface. Yes, it maybe obsolete
but it is specified by IEEE Std 1003.1, 2004 Edition (POSIX) and
the X/Open standards (Issue 6 and XNS 5.2).

* revert change removing gethostent() from gethostbyname(3) man page
* delete kruft from gethnamaddr.c leaving only gethostent() as a
wrapper around _gethtent().
* revert recent changes to <netdb.h>
+ restore gethostent() prototype
+ restore freehostent() prototype; handle similar to non-shipped
getipnodby*() prototypes
+ use correct XOPEN_SOURCE version (520 not 500) for freeaddrinfo()
prototype; interface specified by XNS5.2 not XNS5

Reviewd by <christos> and <drochner>.
 1.25 25-Jun-2004  wiz Sort sections.
 1.24 07-Aug-2003  agc branches: 1.24.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.23 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.22 02-Oct-2002  wiz function with n.
 1.21 07-Feb-2002  ross Generate <>& symbolically.
 1.20 16-Sep-2001  wiz Sort sections, sort SEE ALSO, and misc. fixes.
 1.19 26-Apr-2001  kleink Change the `len' arguemtn to gethostbyaddr(3) from int to socklen_t in
accordance with XNS5.2; fixes PR standards/12703.
 1.18 28-Feb-2001  itojun branches: 1.18.2;
it seems that gethostent(3) is no longer supplied in libc.
couple of wording corrections.
From: Hubert Feyrer <hubert.feyrer@informatik.fh-regensburg.de>
 1.17 24-Apr-2000  itojun add missing period.
 1.16 01-Jul-1999  itojun document gethostbyname2().
 1.15 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.14 18-Jan-1999  lukem highlight nsswitch.conf(5) in the first paragraph
 1.13 16-Jan-1999  lukem reference nsswitch.conf(5)
 1.12 28-Apr-1998  fair fix mdoc references
 1.11 05-Feb-1998  perry add LIBRARY section to man page
 1.10 02-Feb-1998  mrg merge in lite2 rcsids and a couple of man page fixes we had not yet found.
 1.9 08-Mar-1997  mouse branches: 1.9.2;
alternate -> alternative, per PR 2643
 1.8 09-Nov-1996  lukem add 'const' qualifiers to various routines (as per the include prototypes
and the implementation)
 1.7 30-Mar-1996  jtc Added explicit return types to all functions in SYNOPSIS section.
Added documentation to hstrerror() function.
Added hstrerror MLINK.
 1.6 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.5 07-Apr-1994  deraadt new resolver. changes from 4.9.2 by <paul@vix.com>, as well as a number
of features and optimizations by myself.
 1.4 12-Mar-1994  davidb h_errno is an int, not a "struct".
 1.3 11-Jan-1994  jtc Fix spelling errors.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 02-Feb-1998  mrg import lite-2 libc/net sources.
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.2.2 08-Mar-1997  mouse alternate -> alternative, per PR 2643
 1.9.2.1 08-Mar-1997  mouse file gethostbyname.3 was added on branch is-newarp on 1997-03-08 13:39:01 +0000
 1.18.2.4 18-Oct-2002  nathanw Catch up to -current.
 1.18.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.18.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.18.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.24.2.1 11-Sep-2004  he Pull up revisions 1.25-1.26 (requested by ginsbach in ticket #834):
Restore gethostent() as a supported interface. Yes, it
may be obsolete, but it is specified by IEEE Std 1003.1,
2004 Edition (POSIX) and the X/Open standards (Issue 66
and XNS 5.2).
 1.28.48.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.28.42.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.27 31-Jul-1997  thorpej This file was deleted with the last resolver merge, and mistakenly
brought back to life with the __weak_alias() commit.
 1.26 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.25 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.24 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.23 26-Apr-1997  mrg branches: 1.23.2;
handle hex hostnames (from vixie, as reported in PR#3535).
 1.22 14-Apr-1997  mrg oops; call getanswer correctly.
 1.21 13-Apr-1997  mrg re-add YP parts.
 1.20 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.19 31-Jan-1997  abrown Prevent buffer overflow (and thus return of bogus data) when a DNS record
has more than MAXADDRS "A" records for a host.

Patch from Paul A. Vixie <paul@vix.com>, slightly modified to fit in with
NetBSD debug framework.
 1.18 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.17 20-Dec-1996  cgd _gethtbyname's arg should be const char *, not char *
 1.16 18-Oct-1996  mrg branches: 1.16.2;
fix another bogon in last change; some changes derived from openbsd.
 1.15 14-Oct-1996  mrg fix bogon in last change.
 1.14 08-Oct-1996  mrg always update length; from vixie.
 1.13 21-May-1995  mycroft branches: 1.13.4; 1.13.6;
Use inet_aton(), not inet_addr().
 1.12 27-Feb-1995  cgd don't forget to take address before deref'ing thru. from fvdl.
 1.11 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.10 02-Nov-1994  deraadt another type change
 1.9 02-Nov-1994  deraadt one more u_long -> u_int32_t change
 1.8 15-Oct-1994  deraadt u_int_{16,32}_t stuff
 1.7 14-Apr-1994  deraadt set h_errno for non-BIND failed lookups too
 1.6 07-Apr-1994  deraadt new resolver. changes from 4.9.2 by <paul@vix.com>, as well as a number
of features and optimizations by myself.
 1.5 27-Feb-1994  deraadt fix bug where yp gethostby* lookups could have extra stuff in the alias
fields, and leave bogon stuff in the address fields...
 1.4 28-Jan-1994  deraadt support for lookup keyword in resolv.conf
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.4 02-Feb-1998  mrg import lite-2 libc/net sources.
 1.1.1.3 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.13.6.1 06-Dec-1996  rat Pullup request from matthew green <mrg@eterna.com.au>

>Fixes possible buffer overruns. Reported by vixie.
 1.13.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.16.2.1 06-Nov-1996  lukem initial nsswitch implementation
 1.23.2.2 26-May-1997  lukem only initialise elements in ns_dtab if it's not already been done
 1.23.2.1 24-May-1997  lukem * convert to using nsdispatch(). note: yp backends could be modified to
support IPv6 addresses...
* remove use of register
* convert bsd mem funcs into ansi mem funcs
 1.19 25-Oct-2017  abhinav Add freeifaddrs to the NAME section
 1.18 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.17 21-Sep-2016  roy Add ifa_addrflags to ifaddrs.
 1.16 23-Jan-2016  wiz branches: 1.16.2;
unsigned -> unsigned int
 1.15 23-Jan-2016  dholland Update synopses to match u_int/u_long/etc. changes. Do not bump date as
it's not a substantive change.
 1.14 07-Apr-2013  wiz Remove trailing whitespace.
 1.13 07-Apr-2013  christos Add a small example.
 1.12 22-Mar-2010  joerg branches: 1.12.6; 1.12.12;
Use .In for header files instead of .Ar Pa and variations.
 1.11 22-Apr-2009  wiz Mark up NULL. New sentence, new line. Bump date for previous.
 1.10 21-Apr-2009  dyoung For non-AF_LINK ifaddrs, ifa_data is NULL. AFAICT, this has always been
so. Say so in the documentation.
 1.9 11-Mar-2009  joerg Fix preamble
 1.8 16-Apr-2003  wiz branches: 1.8.38; 1.8.42; 1.8.46;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.7 07-Feb-2002  ross Generate <>& symbolically.
 1.6 16-Sep-2001  wiz Sort sections, sort SEE ALSO, and misc. fixes.
 1.5 16-Sep-2001  wiz Boring whitespace fixes.
 1.4 10-Apr-2001  wiz Fix date.
 1.3 21-Sep-2000  ad branches: 1.3.2;
Use .{B,Bs,F,N,O}x and fix miscellaneous errors.
 1.2 23-Feb-2000  itojun add freeifaddrs(), which reclaims region allocated by getifaddrs().
in sync with kame and bsdi.
 1.1 23-Feb-2000  itojun add getifaddrs(3) from bsdi4, as mentioned in tech-net (in SIOCGIFCONF
related thread).
this will save future apps from complexity of SIOCGIFCONF.

getifaddrs(3) does not use SIOCGIFCONF internally, it uses sysctl.
 1.3.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.3.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.3.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.8.46.1 21-Apr-2010  matt sync to netbsd-5
 1.8.42.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.8.38.1 03-May-2009  bouyer Pull up following revision(s) (requested by dyoung in ticket #730):
sbin/ifconfig/af_link.c: revisions 1.4 - 1.6
sbin/ifconfig/util.h: revision 1.7
sbin/ifconfig/util.c: revisions 1.10, 1.11
lib/libc/net/getifaddrs.c: revision 1.12
lib/libc/net/getifaddrs.3: revision 1.10
sbin/ifconfig/ifconfig.c: revisions 1.216 - 1.218
Fix indentation: change spaces to tabs.
Use getnameinfo(3) to render a human-readable link-layer address in the
'address: ' line, just as we do in the 'link xx:xx:...:xx' line.
There's no use casting a socket address to sockaddr_dl, only to cast it
back to sockaddr, so don't do it.
Cosmetic: add some whitespace for my ease of reading.
To make sure that we always print the active link-layer address in the
'address: ' field, don't treat the first address as the active address,
but search the link-layer addresses for the ones flagged IFLR_ACTIVE,
and print those. Extract a subroutine, print_link_addresses(), for
printing link-layer addresses.
For non-AF_LINK ifaddrs, ifa_data is NULL. AFAICT, this has always been
so. Say so in the documentation.
Bring getifaddrs(3) behavior in line with the documentation: the
ifa_data member of every AF_LINK struct ifaddrs points at the
corresponding struct if_data. In ifconfig(8), do not try to suppress
duplicate AF_LINK ifaddrs by checking for a NULL ifa_data.
Don't copy out two AF_LINK struct ifaddrs for each active link-layer
address. getifaddrs(3) used to copy out one ifaddrs for the kernel's
RTM_IFINFO message, and one more for the kernel's RTM_NEWADDR message.
I suppress the first duplicate with a highly conservative change that
wastes a little bit of ifaddrs storage. The storage is not leaked.
 1.12.12.1 23-Jun-2013  tls resync from head
 1.12.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.2.1 04-Nov-2016  pgoyette Sync with HEAD
 1.16 21-Sep-2016  roy Add ifa_addrflags to ifaddrs.
 1.15 13-Mar-2012  christos branches: 1.15.14;
PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.14 04-Feb-2011  matt branches: 1.14.4;
Use RT_ROUNDUP instead of a private copy since that's what the kernel uses.
(t_getaddrinfo passes for both i386 (compat_netbsd32) and amd64 with this
change).
 1.13 05-Nov-2010  pooka branches: 1.13.2;
Need getifaddrs() for the rump client since it executes sysctl(2)
 1.12 27-Apr-2009  dyoung Bring getifaddrs(3) behavior in line with the documentation: the
ifa_data member of every AF_LINK struct ifaddrs points at the
corresponding struct if_data. In ifconfig(8), do not try to suppress
duplicate AF_LINK ifaddrs by checking for a NULL ifa_data.

Don't copy out two AF_LINK struct ifaddrs for each active link-layer
address. getifaddrs(3) used to copy out one ifaddrs for the kernel's
RTM_IFINFO message, and one more for the kernel's RTM_NEWADDR message.
I suppress the first duplicate with a highly conservative change that
wastes a little bit of ifaddrs storage. The storage is not leaked.
 1.11 06-Dec-2007  dyoung branches: 1.11.12; 1.11.16; 1.11.20;
Use __arraycount().
 1.10 09-Aug-2002  itojun branches: 1.10.22;
lint clean
 1.9 09-Aug-2002  itojun unifdef for auditability.
 1.8 20-Aug-2001  itojun cope with sa_len < sizeof(struct sockaddr).
From: Patrik Lindergren <patrik@datacom.nu>
sync with kame
 1.7 04-Jan-2001  lukem branches: 1.7.2;
sprinkle _DIAGASSERT() around
 1.6 27-Oct-2000  itojun define HAVE_IFM_ADDRS for non-bsdi. sync with kame
 1.5 06-Jul-2000  christos - avoid non portable casts
- cast arguments to avoid promotion warnings
 1.4 24-Apr-2000  itojun add __RCSID().
 1.3 24-Apr-2000  itojun supply weak alias for IPv6-related library additions. sorry to be late.
 1.2 23-Feb-2000  itojun add freeifaddrs(), which reclaims region allocated by getifaddrs().
in sync with kame and bsdi.
 1.1 23-Feb-2000  itojun add getifaddrs(3) from bsdi4, as mentioned in tech-net (in SIOCGIFCONF
related thread).
this will save future apps from complexity of SIOCGIFCONF.

getifaddrs(3) does not use SIOCGIFCONF internally, it uses sysctl.
 1.7.2.2 13-Aug-2002  nathanw Catch up to -current.
 1.7.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.10.22.1 09-Jan-2008  matt sync with HEAD
 1.11.20.3 13-May-2010  matt Decode the routing message using the new RT_ROUNDUP alignment restrictions.
 1.11.20.2 11-May-2010  matt Use RT_ROUNDUP which will always do the right thing for alignment now.
 1.11.20.1 21-Apr-2010  matt sync to netbsd-5
 1.11.16.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.11.12.1 03-May-2009  bouyer Pull up following revision(s) (requested by dyoung in ticket #730):
sbin/ifconfig/af_link.c: revisions 1.4 - 1.6
sbin/ifconfig/util.h: revision 1.7
sbin/ifconfig/util.c: revisions 1.10, 1.11
lib/libc/net/getifaddrs.c: revision 1.12
lib/libc/net/getifaddrs.3: revision 1.10
sbin/ifconfig/ifconfig.c: revisions 1.216 - 1.218
Fix indentation: change spaces to tabs.
Use getnameinfo(3) to render a human-readable link-layer address in the
'address: ' line, just as we do in the 'link xx:xx:...:xx' line.
There's no use casting a socket address to sockaddr_dl, only to cast it
back to sockaddr, so don't do it.
Cosmetic: add some whitespace for my ease of reading.
To make sure that we always print the active link-layer address in the
'address: ' field, don't treat the first address as the active address,
but search the link-layer addresses for the ones flagged IFLR_ACTIVE,
and print those. Extract a subroutine, print_link_addresses(), for
printing link-layer addresses.
For non-AF_LINK ifaddrs, ifa_data is NULL. AFAICT, this has always been
so. Say so in the documentation.
Bring getifaddrs(3) behavior in line with the documentation: the
ifa_data member of every AF_LINK struct ifaddrs points at the
corresponding struct if_data. In ifconfig(8), do not try to suppress
duplicate AF_LINK ifaddrs by checking for a NULL ifa_data.
Don't copy out two AF_LINK struct ifaddrs for each active link-layer
address. getifaddrs(3) used to copy out one ifaddrs for the kernel's
RTM_IFINFO message, and one more for the kernel's RTM_NEWADDR message.
I suppress the first duplicate with a highly conservative change that
wastes a little bit of ifaddrs storage. The storage is not leaked.
 1.13.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.14.4.1 17-Apr-2012  yamt sync with head
 1.15.14.1 04-Nov-2016  pgoyette Sync with HEAD
 1.45 10-Sep-2024  rillig libc: new function parameter, new line
 1.44 16-Feb-2024  uwe branches: 1.44.2;
getnameinfo(3): fix/prettify markup
 1.43 15-Feb-2024  jkoshy Document the NI_NUMERICSCOPE flag.

PR lib/57832
 1.42 03-Jul-2017  wiz branches: 1.42.8; 1.42.16;
Remove workaround for ancient HTML generation code.
 1.41 18-Aug-2013  wiz branches: 1.41.18;
Update comment.
 1.40 18-Aug-2013  christos getnameinfo is now thread-safe so remove bugs section.
 1.39 26-Sep-2012  christos add and document AF_LOCAL (and the rest that were not)
 1.38 04-Mar-2012  christos branches: 1.38.2;
fix signature according to TOG.
 1.37 22-Mar-2010  joerg branches: 1.37.6; 1.37.8;
Use .In for header files instead of .Ar Pa and variations.
 1.36 21-Mar-2005  kleink branches: 1.36.26;
Only name <netdb.h> in the synopsis, like the old manual page used to.
 1.35 21-Mar-2005  kleink Add restrict qualifiers to getaddrinfo() and getnameinfo() arguments.
 1.34 12-Jan-2005  wiz branches: 1.34.2;
Use \*[Am] and \*[Gt], like before the previous revision; use .In; minor other changes.
 1.33 11-Jan-2005  itojun written-from-scratch manpage (fixes ISOC copyright violation)
 1.32 20-Dec-2004  christos revert previous change while discussion is in progress.
 1.31 20-Dec-2004  itojun RFC cannot be used as manpage regarding to the ISOC copyright boilerplate.
remove it until someone writes it up from scratch/freely-redistributable
text is found.
 1.30 07-Sep-2003  wiz Consistently use 'RFC 1234' instead of 'RFC1234' or 'RFC-1234'.
From jmc@openbsd.
 1.29 28-Aug-2003  wiz Nm -> Fn getnameinfo; grammar improvements; markup improvement;
all from jmc@openbsd, thanks.
 1.28 28-Aug-2003  wiz Bump date for CAVEATS; fix punctuation usage in one place;
drop trailing space; use \*[Am] instead of & for HTML generation.
 1.27 28-Aug-2003  itojun use NI_NUMERICHOST for 2nd invocation
 1.26 28-Aug-2003  itojun add int error in CAVEAT
 1.25 28-Aug-2003  itojun add CAVEATS section
 1.24 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.23 30-Apr-2003  itojun english grammer. by Jason McIntyre via kame
 1.22 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.21 22-May-2002  kleink Turn the flags argument to getnameinfo(3) back into an int (from unsigned
int); this is consistent with RFC2553, the current draft-ietf-ipngwg-
rfc2553bis-05 and the majority of deployed implementations.

Also, there is an effort under way to have this changed back to int in
XBD6/XSH6, XNS, and POSIX-2001 TC1.
 1.20 15-May-2002  kleink branches: 1.20.2;
<netdb.h> doesn't need prerequisite headers.
 1.19 14-May-2002  kleink More XNS5.2/POSIX-2001 alignment: change the flags argument to
getnameinfo() from int to unsigned int.
 1.18 14-May-2002  kleink Align with XNS5.2/POSIX-2001: change hostlen and servlen arguments to
getnameinfo() from size_t to socklen_t.
 1.17 07-Feb-2002  ross Generate <>& symbolically.
 1.16 15-Nov-2001  itojun sync with reality; scope identifier comes with the result even without
NI_WITHSCOPEID.
 1.15 16-Sep-2001  wiz Sort sections, sort SEE ALSO, and misc. fixes.
 1.14 05-Aug-2001  itojun there's no host.conf in netbsd. pointed out by smb
 1.13 29-Apr-2001  itojun copy-paste mistake; s/getaddrinfo/getnameinfo/
 1.12 05-Jan-2001  itojun branches: 1.12.2;
do not refer getnodebyaddr.
sync with latest kame.
 1.11 09-Aug-2000  itojun mention that current get{addr,name}info implementation are not thread-safe.
(sync with kame)
From: Greg Thompson
 1.10 30-Jun-2000  itojun typo in RFC number. KAME PR 263
 1.9 22-Jun-2000  itojun add cmetz paper, correct example
 1.8 04-Jun-2000  itojun branches: 1.8.2;
correct arg type (salen) to conform to RFC2553.
 1.7 11-May-2000  itojun branches: 1.7.2;
$NetBSD$
 1.6 11-May-2000  itojun update internet draft #. correct samples.
sync getnameinfo function prototype with /usr/include/netdb.h (not
standard conformant yet, needs update - will do soon)
 1.5 17-Jan-2000  itojun sync with latest KAME tree.
add example section to get{addr,name}info.
s/\.Os KAME/.Os/.
 1.4 07-Jan-2000  itojun need sys/types.h before sys/socket.h
 1.3 13-Dec-1999  itojun bring in latest KAME get{addr,name}info(3).
getnameinfo(3) globs ai_socktype and ai_protocol correctly.
KAME scopeid extension is implemented.
(draft-ietf-ipngwg-scopedaddr-format-00.txt)

bump up shlib minor
(may not be necessary, but rather big difference in behavior - especially
ai_flags)
 1.2 03-Jul-1999  kleink branches: 1.2.4;
Add missing LIBRARY sections.
 1.1 01-Jul-1999  itojun add IPv6 support functions.

get{addr,name} info are implemented to have as little impact to existing
resolver code as possible, so they are NOT the optimal implementation.
They are at this moment not very thread safe (as they call
gethostby{name,addr}).

(shlib minor version)++, as new interfaces are added.

TODO: getipnodeby{name,addr} - which needs total reimplementation of
gethostby{name,addr}.
upgrade rcmd.c for multiple af support (needed for IPv6-ready rsh/rlogin)
 1.2.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.7.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.8.2.3 10-Aug-2000  itojun pullup (approved by releng-1-5)
mention that current implementation is not thread-safe. (sync with kame)
From: Greg Thompson

getaddrinfo.3 1.15 -> 1.16
getnameinfo.3 1.10 -> 1.11
 1.8.2.2 03-Jul-2000  thorpej Pull up rev. 1.10:
typo in RFC number. KAME PR 263
 1.8.2.1 27-Jun-2000  thorpej Pull up rev. 1.9:
add cmetz paper, correct example
 1.12.2.5 21-Jun-2002  nathanw Catch up to -current.
 1.12.2.4 22-Mar-2002  nathanw Catch up to -current.
 1.12.2.3 08-Mar-2002  nathanw Catch up to -current.
 1.12.2.2 16-Nov-2001  thorpej Fix merge errors from last sync w/ -current.
 1.12.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.20.2.1 25-May-2002  thorpej Resolve pullup-1-6 ticket #14 (itojun), original commit message:

> Turn the flags argument to getnameinfo(3) back into an int (from unsigned
> int); this is consistent with RFC2553, the current draft-ietf-ipngwg-
> rfc2553bis-05 and the majority of deployed implementations.
>
> Also, there is an effort under way to have this changed back to int in
> XBD6/XSH6, XNS, and POSIX-2001 TC1.
 1.34.2.2 21-Mar-2005  tron Pull up revision 1.36 (requested by kleink in ticket #41):
Only name <netdb.h> in the synopsis, like the old manual page used to.
 1.34.2.1 21-Mar-2005  tron Pull up revision 1.35 (requested by kleink in ticket #40):
Add restrict qualifiers to getaddrinfo() and getnameinfo() arguments.
 1.36.26.1 18-Dec-2013  bouyer Apply patch, requested by bad in ticket #1887:
lib/libc/net/gethnamaddr.c 1.79-1.82 via patch
lib/libc/net/getnameinfo.3 1.37-1.40 via patch
lib/libc/net/getnameinfo.c 1.4 via patch
lib/libc/net/hostent.h 1.1, 1.2 via patch
lib/libc/net/sethostent.c 1.17-1.19 via patch

Make getnameinfo(3) re-entrant (ahem __ypdomain).
Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3).
Implement no-check-names.
 1.37.8.1 18-Dec-2013  bouyer Pullup the following revisions, requested by bad in ticket 975:
lib/libc/net/gethnamaddr.c 1.79-1.81, 1.84
lib/libc/net/getnameinfo.3 1.37-1.40
lib/libc/net/getnameinfo.c 1.51, 1.52, 1.54
lib/libc/net/hostent.h 1.1, 1.2
lib/libc/net/sethostent.c 1.17-1.19

Make getnameinfo(3) re-entrant (ahem __ypdomain).
Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3).
Implement no-check-names.
 1.37.6.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.37.6.2 30-Oct-2012  yamt sync with head
 1.37.6.1 17-Apr-2012  yamt sync with head
 1.38.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.41.18.1 10-Mar-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1941):

lib/libc/net/getnameinfo.3: revision 1.43

Document the NI_NUMERICSCOPE flag.
PR lib/57832
 1.42.16.1 10-Mar-2024  martin Pull up following revision(s) (requested by riastradh in ticket #614):

lib/libc/net/getnameinfo.3: revision 1.43

Document the NI_NUMERICSCOPE flag.
PR lib/57832
 1.42.8.1 10-Mar-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1808):

lib/libc/net/getnameinfo.3: revision 1.43

Document the NI_NUMERICSCOPE flag.
PR lib/57832
 1.44.2.1 02-Aug-2025  perseant Sync with HEAD
 1.60 08-Sep-2023  christos PR/57609: Carl Engvall: Add salen checks but accept larger sizes
(upto sockaddr_storage)
 1.59 22-Sep-2015  christos branches: 1.59.8; 1.59.18; 1.59.26;
be more forgiving, and don't abort on unexpected errors.
 1.58 22-Sep-2015  christos Handle herrors properly so that postfix can return 4XX codes when appropriate.
Pointed out by Viktor Dukhovni.
 1.57 03-Sep-2015  christos PR/50195: Henning Petersen: Incorrect check in getnameinfo_link.
 1.56 15-May-2015  joerg Don't create a weak alias in the !RUMPACTION case.
 1.55 15-May-2015  ozaki-r Fix rump.{netstat,route} shows host's interface names in link local addresses

Interface names of IPv6 link local addresses are resolved
by getnameinfo(3). So we need to rump-ify it as well as
if_indextoname and getifaddrs.
 1.54 16-Aug-2013  christos Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3) so it is re-entrant (ahem __ypdomain). These
are not being advertised because there is a bunch of different
implementation of them that have a variety of type signatures.

If people want to follow someone's implementation, it is now easy.
 1.53 26-Sep-2012  christos add and document AF_LOCAL (and the rest that were not)
 1.52 20-Mar-2012  matt branches: 1.52.2;
Use C89 Prototypes.
Remove use of __P
 1.51 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.50 29-Jun-2010  seanb branches: 1.50.6; 1.50.8;
- remove extra len check as per discussion on tech-net.
 1.49 29-Jan-2010  is Print AppleTalk phase 2 range, too, if available.
 1.48 26-Jan-2010  is Add AF_APPLETALK support to getnameinfo(); make "route show" use it.
Doesn't print "ranges" yet (should it be done here?); only numeric
output.
 1.47 12-Aug-2009  seanb Watch getservbyport_r() semantics. sv needs scope
while results are being looked at which in turn
are no longer valid after a endservent_r().
 1.46 11-Feb-2009  lukem sign-compare fix
 1.45 15-Oct-2006  christos branches: 1.45.24; 1.45.28;
fix incomplete initializers
 1.44 24-Aug-2006  christos use the re-entrant version of getservbyport.
 1.43 17-Feb-2006  ginsbach Return EAI_OVERFLOW instead of EAI_MEMORY when the supplied buffer is
too short. This conforms to RFC3493, POSIX and XPG6. [from KAME]
 1.42 29-Nov-2005  christos WARNS=4
 1.41 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings. Catch error conditions
from snprintf().
 1.40 27-Jun-2002  itojun correct %d/%u mixup.
 1.39 22-May-2002  kleink Turn the flags argument to getnameinfo(3) back into an int (from unsigned
int); this is consistent with RFC2553, the current draft-ietf-ipngwg-
rfc2553bis-05 and the majority of deployed implementations.

Also, there is an effort under way to have this changed back to int in
XBD6/XSH6, XNS, and POSIX-2001 TC1.
 1.38 22-May-2002  itojun use strlcpy, not strcpy
 1.37 14-May-2002  kleink branches: 1.37.2;
More XNS5.2/POSIX-2001 alignment: change the flags argument to
getnameinfo() from int to unsigned int.
 1.36 14-May-2002  kleink Align with XNS5.2/POSIX-2001: change hostlen and servlen arguments to
getnameinfo() from size_t to socklen_t.
 1.35 04-Mar-2002  sommerfeld More ipip references
 1.34 15-Nov-2001  itojun make NI_WITHSCOPEID a default (always on), to synchronize with recent 2553bis.
sync with kame.
 1.33 15-Nov-2001  itojun synchronize with kame better. get rid of #defines for ENI_xx.
 1.32 06-Oct-2001  bjh21 Put back AF_LINK support. This time, all the new code passes lint(1), modulo
bin/14175. It should pass lint on a native i386 build, but I can't test that.
 1.31 05-Oct-2001  bjh21 Remove AF_LINK support. It generates lint warnings, and hence won't compile
on i386. I'll re-commit once I've understood and fixed the problems.
 1.30 05-Oct-2001  itojun make it at least compile (there's no /usr/include/net/if_ieee1394.h exist).
avoid overrun with snprintf. be careful about snprintf return value.
 1.29 04-Oct-2001  bjh21 Extend getnameinfo() to support AF_LINK sockaddrs. The intention is that
anything that wants to print a link-layer address should go through here,
rather than re-inventing the wheel.
 1.28 19-Aug-2001  itojun snprintf return value audit. inspired by deraadt
 1.27 26-Apr-2001  kleink Fix previous rev. the right way, using socklen_t.
 1.26 26-Apr-2001  tron Fix lint problem caused by the changes for PR standards/12703.
 1.25 25-Jan-2001  jdolecek branches: 1.25.2;
make local constant arrays const
 1.24 04-Jan-2001  lukem sprinkle _DIAGASSERT() around
 1.23 25-Sep-2000  itojun remove merge error from kame.
 1.22 25-Sep-2000  itojun off-by-1 error in string length validation.
From: Pavel Kankovsky <peak@argo.troja.mff.cuni.cz>
 1.21 07-Aug-2000  itojun sync comment with reality. from kame
 1.20 06-Jul-2000  christos - remove unused vars
- fix non-portable casts
 1.19 12-Jun-2000  itojun branches: 1.19.2;
correct ENI_SALEN case to meet rfc2553bis.
 1.18 12-Jun-2000  itojun correct return value from getnameinfo to meet rf2553bis.
(this also corrects incorrect "success" value, 0, on invalid sockaddr)
 1.17 04-Jun-2000  itojun correct arg type for getnameinfo(3) for RFC2553 conformance.
 1.16 26-Apr-2000  itojun branches: 1.16.2;
bring in latest KAME implementation.
conforms to draft-ietf-ipngwg-scopedaddr-format-01.txt.
behavior change: returns numeric scopeid if we can't convert to string.
removed #if 0'ed portion which we will never revisit.
 1.15 24-Apr-2000  itojun add __RCSID().
 1.14 24-Apr-2000  itojun supply weak alias for IPv6-related library additions. sorry to be late.
 1.13 17-Mar-2000  christos make this compile on non 4.4BSD systems
 1.12 17-Feb-2000  itojun to synchronize with progress of discussion for post
draft-ietf-ipngwg-scopedaddr-format-00.txt (will be 01),
use "address%interface" notation for extended scoped IPv6 address.

NOTE: the change affects link-local addresses only. I hope it to be
the final change on it.....
 1.11 16-Feb-2000  itojun preparation to flip extended scoped address syntax.

the specification is still under debate; there is high possibility that
"fe80::1%de0" will be the finalist but i'm not sure yet.
 1.10 09-Feb-2000  itojun revise extended scoped address format support. delimiter and the order
is changed, based on discussion in ipngwg scoped address cabal.
past code: fe80::1@de0
now: de0%fe80::1
this will be in sync with next extended address format proposal
(which should be final - I don't want to make this kind of change again).
 1.9 22-Jan-2000  mycroft Partially delint.
 1.8 17-Jan-2000  itojun remove #if 0'ed sections.
 1.7 05-Jan-2000  itojun allow reverse query for v4 loopbacknet (127.0.0.0/8).
 1.6 13-Dec-1999  itojun fix getaddrinfo(3) and getnameinfo(3).

getaddrinfo(3): result from gethostby* will be broken if we call it again.
deep-copy them. we have sa_len so configure them.
getnameinfo(3): we have sa_len so configure them.
 1.5 13-Dec-1999  itojun bring in latest KAME get{addr,name}info(3).
getnameinfo(3) globs ai_socktype and ai_protocol correctly.
KAME scopeid extension is implemented.
(draft-ietf-ipngwg-scopedaddr-format-00.txt)

bump up shlib minor
(may not be necessary, but rather big difference in behavior - especially
ai_flags)
 1.4 22-Aug-1999  kleink branches: 1.4.4;
Need "namespace.h".
 1.3 01-Aug-1999  itojun - provide reverse query for mapped address (::ffff:10.1.1.1).
- NI_NUMERICHOST and NI_HOSTREQD conflict with each other,
so bark if there are both.
(sync with recent KAME)
 1.2 04-Jul-1999  itojun add NetBSD RCSID on top.
 1.1 01-Jul-1999  itojun add IPv6 support functions.

get{addr,name} info are implemented to have as little impact to existing
resolver code as possible, so they are NOT the optimal implementation.
They are at this moment not very thread safe (as they call
gethostby{name,addr}).

(shlib minor version)++, as new interfaces are added.

TODO: getipnodeby{name,addr} - which needs total reimplementation of
gethostby{name,addr}.
upgrade rcmd.c for multiple af support (needed for IPv6-ready rsh/rlogin)
 1.4.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.16.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.19.2.1 25-Sep-2000  itojun pullup 1.21 -> 1.23 (approved by releng-1-5)

> off-by-1 error in string length validation.
> From: Pavel Kankovsky <peak@argo.troja.mff.cuni.cz>
 1.25.2.8 11-Nov-2002  nathanw Catch up to -current
 1.25.2.7 01-Aug-2002  nathanw Catch up to -current.
 1.25.2.6 21-Jun-2002  nathanw Catch up to -current.
 1.25.2.5 22-Mar-2002  nathanw Catch up to -current.
 1.25.2.4 08-Mar-2002  nathanw Catch up to -current.
 1.25.2.3 16-Nov-2001  thorpej Fix merge errors from last sync w/ -current.
 1.25.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.25.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.37.2.2 29-May-2002  tv Pull up revision 1.38 (requested by tv in ticket #66):
use strlcpy, not strcpy
 1.37.2.1 25-May-2002  thorpej Resolve pullup-1-6 ticket #14 (itojun), original commit message:

> Turn the flags argument to getnameinfo(3) back into an int (from unsigned
> int); this is consistent with RFC2553, the current draft-ietf-ipngwg-
> rfc2553bis-05 and the majority of deployed implementations.
>
> Also, there is an effort under way to have this changed back to int in
> XBD6/XSH6, XNS, and POSIX-2001 TC1.
 1.45.28.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.45.24.1 18-Dec-2013  bouyer Apply patch, requested by bad in ticket #1887:
lib/libc/net/gethnamaddr.c 1.79-1.82 via patch
lib/libc/net/getnameinfo.3 1.37-1.40 via patch
lib/libc/net/getnameinfo.c 1.4 via patch
lib/libc/net/hostent.h 1.1, 1.2 via patch
lib/libc/net/sethostent.c 1.17-1.19 via patch

Make getnameinfo(3) re-entrant (ahem __ypdomain).
Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3).
Implement no-check-names.
 1.50.8.1 18-Dec-2013  bouyer Pullup the following revisions, requested by bad in ticket 975:
lib/libc/net/gethnamaddr.c 1.79-1.81, 1.84
lib/libc/net/getnameinfo.3 1.37-1.40
lib/libc/net/getnameinfo.c 1.51, 1.52, 1.54
lib/libc/net/hostent.h 1.1, 1.2
lib/libc/net/sethostent.c 1.17-1.19

Make getnameinfo(3) re-entrant (ahem __ypdomain).
Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3).
Implement no-check-names.
 1.50.6.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.50.6.2 30-Oct-2012  yamt sync with head
 1.50.6.1 17-Apr-2012  yamt sync with head
 1.52.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.52.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.59.26.1 10-Mar-2024  martin Pull up following revision(s) (requested by riastradh in ticket #612):

lib/libc/net/getnameinfo.c: revision 1.60

PR/57609: Carl Engvall: Add salen checks but accept larger sizes
(upto sockaddr_storage)
 1.59.18.1 10-Mar-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1806):

lib/libc/net/getnameinfo.c: revision 1.60

PR/57609: Carl Engvall: Add salen checks but accept larger sizes
(upto sockaddr_storage)
 1.59.8.1 10-Mar-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1939):

lib/libc/net/getnameinfo.c: revision 1.60

PR/57609: Carl Engvall: Add salen checks but accept larger sizes
(upto sockaddr_storage)
 1.14 16-Jan-1999  lukem pull nsswitch up to main branch
convert getnetby*() to nsswitch (from resolv.conf lookup)
 1.13 14-Oct-1998  kleink Need "namespace.h" for internal {end,get,set}netent() names.
 1.12 30-Mar-1998  kleink Need <stddef.h> for NULL definition.
 1.11 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.10 31-Jul-1997  thorpej Fix lossage caused by the __weak_alias() commit. The namespace protection
does NOT belong here; these implement the file lookups, and are internal
functions only. As such, use "__foo" rather than "_foo" in the names, to
avoid confusion.
 1.9 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.8 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.7 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.6 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.5 02-Feb-1996  mrg branches: 1.5.2;
merge with the resolver in bind 4.9.3-P1.
 1.4 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.5 02-Feb-1998  mrg import lite-2 libc/net sources.
 1.1.1.4 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.3 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.12 16-Jan-1999  lukem pull nsswitch up to main branch
convert getnetby*() to nsswitch (from resolv.conf lookup)
 1.11 14-Oct-1998  kleink Need "namespace.h" for internal {end,get,set}netent() names.
 1.10 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.9 31-Jul-1997  thorpej Fix lossage caused by the __weak_alias() commit. The namespace protection
does NOT belong here; these implement the file lookups, and are internal
functions only. As such, use "__foo" rather than "_foo" in the names, to
avoid confusion.
 1.8 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.7 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.6 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.5 02-Feb-1996  mrg branches: 1.5.2;
merge with the resolver in bind 4.9.3-P1.
 1.4 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.4 02-Feb-1998  mrg import lite-2 libc/net sources.
 1.1.1.3 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.17 04-Dec-2022  uwe Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.16 21-Feb-2018  uwe Consistenly use "host byte order".
 1.15 21-Feb-2018  wiz Fix endnetent prototype. Fix NULL. New sentence, new line.
 1.14 21-Feb-2018  kamil Improve the getnetent(3) man-page

Document return type of setnetent(3) and endnetent(3). Both "void".

Sponsored by <The NetBSD Foundation>
 1.13 08-May-2004  kleink struct netnet.n_net used to be an unsigned long integer.

In XNS5, and subsequently in POSIX-2001 it was changed to socklen_t.

To accomodate for this while preserving binary compatibility with the
old interface, prepend or append 32 bits of padding, depending on
the (LP64 data model) architecture's endianness. Fixes PR
standards/21411 from Ben Harris.

This should be deleted the next time the libc major number is
incremented.

Also, update getnetbyaddr(3)'s `net' argument accordingly.
 1.12 07-Aug-2003  agc branches: 1.12.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.10 07-Feb-2002  ross Generate <>& symbolically.
 1.9 16-Sep-2001  wiz Boring whitespace fixes.
 1.8 22-Mar-1999  garbled branches: 1.8.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.7 16-Jan-1999  lukem reference nsswitch.conf(5)
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 08-Mar-1997  mouse branches: 1.5.2;
alternate -> alternative, per PR 2643
 1.4 09-Nov-1996  lukem add 'const' qualifiers to various routines (as per the include prototypes
and the implementation)
 1.3 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.2 08-Mar-1997  mouse alternate -> alternative, per PR 2643
 1.5.2.1 08-Mar-1997  mouse file getnetent.3 was added on branch is-newarp on 1997-03-08 13:39:40 +0000
 1.8.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.8.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.8.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.12.4.1 05-Jul-2005  riz Pull up revision 1.13 (requested by kleink in ticket #2015):
struct netent.n_net used to be an unsigned long integer.
In XNS5, and subsequently in POSIX-2001 it was changed to socklen_t.
To accomodate for this while preserving binary compatibility with the
old interface, prepend or append 32 bits of padding, depending on
the (LP64 data model) architecture's endianness. Fixes PR
standards/21411 from Ben Harris.
This should be deleted the next time the libc major number is
incremented.
Also, update getnetbyaddr(3)'s `net' argument accordingly.
 1.22 05-Jun-2020  nia Remove more bogus tests for 64-bit i386 and SuperH.

These are always false.
 1.21 20-Mar-2012  matt Use C89 Prototypes.
Remove use of __P
 1.20 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.19 15-Oct-2011  christos branches: 1.19.2;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.18 27-Jan-2007  christos Appropriate versions are not supplied by bind anymore.
 1.17 27-Jan-2007  christos merge in resolver portion of bind-9.4.0-rc2
 1.16 08-May-2004  kleink branches: 1.16.10; 1.16.12;
struct netnet.n_net used to be an unsigned long integer.

In XNS5, and subsequently in POSIX-2001 it was changed to socklen_t.

To accomodate for this while preserving binary compatibility with the
old interface, prepend or append 32 bits of padding, depending on
the (LP64 data model) architecture's endianness. Fixes PR
standards/21411 from Ben Harris.

This should be deleted the next time the libc major number is
incremented.

Also, update getnetbyaddr(3)'s `net' argument accordingly.
 1.15 07-Aug-2003  agc branches: 1.15.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 25-Apr-2000  itojun sync with BIND 4.9.7. mostly costmetic.
 1.13 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.12 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.11 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.10 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.9 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.8 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.7 16-Feb-1996  mrg branches: 1.7.2;
re-apply patch from 2 revisions ago
 1.6 02-Feb-1996  mrg merge with the resolver in bind 4.9.3-P1.
 1.5 14-Jan-1996  ghudson Don't read the network address as an alias when there isn't whitespace
after the network address. Closes PR 1940.
 1.4 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.6 25-Apr-2000  itojun BIND 4.9.7
 1.1.1.5 02-Feb-1998  mrg import lite-2 libc/net sources.
 1.1.1.4 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.3 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.15.4.1 05-Jul-2005  riz Pull up revision 1.16 (requested by kleink in ticket #2015):
struct netent.n_net used to be an unsigned long integer.
In XNS5, and subsequently in POSIX-2001 it was changed to socklen_t.
To accomodate for this while preserving binary compatibility with the
old interface, prepend or append 32 bits of padding, depending on
the (LP64 data model) architecture's endianness. Fixes PR
standards/21411 from Ben Harris.
This should be deleted the next time the libc major number is
incremented.
Also, update getnetbyaddr(3)'s `net' argument accordingly.
 1.16.12.1 03-Jun-2007  wrstuden Catch up with now-somewhat-dated netbsd-4. These changes took longer
than expected for me to actually get around to merging.
 1.16.10.1 17-May-2007  jdc Add missing BIND 9.4.x include file and library changes (requested by
tron in ticket #662).
 1.19.2.1 17-Apr-2012  yamt sync with head
 1.45 05-Jun-2020  nia Remove more bogus tests for 64-bit i386 and SuperH.

These are always false.
 1.44 26-Oct-2015  christos put the state back after it is used.
 1.43 26-Oct-2015  christos PR/50367: Stefan Schaeckeler: Apply fix to obey RES_CHECKNAME to getnetbyaddr
and getnetbyname.
 1.42 13-Mar-2012  christos branches: 1.42.10; 1.42.12;
PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.41 18-May-2008  lukem branches: 1.41.2; 1.41.6; 1.41.22;
Fix possible memory leak in error path.
Part of PR 38677.
 1.40 08-May-2008  lukem Convert getnetbyname(3) and getnetbyaddr(3) to the more "standard"
nsdispatch() backend method API.
 1.39 08-May-2008  lukem Fix a misuse of an automatic as a static that was exposed by the previous.
 1.38 08-May-2008  lukem Fix DNS getnetbyname(), which has been broken for at least 5.5 years
(if not longer).
 1.37 27-Jan-2007  christos branches: 1.37.10; 1.37.12;
Appropriate versions are not supplied by bind anymore.
 1.36 27-Jan-2007  christos merge in resolver portion of bind-9.4.0-rc2
 1.35 15-Oct-2006  christos branches: 1.35.2; 1.35.4;
fix incomplete initializers
 1.34 18-Sep-2006  tsutsui Change type of `net' variable passed via va_list in
_{files,dns,yp}_getenetbyaddr() functions from unsigned long to uint32_t.
In rev 1.29, getnetbyaddr(3) was changed to take uint32_t `net' argument
and also passisng uint32_t `net' to nsdispatch(3) varargs, but
these callback functions were not changed accordingly.

Patch was provided by christos, and this fixes amd(8) coredumps on alpha
when /etc/nsswitch.conf has more than one sources for netgroups.
 1.33 17-Mar-2006  ginsbach branches: 1.33.2;
Fix Coverity issue 2281, resource leak, function return without freeing
dynamically allocated storage.
 1.32 01-Jun-2005  lukem Move the test for "more strict reverse lookup handling" to the correct
location so that an uninitialized `in' won't be used if net_i == BYADDR.
Detected with gcc -Wuninitialized, confirmed by diffing against BIND 4.9.11.
(The bug was introduced in rev 1.26. Hi Itojun! :)
 1.31 23-May-2004  christos branches: 1.31.2;
centralize res_*init() calls in __res_get_state()
 1.30 21-May-2004  christos Finish bind9 resolver merge.
 1.29 08-May-2004  kleink struct netnet.n_net used to be an unsigned long integer.

In XNS5, and subsequently in POSIX-2001 it was changed to socklen_t.

To accomodate for this while preserving binary compatibility with the
old interface, prepend or append 32 bits of padding, depending on
the (LP64 data model) architecture's endianness. Fixes PR
standards/21411 from Ben Harris.

This should be deleted the next time the libc major number is
incremented.

Also, update getnetbyaddr(3)'s `net' argument accordingly.
 1.28 29-Jan-2004  lukem branches: 1.28.4;
Use the correct parameters when building the YP map name in _yp_getnetbyaddr().
Fixes getnetbyaddr() when reading from YP. From Brian Ginsbach in email.
 1.27 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.26 14-Nov-2002  itojun pull in changes in http://www.isc.org/products/BIND/patches/bind4910.diff
- better error check on __dn_skipname
- more strict reverse lookup handling
 1.25 13-Nov-2002  itojun fix remote buffer overrun. from openbsd tree (1997).
 1.24 27-Aug-2002  itojun allocate 64K recieve buffer for DNS responses.
 1.23 16-Aug-2002  itojun eliminate sprintf, use snprintf. check strlcat error.
 1.22 26-Jun-2002  itojun avoid remote buffer overrun on hostbuf[]. From: Joost Pol <joost@pine.nl>

correct bad practice in the code - it uses two changing variables
to manage buffer (buf and buflen). we eliminate buflen and use
fixed point (ep) as the ending pointer.

this fix is critical.
 1.21 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.20 20-Dec-2000  christos branches: 1.20.2; 1.20.4;
remove redundant declarations.
 1.19 22-Jan-2000  mycroft branches: 1.19.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.18 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.17 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.16 04-May-1999  kleink Use a _files prefix for local backend routines; would clash with namespace.h
otherwise.
 1.15 03-May-1999  christos sprinkle argsused till lint smiles at you.
 1.14 18-Apr-1999  lukem specifically include stdarg/varargs.h
 1.13 20-Jan-1999  christos branches: 1.13.2;
add ARGSUSED
 1.12 19-Jan-1999  lukem constify ns_dtab defs
 1.11 19-Jan-1999  lukem convert to new nsdispatch(3)
 1.10 19-Jan-1999  lukem support nis lookups for getnetby*()
 1.9 16-Jan-1999  lukem remove unused vars. remove register
 1.8 16-Jan-1999  lukem pull nsswitch up to main branch
convert getnetby*() to nsswitch (from resolv.conf lookup)
 1.7 05-Dec-1998  pk Check the results of argument decomposition in octets to prevent
garbage being sent to name servers.
 1.6 13-Nov-1998  christos delint
 1.5 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.4 19-Aug-1997  mikel sync __getnetbyaddr() prototypes with the one in getnetbyaddr.c; from
Krister Walfridsson in PR lib/4009
 1.3 31-Jul-1997  thorpej - Add __weak_alias() namespace protection and update for changes to
getnetnyname.c and getnetbyaddr.c.
- Now that getnetbyname() and getnetbyaddr() support looking up their
entries via BIND (they were previously file-only), add "lookup ..."
dispatch support (in /etc/resolv.conf), a'la gethostby*().
 1.2 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.1 20-Jul-1997  mrg branches: 1.1.1;
Initial revision
 1.1.1.1 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.13.2.1 26-Jun-2002  he Pull up revision 1.22 (requested by he):
Fix remote buffer overrun on hostbuf[]. Also fix up logic of
buffer handling.
 1.19.4.4 14-Nov-2002  itojun lib/libc/net/getnetnamadr.c 1.25-1.26

Fix remote buffer overrun.

(itojun)
 1.19.4.3 13-Nov-2002  itojun lib/libc/net/getnetnamadr.c 1.25

Fix remote buffer overrun.

(itojun)
 1.19.4.2 04-Sep-2002  itojun lib/libc/net/getaddrinfo.c 1.56
lib/libc/net/res_mkquery.c 1.22
correct bad practice in the code - it uses two changing variables
to manage buffer (buf and buflen). we eliminate buflen and use
fixed point (ep) as the ending pointer.

lib/libc/net/getaddrinfo.c 1.50
remove redundant declarations of h_errno and __hostalias

lib/libc/net/getaddrinfo.c 1.52
make sure "qname" argument to getanswer() is properly given. from lukem

lib/libc/net/getaddrinfo.c 1.54
lib/libc/net/gethnamaddr.c 1.43,1.49-1.50
lib/libc/net/getnetnamadr.c 1.23
use snprintf, string manipulation cleanups

lib/libc/net/getaddrinfo.c 1.57-1.59
correct port range check and signed/unsigned mixup

lib/libc/net/getaddrinfo.c 1.60-1.61
lint clean

lib/libc/net/getaddrinfo.c 1.62
lib/libc/net/gethnamaddr.c 1.51
drop AAAA reply with IPv4 mapped address. sync w/kame
draft-itojun-v6ops-v4mapped-harmful-00.txt

lib/libc/net/getaddrinfo.c 1.63
lib/libc/net/gethnamaddr.c 1.52
lib/libc/net/getnetnamadr.c 1.24
allocate 64K recieve buffer for DNS responses.

lib/libc/net/gethnamaddr.c 1.38
Varargsify dprintf to allow for format string checking

lib/libc/net/gethnamaddr.c 1.39
lib/libc/net/getnetnamadr.c 1.20
remove redundant declarations.

lib/libc/net/gethnamaddr.c 1.41
do not reverse-lookup scoped IPv6 address. it does not make sense as
there's no way to give scope identifier. sync w/kame

lib/libc/net/gethnamaddr.c 1.42
style

lib/libc/net/gethnamaddr.c 1.45
do not pass uninitialized variable to nsdispatch().

lib/libc/net/gethnamaddr.c 1.48
query ip6.arpa then ip6.int for IPv6 reverse lookup. follows RFC3152.
 1.19.4.1 26-Jun-2002  he Pull up revision 1.22 (requested by itojun):
Fix remote buffer overrun on hostbuf[]. Also fix up logic of
buffer handling.
 1.20.4.6 15-Mar-2004  jmc Pullup rev 1.28 (requested by lukem in ticket #1602)

Use the correct parameters when building the YP map name in _yp_getnetbyaddr().
Fixes getnetbyaddr() when reading from YP.
 1.20.4.5 15-Nov-2002  lukem Pull up revision 1.26 (requested by itojun in ticket #990):
pull in changes in http://www.isc.org/products/BIND/patches/bind4910.diff
- better error check on __dn_skipname
- more strict reverse lookup handling
 1.20.4.4 15-Nov-2002  lukem Pull up revision 1.25 (requested by itojun in ticket #986):
fix remote buffer overrun. from openbsd tree (1997).
 1.20.4.3 27-Aug-2002  lukem Pull up revision 1.24 (requested by itojun in ticket #735):
allocate 64K recieve buffer for DNS responses.
 1.20.4.2 17-Aug-2002  lukem Pull up revision 1.23 (requested by itojun in ticket #694):
eliminate sprintf, use snprintf. check strlcat error.
 1.20.4.1 26-Jun-2002  lukem Pull up revision 1.22 (requested by itojun in ticket #371):
avoid remote buffer overrun on hostbuf[]. From: Joost Pol <joost@pine.nl>
correct bad practice in the code - it uses two changing variables
to manage buffer (buf and buflen). we eliminate buflen and use
fixed point (ep) as the ending pointer.
this fix is critical.
 1.20.2.4 10-Dec-2002  thorpej Sync with HEAD.
 1.20.2.3 27-Aug-2002  nathanw Catch up to -current.
 1.20.2.2 01-Aug-2002  nathanw Catch up to -current.
 1.20.2.1 21-Jun-2002  nathanw Catch up to -current.
 1.28.4.1 05-Jul-2005  riz Pull up revision 1.29 (requested by kleink in ticket #2015):
struct netent.n_net used to be an unsigned long integer.
In XNS5, and subsequently in POSIX-2001 it was changed to socklen_t.
To accomodate for this while preserving binary compatibility with the
old interface, prepend or append 32 bits of padding, depending on
the (LP64 data model) architecture's endianness. Fixes PR
standards/21411 from Ben Harris.
This should be deleted the next time the libc major number is
incremented.
Also, update getnetbyaddr(3)'s `net' argument accordingly.
 1.31.2.2 06-Oct-2006  ghen Pull up following revision(s) (requested by tsutsui in ticket #1522):
lib/libc/net/getnetnamadr.c: revision 1.34
Change type of `net' variable passed via va_list in
_{files,dns,yp}_getenetbyaddr() functions from unsigned long to uint32_t.
In rev 1.29, getnetbyaddr(3) was changed to take uint32_t `net' argument
and also passisng uint32_t `net' to nsdispatch(3) varargs, but
these callback functions were not changed accordingly.
Patch was provided by christos, and this fixes amd(8) coredumps on alpha
when /etc/nsswitch.conf has more than one sources for netgroups.
 1.31.2.1 11-Jun-2005  tron Pull up revision 1.32 (requested by lukem in ticket #392):
Move the test for "more strict reverse lookup handling" to the correct
location so that an uninitialized `in' won't be used if net_i == BYADDR.
Detected with gcc -Wuninitialized, confirmed by diffing against BIND 4.9.11.
(The bug was introduced in rev 1.26. Hi Itojun! :)
 1.33.2.1 23-Sep-2006  snj Pull up following revision(s) (requested by tsutsui in ticket #179):
lib/libc/net/getnetnamadr.c: revision 1.34
Change type of `net' variable passed via va_list in
_{files,dns,yp}_getenetbyaddr() functions from unsigned long to uint32_t.
In rev 1.29, getnetbyaddr(3) was changed to take uint32_t `net' argument
and also passisng uint32_t `net' to nsdispatch(3) varargs, but
these callback functions were not changed accordingly.
Patch was provided by christos, and this fixes amd(8) coredumps on alpha
when /etc/nsswitch.conf has more than one sources for netgroups.
 1.35.4.1 03-Jun-2007  wrstuden Catch up with now-somewhat-dated netbsd-4. These changes took longer
than expected for me to actually get around to merging.
 1.35.2.1 17-May-2007  jdc Add missing BIND 9.4.x include file and library changes (requested by
tron in ticket #662).
 1.37.12.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.37.10.2 04-Jun-2008  yamt sync with head
 1.37.10.1 18-May-2008  yamt sync with head.
 1.41.22.1 17-Nov-2015  bouyer Pull up following revision(s) (requested by christos in ticket #1340):
lib/libc/net/getnetnamadr.c: revision 1.43 via patch
lib/libc/net/getnetnamadr.c: revision 1.44 via patch
put the state back after it is used.
PR/50367: Stefan Schaeckeler: Apply fix to obey RES_CHECKNAME to getnetbyaddr
and getnetbyname.
 1.41.6.2 18-May-2008  lukem Fix possible memory leak in error path.
Part of PR 38677.
 1.41.6.1 18-May-2008  lukem file getnetnamadr.c was added on branch christos-time_t on 2008-05-18 22:36:16 +0000
 1.41.2.1 17-Apr-2012  yamt sync with head
 1.42.12.1 08-Nov-2015  riz Pull up following revision(s) (requested by christos in ticket #1012):
lib/libc/net/getnetnamadr.c: revision 1.43
lib/libc/net/getnetnamadr.c: revision 1.44
external/gpl3/binutils/dist/binutils/arsup.c: revision 1.2
put the state back after it is used.
PR/50367: Stefan Schaeckeler: Apply fix to obey RES_CHECKNAME to getnetbyaddr
and getnetbyname.
use asprintf(3)
 1.42.10.1 08-Nov-2015  riz Pull up following revision(s) (requested by christos in ticket #1012):
lib/libc/net/getnetnamadr.c: revision 1.43
lib/libc/net/getnetnamadr.c: revision 1.44
external/gpl3/binutils/dist/binutils/arsup.c: revision 1.2
put the state back after it is used.
PR/50367: Stefan Schaeckeler: Apply fix to obey RES_CHECKNAME to getnetbyaddr
and getnetbyname.
use asprintf(3)
 1.2 29-Jan-2008  abs Adjust "The getpeereid() function appeared in NetBSD 4.0" to a more
correct NetBSD 5.0.
 1.1 09-Aug-2007  he branches: 1.1.2;
Add a new socket option for unix domain sockets: LOCAL_PEEREID, to make
it possible to get the pid, euid and egid of the process at the remote
end at the time it did bind() or connect().

Add a new libc function, getpeereid() to easily get at the euid and egid.
As a consequence, bump libc's minor number.

Document the LOCAL_PEEREID socket option in unix(4).

Based on contribution by Arne H. Juul, minor modifications by myself.
 1.1.2.1 23-Mar-2008  matt sync with HEAD
 1.4 08-Aug-2021  nia introduce a SOL_LOCAL for unix-domain socket level socket options
as an alias of the current 0 used for these options, as in FreeBSD.

reviewed by many.
 1.3 16-Feb-2018  christos Enforce that getpeereid only returns success on AF_LOCAL sockets, instead
of returning garbage for other socket types.
 1.2 29-Apr-2008  martin branches: 1.2.8;
Convert to new 2 clause license
 1.1 09-Aug-2007  he branches: 1.1.8;
Add a new socket option for unix domain sockets: LOCAL_PEEREID, to make
it possible to get the pid, euid and egid of the process at the remote
end at the time it did bind() or connect().

Add a new libc function, getpeereid() to easily get at the euid and egid.
As a consequence, bump libc's minor number.

Document the LOCAL_PEEREID socket option in unix(4).

Based on contribution by Arne H. Juul, minor modifications by myself.
 1.1.8.1 18-May-2008  yamt sync with head.
 1.2.8.2 29-Apr-2008  martin Convert to new 2 clause license
 1.2.8.1 29-Apr-2008  martin file getpeereid.c was added on branch christos-time_t on 2008-04-29 06:53:02 +0000
 1.10 19-Feb-2004  christos Implement the non-reentrant ones using the reentrant ones.
Name files by function name.
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.8 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.7 18-Feb-1998  kleink Include <stddef.h> for NULL.
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.5 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.4 28-Apr-2008  martin branches: 1.4.8;
Remove clause 3 and 4 from TNF licenses
 1.3 18-Apr-2005  kleink branches: 1.3.18;
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.2 07-Jan-2005  mycroft branches: 1.2.2;
Throw in mutex stubs to serialize access to the legacy global structures.
 1.1 19-Feb-2004  christos Implement the non-reentrant ones using the reentrant ones.
Name files by function name.
 1.2.2.1 21-Apr-2005  tron Pull up revision 1.3 (requested by kleink in ticket #172):
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.3.18.1 18-May-2008  yamt sync with head.
 1.4.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.4.8.1 28-Apr-2008  martin file getprotobyname.c was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.3 18-Apr-2005  kleink Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.2 04-Mar-2004  enami branches: 1.2.6;
Don't call end{serv,proto}ent_r() on return. It results dangling pointer.
 1.1 19-Feb-2004  christos Re-entrant versions of services and prorocols functions.
 1.2.6.1 21-Apr-2005  tron Pull up revision 1.3 (requested by kleink in ticket #172):
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.5 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.4 28-Apr-2008  martin branches: 1.4.8;
Remove clause 3 and 4 from TNF licenses
 1.3 18-Apr-2005  kleink branches: 1.3.18;
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.2 07-Jan-2005  mycroft branches: 1.2.2;
Throw in mutex stubs to serialize access to the legacy global structures.
 1.1 19-Feb-2004  christos Implement the non-reentrant ones using the reentrant ones.
Name files by function name.
 1.2.2.1 21-Apr-2005  tron Pull up revision 1.3 (requested by kleink in ticket #172):
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.3.18.1 18-May-2008  yamt sync with head.
 1.4.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.4.8.1 28-Apr-2008  martin file getprotobynumber.c was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.3 18-Apr-2005  kleink Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.2 04-Mar-2004  enami branches: 1.2.6;
Don't call end{serv,proto}ent_r() on return. It results dangling pointer.
 1.1 19-Feb-2004  christos Re-entrant versions of services and prorocols functions.
 1.2.6.1 21-Apr-2005  tron Pull up revision 1.3 (requested by kleink in ticket #172):
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.13 14-Jul-2011  wiz New sentence, new line.
 1.12 14-Jul-2011  jruoho Complete prototypes, markup NULL, complete return values, more markup.
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 16-Sep-2001  wiz Boring whitespace fixes.
 1.7 22-Mar-1999  garbled branches: 1.7.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 08-Mar-1997  mouse branches: 1.5.2;
alternate -> alternative, per PR 2643
 1.4 09-Nov-1996  lukem add 'const' qualifiers to various routines (as per the include prototypes
and the implementation)
 1.3 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.2 08-Mar-1997  mouse alternate -> alternative, per PR 2643
 1.5.2.1 08-Mar-1997  mouse file getprotoent.3 was added on branch is-newarp on 1997-03-08 13:40:19 +0000
 1.7.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.7.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.7.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.12 28-Apr-2008  martin branches: 1.12.8;
Remove clause 3 and 4 from TNF licenses
 1.11 18-Apr-2005  kleink branches: 1.11.18;
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.10 07-Jan-2005  mycroft branches: 1.10.2;
Throw in mutex stubs to serialize access to the legacy global structures.
 1.9 19-Feb-2004  christos Implement the non-reentrant ones using the reentrant ones.
Name files by function name.
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.10.2.1 21-Apr-2005  tron Pull up revision 1.11 (requested by kleink in ticket #172):
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.11.18.1 18-May-2008  yamt sync with head.
 1.12.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.12.8.1 28-Apr-2008  martin file getprotoent.c was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.8 12-Mar-2022  christos reallocarr returns errno. preserve it.
 1.7 12-Mar-2022  nia getprotoent_r: use reallocarr
 1.6 15-Oct-2011  christos close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.5 18-Apr-2005  kleink Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.4 25-Feb-2004  taca branches: 1.4.6;
Semantic fix for allocation size for malloc() and realloc() previously
modified. Allocation unit isn't sizeof(char **) but sizeof(char *).

Noted by Geoff Wing.
 1.3 24-Feb-2004  christos Fix allocation size bug from Takahiro Kambe.
 1.2 23-Feb-2004  christos - fix a memory leak on the current line buffer.
- fix a memory leak on realloc failure.
 1.1 19-Feb-2004  christos Re-entrant versions of services and prorocols functions.
 1.4.6.1 21-Apr-2005  tron Pull up revision 1.5 (requested by kleink in ticket #172):
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.11 19-Feb-2004  christos Implement the non-reentrant ones using the reentrant ones.
Name files by function name.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.8 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.7 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.15 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.14 28-Apr-2008  martin branches: 1.14.8;
Remove clause 3 and 4 from TNF licenses
 1.13 18-Apr-2005  kleink branches: 1.13.18;
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.12 07-Jan-2005  mycroft branches: 1.12.2;
Throw in mutex stubs to serialize access to the legacy global structures.
 1.11 19-Feb-2004  christos Implement the non-reentrant ones using the reentrant ones.
Name files by function name.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.8 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.7 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.12.2.1 21-Apr-2005  tron Pull up revision 1.13 (requested by kleink in ticket #172):
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.13.18.1 18-May-2008  yamt sync with head.
 1.14.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.14.8.1 28-Apr-2008  martin file getservbyname.c was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.9 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.8 03-Apr-2011  christos branches: 1.8.4;
Protect against stack smashes (Maksymilian Arciemowicz)
 1.7 25-Apr-2010  joerg Add the constant database reader (cdbr(3)) and writer ((cdbw(3)).
They implement a space efficent write-once database with fast access
path. Switch the services(5) database to use cdb. The size of the
database file decreases from 2.1MB disk space to 307KB. Access
performance is about the same if setservent(0) is used and about an
order of magnitude faster otherwise. services_mkdb defaults to the new
format, but can optionally create the old db(3) format as well for
statically linked legacy applications.
 1.6 21-Mar-2007  christos branches: 1.6.18; 1.6.24; 1.6.28;
return NULL instead of core-dumping when we could not open the services file/db
 1.5 28-Jul-2006  christos use indirect lookup.
 1.4 27-Jul-2006  christos use a db version of services if one is there.
 1.3 18-Apr-2005  kleink Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.2 04-Mar-2004  enami branches: 1.2.6;
Don't call end{serv,proto}ent_r() on return. It results dangling pointer.
 1.1 19-Feb-2004  christos Re-entrant versions of services and prorocols functions.
 1.2.6.1 21-Apr-2005  tron Pull up revision 1.3 (requested by kleink in ticket #172):
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.6.28.1 05-Apr-2011  riz Apply patch (requested by christos in ticket #1593):
lib/libc/net/getservbyname_r.c patch
lib/libc/net/getservbyport_r.c patch

Protect against stack smashes (from Maksymilian Arciemowicz)
 1.6.24.1 05-Apr-2011  riz Apply patch (requested by christos in ticket #1593):
lib/libc/net/getservbyname_r.c patch
lib/libc/net/getservbyport_r.c patch

Protect against stack smashes (from Maksymilian Arciemowicz)
 1.6.18.1 05-Apr-2011  riz Apply patch (requested by christos in ticket #1593):
lib/libc/net/getservbyname_r.c patch
lib/libc/net/getservbyport_r.c patch

Protect against stack smashes (from Maksymilian Arciemowicz)
 1.8.4.1 17-Apr-2012  yamt sync with head
 1.13 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.12 28-Apr-2008  martin branches: 1.12.8;
Remove clause 3 and 4 from TNF licenses
 1.11 18-Apr-2005  kleink branches: 1.11.18;
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.10 07-Jan-2005  mycroft branches: 1.10.2;
Throw in mutex stubs to serialize access to the legacy global structures.
 1.9 19-Feb-2004  christos Implement the non-reentrant ones using the reentrant ones.
Name files by function name.
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.10.2.1 21-Apr-2005  tron Pull up revision 1.11 (requested by kleink in ticket #172):
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.11.18.1 18-May-2008  yamt sync with head.
 1.12.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.12.8.1 28-Apr-2008  martin file getservbyport.c was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.9 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.8 03-Apr-2011  christos branches: 1.8.4;
Protect against stack smashes (Maksymilian Arciemowicz)
 1.7 25-Apr-2010  joerg Add the constant database reader (cdbr(3)) and writer ((cdbw(3)).
They implement a space efficent write-once database with fast access
path. Switch the services(5) database to use cdb. The size of the
database file decreases from 2.1MB disk space to 307KB. Access
performance is about the same if setservent(0) is used and about an
order of magnitude faster otherwise. services_mkdb defaults to the new
format, but can optionally create the old db(3) format as well for
statically linked legacy applications.
 1.6 21-Mar-2007  christos branches: 1.6.18; 1.6.24; 1.6.28;
return NULL instead of core-dumping when we could not open the services file/db
 1.5 28-Jul-2006  christos use indirect lookup.
 1.4 27-Jul-2006  christos use a db version of services if one is there.
 1.3 18-Apr-2005  kleink Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.2 04-Mar-2004  enami branches: 1.2.6;
Don't call end{serv,proto}ent_r() on return. It results dangling pointer.
 1.1 19-Feb-2004  christos Re-entrant versions of services and prorocols functions.
 1.2.6.1 21-Apr-2005  tron Pull up revision 1.3 (requested by kleink in ticket #172):
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.6.28.1 05-Apr-2011  riz Apply patch (requested by christos in ticket #1593):
lib/libc/net/getservbyname_r.c patch
lib/libc/net/getservbyport_r.c patch

Protect against stack smashes (from Maksymilian Arciemowicz)
 1.6.24.1 05-Apr-2011  riz Apply patch (requested by christos in ticket #1593):
lib/libc/net/getservbyname_r.c patch
lib/libc/net/getservbyport_r.c patch

Protect against stack smashes (from Maksymilian Arciemowicz)
 1.6.18.1 05-Apr-2011  riz Apply patch (requested by christos in ticket #1593):
lib/libc/net/getservbyname_r.c patch
lib/libc/net/getservbyport_r.c patch

Protect against stack smashes (from Maksymilian Arciemowicz)
 1.8.4.1 17-Apr-2012  yamt sync with head
 1.17 07-Sep-2024  rillig getservent.3: fix format of day of month
 1.16 04-Dec-2022  uwe branches: 1.16.4;
getservent(3): Section 3 has RETURN VALUES, not DIAGNOSTICS

While here, don't claim that null pointer is zero.

We should probably just pick the wording from POSIX, but that yak is a
bit too big for me to shave at the moment.
 1.15 03-Dec-2022  jschauma reference /var/db/services.cdb / services_mkdb(8)
 1.14 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.13 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.12 07-Feb-2002  ross Generate <>& symbolically.
 1.11 16-Sep-2001  wiz Boring whitespace fixes.
 1.10 24-Mar-1999  mycroft branches: 1.10.12;
Remove spurious .ne's.
 1.9 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.8 05-Feb-1998  perry add LIBRARY section to man page
 1.7 02-Feb-1998  mrg merge in lite2 rcsids and a couple of man page fixes we had not yet found.
 1.6 12-May-1997  mikel note that s_port must be given in network byte order as well; fixes
PR lib/2986.
 1.5 08-Mar-1997  mouse branches: 1.5.2;
alternate -> alternative, per PR 2643
 1.4 09-Nov-1996  lukem fix prototype for getservbyport, from babafou@ensta.fr [misc/2916],
and also add 'const' qualifiers
 1.3 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 02-Feb-1998  mrg import lite-2 libc/net sources.
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.2 08-Mar-1997  mouse alternate -> alternative, per PR 2643
 1.5.2.1 08-Mar-1997  mouse file getservent.3 was added on branch is-newarp on 1997-03-08 13:41:07 +0000
 1.10.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.10.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.10.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.16.4.1 02-Aug-2025  perseant Sync with HEAD
 1.12 28-Apr-2008  martin branches: 1.12.8;
Remove clause 3 and 4 from TNF licenses
 1.11 18-Apr-2005  kleink branches: 1.11.18;
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.10 07-Jan-2005  mycroft branches: 1.10.2;
Throw in mutex stubs to serialize access to the legacy global structures.
 1.9 19-Feb-2004  christos Implement the non-reentrant ones using the reentrant ones.
Name files by function name.
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.10.2.1 21-Apr-2005  tron Pull up revision 1.11 (requested by kleink in ticket #172):
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.11.18.1 18-May-2008  yamt sync with head.
 1.12.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.12.8.1 28-Apr-2008  martin file getservent.c was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.13 12-Mar-2022  christos reallocarr returns errno. preserve it.
 1.12 12-Mar-2022  nia getservent_r: use reallocarr
CVSv ----------------------------------------------------------------------
 1.11 15-Oct-2011  christos close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")
 1.10 25-Apr-2010  joerg Add the constant database reader (cdbr(3)) and writer ((cdbw(3)).
They implement a space efficent write-once database with fast access
path. Switch the services(5) database to use cdb. The size of the
database file decreases from 2.1MB disk space to 307KB. Access
performance is about the same if setservent(0) is used and about an
order of magnitude faster otherwise. services_mkdb defaults to the new
format, but can optionally create the old db(3) format as well for
statically linked legacy applications.
 1.9 06-Jan-2008  christos PR/37708: A.Leo.: getservbyname, segetaddrinfo sefgfaults when user has no
rights for reading ``/etc/services''
 1.8 14-Sep-2006  christos branches: 1.8.8;
when re-opening the file only set SV_FIRST, don't clear accidentally SV_DB
because it leads to core-dumps.
 1.7 28-Jul-2006  joerg db->seq expects an u_int as fourth argument.
 1.6 27-Jul-2006  christos use a db version of services if one is there.
 1.5 18-Apr-2005  kleink Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.4 25-Feb-2004  taca branches: 1.4.6;
Semantic fix for allocation size for malloc() and realloc() previously
modified. Allocation unit isn't sizeof(char **) but sizeof(char *).

Noted by Geoff Wing.
 1.3 24-Feb-2004  christos Fix allocation size bug from Takahiro Kambe.
 1.2 23-Feb-2004  christos - fix a memory leak on the current line buffer.
- fix a memory leak on realloc failure.
 1.1 19-Feb-2004  christos Re-entrant versions of services and prorocols functions.
 1.4.6.1 21-Apr-2005  tron Pull up revision 1.5 (requested by kleink in ticket #172):
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.8.8.1 09-Jan-2008  matt sync with HEAD
 1.18 21-May-2004  christos Finish bind9 resolver merge.
 1.17 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.16 20-Dec-2000  christos remove redundant declarations.
 1.15 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.14 30-Nov-1998  thorpej h_errlist[] is not exported in any header file. We should consider making
the symbol static when libc's major is bumped. Indicate this with a comment.
 1.13 13-Nov-1998  christos delint
 1.12 16-Oct-1998  kleink Need an internal name for herror().
 1.11 26-Jul-1998  mycroft const poisoning.
 1.10 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.9 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.8 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.7 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.6 02-Feb-1996  mrg branches: 1.6.2;
merge with the resolver in bind 4.9.3-P1.
 1.5 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.4 07-Apr-1994  deraadt new resolver. changes from 4.9.2 by <paul@vix.com>, as well as a number
of features and optimizations by myself.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.5 02-Feb-1998  mrg import lite-2 libc/net sources.
 1.1.1.4 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.3 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.7 10-Mar-2009  joerg Use .An for author list.
 1.6 16-Apr-2003  wiz branches: 1.6.42;
Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.5 07-Feb-2002  ross Generate <>& symbolically.
 1.4 08-Dec-2001  gmcgarry Add .Os
 1.3 04-Oct-2001  wiz Actually, we don't have libhesiod -- the functions are in libc.
Noted by Gregory McGarry.
 1.2 16-Sep-2001  wiz mdoc'ify.
 1.1 25-Jan-1999  lukem branches: 1.1.12;
add hesiod(3) et al
 1.1.12.5 22-Mar-2002  nathanw Catch up to -current.
 1.1.12.4 08-Mar-2002  nathanw Catch up to -current.
 1.1.12.3 28-Jan-2002  nathanw Catch up to -current.
 1.1.12.2 14-Nov-2001  nathanw Catch up to -current.
 1.1.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.6.42.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.30 10-Mar-2017  maya Remove entirely redundant free right after declaration.

This block existed because the original code used bindname as a global.
 1.29 10-Mar-2017  maya Drop redundant null checks.

this doesn't increase diff to upstream, the whole block differs already.
 1.28 18-Sep-2014  christos branches: 1.28.2; 1.28.4;
make more descriptors that we open as close-on-exec
 1.27 20-Mar-2012  matt Use C89 Prototypes.
Remove use of __P
 1.26 15-Oct-2011  christos branches: 1.26.2;
use fparseln
 1.25 05-Jan-2011  wiz Fix fdleak in error case. Found by cppcheck.
 1.24 19-Oct-2005  christos Let the default case handle all the errors; no functional change.
 1.23 28-Feb-2005  lukem Prevent NULL deref upon malloc failure.
 1.22 23-May-2004  christos centralize res_*init() calls in __res_get_state()
 1.21 21-May-2004  christos Finish bind9 resolver merge.
 1.20 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.19 16-Aug-2002  itojun use strlcat
 1.18 16-Aug-2002  itojun fix weird indent for comment lines
 1.17 16-Apr-2002  groo Minor KNF + proper end of string detection in read_config_file()
Inspired by xs@kittenz.org
 1.16 13-Feb-2001  sommerfeld branches: 1.16.2;
Replace strcpy with strlcpy and bounds check.
From mheffner@vt.edu via freebsd-audit@freebsd.org via hesiod@mit.edu
 1.15 31-Oct-2000  lukem Don't getenv $HESIOD_CONFIG or $HES_DOMAIN if issetugid().
Initial problem noted by Danny Braniss <danny@cs.huji.ac.il>
via Jacques A. Vidrine <n@nectar.com>
 1.14 07-Jul-2000  itohy Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.
 1.13 18-Jun-2000  ghudson branches: 1.13.2;
Set errno when res_mkquery fails.
 1.12 22-Jan-2000  mycroft branches: 1.12.2;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.11 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.10 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.9 11-Feb-1999  simonb branches: 1.9.2;
In hesiod_to_bind(), don't append lhs and an extra dot if lhs is empty.
Now works with Ultrix hesiod.conf files.
 1.8 25-Jan-1999  lukem after discussion with greg hudson, change default classes back to "in,hs"
 1.7 25-Jan-1999  lukem * change default classes from "IN,HS" to "HS" (for backwards compat
with older hesiod.conf files & parsers)
* check list != NULL in hesiod_free_list()
* hes_free() is now just a wrapper to hesiod_free_list()
 1.6 25-Jan-1999  lukem merge in hesiod 3.0.2 distribution
 1.5 21-Jan-1999  mycroft Use class IN. (In current Athena code, this is configurable.)
 1.4 20-Jan-1999  christos - fix a misplaced parenthesis in an if statement
- caddr_t -> void *
- remove unnecessary casts
- turn code repeated 3 times into a macro
 1.3 15-Jan-1999  thorpej Fix LP64 warnings.
 1.2 15-Jan-1999  lukem merge nsswitch into main branch
 1.1 06-Nov-1996  lukem branches: 1.1.2; 1.1.4;
file hesiod.c was initially added on branch nsswitch.
 1.1.4.3 02-Nov-1998  lukem sync with current, assign my copyrights to TNF
 1.1.4.2 24-May-1997  lukem fix merge (differences in original and current definitions of StringLists)
 1.1.4.1 23-May-1997  lukem * Add nsdispatch(3) implementation
* Deprecate support for "lookup" in resolv.conf
 1.1.2.1 06-Nov-1996  lukem initial nsswitch implementation
 1.9.2.1 31-Oct-2000  he Pull up revision 1.15 (requested by sommerfeld):
If setuid, ignore environment variables.
 1.12.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.13.2.4 17-Apr-2002  he Pull up revision 1.17 (requested by groo):
Minor style adjustments, and do proper end of string detection
in read_config_file().
 1.13.2.3 17-Apr-2002  he Pull up revision 1.14 (requested by he):
Cast arguments to isspace() to u_char.
 1.13.2.2 17-Apr-2002  he Pull up revision 1.16 (requested by he):
Replace strcpy() with strlcpy() and bounds check.
 1.13.2.1 01-Nov-2000  tv Pullup 1.15 [lukem]:
Don't getenv $HESIOD_CONFIG or $HES_DOMAIN if issetugid().
Initial problem noted by Danny Braniss <danny@cs.huji.ac.il>
via Jacques A. Vidrine <n@nectar.com>
 1.16.2.3 10-Dec-2002  thorpej Sync with HEAD.
 1.16.2.2 27-Aug-2002  nathanw Catch up to -current.
 1.16.2.1 25-Apr-2002  nathanw Catch up to -current.
 1.26.2.1 17-Apr-2012  yamt sync with head
 1.28.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.28.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.3 19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.2 27-Aug-2013  christos branches: 1.2.2; 1.2.4; 1.2.8; 1.2.12;
move the host file getbyname and getbyaddr functions to sethostent.c so
that they are in a separate file from the dns ones in order for libhack
to use them.
 1.1 16-Aug-2013  christos Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3) so it is re-entrant (ahem __ypdomain). These
are not being advertised because there is a bunch of different
implementation of them that have a variety of type signatures.

If people want to follow someone's implementation, it is now easy.
 1.2.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.12.1 27-Aug-2013  tls file hostent.h was added on branch tls-maxphys on 2014-08-20 00:02:15 +0000
 1.2.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.8.1 27-Aug-2013  yamt file hostent.h was added on branch yamt-pagecache on 2014-05-22 11:36:53 +0000
 1.2.4.2 18-Dec-2013  bouyer Pullup the following revisions, requested by bad in ticket 975:
lib/libc/net/gethnamaddr.c 1.79-1.81, 1.84
lib/libc/net/getnameinfo.3 1.37-1.40
lib/libc/net/getnameinfo.c 1.51, 1.52, 1.54
lib/libc/net/hostent.h 1.1, 1.2
lib/libc/net/sethostent.c 1.17-1.19

Make getnameinfo(3) re-entrant (ahem __ypdomain).
Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3).
Implement no-check-names.
 1.2.4.1 27-Aug-2013  bouyer file hostent.h was added on branch netbsd-6 on 2013-12-18 22:39:32 +0000
 1.2.2.2 18-Dec-2013  bouyer Apply patch, requested by bad in ticket #1887:
lib/libc/net/gethnamaddr.c 1.79-1.82 via patch
lib/libc/net/getnameinfo.3 1.37-1.40 via patch
lib/libc/net/getnameinfo.c 1.4 via patch
lib/libc/net/hostent.h 1.1, 1.2 via patch
lib/libc/net/sethostent.c 1.17-1.19 via patch

Make getnameinfo(3) re-entrant (ahem __ypdomain).
Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3).
Implement no-check-names.
 1.2.2.1 27-Aug-2013  bouyer file hostent.h was added on branch netbsd-5 on 2013-12-18 20:23:36 +0000
 1.12 20-Dec-2005  christos Use reach-over sources from common/lib/libc
 1.11 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.10 22-Aug-2001  itojun sync argument/return type of [hn]to[nh][ls] to XNET 5.2 (uint{16,32}_t).
as discussed on tech-net.
 1.9 13-Jul-1997  christos branches: 1.9.14;
Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.8 17-Oct-1996  cgd fix a typo: take and cast a pointer to the argument, rather than trying
to cast the argument to a pointer.
 1.7 13-Oct-1996  christos in_addr_t and in_port_t changes
 1.6 29-May-1996  cgd Add some casts so that we're not bitten by type promotions on 64-bit
systems. Not a great concern since the only 64-bit system currently
supported by NetBSD (Alpha) uses assembly versions of these routines.
 1.5 28-Apr-1995  jtc branches: 1.5.6;
Winning Strategies has placed this code into the Public Domain
 1.4 25-Feb-1995  cgd use NetBSD rather than ID
 1.3 19-Oct-1994  cgd maybe they should actually... WORK!
 1.2 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.1 31-Aug-1993  jtc Provide C language versions of the netorder functions.
These may be "good enough" for big-endian systems that do not have assembly
language versions of their own. A compiler should be able to do a fairly
good job optimising them, it probably won't be smart enough to omit the
stack frame, but then again, these functions won't be called unless the
macro versions are undef'd.
On the other hand, they are only intended for bootstrap purposes on little-
endian systems. They should be replaced with assembly language versions as
soon as possible.
 1.5.6.1 29-May-1996  cgd Pull revision 1.6 (add casts so we're not bitten by type promotions on
64-bit systems) to the release branch.
 1.9.14.1 08-Oct-2001  nathanw Catch up to -current.
 1.11 20-Dec-2005  christos Use reach-over sources from common/lib/libc
 1.10 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.9 22-Aug-2001  itojun sync argument/return type of [hn]to[nh][ls] to XNET 5.2 (uint{16,32}_t).
as discussed on tech-net.
 1.8 13-Jul-1997  christos branches: 1.8.14;
Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.7 13-Oct-1996  christos in_addr_t and in_port_t changes
 1.6 29-May-1996  cgd Add some casts so that we're not bitten by type promotions on 64-bit
systems. Not a great concern since the only 64-bit system currently
supported by NetBSD (Alpha) uses assembly versions of these routines.
 1.5 28-Apr-1995  jtc branches: 1.5.6;
Winning Strategies has placed this code into the Public Domain
 1.4 25-Feb-1995  cgd use NetBSD rather than ID
 1.3 19-Oct-1994  cgd maybe they should actually... WORK!
 1.2 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.1 31-Aug-1993  jtc Provide C language versions of the netorder functions.
These may be "good enough" for big-endian systems that do not have assembly
language versions of their own. A compiler should be able to do a fairly
good job optimising them, it probably won't be smart enough to omit the
stack frame, but then again, these functions won't be called unless the
macro versions are undef'd.
On the other hand, they are only intended for bootstrap purposes on little-
endian systems. They should be replaced with assembly language versions as
soon as possible.
 1.5.6.1 29-May-1996  cgd Pull revision 1.6 (add casts so we're not bitten by type promotions on
64-bit systems) to the release branch.
 1.8.14.1 08-Oct-2001  nathanw Catch up to -current.
 1.12 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.11 11-Mar-2005  ginsbach Update standards section; add X/Open XNS and X/Open - IEEE POSIX.
RFC 2553 made obsolete by RFC 3493. Approved by wiz.
 1.10 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.9 07-Feb-2002  ross Generate <>& symbolically.
 1.8 10-Apr-2001  wiz Fix date.
 1.7 24-Nov-2000  itojun branches: 1.7.2;
strictly conform to RFC2553 (specifically ENXIO case). sync with KAME
 1.6 21-Sep-2000  ad Use .{B,Bs,F,N,O}x and fix miscellaneous errors.
 1.5 24-Apr-2000  itojun use BSDI-origin if_{index,name}* functions. they use getifaddrs(3) as
backend and are more robust against SIOCGIFCONF alignment issue.
now getifaddrs always takes care of the issue. (sync with kame tree)
use weak symbol just in case.
 1.4 17-Jan-2000  itojun sync with latest KAME tree.
add example section to get{addr,name}info.
s/\.Os KAME/.Os/.
 1.3 12-Dec-1999  itojun wording fixes (from openbsd camp -> kame)
 1.2 03-Jul-1999  kleink branches: 1.2.4;
Add missing LIBRARY sections.
 1.1 01-Jul-1999  itojun add IPv6 support functions.

get{addr,name} info are implemented to have as little impact to existing
resolver code as possible, so they are NOT the optimal implementation.
They are at this moment not very thread safe (as they call
gethostby{name,addr}).

(shlib minor version)++, as new interfaces are added.

TODO: getipnodeby{name,addr} - which needs total reimplementation of
gethostby{name,addr}.
upgrade rcmd.c for multiple af support (needed for IPv6-ready rsh/rlogin)
 1.2.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.7.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.7.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.7.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.7 13-Dec-2010  pooka Don't __weak_alias non-existent symbols. Apparently the alpha
compiler doesn't like it.
 1.6 13-Dec-2010  pooka last of the RUMP_ACTION syscall swappers
 1.5 25-Nov-2006  elad strncpy -> strlcpy. from David Holland.
 1.4 24-Nov-2000  itojun strictly conform to RFC2553 (specifically ENXIO case). sync with KAME
 1.3 06-Jul-2000  christos avoid non-portable casts
 1.2 24-Apr-2000  itojun add __RCSID().
 1.1 24-Apr-2000  itojun use BSDI-origin if_{index,name}* functions. they use getifaddrs(3) as
backend and are more robust against SIOCGIFCONF alignment issue.
now getifaddrs always takes care of the issue. (sync with kame tree)
use weak symbol just in case.
 1.7 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.6 20-Dec-2000  christos branches: 1.6.60;
appease lint casting.
 1.5 24-Nov-2000  itojun strictly conform to RFC2553 (specifically ENXIO case). sync with KAME
 1.4 24-Jul-2000  itojun correct malloc() size computation mistake. bug from bsdi, found
by kjc. sync with kame.
 1.3 06-Jul-2000  christos avoid non portable casts
 1.2 24-Apr-2000  itojun branches: 1.2.4;
add __RCSID().
 1.1 24-Apr-2000  itojun use BSDI-origin if_{index,name}* functions. they use getifaddrs(3) as
backend and are more robust against SIOCGIFCONF alignment issue.
now getifaddrs always takes care of the issue. (sync with kame tree)
use weak symbol just in case.
 1.2.4.1 24-Jul-2000  itojun pullup 1.3 -> 1.4 (approved by releng-1-5)
correct malloc() size computation mistake. bug from bsdi, found
by kjc. sync with kame.
 1.6.60.1 17-Apr-2012  yamt sync with head
 1.6 22-Aug-2018  msaitoh - SIOCGIFINDEX was added in 2013, but if_freenameindex(3) have not used it
for years. Use it to improve performance. Same as FreeBSD.
- KNF.
 1.5 01-Sep-2015  ozaki-r branches: 1.5.8; 1.5.14; 1.5.16;
Fix rump.ndp -I options by rump-ifying if_nametoindex(3)

From s-yamaguchi@IIJ
 1.4 24-Nov-2000  itojun strictly conform to RFC2553 (specifically ENXIO case). sync with KAME
 1.3 06-Jul-2000  christos elide non-portable casts
 1.2 24-Apr-2000  itojun add __RCSID().
 1.1 24-Apr-2000  itojun use BSDI-origin if_{index,name}* functions. they use getifaddrs(3) as
backend and are more robust against SIOCGIFCONF alignment issue.
now getifaddrs always takes care of the issue. (sync with kame tree)
use weak symbol just in case.
 1.5.16.1 10-Jun-2019  christos Sync with HEAD
 1.5.14.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.5.8.1 05-Sep-2018  martin Pull up following revision(s) (requested by msaitoh in ticket #1007):

lib/libc/net/if_nametoindex.c: revision 1.6

- SIOCGIFINDEX was added in 2013, but if_freenameindex(3) have not used it
for years. Use it to improve performance. Same as FreeBSD.

- KNF.
 1.8 24-Apr-2000  itojun use BSDI-origin if_{index,name}* functions. they use getifaddrs(3) as
backend and are more robust against SIOCGIFCONF alignment issue.
now getifaddrs always takes care of the issue. (sync with kame tree)
use weak symbol just in case.
 1.7 23-Jan-2000  mycroft Delint.
 1.6 30-Nov-1999  kleink (bcopy, bzero) -> (memcpy, memset)
 1.5 20-Sep-1999  lukem branches: 1.5.4;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.4 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.3 04-Jul-1999  itojun add NetBSD RCSID on top.
 1.2 03-Jul-1999  kleink <sys/errno.h> -> <errno.h>; kill our own declaration of errno (_REENTRANT!).
 1.1 01-Jul-1999  itojun add IPv6 support functions.

get{addr,name} info are implemented to have as little impact to existing
resolver code as possible, so they are NOT the optimal implementation.
They are at this moment not very thread safe (as they call
gethostby{name,addr}).

(shlib minor version)++, as new interfaces are added.

TODO: getipnodeby{name,addr} - which needs total reimplementation of
gethostby{name,addr}.
upgrade rcmd.c for multiple af support (needed for IPv6-ready rsh/rlogin)
 1.5.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.28 21-May-2004  christos Finish bind9 resolver merge.
 1.27 08-Sep-2003  wiz Mention RFC 3493; inet_{ntop,pton} are in 1003.1-2001; move XNS5.2 to HISTORY.
Okayed by kleink.
 1.26 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.25 30-Jun-2003  kleink Sprinkle some restrict.
 1.24 05-May-2003  wiz No leading zero in Dd argument.
 1.23 05-May-2003  bjh21 Document signature changes to inet_addr() and friends.
 1.22 03-May-2003  wiz Misc. fixes from jmc@openbsd.
 1.21 29-Apr-2003  wiz Bump date for last.
 1.20 29-Apr-2003  bjh21 <arpa/inet.h> no longer has any prerequisite headers, so don't pretend
it does.
 1.19 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.18 18-Jul-2002  wiz Two typos.
 1.17 14-May-2002  kleink XNS5.2/POSIX-2001: change the size argument to inet_ntop from size_t to
socklen_t.
 1.16 07-Feb-2002  ross Generate <>& symbolically.
 1.15 16-Nov-2000  lukem branches: 1.15.2;
english fixup
 1.14 18-Jun-2000  itojun recomend get{addr,name}info for scoped address support.
 1.13 03-Jul-1999  kleink branches: 1.13.6;
Add a reference to XNS5.2 D2.0 for inet_{ntop,pton}().
 1.12 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.11 17-Mar-1999  fair Several things: a patch from PR#6355, nroff/mandoc cleanup, and
update a reference to RFC 1884 to RFC 2373.
 1.10 06-Feb-1998  perry macroize BSD, NetBSD, FreeBSD and misc cleanup
 1.9 05-Feb-1998  perry add LIBRARY section to man page
 1.8 14-Nov-1997  mrg add missing .Nm entries. from spz@serpens.swb.de.
 1.7 18-Jun-1997  lukem branches: 1.7.2;
* add man page for inet_net_ntop(3) and inet_net_pton(3)
* xref them in inet(3)
* use Va instead of Fn for 'errno' in inet(3)
 1.6 18-Jun-1997  lukem Describe inet_ntop() and inet_pton(), and the IPv6 address format.
From BSD/OS 3.0, with permission from Jeffrey Finkelstein <finkels@bsdi.com>
 1.5 22-Jan-1997  mikel inet_makeaddr() takes unsigned long, not int, arguments; fixes PR lib/2385.
 1.4 27-Feb-1995  chopps indicate const'ness of args.
 1.3 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.1 14-Nov-1997  mrg pull up from trunk: add missing .Nm entries. from spz@serpens.swb.de.
 1.13.6.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.15.2.4 01-Aug-2002  nathanw Catch up to -current.
 1.15.2.3 21-Jun-2002  nathanw Catch up to -current.
 1.15.2.2 22-Mar-2002  nathanw Catch up to -current.
 1.15.2.1 08-Mar-2002  nathanw Catch up to -current.
 1.3 31-Oct-2013  wiz branches: 1.3.4; 1.3.8;
Try improving the description.
 1.2 19-Oct-2013  wiz Minor fixes.
 1.1 19-Oct-2013  christos document the scopeid functions
 1.3.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.3.8.1 31-Oct-2013  tls file inet6_getscopeid.3 was added on branch tls-maxphys on 2014-08-20 00:02:15 +0000
 1.3.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.4.1 31-Oct-2013  yamt file inet6_getscopeid.3 was added on branch yamt-pagecache on 2014-05-22 11:36:53 +0000
 1.3 04-Dec-2022  uwe Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.2 04-Jan-2014  wiz Sort sections. Punctuation formatting nits.
 1.1 05-May-2006  rpaulo branches: 1.1.44; 1.1.50;
Add support for RFC 3542 Adv. Socket API for IPv6 (which obsoletes 2292).
* RFC 3542 isn't binary compatible with RFC 2292.
* RFC 2292 support is on by default but can be disabled.
* update ping6, telnet and traceroute6 to the new API.

From the KAME project (www.kame.net).
Reviewed by core.
 1.1.50.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.44.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.18 04-Dec-2022  uwe Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.17 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.16 26-Dec-2005  perry u_intN_t -> uintN_t
 1.15 20-Dec-2004  christos revert previous change while discussion is in progress.
 1.14 20-Dec-2004  itojun RFC cannot be used as manpage regarding to the ISOC copyright boilerplate.
remove it until someone writes it up from scratch/freely-redistributable
text is found.
 1.13 21-May-2004  itojun inet6_{option,rthdr}_space are still alive.
 1.12 21-May-2004  christos Finish bind9 resolver merge.
 1.11 07-Sep-2003  wiz Consistently use 'RFC 1234' instead of 'RFC1234' or 'RFC-1234'.
From jmc@openbsd.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 03-May-2003  wiz Misc. fixes from jmc@openbsd.
 1.8 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.7 02-Oct-2002  wiz Correct spelling of "constraints". Noted by Adrian Mrva.
 1.6 07-Feb-2002  ross Generate <>& symbolically.
 1.5 16-Sep-2001  wiz Sort sections, sort SEE ALSO, and misc. fixes.
 1.4 17-May-2000  itojun branches: 1.4.6;
nroff correction. from openbsd.
 1.3 17-May-2000  itojun typo in function name
 1.2 17-May-2000  itojun correct use of .Dt. nuke space at EOL. wording (duplicated verb).
 1.1 12-Dec-1999  itojun branches: 1.1.2;
add manpage for inet6_{option,rthdr}_*.
 1.1.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.6.4 18-Oct-2002  nathanw Catch up to -current.
 1.4.6.3 22-Mar-2002  nathanw Catch up to -current.
 1.4.6.2 08-Mar-2002  nathanw Catch up to -current.
 1.4.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.4 17-Mar-2024  andvar s/argumment/argument/ in documentation.
 1.3 04-Dec-2022  uwe Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.2 04-Jan-2014  wiz Sort sections. Remove trailing whitespace.
 1.1 05-May-2006  rpaulo branches: 1.1.44; 1.1.50;
Add support for RFC 3542 Adv. Socket API for IPv6 (which obsoletes 2292).
* RFC 3542 isn't binary compatible with RFC 2292.
* RFC 2292 support is on by default but can be disabled.
* update ping6, telnet and traceroute6 to the new API.

From the KAME project (www.kame.net).
Reviewed by core.
 1.1.50.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.44.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.18 04-Dec-2022  uwe Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.17 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.16 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.15 20-Dec-2004  christos revert previous change while discussion is in progress.
 1.14 20-Dec-2004  itojun RFC cannot be used as manpage regarding to the ISOC copyright boilerplate.
remove it until someone writes it up from scratch/freely-redistributable
text is found.
 1.13 21-May-2004  itojun inet6_{option,rthdr}_space are still alive.
 1.12 21-May-2004  christos Finish bind9 resolver merge.
 1.11 07-Sep-2003  wiz Consistently use 'RFC 1234' instead of 'RFC1234' or 'RFC-1234'.
From jmc@openbsd.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 03-May-2003  wiz Misc. fixes from jmc@openbsd.
 1.8 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.7 07-Feb-2002  ross generate & symbolically
 1.6 07-Feb-2002  ross Generate <>& symbolically.
 1.5 16-Sep-2001  wiz Sort sections, sort SEE ALSO, and misc. fixes.
 1.4 17-May-2000  itojun branches: 1.4.6;
linebreak fix (nroff tradition)
 1.3 17-May-2000  itojun correct use of .Dt. nuke space at EOL. wording (duplicated verb).
 1.2 12-Dec-1999  itojun branches: 1.2.2;
inet6_rthdr_reverse() is not implemented yet.
 1.1 12-Dec-1999  itojun add manpage for inet6_{option,rthdr}_*.
 1.2.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.6.3 22-Mar-2002  nathanw Catch up to -current.
 1.4.6.2 08-Mar-2002  nathanw Catch up to -current.
 1.4.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.3 14-Dec-2015  ozaki-r KNF
 1.2 19-Oct-2013  christos branches: 1.2.4; 1.2.8;
use new constants
 1.1 19-Oct-2013  christos add inet6_scopeid
 1.2.8.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.8.1 19-Oct-2013  tls file inet6_scopeid.c was added on branch tls-maxphys on 2014-08-20 00:02:15 +0000
 1.2.4.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.4.1 19-Oct-2013  yamt file inet6_scopeid.c was added on branch yamt-pagecache on 2014-05-22 11:36:53 +0000
 1.8 07-Jul-1997  christos inet_pton4() did not handle
- incompletely specified ip addresses
- ip addresses specified in hex
like inet_aton() and inet_addr(). This broke parsing of /etc/hosts
(127.1 localhost stopped working before the resolver is started).
The fix is to use the inet_aton() code to implement inet_pton4(), and
then use the new inet_pton4() code to implement inet_aton() and inet_addr().
At that point inet_addr.c is empty and has been removed.
 1.7 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.6 02-Feb-1996  mrg branches: 1.6.2;
merge with the resolver in bind 4.9.3-P1.
 1.5 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.4 07-Apr-1994  deraadt new resolver. changes from 4.9.2 by <paul@vix.com>, as well as a number
of features and optimizations by myself.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.5 02-Feb-1998  mrg import lite-2 libc/net sources.
 1.1.1.4 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.3 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.11 21-May-2004  christos Finish bind9 resolver merge.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 05-May-2003  bjh21 ANSIfy, since I'm in the area.
 1.8 05-May-2003  bjh21 Fix the signatures of inet_addr(), inet_lnaof(), inet_makeaddr(), inet_netof(),
and inet_network() to match XNS and (where applicable) POSIX. This is largely
just the replacement of unsigned long with in_addr_t.

This constitutes a small ABI change on sh5, but scw (sh5 portmaster) thinks
that both the users of that port will be able to cope. kleink claims the
change is ABI-neutral on other LP64 ports, and it's a no-op on ILP32 ports.
Hence, I'm doing it this way and avoiding the whole __RENAME dance.
 1.7 22-Jan-2000  mycroft branches: 1.7.8;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.7.8.1 27-Oct-2003  jmc Bring BIND up to 8.3.6 (requested by itojun in ticket #1536)
 1.16 21-May-2004  christos Finish bind9 resolver merge.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 05-May-2003  bjh21 ANSIfy, since I'm in the area.
 1.13 05-May-2003  bjh21 Handle struct in_addr with proper respect, rather than assuming we can
make one by casting in in_addr_t *. This has the pleasant side-effect
of making the machine code shorter, at least on ARM.
 1.12 05-May-2003  bjh21 Remove some lint-pacification that's not necessary now that the signature of
inet_makeaddr() is correct.
 1.11 05-May-2003  bjh21 Fix the signatures of inet_addr(), inet_lnaof(), inet_makeaddr(), inet_netof(),
and inet_network() to match XNS and (where applicable) POSIX. This is largely
just the replacement of unsigned long with in_addr_t.

This constitutes a small ABI change on sh5, but scw (sh5 portmaster) thinks
that both the users of that port will be able to cope. kleink claims the
change is ABI-neutral on other LP64 ports, and it's a no-op on ILP32 ports.
Hence, I'm doing it this way and avoiding the whole __RENAME dance.
 1.10 14-Feb-2002  augustss branches: 1.10.2;
Make this lintable so we can build libc again.
 1.9 14-Feb-2002  martin Fix a LP64 problem. Patch from Minoura Makoto in PR lib/15596.
 1.8 22-Jan-2000  mycroft branches: 1.8.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.7 13-Nov-1998  christos delint
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.8.6.2 22-Mar-2002  nathanw Catch up to -current.
 1.8.6.1 08-Mar-2002  nathanw Catch up to -current.
 1.10.2.1 27-Oct-2003  jmc Bring BIND up to 8.3.6 (requested by itojun in ticket #1536)
 1.10 21-May-2004  christos Finish bind9 resolver merge.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 08-Dec-2001  lukem Implement AF_INET6 back-ends for inet_net_ntop() and inet_net_pton(), from
the BIND 8.3.0-T2A sources. Thanks to Paul Vixie for the pointer to it.
 1.6 16-Sep-2001  wiz Sort sections, sort SEE ALSO, and misc. fixes.
 1.5 16-Sep-2001  wiz Boring whitespace fixes.
 1.4 22-Mar-1999  garbled branches: 1.4.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.3 05-Feb-1998  perry add LIBRARY section to man page
 1.2 30-Jul-1997  jtc Fix files using old TNF copyright notice
 1.1 18-Jun-1997  lukem * add man page for inet_net_ntop(3) and inet_net_pton(3)
* xref them in inet(3)
* use Va instead of Fn for 'errno' in inet(3)
 1.4.12.4 22-Mar-2002  nathanw Catch up to -current.
 1.4.12.3 08-Mar-2002  nathanw Catch up to -current.
 1.4.12.2 28-Jan-2002  nathanw Catch up to -current.
 1.4.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.20 21-May-2004  christos Finish bind9 resolver merge.
 1.19 17-Nov-2002  itojun make sure to bound string operation by strlcpy
(there are bunch of "strcpy is safe" comments, i think we should change them
to strlcpy as much as possible)
 1.18 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.17 16-Aug-2002  itojun be more picky about size arg
 1.16 16-Aug-2002  itojun lint clean
 1.15 16-Aug-2002  itojun avoid sprintf. use snprintf with picky error traps.
 1.14 09-Dec-2001  lukem - be consistent about using "u_char" instead of "unsigned char"
- delint
 1.13 08-Dec-2001  lukem Implement AF_INET6 back-ends for inet_net_ntop() and inet_net_pton(), from
the BIND 8.3.0-T2A sources. Thanks to Paul Vixie for the pointer to it.
 1.12 08-Dec-2001  lukem ansi knf
 1.11 23-Apr-2000  itojun branches: 1.11.6;
synchronize better with BIND 8.2.2P5 (actually, src/dist/bind).
inet_net_pton() becomes more strict on hexadecimals/octals.
 1.10 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.9 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.8 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.7 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.4 16-Jul-1997  christos When removing $'s to preserve rcsid's remove them from both sides.
 1.3 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.2 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.1 13-Apr-1997  mrg branches: 1.1.1;
Initial revision
 1.1.1.2 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.1 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.11.6.3 10-Dec-2002  thorpej Sync with HEAD.
 1.11.6.2 27-Aug-2002  nathanw Catch up to -current.
 1.11.6.1 28-Jan-2002  nathanw Catch up to -current.
 1.17 21-May-2004  christos Finish bind9 resolver merge.
 1.16 08-Dec-2001  lukem Implement AF_INET6 back-ends for inet_net_ntop() and inet_net_pton(), from
the BIND 8.3.0-T2A sources. Thanks to Paul Vixie for the pointer to it.
 1.15 01-Dec-2001  lukem ansi knf. remove unused cruft
 1.14 07-Jul-2000  itohy branches: 1.14.2;
Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.
 1.13 06-Jul-2000  christos remove noop checks
 1.12 23-Apr-2000  itojun synchronize better with BIND 8.2.2P5 (actually, src/dist/bind).
inet_net_pton() becomes more strict on hexadecimals/octals.
 1.11 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.10 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.9 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.8 13-Nov-1998  christos delint
 1.7 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.4 16-Jul-1997  christos When removing $'s to preserve rcsid's remove them from both sides.
 1.3 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.2 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.1 13-Apr-1997  mrg branches: 1.1.1;
Initial revision
 1.1.1.2 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.1 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.14.2.1 28-Jan-2002  nathanw Catch up to -current.
 1.16 21-May-2004  christos Finish bind9 resolver merge.
 1.15 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.14 16-Aug-2002  itojun check for pointer overwrap
 1.13 16-Aug-2002  itojun correct cases with zero in the middle
(0x00ff00ff should be "0.255.0.255", not "255.255")
 1.12 16-Aug-2002  itojun avoid sprintf. use snprintf. simplify cases where 1st arg is 0.
 1.11 22-Jan-2000  mycroft branches: 1.11.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.10 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.9 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.8 13-Nov-1998  christos delint
 1.7 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.4 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.3 14-Apr-1997  cgd pull in string.h for protos. found by John Franklin (PR 3487), and noticed
by me about 2 minutes before I received the PR.
 1.2 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.1 13-Apr-1997  mrg branches: 1.1.1;
Initial revision
 1.1.1.2 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.1 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.11.6.2 10-Dec-2002  thorpej Sync with HEAD.
 1.11.6.1 27-Aug-2002  nathanw Catch up to -current.
 1.12 21-May-2004  christos Finish bind9 resolver merge.
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 05-May-2003  bjh21 ANSIfy, since I'm in the area.
 1.9 05-May-2003  bjh21 Delint last change (change a variable from unsigned long to in_addr_t).
Remove "register" at the same time.
 1.8 05-May-2003  bjh21 Fix the signatures of inet_addr(), inet_lnaof(), inet_makeaddr(), inet_netof(),
and inet_network() to match XNS and (where applicable) POSIX. This is largely
just the replacement of unsigned long with in_addr_t.

This constitutes a small ABI change on sh5, but scw (sh5 portmaster) thinks
that both the users of that port will be able to cope. kleink claims the
change is ABI-neutral on other LP64 ports, and it's a no-op on ILP32 ports.
Hence, I'm doing it this way and avoiding the whole __RENAME dance.
 1.7 22-Jan-2000  mycroft branches: 1.7.8;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.7.8.1 27-Oct-2003  jmc Bring BIND up to 8.3.6 (requested by itojun in ticket #1536)
 1.20 21-May-2004  christos Finish bind9 resolver merge.
 1.19 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.18 10-Jul-2003  tshiozak make _DIAGNOSTIC happy.
 1.17 05-May-2003  bjh21 ANSIfy, since I'm in the area.
 1.16 05-May-2003  bjh21 Delint last change, reducing size of several variables.
 1.15 05-May-2003  bjh21 Fix the signatures of inet_addr(), inet_lnaof(), inet_makeaddr(), inet_netof(),
and inet_network() to match XNS and (where applicable) POSIX. This is largely
just the replacement of unsigned long with in_addr_t.

This constitutes a small ABI change on sh5, but scw (sh5 portmaster) thinks
that both the users of that port will be able to cope. kleink claims the
change is ABI-neutral on other LP64 ports, and it's a no-op on ILP32 ports.
Hence, I'm doing it this way and avoiding the whole __RENAME dance.
 1.14 22-Jul-2001  itojun branches: 1.14.2;
make sure we do not touch *pp outside of parts[4].
 1.13 07-Jul-2000  itohy branches: 1.13.2;
Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.
 1.12 06-Jul-2000  christos de-register
use the proper types for vars
 1.11 23-Apr-2000  itojun branches: 1.11.4;
synchronize better with BIND 8.2.2P5 (actually, src/dist/bind).
inet_net_pton() becomes more strict on hexadecimals/octals.
 1.10 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.9 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.8 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.5 17-Feb-1996  hpeyerl branches: 1.5.2;
Fix inet addr parsing so no more than 4 octets are valid.
From Amy Baron (amee@remarque.berkeley.edu). Fixes PR#2089. (BFPR)
 1.4 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.11.4.1 03-Sep-2000  jhawk Pullup rev 1.12-1.13, approved by thorpej, requested by jhawk:
> revision 1.13
> date: 2000/07/07 08:03:39; author: itohy; state: Exp; lines: +4 -4
> Passing "char" values to ctype(3) functions is problematic.
> If an argument of a ctype function is outside "unsigned char"
> and if it is not EOF, the behavior is undefined.
>
> The isascii(3) is the sole exception of above and it was used to
> be used to check a value was valid for other ctype functions in
> ancient systems. On modern systems, the ctype functions take
> all values of "unsigned char", and this check is obsolete and
> even wrong for non-ASCII systems. However, we leave the isascii()
> untouched for now, so as not to change the current behavior.
> ----------------------------
> revision 1.12
> date: 2000/07/06 02:57:23; author: christos; state: Exp; lines: +5 -4
> de-register
> use the proper types for vars
 1.13.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.14.2.1 27-Oct-2003  jmc Bring BIND up to 8.3.6 (requested by itojun in ticket #1536)
 1.12 21-May-2004  christos Finish bind9 resolver merge.
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 17-Nov-2002  itojun make sure to bound string operation by strlcpy
(there are bunch of "strcpy is safe" comments, i think we should change them
to strlcpy as much as possible)
 1.9 23-Apr-2000  itojun branches: 1.9.6;
synchronize better with BIND 8.2.2P5 (actually, src/dist/bind).
inet_net_pton() becomes more strict on hexadecimals/octals.
 1.8 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.7 13-Nov-1998  christos delint
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.9.6.1 10-Dec-2002  thorpej Sync with HEAD.
 1.14 21-May-2004  christos Finish bind9 resolver merge.
 1.13 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.12 23-Aug-2002  itojun off-by-one. PR 18049
correct snprintf() return value handling in another place.
 1.11 16-Aug-2002  itojun be more picky about string buffer manipulation. hints from freebsd
 1.10 14-May-2002  kleink branches: 1.10.2;
XNS5.2/POSIX-2001: change the size argument to inet_ntop from size_t to
socklen_t.
 1.9 22-Jan-2000  mycroft branches: 1.9.4; 1.9.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.8 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.7 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.6 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.5 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.4 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.3 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.2 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.1 13-Apr-1997  mrg branches: 1.1.1;
Initial revision
 1.1.1.2 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.1 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.9.6.3 10-Dec-2002  thorpej Sync with HEAD.
 1.9.6.2 27-Aug-2002  nathanw Catch up to -current.
 1.9.6.1 21-Jun-2002  nathanw Catch up to -current.
 1.9.4.1 04-Sep-2002  itojun lib/libc/net/inet_ntop.c 1.11-1.12 (itojun)

be more picky about string buffer manipulation. hints from freebsd.
correct snprintf return value handling.
 1.10.2.2 27-Aug-2002  lukem Pull up revision 1.12 (requested by itojun in ticket #721):
off-by-one. PR 18049
correct snprintf() return value handling in another place.
 1.10.2.1 27-Aug-2002  lukem Pull up revision 1.11 (requested by itojun in ticket #721):
be more picky about string buffer manipulation. hints from freebsd
 1.20 21-May-2004  christos Finish bind9 resolver merge.
 1.19 05-May-2003  bjh21 ANSIfy, since I'm in the area.
 1.18 05-May-2003  bjh21 Fix the signatures of inet_addr(), inet_lnaof(), inet_makeaddr(), inet_netof(),
and inet_network() to match XNS and (where applicable) POSIX. This is largely
just the replacement of unsigned long with in_addr_t.

This constitutes a small ABI change on sh5, but scw (sh5 portmaster) thinks
that both the users of that port will be able to cope. kleink claims the
change is ABI-neutral on other LP64 ports, and it's a no-op on ILP32 ports.
Hence, I'm doing it this way and avoiding the whole __RENAME dance.
 1.17 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.16 07-Feb-2000  itojun branches: 1.16.6; 1.16.8;
fix behavior of inet_pton() to be RFC2553/XNS compliant.
inet_pton() takes decimal dot-quads only. inet_pton() does not
take hexadecimal, octal nor classful (short) representation.
 1.15 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.14 13-Nov-1999  is Properly check for overflows. Fixes PR8314 as annotated by mjl.
 1.13 03-Nov-1999  is Check for invalid component numbers (wrong hex "digits", octal numbers
with digits of 8 or 9) and complain. Fixes PR 8314 by ITOH Yasufumi (but
adding the check of hexadecimal numbers).
 1.12 20-Sep-1999  lukem branches: 1.12.2;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.11 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.10 17-Aug-1999  itojun bring in IPv6 numeric address parsing fix from bind821.
XXX bind821 should be imported here
 1.9 13-Nov-1998  christos branches: 1.9.2;
delint
 1.8 13-Oct-1998  kleink Need an internal name for inet_aton().
 1.7 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.4 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.3 07-Jul-1997  christos inet_pton4() did not handle
- incompletely specified ip addresses
- ip addresses specified in hex
like inet_aton() and inet_addr(). This broke parsing of /etc/hosts
(127.1 localhost stopped working before the resolver is started).
The fix is to use the inet_aton() code to implement inet_pton4(), and
then use the new inet_pton4() code to implement inet_aton() and inet_addr().
At that point inet_addr.c is empty and has been removed.
 1.2 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.1 13-Apr-1997  mrg branches: 1.1.1;
Initial revision
 1.1.1.2 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.1 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.9.2.3 20-Nov-1999  he Pull up revision 1.14 (requested by is):
Do proper overflow checking of IPv4 addresses, fixing PR#8314.
 1.9.2.2 05-Nov-1999  cgd pull up rev 1.13 from trunk (requested by is):
Check for invalid digits in number components. Fixes PR#8314.
 1.9.2.1 20-Oct-1999  he Pull up revision 1.10 (requested by itojun):
Fix IPv6 parsing for the benefit of BIND.
 1.12.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.16.8.1 27-Oct-2003  jmc Bring BIND up to 8.3.6 (requested by itojun in ticket #1536)
 1.16.6.1 10-Dec-2002  thorpej Sync with HEAD.
 1.15 07-Feb-2014  christos RFC 3542 (section 10.1) states that optlen should only be checked when
opt != NULL (Eitan Adler)
 1.14 20-Mar-2012  matt branches: 1.14.2;
Use C89 Prototypes.
Remove use of __P
 1.13 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.12 30-Jan-2009  lukem branches: 1.12.8;
sign-compare fix
 1.11 05-May-2006  rpaulo Add support for RFC 3542 Adv. Socket API for IPv6 (which obsoletes 2292).
* RFC 3542 isn't binary compatible with RFC 2292.
* RFC 2292 support is on by default but can be disabled.
* update ping6, telnet and traceroute6 to the new API.

From the KAME project (www.kame.net).
Reviewed by core.
 1.10 29-Nov-2005  christos WARNS=4
 1.9 05-May-2002  simonb Remove a check for a u_int8_t variable being greater than 255.
 1.8 06-Jul-2000  christos branches: 1.8.2;
elide non portable casts
add lint const castaway directives
 1.7 24-Apr-2000  itojun add __RCSID().
 1.6 24-Apr-2000  itojun supply weak alias for IPv6-related library additions. sorry to be late.
 1.5 23-Jan-2000  mycroft Partially delint.
 1.4 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.3 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.2 04-Jul-1999  itojun add NetBSD RCSID on top.
 1.1 01-Jul-1999  itojun add IPv6 support functions.

get{addr,name} info are implemented to have as little impact to existing
resolver code as possible, so they are NOT the optimal implementation.
They are at this moment not very thread safe (as they call
gethostby{name,addr}).

(shlib minor version)++, as new interfaces are added.

TODO: getipnodeby{name,addr} - which needs total reimplementation of
gethostby{name,addr}.
upgrade rcmd.c for multiple af support (needed for IPv6-ready rsh/rlogin)
 1.8.2.1 21-Jun-2002  nathanw Catch up to -current.
 1.12.8.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12.8.1 17-Apr-2012  yamt sync with head
 1.14.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10 01-Mar-2013  joerg Retire OSI network stack. OK core@
 1.9 11-Apr-2009  joerg branches: 1.9.6; 1.9.12;
Remove reundant quote.
 1.8 07-Aug-2003  agc branches: 1.8.42;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.6 07-Feb-2002  ross Generate <>& symbolically.
 1.5 16-Sep-2001  wiz Boring whitespace fixes.
 1.4 05-Feb-1998  perry branches: 1.4.12;
add LIBRARY section to man page
 1.3 09-Nov-1996  lukem add 'const' qualifiers to various routines (as per the include prototypes
and the implementation)
 1.2 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.1 25-Feb-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.4.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.4.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.4.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.8.42.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.9.12.1 23-Jun-2013  tls resync from head
 1.9.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.15 01-Mar-2013  joerg Retire OSI network stack. OK core@
 1.14 20-Mar-2012  matt branches: 1.14.2;
Use C89 Prototypes.
Remove use of __P
 1.13 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.12 29-Nov-2005  christos branches: 1.12.44;
WARNS=4
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.9 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.8 13-Nov-1998  christos delint
 1.7 15-Oct-1998  kleink (bcmp(), bcopy(), bzero()) -> (memcmp(), memcpy(), memset())
 1.6 26-Jul-1998  mycroft const poisoning.
 1.5 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.12.44.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12.44.1 17-Apr-2012  yamt sync with head
 1.14.2.1 23-Jun-2013  tls resync from head
 1.13 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.12 07-Dec-2016  pgoyette More tweaking...
 1.11 07-Dec-2016  pgoyette Update BUGS section to note the possibility of a truncated return value.
 1.10 07-Aug-2003  agc branches: 1.10.80;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.8 07-Feb-2002  ross Generate <>& symbolically.
 1.7 16-Sep-2001  wiz Boring whitespace fixes.
 1.6 25-Jun-1999  sommerfeld branches: 1.6.10;
Clarify that sdl->sdl_len must be initialized before call to link_addr()
 1.5 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.4 28-Apr-1998  fair fix mdoc references
 1.3 05-Feb-1998  perry add LIBRARY section to man page
 1.2 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.1 25-Feb-1995  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.6.10.3 22-Mar-2002  nathanw Catch up to -current.
 1.6.10.2 08-Mar-2002  nathanw Catch up to -current.
 1.6.10.1 08-Oct-2001  nathanw Catch up to -current.
 1.10.80.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.23 19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.22 07-Dec-2016  pgoyette Fix comment: s/ACCD/ADDC/
 1.21 07-Dec-2016  kre Actually guarantee that the returned buffer from link_ntoa() is always
NUL terminated, even when called by malicious/broken applications.
 1.20 07-Dec-2016  christos make it always return a NUL terminated string instead of NULL when the address
is truncated for compatibility with others.
 1.19 07-Dec-2016  christos Add the terminating NUL as a regular character addition.
 1.18 07-Dec-2016  dholland Leave room for the null terminator. Spotted by DuClare on freenode.
 1.17 06-Dec-2016  christos Fix buffer copy without checking the size of input:
https://www.kb.cert.org/vuls/id/548487
 1.16 20-Mar-2012  matt branches: 1.16.14;
Use C89 Prototypes.
Remove use of __P
 1.15 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.14 29-Nov-2005  christos branches: 1.14.44;
WARNS=4
 1.13 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.11 20-Sep-1999  lukem branches: 1.11.10;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.10 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.9 13-Nov-1998  christos delint
 1.8 15-Oct-1998  kleink (bcmp(), bcopy(), bzero()) -> (memcmp(), memcpy(), memset())
 1.7 26-Jul-1998  mycroft const poisoning.
 1.6 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.5 25-Feb-1995  cgd branches: 1.5.4;
clean up import. also convert everything to new Id format.
 1.4 19-Oct-1994  cgd beware pointer casts.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.11.10.1 10-Dec-2002  thorpej Sync with HEAD.
 1.14.44.1 17-Apr-2012  yamt sync with head
 1.16.14.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.17 26-Aug-2006  matt Remove the XNS man pages.
 1.16 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.15 03-May-2003  wiz Misc. fixes from jmc@openbsd.
 1.14 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.13 31-Mar-2003  perry millenia->millennia from Igor Sobrado PR misc/19814
 1.12 07-Feb-2002  ross Generate <>& symbolically.
 1.11 16-Sep-2001  wiz Sort sections, sort SEE ALSO, and misc. fixes.
 1.10 16-Sep-2001  wiz Boring whitespace fixes.
 1.9 08-Jul-2001  jdolecek remove trailing whitespace
 1.8 05-Oct-2000  ad branches: 1.8.2;
insure -> ensure
 1.7 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.6 05-Feb-1998  perry add LIBRARY section to man page
 1.5 06-Oct-1997  hubertf add xref of ns.4
 1.4 09-Nov-1996  lukem add 'const' qualifiers to various routines (as per the include prototypes
and the implementation)
 1.3 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.8.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.8.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.18 26-Aug-2006  matt Move ns_addr and ns_ntoa to compat libc. Add a stripped version of
<netns/ns.h> which only include struct ns_addr and the ns_addr and ns_ntoa
function prototypes.
 1.17 09-May-2004  kleink Need namespace.h for internal name of strlcpy.
 1.16 07-Aug-2003  agc branches: 1.16.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.15 17-Nov-2002  itojun use strlcpy where it is more appropriate.
 1.14 25-Jun-2001  jdolecek Change ns_addr() to allocate 'addr' on stack, rather than using a global -
we don't need a global variable here.
 1.13 17-Jun-2001  jdolecek Fix fallout from variable string format audit, so that this works again.
 1.12 11-Jun-2001  wiz Fix various misspellings of compatible/compatibility.
 1.11 04-Oct-2000  sommerfeld branches: 1.11.2;
Avoid compile-time variable format string (format audit)
 1.10 20-Sep-1999  lukem branches: 1.10.8;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.9 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.8 13-Nov-1998  christos branches: 1.8.2;
delint
 1.7 18-Jul-1997  thorpej Be careful with types. XXX sys/netns needs to be swept, but this addresses
libc, at least.
 1.6 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.5 25-Feb-1995  cgd branches: 1.5.4;
clean up import. also convert everything to new Id format.
 1.4 25-May-1994  cgd kill typo, pointed out by John Hay <jhay@mikom.csir.co.za>
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.8.2.1 20-Oct-2000  he Pull up revision 1.11 (requested by is):
Avoid use of variable string fmt.
 1.10.8.1 20-Oct-2000  tv Pullup 1.11 [is]:
avoid use of variable string fmt.
 1.11.2.2 10-Dec-2002  thorpej Sync with HEAD.
 1.11.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.16.2.1 11-May-2004  tron Pull up revision 1.17 (requested by kleink in ticket #294):
Need namespace.h for internal name of strlcpy.
 1.13 26-Aug-2006  matt Move ns_addr and ns_ntoa to compat libc. Add a stripped version of
<netns/ns.h> which only include struct ns_addr and the ns_addr and ns_ntoa
function prototypes.
 1.12 23-Sep-2003  itojun out-of-bounds access. from openbsd
 1.11 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.10 27-Aug-2002  itojun kill register decl
 1.9 16-Sep-1999  lukem branches: 1.9.10;
* use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.8 13-Nov-1998  christos delint
 1.7 18-Jul-1997  thorpej Be careful with types. XXX sys/netns needs to be swept, but this addresses
libc, at least.
 1.6 17-Jul-1997  thorpej The return value from ntohl() is an in_addr_t, and should not be printed
with a "long" format modifier.
 1.5 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.4 25-Feb-1995  cgd branches: 1.4.4;
clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.4.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.9.10.1 17-Sep-2002  nathanw Catch up to -current.
 1.13 21-May-2004  christos Finish bind9 resolver merge.
 1.12 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.10 22-Jan-2000  mycroft branches: 1.10.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.9 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.8 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.7 13-Nov-1998  christos delint
 1.6 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.5 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.4 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.3 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.2 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.1 02-Feb-1996  mrg branches: 1.1.1; 1.1.2;
merge with the resolver in bind 4.9.3-P1.
 1.1.2.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.1.1.2 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.1 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.10.6.1 10-Dec-2002  thorpej Sync with HEAD.
 1.34 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.33 04-Jan-2015  wiz Add more markup.
 1.32 04-Jan-2015  christos Correct API for the gethostby{name,addr}
 1.31 28-Apr-2011  wiz Markup fixes.
 1.30 26-Jan-2011  njoly Add section 3 for getpwuid_r xref.
 1.29 14-Oct-2009  joerg branches: 1.29.2;
Do not nest displays, use lists instead. Discussed with wiz.
Fix markup.
 1.28 08-May-2008  lukem branches: 1.28.6;
Convert getnetbyname(3) and getnetbyaddr(3) to the more "standard"
nsdispatch() backend method API.
 1.27 30-Apr-2008  martin branches: 1.27.2;
Convert TNF licenses to new 2 clause variant
 1.26 19-Apr-2008  lukem Document the callback API used by "standard" functions.
NOTE: some of these will be changing in the future to be more
consistent with the technique used in the group & passwd backends.
I'm just documenting the existing behaviour.

Be more consistent when using certain terms.
Rename some variables to reduce confusion.
 1.25 07-Apr-2008  lukem branches: 1.25.2;
The ns_mtab.mdata is passed to the ns_mtab.method as the cbdata argument.
 1.24 07-Apr-2008  lukem Improve description of the arguments and return values of
various methods & callbacks.
Improve markup.
 1.23 26-Dec-2005  perry u_intN_t -> uintN_t
 1.22 29-Sep-2004  wiz Fix a typo, fix an xref, an drop a space at EOL.
 1.21 29-Sep-2004  lukem Implement NS_FORCEALL, which may be set in defaults[0].flags by a caller of
nsdispatch(3) to indicate that all available database methods for a source
will be invoked. This is useful for functions such as endgrent(3).
 1.20 28-Sep-2004  lukem slight formatting tweaks
 1.19 28-Sep-2004  lukem s/foe/for/
 1.18 27-Sep-2004  lukem correct the va_list arg for nss_method
 1.17 27-Jul-2004  wiz Use \*[Lt]\*[Gt] or Aq instead of <>; sort SEE ALSO.
 1.16 24-Jul-2004  thorpej Add support for dynamically loading nsswitch modules on ELF platforms.
Adapted from FreeBSD. Maintains full backward API / ABI compatbility
with built-in-only nsdispatch().

While here, also make nsdispatch() itself thread-safe.
 1.15 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.14 01-Jul-2003  wiz Va Sq -> Sq Va so both work.
 1.13 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.12 04-Sep-2002  wiz implemented, not implementated; arbitrary, not arbritrary.
 1.11 07-Feb-2002  ross Generate <>& symbolically.
 1.10 16-Sep-2001  wiz Sort sections, sort SEE ALSO, and misc. fixes.
 1.9 16-Sep-2001  wiz Boring whitespace fixes.
 1.8 22-Mar-1999  garbled branches: 1.8.12;
Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.7 10-Feb-1999  kleink Add missing LIBRARY section.
 1.6 09-Feb-1999  lukem nsdispatch isn't currently thread safe; highlight this as a bug
 1.5 20-Jan-1999  lukem s/missing or absent/missing or corrupt/
 1.4 19-Jan-1999  lukem * support extra two arguments to nsdispatch():
const char *method /* method name for dynamic linking */
const ns_src defaults[] /* list of defaults */
* document above, and expand other docco.
 1.3 16-Jan-1999  lukem clarify that the lack of support for dynamic loading is only for callback funcs
 1.2 15-Jan-1999  lukem merge nsswitch into main branch
 1.1 06-Nov-1996  lukem branches: 1.1.2; 1.1.4;
file nsdispatch.3 was initially added on branch nsswitch.
 1.1.4.3 14-Jan-1999  lukem major rework to support arbitrary sources. rename all internal functions to
be consistent (e.g, __nsdbtget(), __nsdbtdump(), __nsdbtput())
 1.1.4.2 02-Nov-1998  lukem sync with current, assign my copyrights to TNF
 1.1.4.1 23-May-1997  lukem * Add nsdispatch(3) implementation
* Deprecate support for "lookup" in resolv.conf
 1.1.2.1 06-Nov-1996  lukem initial nsswitch implementation
 1.8.12.4 17-Sep-2002  nathanw Catch up to -current.
 1.8.12.3 22-Mar-2002  nathanw Catch up to -current.
 1.8.12.2 08-Mar-2002  nathanw Catch up to -current.
 1.8.12.1 08-Oct-2001  nathanw Catch up to -current.
 1.25.2.1 18-May-2008  yamt sync with head.
 1.27.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.28.6.2 08-May-2008  lukem Convert getnetbyname(3) and getnetbyaddr(3) to the more "standard"
nsdispatch() backend method API.
 1.28.6.1 08-May-2008  lukem file nsdispatch.3 was added on branch christos-time_t on 2008-05-08 13:01:43 +0000
 1.29.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.39 19-Apr-2022  rillig lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.
 1.38 18-Sep-2014  christos make more descriptors that we open as close-on-exec
 1.37 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.36 22-Feb-2011  joerg branches: 1.36.4;
Introduce __weakref_visible to handle the different required visibility
for weak references. GCC 4.2+ and Clang require static, older GCC wants
extern. Change __weak_reference to include sym. This requires changes
the existing users to not reuse the name of the symbol, but avoids
further differences between GCC 4.1 and GCC 4.2+/clang.
 1.35 18-Feb-2011  joerg Support the different weakref semantic in GCC 4.2 and clang.
 1.34 05-Feb-2009  lukem branches: 1.34.4;
sign-compare fix
 1.33 17-Aug-2008  gmcgarry branches: 1.33.6;
Changee __attribute(__weak__) to __weak_reference(). Produces same object code
and matches lib/csu/common_elf/common.h. Fixes linkage with PCC.
 1.32 28-Apr-2008  martin branches: 1.32.2;
Remove clause 3 and 4 from TNF licenses
 1.31 15-Oct-2006  christos branches: 1.31.16;
fix incomplete initializers
 1.30 29-Nov-2005  christos WARNS=4
 1.29 26-Jun-2005  thorpej _nsdispatching needs to count, not just be 1 or 0. Also shuffle around
its use a little to eliminate some duplication.
 1.28 10-Nov-2004  lukem branches: 1.28.2;
* Improve the comments in <nsswitch.h>
* Provide some more useful default ns_src arrays.
 1.27 04-Oct-2004  lukem * Re-number NS_FORCEALL from 1<<7 to 1<<8, moving it out of the "public"
bitrange for nsdispatch(3) return values.
* Tweak documentation comments in nsswitch.h
* Ensure the result from the back-end method is masked with
NS_STATUSMASK before nsdispatch(3) returns it.
 1.26 29-Sep-2004  lukem Implement NS_FORCEALL, which may be set in defaults[0].flags by a caller of
nsdispatch(3) to indicate that all available database methods for a source
will be invoked. This is useful for functions such as endgrent(3).
 1.25 28-Sep-2004  lukem also ensure defaults != NULL
 1.24 08-Sep-2004  simonb Fix non-ELF case in _nsloadmod().
 1.23 02-Aug-2004  thorpej Prevent a deadlock that could occur if we try to update the configuration
data structures during a recursive call to nsdispatch() by keeping a record
of which threads are inside nsdispatch() at any given time.
 1.22 24-Jul-2004  thorpej Add support for dynamically loading nsswitch modules on ELF platforms.
Adapted from FreeBSD. Maintains full backward API / ABI compatbility
with built-in-only nsdispatch().

While here, also make nsdispatch() itself thread-safe.
 1.21 16-Jul-2004  thorpej Use ANSI function decls.
 1.20 24-May-2004  christos remove stray NSUNLOCK(); pointed out by Brian Ginsbach.
 1.19 23-May-2004  christos make this thread-safe.
 1.18 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.17 20-Dec-2000  christos branches: 1.17.2;
remove redundant declarations.
 1.16 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.15 28-Nov-1999  lukem don't use err(); instead pass an error condition back to a higher
layer to warn() about.
 1.14 20-Sep-1999  lukem branches: 1.14.4;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.13 16-Sep-1999  lukem return NS_UNAVAIL if args are dodgy
 1.12 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.11 03-May-1999  christos sprinkle argsused till lint smiles at you.
 1.10 18-Apr-1999  lukem specifically include stdarg/varargs.h
 1.9 25-Jan-1999  lukem add rcsids
 1.8 20-Jan-1999  lukem minor knf; don't exceed 80 columns ;)
 1.7 20-Jan-1999  christos - add ARGSUSED
- remove unnecessary casts
- const poisoning
 1.6 20-Jan-1999  lukem weak_alias nsdispatch
 1.5 19-Jan-1999  lukem * support extra two arguments to nsdispatch():
const char *method /* method name for dynamic linking */
const ns_src defaults[] /* list of defaults */
* document above, and expand other docco.
 1.4 17-Jan-1999  lukem fix thinko introduced in last rototilling of nsdispatch; _nsdbtget()
would always return the entry for the first entry looked up. noted by
andrew gillham (manifesting itself as ftp failing to lookup names).
 1.3 16-Jan-1999  lukem remove debugging override of _PATH_NS_CONF
 1.2 15-Jan-1999  lukem merge nsswitch into main branch
 1.1 06-Nov-1996  lukem branches: 1.1.2; 1.1.4;
file nsdispatch.c was initially added on branch nsswitch.
 1.1.4.5 15-Jan-1999  lukem display line number in yacc error messages (using yylineno). minor cleanup
 1.1.4.4 14-Jan-1999  lukem major rework to support arbitrary sources. rename all internal functions to
be consistent (e.g, __nsdbtget(), __nsdbtdump(), __nsdbtput())
 1.1.4.3 02-Nov-1998  lukem sync with current, assign my copyrights to TNF
 1.1.4.2 26-May-1997  lukem reduce # of elems to malloc at once from 17 to 10, due to increased size
of ns_DBT
 1.1.4.1 23-May-1997  lukem * Add nsdispatch(3) implementation
* Deprecate support for "lookup" in resolv.conf
 1.1.2.1 06-Nov-1996  lukem initial nsswitch implementation
 1.14.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.17.2.1 21-Jun-2002  nathanw Catch up to -current.
 1.28.2.1 02-Jul-2005  tron Pull up revision 1.29 (requested by thorpej in ticket #501):
_nsdispatching needs to count, not just be 1 or 0. Also shuffle
around
its use a little to eliminate some duplication.
 1.31.16.1 18-May-2008  yamt sync with head.
 1.32.2.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.33.6.2 17-Aug-2008  gmcgarry Changee __attribute(__weak__) to __weak_reference(). Produces same object code
and matches lib/csu/common_elf/common.h. Fixes linkage with PCC.
 1.33.6.1 17-Aug-2008  gmcgarry file nsdispatch.c was added on branch christos-time_t on 2008-08-17 10:51:20 +0000
 1.34.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.36.4.1 17-Apr-2012  yamt sync with head
 1.13 25-Jun-2012  abs Update old-style definitions to ANSI, remove a couple of register
definitions along the way. Fixed gcc 4.1 build (thank you vax)
 1.12 20-Mar-2012  matt Use C89 Prototypes.
Remove use of __P
 1.11 08-Dec-2010  christos branches: 1.11.6;
use %option noinput
 1.10 08-Dec-2010  joerg input() is not used, so don't provide it.
 1.9 29-Oct-2009  christos use %option instead of #define YY_NO_...
 1.8 28-Apr-2008  martin branches: 1.8.8;
Remove clause 3 and 4 from TNF licenses
 1.7 25-Jan-2004  lukem branches: 1.7.30;
Use syslog(3) instead of err(3) to log errors.
Based on email conversation with Brian Ginsbach.

Add '%option never-interactive' to nslexer.l, to prevent isatty() from
being called unnecessarily.
Per discussion on current-users@ between Christian Biere and Greg Woods.
 1.6 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.5 19-Mar-2002  lukem branches: 1.5.2;
Fixes from Bill Fenner <fenner@research.att.com> for problems he found
in FreeBSD's port of this nsswitch code:

- Don't ignore unknown characters. The old lexer would treat
hosts:!!!!!!!!@@@@@$%^&*()()*$(files{}{}|||++!)(dns
exactly the same as
hosts: files dns

- Recover from errors by looking for the end of a line. This means
that having a syntax error near the top of the file doesn't prevent
a service at the bottom of the file with no syntax error from being
looked up.

Thanks Bill!
 1.4 02-Jul-1999  kleink branches: 1.4.10;
Need "namespace.h".
 1.3 25-Jan-1999  lukem add rcsids
 1.2 15-Jan-1999  lukem merge nsswitch into main branch
 1.1 06-Nov-1996  lukem branches: 1.1.2; 1.1.4;
file nslexer.l was initially added on branch nsswitch.
 1.1.4.4 15-Jan-1999  lukem display line number in yacc error messages (using yylineno). minor cleanup
 1.1.4.3 14-Jan-1999  lukem major rework to support arbitrary sources. rename all internal functions to
be consistent (e.g, __nsdbtget(), __nsdbtdump(), __nsdbtput())
 1.1.4.2 02-Nov-1998  lukem sync with current, assign my copyrights to TNF
 1.1.4.1 23-May-1997  lukem * Add nsdispatch(3) implementation
* Deprecate support for "lookup" in resolv.conf
 1.1.2.1 06-Nov-1996  lukem initial nsswitch implementation
 1.4.10.2 10-Dec-2002  thorpej Sync with HEAD.
 1.4.10.1 22-Mar-2002  nathanw Catch up to -current.
 1.5.2.1 15-Mar-2004  jmc Pullup rev 1.7 (requested by lukem in ticket #1601)

Use syslog(3) instead of err(3) to log errors.
Add '%option never-interactive' to nslexer.l, to prevent isatty() from
being called unnecessarily.
 1.7.30.1 18-May-2008  yamt sync with head.
 1.8.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.8.8.1 28-Apr-2008  martin file nslexer.l was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.11.6.2 30-Oct-2012  yamt sync with head
 1.11.6.1 17-Apr-2012  yamt sync with head
 1.12 20-Mar-2012  matt Use C89 Prototypes.
Remove use of __P
 1.11 05-Feb-2009  lukem branches: 1.11.8;
sign-compare fix
 1.10 28-Apr-2008  martin branches: 1.10.8;
Remove clause 3 and 4 from TNF licenses
 1.9 25-Jan-2004  lukem branches: 1.9.30;
Use syslog(3) instead of err(3) to log errors.
Based on email conversation with Brian Ginsbach.

Add '%option never-interactive' to nslexer.l, to prevent isatty() from
being called unnecessarily.
Per discussion on current-users@ between Christian Biere and Greg Woods.
 1.8 19-Mar-2002  lukem branches: 1.8.2;
Fixes from Bill Fenner <fenner@research.att.com> for problems he found
in FreeBSD's port of this nsswitch code:

- Don't ignore unknown characters. The old lexer would treat
hosts:!!!!!!!!@@@@@$%^&*()()*$(files{}{}|||++!)(dns
exactly the same as
hosts: files dns

- Recover from errors by looking for the end of a line. This means
that having a syntax error near the top of the file doesn't prevent
a service at the bottom of the file with no syntax error from being
looked up.

Thanks Bill!
 1.7 20-Dec-2000  christos branches: 1.7.2;
add _nsyylineno declaration
 1.6 28-Nov-1999  lukem don't use err(); instead pass an error condition back to a higher
layer to warn() about.
 1.5 16-Sep-1999  lukem branches: 1.5.4;
* use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.4 02-Jul-1999  kleink Need "namespace.h".
 1.3 25-Jan-1999  lukem add rcsids
 1.2 15-Jan-1999  lukem merge nsswitch into main branch
 1.1 06-Nov-1996  lukem branches: 1.1.2; 1.1.4;
file nsparser.y was initially added on branch nsswitch.
 1.1.4.4 15-Jan-1999  lukem display line number in yacc error messages (using yylineno). minor cleanup
 1.1.4.3 14-Jan-1999  lukem major rework to support arbitrary sources. rename all internal functions to
be consistent (e.g, __nsdbtget(), __nsdbtdump(), __nsdbtput())
 1.1.4.2 02-Nov-1998  lukem sync with current, assign my copyrights to TNF
 1.1.4.1 23-May-1997  lukem * Add nsdispatch(3) implementation
* Deprecate support for "lookup" in resolv.conf
 1.1.2.1 06-Nov-1996  lukem initial nsswitch implementation
 1.5.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.7.2.1 22-Mar-2002  nathanw Catch up to -current.
 1.8.2.1 15-Mar-2004  jmc Pullup rev 1.9 (requested by lukem in ticket #1601)

Use syslog(3) instead of err(3) to log errors.
Add '%option never-interactive' to nslexer.l, to prevent isatty() from
being called unnecessarily.
 1.9.30.1 18-May-2008  yamt sync with head.
 1.10.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.10.8.1 28-Apr-2008  martin file nsparser.y was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.11.8.1 17-Apr-2012  yamt sync with head
 1.11 20-Dec-2005  christos Use reach-over sources from common/lib/libc
 1.10 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.9 22-Aug-2001  itojun sync argument/return type of [hn]to[nh][ls] to XNET 5.2 (uint{16,32}_t).
as discussed on tech-net.
 1.8 13-Jul-1997  christos branches: 1.8.14;
Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.7 13-Oct-1996  christos in_addr_t and in_port_t changes
 1.6 29-May-1996  cgd Add some casts so that we're not bitten by type promotions on 64-bit
systems. Not a great concern since the only 64-bit system currently
supported by NetBSD (Alpha) uses assembly versions of these routines.
 1.5 28-Apr-1995  jtc branches: 1.5.6;
Winning Strategies has placed this code into the Public Domain
 1.4 25-Feb-1995  cgd use NetBSD rather than ID
 1.3 19-Oct-1994  cgd maybe they should actually... WORK!
 1.2 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.1 31-Aug-1993  jtc Provide C language versions of the netorder functions.
These may be "good enough" for big-endian systems that do not have assembly
language versions of their own. A compiler should be able to do a fairly
good job optimising them, it probably won't be smart enough to omit the
stack frame, but then again, these functions won't be called unless the
macro versions are undef'd.
On the other hand, they are only intended for bootstrap purposes on little-
endian systems. They should be replaced with assembly language versions as
soon as possible.
 1.5.6.1 29-May-1996  cgd Pull revision 1.6 (add casts so we're not bitten by type promotions on
64-bit systems) to the release branch.
 1.8.14.1 08-Oct-2001  nathanw Catch up to -current.
 1.11 20-Dec-2005  christos Use reach-over sources from common/lib/libc
 1.10 26-Jul-2003  salo netbsd.org->NetBSD.org
 1.9 22-Aug-2001  itojun sync argument/return type of [hn]to[nh][ls] to XNET 5.2 (uint{16,32}_t).
as discussed on tech-net.
 1.8 13-Jul-1997  christos branches: 1.8.14;
Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.7 13-Oct-1996  christos in_addr_t and in_port_t changes
 1.6 29-May-1996  cgd Add some casts so that we're not bitten by type promotions on 64-bit
systems. Not a great concern since the only 64-bit system currently
supported by NetBSD (Alpha) uses assembly versions of these routines.
 1.5 28-Apr-1995  jtc branches: 1.5.6;
Winning Strategies has placed this code into the Public Domain
 1.4 25-Feb-1995  cgd use NetBSD rather than ID
 1.3 19-Oct-1994  cgd maybe they should actually... WORK!
 1.2 28-Jan-1994  jtc Fix spelling error in Copyright notice
 1.1 31-Aug-1993  jtc Provide C language versions of the netorder functions.
These may be "good enough" for big-endian systems that do not have assembly
language versions of their own. A compiler should be able to do a fairly
good job optimising them, it probably won't be smart enough to omit the
stack frame, but then again, these functions won't be called unless the
macro versions are undef'd.
On the other hand, they are only intended for bootstrap purposes on little-
endian systems. They should be replaced with assembly language versions as
soon as possible.
 1.5.6.1 29-May-1996  cgd Pull revision 1.6 (add casts so we're not bitten by type promotions on
64-bit systems) to the release branch.
 1.8.14.1 08-Oct-2001  nathanw Catch up to -current.
 1.3 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.2 28-Apr-2008  martin branches: 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 18-Apr-2005  kleink branches: 1.1.2; 1.1.20;
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.1.20.1 18-May-2008  yamt sync with head.
 1.1.2.2 21-Apr-2005  tron Pull up revision 1.1 (requested by kleink in ticket #172):
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.1.2.1 18-Apr-2005  tron file protoent.h was added on branch netbsd-3 on 2005-04-21 16:59:35 +0000
 1.2.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2.8.1 28-Apr-2008  martin file protoent.h was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.30 04-Dec-2022  uwe lib: Mark up error names in man pages with .Er
 1.29 04-Dec-2022  uwe Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.28 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.27 26-Dec-2005  perry u_intN_t -> uintN_t
 1.26 31-Mar-2005  christos Remove the bugs section. It has been fixed.
 1.25 07-Aug-2003  agc branches: 1.25.6;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.24 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.23 02-Oct-2002  wiz writable instead of writeable. By Adrian Mrva.
 1.22 07-Feb-2002  ross Generate <>& symbolically.
 1.21 16-Sep-2001  wiz Sort sections, sort SEE ALSO, and misc. fixes.
 1.20 16-Sep-2001  wiz Boring whitespace fixes.
 1.19 27-Jan-2000  itojun branches: 1.19.6;
add IPv6 support to rcmd() and friends.
rcmd() and iruserok(): unchanged
ruserok(): became address family independent
rcmd_af(), iruesrok_sa(): address family independent
 1.18 04-Jul-1999  itojun add NetBSD RCSID on top.
 1.17 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.16 28-Apr-1998  fair Change occurrences of "UNIX" to .Ux or .At as appropriate.
 1.15 05-Feb-1998  perry add LIBRARY section to man page
 1.14 26-Nov-1997  tv Add xrefs to new hosts.equiv(5)/rhosts(5) man page.
 1.13 14-Nov-1997  mrg add missing .Nm entries. from spz@serpens.swb.de.
 1.12 14-Jul-1997  mikel branches: 1.12.2;
xref gethostname(3) not gethostname(2), alphabetize xrefs
 1.11 05-Jun-1997  mrg add a bugs section.
 1.10 28-May-1997  mrg update rcmd documentation.
 1.9 28-May-1996  mrg Change iuserok() to take u_int32_t. Some netgroup fixes (partially
from OpenBSD and Theo).
 1.8 25-Feb-1995  cgd branches: 1.8.6;
clean up import. also convert everything to new Id format.
 1.7 28-Oct-1994  mycroft Fix typo in previous.
 1.6 28-Oct-1994  mycroft Properly document what iruserok(3) does.
 1.5 28-Oct-1994  cgd fix bug 535, reported by Brian Moore.
 1.4 18-May-1994  cgd udpated rcmd
 1.3 11-Jan-1994  jtc Fix spelling errors.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 18-May-1994  cgd new rcmd
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.6.1 28-May-1996  mrg merge in some size fixes, fixes couple of alpha bugs.
 1.12.2.2 27-Nov-1997  mellon Pull rev 1.14 up from trunk (tv)
 1.12.2.1 14-Nov-1997  mrg pull up from trunk: add missing .Nm entries. from spz@serpens.swb.de.
 1.19.6.4 18-Oct-2002  nathanw Catch up to -current.
 1.19.6.3 22-Mar-2002  nathanw Catch up to -current.
 1.19.6.2 08-Mar-2002  nathanw Catch up to -current.
 1.19.6.1 08-Oct-2001  nathanw Catch up to -current.
 1.25.6.1 04-Apr-2005  tron Pull up revision 1.26 (requested by thorpej in ticket #101):
Remove the bugs section. It has been fixed.
 1.73 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.72 22-May-2022  andvar fix various small typos, mainly in comments.
 1.71 26-Nov-2014  enami Changes done in rsh.c rev. 1.36 was incomplete. As chuq pointed
in private mail, it broke rcp(1).

To achieve the documented behavior and to fix long standing incorrect
rsh(1) behavior which I've tried to fix in rev. 1.36, rcmd(1) should have
two operation mode; whether it should relay signal information on
auxiliary channel or not, depending on the argument `fd2p' passed to rcmd(3).
So, make rcmd(1) behave differntly depending on the environment variable and
set it when necessary in rcmd(3) according to how auxiliary channel
is set up by rcmd(3).
 1.70 18-Sep-2014  christos make more descriptors that we open as close-on-exec
 1.69 28-May-2014  christos branches: 1.69.2;
CID 975111: Ignore return value from initgroups(). If we failed, then
the failure would be that we could not open the .rhosts file so we fail
closed.
 1.68 14-Jul-2012  darrenr branches: 1.68.2; 1.68.8;
bin/46703: BSD r-commands use wrong source address for stderr
http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=46703
Bump libc minor for the addition of rresvport_af_addr()
 1.67 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.66 31-May-2011  christos branches: 1.66.4;
PR/45007: rcmd_af(3) and thusly rsh(1) ignore requested address family
Pass in the address family to rshrcmd and DTRT.
While here KNF.
 1.65 03-Jan-2007  ws Don't leak file descriptors.
 1.64 03-Nov-2006  christos nuke perror.
 1.63 02-Dec-2005  yamt constify and remove an unnecessary __UNCONST.
 1.62 29-Nov-2005  christos WARNS=4
 1.61 28-Nov-2005  christos forgot to commit this; cleanup to compile with WARNS=4, since lpd uses it.
 1.60 19-Apr-2005  christos check for pwd != NULL
 1.59 30-Mar-2005  christos use re-entrant versions of getpw*(). In libc only pwcache remains and this
cannot be changed easily because it involves an API change.
 1.58 29-Nov-2004  ginsbach branches: 1.58.2;
rresvport_af() should return -1 when the address family is unsupported
and set errno accordingly.
 1.57 16-Nov-2004  itojun NI_WITHSCOPEID was not picked up by IETF standardization process
 1.56 21-Mar-2004  mrg remove my copyright statement
 1.55 27-Jan-2004  lukem Retain the euid of the target user whilst reading the
.rhosts file. This allows it to have a mode of 600
and still function correctly even when used on an NFS
client with uid 0 mapped to another (anonymous) UID.
Patch from Brian Ginsbach <ginsbach@cray.com>,
and fixes [bin/14880] from Darren Reed <darrenr@>.
 1.54 13-Oct-2003  agc Move Matt Green's code from a 4-clause to a 3-clause licence by removing
the advertising clause. Diffs provided in PR 22396 by Joel Baker, the changes
were confirmed to the board by Matt Green.
 1.53 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.52 06-Jan-2003  wiz writable, not writeable.
 1.51 17-Nov-2002  itojun make sure to bound string operation by strlcpy
(there are bunch of "strcpy is safe" comments, i think we should change them
to strlcpy as much as possible)
 1.50 17-Nov-2002  itojun use strlcpy where it is more appropriate.
 1.49 11-Nov-2002  thorpej Fix signed/unsigned comparison warnings.
 1.48 22-May-2002  tron Revert last change after protoype of getnameinfo(3) has been changed back.
 1.47 14-May-2002  thorpej branches: 1.47.2;
Delint after getaddrinfo(), etc. changes.
 1.46 16-Apr-2002  groo botched strn* -> strl*
from xs@kittenz.org
 1.45 04-Nov-2001  lukem fix WARNS=2 (-Wshadow) warnings
 1.44 07-Jul-2000  itohy branches: 1.44.2;
Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.
 1.43 06-Jul-2000  christos add argsused lint directives
add explicit casts
elide non-portable casts
 1.42 30-May-2000  itojun branches: 1.42.2;
usr.sbin/lpr/lpd now compiles lib/libc/net/rcmd.c on its own, to avoid
use of non-exported function __ivaliduser{,_sa}().

we cannot make __ivaliduser{,_sa}() static yet, since doing that would choke
compiled lpd binaries. we should do it on next libc major version bump.
added a memo on lib/libc/shlib_version.
 1.41 05-Mar-2000  itojun branches: 1.41.2;
fix fatal typo, which misused luser/ruser (PR 9543).
 1.40 24-Feb-2000  itojun (rcmd.c) to make Zoularis happier, pass sa_len separately from sockaddrs.
this changes function prototype for __ivalid*.
This commit breaks binary compatibility for __ivalid*. I believe this can be
forgiven due to the following:
- this is not really exported function. no function prototype is in headers.
function name starts with underbars. No third-party applications are
expected to use it.
- the function was introduced very recently, when rcmd.c was made IPv6-ready.
- the only customer in NetBSD tree is lpd.

(lpd.c) sync with rcmd.c change.
 1.39 18-Feb-2000  itojun do not perform sleep() every time we get ECONNREFUSED.
try all the set of addresses before go to sleep() and retry.

not sure if we still need sleep() - retry logic. why is it so persistent
in connecting?

From: SHIMIZU Ryo <ryo@misakimix.org>
 1.38 31-Jan-2000  itojun visit next addrinfo struct on socket failure.

this should fix the behavior of rcmd() on ipv4-only node, trying to
connect to dual stack node (AAAA and A record on DNS/hostname databaes)
 1.37 27-Jan-2000  itojun add IPv6 support to rcmd() and friends.
rcmd() and iruserok(): unchanged
ruserok(): became address family independent
rcmd_af(), iruesrok_sa(): address family independent
 1.36 22-Jan-2000  mycroft Use a better type in previous.
 1.35 22-Jan-2000  mycroft Delint.
 1.34 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.33 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.32 04-Jul-1999  itojun add NetBSD RCSID on top.
 1.31 03-May-1999  christos int -> socklen_t
 1.30 16-Mar-1999  christos - fix gcc-2.8.1 warnings
- portability fix: Don't use bindresvport() if !BSD4_4 because we could
be on an operating system where it takes different arguments (hint, hint).
 1.29 15-Nov-1998  christos delint
 1.28 13-Nov-1998  christos delint
 1.27 18-Oct-1998  christos Portability. Use #ifdef BSD4_4 for sin_len
 1.26 26-Sep-1998  christos Use posix signal system calls.
 1.25 26-Jul-1998  mycroft const poisoning.
 1.24 18-Jul-1998  lukem use AF_LOCAL instead of AF_UNIX
 1.23 18-Jan-1998  lukem use bindresvport for rresvport (from freebsd). old code #if 0-ed out
 1.22 21-Dec-1997  christos inet_addr -> inet_aton
 1.21 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.20 26-May-1997  mrg allow rcmd() to use something other than rsh protocol.
 1.19 08-Feb-1997  mycroft branches: 1.19.2; 1.19.4;
It's not necessary to initialize the `revents' field of struct pollfd.
 1.18 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.17 28-Dec-1996  veego iruserok fails to open a ~/.rhosts file if you have a directory
above the home dir which is only group acessable:

directroy owner group permission
/a root wheel 755
/a/b root b 750 <
/a/b/c c b 700
/a/b/c/.rhosts c b 600

add getegid and initgroups before and setegid behind fopen to fix this.
add <netgroup.h> for the prototype of innetgr.
 1.16 18-Dec-1996  thorpej Don't pass a timeout of 0 to poll(2); block indefinitely, like the
pre-poll(2) aware implementation.
From enami tsugutomo <enami@ba2.so-net.or.jp>, PR #3043.
 1.15 17-Dec-1996  mrg use poll() instead of select()
 1.14 28-May-1996  mrg branches: 1.14.2;
Change iuserok() to take u_int32_t. Some netgroup fixes (partially
from OpenBSD and Theo).
 1.13 16-Nov-1995  pk branches: 1.13.4;
Remove call to abort() (from John Kohl; PR#1764).
 1.12 03-Jun-1995  mycroft Fill in sin_len.
 1.11 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.10 04-Dec-1994  christos branches: 1.10.2;
Added code to handle netgroups in user authorization.
 1.9 01-Jun-1994  pk Avoid stomping on static memory by repeatly calling gethostbyname().
 1.8 01-Jun-1994  pk Don't try to lookup an empty hostname; some nameservers return the root servers
for such a query.
 1.7 27-May-1994  deraadt fix the stupid select bug AGAIN
 1.6 18-May-1994  cgd udpated rcmd
 1.5 27-Mar-1994  deraadt but described in a posting by <RHussein@uh.edu> somewhere on the net.
select() loop hung if either socket was >=32.
 1.4 05-Dec-1993  deraadt should bzero automatic sockaddr's before use
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 18-May-1994  cgd new rcmd
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10.2.1 02-May-1995  jtc #include "namespace.h"
 1.13.4.1 28-May-1996  mrg merge in some size fixes, fixes couple of alpha bugs.
 1.14.2.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.19.4.2 08-Feb-1997  mycroft It's not necessary to initialize the `revents' field of struct pollfd.
 1.19.4.1 08-Feb-1997  mycroft file rcmd.c was added on branch is-newarp on 1997-02-08 04:38:31 +0000
 1.19.2.6 14-May-1997  mrg use waitpid(), as suggested by lukem. teeny KNFing.
 1.19.2.5 19-Mar-1997  lukem * set fd2p to fd of ep[] if socketpair() worked, not after failure exit.
this should make rshrcmd() work properly now
* check if local user exists, barf if not. setuid() to them
* cleanup warnx() messages
* use memmove/memcmp instead of bcopy/bcmp
 1.19.2.4 16-Feb-1997  mrg use hprcmd; minor KNF.
 1.19.2.3 16-Feb-1997  mrg propogate return values; make rcmd(1) work!
 1.19.2.2 16-Feb-1997  mrg handle locuser with rcmd(1).
 1.19.2.1 16-Feb-1997  mrg first non-working cut of Chris Siebenmann <cks@utcc.utoronto.ca> rshrcmd()
kind of reworked, to fit in to the framework required for rcmd(3) to remain
as useful as it is, and for backwards compatibility.
 1.41.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.42.2.1 17-Apr-2002  he Pull up revision 1.46 (requested by groo):
Replace two instances of strn* functions with strl* functions.
 1.44.2.5 08-Jan-2003  thorpej Sync with HEAD.
 1.44.2.4 10-Dec-2002  thorpej Sync with HEAD.
 1.44.2.3 21-Jun-2002  nathanw Catch up to -current.
 1.44.2.2 25-Apr-2002  nathanw Catch up to -current.
 1.44.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.47.2.2 06-Apr-2005  tron Pull up revision 1.55 via patch (requested by ginsbach in ticket #5732):
Retain the euid of the target user whilst reading the
.rhosts file. This allows it to have a mode of 600
and still function correctly even when used on an NFS
client with uid 0 mapped to another (anonymous) UID.
Patch from Brian Ginsbach <ginsbach@cray.com>,
and fixes [bin/14880] from Darren Reed <darrenr@>.
 1.47.2.1 28-May-2002  lukem Pull up revision 1.48 (requested by tron):
Revert last change after protoype of getnameinfo(3) has been changed back.
 1.58.2.2 09-Jul-2005  tron Pull up revision 1.60 (requested by lukem in ticket #534):
check for pwd != NULL
 1.58.2.1 04-Apr-2005  tron Pull up revision 1.59 (requested by thorpej in ticket #97):
use re-entrant versions of getpw*(). In libc only pwcache remains and this
cannot be changed easily because it involves an API change.
 1.66.4.2 30-Oct-2012  yamt sync with head
 1.66.4.1 17-Apr-2012  yamt sync with head
 1.68.8.1 10-Aug-2014  tls Rebase.
 1.68.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.69.2.1 01-Dec-2014  martin Pull up following revision(s) (requested by enami in ticket #286):
usr.bin/rsh/rsh.c: revision 1.38
lib/libc/net/rcmd.c: revision 1.71
Changes done in rsh.c rev. 1.36 was incomplete. As chuq pointed
in private mail, it broke rcp(1).
To achieve the documented behavior and to fix long standing incorrect
rsh(1) behavior which I've tried to fix in rev. 1.36, rcmd(1) should have
two operation mode; whether it should relay signal information on
auxiliary channel or not, depending on the argument `fd2p' passed to rcmd(3).
So, make rcmd(1) behave differntly depending on the environment variable and
set it when necessary in rcmd(3) according to how auxiliary channel
is set up by rcmd(3).
 1.10 20-Mar-2012  matt Use C89 Prototypes.
Remove use of __P
 1.9 22-Oct-2003  drochner branches: 1.9.56;
the last argument to recvfrom() is a pointer, so use "NULL" for
consistency
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.6 25-Feb-1995  cgd branches: 1.6.4;
clean up import. also convert everything to new Id format.
 1.5 19-Oct-1994  cgd branches: 1.5.2;
get return type right.
 1.4 13-May-1994  deraadt size_t
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 02-May-1995  jtc #include "namespace.h"
 1.6.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.9.56.1 17-Apr-2012  yamt sync with head
 1.22 21-May-2004  christos Finish bind9 resolver merge.
 1.21 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.20 26-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.19 06-Jul-2000  christos branches: 1.19.2;
add explicit casts
 1.18 25-Apr-2000  itojun sync with BIND 4.9.7. uses BIND 8.x codebase for dn_expand().
hyphenchar() definition is now fixed to specwise-correct declaration
(only "-" is permitted). may need more KNF and/or delint.
 1.17 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.16 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.15 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.14 17-Aug-1999  mycroft Make some needed weak aliases.
 1.13 13-Nov-1998  christos delint
 1.12 15-Oct-1998  kleink Need an internal name for dn_expand().
 1.11 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.10 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.9 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.8 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.7 02-Feb-1996  mrg branches: 1.7.2;
merge with the resolver in bind 4.9.3-P1.
 1.6 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.5 15-Oct-1994  deraadt u_int_{16,32}_t stuff
 1.4 07-Apr-1994  deraadt new resolver. changes from 4.9.2 by <paul@vix.com>, as well as a number
of features and optimizations by myself.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.6 25-Apr-2000  itojun BIND 4.9.7
 1.1.1.5 02-Feb-1998  mrg import lite-2 libc/net sources.
 1.1.1.4 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.3 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.7.2.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.19.2.1 21-Jun-2002  nathanw Catch up to -current.
 1.9 21-May-2004  christos Finish bind9 resolver merge.
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 26-Jul-1998  mycroft constify some tables.
 1.6 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.5 09-Oct-1997  lukem fix mistake in previous commit (added too many __RCSID/#endif lines
 1.4 09-Oct-1997  lukem rcsid police
 1.3 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.2 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.1 13-Apr-1997  mrg branches: 1.1.1;
Initial revision
 1.1.1.3 25-Apr-2000  itojun BIND 4.9.7
 1.1.1.2 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.1 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.36 21-May-2004  christos Finish bind9 resolver merge.
 1.35 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.34 17-Nov-2002  itojun whitespace
 1.33 16-Aug-2002  itojun eliminate sprintf. use snprintf.
XXX loc_ntoa should be changed to take additional size_t as arg
 1.32 27-Jun-2002  itojun correct %d/%u mixup.
 1.31 16-Apr-2002  groo botched strncpy -> strlcpy
from xs@kittenz.org
 1.30 20-Dec-2000  christos branches: 1.30.2;
remove unnecessary prototypes
lint casting.
 1.29 09-Aug-2000  itojun implement EDNS0 support, as EDNS0 support will be made mandatory for
IPv6 transport-ready resolvers/DNS servers. need careful configuration
when enable it. (default config is not affected).
see manpage for details.

XXX visible symbol __res_opt() is added, however, it is not supposed to be
called from outside, libc minor is not bumped.
 1.28 08-Jul-2000  itojun %-format pedant (always pass %s, don't use variable alone).
from openbsd.
 1.27 07-Jul-2000  itohy Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.
 1.26 25-Apr-2000  itojun branches: 1.26.4;
sync with BIND 4.9.7. mostly costmetic.
 1.25 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.24 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.23 15-Nov-1998  christos delint
 1.22 13-Nov-1998  christos delint
 1.21 15-Oct-1998  kleink (bcmp(), bcopy(), bzero()) -> (memcmp(), memcpy(), memset())
 1.20 13-Sep-1998  kleink Use gmtime_r() rather than gmtime(); removes a potential source of surprise for
the application.
 1.19 19-Aug-1998  ross Shut up egcs. (`...might be used uninitialized')
 1.18 18-Aug-1998  thorpej Add some braces to keep egcs happy.
 1.17 26-Jul-1998  mycroft const poisoning.
 1.16 26-Jul-1998  mycroft constify some tables.
 1.15 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.14 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.13 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.12 17-Jul-1997  thorpej Cast the result of pointer arithmetic to "long" for printing, and use
%ld printf format.
 1.11 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.10 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.9 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.8 02-Feb-1996  mrg merge with the resolver in bind 4.9.3-P1.
 1.7 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.6 15-Oct-1994  deraadt u_int_{16,32}_t stuff
 1.5 07-Apr-1994  deraadt new resolver. changes from 4.9.2 by <paul@vix.com>, as well as a number
of features and optimizations by myself.
 1.4 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.3 03-Aug-1993  mycroft Add RCS identifier.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.6 25-Apr-2000  itojun BIND 4.9.7
 1.1.1.5 02-Feb-1998  mrg import lite-2 libc/net sources.
 1.1.1.4 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.3 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.26.4.2 17-Apr-2002  he Pull up revision 1.31 (requested by groo):
Replace an instance of strncpy() with strlcpy().
 1.26.4.1 27-Jul-2000  itojun pullup 1.27 -> 1.28 (approved by releng-1-5)
%-format pedant (always pass %s, don't use variable alone).
from openbsd.
 1.30.2.4 10-Dec-2002  thorpej Sync with HEAD.
 1.30.2.3 27-Aug-2002  nathanw Catch up to -current.
 1.30.2.2 01-Aug-2002  nathanw Catch up to -current.
 1.30.2.1 25-Apr-2002  nathanw Catch up to -current.
 1.46 21-May-2004  christos Finish bind9 resolver merge.
 1.45 09-Sep-2003  itojun use randomid(3). actually generate random ID for DNS queries (previous
fix was incomplete)
 1.44 06-Sep-2003  christos rename exp to expo to avoid global shadowing warning.
 1.43 06-Sep-2003  itojun move provos' copyright closer to res_randomid()
 1.42 06-Sep-2003  itojun bring in openbsd lib/libc/net/res_random.c for truely-random res_randomid().
 1.41 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.40 06-Jan-2003  wiz transmission, not transmition.
 1.39 02-Aug-2002  itojun use strlcpy where appropriate
 1.38 27-Jun-2002  itojun correct %d/%u mixup.
 1.37 13-Sep-2001  itojun make it possible to turn on RES_INSECURE[12] with /etc/resolv.conf.
don't connect datagram socket if RES_INSECURE1.
needed to implement IPv6 anycast UDP DNS queries as documented in
<draft-ietf-ipngwg-dns-discovery-02.txt>.
sync with kame.
 1.36 09-Aug-2000  itojun branches: 1.36.2;
implement EDNS0 support, as EDNS0 support will be made mandatory for
IPv6 transport-ready resolvers/DNS servers. need careful configuration
when enable it. (default config is not affected).
see manpage for details.

XXX visible symbol __res_opt() is added, however, it is not supposed to be
called from outside, libc minor is not bumped.
 1.35 07-Jul-2000  itohy Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.
 1.34 06-Jul-2000  christos add explicit casts
elide non-portable casts
 1.33 18-Jun-2000  itojun do not assume that nsaddr_list[n].sa_len is properly initialized,
there can be some third-party code that does not.
 1.32 25-Apr-2000  itojun branches: 1.32.2;
sync with BIND 4.9.7. mostly costmetic.
XXX 4.9.5 -> 4.9.7 moves _res from data to bss. the bss version of the code
is committed, but is wrapped with #ifdef __RES_IN_BSS and is disabled
(_res is still in data segment).
 1.31 25-Apr-2000  itojun correct a use of sizeof() against nsaddr_list.
 1.30 25-Apr-2000  itojun cleanup nsaddr_list handling.
- be more backward compatible with apps that update _res.nsaddr_list[n].
- allow scoped IPv6 addresses in /etc/resolv.conf (like fe80::1%lo0).
- simplify #ifdefs.
 1.29 22-Jan-2000  mycroft Delint.
 1.28 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.27 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.26 04-Jul-1999  itojun if the list of name server on /etc/resolv.conf is in a
non-supported AF, try the next nameserver instead of abort.

This helps situations like:
- you write IPv6 nameserver into /etc/resolv.conf and
- run non-IPv6 kernel
 1.25 04-Jul-1999  itojun add NetBSD RCSID on top.
 1.24 01-Jul-1999  itojun IPv6 DNS transport support for resolver.
Now you can write
nameserver 3ffe:0501:4819::42
in /etc/resolv.conf for DNS query over IPv6 network.
(the above address is alive as DNS server)
 1.23 16-Jan-1999  lukem pull nsswitch up to main branch
convert getnetby*() to nsswitch (from resolv.conf lookup)
 1.22 13-Nov-1998  christos delint
 1.21 15-Oct-1998  kleink (bcmp(), bcopy(), bzero()) -> (memcmp(), memcpy(), memset())
 1.20 14-Oct-1998  kleink Since these files are shared with parts of the BIND-4 userland (outside libc),
do the internal symbol renaming dance only if inside the libc build environment.
 1.19 14-Oct-1998  kleink Need internal names for res_init(), res_mkquery(), res_query() and res_search().
 1.18 06-Jul-1998  mrg - use an array MAXHOSTNAMELEN+1 size to hold hostnames
- ensure hostname from gethostname() is nul-terminated in all cases
- minor KNF
- use MAXHOSTNAMELEN over various other values/defines
- be safe will buffers that hold hostnames
 1.17 02-Feb-1998  perry add sys/time.h include
 1.16 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.15 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.14 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.13 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.12 30-Apr-1997  mrg branches: 1.12.2;
use a nul not '0'. from <enami@ba2.so-net.or.jp> in PR#3558
 1.11 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.10 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.9 02-Feb-1996  mrg branches: 1.9.2; 1.9.6;
merge with the resolver in bind 4.9.3-P1.
 1.8 03-Jun-1995  mycroft Fill in sin_len.
 1.7 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.6 15-Oct-1994  deraadt u_int_{16,32}_t stuff
 1.5 07-Apr-1994  deraadt new resolver. changes from 4.9.2 by <paul@vix.com>, as well as a number
of features and optimizations by myself.
 1.4 28-Jan-1994  deraadt support for lookup keyword in resolv.conf
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.6 25-Apr-2000  itojun BIND 4.9.7
 1.1.1.5 02-Feb-1998  mrg import lite-2 libc/net sources.
 1.1.1.4 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.3 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.9.6.1 06-Nov-1996  lukem initial nsswitch implementation
 1.9.2.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.12.2.2 02-Nov-1998  lukem sync with current, assign my copyrights to TNF
 1.12.2.1 23-May-1997  lukem * Add nsdispatch(3) implementation
* Deprecate support for "lookup" in resolv.conf
 1.32.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.36.2.4 08-Jan-2003  thorpej Sync with HEAD.
 1.36.2.3 13-Aug-2002  nathanw Catch up to -current.
 1.36.2.2 01-Aug-2002  nathanw Catch up to -current.
 1.36.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.26 21-May-2004  christos Finish bind9 resolver merge.
 1.25 09-Sep-2003  itojun use randomid(3). actually generate random ID for DNS queries (previous
fix was incomplete)
 1.24 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.23 28-Aug-2002  onoe Limit UDP payload size for EDNS0 to 0xffff, not use lower 16bit value.
 1.22 26-Jun-2002  itojun correct bad practice in the code - it uses two changing variables
to manage buffer (buf and buflen). we eliminate buflen and use
fixed point (ep) as the ending pointer.

this fix is NOT critical.
 1.21 20-Dec-2000  christos branches: 1.21.2; 1.21.4;
appease lint casting.
 1.20 09-Aug-2000  itojun implement EDNS0 support, as EDNS0 support will be made mandatory for
IPv6 transport-ready resolvers/DNS servers. need careful configuration
when enable it. (default config is not affected).
see manpage for details.

XXX visible symbol __res_opt() is added, however, it is not supposed to be
called from outside, libc minor is not bumped.
 1.19 06-Jul-2000  christos add constcond lint directive
 1.18 25-Apr-2000  itojun branches: 1.18.4;
sync with BIND 4.9.7. mostly costmetic.
XXX 4.9.5 -> 4.9.7 moves _res from data to bss. the bss version of the code
is committed, but is wrapped with #ifdef __RES_IN_BSS and is disabled
(_res is still in data segment).
 1.17 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.16 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.15 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.14 13-Nov-1998  christos delint
 1.13 15-Oct-1998  kleink (bcmp(), bcopy(), bzero()) -> (memcmp(), memcpy(), memset())
 1.12 14-Oct-1998  kleink Since these files are shared with parts of the BIND-4 userland (outside libc),
do the internal symbol renaming dance only if inside the libc build environment.
 1.11 14-Oct-1998  kleink Need internal names for res_init(), res_mkquery(), res_query() and res_search().
 1.10 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.9 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.8 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.7 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.6 02-Feb-1996  mrg branches: 1.6.2;
merge with the resolver in bind 4.9.3-P1.
 1.5 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.4 07-Apr-1994  deraadt new resolver. changes from 4.9.2 by <paul@vix.com>, as well as a number
of features and optimizations by myself.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.6 25-Apr-2000  itojun BIND 4.9.7
 1.1.1.5 02-Feb-1998  mrg import lite-2 libc/net sources.
 1.1.1.4 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.3 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.6.2.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.18.4.1 04-Sep-2002  itojun pullup lib/libc/net/res_mkquery.c 1.22 (itojun)

correct bad practice in the code - it uses two changing variables
to manage buffer (buf and buflen). we eliminate buflen and use
fixed point (ep) as the ending pointer.
 1.21.4.2 28-Aug-2002  lukem Pull up revision 1.23 (requested by itojun in ticket #739):
Limit UDP payload size for EDNS0 to 0xffff, not use lower 16bit value.
 1.21.4.1 17-Aug-2002  lukem Pull up revision 1.22 (requested by itojun in ticket #693):
correct bad practice in the code - it uses two changing variables
to manage buffer (buf and buflen). we eliminate buflen and use
fixed point (ep) as the ending pointer.
this fix is NOT critical.
 1.21.2.2 17-Sep-2002  nathanw Catch up to -current.
 1.21.2.1 01-Aug-2002  nathanw Catch up to -current.
 1.38 21-May-2004  christos Finish bind9 resolver merge.
 1.37 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.36 16-Aug-2002  itojun use sizeof, avoid duplicated use of MAXDNAME
 1.35 16-Aug-2002  itojun use snprintf. don't duplicate MAXDNAME (use sizeof).
 1.34 02-Aug-2002  itojun use strlcpy where appropriate
 1.33 27-Jun-2002  itojun correct %d/%u mixup.
 1.32 20-Dec-2000  christos branches: 1.32.2;
remove redundant declarations.
 1.31 09-Aug-2000  itojun implement EDNS0 support, as EDNS0 support will be made mandatory for
IPv6 transport-ready resolvers/DNS servers. need careful configuration
when enable it. (default config is not affected).
see manpage for details.

XXX visible symbol __res_opt() is added, however, it is not supposed to be
called from outside, libc minor is not bumped.
 1.30 07-Jul-2000  itohy Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.
 1.29 28-Apr-2000  itojun typo in comment
 1.28 27-Apr-2000  itojun don't look at $HOSTALIASES, if issetugid() says the binary is dirty.
 1.27 26-Apr-2000  itojun improve comment before setbuf() in hostalias().
 1.26 25-Apr-2000  itojun sync with BIND 4.9.7. correct boundary checking broken by delint mistake
(auto increment evaluation order). costmetic changes.
 1.25 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.24 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.23 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.22 24-Nov-1998  christos - (void) casts.
- fix off-by-one bug in fgets()
- don't make the file unbuffered.
 1.21 15-Nov-1998  christos delint
 1.20 13-Nov-1998  christos delint
 1.19 14-Oct-1998  kleink Since these files are shared with parts of the BIND-4 userland (outside libc),
do the internal symbol renaming dance only if inside the libc build environment.
 1.18 14-Oct-1998  kleink Need internal names for res_init(), res_mkquery(), res_query() and res_search().
 1.17 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.16 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.15 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.14 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.13 22-Apr-1997  mrg note possible security concerns.
 1.12 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.11 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.10 02-Feb-1996  mrg branches: 1.10.2;
merge with the resolver in bind 4.9.3-P1.
 1.9 25-Feb-1995  cgd oops; fix the cleanup.
 1.8 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.7 19-Oct-1994  cgd casts for happiness.
 1.6 03-Jun-1994  pk Fix last bug correctly
 1.5 01-Jun-1994  pk Defend against empty names.
 1.4 07-Apr-1994  deraadt new resolver. changes from 4.9.2 by <paul@vix.com>, as well as a number
of features and optimizations by myself.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.6 25-Apr-2000  itojun BIND 4.9.7
 1.1.1.5 02-Feb-1998  mrg import lite-2 libc/net sources.
 1.1.1.4 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.3 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.10.2.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.32.2.3 27-Aug-2002  nathanw Catch up to -current.
 1.32.2.2 13-Aug-2002  nathanw Catch up to -current.
 1.32.2.1 01-Aug-2002  nathanw Catch up to -current.
 1.38 21-May-2004  christos Finish bind9 resolver merge.
 1.37 07-Aug-2003  agc branches: 1.37.4;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.36 17-Nov-2002  itojun make sure to bound string operation by strlcpy
(there are bunch of "strcpy is safe" comments, i think we should change them
to strlcpy as much as possible)
 1.35 11-Nov-2002  thorpej Avoid strict alias warning.
 1.34 13-Sep-2001  itojun make it possible to turn on RES_INSECURE[12] with /etc/resolv.conf.
don't connect datagram socket if RES_INSECURE1.
needed to implement IPv6 anycast UDP DNS queries as documented in
<draft-ietf-ipngwg-dns-discovery-02.txt>.
sync with kame.
 1.33 12-Feb-2001  itojun branches: 1.33.2;
use standard IPv6 address comparison macros. sync with kame
 1.32 04-Jan-2001  lukem ensure that buf1 in res_queriesmatch() isn't dereferenced before
testing with _DIAGASSERT(buf1 != NULL).
(damn those pesky initialisations in declarations... :)
 1.31 27-Jul-2000  itojun do not try to transmit UDP DNS query forever, in EINTR-busy situation.
the change uses extra variables which can be avoided,
it is to make the change look similar to BIND8 change.
question: timeout resolution is 1 second (time_t). should we use
timevals instead?

PR 6410 From: maximum entropy <entropy@venom.bernstein.com>
 1.30 06-Jul-2000  christos add explicit casts
elide non-portable casts
 1.29 18-Jun-2000  itojun branches: 1.29.2;
do not assume that nsaddr_list[n].sa_len is properly initialized,
there can be some third-party code that does not.
 1.28 14-Jun-2000  itojun besure to check getnameinfo() return value. (debugging code)
 1.27 26-Apr-2000  itojun branches: 1.27.2;
simplify #ifdef a bit, by assuming getnameinfo.
 1.26 25-Apr-2000  itojun sync with BIND 4.9.7. reject too short messages.
 1.25 25-Apr-2000  itojun cleanup nsaddr_list handling.
- be more backward compatible with apps that update _res.nsaddr_list[n].
- allow scoped IPv6 addresses in /etc/resolv.conf (like fe80::1%lo0).
- simplify #ifdefs.
 1.24 23-Jan-2000  mycroft Delint some more.
 1.23 22-Jan-2000  mycroft Delint.
 1.22 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.21 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.20 17-Aug-1999  mycroft Make some needed weak aliases.
 1.19 04-Jul-1999  itojun if the list of name server on /etc/resolv.conf is in a
non-supported AF, try the next nameserver instead of abort.

This helps situations like:
- you write IPv6 nameserver into /etc/resolv.conf and
- run non-IPv6 kernel
 1.18 01-Jul-1999  itojun IPv6 DNS transport support for resolver.
Now you can write
nameserver 3ffe:0501:4819::42
in /etc/resolv.conf for DNS query over IPv6 network.
(the above address is alive as DNS server)
 1.17 03-May-1999  christos int -> socklen_t
 1.16 15-Nov-1998  christos branches: 1.16.2;
delint
 1.15 13-Nov-1998  christos delint
 1.14 14-Oct-1998  kleink Since these files are shared with parts of the BIND-4 userland (outside libc),
do the internal symbol renaming dance only if inside the libc build environment.
 1.13 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.12 09-Oct-1997  lukem WARNSify if -DDEBUG
 1.11 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.10 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.9 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.8 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.7 08-Feb-1997  mycroft branches: 1.7.2;
It's not necessary to initialize the `revents' field of struct pollfd.
 1.6 17-Dec-1996  mrg use poll() instead of select()
 1.5 02-Feb-1996  mrg branches: 1.5.2;
merge with the resolver in bind 4.9.3-P1.
 1.4 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.6 25-Apr-2000  itojun BIND 4.9.7
 1.1.1.5 02-Feb-1998  mrg import lite-2 libc/net sources.
 1.1.1.4 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.3 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.7.2.2 08-Feb-1997  mycroft It's not necessary to initialize the `revents' field of struct pollfd.
 1.7.2.1 08-Feb-1997  mycroft file res_send.c was added on branch is-newarp on 1997-02-08 04:38:32 +0000
 1.16.2.1 15-Aug-2000  he Pull up revision 1.31 (requested by itojun):
Do not try to retransmit forever in EINTR-busy situation.
Fixes PR#6410.
 1.27.2.1 23-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.29.2.1 07-Aug-2000  itojun pullup 1.30 -> 1.31 (approved by releng-1-5)
 1.31 27-Jul-2000  itojun do not try to transmit UDP DNS query forever, in EINTR-busy situation.
the change uses extra variables which can be avoided,
it is to make the change look similar to BIND8 change.
question: timeout resolution is 1 second (time_t). should we use
timevals instead?

PR 6410 From: maximum entropy <entropy@venom.bernstein.com>
 1.33.2.2 10-Dec-2002  thorpej Sync with HEAD.
 1.33.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.37.4.1 12-May-2005  riz Fix for PR#29970, "2.0 fails to compile without INET6 due to warnings",
from David Brownlee.
Requested in ticket #1424 by christos.
 1.34 07-Feb-2018  pgoyette Fix typos, as reported by Eitan Adler. Update dates.
 1.33 30-Oct-2017  wiz Fix Bl argument.
 1.32 25-Oct-2017  abhinav Remove comma after last Nm entry
 1.31 18-Dec-2016  christos clarify res_nclose and res_ndestroy.
 1.30 22-Jan-2016  wiz branches: 1.30.2;
Try to reduce singular/plural confusion. Use more markup.
 1.29 22-Jan-2016  zafer fix typo.
 1.28 14-Nov-2013  wiz Remove annoying comma and sort SEE ALSO.
 1.27 13-Nov-2013  christos PR/48379: mention kqueue functionality
 1.26 08-May-2013  wiz New sentence, new line. Fix minus. Avoid <>.
Remove trailing whitespace.
 1.25 08-May-2013  christos Clarify which functions are only in libresolv.
 1.24 07-Nov-2012  christos fix outdated includes list.
 1.23 02-Oct-2009  cegger branches: 1.23.6; 1.23.12;
fix grammar: a -> an
 1.22 08-Jun-2009  christos merge our changes
 1.21 25-Jan-2005  wiz branches: 1.21.32; 1.21.38; 1.21.42;
Fix a double word, and improve mark up in FILES section. From jmc@openbsd.
 1.20 07-Sep-2003  wiz Consistently use 'RFC 1234' instead of 'RFC1234' or 'RFC-1234'.
From jmc@openbsd.
 1.19 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.18 23-Apr-2003  simonb Add a missing full stop, join to short lines.
 1.17 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.16 07-Feb-2002  ross Generate <>& symbolically.
 1.15 16-Sep-2001  wiz Sort sections, sort SEE ALSO, and misc. fixes.
 1.14 16-Sep-2001  wiz Boring whitespace fixes.
 1.13 09-Aug-2000  itojun branches: 1.13.2;
implement EDNS0 support, as EDNS0 support will be made mandatory for
IPv6 transport-ready resolvers/DNS servers. need careful configuration
when enable it. (default config is not affected).
see manpage for details.

XXX visible symbol __res_opt() is added, however, it is not supposed to be
called from outside, libc minor is not bumped.
 1.12 03-Jan-2000  itojun clarify text for RES_USE_INET6. this is almost always unnecessary.
 1.11 22-Mar-1999  garbled Last of the .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages. Wheee!
 1.10 29-Aug-1998  lukem first pass at fixing up capitalization of function names and
arguments; ensure that each is correct with respect to the
implementation, rather than being correct as per english.
 1.9 05-Feb-1998  perry add LIBRARY section to man page
 1.8 08-Jun-1997  lukem document RES_USE_INET6
sort RFCs numerically (974 < 1032, not > 1535)
 1.7 09-Nov-1996  lukem add 'const' qualifiers to various routines (as per the include prototypes
and the implementation)
 1.6 02-Feb-1996  mrg merge with the resolver in bind 4.9.3-P1.
 1.5 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.4 07-Apr-1994  deraadt new resolver. changes from 4.9.2 by <paul@vix.com>, as well as a number
of features and optimizations by myself.
 1.3 26-Jan-1994  deraadt note resolver(5) -> resolv.conf(5) move
(any more of these needed?)
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 08-Jun-2009  christos import the resolv.3 man page
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.13.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.13.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.13.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.21.42.1 09-Jan-2011  riz Apply patches (requested by spz in ticket #1517):

Update bind to 9.7.2-P3.
 1.21.38.1 10-Jan-2011  riz Apply patches (requested by spz in ticket #1517):

Update bind to 9.7.2-P3.
 1.21.32.1 06-Jan-2011  riz Apply patches (requested by spz in ticket #1517):

Update bind to 9.7.2-P3.
 1.23.12.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.23.12.2 23-Jun-2013  tls resync from head
 1.23.12.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.23.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.23.6.1 16-Jan-2013  yamt sync with (a bit old) head
 1.30.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.19 29-May-2019  msaitoh Fix typo(s/suppport/support/) in comment. From FreeBSD.
 1.18 13-Mar-2012  christos branches: 1.18.32;
PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.17 05-Feb-2009  lukem branches: 1.17.8;
sign-compare fix
 1.16 05-May-2006  rpaulo branches: 1.16.16;
Add support for RFC 3542 Adv. Socket API for IPv6 (which obsoletes 2292).
* RFC 3542 isn't binary compatible with RFC 2292.
* RFC 2292 support is on by default but can be disabled.
* update ping6, telnet and traceroute6 to the new API.

From the KAME project (www.kame.net).
Reviewed by core.
 1.15 29-Nov-2005  christos WARNS=4
 1.14 06-Jun-2003  itojun - sync up MLD declaration with RFC3542 (s/MLD6/MLD/)
- routing header declaration with RFC3542
(note: sizeof(ip6_rthdr0) has changed!)
also, sync up with RFC2460 routing header definition (no "strict" source
routing mode any more)

part of advanced API update (RFC2292 -> 3542).
 1.13 06-Jun-2003  itojun KNF.
 1.12 27-Jun-2002  itojun correct %d/%u mixup.
 1.11 04-Nov-2001  lukem fix WARNS=2 (-Wshadow) warnings
 1.10 06-Jul-2000  christos branches: 1.10.2;
remove register
elide non-portable casts
 1.9 24-Apr-2000  itojun add __RCSID().
 1.8 24-Apr-2000  itojun supply weak alias for IPv6-related library additions. sorry to be late.
 1.7 29-Feb-2000  itojun fix alignment constraint in IPv6 routing header manipulation (ancillary data).
documented in RFC2292.
from: shin@kame.net
 1.6 23-Jan-2000  mycroft Partially delint.
 1.5 30-Nov-1999  kleink (bcopy, bzero) -> (memcpy, memset)
 1.4 20-Sep-1999  lukem branches: 1.4.4;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.3 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.2 04-Jul-1999  itojun add NetBSD RCSID on top.
 1.1 01-Jul-1999  itojun add IPv6 support functions.

get{addr,name} info are implemented to have as little impact to existing
resolver code as possible, so they are NOT the optimal implementation.
They are at this moment not very thread safe (as they call
gethostby{name,addr}).

(shlib minor version)++, as new interfaces are added.

TODO: getipnodeby{name,addr} - which needs total reimplementation of
gethostby{name,addr}.
upgrade rcmd.c for multiple af support (needed for IPv6-ready rsh/rlogin)
 1.4.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.10.2.2 01-Aug-2002  nathanw Catch up to -current.
 1.10.2.1 14-Nov-2001  nathanw Catch up to -current.
 1.16.16.1 22-Feb-2008  keiichi imported Mobile IPv6 code developed by the SHISA project
(http://www.mobileip.jp/).
 1.17.8.1 17-Apr-2012  yamt sync with head
 1.18.32.1 10-Jun-2019  christos Sync with HEAD
 1.2 13-Aug-2018  wiz branches: 1.2.2; 1.2.4;
Various improvements.
More markup, sort errors, fix -1.
 1.1 02-Aug-2018  rjs Add userland support for SCTP and manpages.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 13-Aug-2018  christos file sctp_bindx.3 was added on branch phil-wifi on 2019-06-10 22:05:20 +0000
 1.2.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.2.1 13-Aug-2018  pgoyette file sctp_bindx.3 was added on branch pgoyette-compat on 2018-09-06 06:55:19 +0000
 1.2 13-Aug-2018  wiz branches: 1.2.2; 1.2.4;
Various improvements.
More markup, sort errors, fix -1.
 1.1 02-Aug-2018  rjs Add userland support for SCTP and manpages.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 13-Aug-2018  christos file sctp_connectx.3 was added on branch phil-wifi on 2019-06-10 22:05:20 +0000
 1.2.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.2.1 13-Aug-2018  pgoyette file sctp_connectx.3 was added on branch pgoyette-compat on 2018-09-06 06:55:19 +0000
 1.2 13-Aug-2018  wiz branches: 1.2.2; 1.2.4;
Various improvements.
More markup, sort errors, fix -1.
 1.1 02-Aug-2018  rjs Add userland support for SCTP and manpages.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 13-Aug-2018  christos file sctp_freepaddrs.3 was added on branch phil-wifi on 2019-06-10 22:05:20 +0000
 1.2.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.2.1 13-Aug-2018  pgoyette file sctp_freepaddrs.3 was added on branch pgoyette-compat on 2018-09-06 06:55:19 +0000
 1.2 13-Aug-2018  wiz branches: 1.2.2; 1.2.4;
Various improvements.
More markup, sort errors, fix -1.
 1.1 02-Aug-2018  rjs Add userland support for SCTP and manpages.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 13-Aug-2018  christos file sctp_getaddrlen.3 was added on branch phil-wifi on 2019-06-10 22:05:20 +0000
 1.2.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.2.1 13-Aug-2018  pgoyette file sctp_getaddrlen.3 was added on branch pgoyette-compat on 2018-09-06 06:55:19 +0000
 1.2 13-Aug-2018  wiz branches: 1.2.2; 1.2.4;
Various improvements.
More markup, sort errors, fix -1.
 1.1 02-Aug-2018  rjs Add userland support for SCTP and manpages.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 13-Aug-2018  christos file sctp_getassocid.3 was added on branch phil-wifi on 2019-06-10 22:05:20 +0000
 1.2.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.2.1 13-Aug-2018  pgoyette file sctp_getassocid.3 was added on branch pgoyette-compat on 2018-09-06 06:55:19 +0000
 1.2 13-Aug-2018  wiz branches: 1.2.2; 1.2.4;
Various improvements.
More markup, sort errors, fix -1.
 1.1 02-Aug-2018  rjs Add userland support for SCTP and manpages.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 13-Aug-2018  christos file sctp_getpaddrs.3 was added on branch phil-wifi on 2019-06-10 22:05:20 +0000
 1.2.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.2.1 13-Aug-2018  pgoyette file sctp_getpaddrs.3 was added on branch pgoyette-compat on 2018-09-06 06:55:19 +0000
 1.2 13-Aug-2018  wiz branches: 1.2.2; 1.2.4;
Various improvements.
More markup, sort errors, fix -1.
 1.1 02-Aug-2018  rjs Add userland support for SCTP and manpages.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 13-Aug-2018  christos file sctp_opt_info.3 was added on branch phil-wifi on 2019-06-10 22:05:20 +0000
 1.2.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.2.1 13-Aug-2018  pgoyette file sctp_opt_info.3 was added on branch pgoyette-compat on 2018-09-06 06:55:19 +0000
 1.2 13-Aug-2018  wiz branches: 1.2.2; 1.2.4;
Various improvements.
More markup, sort errors, fix -1.
 1.1 02-Aug-2018  rjs Add userland support for SCTP and manpages.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 13-Aug-2018  christos file sctp_peeloff.3 was added on branch phil-wifi on 2019-06-10 22:05:20 +0000
 1.2.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.2.1 13-Aug-2018  pgoyette file sctp_peeloff.3 was added on branch pgoyette-compat on 2018-09-06 06:55:19 +0000
 1.2 13-Aug-2018  wiz branches: 1.2.2; 1.2.4;
Various improvements.
More markup, sort errors, fix -1.
 1.1 02-Aug-2018  rjs Add missing SCTP manpage.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 13-Aug-2018  christos file sctp_recvmsg.3 was added on branch phil-wifi on 2019-06-10 22:05:20 +0000
 1.2.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.2.1 13-Aug-2018  pgoyette file sctp_recvmsg.3 was added on branch pgoyette-compat on 2018-09-06 06:55:19 +0000
 1.2 13-Aug-2018  wiz branches: 1.2.2; 1.2.4;
Various improvements.
More markup, sort errors, fix -1.
 1.1 02-Aug-2018  rjs Add userland support for SCTP and manpages.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 13-Aug-2018  christos file sctp_send.3 was added on branch phil-wifi on 2019-06-10 22:05:20 +0000
 1.2.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.2.1 13-Aug-2018  pgoyette file sctp_send.3 was added on branch pgoyette-compat on 2018-09-06 06:55:19 +0000
 1.2 13-Aug-2018  wiz branches: 1.2.2; 1.2.4;
Various improvements.
More markup, sort errors, fix -1.
 1.1 02-Aug-2018  rjs Add userland support for SCTP and manpages.
 1.2.4.2 10-Jun-2019  christos Sync with HEAD
 1.2.4.1 13-Aug-2018  christos file sctp_sendmsg.3 was added on branch phil-wifi on 2019-06-10 22:05:20 +0000
 1.2.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.2.2.1 13-Aug-2018  pgoyette file sctp_sendmsg.3 was added on branch pgoyette-compat on 2018-09-06 06:55:19 +0000
 1.2 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.1 02-Aug-2018  rjs branches: 1.1.2; 1.1.4;
Add userland support for SCTP and manpages.
 1.1.4.2 10-Jun-2019  christos Sync with HEAD
 1.1.4.1 02-Aug-2018  christos file sctp_sys_calls.c was added on branch phil-wifi on 2019-06-10 22:05:20 +0000
 1.1.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.1.2.1 02-Aug-2018  pgoyette file sctp_sys_calls.c was added on branch pgoyette-compat on 2018-09-06 06:55:19 +0000
 1.10 20-Mar-2012  matt Use C89 Prototypes.
Remove use of __P
 1.9 07-Aug-2003  agc branches: 1.9.56;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.8 08-May-2000  kleink Need an internal name for send(); noticed by itojun.
 1.7 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.6 25-Feb-1995  cgd branches: 1.6.4;
clean up import. also convert everything to new Id format.
 1.5 19-Oct-1994  cgd branches: 1.5.2;
get return type right.
 1.4 13-May-1994  deraadt size_t
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 02-May-1995  jtc #include "namespace.h"
 1.6.4.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.9.56.1 17-Apr-2012  yamt sync with head
 1.5 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.4 25-Apr-2010  joerg Add the constant database reader (cdbr(3)) and writer ((cdbw(3)).
They implement a space efficent write-once database with fast access
path. Switch the services(5) database to use cdb. The size of the
database file decreases from 2.1MB disk space to 307KB. Access
performance is about the same if setservent(0) is used and about an
order of magnitude faster otherwise. services_mkdb defaults to the new
format, but can optionally create the old db(3) format as well for
statically linked legacy applications.
 1.3 28-Apr-2008  martin branches: 1.3.8;
Remove clause 3 and 4 from TNF licenses
 1.2 27-Jul-2006  christos branches: 1.2.18;
use a db version of services if one is there.
 1.1 18-Apr-2005  kleink branches: 1.1.2;
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.1.2.2 21-Apr-2005  tron Pull up revision 1.1 (requested by kleink in ticket #172):
Move the (at this time private) get{proto,serv}ent_r() prototypes and
data structures into the libc sources until the interface gets redone.
Approved by christos.
 1.1.2.1 18-Apr-2005  tron file servent.h was added on branch netbsd-3 on 2005-04-21 16:59:35 +0000
 1.2.18.1 18-May-2008  yamt sync with head.
 1.3.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.3.8.1 28-Apr-2008  martin file servent.h was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.21 07-Dec-2023  kre Fix a couple of (not very likely) memory leaks, reported by enh@google.com
who attributed them:

the malloc one was reported to Android (as
https://android-review.googlesource.com/c/platform/bionic/+/2856549)
by wuhaitao3 <wuhaitao3@xiaomi.corp-partner.google.com>; Chris Ferris
<cferris@google.com> then spotted the goto nospc one.
 1.20 17-Mar-2014  christos branches: 1.20.18; 1.20.28; 1.20.36;
fix memory leak
XXX: pullup 6
 1.19 27-Aug-2013  christos move the host file getbyname and getbyaddr functions to sethostent.c so
that they are in a separate file from the dns ones in order for libhack
to use them.
 1.18 16-Aug-2013  christos Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3) so it is re-entrant (ahem __ypdomain). These
are not being advertised because there is a bunch of different
implementation of them that have a variety of type signatures.

If people want to follow someone's implementation, it is now easy.
 1.17 20-Mar-2012  matt branches: 1.17.2;
Use C89 Prototypes.
Remove use of __P
 1.16 27-Jan-2007  christos branches: 1.16.18; 1.16.36; 1.16.38;
Appropriate versions are not supplied by bind anymore.
 1.15 27-Jan-2007  christos merge in resolver portion of bind-9.4.0-rc2
 1.14 17-Aug-2004  ginsbach branches: 1.14.10; 1.14.12;
endhostent() and sethostent() should actaully do something now that
gethostent() has been restored to libc. Reviewed by <christos>.
 1.13 21-May-2004  christos Finish bind9 resolver merge.
 1.12 07-Aug-2003  agc branches: 1.12.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.11 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.10 14-Oct-1998  kleink Need internal names for {end,set}hostent().
 1.9 06-Jan-1998  perry $Id: -> Id: (to make hunting down other bad Ids easier).
 1.8 20-Jul-1997  mrg merge bind 4.9.6 resolver. still need to fix <resolv.h>
 1.7 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings
Add missing prototypes
Use "namespace.h"
 1.6 13-Apr-1997  mrg merge in the bind 4.9.5-P1 resolver. we are now _mostly_ the
same as this, with our changes also included (resolv.conf and
other minor differences).
 1.5 02-Feb-1996  mrg branches: 1.5.2;
merge with the resolver in bind 4.9.3-P1.
 1.4 25-Feb-1995  cgd clean up import. also convert everything to new Id format.
 1.3 26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.5 02-Feb-1998  mrg import lite-2 libc/net sources.
 1.1.1.4 20-Jul-1997  mrg bind 4.9.6 resolver files.
 1.1.1.3 13-Apr-1997  mrg BIND 4.9.5-P1 resolver bits we use
 1.1.1.2 25-Feb-1995  cgd 4.4-Lite lib/libc/net
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.2.1 20-Sep-1996  jtc snapshot namespace cleanup: net, etc.
 1.12.2.1 11-Sep-2004  he Pull up revisions 1.13-1.14 (requested by ginsbach in ticket #834):
Restore gethostent() as a supported interface. Yes, it
may be obsolete, but it is specified by IEEE Std 1003.1,
2004 Edition (POSIX) and the X/Open standards (Issue 66
and XNS 5.2).
 1.14.12.1 03-Jun-2007  wrstuden Catch up with now-somewhat-dated netbsd-4. These changes took longer
than expected for me to actually get around to merging.
 1.14.10.1 17-May-2007  jdc Add missing BIND 9.4.x include file and library changes (requested by
tron in ticket #662).
 1.16.38.2 22-Apr-2014  msaitoh Pull up following revision(s) (requested by christos in ticket #1036):
lib/libc/net/sethostent.c: revision 1.20
fix memory leak
XXX: pullup 6
 1.16.38.1 18-Dec-2013  bouyer Pullup the following revisions, requested by bad in ticket 975:
lib/libc/net/gethnamaddr.c 1.79-1.81, 1.84
lib/libc/net/getnameinfo.3 1.37-1.40
lib/libc/net/getnameinfo.c 1.51, 1.52, 1.54
lib/libc/net/hostent.h 1.1, 1.2
lib/libc/net/sethostent.c 1.17-1.19

Make getnameinfo(3) re-entrant (ahem __ypdomain).
Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3).
Implement no-check-names.
 1.16.36.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.36.1 17-Apr-2012  yamt sync with head
 1.16.18.1 18-Dec-2013  bouyer Apply patch, requested by bad in ticket #1887:
lib/libc/net/gethnamaddr.c 1.79-1.82 via patch
lib/libc/net/getnameinfo.3 1.37-1.40 via patch
lib/libc/net/getnameinfo.c 1.4 via patch
lib/libc/net/hostent.h 1.1, 1.2 via patch
lib/libc/net/sethostent.c 1.17-1.19 via patch

Make getnameinfo(3) re-entrant (ahem __ypdomain).
Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3).
Implement no-check-names.
 1.17.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.20.36.1 10-Dec-2023  martin Pull up following revision(s) (requested by kre in ticket #488):

lib/libc/net/sethostent.c: revision 1.21

Fix a couple of (not very likely) memory leaks, reported by enh@google.com
who attributed them:

the malloc one was reported to Android (as
https://android-review.googlesource.com/c/platform/bionic/+/2856549)
by wuhaitao3 <wuhaitao3@xiaomi.corp-partner.google.com>; Chris Ferris
<cferris@google.com> then spotted the goto nospc one.
 1.20.28.1 10-Dec-2023  martin Pull up following revision(s) (requested by kre in ticket #1776):

lib/libc/net/sethostent.c: revision 1.21

Fix a couple of (not very likely) memory leaks, reported by enh@google.com
who attributed them:

the malloc one was reported to Android (as
https://android-review.googlesource.com/c/platform/bionic/+/2856549)
by wuhaitao3 <wuhaitao3@xiaomi.corp-partner.google.com>; Chris Ferris
<cferris@google.com> then spotted the goto nospc one.
 1.20.18.1 10-Dec-2023  martin Pull up following revision(s) (requested by kre in ticket #1925):

lib/libc/net/sethostent.c: revision 1.21

Fix a couple of (not very likely) memory leaks, reported by enh@google.com
who attributed them:

the malloc one was reported to Android (as
https://android-review.googlesource.com/c/platform/bionic/+/2856549)
by wuhaitao3 <wuhaitao3@xiaomi.corp-partner.google.com>; Chris Ferris
<cferris@google.com> then spotted the goto nospc one.
 1.10 28-Jun-2022  rillig fix references in manual pages to the reference documentation
 1.9 30-Apr-2008  martin branches: 1.9.8;
Convert TNF licenses to new 2 clause variant
 1.8 15-May-2003  kleink branches: 1.8.30;
Change conformance reference to 1003.1-2001; the reference to 1003.1g is
retained in HISTORY. Spotted by Thomas Klausner.
 1.7 15-May-2003  wiz Point to IPC tutorials in /usr/share/doc/psd, update names, and add authors.
Bump date.
Suggested by kleink.
 1.6 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.5 31-Mar-2003  perry preceeded->preceded, desciptor->descriptor from Igor Sobrado, PR misc/19814
 1.4 07-Feb-2002  ross Generate <>& symbolically.
 1.3 22-Oct-2001  wiz branches: 1.3.2;
sort sections
 1.2 22-Oct-2001  kleink Add a reference to recv(2) as well.
 1.1 22-Oct-2001  kleink Add a sockatmark(3), the 1003.1g wrapper around SIOCATMARK.
 1.3.2.4 22-Mar-2002  nathanw Catch up to -current.
 1.3.2.3 08-Mar-2002  nathanw Catch up to -current.
 1.3.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.3.2.1 22-Oct-2001  nathanw file sockatmark.3 was added on branch nathanw_sa on 2001-11-14 19:32:00 +0000
 1.8.30.1 18-May-2008  yamt sync with head.
 1.9.8.2 30-Apr-2008  martin Convert TNF licenses to new 2 clause variant
 1.9.8.1 30-Apr-2008  martin file sockatmark.3 was added on branch christos-time_t on 2008-04-30 13:10:51 +0000
 1.3 20-Mar-2012  matt Use C89 Prototypes.
Remove use of __P
 1.2 28-Apr-2008  martin branches: 1.2.4; 1.2.8;
Remove clause 3 and 4 from TNF licenses
 1.1 22-Oct-2001  kleink branches: 1.1.2; 1.1.34;
Add a sockatmark(3), the 1003.1g wrapper around SIOCATMARK.
 1.1.34.1 18-May-2008  yamt sync with head.
 1.1.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.1.2.1 22-Oct-2001  nathanw file sockatmark.c was added on branch nathanw_sa on 2001-11-14 19:32:00 +0000
 1.2.8.2 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.2.8.1 28-Apr-2008  martin file sockatmark.c was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.2.4.1 17-Apr-2012  yamt sync with head
 1.7 07-Aug-2005  christos add missing in6addr_linklocal_allrouters.
 1.6 10-May-2003  uebayasi Typo; from Onno van der Linden <o dot vd dot linden at quicknet dot nl>.
 1.5 24-Apr-2000  itojun add __RCSID().
 1.4 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.3 20-Sep-1999  kleink Need internal names for these, too.
 1.2 04-Jul-1999  itojun add NetBSD RCSID on top.
 1.1 01-Jul-1999  itojun add IPv6 support functions.

get{addr,name} info are implemented to have as little impact to existing
resolver code as possible, so they are NOT the optimal implementation.
They are at this moment not very thread safe (as they call
gethostby{name,addr}).

(shlib minor version)++, as new interfaces are added.

TODO: getipnodeby{name,addr} - which needs total reimplementation of
gethostby{name,addr}.
upgrade rcmd.c for multiple af support (needed for IPv6-ready rsh/rlogin)

RSS XML Feed