diff options
Diffstat (limited to 'lib/libc/net')
93 files changed, 1048 insertions, 722 deletions
diff --git a/lib/libc/net/Makefile.inc b/lib/libc/net/Makefile.inc index 755d44e6c5dd..7e9e5295c78c 100644 --- a/lib/libc/net/Makefile.inc +++ b/lib/libc/net/Makefile.inc @@ -1,10 +1,7 @@ -# from @(#)Makefile.inc 8.2 (Berkeley) 9/5/93 -# $FreeBSD$ - # machine-independent net sources .PATH: ${LIBC_SRCTOP}/net -CONFS+= net/hosts net/hosts.equiv net/networks net/nsswitch.conf net/protocols +CONFS+= net/hosts net/hosts.equiv net/networks ${.OBJDIR}/nsswitch.conf net/protocols SRCS+= base64.c ether_addr.c eui64.c \ gai_strerror.c getaddrinfo.c \ gethostbydns.c gethostbyht.c gethostbynis.c gethostnamadr.c \ @@ -14,7 +11,7 @@ SRCS+= base64.c ether_addr.c eui64.c \ if_indextoname.c if_nameindex.c if_nametoindex.c \ ip6opt.c linkaddr.c map_v4v6.c name6.c ntoh.c \ nsdispatch.c nslexer.l nsparser.y nss_compat.c \ - rcmd.c rcmdsh.c recv.c rthdr.c sctp_sys_calls.c send.c \ + rcmd.c rcmdsh.c rthdr.c sctp_sys_calls.c \ sockatmark.c sourcefilter.c vars.c .if ${MK_NS_CACHING} != "no" @@ -51,41 +48,75 @@ MAN+= byteorder.3 ethers.3 eui64.3 \ sctp_getaddrlen.3 sctp_getassocid.3 sctp_getpaddrs.3 \ sctp_opt_info.3 sctp_recvmsg.3 sctp_send.3 sctp_sendmsg.3 \ -MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \ +MLINKS+=byteorder.3 htonl.3 \ + byteorder.3 htons.3 \ + byteorder.3 ntohl.3 \ byteorder.3 ntohs.3 -MLINKS+=ethers.3 ether_aton.3 ethers.3 ether_hostton.3 ethers.3 ether_line.3 \ - ethers.3 ether_ntoa.3 ethers.3 ether_ntohost.3 -MLINKS+=eui64.3 eui64_aton.3 eui64.3 eui64_hostton.3 \ - eui64.3 eui64_ntoa.3 eui64.3 eui64_ntohost.3 -MLINKS+=getaddrinfo.3 freeaddrinfo.3 -MLINKS+=gethostbyname.3 endhostent.3 gethostbyname.3 gethostbyaddr.3 \ - gethostbyname.3 gethostbyaddr_r.3 gethostbyname.3 gethostbyname2.3 \ - gethostbyname.3 gethostbyname2_r.3 gethostbyname.3 gethostbyname_r.3 \ - gethostbyname.3 gethostent.3 gethostbyname.3 herror.3 \ - gethostbyname.3 hstrerror.3 gethostbyname.3 sethostent.3 +MLINKS+=ethers.3 ether_aton.3 \ + ethers.3 ether_aton_r.3 \ + ethers.3 ether_hostton.3 \ + ethers.3 ether_line.3 \ + ethers.3 ether_ntoa.3 \ + ethers.3 ether_ntoa_r.3 \ + ethers.3 ether_ntohost.3 +MLINKS+=eui64.3 eui64_aton.3 \ + eui64.3 eui64_hostton.3 \ + eui64.3 eui64_ntoa.3 \ + eui64.3 eui64_ntohost.3 +MLINKS+=getaddrinfo.3 freeaddrinfo.3 +MLINKS+=gethostbyname.3 endhostent.3 \ + gethostbyname.3 gethostbyaddr.3 \ + gethostbyname.3 gethostbyaddr_r.3 \ + gethostbyname.3 gethostbyname2.3 \ + gethostbyname.3 gethostbyname2_r.3 \ + gethostbyname.3 gethostbyname_r.3 \ + gethostbyname.3 gethostent.3 \ + gethostbyname.3 herror.3 \ + gethostbyname.3 hstrerror.3 \ + gethostbyname.3 sethostent.3 MLINKS+=getifaddrs.3 freeifaddrs.3 MLINKS+=getifmaddrs.3 freeifmaddrs.3 -MLINKS+=getipnodebyname.3 getipnodebyaddr.3 getipnodebyname.3 freehostent.3 -MLINKS+=getnetent.3 endnetent.3 getnetent.3 getnetbyaddr.3 \ - getnetent.3 getnetbyaddr_r.3 getnetent.3 getnetbyname.3 \ - getnetent.3 getnetbyname_r.3 getnetent.3 setnetent.3 \ +MLINKS+=getipnodebyname.3 getipnodebyaddr.3 \ + getipnodebyname.3 freehostent.3 +MLINKS+=getnetent.3 endnetent.3 \ + getnetent.3 getnetbyaddr.3 \ + getnetent.3 getnetbyaddr_r.3 \ + getnetent.3 getnetbyname.3 \ + getnetent.3 getnetbyname_r.3 \ + getnetent.3 setnetent.3 \ getnetent.3 getnetent_r.3 -MLINKS+=getprotoent.3 endprotoent.3 getprotoent.3 getprotobyname.3 \ - getprotoent.3 getprotobynumber.3 getprotoent.3 setprotoent.3 -MLINKS+=getservent.3 endservent.3 getservent.3 getservbyname.3 \ - getservent.3 getservbyport.3 getservent.3 setservent.3 -MLINKS+=if_indextoname.3 if_nametoindex.3 if_indextoname.3 if_nameindex.3 \ +MLINKS+=getprotoent.3 endprotoent.3 \ + getprotoent.3 getprotobyname.3 \ + getprotoent.3 getprotobynumber.3 \ + getprotoent.3 setprotoent.3 +MLINKS+=getservent.3 endservent.3 \ + getservent.3 getservbyname.3 \ + getservent.3 getservbyport.3 \ + getservent.3 setservent.3 +MLINKS+=if_indextoname.3 if_nametoindex.3 \ + if_indextoname.3 if_nameindex.3 \ if_indextoname.3 if_freenameindex.3 -MLINKS+=inet.3 addr.3 inet.3 inet_addr.3 inet.3 inet_aton.3 \ - inet.3 inet_lnaof.3 inet.3 inet_makeaddr.3 inet.3 inet_netof.3 \ - inet.3 inet_network.3 inet.3 inet_ntoa.3 inet.3 inet_ntoa_r.3\ - inet.3 inet_ntop.3 inet.3 inet_pton.3 \ - inet.3 network.3 inet.3 ntoa.3 -MLINKS+= sctp_send.3 sctp_sendx.3 -MLINKS+= sctp_sendmsg.3 sctp_sendmsgx.3 -MLINKS+= sctp_freepaddrs.3 sctp_freeladdrs.3 -MLINKS+= sctp_getpaddrs.3 sctp_getladdrs.3 -MLINKS+=inet_net.3 inet_net_ntop.3 inet_net.3 inet_net_pton.3 +MLINKS+=inet.3 addr.3 \ + inet.3 inet_addr.3 \ + inet.3 inet_aton.3 \ + inet.3 inet_lnaof.3 \ + inet.3 inet_makeaddr.3 \ + inet.3 inet_netof.3 \ + inet.3 inet_network.3 \ + inet.3 inet_ntoa.3 \ + inet.3 inet_ntoa_r.3 \ + inet.3 inet_ntop.3 \ + inet.3 inet_pton.3 \ + inet.3 network.3 \ + inet.3 ntoa.3 +MLINKS+=sctp_freepaddrs.3 sctp_freeladdrs.3 +MLINKS+=sctp_getpaddrs.3 sctp_getladdrs.3 +MLINKS+=sctp_recvmsg.3 sctp_recvv.3 +MLINKS+=sctp_sendmsg.3 sctp_sendmsgx.3 +MLINKS+=sctp_send.3 sctp_sendx.3 \ + sctp_send.3 sctp_sendv.3 +MLINKS+=inet_net.3 inet_net_ntop.3 \ + inet_net.3 inet_net_pton.3 MLINKS+=inet6_opt_init.3 inet6_opt_append.3 \ inet6_opt_init.3 inet6_opt_find.3 \ inet6_opt_init.3 inet6_opt_finish.3 \ @@ -109,27 +140,50 @@ MLINKS+=inet6_opt_init.3 inet6_opt_append.3 \ inet6_rthdr_space.3 inet6_rthdr_lasthop.3 \ inet6_rthdr_space.3 inet6_rthdr_reverse.3 \ inet6_rthdr_space.3 inet6_rthdr_segments.3 -MLINKS+=linkaddr.3 link_addr.3 linkaddr.3 link_ntoa.3 -MLINKS+=rcmd.3 iruserok.3 rcmd.3 iruserok_sa.3 \ +MLINKS+=linkaddr.3 link_addr.3 \ + linkaddr.3 link_ntoa.3 \ + linkaddr.3 link_ntoa_r.3 +MLINKS+=rcmd.3 iruserok.3 \ + rcmd.3 iruserok_sa.3 \ rcmd.3 rcmd_af.3 \ - rcmd.3 rresvport.3 rcmd.3 rresvport_af.3 \ + rcmd.3 rresvport.3 \ + rcmd.3 rresvport_af.3 \ rcmd.3 ruserok.3 -MLINKS+=resolver.3 dn_comp.3 resolver.3 dn_expand.3 resolver.3 res_init.3 \ - resolver.3 res_mkquery.3 resolver.3 res_query.3 \ - resolver.3 res_search.3 resolver.3 res_send.3 resolver.3 dn_skipname.3 \ - resolver.3 ns_get16.3 resolver.3 ns_get32.3 \ - resolver.3 ns_put16.3 resolver.3 ns_put32.3 -MLINKS+=sourcefilter.3 setipv4sourcefilter.3 sourcefilter.3 getipv4sourcefilter.3 \ - sourcefilter.3 setsourcefilter.3 sourcefilter.3 getsourcefilter.3 +MLINKS+=resolver.3 dn_comp.3 \ + resolver.3 dn_expand.3 \ + resolver.3 res_init.3 \ + resolver.3 res_mkquery.3 \ + resolver.3 res_query.3 \ + resolver.3 res_search.3 \ + resolver.3 res_send.3 \ + resolver.3 dn_skipname.3 \ + resolver.3 ns_get16.3 \ + resolver.3 ns_get32.3 \ + resolver.3 ns_put16.3 \ + resolver.3 ns_put32.3 +MLINKS+=sourcefilter.3 setipv4sourcefilter.3 \ + sourcefilter.3 getipv4sourcefilter.3 \ + sourcefilter.3 setsourcefilter.3 \ + sourcefilter.3 getsourcefilter.3 .if ${MK_HESIOD} != "no" -SRCS+= hesiod.c +SRCS+= hesiod.c +SYM_MAPS+=${LIBC_SRCTOP}/net/Symbol.hesiod.map MAN+= hesiod.3 +MLINKS+=hesiod.3 hesiod_init.3 \ + hesiod.3 hesiod_resolve.3 \ + hesiod.3 hesiod_free_list.3 \ + hesiod.3 hesiod_to_bind.3 \ + hesiod.3 hesiod_end.3 .endif -afterinstallconfig: modify-nsswitch-conf -modify-nsswitch-conf: .PHONY +all: ${.OBJDIR}/nsswitch.conf + +# Manually stage nsswitch.conf in the object directory so that we can edit it +# before installing. +${.OBJDIR}/nsswitch.conf: ${LIBC_SRCTOP}/net/nsswitch.conf + cp -f ${LIBC_SRCTOP}/net/nsswitch.conf ${.TARGET} .if ${MK_NIS} == "no" sed -i "" -e 's/.*_compat:/# &/' -e 's/compat$$/files/' \ - ${DESTDIR}/etc/nsswitch.conf + ${.TARGET} .endif diff --git a/lib/libc/net/Symbol.hesiod.map b/lib/libc/net/Symbol.hesiod.map new file mode 100644 index 000000000000..bb020c969ee9 --- /dev/null +++ b/lib/libc/net/Symbol.hesiod.map @@ -0,0 +1,12 @@ +FBSD_1.0 { + hesiod_init; + hesiod_end; + hesiod_to_bind; + hesiod_resolve; + hesiod_free_list; + hes_init; + hes_to_bind; + hes_resolve; + hes_error; + hes_free; +}; diff --git a/lib/libc/net/Symbol.map b/lib/libc/net/Symbol.map index 01d3bcb888d0..25e79b4e5807 100644 --- a/lib/libc/net/Symbol.map +++ b/lib/libc/net/Symbol.map @@ -1,7 +1,3 @@ -/* - * $FreeBSD$ - */ - FBSD_1.0 { __b64_ntop; __b64_pton; @@ -58,16 +54,10 @@ FBSD_1.0 { endservent; getservent; getservent_r; - hesiod_init; - hesiod_end; - hesiod_to_bind; - hesiod_resolve; - hesiod_free_list; - hes_init; - hes_to_bind; - hes_resolve; - hes_error; - hes_free; + htonl; + htons; + ntohl; + ntohs; if_indextoname; if_nameindex; if_freenameindex; @@ -92,7 +82,6 @@ FBSD_1.0 { freehostent; __nsdefaultsrc; _nsdbtaddsrc; - _nsdbtdump; _nsdbtput; nsdispatch; rcmd; @@ -149,6 +138,10 @@ FBSD_1.3 { sctp_sendv; }; +FBSD_1.8 { + link_ntoa_r; +}; + FBSDprivate_1.0 { _nsdispatch; _nsyyerror; /* generated from nslexer.l */ diff --git a/lib/libc/net/base64.c b/lib/libc/net/base64.c index 998c3c213834..f508275e4eb9 100644 --- a/lib/libc/net/base64.c +++ b/lib/libc/net/base64.c @@ -40,9 +40,6 @@ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/socket.h> @@ -110,9 +107,9 @@ static const char Pad64 = '='; end of the data is performed using the '=' character. Since all base64 input is an integral number of octets, only the - ------------------------------------------------- + ------------------------------------------------- following cases can arise: - + (1) the final quantum of encoding input is an integral multiple of 24 bits; here, the final unit of encoded output will be an integral multiple of 4 characters @@ -154,14 +151,14 @@ b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize) { target[datalength++] = Base64[output[2]]; target[datalength++] = Base64[output[3]]; } - + /* Now we worry about padding. */ if (0 != srclength) { /* Get what's left. */ input[0] = input[1] = input[2] = '\0'; for (i = 0; i < srclength; i++) input[i] = *src++; - + output[0] = input[0] >> 2; output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); diff --git a/lib/libc/net/byteorder.3 b/lib/libc/net/byteorder.3 index fa6daf5e8a68..9c28e7b80882 100644 --- a/lib/libc/net/byteorder.3 +++ b/lib/libc/net/byteorder.3 @@ -25,9 +25,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)byteorder.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" .Dd March 20, 2005 .Dt BYTEORDER 3 .Os diff --git a/lib/libc/net/ether_addr.c b/lib/libc/net/ether_addr.c index 98e5398096ff..efcd84a53437 100644 --- a/lib/libc/net/ether_addr.c +++ b/lib/libc/net/ether_addr.c @@ -39,9 +39,6 @@ * Columbia University, New York City */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/socket.h> diff --git a/lib/libc/net/ethers.3 b/lib/libc/net/ethers.3 index 6fe568b8765f..d68f98016b97 100644 --- a/lib/libc/net/ethers.3 +++ b/lib/libc/net/ethers.3 @@ -29,8 +29,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd October 30, 2007 .Dt ETHERS 3 .Os diff --git a/lib/libc/net/eui64.3 b/lib/libc/net/eui64.3 index fc563d157a14..f04766692363 100644 --- a/lib/libc/net/eui64.3 +++ b/lib/libc/net/eui64.3 @@ -54,8 +54,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd March 4, 2004 .Dt EUI64 3 .Os diff --git a/lib/libc/net/eui64.c b/lib/libc/net/eui64.c index 2c2c4ea57b21..274c00186153 100644 --- a/lib/libc/net/eui64.c +++ b/lib/libc/net/eui64.c @@ -67,9 +67,6 @@ * Columbia University, New York City */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stdio.h> #include <paths.h> #include <sys/param.h> diff --git a/lib/libc/net/gai_strerror.3 b/lib/libc/net/gai_strerror.3 index d948083447db..b9d35e1f37e6 100644 --- a/lib/libc/net/gai_strerror.3 +++ b/lib/libc/net/gai_strerror.3 @@ -16,9 +16,7 @@ .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR .\" PERFORMANCE OF THIS SOFTWARE. .\" -.\" $FreeBSD$ -.\" -.Dd December 23, 2018 +.Dd November 2, 2022 .Dt GAI_STRERROR 3 .Os .Sh NAME @@ -42,7 +40,9 @@ or The following error codes and their meaning are defined in .In netdb.h : .Pp -.Bl -tag -width ".Dv EAI_BADFLAGS" -offset indent -compact +.Bl -tag -width ".Dv EAI_ADDRFAMILY" -offset indent -compact +.It Dv EAI_ADDRFAMILY +Address family for hostname not supported .It Dv EAI_AGAIN Name could not be resolved at this time .It Dv EAI_BADFLAGS @@ -56,6 +56,8 @@ Non-recoverable failure in name resolution Address family was not recognized .It Dv EAI_MEMORY Memory allocation failure +.It Dv EAI_NODATA +No address associated with hostname .It Dv EAI_NONAME Name does not resolve .It Dv EAI_OVERFLOW @@ -83,7 +85,14 @@ is out of range, an implementation-specific error message string is returned. .Xr getaddrinfo 3 , .Xr getnameinfo 3 .Sh STANDARDS -.Bl -tag -width ".It RFC 2743" +.Bl -tag -width ".It RFC 3493" .It RFC 3493 Basic Socket Interface Extensions for IPv6 .El +.Pp +EAI_ADDRFAMILY and EAI_NODATA were in previous RFCs, but not in RFC 3493. +They are not in POSIX (IEEE Std 1003.1-2017). +They were in +.Fx +before 5.2, and were re-added for 14.0. +EAI_BADHINTS, EAI_OVERFLOW, and EAI_PROTOCOL are not in RFC 3493 or POSIX. diff --git a/lib/libc/net/gai_strerror.c b/lib/libc/net/gai_strerror.c index f168c3093735..0d4303e76a73 100644 --- a/lib/libc/net/gai_strerror.c +++ b/lib/libc/net/gai_strerror.c @@ -29,9 +29,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <netdb.h> #if defined(NLS) @@ -44,17 +41,19 @@ __FBSDID("$FreeBSD$"); #endif #include "un-namespace.h" -/* Entries EAI_ADDRFAMILY (1) and EAI_NODATA (7) are obsoleted, but left */ -/* for backwards compatibility with userland code prior to RFC2553bis-02 */ +/* + * Entries EAI_ADDRFAMILY (1) and EAI_NODATA (7) were omitted from RFC 3493, + * but are or may be used as extensions or in old code. + */ static const char *ai_errlist[] = { "Success", /* 0 */ - "Address family for hostname not supported", /* 1: Obsolete */ + "Address family for hostname not supported", /* EAI_ADDRFAMILY */ "Name could not be resolved at this time", /* EAI_AGAIN */ "Flags parameter had an invalid value", /* EAI_BADFLAGS */ "Non-recoverable failure in name resolution", /* EAI_FAIL */ "Address family not recognized", /* EAI_FAMILY */ "Memory allocation failure", /* EAI_MEMORY */ - "No address associated with hostname", /* 7: Obsolete*/ + "No address associated with hostname", /* EAI_NODATA*/ "Name does not resolve", /* EAI_NONAME */ "Service was not recognized for socket type", /* EAI_SERVICE */ "Intended socket type was not recognized", /* EAI_SOCKTYPE */ diff --git a/lib/libc/net/getaddrinfo.3 b/lib/libc/net/getaddrinfo.3 index a91a26973ecb..634786a8bd12 100644 --- a/lib/libc/net/getaddrinfo.3 +++ b/lib/libc/net/getaddrinfo.3 @@ -16,8 +16,6 @@ .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR .\" PERFORMANCE OF THIS SOFTWARE. .\" -.\" $FreeBSD$ -.\" .Dd June 27, 2022 .Dt GETADDRINFO 3 .Os @@ -353,7 +351,7 @@ structure created by a call to .Fn getaddrinfo . .Sh IMPLEMENTATION NOTES The behavior of -.Li freeadrinfo(NULL) +.Li freeaddrinfo(NULL) is left unspecified by both .St -susv4 and @@ -482,7 +480,8 @@ freeaddrinfo(res0); .Xr hosts 5 , .Xr resolv.conf 5 , .Xr services 5 , -.Xr hostname 7 +.Xr hostname 7 , +.Xr ip6addrctl 8 .Rs .%A R. Gilligan .%A S. Thomson diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index a33f240bc376..b8af23ebe8da 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -53,9 +53,6 @@ * - FreeBSD supported $GAI. The code does not. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <sys/param.h> #include <sys/socket.h> @@ -1953,6 +1950,9 @@ explore_fqdn(const struct addrinfo *pai, const char *hostname, case NS_NOTFOUND: error = EAI_NONAME; goto free; + case NS_ADDRFAMILY: + error = EAI_ADDRFAMILY; + goto free; case NS_SUCCESS: error = 0; for (cur = result; cur; cur = cur->ai_next) { @@ -2091,7 +2091,7 @@ getanswer(const querybuf *answer, int anslen, const char *qname, int qtype, } else if (type != qtype) { #ifdef DEBUG if (type != T_KEY && type != T_SIG && - type != ns_t_dname) + type != T_DNAME && type != T_RRSIG) syslog(LOG_NOTICE|LOG_AUTH, "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"", qname, p_class(C_IN), p_type(qtype), @@ -2341,7 +2341,14 @@ _dns_getaddrinfo(void *rv, void *cb_data, va_list ap) if (res_searchN(hostname, &q, res) < 0) { free(buf); free(buf2); - return NS_NOTFOUND; + switch (res->res_h_errno) { + case NO_DATA: + return (NS_ADDRFAMILY); + case TRY_AGAIN: + return (NS_TRYAGAIN); + default: + return (NS_NOTFOUND); + } } /* prefer IPv6 */ if (q.next) { @@ -2363,15 +2370,16 @@ _dns_getaddrinfo(void *rv, void *cb_data, va_list ap) if (sentinel.ai_next == NULL) switch (res->res_h_errno) { case HOST_NOT_FOUND: + return (NS_NOTFOUND); case NO_DATA: - return NS_NOTFOUND; + return (NS_ADDRFAMILY); case TRY_AGAIN: - return NS_TRYAGAIN; + return (NS_TRYAGAIN); default: - return NS_UNAVAIL; + return (NS_UNAVAIL); } *((struct addrinfo **)rv) = sentinel.ai_next; - return NS_SUCCESS; + return (NS_SUCCESS); } static void @@ -2702,9 +2710,18 @@ res_queryN(const char *name, struct res_target *target, res_state res) int n; u_int oflags; struct res_target *t; - int rcode; + u_int rcode; int ancount; + /* + * Extend rcode values in the scope of this function. The DNS header + * rcode we use in this function (hp->rcode) is limited by 4 bits, so + * anything starting from 16 is safe wrt aliasing. However, nameser.h + * already has extended enum __ns_rcode, so for future safety let's use + * even larger values. + */ +#define RCODE_UNREACH 32 +#define RCODE_TIMEDOUT 33 rcode = NOERROR; ancount = 0; @@ -2765,7 +2782,29 @@ again: printf(";; res_nquery: retry without EDNS0\n"); goto again; } - rcode = hp->rcode; /* record most recent error */ + /* + * Historically if a DNS server replied with ICMP port + * unreach res_nsend() would signal that with + * ECONNREFUSED and the upper layers would convert that + * into TRY_AGAIN. See 3a0b3b673936b and deeper. + * Also, res_nsend() may set errno to ECONNREFUSED due + * to internal failures. This may not be intentional, + * but we also treat that as soft failures. + * + * A more practical case is when a DNS server(s) were + * queried and didn't respond anything, which usually + * indicates a soft network failure. + */ + switch (errno) { + case ECONNREFUSED: + rcode = RCODE_UNREACH; + break; + case ETIMEDOUT: + rcode = RCODE_TIMEDOUT; + break; + default: + rcode = hp->rcode; + } #ifdef DEBUG if (res->options & RES_DEBUG) printf(";; res_query: send error\n"); @@ -2797,6 +2836,8 @@ again: case NXDOMAIN: RES_SET_H_ERRNO(res, HOST_NOT_FOUND); break; + case RCODE_UNREACH: + case RCODE_TIMEDOUT: case SERVFAIL: RES_SET_H_ERRNO(res, TRY_AGAIN); break; @@ -2859,10 +2900,6 @@ res_searchN(const char *name, struct res_target *target, res_state res) ret = res_querydomainN(name, NULL, target, res); if (ret > 0 || trailing_dot) return (ret); - if (errno == ECONNREFUSED) { - RES_SET_H_ERRNO(res, TRY_AGAIN); - return (-1); - } switch (res->res_h_errno) { case NO_DATA: case HOST_NOT_FOUND: @@ -2903,7 +2940,6 @@ res_searchN(const char *name, struct res_target *target, res_state res) ret = res_querydomainN(name, *domain, target, res); if (ret > 0) return (ret); - /* * If no server present, give up. * If name isn't found in this domain, @@ -2917,11 +2953,6 @@ res_searchN(const char *name, struct res_target *target, res_state res) * but try the input name below in case it's * fully-qualified. */ - if (errno == ECONNREFUSED) { - RES_SET_H_ERRNO(res, TRY_AGAIN); - return (-1); - } - switch (res->res_h_errno) { case NO_DATA: got_nodata++; @@ -2930,8 +2961,8 @@ res_searchN(const char *name, struct res_target *target, res_state res) /* keep trying */ break; case TRY_AGAIN: - got_servfail++; if (hp->rcode == SERVFAIL) { + got_servfail++; /* try next search element, if any */ break; } diff --git a/lib/libc/net/gethostbydns.c b/lib/libc/net/gethostbydns.c index 09800b874f90..216fc9bcf9a4 100644 --- a/lib/libc/net/gethostbydns.c +++ b/lib/libc/net/gethostbydns.c @@ -51,13 +51,6 @@ * --Copyright-- */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93"; -static char fromrcsid[] = "From: Id: gethnamaddr.c,v 8.23 1998/04/07 04:59:46 vixie Exp $"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/socket.h> #include <netinet/in.h> @@ -81,8 +74,10 @@ __FBSDID("$FreeBSD$"); #define SPRINTF(x) ((size_t)sprintf x) +#ifdef DEBUG static const char AskedForGot[] = "gethostby*.gethostanswer: asked for \"%s\", got \"%s\""; +#endif #ifdef RESOLVSORT static void addrsort(char **, int, res_state); @@ -292,19 +287,24 @@ gethostanswer(const querybuf *answer, int anslen, const char *qname, int qtype, continue; } if (type != qtype) { - if (type != T_SIG && type != ns_t_dname) +#ifdef DEBUG + if (type != T_KEY && type != T_SIG && + type != T_DNAME && type != T_RRSIG) syslog(LOG_NOTICE|LOG_AUTH, "gethostby*.gethostanswer: asked for \"%s %s %s\", got type \"%s\"", qname, p_class(C_IN), p_type(qtype), p_type(type)); +#endif cp += n; continue; /* XXX - had_error++ ? */ } switch (type) { case T_PTR: if (strcasecmp(tname, bp) != 0) { +#ifdef DEBUG syslog(LOG_NOTICE|LOG_AUTH, AskedForGot, qname, bp); +#endif cp += n; continue; /* XXX - had_error++ ? */ } @@ -351,8 +351,10 @@ gethostanswer(const querybuf *answer, int anslen, const char *qname, int qtype, case T_A: case T_AAAA: if (strcasecmp(he->h_name, bp) != 0) { +#ifdef DEBUG syslog(LOG_NOTICE|LOG_AUTH, AskedForGot, he->h_name, bp); +#endif cp += n; continue; /* XXX - had_error++ ? */ } diff --git a/lib/libc/net/gethostbyht.c b/lib/libc/net/gethostbyht.c index 3251f407f439..ac8585439ccf 100644 --- a/lib/libc/net/gethostbyht.c +++ b/lib/libc/net/gethostbyht.c @@ -49,12 +49,6 @@ * --Copyright-- */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/socket.h> #include <netinet/in.h> diff --git a/lib/libc/net/gethostbyname.3 b/lib/libc/net/gethostbyname.3 index 85b6806092e5..1d817679c028 100644 --- a/lib/libc/net/gethostbyname.3 +++ b/lib/libc/net/gethostbyname.3 @@ -25,9 +25,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 -.\" $FreeBSD$ -.\" .Dd June 27, 2022 .Dt GETHOSTBYNAME 3 .Os @@ -348,6 +345,10 @@ The function first appeared in .Tn BIND version 4.9.4. +The +.Fn gethostbyname_r +function first appeared in +.Fx 6.2 . .Sh CAVEATS The .Fn gethostent diff --git a/lib/libc/net/gethostbynis.c b/lib/libc/net/gethostbynis.c index edc0a092ae10..2d6abb49b44f 100644 --- a/lib/libc/net/gethostbynis.c +++ b/lib/libc/net/gethostbynis.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1994, Garrett Wollman * @@ -25,9 +25,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/socket.h> #include <netinet/in.h> diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c index 2da8024c47f4..b54ca8b2998e 100644 --- a/lib/libc/net/gethostnamadr.c +++ b/lib/libc/net/gethostnamadr.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1994, Garrett Wollman * @@ -25,9 +25,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include "reentrant.h" #include <sys/param.h> diff --git a/lib/libc/net/getifaddrs.3 b/lib/libc/net/getifaddrs.3 index b0b17bb388da..7bec595b1f8a 100644 --- a/lib/libc/net/getifaddrs.3 +++ b/lib/libc/net/getifaddrs.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd November 25, 2014 .Dt GETIFADDRS 3 .Os diff --git a/lib/libc/net/getifaddrs.c b/lib/libc/net/getifaddrs.c index 2de869ca6f9e..35d31d46af78 100644 --- a/lib/libc/net/getifaddrs.c +++ b/lib/libc/net/getifaddrs.c @@ -31,9 +31,6 @@ * try-and-error for region size. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <sys/types.h> #include <sys/ioctl.h> diff --git a/lib/libc/net/getifmaddrs.3 b/lib/libc/net/getifmaddrs.3 index 14c40875439c..0e18c148314d 100644 --- a/lib/libc/net/getifmaddrs.3 +++ b/lib/libc/net/getifmaddrs.3 @@ -18,8 +18,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd May 21, 2013 .Dt GETIFMADDRS 3 .Os diff --git a/lib/libc/net/getifmaddrs.c b/lib/libc/net/getifmaddrs.c index 92a032f9f2ee..415c25f11968 100644 --- a/lib/libc/net/getifmaddrs.c +++ b/lib/libc/net/getifmaddrs.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2003 Bruce M. Simpson. * All rights reserved @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <sys/param.h> #include <sys/sysctl.h> diff --git a/lib/libc/net/getipnodebyname.3 b/lib/libc/net/getipnodebyname.3 index d57f529a0707..2e5b05edec9c 100644 --- a/lib/libc/net/getipnodebyname.3 +++ b/lib/libc/net/getipnodebyname.3 @@ -27,9 +27,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 -.\" $FreeBSD$ -.\" .Dd June 27, 2022 .Dt GETIPNODEBYNAME 3 .Os diff --git a/lib/libc/net/getnameinfo.3 b/lib/libc/net/getnameinfo.3 index 021505542cfa..7c6ef419d8ea 100644 --- a/lib/libc/net/getnameinfo.3 +++ b/lib/libc/net/getnameinfo.3 @@ -16,8 +16,6 @@ .\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR .\" PERFORMANCE OF THIS SOFTWARE. .\" -.\" $FreeBSD$ -.\" .Dd June 27, 2022 .Dt GETNAMEINFO 3 .Os diff --git a/lib/libc/net/getnameinfo.c b/lib/libc/net/getnameinfo.c index b72734e56ed3..01bceaa98fce 100644 --- a/lib/libc/net/getnameinfo.c +++ b/lib/libc/net/getnameinfo.c @@ -46,9 +46,6 @@ * beware on merge. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> @@ -232,24 +229,44 @@ getnameinfo_inet(const struct afd *afd, case AF_INET6: { const struct sockaddr_in6 *sin6; + sin6 = (const struct sockaddr_in6 *)sa; - switch (sin6->sin6_addr.s6_addr[0]) { - case 0x00: - if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) - ; - else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr)) - ; - else - flags |= NI_NUMERICHOST; - break; - default: - if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { - flags |= NI_NUMERICHOST; - } - else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) - flags |= NI_NUMERICHOST; - break; - } + + /* + * https://pubs.opengroup.org/onlinepubs/9699919799/functions/getnameinfo.html + * "[IP6] [Option Start] If the socket address structure + * contains an IPv4-mapped IPv6 address or an IPv4-compatible + * IPv6 address, the implementation shall extract the embedded + * IPv4 address and lookup the node name for that IPv4 address. + * [Option End]" + * => getipnodebyaddr() handles this case for us. + * => in case of NI_NUMERICHOST being set, inet_ntop[6] will + * handle it too. + * + * "If the address is the IPv6 unspecified address ( "::" ), + * a lookup shall not be performed and the behavior shall be + * the same as when the node's name cannot be located." + * => getipnodebyaddr() handles this case for us. + * => in case of NI_NUMERICHOST being set, + * ip6_parsenumeric() -> inet_ntop[6] will handle it too. + */ + + /* + * We used to exclude link-local from lookups. + * Even though calles in the resolver chain may not (yet) + * properly deal with them, we no longer do as for link-local + * there is a path to resolve these. See: + * RFC 6303 4.5. IPv6 Link-Local Addresses + * RFC 6762 4. Reverse Address Mapping + * + * XXX For IPv6 MC the only reference found was + * https://www.ietf.org/archive/id/draft-michaelson-as112-ipv6-02.html + * but there are also no "empty zone"s for x.0.f.f.ip6.arpa + * in DNS servers. Keep catching it here for now and + * do not attempt name resolution but return the address string. + */ + if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) + flags |= NI_NUMERICHOST; } break; #endif diff --git a/lib/libc/net/getnetbydns.c b/lib/libc/net/getnetbydns.c index ac35ae4a96c4..deca8c58fca5 100644 --- a/lib/libc/net/getnetbydns.c +++ b/lib/libc/net/getnetbydns.c @@ -56,12 +56,6 @@ * copyright notice and this permission notice appear in all copies. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/socket.h> #include <netinet/in.h> diff --git a/lib/libc/net/getnetbyht.c b/lib/libc/net/getnetbyht.c index 9db1a37ebd36..00bfd61552af 100644 --- a/lib/libc/net/getnetbyht.c +++ b/lib/libc/net/getnetbyht.c @@ -39,13 +39,6 @@ * from getnetent.c 1.1 (Coimbra) 93/06/02 */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getnetent.c 8.1 (Berkeley) 6/4/93"; -static char orig_rcsid[] = "From: Id: getnetent.c,v 8.4 1997/06/01 20:34:37 vixie Exp"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> diff --git a/lib/libc/net/getnetbynis.c b/lib/libc/net/getnetbynis.c index 48407eb12b29..a56404a14fe7 100644 --- a/lib/libc/net/getnetbynis.c +++ b/lib/libc/net/getnetbynis.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1994, Garrett Wollman * @@ -25,9 +25,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/socket.h> #include <netinet/in.h> diff --git a/lib/libc/net/getnetent.3 b/lib/libc/net/getnetent.3 index 4d90c84e8fc1..bd588bd7551a 100644 --- a/lib/libc/net/getnetent.3 +++ b/lib/libc/net/getnetent.3 @@ -25,9 +25,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)getnetent.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" .Dd June 27, 2022 .Dt GETNETENT 3 .Os diff --git a/lib/libc/net/getnetnamadr.c b/lib/libc/net/getnetnamadr.c index 82ff089c1f1b..660de3302606 100644 --- a/lib/libc/net/getnetnamadr.c +++ b/lib/libc/net/getnetnamadr.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1994, Garrett Wollman * @@ -25,9 +25,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include "reentrant.h" #include <sys/param.h> diff --git a/lib/libc/net/getproto.c b/lib/libc/net/getproto.c index ec7ee39447a5..62ecb04972c4 100644 --- a/lib/libc/net/getproto.c +++ b/lib/libc/net/getproto.c @@ -29,12 +29,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getproto.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <netdb.h> #include <nsswitch.h> diff --git a/lib/libc/net/getprotoent.3 b/lib/libc/net/getprotoent.3 index e416824f8479..eeea57ac9859 100644 --- a/lib/libc/net/getprotoent.3 +++ b/lib/libc/net/getprotoent.3 @@ -25,9 +25,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)getprotoent.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" .Dd June 4, 1993 .Dt GETPROTOENT 3 .Os diff --git a/lib/libc/net/getprotoent.c b/lib/libc/net/getprotoent.c index b3bb52195dfc..9fcbf41530cf 100644 --- a/lib/libc/net/getprotoent.c +++ b/lib/libc/net/getprotoent.c @@ -29,12 +29,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getprotoent.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/socket.h> #include <errno.h> diff --git a/lib/libc/net/getprotoname.c b/lib/libc/net/getprotoname.c index 22c2938dd53e..f3654a8955ec 100644 --- a/lib/libc/net/getprotoname.c +++ b/lib/libc/net/getprotoname.c @@ -29,12 +29,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getprotoname.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <netdb.h> #include <nsswitch.h> diff --git a/lib/libc/net/getservent.3 b/lib/libc/net/getservent.3 index 9223369fe19e..996d1606eb79 100644 --- a/lib/libc/net/getservent.3 +++ b/lib/libc/net/getservent.3 @@ -25,10 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" From: @(#)getservent.3 8.3 (Berkeley) 1/12/94 -.\" $FreeBSD$ -.\" -.Dd July 9, 1995 +.Dd December 7, 2020 .Dt GETSERVENT 3 .Os .Sh NAME @@ -128,6 +125,7 @@ searches must also match the protocol. .Sh FILES .Bl -tag -width /etc/services -compact .It Pa /etc/services +.It Pa /var/db/services.db .El .Sh DIAGNOSTICS Null pointer returned on @@ -135,7 +133,8 @@ Null pointer returned on or error. .Sh SEE ALSO .Xr getprotoent 3 , -.Xr services 5 +.Xr services 5 , +.Xr services_mkdb 8 .Sh HISTORY The .Fn getservent , diff --git a/lib/libc/net/getservent.c b/lib/libc/net/getservent.c index bcb9f8ff8b84..26f68f24cc78 100644 --- a/lib/libc/net/getservent.c +++ b/lib/libc/net/getservent.c @@ -29,12 +29,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getservent.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/socket.h> #include <arpa/inet.h> @@ -943,7 +937,7 @@ fin: return (res); } -int +static int serv_marshal_func(char *buffer, size_t *buffer_size, void *retval, va_list ap, void *cache_mdata) { @@ -1044,7 +1038,7 @@ serv_marshal_func(char *buffer, size_t *buffer_size, void *retval, va_list ap, return (NS_SUCCESS); } -int +static int serv_unmarshal_func(char *buffer, size_t buffer_size, void *retval, va_list ap, void *cache_mdata) { diff --git a/lib/libc/net/hesiod.3 b/lib/libc/net/hesiod.3 index af62468557d2..c6e75ff42db7 100644 --- a/lib/libc/net/hesiod.3 +++ b/lib/libc/net/hesiod.3 @@ -16,8 +16,6 @@ .\" this software for any purpose. It is provided "as is" .\" without express or implied warranty. .\" -.\" $FreeBSD$ -.\" .Dd June 27, 2022 .Dt HESIOD 3 .Os diff --git a/lib/libc/net/hesiod.c b/lib/libc/net/hesiod.c index 0966b6d7ef91..18d5c7348c78 100644 --- a/lib/libc/net/hesiod.c +++ b/lib/libc/net/hesiod.c @@ -43,13 +43,6 @@ * it uses res_send() and accesses _res. */ -#include <sys/cdefs.h> - -#if 0 -static char *orig_rcsid = "$NetBSD: hesiod.c,v 1.9 1999/02/11 06:16:38 simonb Exp $"; -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); #include <sys/param.h> #include <netinet/in.h> @@ -83,8 +76,7 @@ static void translate_errors(void); * initialize a hesiod_p. */ int -hesiod_init(context) - void **context; +hesiod_init(void **context) { struct hesiod_p *ctx; const char *p, *configname; @@ -92,10 +84,7 @@ hesiod_init(context) ctx = malloc(sizeof(struct hesiod_p)); if (ctx) { *context = ctx; - if (!issetugid()) - configname = getenv("HESIOD_CONFIG"); - else - configname = NULL; + configname = secure_getenv("HESIOD_CONFIG"); if (!configname) configname = _PATH_HESIOD_CONF; if (read_config_file(ctx, configname) >= 0) { @@ -103,10 +92,7 @@ hesiod_init(context) * The default rhs can be overridden by an * environment variable. */ - if (!issetugid()) - p = getenv("HES_DOMAIN"); - else - p = NULL; + p = secure_getenv("HES_DOMAIN"); if (p) { if (ctx->rhs) free(ctx->rhs); @@ -138,8 +124,7 @@ hesiod_init(context) * Deallocates the hesiod_p. */ void -hesiod_end(context) - void *context; +hesiod_end(void *context) { struct hesiod_p *ctx = (struct hesiod_p *) context; @@ -229,10 +214,7 @@ hesiod_to_bind(void *context, const char *name, const char *type) * by the resolver. */ char ** -hesiod_resolve(context, name, type) - void *context; - const char *name; - const char *type; +hesiod_resolve(void *context, const char *name, const char *type) { struct hesiod_p *ctx = (struct hesiod_p *) context; char *bindname, **retvec; @@ -251,9 +233,7 @@ hesiod_resolve(context, name, type) /*ARGSUSED*/ void -hesiod_free_list(context, list) - void *context; - char **list; +hesiod_free_list(void *context, char **list) { char **p; @@ -271,9 +251,7 @@ hesiod_free_list(context, list) * or ctx->rhs which need to be freed by the caller. */ static int -read_config_file(ctx, filename) - struct hesiod_p *ctx; - const char *filename; +read_config_file(struct hesiod_p *ctx, const char *filename) { char *key, *data, *p, **which; char buf[MAXDNAME + 7]; @@ -365,9 +343,7 @@ read_config_file(ctx, filename) * return a list of them. */ static char ** -get_txt_records(qclass, name) - int qclass; - const char *name; +get_txt_records(int qclass, const char *name) { HEADER *hp; unsigned char qbuf[PACKETSZ], abuf[MAX_HESRESP], *p, *eom, *eor; @@ -491,16 +467,14 @@ static void *context; static int errval = HES_ER_UNINIT; int -hes_init() +hes_init(void) { init_context(); return errval; } char * -hes_to_bind(name, type) - const char *name; - const char *type; +hes_to_bind(const char *name, const char *type) { static char *bindname; if (init_context() < 0) @@ -514,9 +488,7 @@ hes_to_bind(name, type) } char ** -hes_resolve(name, type) - const char *name; - const char *type; +hes_resolve(const char *name, const char *type) { static char **list; @@ -537,20 +509,19 @@ hes_resolve(name, type) } int -hes_error() +hes_error(void) { return errval; } void -hes_free(hp) - char **hp; +hes_free(char **hp) { hesiod_free_list(context, hp); } static int -init_context() +init_context(void) { if (!inited) { inited = 1; @@ -564,7 +535,7 @@ init_context() } static void -translate_errors() +translate_errors(void) { switch (errno) { case ENOENT: diff --git a/lib/libc/net/hosts b/lib/libc/net/hosts index 1722a0c958d8..f6933fcaaf33 100644 --- a/lib/libc/net/hosts +++ b/lib/libc/net/hosts @@ -1,4 +1,3 @@ -# $FreeBSD$ # # Host Database # diff --git a/lib/libc/net/hosts.equiv b/lib/libc/net/hosts.equiv index d8a71c1ebc7f..77e9ccd4b12c 100644 --- a/lib/libc/net/hosts.equiv +++ b/lib/libc/net/hosts.equiv @@ -1,4 +1,3 @@ -# $FreeBSD$ # #localhost #my_very_good_friend.domain diff --git a/lib/libc/net/if_indextoname.3 b/lib/libc/net/if_indextoname.3 index 715c33cfedcd..29bf565e3429 100644 --- a/lib/libc/net/if_indextoname.3 +++ b/lib/libc/net/if_indextoname.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd November 23, 2005 .Dt IF_NAMETOINDEX 3 .Os diff --git a/lib/libc/net/if_indextoname.c b/lib/libc/net/if_indextoname.c index e7ccb422dc6a..99620c9cac0d 100644 --- a/lib/libc/net/if_indextoname.c +++ b/lib/libc/net/if_indextoname.c @@ -27,9 +27,6 @@ * BSDI Id: if_indextoname.c,v 2.3 2000/04/17 22:38:05 dab Exp */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/socket.h> #include <net/if_dl.h> diff --git a/lib/libc/net/if_nameindex.c b/lib/libc/net/if_nameindex.c index 4b6b15ecefb1..a7c2c92bd8d1 100644 --- a/lib/libc/net/if_nameindex.c +++ b/lib/libc/net/if_nameindex.c @@ -27,9 +27,6 @@ * BSDI Id: if_nameindex.c,v 2.3 2000/04/17 22:38:05 dab Exp */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/socket.h> #include <net/if_dl.h> diff --git a/lib/libc/net/if_nametoindex.c b/lib/libc/net/if_nametoindex.c index c38fce76b037..febf33b86667 100644 --- a/lib/libc/net/if_nametoindex.c +++ b/lib/libc/net/if_nametoindex.c @@ -27,9 +27,6 @@ * BSDI Id: if_nametoindex.c,v 2.3 2000/04/17 22:38:05 dab Exp */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <sys/types.h> #include <sys/socket.h> diff --git a/lib/libc/net/inet.3 b/lib/libc/net/inet.3 index cb44394d0a0c..9b822fd6805a 100644 --- a/lib/libc/net/inet.3 +++ b/lib/libc/net/inet.3 @@ -25,9 +25,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" From: @(#)inet.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" .Dd November 9, 2021 .Dt INET 3 .Os @@ -176,10 +173,15 @@ All Internet addresses are returned in network order (bytes ordered from left to right). All network numbers and local address parts are returned as machine byte order integer values. -.Sh INTERNET ADDRESSES -Values specified using the +.Sh INTERNET ADDRESSES (IP VERSION 4) +The +.Fn inet_aton +and +.Fn inet_addr +functions accept IPv4 +values specified using the .Ql .\& -notation take one +notation in one of the following forms: .Bd -literal -offset indent a.b.c.d @@ -191,17 +193,6 @@ a When four parts are specified, each is interpreted as a byte of data and assigned, from left to right, to the four bytes of an Internet address. -Note -that when an Internet address is viewed as a 32-bit -integer quantity on the -.Tn VAX -the bytes referred to -above appear as -.Dq Li d.c.b.a . -That is, -.Tn VAX -bytes are -ordered from right to left. .Pp When a three part address is specified, the last part is interpreted as a 16-bit quantity and placed @@ -224,6 +215,13 @@ 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). +.Pp +Note that +.Fn inet_pton +does not accept 1-, 2-, or 3-part dotted addresses; all four parts +must be specified and are interpreted only as decimal values. +This is a narrower input set than that accepted by +.Fn inet_aton . .Sh DIAGNOSTICS The constant .Dv INADDR_NONE @@ -270,12 +268,6 @@ and .Fn inet_pton functions conform to .St -xns5.2 . -Note that -.Fn inet_pton -does not accept 1-, 2-, or 3-part dotted addresses; all four parts -must be specified and are interpreted only as decimal values. -This is a narrower input set than that accepted by -.Fn inet_aton . .Sh HISTORY These functions appeared in diff --git a/lib/libc/net/inet6_opt_init.3 b/lib/libc/net/inet6_opt_init.3 index 484767f781fa..bccc08fa4700 100644 --- a/lib/libc/net/inet6_opt_init.3 +++ b/lib/libc/net/inet6_opt_init.3 @@ -27,9 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd August 1, 2021 +.Dd February 25, 2023 .Dt INET6_OPT_INIT 3 .Os .\" @@ -43,20 +41,22 @@ .Nm inet6_opt_get_val .Nd IPv6 Hop-by-Hop and Destination Options manipulation .\" +.Sh LIBRARY +.Lb libc .Sh SYNOPSIS .In netinet/in.h .Ft "int" .Fn inet6_opt_init "void *extbuf" "socklen_t extlen" .Ft "int" -.Fn inet6_opt_append "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t type" "socklen_t len" "u_int8_t align" "void **databufp" +.Fn inet6_opt_append "void *extbuf" "socklen_t extlen" "int offset" "uint8_t type" "socklen_t len" "uint8_t align" "void **databufp" .Ft "int" .Fn inet6_opt_finish "void *extbuf" "socklen_t extlen" "int offset" .Ft "int" .Fn inet6_opt_set_val "void *databuf" "int offset" "void *val" "socklen_t vallen" .Ft "int" -.Fn inet6_opt_next "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t *typep" "socklen_t *lenp" "void **databufp" +.Fn inet6_opt_next "void *extbuf" "socklen_t extlen" "int offset" "uint8_t *typep" "socklen_t *lenp" "void **databufp" .Ft "int" -.Fn inet6_opt_find "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t type" "socklen_t *lenp" "void **databufp" +.Fn inet6_opt_find "void *extbuf" "socklen_t extlen" "int offset" "uint8_t type" "socklen_t *lenp" "void **databufp" .Ft "int" .Fn inet6_opt_get_val "void *databuf" "int offset" "void *val" "socklen_t vallen" .\" @@ -67,9 +67,9 @@ The advanced sockets API defines a set of functions to help applications create and manipulate Hop-by-Hop and Destination options. This man page describes the functions specified in -IETF Draft RFC3542. +IETF Draft RFC 3542. These functions use the -formatting rules specified in Appendix B in RFC2460, i.e., that the +formatting rules specified in Appendix B in RFC 2460, i.e., that the largest field is placed last in the option. The function prototypes for these functions are all contained in the @@ -206,7 +206,7 @@ inserted into the extension header, and the argument indicates how much data to copy. .Pp The caller should ensure that each field is aligned on its natural -boundaries as described in Appendix B of RFC2460. +boundaries as described in Appendix B of RFC 2460. .Pp The function returns the offset for the next field which is calculated as .Fa offset @@ -281,7 +281,7 @@ or functions. The .Fa val -argument points where the data will be extracted. +argument points to where the data will be extracted. The .Fa offset argument specifies from where in the data portion of the option the @@ -289,7 +289,7 @@ value should be extracted; the first byte of option data is specified by an offset of zero. .Pp It is expected that each field is aligned on its natural boundaries as -described in Appendix B of RFC2460. +described in Appendix B of RFC 2460. .Pp The function returns the offset for the next field by calculating @@ -305,7 +305,7 @@ All the functions return on an error. .\" .Sh EXAMPLES -RFC3542 gives comprehensive examples in Section 22. +RFC 3542 gives comprehensive examples in Section 22. .Pp KAME also provides examples in the .Pa advapitest @@ -318,20 +318,20 @@ directory of its kit. .%A E. Nordmark .%A T. Jinmei .%T "Advanced Sockets API for IPv6" -.%N RFC3542 +.%N RFC 3542 .%D October 2002 .Re .Rs .%A S. Deering .%A R. Hinden .%T "Internet Protocol, Version 6 (IPv6) Specification" -.%N RFC2460 +.%N RFC 2460 .%D December 1998 .Re .Sh STANDARDS The functions are documented in .Dq Advanced Sockets API for IPv6 -.Pq RFC3542 . +.Pq RFC 3542 . .\" .Sh HISTORY The implementation first appeared in KAME advanced networking kit. diff --git a/lib/libc/net/inet6_option_space.3 b/lib/libc/net/inet6_option_space.3 index e17855a32ba7..87395fba347d 100644 --- a/lib/libc/net/inet6_option_space.3 +++ b/lib/libc/net/inet6_option_space.3 @@ -27,8 +27,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd January 24, 2005 .Dt INET6_OPTION_SPACE 3 .Os diff --git a/lib/libc/net/inet6_rth_space.3 b/lib/libc/net/inet6_rth_space.3 index a3db7942c6cd..7c42cdaf46a0 100644 --- a/lib/libc/net/inet6_rth_space.3 +++ b/lib/libc/net/inet6_rth_space.3 @@ -27,8 +27,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd December 24, 2004 .Dt INET6_RTH_SPACE 3 .Os diff --git a/lib/libc/net/inet6_rthdr_space.3 b/lib/libc/net/inet6_rthdr_space.3 index bfb2f231a874..d7856a686098 100644 --- a/lib/libc/net/inet6_rthdr_space.3 +++ b/lib/libc/net/inet6_rthdr_space.3 @@ -27,8 +27,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd January 24, 2005 .Dt INET6_RTHDR_SPACE 3 .Os diff --git a/lib/libc/net/inet_net.3 b/lib/libc/net/inet_net.3 index 4028984bd09b..3102f949ebca 100644 --- a/lib/libc/net/inet_net.3 +++ b/lib/libc/net/inet_net.3 @@ -30,8 +30,6 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd November 9, 2021 .Dt INET_NET 3 .Os diff --git a/lib/libc/net/ip6opt.c b/lib/libc/net/ip6opt.c index 5e2f9df8d008..4f53840299ea 100644 --- a/lib/libc/net/ip6opt.c +++ b/lib/libc/net/ip6opt.c @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/socket.h> diff --git a/lib/libc/net/linkaddr.3 b/lib/libc/net/linkaddr.3 index e17847cfca4c..38ee6a0aedea 100644 --- a/lib/libc/net/linkaddr.3 +++ b/lib/libc/net/linkaddr.3 @@ -28,15 +28,13 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" From: @(#)linkaddr.3 8.1 (Berkeley) 7/28/93 -.\" $FreeBSD$ -.\" -.Dd February 28, 2007 +.Dd May 9, 2025 .Dt LINK_ADDR 3 .Os .Sh NAME .Nm link_addr , -.Nm link_ntoa +.Nm link_ntoa , +.Nm link_ntoa_r .Nd elementary address specification routines for link level access .Sh LIBRARY .Lb libc @@ -44,16 +42,29 @@ .In sys/types.h .In sys/socket.h .In net/if_dl.h -.Ft void +.Ft int .Fn link_addr "const char *addr" "struct sockaddr_dl *sdl" .Ft char * .Fn link_ntoa "const struct sockaddr_dl *sdl" +.Ft int +.Fn link_ntoa_r "const struct sockaddr_dl *sdl" "char *obuf" "size_t *buflen" .Sh DESCRIPTION The routine .Fn link_addr -interprets character strings representing -link-level addresses, returning binary information suitable -for use in system calls. +parses a character string +.Fa addr +representing a link-level address, +and stores the resulting address in the structure pointed to by +.Fa sdl . +A link-level address consists of an optional interface name, followed by +a colon (which is required in all cases), followed by an address +consisting of either a string of hexadecimal digits, or a series of +hexadecimal octets separated by one of the characters +.Sq "." , +.Sq ":" , +or +.Sq - . +.Pp The routine .Fn link_ntoa takes @@ -63,9 +74,34 @@ address and returns an string representing some of the information present, including the link level address itself, and the interface name or number, if present. +The returned string is stored in a static buffer. This facility is experimental and is still subject to change. .Pp +The routine +.Fn link_ntoa_r +behaves like +.Fn link_ntoa , +except the string is placed in the provided buffer instead of a static +buffer. +The caller should initialize +.Fa buflen +to the number of bytes available in +.Fa obuf . +On return, +.Fa buflen +is set to the actual number of bytes required for the output buffer, +including the NUL terminator. +If +.Fa obuf +is NULL, then +.Fa buflen +is set as described, but nothing is written. +This may be used to determine the required length of the buffer before +calling +.Fn link_ntoa_r +a second time. +.Pp For .Fn link_addr , the string @@ -97,12 +133,21 @@ The .Fn link_ntoa function always returns a null terminated string. +.Pp +The +.Fn link_ntoa_r +function returns 0 on success, or -1 if the provided buffer was not +large enough; in the latter case, the contents of the buffer are +indeterminate, but a trailing NUL will always be written if the buffer +was at least one byte in size. +.Pp The .Fn link_addr -function -has no return value. -(See -.Sx BUGS . ) +function returns 0 on success. +If the address did not appear to be a valid link-level address, -1 is +returned and +.Va errno +is set to indicate the error. .Sh SEE ALSO .Xr getnameinfo 3 .Sh HISTORY @@ -112,15 +157,14 @@ and .Fn link_ntoa functions appeared in .Bx 4.3 Reno . +The +.Fn link_ntoa_r +function appeared in +.Fx 15.0 . .Sh BUGS The returned values for link_ntoa reside in a static memory area. .Pp -The function -.Fn link_addr -should diagnose improperly formed input, and there should be an unambiguous -way to recognize this. -.Pp If the .Va sdl_len field of the link socket address diff --git a/lib/libc/net/linkaddr.c b/lib/libc/net/linkaddr.c index f50197ec32a8..5be4c0a7a43e 100644 --- a/lib/libc/net/linkaddr.c +++ b/lib/libc/net/linkaddr.c @@ -29,143 +29,263 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)linkaddr.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/socket.h> + #include <net/if.h> #include <net/if_dl.h> + +#include <assert.h> +#include <errno.h> +#include <stdint.h> #include <string.h> -/* States*/ -#define NAMING 0 -#define GOTONE 1 -#define GOTTWO 2 -#define RESET 3 -/* Inputs */ -#define DIGIT (4*0) -#define END (4*1) -#define DELIM (4*2) -#define LETTER (4*3) - -void +int link_addr(const char *addr, struct sockaddr_dl *sdl) { char *cp = sdl->sdl_data; char *cplim = sdl->sdl_len + (char *)sdl; - int byte = 0, state = NAMING, new; + const char *nptr; + size_t newsize; + int error = 0; + char delim = 0; + /* Initialise the sdl to zero, except for sdl_len. */ bzero((char *)&sdl->sdl_family, sdl->sdl_len - 1); sdl->sdl_family = AF_LINK; - do { - state &= ~LETTER; - if ((*addr >= '0') && (*addr <= '9')) { - new = *addr - '0'; - } else if ((*addr >= 'a') && (*addr <= 'f')) { - new = *addr - 'a' + 10; - } else if ((*addr >= 'A') && (*addr <= 'F')) { - new = *addr - 'A' + 10; - } else if (*addr == 0) { - state |= END; - } else if (state == NAMING && - (((*addr >= 'A') && (*addr <= 'Z')) || - ((*addr >= 'a') && (*addr <= 'z')))) - state |= LETTER; - else - state |= DELIM; - addr++; - switch (state /* | INPUT */) { - case NAMING | DIGIT: - case NAMING | LETTER: - *cp++ = addr[-1]; - continue; - case NAMING | DELIM: - state = RESET; - sdl->sdl_nlen = cp - sdl->sdl_data; - continue; - case GOTTWO | DIGIT: - *cp++ = byte; - /* FALLTHROUGH */ - case RESET | DIGIT: - state = GOTONE; - byte = new; - continue; - case GOTONE | DIGIT: - state = GOTTWO; - byte = new + (byte << 4); - continue; - default: /* | DELIM */ - state = RESET; - *cp++ = byte; - byte = 0; - continue; - case GOTONE | END: - case GOTTWO | END: - *cp++ = byte; - /* FALLTHROUGH */ - case RESET | END: + + /* + * Everything up to the first ':' is the interface name. Usually the + * ':' should always be present even if there's no interface name, but + * since this interface was poorly specified in the past, accept a + * missing colon as meaning no interface name. + */ + if ((nptr = strchr(addr, ':')) != NULL) { + size_t namelen = nptr - addr; + + /* Ensure the sdl is large enough to store the name. */ + if (namelen > cplim - cp) { + errno = ENOSPC; + return (-1); + } + + memcpy(cp, addr, namelen); + cp += namelen; + sdl->sdl_nlen = namelen; + /* Skip the interface name and the colon. */ + addr += namelen + 1; + } + + /* + * The remainder of the string should be hex digits representing the + * address, with optional delimiters. Each two hex digits form one + * octet, but octet output can be forced using a delimiter, so we accept + * a long string of hex digits, or a mix of delimited and undelimited + * digits like "1122.3344.5566", or delimited one- or two-digit octets + * like "1.22.3". + * + * If anything fails at this point, exit the loop so we set sdl_alen and + * sdl_len based on whatever we did manage to parse. This preserves + * compatibility with the 4.3BSD version of link_addr, which had no way + * to indicate an error and would just return. + */ +#define DIGIT(c) \ + (((c) >= '0' && (c) <= '9') ? ((c) - '0') \ + : ((c) >= 'a' && (c) <= 'f') ? ((c) - 'a' + 10) \ + : ((c) >= 'A' && (c) <= 'F') ? ((c) - 'A' + 10) \ + : (-1)) +#define ISDELIM(c) (((c) == '.' || (c) == ':' || (c) == '-') && \ + (delim == 0 || delim == (c))) + + for (;;) { + int digit, digit2; + + /* + * Treat any leading delimiters as empty bytes. This supports + * the (somewhat obsolete) form of Ethernet addresses with empty + * octets, e.g. "1::3:4:5:6". + */ + while (ISDELIM(*addr) && cp < cplim) { + delim = *addr++; + *cp++ = 0; + } + + /* Did we reach the end of the string? */ + if (*addr == '\0') + break; + + /* + * If not, the next character must be a digit, so make sure we + * have room for at least one more octet. + */ + + if (cp >= cplim) { + error = ENOSPC; + break; + } + + if ((digit = DIGIT(*addr)) == -1) { + error = EINVAL; + break; + } + + ++addr; + + /* If the next character is another digit, consume it. */ + if ((digit2 = DIGIT(*addr)) != -1) { + digit = (digit << 4) | digit2; + ++addr; + } + + if (ISDELIM(*addr)) { + /* + * If the digit is followed by a delimiter, write it + * and consume the delimiter. + */ + delim = *addr++; + *cp++ = digit; + } else if (DIGIT(*addr) != -1) { + /* + * If two digits are followed by a third digit, treat + * the two digits we have as a single octet and + * continue. + */ + *cp++ = digit; + } else if (*addr == '\0') { + /* If the digit is followed by EOS, we're done. */ + *cp++ = digit; + break; + } else { + /* Otherwise, the input was invalid. */ + error = EINVAL; break; } - break; - } while (cp < cplim); + } +#undef DIGIT +#undef ISDELIM + + /* How many bytes did we write to the address? */ sdl->sdl_alen = cp - LLADDR(sdl); - new = cp - (char *)sdl; - if (new > sizeof(*sdl)) - sdl->sdl_len = new; - return; + + /* + * The user might have given us an sdl which is larger than sizeof(sdl); + * in that case, record the actual size of the new sdl. + */ + newsize = cp - (char *)sdl; + if (newsize > sizeof(*sdl)) + sdl->sdl_len = (u_char)newsize; + + if (error == 0) + return (0); + + errno = error; + return (-1); } -static const char hexlist[] = "0123456789abcdef"; char * link_ntoa(const struct sockaddr_dl *sdl) { static char obuf[64]; + size_t buflen; _Static_assert(sizeof(obuf) >= IFNAMSIZ + 20, "obuf is too small"); + + /* + * Ignoring the return value of link_ntoa_r() is safe here because it + * always writes the terminating NUL. This preserves the traditional + * behaviour of link_ntoa(). + */ + buflen = sizeof(obuf); + (void)link_ntoa_r(sdl, obuf, &buflen); + return obuf; +} + +int +link_ntoa_r(const struct sockaddr_dl *sdl, char *obuf, size_t *buflen) +{ + static const char hexlist[] = "0123456789abcdef"; char *out; const u_char *in, *inlim; int namelen, i, rem; + size_t needed; - namelen = (sdl->sdl_nlen <= IFNAMSIZ) ? sdl->sdl_nlen : IFNAMSIZ; + assert(sdl); + assert(buflen); + /* obuf may be null */ + needed = 1; /* 1 for the NUL */ out = obuf; - rem = sizeof(obuf); + if (obuf) + rem = *buflen; + else + rem = 0; + +/* + * Check if at least n bytes are available in the output buffer, plus 1 for the + * trailing NUL. If not, set rem = 0 so we stop writing. + * Either way, increment needed by the amount we would have written. + */ +#define CHECK(n) do { \ + if ((SIZE_MAX - (n)) >= needed) \ + needed += (n); \ + if (rem >= ((n) + 1)) \ + rem -= (n); \ + else \ + rem = 0; \ + } while (0) + +/* + * Write the char c to the output buffer, unless the buffer is full. + * Note that if obuf is NULL, rem is always zero. + */ +#define OUT(c) do { \ + if (rem > 0) \ + *out++ = (c); \ + } while (0) + + namelen = (sdl->sdl_nlen <= IFNAMSIZ) ? sdl->sdl_nlen : IFNAMSIZ; if (namelen > 0) { - bcopy(sdl->sdl_data, out, namelen); - out += namelen; - rem -= namelen; + CHECK(namelen); + if (rem > 0) { + bcopy(sdl->sdl_data, out, namelen); + out += namelen; + } + if (sdl->sdl_alen > 0) { - *out++ = ':'; - rem--; + CHECK(1); + OUT(':'); } } - in = (const u_char *)sdl->sdl_data + sdl->sdl_nlen; + in = (const u_char *)LLADDR(sdl); inlim = in + sdl->sdl_alen; - while (in < inlim && rem > 1) { - if (in != (const u_char *)sdl->sdl_data + sdl->sdl_nlen) { - *out++ = '.'; - rem--; + while (in < inlim) { + if (in != (const u_char *)LLADDR(sdl)) { + CHECK(1); + OUT('.'); } i = *in++; if (i > 0xf) { - if (rem < 3) - break; - *out++ = hexlist[i >> 4]; - *out++ = hexlist[i & 0xf]; - rem -= 2; + CHECK(2); + OUT(hexlist[i >> 4]); + OUT(hexlist[i & 0xf]); } else { - if (rem < 2) - break; - *out++ = hexlist[i]; - rem--; + CHECK(1); + OUT(hexlist[i]); } } - *out = 0; - return (obuf); + +#undef CHECK +#undef OUT + + /* + * We always leave enough room for the NUL if possible, but the user + * might have passed a NULL or zero-length buffer. + */ + if (out && *buflen) + *out = '\0'; + + *buflen = needed; + return ((rem > 0) ? 0 : -1); } diff --git a/lib/libc/net/map_v4v6.c b/lib/libc/net/map_v4v6.c index addc5194786c..bb3d580473ec 100644 --- a/lib/libc/net/map_v4v6.c +++ b/lib/libc/net/map_v4v6.c @@ -51,12 +51,6 @@ * --Copyright-- */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/socket.h> #include <netinet/in.h> diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c index 9b7aaf66ae21..ae1a117665cb 100644 --- a/lib/libc/net/name6.c +++ b/lib/libc/net/name6.c @@ -85,9 +85,6 @@ * Atsushi Onoe <onoe@sm.sony.co.jp> */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <sys/param.h> #include <sys/socket.h> diff --git a/lib/libc/net/netdb_private.h b/lib/libc/net/netdb_private.h index 9f2bde221c92..5049bcf3fbda 100644 --- a/lib/libc/net/netdb_private.h +++ b/lib/libc/net/netdb_private.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (C) 2005 The FreeBSD Project. All rights reserved. * @@ -23,8 +23,6 @@ * 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. - * - * $FreeBSD$ */ #ifndef _NETDB_PRIVATE_H_ diff --git a/lib/libc/net/networks b/lib/libc/net/networks index a6b15d4519b7..48e5e38269d2 100644 --- a/lib/libc/net/networks +++ b/lib/libc/net/networks @@ -1,6 +1,3 @@ -# $FreeBSD$ -# @(#)networks 5.1 (Berkeley) 6/30/90 -# # Your Local Networks Database # your-net 127 # your comment diff --git a/lib/libc/net/nscache.c b/lib/libc/net/nscache.c index e9954386b24f..3537d77edbbe 100644 --- a/lib/libc/net/nscache.c +++ b/lib/libc/net/nscache.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005 Michael Bushkov <bushman@rsu.ru> * All rights reserved. @@ -27,9 +27,6 @@ * */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #define _NS_PRIVATE #include <nsswitch.h> diff --git a/lib/libc/net/nscachedcli.c b/lib/libc/net/nscachedcli.c index 2acc12af2d1e..f57e69bdceb2 100644 --- a/lib/libc/net/nscachedcli.c +++ b/lib/libc/net/nscachedcli.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005 Michael Bushkov <bushman@rsu.ru> * All rights reserved. @@ -27,9 +27,6 @@ * */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <sys/types.h> #include <sys/socket.h> diff --git a/lib/libc/net/nsdispatch.3 b/lib/libc/net/nsdispatch.3 index e53bbb9647ce..ef998bdf061d 100644 --- a/lib/libc/net/nsdispatch.3 +++ b/lib/libc/net/nsdispatch.3 @@ -30,8 +30,6 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd October 15, 2018 .Dt NSDISPATCH 3 .Os diff --git a/lib/libc/net/nsdispatch.c b/lib/libc/net/nsdispatch.c index ada7ac606e15..60baa0014904 100644 --- a/lib/libc/net/nsdispatch.c +++ b/lib/libc/net/nsdispatch.c @@ -1,7 +1,7 @@ /* $NetBSD: nsdispatch.c,v 1.9 1999/01/25 00:16:17 lukem Exp $ */ /*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. * All rights reserved. @@ -62,9 +62,6 @@ * SUCH DAMAGE. * */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <sys/param.h> #include <sys/stat.h> diff --git a/lib/libc/net/nslexer.l b/lib/libc/net/nslexer.l index 946aace3a8a8..ce0f18670e21 100644 --- a/lib/libc/net/nslexer.l +++ b/lib/libc/net/nslexer.l @@ -2,7 +2,7 @@ /* $NetBSD: nslexer.l,v 1.3 1999/01/25 00:16:17 lukem Exp $ */ /*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. * All rights reserved. @@ -32,12 +32,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = - "$FreeBSD$"; -#endif /* LIBC_SCCS and not lint */ - #include "namespace.h" #include <ctype.h> #define _NS_PRIVATE diff --git a/lib/libc/net/nsparser.y b/lib/libc/net/nsparser.y index 6e90fc73d8c9..ec840d996f90 100644 --- a/lib/libc/net/nsparser.y +++ b/lib/libc/net/nsparser.y @@ -2,7 +2,7 @@ /* $NetBSD: nsparser.y,v 1.3 1999/01/25 00:16:18 lukem Exp $ */ /*- - * SPDX-License-Identifier: BSD-2-Clause-NetBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. * All rights reserved. @@ -32,9 +32,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #define _NS_PRIVATE #include <nsswitch.h> diff --git a/lib/libc/net/nss_backends.h b/lib/libc/net/nss_backends.h index 0ec803220ada..3167208f09cd 100644 --- a/lib/libc/net/nss_backends.h +++ b/lib/libc/net/nss_backends.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2003 Networks Associates Technology, Inc. * All rights reserved. @@ -30,8 +30,6 @@ * 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. - * - * $FreeBSD$ */ /* * Eventually, the implementations of existing built-in NSS functions diff --git a/lib/libc/net/nss_compat.c b/lib/libc/net/nss_compat.c index 110cd66090d6..fb1956b1e71a 100644 --- a/lib/libc/net/nss_compat.c +++ b/lib/libc/net/nss_compat.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2003 Networks Associates Technology, Inc. * All rights reserved. @@ -33,9 +33,6 @@ * * Compatibility shims for the GNU C Library-style nsswitch interface. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <sys/param.h> #include <errno.h> diff --git a/lib/libc/net/nsswitch.conf b/lib/libc/net/nsswitch.conf index e0f14af76f2d..846b58754184 100644 --- a/lib/libc/net/nsswitch.conf +++ b/lib/libc/net/nsswitch.conf @@ -1,6 +1,5 @@ # # nsswitch.conf(5) - name service switch configuration file -# $FreeBSD$ # group: compat group_compat: nis diff --git a/lib/libc/net/ntoh.c b/lib/libc/net/ntoh.c index 7b2bf9edc113..508a2c81d466 100644 --- a/lib/libc/net/ntoh.c +++ b/lib/libc/net/ntoh.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Olivier Houchard * All rights reserved. @@ -26,9 +26,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/endian.h> #define _BYTEORDER_FUNC_DEFINED #include <arpa/inet.h> diff --git a/lib/libc/net/protocols b/lib/libc/net/protocols index 05702d430da1..7581cff17908 100644 --- a/lib/libc/net/protocols +++ b/lib/libc/net/protocols @@ -1,9 +1,5 @@ # # Internet protocols -# -# $FreeBSD$ -# from: @(#)protocols 5.1 (Berkeley) 4/17/89 -# # See also http://www.iana.org/assignments/protocol-numbers # ip 0 IP # internet protocol, pseudo protocol number diff --git a/lib/libc/net/rcmd.3 b/lib/libc/net/rcmd.3 index 7bd586975d3c..b4b80e4385cf 100644 --- a/lib/libc/net/rcmd.3 +++ b/lib/libc/net/rcmd.3 @@ -25,9 +25,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" From: @(#)rcmd.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" .Dd March 3, 2000 .Dt RCMD 3 .Os diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index e8b4ffd356c4..f9f70c7921ca 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -29,12 +29,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <sys/param.h> #include <sys/socket.h> @@ -97,7 +91,7 @@ rcmd_af(char **ahost, int rport, const char *locuser, const char *remuser, static char canonnamebuf[MAXDNAME]; /* is it proper here? */ /* call rcmdsh() with specified remote shell if appropriate. */ - if (!issetugid() && (p = getenv("RSH"))) { + if ((p = secure_getenv("RSH")) != NULL) { struct servent *sp = getservbyname("shell", "tcp"); if (sp && sp->s_port == rport) diff --git a/lib/libc/net/rcmdsh.3 b/lib/libc/net/rcmdsh.3 index d9929d540570..371c5b1160cb 100644 --- a/lib/libc/net/rcmdsh.3 +++ b/lib/libc/net/rcmdsh.3 @@ -27,8 +27,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd September 1, 1996 .Dt RCMDSH 3 .Os diff --git a/lib/libc/net/rcmdsh.c b/lib/libc/net/rcmdsh.c index b321b5a51a2f..7e400e99cb3b 100644 --- a/lib/libc/net/rcmdsh.c +++ b/lib/libc/net/rcmdsh.c @@ -35,9 +35,6 @@ * Chris Siebenmann <cks@utcc.utoronto.ca>. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <sys/types.h> #include <sys/socket.h> diff --git a/lib/libc/net/recv.c b/lib/libc/net/recv.c deleted file mode 100644 index 5304745848a7..000000000000 --- a/lib/libc/net/recv.c +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1988, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)recv.c 8.2 (Berkeley) 2/21/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/socket.h> -#include "libc_private.h" - -#include <stddef.h> - -ssize_t -recv(int s, void *buf, size_t len, int flags) -{ - /* - * POSIX says recv() shall be a cancellation point, so call the - * cancellation-enabled recvfrom() and not _recvfrom(). - */ - return (((ssize_t (*)(int, void *, size_t, int, - struct sockaddr *, socklen_t *)) - __libc_interposing[INTERPOS_recvfrom])(s, buf, len, flags, - NULL, NULL)); -} diff --git a/lib/libc/net/res_config.h b/lib/libc/net/res_config.h index 51b609b48eaf..39a1b5f1486f 100644 --- a/lib/libc/net/res_config.h +++ b/lib/libc/net/res_config.h @@ -1,6 +1,5 @@ -/* $FreeBSD$ */ -#define DEBUG 1 /* enable debugging code (needed for dig) */ +//#define DEBUG /* enable debugging code */ #define RESOLVSORT /* allow sorting of addresses in gethostbyname */ -#undef SUNSECURITY /* verify gethostbyaddr() calls - WE DON'T NEED IT */ +//#define SUNSECURITY /* verify gethostbyaddr() calls */ #define MULTI_PTRS_ARE_ALIASES 1 /* fold multiple PTR records into aliases */ diff --git a/lib/libc/net/resolver.3 b/lib/libc/net/resolver.3 index 98778f746a03..f1220dcf9b7f 100644 --- a/lib/libc/net/resolver.3 +++ b/lib/libc/net/resolver.3 @@ -25,10 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)resolver.3 8.1 (Berkeley) 6/4/93 -.\" $FreeBSD$ -.\" -.Dd June 27, 2022 +.Dd January 8, 2024 .Dt RESOLVER 3 .Os .Sh NAME @@ -48,9 +45,6 @@ .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In sys/types.h -.In netinet/in.h -.In arpa/nameser.h .In resolv.h .Ft int .Fo res_query @@ -450,9 +444,6 @@ see .%T RFC1034 , .%T RFC1035 , .%T RFC974 -.Rs -.%T "Name Server Operations Guide for BIND" -.Re .Sh HISTORY The .Nm diff --git a/lib/libc/net/rthdr.c b/lib/libc/net/rthdr.c index 81f07c0e77dd..0698a3f7712e 100644 --- a/lib/libc/net/rthdr.c +++ b/lib/libc/net/rthdr.c @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/socket.h> diff --git a/lib/libc/net/sctp_bindx.3 b/lib/libc/net/sctp_bindx.3 index c121eb4d9eeb..93a9857ddc86 100644 --- a/lib/libc/net/sctp_bindx.3 +++ b/lib/libc/net/sctp_bindx.3 @@ -25,10 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94 -.\" $FreeBSD$ -.\" -.Dd June 14, 2015 +.Dd February 2, 2024 .Dt SCTP_BINDX 3 .Os .Sh NAME @@ -108,3 +105,17 @@ is not a socket. .Sh SEE ALSO .Xr bind 2 , .Xr sctp 4 +.Rs +.%A R. Stewart +.%A M. Tuexen +.%A K. Poon +.%A P. Lei +.%A V. Yasevich +.%T Sockets API Extensions for the Stream Control Transmission Protocol (SCTP) +.%R RFC 6458 +.%D December 2011 +.Re +.Sh STANDARDS +The +.Fn sctp_bindx +function conforms to RFC 6458. diff --git a/lib/libc/net/sctp_connectx.3 b/lib/libc/net/sctp_connectx.3 index 0c298e1ea00a..c6cbca14006d 100644 --- a/lib/libc/net/sctp_connectx.3 +++ b/lib/libc/net/sctp_connectx.3 @@ -25,9 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd June 19, 2007 +.Dd February 2, 2024 .Dt SCTP_CONNECTX 3 .Os .Sh NAME @@ -100,3 +98,17 @@ is not a socket. .Sh SEE ALSO .Xr connect 2 , .Xr sctp 4 +.Rs +.%A R. Stewart +.%A M. Tuexen +.%A K. Poon +.%A P. Lei +.%A V. Yasevich +.%T Sockets API Extensions for the Stream Control Transmission Protocol (SCTP) +.%R RFC 6458 +.%D December 2011 +.Re +.Sh STANDARDS +The +.Fn sctp_connectx +function conforms to RFC 6458. diff --git a/lib/libc/net/sctp_freepaddrs.3 b/lib/libc/net/sctp_freepaddrs.3 index 400f21d8d808..07d486920125 100644 --- a/lib/libc/net/sctp_freepaddrs.3 +++ b/lib/libc/net/sctp_freepaddrs.3 @@ -25,10 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94 -.\" $FreeBSD$ -.\" -.Dd December 15, 2006 +.Dd February 2, 2024 .Dt SCTP_FREEPADDRS 3 .Os .Sh NAME @@ -62,3 +59,19 @@ none. .Xr sctp_getladdrs 3 , .Xr sctp_getpaddrs 3 , .Xr sctp 4 +.Rs +.%A R. Stewart +.%A M. Tuexen +.%A K. Poon +.%A P. Lei +.%A V. Yasevich +.%T Sockets API Extensions for the Stream Control Transmission Protocol (SCTP) +.%R RFC 6458 +.%D December 2011 +.Re +.Sh STANDARDS +The +.Fn sctp_freepaddrs +and +.Fn sctp_freeladdrs +functions conform to RFC 6458. diff --git a/lib/libc/net/sctp_getaddrlen.3 b/lib/libc/net/sctp_getaddrlen.3 index 70e3688c74d6..cb755a71d107 100644 --- a/lib/libc/net/sctp_getaddrlen.3 +++ b/lib/libc/net/sctp_getaddrlen.3 @@ -25,9 +25,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94 -.\" $FreeBSD$ -.\" .Dd December 15, 2006 .Dt SCTP_GETADDRLEN 3 .Os diff --git a/lib/libc/net/sctp_getassocid.3 b/lib/libc/net/sctp_getassocid.3 index e0da322f943a..533833d15784 100644 --- a/lib/libc/net/sctp_getassocid.3 +++ b/lib/libc/net/sctp_getassocid.3 @@ -25,8 +25,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd December 15, 2006 .Dt SCTP_GETASSOCID 3 .Os diff --git a/lib/libc/net/sctp_getpaddrs.3 b/lib/libc/net/sctp_getpaddrs.3 index 0c7b8ecb5051..0e80e72bbaf6 100644 --- a/lib/libc/net/sctp_getpaddrs.3 +++ b/lib/libc/net/sctp_getpaddrs.3 @@ -25,10 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94 -.\" $FreeBSD$ -.\" -.Dd December 15, 2006 +.Dd February 2, 2024 .Dt SCTP_GETPADDRS 3 .Os .Sh NAME @@ -94,3 +91,19 @@ is not a socket. .Xr sctp_freeladdrs 3 , .Xr sctp_freepaddrs 3 , .Xr sctp 4 +.Rs +.%A R. Stewart +.%A M. Tuexen +.%A K. Poon +.%A P. Lei +.%A V. Yasevich +.%T Sockets API Extensions for the Stream Control Transmission Protocol (SCTP) +.%R RFC 6458 +.%D December 2011 +.Re +.Sh STANDARDS +The +.Fn sctp_getpaddrs +and +.Fn sctp_getladdrs +functions conform to RFC 6458. diff --git a/lib/libc/net/sctp_opt_info.3 b/lib/libc/net/sctp_opt_info.3 index 170692cfd3fc..b8b4c1a832b5 100644 --- a/lib/libc/net/sctp_opt_info.3 +++ b/lib/libc/net/sctp_opt_info.3 @@ -25,9 +25,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94 -.\" $FreeBSD$ -.\" .Dd June 18, 2011 .Dt SCTP_OPT_INFO 3 .Os diff --git a/lib/libc/net/sctp_recvmsg.3 b/lib/libc/net/sctp_recvmsg.3 index a8b073418657..7bcdcc74f7a1 100644 --- a/lib/libc/net/sctp_recvmsg.3 +++ b/lib/libc/net/sctp_recvmsg.3 @@ -25,13 +25,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd April 23, 2015 +.Dd May 2, 2024 .Dt SCTP_RECVMSG 3 .Os .Sh NAME -.Nm sctp_recvmsg +.Nm sctp_recvmsg , +.Nm sctp_recvv .Nd receive a message from an SCTP socket .Sh LIBRARY .Lb libc @@ -41,18 +40,22 @@ .In netinet/sctp.h .Ft ssize_t .Fo sctp_recvmsg -.Fa "int s" "void *msg" "size_t len" "struct sockaddr * restrict from" -.Fa "socklen_t * restrict fromlen" "struct sctp_sndrcvinfo *sinfo" "int *flags" +.Fa "int s" "void *msg" "size_t len" "struct sockaddr *from" +.Fa "socklen_t *fromlen" "struct sctp_sndrcvinfo *sinfo" "int *flags" +.Fc +.Ft ssize_t +.Fo sctp_recvv +.Fa "int s" "const struct iovec *iov" "int iovlen" "struct sockaddr *from" +.Fa "socklen_t *fromlen" "void *info" "socklen_t *infolen" +.Fa "unsigned int *infotype" "int *flags" .Fc .Sh DESCRIPTION The .Fn sctp_recvmsg -system call -is used to receive a message from another SCTP endpoint. -The -.Fn sctp_recvmsg -call is used by one-to-one (SOCK_STREAM) type sockets after a -successful +and +.Fn sctp_recvv +functions are used to receive a message from another SCTP endpoint. +They are used by one-to-one (SOCK_STREAM) type sockets after a successful .Fn connect call or after the application has performed a .Fn listen @@ -60,6 +63,8 @@ followed by a successful .Fn accept . For a one-to-many (SOCK_SEQPACKET) type socket, an endpoint may call .Fn sctp_recvmsg +or +.Fn sctp_recvv after having implicitly started an association via one of the send calls including .Fn sctp_sendmsg , @@ -233,6 +238,159 @@ The .Fa sinfo->info_timetolive field is not used by .Fn sctp_recvmsg . +.Pp +The +.Fn sctp_recvv +function works as +.Fn sctp_recvmsg +with two differences. +Firstly, the receive buffer is passed as an array containing +.Vt iocnt +objects of type +.Vt struct iovec , +where the received data will be scattered in the same manner as +.Xr readv 2 . +Secondly, the +.Fa sinfo +argument is replaced by the tuple +.Fa info , +.Fa infolen , +and +.Fa infotype , +which allow different information to be received based on the socket options. +.Pp +To receive an +.Vt sctp_rcvinfo +structure, set the +.Va SCTP_RECVRCVINFO +socket option, and pass a pointer to a +.Vt struct sctp_rcvinfo +structure in +.Fa info . +The +.Vt sctp_rcvinfo +structure has the following format: +.Bd -literal +struct sctp_rcvinfo { + uint16_t rcv_sid; /* Stream arriving on */ + uint16_t rcv_ssn; /* Stream Sequence Number */ + uint16_t rcv_flags; /* Flags on the incoming message */ + uint32_t rcv_ppid; /* The ppid field */ + uint32_t rcv_tsn; /* The transport sequence number */ + uint32_t rcv_cumtsn; /* The cumulative TSN */ + uint32_t rcv_context; /* Opaque context field */ + sctp_assoc_t rcv_assoc_id; /* Peer association id */ +}; +.Ed +.Pp +These fields have the same meaning as the equivalent fields in +.Vt struct sctp_sndrcvinfo , +defined above. +.Pp +To receive an +.Vt sctp_nxtinfo +structure, set the +.Va SCTP_RECVNXTINFO +socket option, and pass a pointer to a +.Vt struct sctp_nxtinfo +structure in +.Fa info . +The +.Vt struct sctp_nxtinfo +structure has the following format: +.Bd -literal +struct sctp_nxtinfo { + uint16_t nxt_sid; /* Next message's stream number */ + uint16_t nxt_flags; /* Flags (see below) */ + uint32_t nxt_ppid; /* The ppid field */ + uint32_t nxt_length; /* Length of next message */ + sctp_assoc_t nxt_assoc_id; /* Peer association id */ +}; +.Ed +.Pp +The fields +.Va nxt_sid , +.Va nxt_ppid , +and +.Va nxt_assoc_id +have the same meaning as in +.Vt struct sctp_rcvinfo , +except they refer to the next message rather than the message that was +received. +The field +.Va nxt_length +contains the length of the part of the next message currently available in +the socket buffer. +This may not represent the length of the entire message unless the +.Va SCTP_COMPLETE +flag is set in +.Va nxt_flags . +.Pp +The +.Va nxt_flags +field is a bitmask which may contain any of the following values: +.Bl -bullet +.It +.Va SCTP_UNORDERED : +The next message was sent unordered. +.It +.Va SCTP_COMPLETE : +The entirety of the next message has been received in the socket buffer. +In this case, the +.Va nxt_length +field contains the length of the entire message. +.It +.Va SCTP_NOTIFICATION : +The next message is a notification, not a user message. +.El +.Pp +If both the +.Va SCTP_RECVRCVINFO +and +.Va SCTP_RECVNXTINFO +socket options are set, then pass a pointer to a +.Vt struct sctp_recvv_rn +structure in +.Fa info . +This struct has the following format: +.Bd -literal +struct sctp_recvv_rn { + struct sctp_rcvinfo recvv_rcvinfo; + struct sctp_nxtinfo recvv_nxtinfo; +}; +.Ed +.Pp +The value pointed to by +.Fa infolen +should initially contain the length of the structure to which +.Fa info +points. +When the function returns, it will be set to the length of the +returned structure. +Additionally, +.Fa *infotype +will be set to one of the following values depending on what type of info +was returned: +.Bl -bullet +.It +.Va SCTP_RECVV_NOINFO : +no information was returned. +.It +.Va SCTP_RECVV_RCVINFO : +.Fa *info +contains an object of type +.Vt struct sctp_rcvinfo . +.It +.Va SCTP_RECVV_NXTINFO : +.Fa *info +contains an object of type +.Vt struct sctp_nxtinfo . +.It +.Va SCTP_RECVV_RN : +.Fa *info +contains an object of type +.Vt struct sctp_recvv_rn . +.El .Sh RETURN VALUES The call returns the number of bytes received, or -1 if an error occurred. @@ -281,6 +439,12 @@ has been set on the socket). This typically means that the socket is not connected and is a one-to-one style socket. .El +.Sh NOTES +The +.Fn sctp_recvmsg +function is deprecated. +New applications should use +.Fn sctp_recvv . .Sh SEE ALSO .Xr getsockopt 2 , .Xr recv 2 , @@ -292,3 +456,15 @@ is not connected and is a one-to-one style socket. .Xr sctp_send 3 , .Xr sctp_sendmsg 3 , .Xr sctp 4 +.Rs +.%A R. Stewart +.%A M. Tuexen +.%A K. Poon +.%A P. Lei +.%A V. Yasevich +.%T Sockets API Extensions for the Stream Control Transmission Protocol (SCTP) +.%R RFC 6458 +.%D December 2011 +.Re +.Sh STANDARDS +The functions described in this document conform to RFC 6458. diff --git a/lib/libc/net/sctp_send.3 b/lib/libc/net/sctp_send.3 index 18a3e99473d8..ce34a2554576 100644 --- a/lib/libc/net/sctp_send.3 +++ b/lib/libc/net/sctp_send.3 @@ -25,14 +25,13 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd December 15, 2006 +.Dd February 2, 2024 .Dt SCTP_SEND 3 .Os .Sh NAME .Nm sctp_send , -.Nm sctp_sendx +.Nm sctp_sendx , +.Nm sctp_sendv .Nd send a message from an SCTP socket .Sh LIBRARY .Lb libc @@ -50,11 +49,27 @@ .Fa "int sd" "const void *msg" "size_t len" "struct sockaddr *addrs" .Fa "int addrcnt" "const struct sctp_sndrcvinfo *sinfo" "int flags" .Fc +.Ft ssize_t +.Fo sctp_sendv +.Fa "int sd" "const struct iovec *iov" "int iocnt" "struct sockaddr *addrs" +.Fa "int addrcnt" "void *info" "socklen_t infolen" "unsigned int infotype" +.Fa "int flags" +.Fc .Sh DESCRIPTION The .Fn sctp_send system call is used to transmit a message to another SCTP endpoint. +The +.Fn sctp_sendx +function is used to specify multiple peer addresses when creating an implicit +association, as in +.Xr sctp_connectx 3 . +The +.Fn sctp_sendv +function is used to transmit a message whose data is gathered from the +provided I/O buffers. +.Pp .Fn sctp_send may be used to send data to an existing association for both one-to-many (SOCK_SEQPACKET) and one-to-one (SOCK_STREAM) socket types. @@ -255,6 +270,7 @@ and .Fa sinfo->sinfo_cumtsn are used only when receiving messages and are thus ignored by .Fn sctp_send . +.Pp The function .Fn sctp_sendx has the same properties as @@ -283,6 +299,156 @@ the association in place of the association id. If both an address and an association id are specified, the association id has priority. +.Pp +The function +.Fn sctp_sendv +works as +.Fn sctp_sendx , +with two differences. +Firstly, the data to be written is passed as an array containing +.Vt iocnt +objects of type +.Vt struct iovec , +which will be gathered for sending in the same manner as +.Xr writev 2 . +Secondly, the +.Fa info +argument is replaced by the tuple +.Fa sinfo , +.Fa infolen , +.Fa infotype , +where +.Fa sinfo +is a pointer to a struct of size +.Fa infolen +whose type is indicated by the +.Fa infotype +argument. +.Pp +If no information is passed, set +.Fa infotype +to +.Va SCTP_SENDV_NOINFO . +.Fa sinfo +may be a null pointer. +.Pp +If +.Fa sinfo +points to a +.Vt struct sctp_sndinfo , +set +.Fa infotype +to +.Va SCTP_SENDV_SNDINFO . +The +.Vt sctp_sndinfo +structure has the following format: +.Bd -literal +struct sctp_sndinfo { + uint16_t snd_sid; /* stream identifier */ + uint16_t snd_flags; /* Flags */ + uint32_t snd_ppid; /* ppid field */ + uint32_t snd_context; /* context field */ + sctp_assoc_t snd_assoc_id; /* association id */ +}; +.Ed +.Pp +The meaning of these fields is the same as in +.Vt struct sctp_sndrcvinfo , +described above. +.Pp +If +.Fa sinfo +points to a +.Vt struct sctp_authinfo , +set +.Fa infotype +to +.Va SCTP_SENDV_AUTHINFO . +The +.Vt sctp_authinfo +struct has the following format: +.Bd -literal +struct sctp_authinfo { + uint16_t auth_keynumber; /* Shared key identifier */ +}; +.Ed +.Pp +The +.Va auth_keynumber +field specifies the shared key identifier that will be used for sending the +message. +.Pp +If +.Fa sinfo +points to a +.Vt struct sctp_prinfo , +set +.Fa infotype +to +.Va SCTP_SENDV_PRINFO . +The +.Vt sctp_prinfo +structure has the following format: +.Bd -literal +struct sctp_prinfo { + uint16_t pr_policy; /* PR-SCTP policy */ + uint32_t pr_value; /* PR-SCTP Policy option */ +}; +.Ed +.Pp +The +.Va pr_policy +field should be set to either +.Va SCTP_PR_SCTP_NONE +to use reliable transmission (in which case the field +.Va pr_value +is ignored), or +.Va SCTP_PR_SCTP_TTL +to use RFC 3758 timed reliability, in which case the field +.Va pr_value +contains the lifetime in milliseconds. +.Pp +To pass two or more types in +.Fa sinfo , +set +.Fa infotype +to +.Va SCTP_SENDV_SPA +and pass a pointer to a +.Vt struct sctp_sendv_spa +in +.Fa sinfo . +The +.Ft sctp_sendv_spa +structure has the following format: +.Bd -literal +struct sctp_sendv_spa { + uint32_t sendv_flags; + struct sctp_sndinfo sendv_sndinfo; + struct sctp_prinfo sendv_prinfo; + struct sctp_authinfo sendv_authinfo; +}; +.Ed +.Pp +The +.Va sendv_flags +member should be set to the bitwise OR of the flags +.Va SCTP_SEND_SNDINFO_VALID , +.Va SCTP_SEND_PRINFO_VALID , +and +.Va SCTP_SEND_AUTHINFO_VALID +to indicate which fields of the struct contain valid data. +.Pp +If +.Fa infotype +is set to SCTP_SENDV_NOINFO, the +.Fa infolen +argument should be set to zero. +Otherwise, +.Fa infolen +should be set to the length of the data structure pointed to by +.Fa info . .Sh RETURN VALUES The call returns the number of characters sent, or -1 if an error occurred. @@ -331,6 +497,14 @@ has been set on the socket). This typically means that the socket is not connected and is a one-to-one style socket. .El +.Sh NOTES +The functions +.Fn sctp_send +and +.Fn sctp_sendx +are deprecated. +New applications should use +.Fn sctp_sendv . .Sh SEE ALSO .Xr getsockopt 2 , .Xr recv 2 , @@ -342,6 +516,18 @@ is not connected and is a one-to-one style socket. .Xr sctp_recvmsg 3 , .Xr sctp_sendmsg 3 , .Xr sctp 4 +.Rs +.%A R. Stewart +.%A M. Tuexen +.%A K. Poon +.%A P. Lei +.%A V. Yasevich +.%T Sockets API Extensions for the Stream Control Transmission Protocol (SCTP) +.%R RFC 6458 +.%D December 2011 +.Re +.Sh STANDARDS +The functions described in this document conform to RFC 6458. .Sh BUGS Because .Fn sctp_send diff --git a/lib/libc/net/sctp_sendmsg.3 b/lib/libc/net/sctp_sendmsg.3 index 65f790ab8a3f..47a7c7db2d8b 100644 --- a/lib/libc/net/sctp_sendmsg.3 +++ b/lib/libc/net/sctp_sendmsg.3 @@ -25,10 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94 -.\" $FreeBSD$ -.\" -.Dd December 15, 2006 +.Dd February 2, 2024 .Dt SCTP_SENDMSG 3 .Os .Sh NAME @@ -99,13 +96,13 @@ is set to the message is not transmitted. .Pp No indication of failure to deliver is implicit in a -.Xr sctp_sendmsg 3 +.Fn sctp_sendmsg call. Locally detected errors are indicated by a return value of -1. .Pp If no space is available at the socket to hold the message to be transmitted, then -.Xr sctp_sendmsg 3 +.Fn sctp_sendmsg normally blocks, unless the socket has been placed in non-blocking I/O mode. The diff --git a/lib/libc/net/sctp_sys_calls.c b/lib/libc/net/sctp_sys_calls.c index 7c3652ff5d3c..5cb26266c888 100644 --- a/lib/libc/net/sctp_sys_calls.c +++ b/lib/libc/net/sctp_sys_calls.c @@ -32,9 +32,6 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stdbool.h> #include <stddef.h> #include <stdio.h> diff --git a/lib/libc/net/send.c b/lib/libc/net/send.c deleted file mode 100644 index b0c179c2e6b4..000000000000 --- a/lib/libc/net/send.c +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 1988, 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)send.c 8.2 (Berkeley) 2/21/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <sys/socket.h> -#include "libc_private.h" - -#include <stddef.h> - -ssize_t -send(int s, const void *msg, size_t len, int flags) -{ - /* - * POSIX says send() shall be a cancellation point, so call the - * cancellation-enabled sendto() and not _sendto(). - */ - return (((ssize_t (*)(int, const void *, size_t, int, - const struct sockaddr *, socklen_t)) - __libc_interposing[INTERPOS_sendto])(s, msg, len, flags, - NULL, 0)); -} diff --git a/lib/libc/net/sockatmark.3 b/lib/libc/net/sockatmark.3 index b44311234d0c..f499eb0b902d 100644 --- a/lib/libc/net/sockatmark.3 +++ b/lib/libc/net/sockatmark.3 @@ -21,8 +21,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd July 3, 2022 .Dt SOCKATMARK 3 .Os diff --git a/lib/libc/net/sockatmark.c b/lib/libc/net/sockatmark.c index f56304359a76..4a26b09e3c88 100644 --- a/lib/libc/net/sockatmark.c +++ b/lib/libc/net/sockatmark.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2002 William C. Fenner. All rights reserved. * @@ -23,8 +23,6 @@ * 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. - * - * $FreeBSD$ */ #include "namespace.h" #include <sys/ioctl.h> diff --git a/lib/libc/net/sourcefilter.3 b/lib/libc/net/sourcefilter.3 index a123ff38d68e..41f0fdca04de 100644 --- a/lib/libc/net/sourcefilter.3 +++ b/lib/libc/net/sourcefilter.3 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd February 13, 2009 .Dt SOURCEFILTER 3 .Os diff --git a/lib/libc/net/sourcefilter.c b/lib/libc/net/sourcefilter.c index 9bfb72d84504..81fa55741d0c 100644 --- a/lib/libc/net/sourcefilter.c +++ b/lib/libc/net/sourcefilter.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2007-2009 Bruce Simpson. * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <sys/param.h> diff --git a/lib/libc/net/vars.c b/lib/libc/net/vars.c index 5bcfb9f9263e..1a8824740dec 100644 --- a/lib/libc/net/vars.c +++ b/lib/libc/net/vars.c @@ -31,9 +31,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <netinet/in.h> |