From 8246156efcf91d8f31624e8dd455eee553240f60 Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Fri, 30 Aug 2019 18:33:17 +0000 Subject: Move 4 manual pages from not-a-function filenames to a correct filename, and correct Xr. ok jmc --- src/lib/libc/net/Makefile.inc | 8 +- src/lib/libc/net/byteorder.3 | 166 ---------------- src/lib/libc/net/ether_aton.3 | 114 +++++++++++ src/lib/libc/net/ethers.3 | 114 ----------- src/lib/libc/net/htobe64.3 | 166 ++++++++++++++++ src/lib/libc/net/inet_addr.3 | 6 +- src/lib/libc/net/inet_net.3 | 197 ------------------- src/lib/libc/net/inet_net_ntop.3 | 197 +++++++++++++++++++ src/lib/libc/net/res_init.3 | 410 +++++++++++++++++++++++++++++++++++++++ src/lib/libc/net/resolver.3 | 410 --------------------------------------- 10 files changed, 894 insertions(+), 894 deletions(-) delete mode 100644 src/lib/libc/net/byteorder.3 create mode 100644 src/lib/libc/net/ether_aton.3 delete mode 100644 src/lib/libc/net/ethers.3 create mode 100644 src/lib/libc/net/htobe64.3 delete mode 100644 src/lib/libc/net/inet_net.3 create mode 100644 src/lib/libc/net/inet_net_ntop.3 create mode 100644 src/lib/libc/net/res_init.3 delete mode 100644 src/lib/libc/net/resolver.3 (limited to 'src/lib/libc') diff --git a/src/lib/libc/net/Makefile.inc b/src/lib/libc/net/Makefile.inc index b78cd6be85..41a3164d6a 100644 --- a/src/lib/libc/net/Makefile.inc +++ b/src/lib/libc/net/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.59 2016/03/30 06:38:41 jmc Exp $ +# $OpenBSD: Makefile.inc,v 1.60 2019/08/30 18:33:17 deraadt Exp $ # net sources .PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/net ${LIBCSRCDIR}/net @@ -28,9 +28,9 @@ SRCS+= ip6opt.c rthdr.c vars6.c .include "${LIBCSRCDIR}/arch/${MACHINE_CPU}/net/Makefile.inc" -MAN+= byteorder.3 ethers.3 gai_strerror.3 getaddrinfo.3 gethostbyname.3 \ +MAN+= htobe64.3 ether_aton.3 gai_strerror.3 getaddrinfo.3 gethostbyname.3 \ getifaddrs.3 getnameinfo.3 getnetent.3 getpeereid.3 getprotoent.3 \ getrrsetbyname.3 getservent.3 htonl.3 if_indextoname.3 \ - inet_addr.3 inet_lnaof.3 inet_net.3 inet_ntop.3 \ + inet_addr.3 inet_lnaof.3 inet_net_ntop.3 inet_ntop.3 \ inet6_opt_init.3 inet6_rth_space.3 link_ntoa.3 \ - rcmd.3 rcmdsh.3 resolver.3 sockatmark.3 + rcmd.3 rcmdsh.3 res_init.3 sockatmark.3 diff --git a/src/lib/libc/net/byteorder.3 b/src/lib/libc/net/byteorder.3 deleted file mode 100644 index 98f6aff362..0000000000 --- a/src/lib/libc/net/byteorder.3 +++ /dev/null @@ -1,166 +0,0 @@ -.\" $OpenBSD: byteorder.3,v 1.22 2015/11/10 23:48:18 jmc Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: November 10 2015 $ -.Dt HTOBE64 3 -.Os -.Sh NAME -.Nm htobe64 , -.Nm htobe32 , -.Nm htobe16 , -.Nm be64toh , -.Nm be32toh , -.Nm be16toh , -.Nm betoh64 , -.Nm betoh32 , -.Nm betoh16 , -.Nm htole64 , -.Nm htole32 , -.Nm htole16 , -.Nm le64toh , -.Nm le32toh , -.Nm le16toh , -.Nm letoh64 , -.Nm letoh32 , -.Nm letoh16 , -.Nm swap64 , -.Nm swap32 , -.Nm swap16 -.Nd convert values between different byte orderings -.Sh SYNOPSIS -.In endian.h -.Ft uint64_t -.Fn htobe64 "uint64_t host64" -.Ft uint32_t -.Fn htobe32 "uint32_t host32" -.Ft uint16_t -.Fn htobe16 "uint16_t host16" -.Ft uint64_t -.Fn be64toh "uint64_t big64" -.Ft uint32_t -.Fn be32toh "uint32_t big32" -.Ft uint16_t -.Fn be16toh "uint16_t big16" -.Ft uint64_t -.Fn betoh64 "uint64_t big64" -.Ft uint32_t -.Fn betoh32 "uint32_t big32" -.Ft uint16_t -.Fn betoh16 "uint16_t big16" -.Ft uint64_t -.Fn htole64 "uint64_t host64" -.Ft uint32_t -.Fn htole32 "uint32_t host32" -.Ft uint16_t -.Fn htole16 "uint16_t host16" -.Ft uint64_t -.Fn letoh64 "uint64_t little64" -.Ft uint64_t -.Fn le64toh "uint64_t little64" -.Ft uint32_t -.Fn le32toh "uint32_t little32" -.Ft uint16_t -.Fn le16toh "uint16_t little16" -.Ft uint32_t -.Fn letoh32 "uint32_t little32" -.Ft uint16_t -.Fn letoh16 "uint16_t little16" -.Ft uint64_t -.Fn swap64 "uint64_t val64" -.Ft uint32_t -.Fn swap32 "uint32_t val32" -.Ft uint16_t -.Fn swap16 "uint16_t val16" -.Sh DESCRIPTION -These routines convert 16, 32 and 64-bit quantities between different -byte orderings. -The -.Dq swap -functions reverse the byte ordering of -the given quantity; the others convert either from/to the native -byte order used by the host to/from either little- or big-endian (a.k.a -network) order. -.Pp -Apart from the swap functions, -the names containing -.Dq be -convert between host and big-endian (most significant byte first) order -of the given quantity, while the names containing -.Dq le -convert between host and little-endian (least significant byte first) order -of the given quantity. -.Pp -All these functions use the numbers -16, 32, or 64 for specifying the bitwidth of the quantities they operate on. -Currently all supported architectures are either big- or little-endian -so either the -.Dq be -or -.Dq le -variants are implemented as null macros. -.Sh SEE ALSO -.Xr htonl 3 -.Sh STANDARDS -The -.Fn htobe64 , -.Fn htobe32 , -.Fn htobe16 , -.Fn be64toh , -.Fn be32toh , -.Fn be16toh , -.Fn htole64 , -.Fn htole32 , -.Fn htole16 , -.Fn le64toh , -.Fn le32toh , -and -.Fn le16toh -functions are expected to conform to a future version of -.St -p1003.1 . -The other functions are extensions that should not be used -when portability is required. -.Sh HISTORY -The -.Nm swap{size} -and -.Nm {src-order}to{dst-order}{size} -functions appeared in -.Bx 4.2 . -The -.Nm {src-order}{size}to{dst-order} -functions appeared in -.Ox 5.6 . -A subset of them was submitted for standardization after -.St -p1003.1-2008 . -.Sh BUGS -The perceived antagonism between -.Sq host -and -.Sq network -byte order does not allow PDP-11 users to sleep soundly at night. diff --git a/src/lib/libc/net/ether_aton.3 b/src/lib/libc/net/ether_aton.3 new file mode 100644 index 0000000000..98beb5e492 --- /dev/null +++ b/src/lib/libc/net/ether_aton.3 @@ -0,0 +1,114 @@ +.\" $OpenBSD: ether_aton.3,v 1.1 2019/08/30 18:33:17 deraadt Exp $ +.\" +.\" Written by roland@frob.com. Public domain. +.\" +.Dd $Mdocdate: August 30 2019 $ +.Dt ETHER_ATON 3 +.Os +.Sh NAME +.Nm ether_aton , +.Nm ether_ntoa , +.Nm ether_ntohost , +.Nm ether_hostton , +.Nm ether_line +.Nd get ethers entry +.Sh SYNOPSIS +.In sys/types.h +.In sys/socket.h +.In net/if.h +.In netinet/in.h +.In netinet/if_ether.h +.Ft char * +.Fn ether_ntoa "struct ether_addr *e" +.Ft struct ether_addr * +.Fn ether_aton "const char *s" +.Ft int +.Fn ether_ntohost "char *hostname" "struct ether_addr *e" +.Ft int +.Fn ether_hostton "const char *hostname" "struct ether_addr *e" +.Ft int +.Fn ether_line "const char *l" "struct ether_addr *e" "char *hostname" +.Sh DESCRIPTION +Ethernet addresses are represented by the +following structure: +.Bd -literal -offset indent +struct ether_addr { + u_int8_t ether_addr_octet[ETHER_ADDR_LEN]; +}; +.Ed +.Pp +The +.Fn ether_ntoa +function converts this structure into an +.Tn ASCII +string of the form +.Dq xx:xx:xx:xx:xx:xx , +consisting of 6 hexadecimal numbers separated +by colons. +It returns a pointer to a static buffer that is reused for each call. +The +.Fn ether_aton +converts an +.Tn ASCII +string of the same form and to a structure +containing the 6 octets of the address. +It returns a pointer to a static structure that is reused for each call. +.Fn ether_aton +will return NULL if the string does not represent a valid address. +.Pp +The +.Fn ether_ntohost +and +.Fn ether_hostton +functions interrogate the database mapping host names to Ethernet +addresses, +.Pa /etc/ethers . +The +.Fn ether_ntohost +function looks up the given Ethernet address and writes the associated +host name into the character buffer passed. +This buffer should be +.Dv MAXHOSTNAMELEN +characters in size. +The +.Fn ether_hostton +function looks up the given host name and writes the associated +Ethernet address into the structure passed. +Both functions return +zero if they find the requested host name or address, and \-1 if not. +.Pp +Each call reads +.Pa /etc/ethers +from the beginning. +.Pp +The +.Fn ether_line +function parses a line from the +.Pa /etc/ethers +file and fills in the passed +.Li struct ether_addr +and character buffer with the Ethernet address and host name on the line. +It returns zero if the line was successfully parsed and \-1 if not. +The character buffer should be +.Dv MAXHOSTNAMELEN +characters in size. +.Sh FILES +.Bl -tag -width /etc/ethers -compact +.It Pa /etc/ethers +.El +.Sh SEE ALSO +.Xr ethers 5 +.Sh HISTORY +The +.Fn ether_ntoa , +.Fn ether_aton , +.Fn ether_ntohost , +.Fn ether_hostton , +and +.Fn ether_line +functions were adopted from SunOS and appeared in +.Nx 0.9b . +.Sh BUGS +The data space used by these functions is static; if future use +requires the data, it should be copied before any subsequent calls to +these functions overwrite it. diff --git a/src/lib/libc/net/ethers.3 b/src/lib/libc/net/ethers.3 deleted file mode 100644 index 021e1ced73..0000000000 --- a/src/lib/libc/net/ethers.3 +++ /dev/null @@ -1,114 +0,0 @@ -.\" $OpenBSD: ethers.3,v 1.25 2018/11/09 17:49:32 brynet Exp $ -.\" -.\" Written by roland@frob.com. Public domain. -.\" -.Dd $Mdocdate: November 9 2018 $ -.Dt ETHER_ATON 3 -.Os -.Sh NAME -.Nm ether_aton , -.Nm ether_ntoa , -.Nm ether_ntohost , -.Nm ether_hostton , -.Nm ether_line -.Nd get ethers entry -.Sh SYNOPSIS -.In sys/types.h -.In sys/socket.h -.In net/if.h -.In netinet/in.h -.In netinet/if_ether.h -.Ft char * -.Fn ether_ntoa "struct ether_addr *e" -.Ft struct ether_addr * -.Fn ether_aton "const char *s" -.Ft int -.Fn ether_ntohost "char *hostname" "struct ether_addr *e" -.Ft int -.Fn ether_hostton "const char *hostname" "struct ether_addr *e" -.Ft int -.Fn ether_line "const char *l" "struct ether_addr *e" "char *hostname" -.Sh DESCRIPTION -Ethernet addresses are represented by the -following structure: -.Bd -literal -offset indent -struct ether_addr { - u_int8_t ether_addr_octet[ETHER_ADDR_LEN]; -}; -.Ed -.Pp -The -.Fn ether_ntoa -function converts this structure into an -.Tn ASCII -string of the form -.Dq xx:xx:xx:xx:xx:xx , -consisting of 6 hexadecimal numbers separated -by colons. -It returns a pointer to a static buffer that is reused for each call. -The -.Fn ether_aton -converts an -.Tn ASCII -string of the same form and to a structure -containing the 6 octets of the address. -It returns a pointer to a static structure that is reused for each call. -.Fn ether_aton -will return NULL if the string does not represent a valid address. -.Pp -The -.Fn ether_ntohost -and -.Fn ether_hostton -functions interrogate the database mapping host names to Ethernet -addresses, -.Pa /etc/ethers . -The -.Fn ether_ntohost -function looks up the given Ethernet address and writes the associated -host name into the character buffer passed. -This buffer should be -.Dv MAXHOSTNAMELEN -characters in size. -The -.Fn ether_hostton -function looks up the given host name and writes the associated -Ethernet address into the structure passed. -Both functions return -zero if they find the requested host name or address, and \-1 if not. -.Pp -Each call reads -.Pa /etc/ethers -from the beginning. -.Pp -The -.Fn ether_line -function parses a line from the -.Pa /etc/ethers -file and fills in the passed -.Li struct ether_addr -and character buffer with the Ethernet address and host name on the line. -It returns zero if the line was successfully parsed and \-1 if not. -The character buffer should be -.Dv MAXHOSTNAMELEN -characters in size. -.Sh FILES -.Bl -tag -width /etc/ethers -compact -.It Pa /etc/ethers -.El -.Sh SEE ALSO -.Xr ethers 5 -.Sh HISTORY -The -.Fn ether_ntoa , -.Fn ether_aton , -.Fn ether_ntohost , -.Fn ether_hostton , -and -.Fn ether_line -functions were adopted from SunOS and appeared in -.Nx 0.9b . -.Sh BUGS -The data space used by these functions is static; if future use -requires the data, it should be copied before any subsequent calls to -these functions overwrite it. diff --git a/src/lib/libc/net/htobe64.3 b/src/lib/libc/net/htobe64.3 new file mode 100644 index 0000000000..3e500897e2 --- /dev/null +++ b/src/lib/libc/net/htobe64.3 @@ -0,0 +1,166 @@ +.\" $OpenBSD: htobe64.3,v 1.1 2019/08/30 18:33:17 deraadt Exp $ +.\" +.\" Copyright (c) 1983, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd $Mdocdate: August 30 2019 $ +.Dt HTOBE64 3 +.Os +.Sh NAME +.Nm htobe64 , +.Nm htobe32 , +.Nm htobe16 , +.Nm be64toh , +.Nm be32toh , +.Nm be16toh , +.Nm betoh64 , +.Nm betoh32 , +.Nm betoh16 , +.Nm htole64 , +.Nm htole32 , +.Nm htole16 , +.Nm le64toh , +.Nm le32toh , +.Nm le16toh , +.Nm letoh64 , +.Nm letoh32 , +.Nm letoh16 , +.Nm swap64 , +.Nm swap32 , +.Nm swap16 +.Nd convert values between different byte orderings +.Sh SYNOPSIS +.In endian.h +.Ft uint64_t +.Fn htobe64 "uint64_t host64" +.Ft uint32_t +.Fn htobe32 "uint32_t host32" +.Ft uint16_t +.Fn htobe16 "uint16_t host16" +.Ft uint64_t +.Fn be64toh "uint64_t big64" +.Ft uint32_t +.Fn be32toh "uint32_t big32" +.Ft uint16_t +.Fn be16toh "uint16_t big16" +.Ft uint64_t +.Fn betoh64 "uint64_t big64" +.Ft uint32_t +.Fn betoh32 "uint32_t big32" +.Ft uint16_t +.Fn betoh16 "uint16_t big16" +.Ft uint64_t +.Fn htole64 "uint64_t host64" +.Ft uint32_t +.Fn htole32 "uint32_t host32" +.Ft uint16_t +.Fn htole16 "uint16_t host16" +.Ft uint64_t +.Fn letoh64 "uint64_t little64" +.Ft uint64_t +.Fn le64toh "uint64_t little64" +.Ft uint32_t +.Fn le32toh "uint32_t little32" +.Ft uint16_t +.Fn le16toh "uint16_t little16" +.Ft uint32_t +.Fn letoh32 "uint32_t little32" +.Ft uint16_t +.Fn letoh16 "uint16_t little16" +.Ft uint64_t +.Fn swap64 "uint64_t val64" +.Ft uint32_t +.Fn swap32 "uint32_t val32" +.Ft uint16_t +.Fn swap16 "uint16_t val16" +.Sh DESCRIPTION +These routines convert 16, 32 and 64-bit quantities between different +byte orderings. +The +.Dq swap +functions reverse the byte ordering of +the given quantity; the others convert either from/to the native +byte order used by the host to/from either little- or big-endian (a.k.a +network) order. +.Pp +Apart from the swap functions, +the names containing +.Dq be +convert between host and big-endian (most significant byte first) order +of the given quantity, while the names containing +.Dq le +convert between host and little-endian (least significant byte first) order +of the given quantity. +.Pp +All these functions use the numbers +16, 32, or 64 for specifying the bitwidth of the quantities they operate on. +Currently all supported architectures are either big- or little-endian +so either the +.Dq be +or +.Dq le +variants are implemented as null macros. +.Sh SEE ALSO +.Xr htonl 3 +.Sh STANDARDS +The +.Fn htobe64 , +.Fn htobe32 , +.Fn htobe16 , +.Fn be64toh , +.Fn be32toh , +.Fn be16toh , +.Fn htole64 , +.Fn htole32 , +.Fn htole16 , +.Fn le64toh , +.Fn le32toh , +and +.Fn le16toh +functions are expected to conform to a future version of +.St -p1003.1 . +The other functions are extensions that should not be used +when portability is required. +.Sh HISTORY +The +.Nm swap{size} +and +.Nm {src-order}to{dst-order}{size} +functions appeared in +.Bx 4.2 . +The +.Nm {src-order}{size}to{dst-order} +functions appeared in +.Ox 5.6 . +A subset of them was submitted for standardization after +.St -p1003.1-2008 . +.Sh BUGS +The perceived antagonism between +.Sq host +and +.Sq network +byte order does not allow PDP-11 users to sleep soundly at night. diff --git a/src/lib/libc/net/inet_addr.3 b/src/lib/libc/net/inet_addr.3 index 231f94ff1b..77d5cde9c7 100644 --- a/src/lib/libc/net/inet_addr.3 +++ b/src/lib/libc/net/inet_addr.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: inet_addr.3,v 1.3 2018/04/28 16:03:43 schwarze Exp $ +.\" $OpenBSD: inet_addr.3,v 1.4 2019/08/30 18:33:17 deraadt Exp $ .\" $NetBSD: inet.3,v 1.7 1997/06/18 02:25:24 lukem Exp $ .\" .\" Copyright (c) 1983, 1990, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)inet.3 8.1 (Berkeley) 6/4/93 .\" -.Dd $Mdocdate: April 28 2018 $ +.Dd $Mdocdate: August 30 2019 $ .Dt INET_ADDR 3 .Os .Sh NAME @@ -144,7 +144,7 @@ in the C language (i.e., a leading 0x or 0X implies hexadecimal; a leading 0 implies octal; otherwise, the number is interpreted as decimal). .Sh SEE ALSO -.Xr byteorder 3 , +.Xr htonl 3 , .Xr gethostbyname 3 , .Xr inet_lnaof 3 , .Xr inet_net 3 , diff --git a/src/lib/libc/net/inet_net.3 b/src/lib/libc/net/inet_net.3 deleted file mode 100644 index adb7589fca..0000000000 --- a/src/lib/libc/net/inet_net.3 +++ /dev/null @@ -1,197 +0,0 @@ -.\" $OpenBSD: inet_net.3,v 1.19 2018/04/28 20:29:18 schwarze Exp $ -.\" $NetBSD: inet_net.3,v 1.1 1997/06/18 02:25:27 lukem Exp $ -.\" -.\" Copyright (c) 1997 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Luke Mewburn. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd $Mdocdate: April 28 2018 $ -.Dt INET_NET_NTOP 3 -.Os -.Sh NAME -.Nm inet_net_ntop , -.Nm inet_net_pton -.Nd Internet network number manipulation routines -.Sh SYNOPSIS -.In sys/types.h -.In sys/socket.h -.In netinet/in.h -.In arpa/inet.h -.Ft char * -.Fn inet_net_ntop "int af" "const void *src" "int bits" "char *dst" "size_t size" -.Ft int -.Fn inet_net_pton "int af" "const char *src" "void *dst" "size_t size" -.Sh DESCRIPTION -The -.Fn inet_net_ntop -function converts an Internet network number from network format (usually a -.Li struct in_addr -or some other binary form, in network byte order) to CIDR presentation format -(suitable for external display purposes). -.Fa bits -is the number of bits in -.Fa src -that are the network number. -It returns -.Dv NULL -if a system error occurs (in which case, -.Va errno -will have been set), or it returns a pointer to the destination string. -.Pp -The -.Fn inet_net_pton -function converts a presentation format Internet network number (that is, -printable form as held in a character string) to network format (usually a -.Li struct in_addr -or some other internal binary representation, in network byte order). -It returns the number of bits (either computed based on the class, or -specified with /CIDR), or \-1 if a failure occurred -(in which case -.Va errno -will have been set. -It will be set to -.Er ENOENT -if the Internet network number was not valid). -.Pp -Caution: -The -.Fa dst -field should be zeroed before calling -.Fn inet_net_pton -as the function will only fill the number of bytes necessary to -encode the network number in network byte order. -.Pp -The only values for -.Fa af -currently supported are -.Dv AF_INET -and -.Dv AF_INET6 . -.Fa size -is the size of the result buffer -.Fa dst . -.Sh NETWORK NUMBERS (IP VERSION 4) -The external representation of Internet network numbers may be specified in -one of the following forms: -.Bd -literal -offset indent -a -a.b -a.b.c -a.b.c.d -.Ed -.Pp -Any of the above four forms may have -.Dq Li /bits -appended where -.Dq Li bits -is in the range -.Li 0-32 -and is used to explicitly specify the number of bits in the network address. -When -.Dq Li /bits -is not specified the number of bits in the network address is calculated -as the larger of the number of bits in the class to which the address -belongs and the number of bits provided rounded up modulo 8. -Examples: -.Pp -.Bl -tag -width 10.1.2.3/24 -offset indent -compact -.It Li 10 -an 8-bit network number (class A), value -.Li 10.0.0.0 . -.It Li 192 -a 24-bit network number (class C), value -.Li 192.0.0.0 . -.It Li 10.10 -a 16-bit network number, value -.Li 10.10.0.0 . -.It Li 10.1.2 -a 24-bit network number, value -.Li 10.1.2.0 . -.It Li 10.1.2.3 -a 32-bit network number, value -.Li 10.1.2.3 . -.It Li 10.1.2.3/24 -a 24-bit network number (explicit), value -.Li 10.1.2.3 . -.El -.Pp -Note that when the number of bits is specified using -.Dq Li /bits -notation, the value of the address still includes all bits supplied -in the external representation, even those bits which are the host -part of an Internet address. -Also, unlike -.Xr inet_pton 3 -where the external representation is assumed to be a host address, the -external representation for -.Fn inet_net_pton -is assumed to be a network address. -Thus -.Dq Li 10.1 -is assumed to be -.Dq Li 10.1.0.0 -not -.Dq Li 10.0.0.1 -.Pp -All numbers supplied as -.Dq parts -in a -.Ql \&. -notation -may be decimal, octal, or hexadecimal, as specified -in the C language (i.e., a leading 0x or 0X implies -hexadecimal; otherwise, a leading 0 implies octal; -otherwise, the number is interpreted as decimal). -.Sh NETWORK NUMBERS (IP VERSION 6) -See -.Xr inet_pton 3 -for valid external representations of IP version 6 addresses. -A valid external representation may have -.Dq Li /bits -appended where -.Dq Li bits -is in the range -.Li 0-128 -and is used to explicitly specify the number of bits in the network address. -When -.Dq Li /bits -is not specified 128 is used. -Note that when the number of bits is specified using -.Dq Li /bits -notation, the value of the address still includes all bits supplied -in the external representation, even those bits which are the host -part of an Internet address. -.Sh SEE ALSO -.Xr byteorder 3 , -.Xr inet_pton 3 , -.Xr inet 4 , -.Xr hosts 5 -.Sh HISTORY -The -.Nm inet_net_ntop -and -.Nm inet_net_pton -functions first appeared in BIND 4.9.4. diff --git a/src/lib/libc/net/inet_net_ntop.3 b/src/lib/libc/net/inet_net_ntop.3 new file mode 100644 index 0000000000..db10bf962c --- /dev/null +++ b/src/lib/libc/net/inet_net_ntop.3 @@ -0,0 +1,197 @@ +.\" $OpenBSD: inet_net_ntop.3,v 1.1 2019/08/30 18:33:17 deraadt Exp $ +.\" $NetBSD: inet_net.3,v 1.1 1997/06/18 02:25:27 lukem Exp $ +.\" +.\" Copyright (c) 1997 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Luke Mewburn. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE +.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd $Mdocdate: August 30 2019 $ +.Dt INET_NET_NTOP 3 +.Os +.Sh NAME +.Nm inet_net_ntop , +.Nm inet_net_pton +.Nd Internet network number manipulation routines +.Sh SYNOPSIS +.In sys/types.h +.In sys/socket.h +.In netinet/in.h +.In arpa/inet.h +.Ft char * +.Fn inet_net_ntop "int af" "const void *src" "int bits" "char *dst" "size_t size" +.Ft int +.Fn inet_net_pton "int af" "const char *src" "void *dst" "size_t size" +.Sh DESCRIPTION +The +.Fn inet_net_ntop +function converts an Internet network number from network format (usually a +.Li struct in_addr +or some other binary form, in network byte order) to CIDR presentation format +(suitable for external display purposes). +.Fa bits +is the number of bits in +.Fa src +that are the network number. +It returns +.Dv NULL +if a system error occurs (in which case, +.Va errno +will have been set), or it returns a pointer to the destination string. +.Pp +The +.Fn inet_net_pton +function converts a presentation format Internet network number (that is, +printable form as held in a character string) to network format (usually a +.Li struct in_addr +or some other internal binary representation, in network byte order). +It returns the number of bits (either computed based on the class, or +specified with /CIDR), or \-1 if a failure occurred +(in which case +.Va errno +will have been set. +It will be set to +.Er ENOENT +if the Internet network number was not valid). +.Pp +Caution: +The +.Fa dst +field should be zeroed before calling +.Fn inet_net_pton +as the function will only fill the number of bytes necessary to +encode the network number in network byte order. +.Pp +The only values for +.Fa af +currently supported are +.Dv AF_INET +and +.Dv AF_INET6 . +.Fa size +is the size of the result buffer +.Fa dst . +.Sh NETWORK NUMBERS (IP VERSION 4) +The external representation of Internet network numbers may be specified in +one of the following forms: +.Bd -literal -offset indent +a +a.b +a.b.c +a.b.c.d +.Ed +.Pp +Any of the above four forms may have +.Dq Li /bits +appended where +.Dq Li bits +is in the range +.Li 0-32 +and is used to explicitly specify the number of bits in the network address. +When +.Dq Li /bits +is not specified the number of bits in the network address is calculated +as the larger of the number of bits in the class to which the address +belongs and the number of bits provided rounded up modulo 8. +Examples: +.Pp +.Bl -tag -width 10.1.2.3/24 -offset indent -compact +.It Li 10 +an 8-bit network number (class A), value +.Li 10.0.0.0 . +.It Li 192 +a 24-bit network number (class C), value +.Li 192.0.0.0 . +.It Li 10.10 +a 16-bit network number, value +.Li 10.10.0.0 . +.It Li 10.1.2 +a 24-bit network number, value +.Li 10.1.2.0 . +.It Li 10.1.2.3 +a 32-bit network number, value +.Li 10.1.2.3 . +.It Li 10.1.2.3/24 +a 24-bit network number (explicit), value +.Li 10.1.2.3 . +.El +.Pp +Note that when the number of bits is specified using +.Dq Li /bits +notation, the value of the address still includes all bits supplied +in the external representation, even those bits which are the host +part of an Internet address. +Also, unlike +.Xr inet_pton 3 +where the external representation is assumed to be a host address, the +external representation for +.Fn inet_net_pton +is assumed to be a network address. +Thus +.Dq Li 10.1 +is assumed to be +.Dq Li 10.1.0.0 +not +.Dq Li 10.0.0.1 +.Pp +All numbers supplied as +.Dq parts +in a +.Ql \&. +notation +may be decimal, octal, or hexadecimal, as specified +in the C language (i.e., a leading 0x or 0X implies +hexadecimal; otherwise, a leading 0 implies octal; +otherwise, the number is interpreted as decimal). +.Sh NETWORK NUMBERS (IP VERSION 6) +See +.Xr inet_pton 3 +for valid external representations of IP version 6 addresses. +A valid external representation may have +.Dq Li /bits +appended where +.Dq Li bits +is in the range +.Li 0-128 +and is used to explicitly specify the number of bits in the network address. +When +.Dq Li /bits +is not specified 128 is used. +Note that when the number of bits is specified using +.Dq Li /bits +notation, the value of the address still includes all bits supplied +in the external representation, even those bits which are the host +part of an Internet address. +.Sh SEE ALSO +.Xr htonl 3 , +.Xr inet_pton 3 , +.Xr inet 4 , +.Xr hosts 5 +.Sh HISTORY +The +.Nm inet_net_ntop +and +.Nm inet_net_pton +functions first appeared in BIND 4.9.4. diff --git a/src/lib/libc/net/res_init.3 b/src/lib/libc/net/res_init.3 new file mode 100644 index 0000000000..01a6b8e0b3 --- /dev/null +++ b/src/lib/libc/net/res_init.3 @@ -0,0 +1,410 @@ +.\" $OpenBSD: res_init.3,v 1.1 2019/08/30 18:33:17 deraadt Exp $ +.\" +.\" Copyright (c) 1985, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.Dd $Mdocdate: August 30 2019 $ +.Dt RES_INIT 3 +.Os +.Sh NAME +.Nm res_query , +.Nm res_search , +.Nm res_mkquery , +.Nm res_send , +.Nm res_init , +.Nm dn_comp , +.Nm dn_expand +.Nd resolver routines +.Sh SYNOPSIS +.In sys/types.h +.In netinet/in.h +.In arpa/nameser.h +.In resolv.h +.Ft int +.Fo res_query +.Fa "const char *dname" +.Fa "int class" +.Fa "int type" +.Fa "unsigned char *answer" +.Fa "int anslen" +.Fc +.Ft int +.Fo res_search +.Fa "const char *dname" +.Fa "int class" +.Fa "int type" +.Fa "unsigned char *answer" +.Fa "int anslen" +.Fc +.Ft int +.Fo res_mkquery +.Fa "int op" +.Fa "const char *dname" +.Fa "int class" +.Fa "int type" +.Fa "const unsigned char *data" +.Fa "int datalen" +.Fa "const unsigned char *newrr" +.Fa "unsigned char *buf" +.Fa "int buflen" +.Fc +.Ft int +.Fo res_send +.Fa "const unsigned char *msg" +.Fa "int msglen" +.Fa "unsigned char *answer" +.Fa "int anslen" +.Fc +.Ft int +.Fn res_init "void" +.Ft int +.Fo dn_comp +.Fa "const char *exp_dn" +.Fa "unsigned char *comp_dn" +.Fa "int length" +.Fa "unsigned char **dnptrs" +.Fa "unsigned char **lastdnptr" +.Fc +.Ft int +.Fo dn_expand +.Fa "const unsigned char *msg" +.Fa "const unsigned char *eomorig" +.Fa "const unsigned char *comp_dn" +.Fa "char *exp_dn" +.Fa "int length" +.Fc +.Sh DESCRIPTION +These routines are used for making, sending, and interpreting +query and reply messages with Internet domain name servers. +.Pp +Global configuration and state information that is used by the +resolver routines is kept in the structure +.Va _res . +Most of the values have reasonable defaults and can be ignored. +Options stored in +.Va _res.options +are defined in +.In resolv.h +and are as follows. +Options are stored as a simple bit mask containing the bitwise OR +of the options enabled. +.Bl -tag -width RES_USE_DNSSEC +.It Dv RES_INIT +True if the initial name server address and default domain name are +initialized (i.e.\& +.Fn res_init +has been called). +.It Dv RES_DEBUG +Print debugging messages, +if libc is compiled with +.Dv DEBUG . +By default on +.Ox +this option does nothing. +.It Dv RES_AAONLY +Accept authoritative answers only. +With this option, +.Fn res_send +should continue until it finds an authoritative answer or finds an error. +On +.Ox +this option does nothing. +.It Dv RES_USEVC +Use TCP connections for queries instead of UDP datagrams. +.It Dv RES_PRIMARY +Query the primary name server only. +On +.Ox +this option does nothing. +.It Dv RES_IGNTC +Ignore truncation errors, i.e. don't retry with TCP. +.It Dv RES_RECURSE +Set the recursion-desired bit in queries. +.Pf ( Fn res_send +does not do iterative queries and expects the name server +to handle recursion.) +This option is enabled by default. +.It Dv RES_DEFNAMES +If set, +.Fn res_search +will append the default domain name to single-component names +(those that do not contain a dot). +This option is enabled by default. +.It Dv RES_STAYOPEN +Used with +.Dv RES_USEVC +to keep the TCP connection open between queries. +This is useful only in programs that regularly do many queries. +UDP should be the normal mode used. +.It Dv RES_DNSRCH +If this option is set, +.Fn res_search +will search for host names in the current domain and in parent domains; see +.Xr hostname 7 . +This is used by the standard host lookup routine +.Xr gethostbyname 3 . +This option is enabled by default. +.It Dv RES_INSECURE_1 +Do not require the IP source address on the reply packet +to be equal to the server's address. +.It Dv RES_INSECURE_2 +Do not check if the query section of the reply packet +is equal to that of the query packet. +.It Dv RES_NOALIASES +This option has no effect. +In the past, it turned off the legacy +.Ev HOSTALIASES +feature. +.It Dv RES_USE_INET6 +Enables support for IPv6-only applications. +This causes IPv4 addresses to be returned as an IPv4 mapped address. +For example, 10.1.1.1 will be returned as ::ffff:10.1.1.1. +On +.Ox +this option does nothing. +.It Dv RES_USE_EDNS0 +Attach an OPT pseudo-RR for the EDNS0 extension, +as specified in RFC 2671. +This informs DNS servers of a client's receive buffer size, +allowing them to take advantage of a non-default receive buffer size, +and thus to send larger replies. +DNS query packets with the EDNS0 extension are not compatible with +non-EDNS0 DNS servers. +.Ox +uses 4096 bytes as input buffer size. +.It Dv RES_USE_DNSSEC +Request that the resolver uses +Domain Name System Security Extensions (DNSSEC), +as defined in RFCs 4033, 4034, and 4035. +.It Dv RES_USE_CD +Set the Checking Disabled flag on queries. +.El +.Pp +The +.Fn res_init +routine reads the configuration file (if any; see +.Xr resolv.conf 5 ) +to get the default domain name, search list, and the Internet address +of the local name server(s). +If no server is configured, the host running +the resolver is tried. +The current domain name is defined by the hostname +if not specified in the configuration file; +it can be overridden by the environment variable +.Ev LOCALDOMAIN . +This environment variable may contain several blank-separated +tokens if you wish to override the search list on a per-process basis. +This is similar to the +.Ic search +command in the configuration file. +Another environment variable +.Ev RES_OPTIONS +can be set to override certain internal resolver options which +are otherwise set by changing fields in the +.Va _res +structure or are inherited from the configuration file's +.Ic options +command. +The syntax of the +.Ev RES_OPTIONS +environment variable is explained in +.Xr resolv.conf 5 . +Initialization normally occurs on the first call +to one of the following routines. +.Pp +The +.Fn res_query +function provides an interface to the server query mechanism. +It constructs a query, sends it to the local server, +awaits a response, and makes preliminary checks on the reply. +The query requests information of the specified +.Fa type +and +.Fa class +for the specified fully qualified domain name +.Fa dname . +The reply message is left in the +.Fa answer +buffer with length +.Fa anslen +supplied by the caller. +Values for the +.Fa class +and +.Fa type +fields +are defined in +.In arpa/nameser.h . +.Pp +The +.Fn res_search +routine makes a query and awaits a response like +.Fn res_query , +but in addition, it implements the default and search rules controlled by the +.Dv RES_DEFNAMES +and +.Dv RES_DNSRCH +options. +It returns the first successful reply. +.Pp +The remaining routines are lower-level routines used by +.Fn res_query . +The +.Fn res_mkquery +function constructs a standard query message and places it in +.Fa buf . +It returns the size of the query, or \-1 if the query is larger than +.Fa buflen . +The query type +.Fa op +is usually +.Dv QUERY , +but can be any of the query types defined in +.In arpa/nameser.h . +The domain name for the query is given by +.Fa dname . +.Fa newrr +is currently unused but is intended for making update messages. +.Pp +The +.Fn res_send +routine sends a pre-formatted query and returns an answer. +It will call +.Fn res_init +if +.Dv RES_INIT +is not set, send the query to the local name server, and +handle timeouts and retries. +The length of the reply message is returned, or \-1 if there were errors. +.Pp +The +.Fn dn_comp +function compresses the domain name +.Fa exp_dn +and stores it in +.Fa comp_dn . +The size of the compressed name is returned or \-1 if there were errors. +The size of the array pointed to by +.Fa comp_dn +is given by +.Fa length . +The compression uses an array of pointers +.Fa dnptrs +to previously compressed names in the current message. +The first pointer points +to the beginning of the message and the list ends with +.Dv NULL . +The limit to the array is specified by +.Fa lastdnptr . +A side effect of +.Fn dn_comp +is to update the list of pointers for labels inserted into the message +as the name is compressed. +If +.Fa dnptrs +is +.Dv NULL , +names are not compressed. +If +.Fa lastdnptr +is +.Dv NULL , +the list of labels is not updated. +.Pp +The +.Fn dn_expand +entry expands the compressed domain name +.Fa comp_dn +to a full domain name. +The compressed name is contained in a query or reply message; +.Fa msg +is a pointer to the beginning of the message. +The uncompressed name is placed in the buffer indicated by +.Fa exp_dn +which is of size +.Fa length . +The size of compressed name is returned or \-1 if there was an error. +.Sh FILES +.Bl -tag -width "/etc/resolv.confXX" +.It Pa /etc/resolv.conf +The configuration file. +.El +.Sh SEE ALSO +.Xr gethostbyname 3 , +.Xr resolv.conf 5 , +.Xr hostname 7 +.Sh STANDARDS +.Rs +.%A M. Stahl +.%D November 1987 +.%R RFC 1032 +.%T Domain Administrators Guide +.Re +.Pp +.Rs +.%A M. Lottor +.%D November 1987 +.%R RFC 1033 +.%T Domain Administrators Operations Guide +.Re +.Pp +.Rs +.%A P. Mockapetris +.%D November 1987 +.%R RFC 1034 +.%T Domain Names \(en Concepts and Facilities +.Re +.Pp +.Rs +.%A P. Mockapetris +.%D November 1987 +.%R RFC 1035 +.%T Domain Names \(en Implementation and Specification +.Re +.Pp +.Rs +.%A J. Klensin +.%D October 2008 +.%R RFC 5321 +.%T Simple Mail Transfer Protocol +.Re +.Sh HISTORY +The functions +.Fn res_mkquery , +.Fn res_send , +.Fn res_init , +.Fn dn_comp , +and +.Fn dn_expand +appeared in +.Bx 4.3 . +The functions +.Fn res_query +and +.Fn res_search +appeared in +.Bx 4.3 Tahoe . diff --git a/src/lib/libc/net/resolver.3 b/src/lib/libc/net/resolver.3 deleted file mode 100644 index e354bdbec4..0000000000 --- a/src/lib/libc/net/resolver.3 +++ /dev/null @@ -1,410 +0,0 @@ -.\" $OpenBSD: resolver.3,v 1.39 2019/05/13 14:11:20 schwarze Exp $ -.\" -.\" Copyright (c) 1985, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: May 13 2019 $ -.Dt RES_INIT 3 -.Os -.Sh NAME -.Nm res_query , -.Nm res_search , -.Nm res_mkquery , -.Nm res_send , -.Nm res_init , -.Nm dn_comp , -.Nm dn_expand -.Nd resolver routines -.Sh SYNOPSIS -.In sys/types.h -.In netinet/in.h -.In arpa/nameser.h -.In resolv.h -.Ft int -.Fo res_query -.Fa "const char *dname" -.Fa "int class" -.Fa "int type" -.Fa "unsigned char *answer" -.Fa "int anslen" -.Fc -.Ft int -.Fo res_search -.Fa "const char *dname" -.Fa "int class" -.Fa "int type" -.Fa "unsigned char *answer" -.Fa "int anslen" -.Fc -.Ft int -.Fo res_mkquery -.Fa "int op" -.Fa "const char *dname" -.Fa "int class" -.Fa "int type" -.Fa "const unsigned char *data" -.Fa "int datalen" -.Fa "const unsigned char *newrr" -.Fa "unsigned char *buf" -.Fa "int buflen" -.Fc -.Ft int -.Fo res_send -.Fa "const unsigned char *msg" -.Fa "int msglen" -.Fa "unsigned char *answer" -.Fa "int anslen" -.Fc -.Ft int -.Fn res_init "void" -.Ft int -.Fo dn_comp -.Fa "const char *exp_dn" -.Fa "unsigned char *comp_dn" -.Fa "int length" -.Fa "unsigned char **dnptrs" -.Fa "unsigned char **lastdnptr" -.Fc -.Ft int -.Fo dn_expand -.Fa "const unsigned char *msg" -.Fa "const unsigned char *eomorig" -.Fa "const unsigned char *comp_dn" -.Fa "char *exp_dn" -.Fa "int length" -.Fc -.Sh DESCRIPTION -These routines are used for making, sending, and interpreting -query and reply messages with Internet domain name servers. -.Pp -Global configuration and state information that is used by the -resolver routines is kept in the structure -.Va _res . -Most of the values have reasonable defaults and can be ignored. -Options stored in -.Va _res.options -are defined in -.In resolv.h -and are as follows. -Options are stored as a simple bit mask containing the bitwise OR -of the options enabled. -.Bl -tag -width RES_USE_DNSSEC -.It Dv RES_INIT -True if the initial name server address and default domain name are -initialized (i.e.\& -.Fn res_init -has been called). -.It Dv RES_DEBUG -Print debugging messages, -if libc is compiled with -.Dv DEBUG . -By default on -.Ox -this option does nothing. -.It Dv RES_AAONLY -Accept authoritative answers only. -With this option, -.Fn res_send -should continue until it finds an authoritative answer or finds an error. -On -.Ox -this option does nothing. -.It Dv RES_USEVC -Use TCP connections for queries instead of UDP datagrams. -.It Dv RES_PRIMARY -Query the primary name server only. -On -.Ox -this option does nothing. -.It Dv RES_IGNTC -Ignore truncation errors, i.e. don't retry with TCP. -.It Dv RES_RECURSE -Set the recursion-desired bit in queries. -.Pf ( Fn res_send -does not do iterative queries and expects the name server -to handle recursion.) -This option is enabled by default. -.It Dv RES_DEFNAMES -If set, -.Fn res_search -will append the default domain name to single-component names -(those that do not contain a dot). -This option is enabled by default. -.It Dv RES_STAYOPEN -Used with -.Dv RES_USEVC -to keep the TCP connection open between queries. -This is useful only in programs that regularly do many queries. -UDP should be the normal mode used. -.It Dv RES_DNSRCH -If this option is set, -.Fn res_search -will search for host names in the current domain and in parent domains; see -.Xr hostname 7 . -This is used by the standard host lookup routine -.Xr gethostbyname 3 . -This option is enabled by default. -.It Dv RES_INSECURE_1 -Do not require the IP source address on the reply packet -to be equal to the server's address. -.It Dv RES_INSECURE_2 -Do not check if the query section of the reply packet -is equal to that of the query packet. -.It Dv RES_NOALIASES -This option has no effect. -In the past, it turned off the legacy -.Ev HOSTALIASES -feature. -.It Dv RES_USE_INET6 -Enables support for IPv6-only applications. -This causes IPv4 addresses to be returned as an IPv4 mapped address. -For example, 10.1.1.1 will be returned as ::ffff:10.1.1.1. -On -.Ox -this option does nothing. -.It Dv RES_USE_EDNS0 -Attach an OPT pseudo-RR for the EDNS0 extension, -as specified in RFC 2671. -This informs DNS servers of a client's receive buffer size, -allowing them to take advantage of a non-default receive buffer size, -and thus to send larger replies. -DNS query packets with the EDNS0 extension are not compatible with -non-EDNS0 DNS servers. -.Ox -uses 4096 bytes as input buffer size. -.It Dv RES_USE_DNSSEC -Request that the resolver uses -Domain Name System Security Extensions (DNSSEC), -as defined in RFCs 4033, 4034, and 4035. -.It Dv RES_USE_CD -Set the Checking Disabled flag on queries. -.El -.Pp -The -.Fn res_init -routine reads the configuration file (if any; see -.Xr resolv.conf 5 ) -to get the default domain name, search list, and the Internet address -of the local name server(s). -If no server is configured, the host running -the resolver is tried. -The current domain name is defined by the hostname -if not specified in the configuration file; -it can be overridden by the environment variable -.Ev LOCALDOMAIN . -This environment variable may contain several blank-separated -tokens if you wish to override the search list on a per-process basis. -This is similar to the -.Ic search -command in the configuration file. -Another environment variable -.Ev RES_OPTIONS -can be set to override certain internal resolver options which -are otherwise set by changing fields in the -.Va _res -structure or are inherited from the configuration file's -.Ic options -command. -The syntax of the -.Ev RES_OPTIONS -environment variable is explained in -.Xr resolv.conf 5 . -Initialization normally occurs on the first call -to one of the following routines. -.Pp -The -.Fn res_query -function provides an interface to the server query mechanism. -It constructs a query, sends it to the local server, -awaits a response, and makes preliminary checks on the reply. -The query requests information of the specified -.Fa type -and -.Fa class -for the specified fully qualified domain name -.Fa dname . -The reply message is left in the -.Fa answer -buffer with length -.Fa anslen -supplied by the caller. -Values for the -.Fa class -and -.Fa type -fields -are defined in -.In arpa/nameser.h . -.Pp -The -.Fn res_search -routine makes a query and awaits a response like -.Fn res_query , -but in addition, it implements the default and search rules controlled by the -.Dv RES_DEFNAMES -and -.Dv RES_DNSRCH -options. -It returns the first successful reply. -.Pp -The remaining routines are lower-level routines used by -.Fn res_query . -The -.Fn res_mkquery -function constructs a standard query message and places it in -.Fa buf . -It returns the size of the query, or \-1 if the query is larger than -.Fa buflen . -The query type -.Fa op -is usually -.Dv QUERY , -but can be any of the query types defined in -.In arpa/nameser.h . -The domain name for the query is given by -.Fa dname . -.Fa newrr -is currently unused but is intended for making update messages. -.Pp -The -.Fn res_send -routine sends a pre-formatted query and returns an answer. -It will call -.Fn res_init -if -.Dv RES_INIT -is not set, send the query to the local name server, and -handle timeouts and retries. -The length of the reply message is returned, or \-1 if there were errors. -.Pp -The -.Fn dn_comp -function compresses the domain name -.Fa exp_dn -and stores it in -.Fa comp_dn . -The size of the compressed name is returned or \-1 if there were errors. -The size of the array pointed to by -.Fa comp_dn -is given by -.Fa length . -The compression uses an array of pointers -.Fa dnptrs -to previously compressed names in the current message. -The first pointer points -to the beginning of the message and the list ends with -.Dv NULL . -The limit to the array is specified by -.Fa lastdnptr . -A side effect of -.Fn dn_comp -is to update the list of pointers for labels inserted into the message -as the name is compressed. -If -.Fa dnptrs -is -.Dv NULL , -names are not compressed. -If -.Fa lastdnptr -is -.Dv NULL , -the list of labels is not updated. -.Pp -The -.Fn dn_expand -entry expands the compressed domain name -.Fa comp_dn -to a full domain name. -The compressed name is contained in a query or reply message; -.Fa msg -is a pointer to the beginning of the message. -The uncompressed name is placed in the buffer indicated by -.Fa exp_dn -which is of size -.Fa length . -The size of compressed name is returned or \-1 if there was an error. -.Sh FILES -.Bl -tag -width "/etc/resolv.confXX" -.It Pa /etc/resolv.conf -The configuration file. -.El -.Sh SEE ALSO -.Xr gethostbyname 3 , -.Xr resolv.conf 5 , -.Xr hostname 7 -.Sh STANDARDS -.Rs -.%A M. Stahl -.%D November 1987 -.%R RFC 1032 -.%T Domain Administrators Guide -.Re -.Pp -.Rs -.%A M. Lottor -.%D November 1987 -.%R RFC 1033 -.%T Domain Administrators Operations Guide -.Re -.Pp -.Rs -.%A P. Mockapetris -.%D November 1987 -.%R RFC 1034 -.%T Domain Names \(en Concepts and Facilities -.Re -.Pp -.Rs -.%A P. Mockapetris -.%D November 1987 -.%R RFC 1035 -.%T Domain Names \(en Implementation and Specification -.Re -.Pp -.Rs -.%A J. Klensin -.%D October 2008 -.%R RFC 5321 -.%T Simple Mail Transfer Protocol -.Re -.Sh HISTORY -The functions -.Fn res_mkquery , -.Fn res_send , -.Fn res_init , -.Fn dn_comp , -and -.Fn dn_expand -appeared in -.Bx 4.3 . -The functions -.Fn res_query -and -.Fn res_search -appeared in -.Bx 4.3 Tahoe . -- cgit v1.2.3-55-g6feb