[Midnightbsd-cvs] src [10574] trunk/lib/libc/net: tag
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Thu Jun 7 21:46:19 EDT 2018
Revision: 10574
http://svnweb.midnightbsd.org/src/?rev=10574
Author: laffer1
Date: 2018-06-07 21:46:18 -0400 (Thu, 07 Jun 2018)
Log Message:
-----------
tag
Modified Paths:
--------------
trunk/lib/libc/net/Makefile.inc
trunk/lib/libc/net/Symbol.map
trunk/lib/libc/net/base64.c
trunk/lib/libc/net/byteorder.3
trunk/lib/libc/net/ether_addr.c
trunk/lib/libc/net/ethers.3
trunk/lib/libc/net/eui64.3
trunk/lib/libc/net/eui64.c
trunk/lib/libc/net/gai_strerror.3
trunk/lib/libc/net/gai_strerror.c
trunk/lib/libc/net/getaddrinfo.3
trunk/lib/libc/net/getaddrinfo.c
trunk/lib/libc/net/gethostbydns.c
trunk/lib/libc/net/gethostbyht.c
trunk/lib/libc/net/gethostbyname.3
trunk/lib/libc/net/gethostbynis.c
trunk/lib/libc/net/gethostnamadr.c
trunk/lib/libc/net/getifaddrs.3
trunk/lib/libc/net/getifaddrs.c
trunk/lib/libc/net/getifmaddrs.3
trunk/lib/libc/net/getifmaddrs.c
trunk/lib/libc/net/getipnodebyname.3
trunk/lib/libc/net/getnameinfo.3
trunk/lib/libc/net/getnameinfo.c
trunk/lib/libc/net/getnetbydns.c
trunk/lib/libc/net/getnetbyht.c
trunk/lib/libc/net/getnetbynis.c
trunk/lib/libc/net/getnetent.3
trunk/lib/libc/net/getnetnamadr.c
trunk/lib/libc/net/getproto.c
trunk/lib/libc/net/getprotoent.3
trunk/lib/libc/net/getprotoent.c
trunk/lib/libc/net/getprotoname.c
trunk/lib/libc/net/getservent.3
trunk/lib/libc/net/getservent.c
trunk/lib/libc/net/hesiod.3
trunk/lib/libc/net/hesiod.c
trunk/lib/libc/net/if_indextoname.3
trunk/lib/libc/net/if_indextoname.c
trunk/lib/libc/net/if_nameindex.c
trunk/lib/libc/net/if_nametoindex.c
trunk/lib/libc/net/inet.3
trunk/lib/libc/net/inet6_opt_init.3
trunk/lib/libc/net/inet6_option_space.3
trunk/lib/libc/net/inet6_rth_space.3
trunk/lib/libc/net/inet6_rthdr_space.3
trunk/lib/libc/net/inet_net.3
trunk/lib/libc/net/ip6opt.c
trunk/lib/libc/net/linkaddr.3
trunk/lib/libc/net/linkaddr.c
trunk/lib/libc/net/map_v4v6.c
trunk/lib/libc/net/name6.c
trunk/lib/libc/net/netdb_private.h
trunk/lib/libc/net/nscache.c
trunk/lib/libc/net/nscachedcli.c
trunk/lib/libc/net/nsdispatch.3
trunk/lib/libc/net/nsdispatch.c
trunk/lib/libc/net/nslexer.l
trunk/lib/libc/net/nsparser.y
trunk/lib/libc/net/nss_backends.h
trunk/lib/libc/net/nss_compat.c
trunk/lib/libc/net/ntoh.c
trunk/lib/libc/net/rcmd.3
trunk/lib/libc/net/rcmd.c
trunk/lib/libc/net/rcmdsh.3
trunk/lib/libc/net/rcmdsh.c
trunk/lib/libc/net/recv.c
trunk/lib/libc/net/res_config.h
trunk/lib/libc/net/resolver.3
trunk/lib/libc/net/rthdr.c
trunk/lib/libc/net/sctp_bindx.3
trunk/lib/libc/net/sctp_connectx.3
trunk/lib/libc/net/sctp_freepaddrs.3
trunk/lib/libc/net/sctp_getaddrlen.3
trunk/lib/libc/net/sctp_getassocid.3
trunk/lib/libc/net/sctp_getpaddrs.3
trunk/lib/libc/net/sctp_opt_info.3
trunk/lib/libc/net/sctp_recvmsg.3
trunk/lib/libc/net/sctp_send.3
trunk/lib/libc/net/sctp_sendmsg.3
trunk/lib/libc/net/sctp_sys_calls.c
trunk/lib/libc/net/send.c
trunk/lib/libc/net/sockatmark.3
trunk/lib/libc/net/sockatmark.c
trunk/lib/libc/net/sourcefilter.3
Property Changed:
----------------
trunk/lib/libc/net/nslexer.l
trunk/lib/libc/net/nsparser.y
Modified: trunk/lib/libc/net/Makefile.inc
===================================================================
--- trunk/lib/libc/net/Makefile.inc 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/Makefile.inc 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,4 +1,5 @@
# from @(#)Makefile.inc 8.2 (Berkeley) 9/5/93
+# $FreeBSD: stable/10/lib/libc/net/Makefile.inc 296765 2016-03-12 19:26:21Z bdrewery $
# $MidnightBSD$
# machine-independent net sources
@@ -12,7 +13,7 @@
getproto.c getprotoent.c getprotoname.c getservent.c \
if_indextoname.c if_nameindex.c if_nametoindex.c \
ip6opt.c linkaddr.c map_v4v6.c name6.c ntoh.c \
- nsdispatch.c nslexer.c nsparser.y nss_compat.c \
+ nsdispatch.c nslexer.l nsparser.y nss_compat.c \
rcmd.c rcmdsh.c recv.c rthdr.c sctp_sys_calls.c send.c \
sockatmark.c sourcefilter.c vars.c
@@ -34,12 +35,9 @@
YFLAGS+=-p_nsyy
LFLAGS+=-P_nsyy
-CLEANFILES+=nslexer.c
+CFLAGS.nslexer.c= -DYY_BUF_SIZE=1024
+CFLAGS+= ${CFLAGS.${.IMPSRC:T}}
-nslexer.c: nslexer.l
- ${LEX} ${LFLAGS} -o/dev/stdout ${.IMPSRC} | \
- sed -e '/YY_BUF_SIZE/s/16384/1024/' >${.TARGET}
-
MAN+= byteorder.3 ethers.3 eui64.3 \
getaddrinfo.3 gai_strerror.3 gethostbyname.3 \
getifaddrs.3 getifmaddrs.3 getipnodebyname.3 \
@@ -60,7 +58,7 @@
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 getaddrinfo.3 allocaddrinfo.3
+MLINKS+=getaddrinfo.3 freeaddrinfo.3
MLINKS+=gethostbyname.3 endhostent.3 gethostbyname.3 gethostbyaddr.3 \
gethostbyname.3 gethostbyname2.3 gethostbyname.3 gethostent.3 \
gethostbyname.3 herror.3 gethostbyname.3 hstrerror.3 \
Modified: trunk/lib/libc/net/Symbol.map
===================================================================
--- trunk/lib/libc/net/Symbol.map 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/Symbol.map 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,5 +1,5 @@
-/*
- * $MidnightBSD$
+/* $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/net/Symbol.map 283737 2015-05-29 13:28:24Z tuexen $
*/
FBSD_1.0 {
@@ -124,6 +124,7 @@
in6addr_nodelocal_allnodes;
in6addr_linklocal_allnodes;
sctp_getaddrlen;
+ sctp_getassocid;
sctp_bindx;
sctp_connectx;
sctp_peeloff;
@@ -148,10 +149,6 @@
sctp_sendv;
};
-MNBSD_1.1 {
- allocaddrinfo;
-};
-
FBSDprivate_1.0 {
_nsdispatch;
_nsyyerror; /* generated from nslexer.l */
@@ -164,14 +161,14 @@
__ivaliduser_sa;
__check_rhosts_file;
__rcmd_errstr;
- __nss_compat_getgrnam_r;
- __nss_compat_getgrgid_r;
- __nss_compat_getgrent_r;
- __nss_compat_setgrent;
- __nss_compat_endgrent;
- __nss_compat_getpwnam_r;
- __nss_compat_getpwuid_r;
- __nss_compat_getpwent_r;
- __nss_compat_setpwent;
- __nss_compat_endpwent;
+ __nss_compat_getgrnam_r;
+ __nss_compat_getgrgid_r;
+ __nss_compat_getgrent_r;
+ __nss_compat_setgrent;
+ __nss_compat_endgrent;
+ __nss_compat_getpwnam_r;
+ __nss_compat_getpwuid_r;
+ __nss_compat_getpwent_r;
+ __nss_compat_setpwent;
+ __nss_compat_endpwent;
};
Modified: trunk/lib/libc/net/base64.c
===================================================================
--- trunk/lib/libc/net/base64.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/base64.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1996, 1998 by Internet Software Consortium.
*
@@ -41,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/base64.c 309485 2016-12-03 17:17:42Z ngie $");
#include <sys/types.h>
#include <sys/param.h>
@@ -193,12 +194,10 @@
*/
int
-b64_pton(src, target, targsize)
- char const *src;
- u_char *target;
- size_t targsize;
+b64_pton(const char *src, u_char *target, size_t targsize)
{
int tarindex, state, ch;
+ u_char nextbyte;
char *pos;
state = 0;
@@ -212,7 +211,7 @@
break;
pos = strchr(Base64, ch);
- if (pos == 0) /* A non-base64 character. */
+ if (pos == NULL) /* A non-base64 character. */
return (-1);
switch (state) {
@@ -226,11 +225,14 @@
break;
case 1:
if (target) {
- if ((size_t)tarindex + 1 >= targsize)
+ if ((size_t)tarindex >= targsize)
return (-1);
target[tarindex] |= (pos - Base64) >> 4;
- target[tarindex+1] = ((pos - Base64) & 0x0f)
- << 4 ;
+ nextbyte = ((pos - Base64) & 0x0f) << 4;
+ if ((size_t)tarindex + 1 < targsize)
+ target[tarindex + 1] = nextbyte;
+ else if (nextbyte)
+ return (-1);
}
tarindex++;
state = 2;
@@ -237,11 +239,14 @@
break;
case 2:
if (target) {
- if ((size_t)tarindex + 1 >= targsize)
+ if ((size_t)tarindex >= targsize)
return (-1);
target[tarindex] |= (pos - Base64) >> 2;
- target[tarindex+1] = ((pos - Base64) & 0x03)
- << 6;
+ nextbyte = ((pos - Base64) & 0x03) << 6;
+ if ((size_t)tarindex + 1 < targsize)
+ target[tarindex + 1] = nextbyte;
+ else if (nextbyte)
+ return (-1);
}
tarindex++;
state = 3;
@@ -299,7 +304,8 @@
* zeros. If we don't check them, they become a
* subliminal channel.
*/
- if (target && target[tarindex] != 0)
+ if (target && (size_t)tarindex < targsize &&
+ target[tarindex] != 0)
return (-1);
}
} else {
Modified: trunk/lib/libc/net/byteorder.3
===================================================================
--- trunk/lib/libc/net/byteorder.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/byteorder.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)byteorder.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/byteorder.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd March 20, 2005
.Dt BYTEORDER 3
Modified: trunk/lib/libc/net/ether_addr.c
===================================================================
--- trunk/lib/libc/net/ether_addr.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/ether_addr.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1995 Bill Paul <wpaul at ctr.columbia.edu>.
* Copyright (c) 2007 Robert N. M. Watson
@@ -38,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/ether_addr.c 264592 2014-04-17 11:49:19Z jmmv $");
#include <sys/types.h>
#include <sys/param.h>
@@ -72,11 +73,13 @@
i = sscanf(l, "%x:%x:%x:%x:%x:%x %s", &o[0], &o[1], &o[2], &o[3],
&o[4], &o[5], hostname);
- if (i != 7)
- return (i);
- for (i=0; i<6; i++)
- e->octet[i] = o[i];
- return (0);
+ if (i == 7) {
+ for (i = 0; i < 6; i++)
+ e->octet[i] = o[i];
+ return (0);
+ } else {
+ return (-1);
+ }
}
/*
@@ -148,7 +151,7 @@
char *yp_domain;
#endif
- if ((fp = fopen(_PATH_ETHERS, "r")) == NULL)
+ if ((fp = fopen(_PATH_ETHERS, "re")) == NULL)
return (1);
while (fgets(buf,BUFSIZ,fp)) {
if (buf[0] == '#')
@@ -197,7 +200,7 @@
char *yp_domain;
#endif
- if ((fp = fopen(_PATH_ETHERS, "r")) == NULL)
+ if ((fp = fopen(_PATH_ETHERS, "re")) == NULL)
return (1);
while (fgets(buf,BUFSIZ,fp)) {
if (buf[0] == '#')
Modified: trunk/lib/libc/net/ethers.3
===================================================================
--- trunk/lib/libc/net/ethers.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/ethers.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1995 Bill Paul <wpaul at ctr.columbia.edu>.
.\" Copyright (c) 2007 Robert N. M. Watson
.\" All rights reserved.
@@ -29,7 +30,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/ethers.3 224701 2011-08-08 03:09:03Z hrs $
.\"
.Dd October 30, 2007
.Dt ETHERS 3
Modified: trunk/lib/libc/net/eui64.3
===================================================================
--- trunk/lib/libc/net/eui64.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/eui64.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright 2004 The Aerospace Corporation. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -54,7 +55,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/eui64.3 231196 2012-02-08 11:30:13Z brooks $
.\"
.Dd March 4, 2004
.Dt EUI64 3
Modified: trunk/lib/libc/net/eui64.c
===================================================================
--- trunk/lib/libc/net/eui64.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/eui64.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright 2004 The Aerospace Corporation. All rights reserved.
*
@@ -68,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/eui64.c 254700 2013-08-23 13:59:47Z jilles $");
#include <stdio.h>
#include <paths.h>
@@ -227,7 +228,7 @@
char eui64_a[24];
char *yp_domain;
#endif
- if ((fp = fopen(_PATH_EUI64, "r")) == NULL)
+ if ((fp = fopen(_PATH_EUI64, "re")) == NULL)
return (1);
while (fgets(buf,BUFSIZ,fp)) {
@@ -277,7 +278,7 @@
int resultlen;
char *yp_domain;
#endif
- if ((fp = fopen(_PATH_EUI64, "r")) == NULL)
+ if ((fp = fopen(_PATH_EUI64, "re")) == NULL)
return (1);
while (fgets(buf,BUFSIZ,fp)) {
Modified: trunk/lib/libc/net/gai_strerror.3
===================================================================
--- trunk/lib/libc/net/gai_strerror.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/gai_strerror.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $KAME: gai_strerror.3,v 1.1 2005/01/05 03:04:47 itojun Exp $
.\" $OpenBSD: gai_strerror.3,v 1.4 2004/12/20 23:04:53 millert Exp $
.\"
@@ -16,7 +17,7 @@
.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/gai_strerror.3 162385 2006-09-17 21:27:35Z ru $
.\"
.Dd May 21, 2006
.Dt GAI_STRERROR 3
Modified: trunk/lib/libc/net/gai_strerror.c
===================================================================
--- trunk/lib/libc/net/gai_strerror.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/gai_strerror.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
@@ -28,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/gai_strerror.c 199083 2009-11-09 12:46:59Z ume $");
#include "namespace.h"
#include <netdb.h>
Modified: trunk/lib/libc/net/getaddrinfo.3
===================================================================
--- trunk/lib/libc/net/getaddrinfo.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getaddrinfo.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $KAME: getaddrinfo.3,v 1.36 2005/01/05 03:23:05 itojun Exp $
.\" $OpenBSD: getaddrinfo.3,v 1.35 2004/12/21 03:40:31 jaredy Exp $
.\"
@@ -16,9 +17,9 @@
.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/getaddrinfo.3 292760 2015-12-27 00:37:04Z ume $
.\"
-.Dd February 14, 2013
+.Dd December 21, 2015
.Dt GETADDRINFO 3
.Os
.Sh NAME
@@ -26,9 +27,9 @@
.Nm freeaddrinfo
.Nd socket address structure to host and service name
.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/socket.h>
-.Fd #include <netdb.h>
+.In sys/types.h
+.In sys/socket.h
+.In netdb.h
.Ft int
.Fo getaddrinfo
.Fa "const char *hostname" "const char *servname"
@@ -78,7 +79,7 @@
.Bd -literal
struct addrinfo {
int ai_flags; /* input flags */
- int ai_family; /* protocol family for socket */
+ int ai_family; /* address family for socket */
int ai_socktype; /* socket type */
int ai_protocol; /* protocol for socket */
socklen_t ai_addrlen; /* length of socket-address */
@@ -94,12 +95,12 @@
.Fa hints :
.Bl -tag -width "ai_socktypeXX"
.It Fa ai_family
-The protocol family that should be used.
+The address family that should be used.
When
.Fa ai_family
is set to
-.Dv PF_UNSPEC ,
-it means the caller will accept any protocol family supported by the
+.Dv AF_UNSPEC ,
+it means the caller will accept any address family supported by the
operating system.
.It Fa ai_socktype
Denotes the type of socket that is wanted:
@@ -126,11 +127,13 @@
parameter points shall be set to zero
or be the bitwise-inclusive OR of one or more of the values
.Dv AI_ADDRCONFIG ,
+.Dv AI_ALL ,
.Dv AI_CANONNAME ,
.Dv AI_NUMERICHOST ,
-.Dv AI_NUMERICSERV
+.Dv AI_NUMERICSERV ,
+.Dv AI_PASSIVE
and
-.Dv AI_PASSIVE .
+.Dv AI_V4MAPPED .
.Bl -tag -width "AI_CANONNAMEXX"
.It Dv AI_ADDRCONFIG
If the
@@ -139,6 +142,25 @@
an IPv4 address is configured on the local system,
and IPv6 addresses shall be returned only if
an IPv6 address is configured on the local system.
+.It Dv AI_ALL
+If the
+.Dv AI_ALL
+flag is used with the
+.Dv AI_V4MAPPED
+flag, then
+.Fn getaddrinfo
+shall return all matching IPv6 and IPv4 addresses.
+.Pp
+For example, when using the DNS, queries are made for both AAAA records and A records, and
+.Fn getaddrinfo
+returns the combined results of both queries.
+Any IPv4 addresses found are returned as IPv4-mapped IPv6 addresses.
+.Pp
+The
+.Dv AI_ALL
+flag without the
+.Dv AI_V4MAPPED
+flag is ignored.
.It Dv AI_CANONNAME
If the
.Dv AI_CANONNAME
@@ -203,6 +225,25 @@
is the null pointer and
.Dv AI_PASSIVE
is not set.
+.It Dv AI_V4MAPPED
+If the
+.Dv AI_V4MAPPED
+flag is specified along with an ai_family of
+.Dv AF_INET6 ,
+then
+.Fn getaddrinfo
+shall return IPv4-mapped IPv6 addresses on finding no matching IPv6 addresses (
+.Fa ai_addrlen
+shall be 16).
+.Pp
+For example, when using the DNS, if no AAAA records are found then a query is made for A records and any found are returned as IPv4-mapped IPv6 addresses.
+.Pp
+The
+.Dv AI_V4MAPPED
+flag shall be ignored unless
+.Fa ai_family
+equals
+.Dv AF_INET6 .
.El
.El
.Pp
@@ -221,7 +262,7 @@
with
.Fa ai_family
set to
-.Dv PF_UNSPEC
+.Dv AF_UNSPEC
and all other elements set to zero or
.Dv NULL .
.Pp
@@ -236,15 +277,14 @@
pointer in each
.Li addrinfo
structure until a null pointer is encountered.
-The three members
+Each returned
+.Li addrinfo
+structure contains three members that are suitable for a call to
+.Xr socket 2 :
.Fa ai_family,
.Fa ai_socktype,
and
-.Fa ai_protocol
-in each returned
-.Li addrinfo
-structure are suitable for a call to
-.Xr socket 2 .
+.Fa ai_protocol .
For each
.Li addrinfo
structure in the list, the
@@ -334,7 +374,7 @@
const char *cause = NULL;
memset(&hints, 0, sizeof(hints));
-hints.ai_family = PF_UNSPEC;
+hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo("www.kame.net", "http", &hints, &res0);
if (error) {
@@ -377,7 +417,7 @@
const char *cause = NULL;
memset(&hints, 0, sizeof(hints));
-hints.ai_family = PF_UNSPEC;
+hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
error = getaddrinfo(NULL, "http", &hints, &res0);
Modified: trunk/lib/libc/net/getaddrinfo.c
===================================================================
--- trunk/lib/libc/net/getaddrinfo.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getaddrinfo.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $KAME: getaddrinfo.c,v 1.15 2000/07/09 04:37:24 itojun Exp $ */
/*
@@ -54,7 +55,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/getaddrinfo.c 327238 2017-12-27 14:50:07Z ume $");
#include "namespace.h"
#include <sys/types.h>
@@ -62,12 +63,15 @@
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
+#include <net/if_types.h>
+#include <ifaddrs.h>
#include <sys/queue.h>
#ifdef INET6
#include <net/if_var.h>
#include <sys/sysctl.h>
#include <sys/ioctl.h>
-#include <netinet6/in6_var.h> /* XXX */
+#include <netinet6/in6_var.h>
+#include <netinet6/nd6.h>
#endif
#include <arpa/inet.h>
#include <arpa/nameser.h>
@@ -93,6 +97,7 @@
#include <stdarg.h>
#include <nsswitch.h>
#include "un-namespace.h"
+#include "netdb_private.h"
#include "libc_private.h"
#ifdef NS_CACHING
#include "nscache.h"
@@ -155,7 +160,6 @@
int e_af;
int e_socktype;
int e_protocol;
- const char *e_protostr;
int e_wild;
#define WILD_AF(ex) ((ex)->e_wild & 0x01)
#define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02)
@@ -164,21 +168,23 @@
static const struct explore explore[] = {
#if 0
- { PF_LOCAL, ANY, ANY, NULL, 0x01 },
+ { PF_LOCAL, ANY, ANY, 0x01 },
#endif
#ifdef INET6
- { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
- { PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
- { PF_INET6, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x03 },
- { PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 },
- { PF_INET6, SOCK_RAW, ANY, NULL, 0x05 },
+ { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, 0x07 },
+ { PF_INET6, SOCK_STREAM, IPPROTO_TCP, 0x07 },
+ { PF_INET6, SOCK_STREAM, IPPROTO_SCTP, 0x03 },
+ { PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, 0x07 },
+ { PF_INET6, SOCK_DGRAM, IPPROTO_UDPLITE, 0x03 },
+ { PF_INET6, SOCK_RAW, ANY, 0x05 },
#endif
- { PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
- { PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
- { PF_INET, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x03 },
- { PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 },
- { PF_INET, SOCK_RAW, ANY, NULL, 0x05 },
- { -1, 0, 0, NULL, 0 },
+ { PF_INET, SOCK_DGRAM, IPPROTO_UDP, 0x07 },
+ { PF_INET, SOCK_STREAM, IPPROTO_TCP, 0x07 },
+ { PF_INET, SOCK_STREAM, IPPROTO_SCTP, 0x03 },
+ { PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP, 0x07 },
+ { PF_INET, SOCK_DGRAM, IPPROTO_UDPLITE, 0x03 },
+ { PF_INET, SOCK_RAW, ANY, 0x05 },
+ { -1, 0, 0, 0 },
};
#ifdef INET6
@@ -202,6 +208,7 @@
struct policyqueue *aio_dstpolicy;
struct addrinfo *aio_ai;
int aio_matchlen;
+ int aio_initial_sequence;
};
static const ns_src default_dns_files[] = {
@@ -244,6 +251,9 @@
static int get_port(struct addrinfo *, const char *, int);
static const struct afd *find_afd(int);
static int addrconfig(struct addrinfo *);
+#ifdef INET6
+static int is_ifdisabled(char *);
+#endif
static void set_source(struct ai_order *, struct policyhead *);
static int comp_dst(const void *, const void *);
#ifdef INET6
@@ -444,6 +454,24 @@
}
/*
+ * RFC 3493: AI_ALL and AI_V4MAPPED are effective only against
+ * AF_INET6 query. They need to be ignored if specified in other
+ * occassions.
+ */
+ switch (pai->ai_flags & (AI_ALL | AI_V4MAPPED)) {
+ case AI_V4MAPPED:
+ case AI_ALL | AI_V4MAPPED:
+#ifdef INET6
+ if (pai->ai_family != AF_INET6)
+ pai->ai_flags &= ~(AI_ALL | AI_V4MAPPED);
+ break;
+#endif
+ case AI_ALL:
+ pai->ai_flags &= ~(AI_ALL | AI_V4MAPPED);
+ break;
+ }
+
+ /*
* check for special cases. (1) numeric servname is disallowed if
* socktype/protocol are left unspecified. (2) servname is disallowed
* for raw and other inet{,6} sockets.
@@ -646,9 +674,8 @@
return(n);
/* allocate a temporary array for sort and initialization of it. */
- if ((aio = malloc(sizeof(*aio) * n)) == NULL)
+ if ((aio = calloc(n, sizeof(*aio))) == NULL)
return(n); /* give up reordering */
- memset(aio, 0, sizeof(*aio) * n);
/* retrieve address selection policy from the kernel */
TAILQ_INIT(&policyhead);
@@ -664,6 +691,7 @@
aio[i].aio_dstpolicy = match_addrselectpolicy(ai->ai_addr,
&policyhead);
set_source(&aio[i], &policyhead);
+ aio[i].aio_initial_sequence = i;
}
/* perform sorting. */
@@ -752,10 +780,9 @@
memset(&key, 0, sizeof(key));
key.sin6_family = AF_INET6;
key.sin6_len = sizeof(key);
- key.sin6_addr.s6_addr[10] = 0xff;
- key.sin6_addr.s6_addr[11] = 0xff;
- memcpy(&key.sin6_addr.s6_addr[12],
- &((struct sockaddr_in *)addr)->sin_addr, 4);
+ _map_v4v6_address(
+ (char *)&((struct sockaddr_in *)addr)->sin_addr,
+ (char *)&key.sin6_addr);
break;
default:
return(NULL);
@@ -832,8 +859,19 @@
get_port(&ai, "1", 0);
/* open a socket to get the source address for the given dst */
- if ((s = _socket(ai.ai_family, ai.ai_socktype, ai.ai_protocol)) < 0)
+ if ((s = _socket(ai.ai_family, ai.ai_socktype | SOCK_CLOEXEC,
+ ai.ai_protocol)) < 0)
return; /* give up */
+#ifdef INET6
+ if (ai.ai_family == AF_INET6) {
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)ai.ai_addr;
+ int off = 0;
+
+ if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
+ (void)_setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
+ (char *)&off, sizeof(off));
+ }
+#endif
if (_connect(s, ai.ai_addr, ai.ai_addrlen) < 0)
goto cleanup;
srclen = ai.ai_addrlen;
@@ -893,7 +931,7 @@
while (s < lim)
if ((r = (*d++ ^ *s++)) != 0) {
- while (r < addrlen * 8) {
+ while ((r & 0x80) == 0) {
match++;
r <<= 1;
}
@@ -1001,7 +1039,8 @@
* We compare the match length in a same AF only.
*/
if (dst1->aio_ai->ai_addr->sa_family ==
- dst2->aio_ai->ai_addr->sa_family) {
+ dst2->aio_ai->ai_addr->sa_family &&
+ dst1->aio_ai->ai_addr->sa_family != AF_INET) {
if (dst1->aio_matchlen > dst2->aio_matchlen) {
return(-1);
}
@@ -1011,6 +1050,23 @@
}
/* Rule 10: Otherwise, leave the order unchanged. */
+
+ /*
+ * Note that qsort is unstable; so, we can't return zero and
+ * expect the order to be unchanged.
+ * That also means we can't depend on the current position of
+ * dst2 being after dst1. We must enforce the initial order
+ * with an explicit compare on the original position.
+ * The qsort specification requires that "When the same objects
+ * (consisting of width bytes, irrespective of their current
+ * positions in the array) are passed more than once to the
+ * comparison function, the results shall be consistent with one
+ * another."
+ * In other words, If A < B, then we must also return B > A.
+ */
+ if (dst2->aio_initial_sequence < dst1->aio_initial_sequence)
+ return(1);
+
return(-1);
}
@@ -1132,7 +1188,7 @@
* filter out AFs that are not supported by the kernel
* XXX errno?
*/
- s = _socket(pai->ai_family, SOCK_DGRAM, 0);
+ s = _socket(pai->ai_family, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (s < 0) {
if (errno != EMFILE)
return 0;
@@ -1168,7 +1224,7 @@
const char *servname, struct addrinfo **res, const char *canonname)
{
const struct afd *afd;
- struct addrinfo *ai;
+ struct addrinfo *ai, ai0;
int error;
char pton[PTON_MAX];
@@ -1188,12 +1244,22 @@
* does not accept. So we need to separate the case for
* AF_INET.
*/
- if (inet_aton(hostname, (struct in_addr *)pton) != 1)
+ if (inet_aton(hostname, (struct in_addr *)pton) != 1 ||
+ hostname[strspn(hostname, "0123456789.xabcdefXABCDEF")] != '\0')
return 0;
break;
default:
- if (inet_pton(afd->a_af, hostname, pton) != 1)
- return 0;
+ if (inet_pton(afd->a_af, hostname, pton) != 1) {
+ if (pai->ai_family != AF_INET6 ||
+ (pai->ai_flags & AI_V4MAPPED) != AI_V4MAPPED)
+ return 0;
+ if (inet_aton(hostname, (struct in_addr *)pton) != 1)
+ return 0;
+ afd = &afdl[N_INET];
+ ai0 = *pai;
+ ai0.ai_family = AF_INET;
+ pai = &ai0;
+ }
break;
}
@@ -1302,20 +1368,6 @@
return 0;
}
-struct addrinfo *
-allocaddrinfo(socklen_t addrlen)
-{
- struct addrinfo *ai;
-
- ai = calloc(sizeof(struct addrinfo) + addrlen, 1);
- if (ai) {
- ai->ai_addr = (void *)(ai+1);
- ai->ai_addrlen = ai->ai_addr->sa_len = addrlen;
- }
-
- return ai;
-}
-
static struct addrinfo *
get_ai(const struct addrinfo *pai, const struct afd *afd, const char *addr)
{
@@ -1326,6 +1378,9 @@
char *fp_str;
int translate = 0;
#endif
+#ifdef INET6
+ struct in6_addr mapaddr;
+#endif
#ifdef FAITH
/*
@@ -1363,6 +1418,14 @@
}
#endif
+#ifdef INET6
+ if (afd->a_af == AF_INET && (pai->ai_flags & AI_V4MAPPED) != 0) {
+ afd = &afdl[N_INET6];
+ _map_v4v6_address(addr, (char *)&mapaddr);
+ addr = (char *)&mapaddr;
+ }
+#endif
+
ai = (struct addrinfo *)malloc(sizeof(struct addrinfo)
+ (afd->a_socklen));
if (ai == NULL)
@@ -1392,9 +1455,8 @@
size_t l;
l = sizeof(*ai) + pai->ai_addrlen;
- if ((ai = (struct addrinfo *)malloc(l)) == NULL)
+ if ((ai = calloc(1, l)) == NULL)
return NULL;
- memset(ai, 0, l);
memcpy(ai, pai, sizeof(*ai));
ai->ai_addr = (struct sockaddr *)(void *)(ai + 1);
memcpy(ai->ai_addr, pai->ai_addr, pai->ai_addrlen);
@@ -1491,6 +1553,9 @@
case IPPROTO_SCTP:
proto = "sctp";
break;
+ case IPPROTO_UDPLITE:
+ proto = "udplite";
+ break;
default:
proto = NULL;
break;
@@ -1534,10 +1599,11 @@
}
/*
- * post-2553: AI_ADDRCONFIG check. if we use getipnodeby* as backend, backend
- * will take care of it.
- * the semantics of AI_ADDRCONFIG is not defined well. we are not sure
- * if the code is right or not.
+ * RFC 3493: AI_ADDRCONFIG check. Determines which address families are
+ * configured on the local system and correlates with pai->ai_family value.
+ * If an address family is not configured on the system, it will not be
+ * queried for. For this purpose, loopback addresses are not considered
+ * configured addresses.
*
* XXX PF_UNSPEC -> PF_INET6 + PF_INET mapping needs to be in sync with
* _dns_getaddrinfo.
@@ -1545,37 +1611,80 @@
static int
addrconfig(struct addrinfo *pai)
{
- int s, af;
+ struct ifaddrs *ifaddrs, *ifa;
+ struct sockaddr_in *sin;
+#ifdef INET6
+ struct sockaddr_in6 *sin6;
+#endif
+ int seen_inet = 0, seen_inet6 = 0;
- /*
- * TODO:
- * Note that implementation dependent test for address
- * configuration should be done everytime called
- * (or apropriate interval),
- * because addresses will be dynamically assigned or deleted.
- */
- af = pai->ai_family;
- if (af == AF_UNSPEC) {
- if ((s = _socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
- af = AF_INET;
- else {
- _close(s);
- if ((s = _socket(AF_INET, SOCK_DGRAM, 0)) < 0)
- af = AF_INET6;
- else
- _close(s);
+ if (getifaddrs(&ifaddrs) != 0)
+ return (0);
+
+ for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) {
+ if (ifa->ifa_addr == NULL || (ifa->ifa_flags & IFF_UP) == 0)
+ continue;
+ switch (ifa->ifa_addr->sa_family) {
+ case AF_INET:
+ if (seen_inet)
+ continue;
+ sin = (struct sockaddr_in *)(ifa->ifa_addr);
+ if (htonl(sin->sin_addr.s_addr) == INADDR_LOOPBACK)
+ continue;
+ seen_inet = 1;
+ break;
+#ifdef INET6
+ case AF_INET6:
+ if (seen_inet6)
+ continue;
+ sin6 = (struct sockaddr_in6 *)(ifa->ifa_addr);
+ if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
+ continue;
+ if ((ifa->ifa_flags & IFT_LOOP) != 0 &&
+ IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))
+ continue;
+ if (is_ifdisabled(ifa->ifa_name))
+ continue;
+ seen_inet6 = 1;
+ break;
+#endif
}
}
- if (af != AF_UNSPEC) {
- if ((s = _socket(af, SOCK_DGRAM, 0)) < 0)
- return 0;
- _close(s);
+ freeifaddrs(ifaddrs);
+
+ switch(pai->ai_family) {
+ case AF_INET6:
+ return (seen_inet6);
+ case AF_INET:
+ return (seen_inet);
+ case AF_UNSPEC:
+ if (seen_inet == seen_inet6)
+ return (seen_inet);
+ pai->ai_family = seen_inet ? AF_INET : AF_INET6;
+ return (1);
}
- pai->ai_family = af;
- return 1;
+ return (1);
}
#ifdef INET6
+static int
+is_ifdisabled(char *name)
+{
+ struct in6_ndireq nd;
+ int fd;
+
+ if ((fd = _socket(AF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0)) < 0)
+ return (-1);
+ memset(&nd, 0, sizeof(nd));
+ strlcpy(nd.ifname, name, sizeof(nd.ifname));
+ if (_ioctl(fd, SIOCGIFINFO_IN6, &nd) < 0) {
+ _close(fd);
+ return (-1);
+ }
+ _close(fd);
+ return ((nd.ndi.flags & ND6_IFF_IFDISABLED) != 0);
+}
+
/* convert a string to a scope identifier. XXX: IPv6 specific */
static int
ip6_str2scopeid(char *scope, struct sockaddr_in6 *sin6, u_int32_t *scopeid)
@@ -1767,8 +1876,7 @@
size = new_ai.ai_addrlen + sizeof(struct addrinfo) +
_ALIGNBYTES;
- sentinel = (struct addrinfo *)malloc(size);
- memset(sentinel, 0, size);
+ sentinel = calloc(1, size);
memcpy(sentinel, &new_ai, sizeof(struct addrinfo));
sentinel->ai_addr = (struct sockaddr *)_ALIGN((char *)sentinel +
@@ -1781,8 +1889,7 @@
memcpy(&size, p, sizeof(size_t));
p += sizeof(size_t);
- sentinel->ai_canonname = (char *)malloc(size + 1);
- memset(sentinel->ai_canonname, 0, size + 1);
+ sentinel->ai_canonname = calloc(1, size + 1);
memcpy(sentinel->ai_canonname, p, size);
p += size;
@@ -2075,7 +2182,11 @@
return sentinel.ai_next;
}
- RES_SET_H_ERRNO(res, NO_RECOVERY);
+ /*
+ * We could have walked a CNAME chain, but the ultimate target
+ * may not have what we looked for.
+ */
+ RES_SET_H_ERRNO(res, ntohs(hp->ancount) > 0 ? NO_DATA : NO_RECOVERY);
return NULL;
}
@@ -2149,7 +2260,7 @@
static int
_dns_getaddrinfo(void *rv, void *cb_data, va_list ap)
{
- struct addrinfo *ai;
+ struct addrinfo *ai, ai0;
querybuf *buf, *buf2;
const char *hostname;
const struct addrinfo *pai;
@@ -2157,6 +2268,8 @@
struct res_target q, q2;
res_state res;
+ ai = NULL;
+
hostname = va_arg(ap, char *);
pai = va_arg(ap, const struct addrinfo *);
@@ -2165,6 +2278,8 @@
memset(&sentinel, 0, sizeof(sentinel));
cur = &sentinel;
+ res = __res_state();
+
buf = malloc(sizeof(*buf));
if (!buf) {
RES_SET_H_ERRNO(res, NETDB_INTERNAL);
@@ -2177,6 +2292,13 @@
return NS_NOTFOUND;
}
+ if (pai->ai_family == AF_INET6 &&
+ (pai->ai_flags & AI_V4MAPPED) == AI_V4MAPPED) {
+ ai0 = *pai;
+ ai0.ai_family = AF_UNSPEC;
+ pai = &ai0;
+ }
+
switch (pai->ai_family) {
case AF_UNSPEC:
q.name = hostname;
@@ -2211,7 +2333,6 @@
return NS_UNAVAIL;
}
- res = __res_state();
if ((res->options & RES_INIT) == 0 && res_ninit(res) == -1) {
RES_SET_H_ERRNO(res, NETDB_INTERNAL);
free(buf);
@@ -2227,20 +2348,24 @@
/* prefer IPv6 */
if (q.next) {
ai = getanswer(buf2, q2.n, q2.name, q2.qtype, pai, res);
- if (ai) {
+ if (ai != NULL) {
cur->ai_next = ai;
while (cur && cur->ai_next)
cur = cur->ai_next;
}
}
- ai = getanswer(buf, q.n, q.name, q.qtype, pai, res);
- if (ai)
- cur->ai_next = ai;
+ if (ai == NULL || pai->ai_family != AF_UNSPEC ||
+ (pai->ai_flags & (AI_ALL | AI_V4MAPPED)) != AI_V4MAPPED) {
+ ai = getanswer(buf, q.n, q.name, q.qtype, pai, res);
+ if (ai != NULL)
+ cur->ai_next = ai;
+ }
free(buf);
free(buf2);
if (sentinel.ai_next == NULL)
switch (res->res_h_errno) {
case HOST_NOT_FOUND:
+ case NO_DATA:
return NS_NOTFOUND;
case TRY_AGAIN:
return NS_TRYAGAIN;
@@ -2255,7 +2380,7 @@
_sethtent(FILE **hostf)
{
if (!*hostf)
- *hostf = fopen(_PATH_HOSTS, "r");
+ *hostf = fopen(_PATH_HOSTS, "re");
else
rewind(*hostf);
}
@@ -2279,7 +2404,7 @@
const char *addr;
char hostbuf[8*1024];
- if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "r")))
+ if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "re")))
return (NULL);
again:
if (!(p = fgets(hostbuf, sizeof hostbuf, *hostf)))
@@ -2317,6 +2442,9 @@
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = 0;
hints.ai_flags = AI_NUMERICHOST;
+ if (pai->ai_family == AF_INET6 &&
+ (pai->ai_flags & AI_V4MAPPED) == AI_V4MAPPED)
+ hints.ai_flags |= AI_V4MAPPED;
error = getaddrinfo(addr, "0", &hints, &res0);
if (error)
goto again;
@@ -2344,6 +2472,20 @@
return res0;
}
+static struct addrinfo *
+_getht(FILE **hostf, const char *name, const struct addrinfo *pai,
+ struct addrinfo *cur)
+{
+ struct addrinfo *p;
+
+ while ((p = _gethtent(hostf, name, pai)) != NULL) {
+ cur->ai_next = p;
+ while (cur && cur->ai_next)
+ cur = cur->ai_next;
+ }
+ return (cur);
+}
+
/*ARGSUSED*/
static int
_files_getaddrinfo(void *rv, void *cb_data, va_list ap)
@@ -2351,7 +2493,6 @@
const char *name;
const struct addrinfo *pai;
struct addrinfo sentinel, *cur;
- struct addrinfo *p;
FILE *hostf = NULL;
name = va_arg(ap, char *);
@@ -2361,11 +2502,19 @@
cur = &sentinel;
_sethtent(&hostf);
- while ((p = _gethtent(&hostf, name, pai)) != NULL) {
- cur->ai_next = p;
- while (cur && cur->ai_next)
- cur = cur->ai_next;
- }
+ if (pai->ai_family == AF_INET6 &&
+ (pai->ai_flags & (AI_ALL | AI_V4MAPPED)) == AI_V4MAPPED) {
+ struct addrinfo ai0 = *pai;
+
+ ai0.ai_flags &= ~AI_V4MAPPED;
+ cur = _getht(&hostf, name, &ai0, cur);
+ if (sentinel.ai_next == NULL) {
+ _sethtent(&hostf);
+ ai0.ai_flags |= AI_V4MAPPED;
+ cur = _getht(&hostf, name, &ai0, cur);
+ }
+ } else
+ cur = _getht(&hostf, name, pai, cur);
_endhtent(&hostf);
*((struct addrinfo **)rv) = sentinel.ai_next;
@@ -2425,6 +2574,9 @@
hints = *pai;
hints.ai_flags = AI_NUMERICHOST;
+ if (pai->ai_family == AF_INET6 &&
+ (pai->ai_flags & AI_V4MAPPED) == AI_V4MAPPED)
+ hints.ai_flags |= AI_V4MAPPED;
error = getaddrinfo(addr, NULL, &hints, &res0);
if (error == 0) {
for (res = res0; res; res = res->ai_next) {
@@ -2472,8 +2624,38 @@
memset(&sentinel, 0, sizeof(sentinel));
cur = &sentinel;
+ /* ipnodes.byname can hold both IPv4/v6 */
+ r = yp_match(ypdomain, "ipnodes.byname", name,
+ (int)strlen(name), &ypbuf, &ypbuflen);
+ if (r == 0) {
+ ai = _yphostent(ypbuf, pai);
+ if (ai) {
+ cur->ai_next = ai;
+ while (cur && cur->ai_next)
+ cur = cur->ai_next;
+ }
+ free(ypbuf);
+ }
+
+ if (ai != NULL) {
+ struct sockaddr_in6 *sin6;
+
+ switch (ai->ai_family) {
+ case AF_INET:
+ goto done;
+ case AF_INET6:
+ sin6 = (struct sockaddr_in6 *)ai->ai_addr;
+ if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
+ goto done;
+ break;
+ }
+ }
+
/* hosts.byname is only for IPv4 (Solaris8) */
- if (pai->ai_family == PF_UNSPEC || pai->ai_family == PF_INET) {
+ if (pai->ai_family == AF_UNSPEC || pai->ai_family == AF_INET ||
+ ((pai->ai_family == AF_INET6 &&
+ (pai->ai_flags & AI_V4MAPPED) == AI_V4MAPPED) &&
+ (ai == NULL || (pai->ai_flags & AI_ALL) == AI_ALL))) {
r = yp_match(ypdomain, "hosts.byname", name,
(int)strlen(name), &ypbuf, &ypbuflen);
if (r == 0) {
@@ -2480,7 +2662,8 @@
struct addrinfo ai4;
ai4 = *pai;
- ai4.ai_family = AF_INET;
+ if (pai->ai_family == AF_UNSPEC)
+ ai4.ai_family = AF_INET;
ai = _yphostent(ypbuf, &ai4);
if (ai) {
cur->ai_next = ai;
@@ -2491,16 +2674,7 @@
}
}
- /* ipnodes.byname can hold both IPv4/v6 */
- r = yp_match(ypdomain, "ipnodes.byname", name,
- (int)strlen(name), &ypbuf, &ypbuflen);
- if (r == 0) {
- ai = _yphostent(ypbuf, pai);
- if (ai)
- cur->ai_next = ai;
- free(ypbuf);
- }
-
+done:
if (sentinel.ai_next == NULL) {
RES_SET_H_ERRNO(__res_state(), HOST_NOT_FOUND);
return NS_NOTFOUND;
Modified: trunk/lib/libc/net/gethostbydns.c
===================================================================
--- trunk/lib/libc/net/gethostbydns.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/gethostbydns.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* ++Copyright++ 1985, 1988, 1993
* -
@@ -54,7 +55,7 @@
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>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/gethostbydns.c 211340 2010-08-15 16:28:08Z ume $");
#include <sys/types.h>
#include <sys/param.h>
Modified: trunk/lib/libc/net/gethostbyht.c
===================================================================
--- trunk/lib/libc/net/gethostbyht.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/gethostbyht.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1985, 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -51,7 +52,7 @@
static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/gethostbyht.c 254700 2013-08-23 13:59:47Z jilles $");
#include <sys/param.h>
#include <sys/socket.h>
@@ -72,7 +73,7 @@
_sethosthtent(int f, struct hostent_data *hed)
{
if (!hed->hostf)
- hed->hostf = fopen(_PATH_HOSTS, "r");
+ hed->hostf = fopen(_PATH_HOSTS, "re");
else
rewind(hed->hostf);
hed->stayopen = f;
@@ -96,7 +97,7 @@
int af, len;
char hostbuf[BUFSIZ + 1];
- if (!hed->hostf && !(hed->hostf = fopen(_PATH_HOSTS, "r"))) {
+ if (!hed->hostf && !(hed->hostf = fopen(_PATH_HOSTS, "re"))) {
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
return (-1);
}
Modified: trunk/lib/libc/net/gethostbyname.3
===================================================================
--- trunk/lib/libc/net/gethostbyname.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/gethostbyname.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1987, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/gethostbyname.3 324515 2017-10-11 05:07:37Z cy $
.\"
-.Dd May 12, 2006
+.Dd October 4, 2017
.Dt GETHOSTBYNAME 3
.Os
.Sh NAME
@@ -51,7 +52,7 @@
.Ft struct hostent *
.Fn gethostbyname2 "const char *name" "int af"
.Ft struct hostent *
-.Fn gethostbyaddr "const void *addr" "socklen_t len" "int type"
+.Fn gethostbyaddr "const void *addr" "socklen_t len" "int af"
.Ft struct hostent *
.Fn gethostent void
.Ft void
@@ -107,7 +108,7 @@
.Tn ASCII
form).
The
-.Fa type
+.Fa af
argument specifies the address family
(e.g.\&
.Dv AF_INET , AF_INET6 ,
@@ -189,19 +190,20 @@
may be used to request the use of a connected
.Tn TCP
socket for queries.
+Queries will by default use
+.Tn UDP
+datagrams.
If the
.Fa stayopen
-flag is non-zero,
-this sets the option to send all queries to the name server using
+flag is non-zero, a
.Tn TCP
-and to retain the connection after each call to
+connection to the name server will be used.
+It will remain open after calls to
.Fn gethostbyname ,
.Fn gethostbyname2
or
-.Fn gethostbyaddr .
-Otherwise, queries are performed using
-.Tn UDP
-datagrams.
+.Fn gethostbyaddr
+have completed.
.Pp
The
.Fn endhostent
Modified: trunk/lib/libc/net/gethostbynis.c
===================================================================
--- trunk/lib/libc/net/gethostbynis.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/gethostbynis.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1994, Garrett Wollman
*
@@ -24,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/gethostbynis.c 293023 2016-01-01 00:35:06Z ume $");
#include <sys/param.h>
#include <sys/socket.h>
@@ -91,7 +92,7 @@
free(result);
result = (char *)&ypbuf;
- if ((cp = index(result, '\n')))
+ if ((cp = strchr(result, '\n')))
*cp = '\0';
cp = strpbrk(result, " \t");
@@ -198,61 +199,6 @@
}
#endif /* YP */
-/* XXX _gethostbynisname/_gethostbynisaddr only used by getipnodeby*() */
-struct hostent *
-_gethostbynisname(const char *name, int af)
-{
-#ifdef YP
- struct hostent *he;
- struct hostent_data *hed;
- u_long oresopt;
- int error;
- res_state statp;
-
- statp = __res_state();
- if ((he = __hostent_init()) == NULL ||
- (hed = __hostent_data_init()) == NULL) {
- RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
- return (NULL);
- }
-
- oresopt = statp->options;
- statp->options &= ~RES_USE_INET6;
- error = _gethostbynisname_r(name, af, he, hed);
- statp->options = oresopt;
- return (error == 0) ? he : NULL;
-#else
- return (NULL);
-#endif
-}
-
-struct hostent *
-_gethostbynisaddr(const void *addr, socklen_t len, int af)
-{
-#ifdef YP
- struct hostent *he;
- struct hostent_data *hed;
- u_long oresopt;
- int error;
- res_state statp;
-
- statp = __res_state();
- if ((he = __hostent_init()) == NULL ||
- (hed = __hostent_data_init()) == NULL) {
- RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
- return (NULL);
- }
-
- oresopt = statp->options;
- statp->options &= ~RES_USE_INET6;
- error = _gethostbynisaddr_r(addr, len, af, he, hed);
- statp->options = oresopt;
- return (error == 0) ? he : NULL;
-#else
- return (NULL);
-#endif
-}
-
int
_nis_gethostbyname(void *rval, void *cb_data, va_list ap)
{
Modified: trunk/lib/libc/net/gethostnamadr.c
===================================================================
--- trunk/lib/libc/net/gethostnamadr.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/gethostnamadr.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1994, Garrett Wollman
*
@@ -24,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/gethostnamadr.c 211276 2010-08-13 06:39:54Z ume $");
#include "namespace.h"
#include "reentrant.h"
Modified: trunk/lib/libc/net/getifaddrs.3
===================================================================
--- trunk/lib/libc/net/getifaddrs.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getifaddrs.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $KAME: getifaddrs.3,v 1.4 2000/05/17 14:13:14 itojun Exp $
.\" BSDI getifaddrs.3,v 2.5 2000/02/23 14:51:59 dab Exp
.\"
@@ -22,9 +23,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/getifaddrs.3 250888 2013-05-21 21:39:18Z ed $
.\"
-.Dd October 12, 1995
+.Dd May 21, 2013
.Dt GETIFADDRS 3
.Os
.Sh NAME
@@ -31,8 +32,6 @@
.Nm getifaddrs
.Nd get interface addresses
.Sh SYNOPSIS
-.In sys/types.h
-.In sys/socket.h
.In ifaddrs.h
.Ft int
.Fn getifaddrs "struct ifaddrs **ifap"
Modified: trunk/lib/libc/net/getifaddrs.c
===================================================================
--- trunk/lib/libc/net/getifaddrs.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getifaddrs.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $KAME: getifaddrs.c,v 1.9 2001/08/20 02:31:20 itojun Exp $ */
/*
@@ -30,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/getifaddrs.c 309485 2016-12-03 17:17:42Z ngie $");
#include "namespace.h"
#include <sys/types.h>
@@ -72,19 +73,6 @@
#define ALIGN(p) (((u_long)(p) + ALIGNBYTES) &~ ALIGNBYTES)
#endif
-#if _BSDI_VERSION >= 199701
-#define HAVE_IFM_DATA
-#endif
-
-#if _BSDI_VERSION >= 199802
-/* ifam_data is very specific to recent versions of bsdi */
-#define HAVE_IFAM_DATA
-#endif
-
-#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__MidnightBSD__)
-#define HAVE_IFM_DATA
-#endif
-
#define MAX_SYSCTL_TRY 5
int
@@ -93,39 +81,31 @@
int icnt = 1;
int dcnt = 0;
int ncnt = 0;
-#ifdef NET_RT_IFLIST
int ntry = 0;
int mib[6];
size_t needed;
char *buf;
char *next;
- struct ifaddrs *cif = 0;
+ struct ifaddrs *cif;
char *p, *p0;
struct rt_msghdr *rtm;
- struct if_msghdr *ifm;
- struct ifa_msghdr *ifam;
+ struct if_msghdrl *ifm;
+ struct ifa_msghdrl *ifam;
struct sockaddr_dl *dl;
struct sockaddr *sa;
struct ifaddrs *ifa, *ift;
+ struct if_data *if_data;
u_short idx = 0;
-#else /* NET_RT_IFLIST */
- char buf[1024];
- int m, sock;
- struct ifconf ifc;
- struct ifreq *ifr;
- struct ifreq *lifr;
-#endif /* NET_RT_IFLIST */
int i;
size_t len, alen;
char *data;
char *names;
-#ifdef NET_RT_IFLIST
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
mib[2] = 0; /* protocol */
mib[3] = 0; /* wildcard address family */
- mib[4] = NET_RT_IFLIST;
+ mib[4] = NET_RT_IFLISTL;/* extra fields for extensible msghdr structs */
mib[5] = 0; /* no flags */
do {
/*
@@ -159,16 +139,15 @@
continue;
switch (rtm->rtm_type) {
case RTM_IFINFO:
- ifm = (struct if_msghdr *)(void *)rtm;
+ ifm = (struct if_msghdrl *)(void *)rtm;
if (ifm->ifm_addrs & RTA_IFP) {
idx = ifm->ifm_index;
++icnt;
- dl = (struct sockaddr_dl *)(void *)(ifm + 1);
+ if_data = IF_MSGHDRL_IFM_DATA(ifm);
+ dcnt += if_data->ifi_datalen;
+ dl = (struct sockaddr_dl *)IF_MSGHDRL_RTA(ifm);
dcnt += SA_RLEN((struct sockaddr *)(void*)dl) +
ALIGNBYTES;
-#ifdef HAVE_IFM_DATA
- dcnt += sizeof(ifm->ifm_data);
-#endif /* HAVE_IFM_DATA */
ncnt += dl->sdl_nlen + 1;
} else
idx = 0;
@@ -175,7 +154,7 @@
break;
case RTM_NEWADDR:
- ifam = (struct ifa_msghdr *)(void *)rtm;
+ ifam = (struct ifa_msghdrl *)(void *)rtm;
if (idx && ifam->ifam_index != idx)
abort(); /* this cannot happen */
@@ -182,11 +161,11 @@
#define RTA_MASKS (RTA_NETMASK | RTA_IFA | RTA_BRD)
if (idx == 0 || (ifam->ifam_addrs & RTA_MASKS) == 0)
break;
- p = (char *)(void *)(ifam + 1);
+ p = (char *)IFA_MSGHDRL_RTA(ifam);
++icnt;
-#ifdef HAVE_IFAM_DATA
- dcnt += sizeof(ifam->ifam_data) + ALIGNBYTES;
-#endif /* HAVE_IFAM_DATA */
+ if_data = IFA_MSGHDRL_IFAM_DATA(ifam);
+ dcnt += if_data->ifi_datalen + ALIGNBYTES;
+
/* Scan to look for length of address */
alen = 0;
for (p0 = p, i = 0; i < RTAX_MAX; i++) {
@@ -216,35 +195,7 @@
break;
}
}
-#else /* NET_RT_IFLIST */
- ifc.ifc_buf = buf;
- ifc.ifc_len = sizeof(buf);
- if ((sock = _socket(AF_INET, SOCK_STREAM, 0)) < 0)
- return (-1);
- i = _ioctl(sock, SIOCGIFCONF, (char *)&ifc);
- _close(sock);
- if (i < 0)
- return (-1);
-
- ifr = ifc.ifc_req;
- lifr = (struct ifreq *)&ifc.ifc_buf[ifc.ifc_len];
-
- while (ifr < lifr) {
- struct sockaddr *sa;
-
- sa = &ifr->ifr_addr;
- ++icnt;
- dcnt += SA_RLEN(sa);
- ncnt += sizeof(ifr->ifr_name) + 1;
-
- if (SA_LEN(sa) < sizeof(*sa))
- ifr = (struct ifreq *)(((char *)sa) + sizeof(*sa));
- else
- ifr = (struct ifreq *)(((char *)sa) + SA_LEN(sa));
- }
-#endif /* NET_RT_IFLIST */
-
if (icnt + dcnt + ncnt == 1) {
*pif = NULL;
free(buf);
@@ -263,8 +214,8 @@
memset(ifa, 0, sizeof(struct ifaddrs) * icnt);
ift = ifa;
-#ifdef NET_RT_IFLIST
idx = 0;
+ cif = NULL;
for (next = buf; next < buf + needed; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)(void *)next;
if (rtm->rtm_version != RTM_VERSION)
@@ -271,41 +222,38 @@
continue;
switch (rtm->rtm_type) {
case RTM_IFINFO:
- ifm = (struct if_msghdr *)(void *)rtm;
- if (ifm->ifm_addrs & RTA_IFP) {
- idx = ifm->ifm_index;
- dl = (struct sockaddr_dl *)(void *)(ifm + 1);
+ ifm = (struct if_msghdrl *)(void *)rtm;
+ if ((ifm->ifm_addrs & RTA_IFP) == 0) {
+ idx = 0;
+ break;
+ }
- cif = ift;
- ift->ifa_name = names;
- ift->ifa_flags = (int)ifm->ifm_flags;
- memcpy(names, dl->sdl_data,
- (size_t)dl->sdl_nlen);
- names[dl->sdl_nlen] = 0;
- names += dl->sdl_nlen + 1;
+ idx = ifm->ifm_index;
+ dl = (struct sockaddr_dl *)IF_MSGHDRL_RTA(ifm);
- ift->ifa_addr = (struct sockaddr *)(void *)data;
- memcpy(data, dl,
- (size_t)SA_LEN((struct sockaddr *)
- (void *)dl));
- data += SA_RLEN((struct sockaddr *)(void *)dl);
+ cif = ift;
+ ift->ifa_name = names;
+ ift->ifa_flags = (int)ifm->ifm_flags;
+ memcpy(names, dl->sdl_data, (size_t)dl->sdl_nlen);
+ names[dl->sdl_nlen] = 0;
+ names += dl->sdl_nlen + 1;
-#ifdef HAVE_IFM_DATA
- /* ifm_data needs to be aligned */
- ift->ifa_data = data = (void *)ALIGN(data);
- memcpy(data, &ifm->ifm_data, sizeof(ifm->ifm_data));
- data += sizeof(ifm->ifm_data);
-#else /* HAVE_IFM_DATA */
- ift->ifa_data = NULL;
-#endif /* HAVE_IFM_DATA */
+ ift->ifa_addr = (struct sockaddr *)(void *)data;
+ memcpy(data, dl, (size_t)SA_LEN((struct sockaddr *)
+ (void *)dl));
+ data += SA_RLEN((struct sockaddr *)(void *)dl);
- ift = (ift->ifa_next = ift + 1);
- } else
- idx = 0;
+ if_data = IF_MSGHDRL_IFM_DATA(ifm);
+ /* ifm_data needs to be aligned */
+ ift->ifa_data = data = (void *)ALIGN(data);
+ memcpy(data, if_data, if_data->ifi_datalen);
+ data += if_data->ifi_datalen;
+
+ ift = (ift->ifa_next = ift + 1);
break;
case RTM_NEWADDR:
- ifam = (struct ifa_msghdr *)(void *)rtm;
+ ifam = (struct ifa_msghdrl *)(void *)rtm;
if (idx && ifam->ifam_index != idx)
abort(); /* this cannot happen */
@@ -314,7 +262,8 @@
ift->ifa_name = cif->ifa_name;
ift->ifa_flags = cif->ifa_flags;
ift->ifa_data = NULL;
- p = (char *)(void *)(ifam + 1);
+
+ p = (char *)IFA_MSGHDRL_RTA(ifam);
/* Scan to look for length of address */
alen = 0;
for (p0 = p, i = 0; i < RTAX_MAX; i++) {
@@ -365,12 +314,11 @@
p += len;
}
-#ifdef HAVE_IFAM_DATA
+ if_data = IFA_MSGHDRL_IFAM_DATA(ifam);
/* ifam_data needs to be aligned */
ift->ifa_data = data = (void *)ALIGN(data);
- memcpy(data, &ifam->ifam_data, sizeof(ifam->ifam_data));
- data += sizeof(ifam->ifam_data);
-#endif /* HAVE_IFAM_DATA */
+ memcpy(data, if_data, if_data->ifi_datalen);
+ data += if_data->ifi_datalen;
ift = (ift->ifa_next = ift + 1);
break;
@@ -378,28 +326,7 @@
}
free(buf);
-#else /* NET_RT_IFLIST */
- ifr = ifc.ifc_req;
- lifr = (struct ifreq *)&ifc.ifc_buf[ifc.ifc_len];
- while (ifr < lifr) {
- struct sockaddr *sa;
-
- ift->ifa_name = names;
- names[sizeof(ifr->ifr_name)] = 0;
- strncpy(names, ifr->ifr_name, sizeof(ifr->ifr_name));
- while (*names++)
- ;
-
- ift->ifa_addr = (struct sockaddr *)data;
- sa = &ifr->ifr_addr;
- memcpy(data, sa, SA_LEN(sa));
- data += SA_RLEN(sa);
-
- ifr = (struct ifreq *)(((char *)sa) + SA_LEN(sa));
- ift = (ift->ifa_next = ift + 1);
- }
-#endif /* NET_RT_IFLIST */
if (--ift >= ifa) {
ift->ifa_next = NULL;
*pif = ifa;
Modified: trunk/lib/libc/net/getifmaddrs.3
===================================================================
--- trunk/lib/libc/net/getifmaddrs.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getifmaddrs.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2003 Bruce M. Simpson. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -18,9 +19,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/getifmaddrs.3 250888 2013-05-21 21:39:18Z ed $
.\"
-.Dd November 14, 2003
+.Dd May 21, 2013
.Dt GETIFMADDRS 3
.Os
.Sh NAME
@@ -27,8 +28,6 @@
.Nm getifmaddrs
.Nd get multicast group memberships
.Sh SYNOPSIS
-.In sys/types.h
-.In sys/socket.h
.In ifaddrs.h
.Ft int
.Fn getifmaddrs "struct ifmaddrs **ifmap"
Modified: trunk/lib/libc/net/getifmaddrs.c
===================================================================
--- trunk/lib/libc/net/getifmaddrs.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getifmaddrs.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 2003 Bruce M. Simpson.
* All rights reserved
@@ -10,28 +11,22 @@
* 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Bruce M. Simpson.
- * 4. Neither the name of Bruce M. Simpson nor the names of other
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY BRUCE M. SIMPSON AND AFFILIATES
- * ``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 BRUCE M. SIMPSON 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.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/getifmaddrs.c 251475 2013-06-06 21:09:27Z emaste $");
#include "namespace.h"
#include <sys/param.h>
Modified: trunk/lib/libc/net/getipnodebyname.3
===================================================================
--- trunk/lib/libc/net/getipnodebyname.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getipnodebyname.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $KAME: getipnodebyname.3,v 1.6 2000/08/09 21:16:17 itojun Exp $
.\"
.\" Copyright (c) 1983, 1987, 1991, 1993
@@ -28,7 +29,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/getipnodebyname.3 233522 2012-03-26 21:22:53Z joel $
.\"
.Dd August 6, 2004
.Dt GETIPNODEBYNAME 3
@@ -108,13 +109,13 @@
(defined below)
should handle most applications.
That is, porting simple applications to use IPv6 replaces the call
-.Bd -literal -offset
- hptr = gethostbyname(name);
+.Bd -literal -offset indent
+hptr = gethostbyname(name);
.Ed
.Pp
with
-.Bd -literal -offset
- hptr = getipnodebyname(name, AF_INET6, AI_DEFAULT, &error_num);
+.Bd -literal -offset indent
+hptr = getipnodebyname(name, AF_INET6, AI_DEFAULT, &error_num);
.Ed
.Pp
Applications desiring finer control over the types of addresses
@@ -270,8 +271,8 @@
The special flags value of
.Dv AI_DEFAULT
is defined as
-.Bd -literal -offset
- #define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
+.Bd -literal -offset indent
+#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
.Ed
.Pp
We noted that the
Modified: trunk/lib/libc/net/getnameinfo.3
===================================================================
--- trunk/lib/libc/net/getnameinfo.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getnameinfo.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $KAME: getnameinfo.3,v 1.37 2005/01/05 03:23:05 itojun Exp $
.\" $OpenBSD: getnameinfo.3,v 1.36 2004/12/21 09:48:20 jmc Exp $
.\"
@@ -16,7 +17,7 @@
.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/getnameinfo.3 253066 2013-07-09 08:23:43Z hrs $
.\"
.Dd February 14, 2013
.Dt GETNAMEINFO 3
@@ -25,9 +26,9 @@
.Nm getnameinfo
.Nd socket address structure to hostname and service name
.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/socket.h>
-.Fd #include <netdb.h>
+.In sys/types.h
+.In sys/socket.h
+.In netdb.h
.Ft int
.Fo getnameinfo
.Fa "const struct sockaddr *sa" "socklen_t salen" "char *host"
Modified: trunk/lib/libc/net/getnameinfo.c
===================================================================
--- trunk/lib/libc/net/getnameinfo.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getnameinfo.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $KAME: getnameinfo.c,v 1.61 2002/06/27 09:25:47 itojun Exp $ */
/*
@@ -45,7 +46,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/getnameinfo.c 287736 2015-09-13 03:15:37Z hrs $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -78,6 +79,8 @@
char *host, size_t hostlen, char *serv, size_t servlen,
int flags)
{
+ if (sa == NULL)
+ return (EAI_FAIL);
switch (sa->sa_family) {
case AF_INET:
@@ -124,7 +127,6 @@
struct servent *sp;
struct hostent *hp;
u_short port;
- int family, i;
const char *addr;
u_int32_t v4a;
int h_error;
@@ -131,18 +133,13 @@
char numserv[512];
char numaddr[512];
- if (sa == NULL)
- return EAI_FAIL;
+ for (afd = &afdl[0]; afd->a_af > 0; afd++) {
+ if (afd->a_af == sa->sa_family)
+ break;
+ }
+ if (afd->a_af == 0)
+ return (EAI_FAMILY);
- family = sa->sa_family;
- for (i = 0; afdl[i].a_af; i++)
- if (afdl[i].a_af == family) {
- afd = &afdl[i];
- goto found;
- }
- return EAI_FAMILY;
-
- found:
if (salen != afd->a_socklen)
return EAI_FAIL;
@@ -394,13 +391,24 @@
if (sdl->sdl_nlen == 0 && sdl->sdl_alen == 0 && sdl->sdl_slen == 0) {
n = snprintf(host, hostlen, "link#%d", sdl->sdl_index);
- if (n > hostlen) {
+ if (n >= hostlen) {
*host = '\0';
- return EAI_MEMORY;
+ return (EAI_MEMORY);
}
- return 0;
+ return (0);
}
+ if (sdl->sdl_nlen > 0 && sdl->sdl_alen == 0) {
+ n = sdl->sdl_nlen;
+ if (n >= hostlen) {
+ *host = '\0';
+ return (EAI_MEMORY);
+ }
+ memcpy(host, sdl->sdl_data, sdl->sdl_nlen);
+ host[n] = '\0';
+ return (0);
+ }
+
switch (sdl->sdl_type) {
case IFT_IEEE1394:
if (sdl->sdl_alen < sizeof(iha->sender_unique_ID_hi) +
@@ -441,10 +449,7 @@
}
static int
-hexname(cp, len, host, hostlen)
- const u_int8_t *cp;
- char *host;
- size_t len, hostlen;
+hexname(const u_int8_t *cp, size_t len, char *host, size_t hostlen)
{
int i, n;
char *outp = host;
Modified: trunk/lib/libc/net/getnetbydns.c
===================================================================
--- trunk/lib/libc/net/getnetbydns.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getnetbydns.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1985, 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -58,7 +59,7 @@
static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/getnetbydns.c 211276 2010-08-13 06:39:54Z ume $");
#include <sys/param.h>
#include <sys/socket.h>
Modified: trunk/lib/libc/net/getnetbyht.c
===================================================================
--- trunk/lib/libc/net/getnetbyht.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getnetbyht.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -42,7 +43,7 @@
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>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/getnetbyht.c 254700 2013-08-23 13:59:47Z jilles $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -63,7 +64,7 @@
{
if (ned->netf == NULL)
- ned->netf = fopen(_PATH_NETWORKS, "r");
+ ned->netf = fopen(_PATH_NETWORKS, "re");
else
rewind(ned->netf);
ned->stayopen |= f;
@@ -89,7 +90,7 @@
char line[BUFSIZ + 1];
if (ned->netf == NULL &&
- (ned->netf = fopen(_PATH_NETWORKS, "r")) == NULL)
+ (ned->netf = fopen(_PATH_NETWORKS, "re")) == NULL)
return (-1);
again:
p = fgets(line, sizeof line, ned->netf);
Modified: trunk/lib/libc/net/getnetbynis.c
===================================================================
--- trunk/lib/libc/net/getnetbynis.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getnetbynis.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1994, Garrett Wollman
*
@@ -24,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/getnetbynis.c 229403 2012-01-03 18:51:58Z ed $");
#include <sys/param.h>
#include <sys/socket.h>
@@ -80,7 +81,7 @@
free(result);
result = (char *)&ypbuf;
- if ((cp = index(result, '\n')))
+ if ((cp = strchr(result, '\n')))
*cp = '\0';
cp = strpbrk(result, " \t");
Modified: trunk/lib/libc/net/getnetent.3
===================================================================
--- trunk/lib/libc/net/getnetent.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getnetent.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)getnetent.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/getnetent.3 243156 2012-11-16 15:02:35Z kevlo $
.\"
.Dd June 4, 1993
.Dt GETNETENT 3
@@ -73,7 +74,7 @@
`networks' entry in
.Xr nsswitch.conf 5 .
.Bd -literal -offset indent
-struct netent {
+struct netent {
char *n_name; /* official name of net */
char **n_aliases; /* alias list */
int n_addrtype; /* net number type */
@@ -142,8 +143,7 @@
.It Pa /etc/resolv.conf
.El
.Sh DIAGNOSTICS
-Null pointer
-(0) returned on
+Null pointer returned on
.Dv EOF
or error.
.Sh SEE ALSO
Modified: trunk/lib/libc/net/getnetnamadr.c
===================================================================
--- trunk/lib/libc/net/getnetnamadr.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getnetnamadr.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1994, Garrett Wollman
*
@@ -24,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/getnetnamadr.c 211276 2010-08-13 06:39:54Z ume $");
#include "namespace.h"
#include "reentrant.h"
Modified: trunk/lib/libc/net/getproto.c
===================================================================
--- trunk/lib/libc/net/getproto.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getproto.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)getproto.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/getproto.c 213453 2010-10-05 15:40:59Z ume $");
#include <errno.h>
#include <netdb.h>
Modified: trunk/lib/libc/net/getprotoent.3
===================================================================
--- trunk/lib/libc/net/getprotoent.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getprotoent.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)getprotoent.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/getprotoent.3 243156 2012-11-16 15:02:35Z kevlo $
.\"
.Dd June 4, 1993
.Dt GETPROTOENT 3
@@ -65,7 +66,7 @@
fields of a line in the network protocol data base,
.Pa /etc/protocols .
.Bd -literal -offset indent
-struct protoent {
+struct protoent {
char *p_name; /* official name of protocol */
char **p_aliases; /* alias list */
int p_proto; /* protocol number */
@@ -117,8 +118,7 @@
.Dv EOF
is encountered.
.Sh RETURN VALUES
-Null pointer
-(0) returned on
+Null pointer returned on
.Dv EOF
or error.
.Sh FILES
Modified: trunk/lib/libc/net/getprotoent.c
===================================================================
--- trunk/lib/libc/net/getprotoent.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getprotoent.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)getprotoent.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/getprotoent.c 254700 2013-08-23 13:59:47Z jilles $");
#include <sys/param.h>
#include <sys/types.h>
@@ -342,7 +343,7 @@
__setprotoent_p(int f, struct protoent_data *ped)
{
if (ped->fp == NULL)
- ped->fp = fopen(_PATH_PROTOCOLS, "r");
+ ped->fp = fopen(_PATH_PROTOCOLS, "re");
else
rewind(ped->fp);
ped->stayopen |= f;
@@ -365,7 +366,7 @@
char *cp, **q, *endp;
long l;
- if (ped->fp == NULL && (ped->fp = fopen(_PATH_PROTOCOLS, "r")) == NULL)
+ if (ped->fp == NULL && (ped->fp = fopen(_PATH_PROTOCOLS, "re")) == NULL)
return (-1);
again:
if ((p = fgets(ped->line, sizeof ped->line, ped->fp)) == NULL)
Modified: trunk/lib/libc/net/getprotoname.c
===================================================================
--- trunk/lib/libc/net/getprotoname.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getprotoname.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)getprotoname.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/getprotoname.c 213453 2010-10-05 15:40:59Z ume $");
#include <errno.h>
#include <netdb.h>
Modified: trunk/lib/libc/net/getservent.3
===================================================================
--- trunk/lib/libc/net/getservent.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getservent.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)getservent.3 8.3 (Berkeley) 1/12/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/getservent.3 243156 2012-11-16 15:02:35Z kevlo $
.\"
.Dd July 9, 1995
.Dt GETSERVENT 3
@@ -65,7 +66,7 @@
fields of a line in the network services data base,
.Pa /etc/services .
.Bd -literal -offset indent
-struct servent {
+struct servent {
char *s_name; /* official name of service */
char **s_aliases; /* alias list */
int s_port; /* port service resides at */
@@ -130,8 +131,7 @@
.It Pa /etc/services
.El
.Sh DIAGNOSTICS
-Null pointer
-(0) returned on
+Null pointer returned on
.Dv EOF
or error.
.Sh SEE ALSO
Modified: trunk/lib/libc/net/getservent.c
===================================================================
--- trunk/lib/libc/net/getservent.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/getservent.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)getservent.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/getservent.c 309485 2016-12-03 17:17:42Z ngie $");
#include <sys/param.h>
#include <sys/types.h>
@@ -335,7 +336,7 @@
if (st->fp == NULL)
st->compat_mode_active = 0;
- if (st->fp == NULL && (st->fp = fopen(_PATH_SERVICES, "r")) == NULL) {
+ if (st->fp == NULL && (st->fp = fopen(_PATH_SERVICES, "re")) == NULL) {
*errnop = errno;
return (NS_UNAVAIL);
}
@@ -406,7 +407,7 @@
continue;
gotname:
- if (proto == 0 || strcmp(serv->s_proto, proto) == 0)
+ if (proto == NULL || strcmp(serv->s_proto, proto) == 0)
rv = NS_SUCCESS;
break;
case nss_lt_id:
@@ -413,7 +414,7 @@
if (port != serv->s_port)
continue;
- if (proto == 0 || strcmp(serv->s_proto, proto) == 0)
+ if (proto == NULL || strcmp(serv->s_proto, proto) == 0)
rv = NS_SUCCESS;
break;
case nss_lt_all:
@@ -449,7 +450,7 @@
case SETSERVENT:
f = va_arg(ap,int);
if (st->fp == NULL)
- st->fp = fopen(_PATH_SERVICES, "r");
+ st->fp = fopen(_PATH_SERVICES, "re");
else
rewind(st->fp);
st->stayopen |= f;
Modified: trunk/lib/libc/net/hesiod.3
===================================================================
--- trunk/lib/libc/net/hesiod.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/hesiod.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $NetBSD: hesiod.3,v 1.1 1999/01/25 03:43:04 lukem Exp $
.\"
.\" from: #Id: hesiod.3,v 1.9.2.1 1997/01/03 21:02:23 ghudson Exp #
@@ -16,7 +17,7 @@
.\" this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/hesiod.3 140505 2005-01-20 09:17:07Z ru $
.\"
.Dd November 30, 1996
.Dt HESIOD 3
Modified: trunk/lib/libc/net/hesiod.c
===================================================================
--- trunk/lib/libc/net/hesiod.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/hesiod.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $NetBSD: hesiod.c,v 1.9 1999/02/11 06:16:38 simonb Exp $ */
/* Copyright (c) 1996 by Internet Software Consortium.
@@ -49,7 +50,7 @@
static char *orig_rcsid = "$NetBSD: hesiod.c,v 1.9 1999/02/11 06:16:38 simonb Exp $";
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/hesiod.c 254700 2013-08-23 13:59:47Z jilles $");
#include <sys/types.h>
#include <sys/param.h>
@@ -286,7 +287,7 @@
ctx->classes[1] = C_HS;
/* Try to open the configuration file. */
- fp = fopen(filename, "r");
+ fp = fopen(filename, "re");
if (!fp) {
/* Use compiled in default domain names. */
ctx->lhs = strdup(DEF_LHS);
Modified: trunk/lib/libc/net/if_indextoname.3
===================================================================
--- trunk/lib/libc/net/if_indextoname.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/if_indextoname.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $KAME: if_indextoname.3,v 1.10 2000/11/24 08:13:51 itojun Exp $
.\" BSDI Id: if_indextoname.3,v 2.2 2000/04/17 22:38:05 dab Exp
.\"
@@ -22,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/if_indextoname.3 152712 2005-11-23 10:49:07Z ru $
.\"
.Dd November 23, 2005
.Dt IF_NAMETOINDEX 3
Modified: trunk/lib/libc/net/if_indextoname.c
===================================================================
--- trunk/lib/libc/net/if_indextoname.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/if_indextoname.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $KAME: if_indextoname.c,v 1.7 2000/11/08 03:09:30 itojun Exp $ */
/*-
@@ -26,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/if_indextoname.c 235640 2012-05-19 02:39:43Z marcel $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -70,7 +71,7 @@
for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) {
if (ifa->ifa_addr &&
ifa->ifa_addr->sa_family == AF_LINK &&
- ifindex == ((struct sockaddr_dl*)ifa->ifa_addr)->sdl_index)
+ ifindex == LLINDEX((struct sockaddr_dl*)ifa->ifa_addr))
break;
}
Modified: trunk/lib/libc/net/if_nameindex.c
===================================================================
--- trunk/lib/libc/net/if_nameindex.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/if_nameindex.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $KAME: if_nameindex.c,v 1.8 2000/11/24 08:20:01 itojun Exp $ */
/*-
@@ -26,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/if_nameindex.c 235640 2012-05-19 02:39:43Z marcel $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -123,7 +124,7 @@
if (ifa->ifa_addr &&
ifa->ifa_addr->sa_family == AF_LINK) {
ifni2->if_index =
- ((struct sockaddr_dl*)ifa->ifa_addr)->sdl_index;
+ LLINDEX((struct sockaddr_dl*)ifa->ifa_addr);
ifni2->if_name = cp;
strcpy(cp, ifa->ifa_name);
ifni2++;
Modified: trunk/lib/libc/net/if_nametoindex.c
===================================================================
--- trunk/lib/libc/net/if_nametoindex.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/if_nametoindex.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $KAME: if_nametoindex.c,v 1.6 2000/11/24 08:18:54 itojun Exp $ */
/*-
@@ -26,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/if_nametoindex.c 294156 2016-01-16 14:56:30Z tuexen $");
#include "namespace.h"
#include <sys/types.h>
@@ -68,8 +69,9 @@
struct ifaddrs *ifaddrs, *ifa;
unsigned int ni;
- s = _socket(AF_INET, SOCK_DGRAM, 0);
+ s = _socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (s != -1) {
+ memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (_ioctl(s, SIOCGIFINDEX, &ifr) != -1) {
_close(s);
@@ -87,7 +89,7 @@
if (ifa->ifa_addr &&
ifa->ifa_addr->sa_family == AF_LINK &&
strcmp(ifa->ifa_name, ifname) == 0) {
- ni = ((struct sockaddr_dl*)ifa->ifa_addr)->sdl_index;
+ ni = LLINDEX((struct sockaddr_dl*)ifa->ifa_addr);
break;
}
}
Modified: trunk/lib/libc/net/inet.3
===================================================================
--- trunk/lib/libc/net/inet.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/inet.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)inet.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/inet.3 170715 2007-06-14 07:13:28Z delphij $
.\"
.Dd June 14, 2007
.Dt INET 3
Modified: trunk/lib/libc/net/inet6_opt_init.3
===================================================================
--- trunk/lib/libc/net/inet6_opt_init.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/inet6_opt_init.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $KAME: inet6_opt_init.3,v 1.7 2004/12/27 05:08:23 itojun Exp $
.\"
.\" Copyright (C) 2004 WIDE Project.
@@ -27,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/inet6_opt_init.3 152717 2005-11-23 16:07:54Z ru $
.\"
.Dd December 23, 2004
.Dt INET6_OPT_INIT 3
Modified: trunk/lib/libc/net/inet6_option_space.3
===================================================================
--- trunk/lib/libc/net/inet6_option_space.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/inet6_option_space.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $KAME: inet6_option_space.3,v 1.11 2005/01/05 03:00:44 itojun Exp $
.\"
.\" Copyright (C) 2004 WIDE Project.
@@ -27,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/inet6_option_space.3 140750 2005-01-24 18:14:18Z ru $
.\"
.Dd January 24, 2005
.Dt INET6_OPTION_SPACE 3
Modified: trunk/lib/libc/net/inet6_rth_space.3
===================================================================
--- trunk/lib/libc/net/inet6_rth_space.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/inet6_rth_space.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $KAME: inet6_rth_space.3,v 1.7 2005/01/05 03:00:44 itojun Exp $
.\"
.\" Copyright (C) 2004 WIDE Project.
@@ -27,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/inet6_rth_space.3 211397 2010-08-16 15:18:30Z joel $
.\"
.Dd December 24, 2004
.Dt INET6_RTH_SPACE 3
Modified: trunk/lib/libc/net/inet6_rthdr_space.3
===================================================================
--- trunk/lib/libc/net/inet6_rthdr_space.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/inet6_rthdr_space.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $KAME: inet6_rthdr_space.3,v 1.11 2005/01/05 03:00:44 itojun Exp $
.\"
.\" Copyright (C) 2004 WIDE Project.
@@ -27,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/inet6_rthdr_space.3 140750 2005-01-24 18:14:18Z ru $
.\"
.Dd January 24, 2005
.Dt INET6_RTHDR_SPACE 3
Modified: trunk/lib/libc/net/inet_net.3
===================================================================
--- trunk/lib/libc/net/inet_net.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/inet_net.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $NetBSD: inet_net.3,v 1.4 1999/03/22 19:44:52 garbled Exp $
.\"
.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -30,7 +31,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/inet_net.3 233462 2012-03-25 12:13:24Z joel $
.\"
.Dd February 26, 2006
.Dt INET_NET 3
@@ -95,7 +96,6 @@
argument
is the size of the result buffer
.Fa dst .
-.Pp
.Sh NETWORK NUMBERS (IP VERSION 4)
Internet network numbers may be specified in one of the following forms:
.Bd -literal -offset indent
Modified: trunk/lib/libc/net/ip6opt.c
===================================================================
--- trunk/lib/libc/net/ip6opt.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/ip6opt.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $KAME: ip6opt.c,v 1.13 2003/06/06 10:08:20 suz Exp $ */
/*
@@ -30,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/ip6opt.c 269454 2014-08-03 02:24:52Z marcel $");
#include <sys/param.h>
#include <sys/types.h>
@@ -45,6 +46,18 @@
static int ip6optlen(u_int8_t *opt, u_int8_t *lim);
static void inet6_insert_padopt(u_char *p, int len);
+#ifndef IPV6_2292HOPOPTS
+#define IPV6_2292HOPOPTS 22
+#endif
+#ifndef IPV6_2292DSTOPTS
+#define IPV6_2292DSTOPTS 23
+#endif
+
+#define is_ipv6_hopopts(x) \
+ ((x) == IPV6_HOPOPTS || (x) == IPV6_2292HOPOPTS)
+#define is_ipv6_dstopts(x) \
+ ((x) == IPV6_DSTOPTS || (x) == IPV6_2292DSTOPTS)
+
/*
* This function returns the number of bytes required to hold an option
* when it is stored as ancillary data, including the cmsghdr structure
@@ -72,9 +85,9 @@
struct cmsghdr *ch = (struct cmsghdr *)bp;
/* argument validation */
- if (type != IPV6_HOPOPTS && type != IPV6_DSTOPTS)
+ if (!is_ipv6_hopopts(type) && !is_ipv6_dstopts(type))
return(-1);
-
+
ch->cmsg_level = IPPROTO_IPV6;
ch->cmsg_type = type;
ch->cmsg_len = CMSG_LEN(0);
@@ -234,8 +247,8 @@
u_int8_t *lim;
if (cmsg->cmsg_level != IPPROTO_IPV6 ||
- (cmsg->cmsg_type != IPV6_HOPOPTS &&
- cmsg->cmsg_type != IPV6_DSTOPTS))
+ (!is_ipv6_hopopts(cmsg->cmsg_type) &&
+ !is_ipv6_dstopts(cmsg->cmsg_type)))
return(-1);
/* message length validation */
@@ -290,8 +303,8 @@
u_int8_t *optp, *lim;
if (cmsg->cmsg_level != IPPROTO_IPV6 ||
- (cmsg->cmsg_type != IPV6_HOPOPTS &&
- cmsg->cmsg_type != IPV6_DSTOPTS))
+ (!is_ipv6_hopopts(cmsg->cmsg_type) &&
+ !is_ipv6_dstopts(cmsg->cmsg_type)))
return(-1);
/* message length validation */
Modified: trunk/lib/libc/net/linkaddr.3
===================================================================
--- trunk/lib/libc/net/linkaddr.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/linkaddr.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -29,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)linkaddr.3 8.1 (Berkeley) 7/28/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/linkaddr.3 167121 2007-02-28 21:18:38Z bms $
.\"
.Dd February 28, 2007
.Dt LINK_ADDR 3
Modified: trunk/lib/libc/net/linkaddr.c
===================================================================
--- trunk/lib/libc/net/linkaddr.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/linkaddr.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)linkaddr.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/linkaddr.c 309690 2016-12-07 23:20:26Z glebius $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -119,7 +120,7 @@
return;
}
-static char hexlist[] = "0123456789abcdef";
+static const char hexlist[] = "0123456789abcdef";
char *
link_ntoa(sdl)
Modified: trunk/lib/libc/net/map_v4v6.c
===================================================================
--- trunk/lib/libc/net/map_v4v6.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/map_v4v6.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* ++Copyright++ 1985, 1988, 1993
* -
@@ -53,7 +54,7 @@
static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/map_v4v6.c 292850 2015-12-29 00:42:35Z ume $");
#include <sys/types.h>
#include <sys/param.h>
@@ -77,19 +78,11 @@
void
_map_v4v6_address(const char *src, char *dst)
{
- u_char *p = (u_char *)dst;
- char tmp[NS_INADDRSZ];
- int i;
-
- /* Stash a temporary copy so our caller can update in place. */
- memcpy(tmp, src, NS_INADDRSZ);
+ /* Our caller may update in place. */
+ memmove(&dst[12], src, NS_INADDRSZ);
/* Mark this ipv6 addr as a mapped ipv4. */
- for (i = 0; i < 10; i++)
- *p++ = 0x00;
- *p++ = 0xff;
- *p++ = 0xff;
- /* Retrieve the saved copy and we're done. */
- memcpy((void*)p, tmp, NS_INADDRSZ);
+ memset(&dst[10], 0xff, 2);
+ memset(&dst[0], 0, 10);
}
void
Modified: trunk/lib/libc/net/name6.c
===================================================================
--- trunk/lib/libc/net/name6.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/name6.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $KAME: name6.c,v 1.25 2000/06/26 16:44:40 itojun Exp $ */
/*
@@ -42,11 +43,7 @@
* 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 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.
*
@@ -88,7 +85,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: release/9.2.0/lib/libc/net/name6.c 245553 2013-01-17 16:11:38Z ume $");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/name6.c 305401 2016-09-05 00:36:52Z ache $");
#include "namespace.h"
#include <sys/param.h>
@@ -190,6 +187,7 @@
#define aio_sa aio_un.aiou_sa
int aio_matchlen;
char *aio_h_addr;
+ int aio_initial_sequence;
};
static struct hostent *_hpcopy(struct hostent *, int *);
@@ -239,7 +237,7 @@
if (flags & AI_ADDRCONFIG) {
int s;
- if ((s = _socket(af, SOCK_DGRAM, 0)) < 0)
+ if ((s = _socket(af, SOCK_DGRAM | SOCK_CLOEXEC, 0)) < 0)
return NULL;
/*
* TODO:
@@ -659,7 +657,6 @@
#endif
break;
default:
- free_addrselectpolicy(&policyhead);
return hp;
}
@@ -716,6 +713,7 @@
aio[i].aio_dstscope = gai_addr2scopetype(sa);
aio[i].aio_dstpolicy = match_addrselectpolicy(sa, &policyhead);
set_source(&aio[i], &policyhead);
+ aio[i].aio_initial_sequence = i;
}
/* perform sorting. */
@@ -799,10 +797,9 @@
memset(&key, 0, sizeof(key));
key.sin6_family = AF_INET6;
key.sin6_len = sizeof(key);
- key.sin6_addr.s6_addr[10] = 0xff;
- key.sin6_addr.s6_addr[11] = 0xff;
- memcpy(&key.sin6_addr.s6_addr[12],
- &((struct sockaddr_in *)addr)->sin_addr, 4);
+ _map_v4v6_address(
+ (char *)&((struct sockaddr_in *)addr)->sin_addr,
+ (char *)&key.sin6_addr);
break;
default:
return(NULL);
@@ -872,7 +869,8 @@
}
/* open a socket to get the source address for the given dst */
- if ((s = _socket(ss.ss_family, SOCK_DGRAM, IPPROTO_UDP)) < 0)
+ if ((s = _socket(ss.ss_family, SOCK_DGRAM | SOCK_CLOEXEC,
+ IPPROTO_UDP)) < 0)
return; /* give up */
if (_connect(s, (struct sockaddr *)&ss, ss.ss_len) < 0)
goto cleanup;
@@ -933,7 +931,7 @@
while (s < lim)
if ((r = (*d++ ^ *s++)) != 0) {
- while (r < addrlen * 8) {
+ while ((r & 0x80) == 0) {
match++;
r <<= 1;
}
@@ -1050,6 +1048,23 @@
}
/* Rule 10: Otherwise, leave the order unchanged. */
+
+ /*
+ * Note that qsort is unstable; so, we can't return zero and
+ * expect the order to be unchanged.
+ * That also means we can't depend on the current position of
+ * dst2 being after dst1. We must enforce the initial order
+ * with an explicit compare on the original position.
+ * The qsort specification requires that "When the same objects
+ * (consisting of width bytes, irrespective of their current
+ * positions in the array) are passed more than once to the
+ * comparison function, the results shall be consistent with one
+ * another."
+ * In other words, If A < B, then we must also return B > A.
+ */
+ if (dst2->aio_initial_sequence < dst1->aio_initial_sequence)
+ return(1);
+
return(-1);
}
Modified: trunk/lib/libc/net/netdb_private.h
===================================================================
--- trunk/lib/libc/net/netdb_private.h 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/netdb_private.h 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (C) 2005 The FreeBSD Project. All rights reserved.
*
@@ -22,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/net/netdb_private.h 293023 2016-01-01 00:35:06Z ume $
*/
#ifndef _NETDB_PRIVATE_H_
@@ -133,8 +134,6 @@
void _endhosthtent(struct hostent_data *);
void _endnetdnsent(void);
void _endnethtent(struct netent_data *);
-struct hostent *_gethostbynisaddr(const void *, socklen_t, int);
-struct hostent *_gethostbynisname(const char *, int);
void _map_v4v6_address(const char *, char *);
void _map_v4v6_hostent(struct hostent *, char **, char *);
void _sethostdnsent(int);
Modified: trunk/lib/libc/net/nscache.c
===================================================================
--- trunk/lib/libc/net/nscache.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/nscache.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
* All rights reserved.
@@ -26,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/nscache.c 172730 2007-10-17 23:20:49Z tmclaugh $");
#include "namespace.h"
#include <nsswitch.h>
Modified: trunk/lib/libc/net/nscachedcli.c
===================================================================
--- trunk/lib/libc/net/nscachedcli.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/nscachedcli.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2005 Michael Bushkov <bushman at rsu.ru>
* All rights reserved.
@@ -26,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/nscachedcli.c 255328 2013-09-06 21:02:06Z jilles $");
#include "namespace.h"
#include <sys/types.h>
@@ -200,7 +201,7 @@
assert(params != NULL);
- client_socket = _socket(PF_LOCAL, SOCK_STREAM, 0);
+ client_socket = _socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
client_address.sun_family = PF_LOCAL;
strncpy(client_address.sun_path, params->socket_path,
sizeof(client_address.sun_path));
Modified: trunk/lib/libc/net/nsdispatch.3
===================================================================
--- trunk/lib/libc/net/nsdispatch.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/nsdispatch.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $NetBSD: nsdispatch.3,v 1.8 1999/03/22 19:44:53 garbled Exp $
.\"
.\" Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
@@ -30,7 +31,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/nsdispatch.3 235401 2012-05-13 14:28:00Z joel $
.\"
.Dd April 4, 2010
.Dt NSDISPATCH 3
@@ -85,7 +86,7 @@
void *mdata;
} ns_dtab;
.Ed
-.Bd -ragged -offset indent
+.Pp
The
.Fa dtab
array should consist of one entry for each source type that is
@@ -105,7 +106,6 @@
.Va method ,
and
.Va mdata .
-.Ed
.Pp
Additionally, methods may be implemented in NSS modules, in
which case they are selected using the
@@ -129,10 +129,10 @@
.Bd -literal -offset indent
typedef struct _ns_src {
const char *src;
- u_int32_t flags;
+ uint32_t flags;
} ns_src;
.Ed
-.Bd -ragged -offset indent
+.Pp
The
.Fa defaults
array should consist of one entry for each source to be configured by
@@ -157,12 +157,13 @@
set to 0.
.Pp
For convenience, a global variable defined as:
+.Pp
.Dl extern const ns_src __nsdefaultsrc[];
+.Pp
exists which contains a single default entry for the source
.Sq files
that may be used by callers which do not require complicated default
rules.
-.Ed
.Pp
.Sq Va ...
are optional extra arguments, which are passed to the appropriate method
@@ -173,17 +174,16 @@
#defines for commonly implemented sources are available:
.Bl -column NSSRC_COMPAT compat -offset indent
.It Sy "#define value"
-.It Dv NSSRC_FILES Ta """files""
-.It Dv NSSRC_DB Ta """db""
-.It Dv NSSRC_DNS Ta """dns""
-.It Dv NSSRC_NIS Ta """nis""
-.It Dv NSSRC_COMPAT Ta """compat""
+.It Dv NSSRC_FILES Ta \&"files\&"
+.It Dv NSSRC_DB Ta \&"db\&"
+.It Dv NSSRC_DNS Ta \&"dns\&"
+.It Dv NSSRC_NIS Ta \&"nis\&"
+.It Dv NSSRC_COMPAT Ta \&"compat\&"
.El
.Pp
Refer to
.Xr nsswitch.conf 5
for a complete description of what each source type is.
-.Pp
.Ss Method return values
The
.Vt nss_method
Modified: trunk/lib/libc/net/nsdispatch.c
===================================================================
--- trunk/lib/libc/net/nsdispatch.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/nsdispatch.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $NetBSD: nsdispatch.c,v 1.9 1999/01/25 00:16:17 lukem Exp $ */
/*-
@@ -15,13 +16,6 @@
* 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -68,7 +62,7 @@
*
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/nsdispatch.c 285317 2015-07-09 13:30:37Z des $");
#include "namespace.h"
#include <sys/param.h>
@@ -139,14 +133,17 @@
#endif
/*
- * When this is set to 1, nsdispatch won't use nsswitch.conf
- * but will consult the 'defaults' source list only.
- * NOTE: nested fallbacks (when nsdispatch calls fallback functions,
- * which in turn calls nsdispatch, which should call fallback
- * function) are not supported
+ * We keep track of nsdispatch() nesting depth in dispatch_depth. When a
+ * fallback method is invoked from nsdispatch(), we temporarily set
+ * fallback_depth to the current dispatch depth plus one. Subsequent
+ * calls at that exact depth will run in fallback mode (restricted to the
+ * same source as the call that was handled by the fallback method), while
+ * calls below that depth will be handled normally, allowing fallback
+ * methods to perform arbitrary lookups.
*/
struct fb_state {
- int fb_dispatch;
+ int dispatch_depth;
+ int fallback_depth;
};
static void fb_endstate(void *);
NSS_TLS_HANDLING(fb);
@@ -368,7 +365,7 @@
if (result != 0)
goto fin2;
}
- _nsyyin = fopen(path, "r");
+ _nsyyin = fopen(path, "re");
if (_nsyyin == NULL)
goto fin;
VECTOR_FREE(_nsmap, &_nsmapsize, sizeof(*_nsmap),
@@ -623,6 +620,7 @@
void *mdata;
int isthreaded, serrno, i, result, srclistsize;
struct fb_state *st;
+ int saved_depth;
#ifdef NS_CACHING
nss_cache_data cache_data;
@@ -654,7 +652,8 @@
result = NS_UNAVAIL;
goto fin;
}
- if (st->fb_dispatch == 0) {
+ ++st->dispatch_depth;
+ if (st->dispatch_depth > st->fallback_depth) {
dbt = vector_search(&database, _nsmap, _nsmapsize, sizeof(*_nsmap),
string_compare);
fb_method = nss_method_lookup(NSSRC_FALLBACK, database,
@@ -723,12 +722,13 @@
break;
} else {
if (fb_method != NULL) {
- st->fb_dispatch = 1;
+ saved_depth = st->fallback_depth;
+ st->fallback_depth = st->dispatch_depth + 1;
va_start(ap, defaults);
result = fb_method(retval,
(void *)srclist[i].name, ap);
va_end(ap);
- st->fb_dispatch = 0;
+ st->fallback_depth = saved_depth;
} else
nss_log(LOG_DEBUG, "%s, %s, %s, not found, "
"and no fallback provided",
@@ -760,6 +760,7 @@
if (isthreaded)
(void)_pthread_rwlock_unlock(&nss_lock);
+ --st->dispatch_depth;
fin:
errno = serrno;
return (result);
Modified: trunk/lib/libc/net/nslexer.l
===================================================================
--- trunk/lib/libc/net/nslexer.l 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/nslexer.l 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
%{
/* $NetBSD: nslexer.l,v 1.3 1999/01/25 00:16:17 lukem Exp $ */
@@ -16,13 +17,6 @@
* 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -40,7 +34,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
static char *rcsid =
- "$MidnightBSD$";
+ "$FreeBSD: stable/10/lib/libc/net/nslexer.l 251091 2013-05-29 01:54:10Z emaste $";
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
Property changes on: trunk/lib/libc/net/nslexer.l
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/net/nsparser.y
===================================================================
--- trunk/lib/libc/net/nsparser.y 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/nsparser.y 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
%{
/* $NetBSD: nsparser.y,v 1.3 1999/01/25 00:16:18 lukem Exp $ */
@@ -16,13 +17,6 @@
* 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -38,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/nsparser.y 251091 2013-05-29 01:54:10Z emaste $");
#include "namespace.h"
#define _NS_PRIVATE
Property changes on: trunk/lib/libc/net/nsparser.y
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/net/nss_backends.h
===================================================================
--- trunk/lib/libc/net/nss_backends.h 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/nss_backends.h 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Networks Associates Technology, Inc.
* All rights reserved.
@@ -29,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/net/nss_backends.h 113595 2003-04-17 14:14:22Z nectar $
*/
/*
* Eventually, the implementations of existing built-in NSS functions
Modified: trunk/lib/libc/net/nss_compat.c
===================================================================
--- trunk/lib/libc/net/nss_compat.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/nss_compat.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2003 Networks Associates Technology, Inc.
* All rights reserved.
@@ -32,7 +33,7 @@
* Compatibility shims for the GNU C Library-style nsswitch interface.
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/nss_compat.c 127625 2004-03-30 15:56:15Z nectar $");
#include "namespace.h"
#include <sys/param.h>
Modified: trunk/lib/libc/net/ntoh.c
===================================================================
--- trunk/lib/libc/net/ntoh.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/ntoh.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2006 Olivier Houchard
* All rights reserved.
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/ntoh.c 164053 2006-11-06 22:07:47Z cognet $");
#include <sys/endian.h>
Modified: trunk/lib/libc/net/rcmd.3
===================================================================
--- trunk/lib/libc/net/rcmd.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/rcmd.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)rcmd.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/rcmd.3 189208 2009-03-01 05:47:14Z delphij $
.\"
.Dd March 3, 2000
.Dt RCMD 3
Modified: trunk/lib/libc/net/rcmd.c
===================================================================
--- trunk/lib/libc/net/rcmd.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/rcmd.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1983, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -31,7 +32,7 @@
static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/rcmd.c 309485 2016-12-03 17:17:42Z ngie $");
#include "namespace.h"
#include <sys/param.h>
@@ -58,6 +59,7 @@
#endif
#include <arpa/nameser.h>
#include "un-namespace.h"
+#include "libc_private.h"
extern int innetgr( const char *, const char *, const char *, const char * );
@@ -148,7 +150,7 @@
refused = 0;
sigemptyset(&newmask);
sigaddset(&newmask, SIGURG);
- _sigprocmask(SIG_BLOCK, (const sigset_t *)&newmask, &oldmask);
+ __libc_sigprocmask(SIG_BLOCK, (const sigset_t *)&newmask, &oldmask);
for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
s = rresvport_af(&lport, ai->ai_family);
if (s < 0) {
@@ -163,7 +165,7 @@
(void)fprintf(stderr, "rcmd: socket: %s\n",
strerror(errno));
freeaddrinfo(res);
- _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask,
+ __libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask,
NULL);
return (-1);
}
@@ -181,7 +183,7 @@
(void)fprintf(stderr, "%s: %s\n",
*ahost, strerror(errno));
freeaddrinfo(res);
- _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask,
+ __libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask,
NULL);
return (-1);
}
@@ -213,7 +215,7 @@
}
}
lport--;
- if (fd2p == 0) {
+ if (fd2p == NULL) {
_write(s, "", 1);
lport = 0;
} else {
@@ -306,7 +308,7 @@
}
goto bad2;
}
- _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL);
+ __libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL);
freeaddrinfo(res);
return (s);
bad2:
@@ -314,7 +316,7 @@
(void)_close(*fd2p);
bad:
(void)_close(s);
- _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL);
+ __libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL);
freeaddrinfo(res);
return (-1);
}
@@ -458,7 +460,7 @@
raddr = (struct sockaddr *)&ss;
first = 1;
- hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "r");
+ hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "re");
again:
if (hostf) {
if (__ivaliduser_sa(hostf, raddr, rlen, luser, ruser) == 0) {
@@ -481,7 +483,7 @@
*/
uid = geteuid();
(void)seteuid(pwd->pw_uid);
- hostf = fopen(pbuf, "r");
+ hostf = fopen(pbuf, "re");
(void)seteuid(uid);
if (hostf == NULL)
Modified: trunk/lib/libc/net/rcmdsh.3
===================================================================
--- trunk/lib/libc/net/rcmdsh.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/rcmdsh.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" $OpenBSD: rcmdsh.3,v 1.6 1999/07/05 04:41:00 aaron Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
@@ -27,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/rcmdsh.3 165903 2007-01-09 00:28:16Z imp $
.\"
.Dd September 1, 1996
.Dt RCMDSH 3
Modified: trunk/lib/libc/net/rcmdsh.c
===================================================================
--- trunk/lib/libc/net/rcmdsh.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/rcmdsh.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,4 +1,5 @@
-/* $OpenBSD: rcmdsh.c,v 1.5 1998/04/25 16:23:58 millert Exp $ */
+/* $MidnightBSD$ */
+/* $OpenBSD: rcmdsh.c,v 1.7 2002/03/12 00:05:44 millert Exp $ */
/*
* Copyright (c) 2001, MagniComp
@@ -34,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/rcmdsh.c 287339 2015-09-01 01:03:45Z delphij $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -49,10 +50,6 @@
#include <string.h>
#include <unistd.h>
-#ifndef _PATH_RSH
-#define _PATH_RSH "/usr/bin/rsh"
-#endif
-
/*
* This is a replacement rcmd() function that uses the rsh(1)
* program in place of a direct rcmd(3) function call so as to
@@ -59,13 +56,12 @@
* avoid having to be root. Note that rport is ignored.
*/
int
-rcmdsh(ahost, rport, locuser, remuser, cmd, rshprog)
- char **ahost;
- int rport;
- const char *locuser, *remuser, *cmd, *rshprog;
+rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser,
+ const char *cmd, const char *rshprog)
{
struct addrinfo hints, *res;
- int cpid, sp[2], error;
+ int sp[2], error;
+ pid_t cpid;
char *p;
struct passwd *pw;
char num[8];
Modified: trunk/lib/libc/net/recv.c
===================================================================
--- trunk/lib/libc/net/recv.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/recv.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,14 +32,12 @@
static char sccsid[] = "@(#)recv.c 8.2 (Berkeley) 2/21/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/recv.c 251575 2013-06-09 14:31:59Z jilles $");
-#include "namespace.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <stddef.h>
-#include "un-namespace.h"
ssize_t
recv(s, buf, len, flags)
@@ -46,5 +45,9 @@
size_t len;
void *buf;
{
- return (_recvfrom(s, buf, len, flags, NULL, 0));
+ /*
+ * POSIX says recv() shall be a cancellation point, so call the
+ * cancellation-enabled recvfrom() and not _recvfrom().
+ */
+ return (recvfrom(s, buf, len, flags, NULL, 0));
}
Modified: trunk/lib/libc/net/res_config.h
===================================================================
--- trunk/lib/libc/net/res_config.h 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/res_config.h 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,4 +1,5 @@
/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/net/res_config.h 156960 2006-03-21 16:11:11Z ume $ */
#define DEBUG 1 /* enable debugging code (needed for dig) */
#define RESOLVSORT /* allow sorting of addresses in gethostbyname */
Modified: trunk/lib/libc/net/resolver.3
===================================================================
--- trunk/lib/libc/net/resolver.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/resolver.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)resolver.3 8.1 (Berkeley) 6/4/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/resolver.3 193024 2009-05-29 07:55:44Z delphij $
.\"
.Dd May 29, 2009
.Dt RESOLVER 3
Modified: trunk/lib/libc/net/rthdr.c
===================================================================
--- trunk/lib/libc/net/rthdr.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/rthdr.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/* $KAME: rthdr.c,v 1.19 2003/06/06 10:48:51 itojun Exp $ */
/*
@@ -30,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/rthdr.c 168867 2007-04-19 15:48:16Z mtm $");
#include <sys/param.h>
#include <sys/types.h>
Modified: trunk/lib/libc/net/sctp_bindx.3
===================================================================
--- trunk/lib/libc/net/sctp_bindx.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/sctp_bindx.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -9,11 +10,7 @@
.\" 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. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 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.
.\"
@@ -30,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/sctp_bindx.3 284506 2015-06-17 09:41:16Z tuexen $
.\"
-.Dd December 15, 2006
+.Dd June 14, 2015
.Dt SCTP_BINDX 3
.Os
.Sh NAME
@@ -75,7 +72,7 @@
This value indicates that the listed address(es) need to
be added to the endpoint.
.Pp
-.Dv SCTP_BINDX_DEL_ADDR
+.Dv SCTP_BINDX_REM_ADDR
This value indicates that the listed address(es) need to
be removed from the endpoint.
.Pp
Modified: trunk/lib/libc/net/sctp_connectx.3
===================================================================
--- trunk/lib/libc/net/sctp_connectx.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/sctp_connectx.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -9,11 +10,7 @@
.\" 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. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 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.
.\"
@@ -29,7 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/sctp_connectx.3 251067 2013-05-28 20:37:48Z emaste $
.\"
.Dd June 19, 2007
.Dt SCTP_CONNECTX 3
Modified: trunk/lib/libc/net/sctp_freepaddrs.3
===================================================================
--- trunk/lib/libc/net/sctp_freepaddrs.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/sctp_freepaddrs.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -9,11 +10,7 @@
.\" 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. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 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.
.\"
@@ -30,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/sctp_freepaddrs.3 251067 2013-05-28 20:37:48Z emaste $
.\"
.Dd December 15, 2006
.Dt SCTP_FREEPADDRS 3
Modified: trunk/lib/libc/net/sctp_getaddrlen.3
===================================================================
--- trunk/lib/libc/net/sctp_getaddrlen.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/sctp_getaddrlen.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -9,11 +10,7 @@
.\" 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. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 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.
.\"
@@ -30,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/sctp_getaddrlen.3 251067 2013-05-28 20:37:48Z emaste $
.\"
.Dd December 15, 2006
.Dt SCTP_GETADDRLEN 3
Modified: trunk/lib/libc/net/sctp_getassocid.3
===================================================================
--- trunk/lib/libc/net/sctp_getassocid.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/sctp_getassocid.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -9,11 +10,7 @@
.\" 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. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 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.
.\"
@@ -29,7 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/sctp_getassocid.3 251067 2013-05-28 20:37:48Z emaste $
.\"
.Dd December 15, 2006
.Dt SCTP_GETASSOCID 3
@@ -51,7 +48,6 @@
call attempts to look up the specified socket address
.Fa addr
and find the respective association identification.
-.Pp
.Sh RETURN VALUES
The call returns the association id upon success and
0 is returned upon failure.
Modified: trunk/lib/libc/net/sctp_getpaddrs.3
===================================================================
--- trunk/lib/libc/net/sctp_getpaddrs.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/sctp_getpaddrs.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -9,11 +10,7 @@
.\" 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. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 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.
.\"
@@ -30,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/sctp_getpaddrs.3 251067 2013-05-28 20:37:48Z emaste $
.\"
.Dd December 15, 2006
.Dt SCTP_GETPADDRS 3
Modified: trunk/lib/libc/net/sctp_opt_info.3
===================================================================
--- trunk/lib/libc/net/sctp_opt_info.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/sctp_opt_info.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -9,11 +10,7 @@
.\" 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. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 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.
.\"
@@ -30,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/sctp_opt_info.3 251067 2013-05-28 20:37:48Z emaste $
.\"
.Dd June 18, 2011
.Dt SCTP_OPT_INFO 3
Modified: trunk/lib/libc/net/sctp_recvmsg.3
===================================================================
--- trunk/lib/libc/net/sctp_recvmsg.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/sctp_recvmsg.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -9,11 +10,7 @@
.\" 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. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 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.
.\"
@@ -29,9 +26,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/sctp_recvmsg.3 283739 2015-05-29 13:32:08Z tuexen $
.\"
-.Dd August 13, 2007
+.Dd April 23, 2015
.Dt SCTP_RECVMSG 3
.Os
.Sh NAME
@@ -102,13 +99,13 @@
argument will
.Em not
have the
-.Dv MSG_EOF
+.Dv MSG_EOR
flag applied.
If the message is a complete message then
the
.Fa flags
argument will have
-.Dv MSG_EOF
+.Dv MSG_EOR
set.
Locally detected errors are
indicated by a return value of -1 with
Modified: trunk/lib/libc/net/sctp_send.3
===================================================================
--- trunk/lib/libc/net/sctp_send.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/sctp_send.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -9,11 +10,7 @@
.\" 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. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 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.
.\"
@@ -29,7 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/sctp_send.3 321154 2017-07-18 18:34:16Z ngie $
.\"
.Dd December 15, 2006
.Dt SCTP_SEND 3
@@ -109,8 +106,8 @@
The
.Fa sinfo->sinfo_ppid
argument is an opaque 32 bit value that is passed transparently
-through the stack to the peer endpoint. It will be available on
-reception of a message (see
+through the stack to the peer endpoint.
+It will be available on reception of a message (see
.Xr sctp_recvmsg 3 ) .
Note that the stack passes this value without regard to byte
order.
Modified: trunk/lib/libc/net/sctp_sendmsg.3
===================================================================
--- trunk/lib/libc/net/sctp_sendmsg.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/sctp_sendmsg.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -9,11 +10,7 @@
.\" 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. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 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.
.\"
@@ -30,7 +27,7 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/sctp_sendmsg.3 251067 2013-05-28 20:37:48Z emaste $
.\"
.Dd December 15, 2006
.Dt SCTP_SENDMSG 3
Modified: trunk/lib/libc/net/sctp_sys_calls.c
===================================================================
--- trunk/lib/libc/net/sctp_sys_calls.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/sctp_sys_calls.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
@@ -31,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/sctp_sys_calls.c 294911 2016-01-27 14:01:21Z tuexen $");
#include <stdio.h>
#include <string.h>
@@ -48,8 +49,6 @@
#include <netinet/sctp_uio.h>
#include <netinet/sctp.h>
-#include <net/if_dl.h>
-
#ifndef IN6_IS_ADDR_V4MAPPED
#define IN6_IS_ADDR_V4MAPPED(a) \
((*(const uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
@@ -57,79 +56,10 @@
(*(const uint32_t *)(const void *)(&(a)->s6_addr[8]) == ntohl(0x0000ffff)))
#endif
-
-#define SCTP_CONTROL_VEC_SIZE_SND 8192
#define SCTP_CONTROL_VEC_SIZE_RCV 16384
-#define SCTP_STACK_BUF_SIZE 2048
-#ifdef SCTP_DEBUG_PRINT_ADDRESS
-#define SCTP_STRING_BUF_SZ 256
-
static void
-SCTPPrintAnAddress(struct sockaddr *a)
-{
- char stringToPrint[SCTP_STRING_BUF_SZ];
- u_short prt;
- char *srcaddr, *txt;
-
- if (a == NULL) {
- printf("NULL\n");
- return;
- }
- if (a->sa_family == AF_INET) {
- srcaddr = (char *)&((struct sockaddr_in *)a)->sin_addr;
- txt = "IPv4 Address: ";
- prt = ntohs(((struct sockaddr_in *)a)->sin_port);
- } else if (a->sa_family == AF_INET6) {
- srcaddr = (char *)&((struct sockaddr_in6 *)a)->sin6_addr;
- prt = ntohs(((struct sockaddr_in6 *)a)->sin6_port);
- txt = "IPv6 Address: ";
- } else if (a->sa_family == AF_LINK) {
- int i;
- char tbuf[SCTP_STRING_BUF_SZ];
- u_char adbuf[SCTP_STRING_BUF_SZ];
- struct sockaddr_dl *dl;
-
- dl = (struct sockaddr_dl *)a;
- strncpy(tbuf, dl->sdl_data, dl->sdl_nlen);
- tbuf[dl->sdl_nlen] = 0;
- printf("Intf:%s (len:%d)Interface index:%d type:%x(%d) ll-len:%d ",
- tbuf,
- dl->sdl_nlen,
- dl->sdl_index,
- dl->sdl_type,
- dl->sdl_type,
- dl->sdl_alen
- );
- memcpy(adbuf, LLADDR(dl), dl->sdl_alen);
- for (i = 0; i < dl->sdl_alen; i++) {
- printf("%2.2x", adbuf[i]);
- if (i < (dl->sdl_alen - 1))
- printf(":");
- }
- printf("\n");
- return;
- } else {
- return;
- }
- if (inet_ntop(a->sa_family, srcaddr, stringToPrint, sizeof(stringToPrint))) {
- if (a->sa_family == AF_INET6) {
- printf("%s%s:%d scope:%d\n",
- txt, stringToPrint, prt,
- ((struct sockaddr_in6 *)a)->sin6_scope_id);
- } else {
- printf("%s%s:%d\n", txt, stringToPrint, prt);
- }
-
- } else {
- printf("%s unprintable?\n", txt);
- }
-}
-
-#endif /* SCTP_DEBUG_PRINT_ADDRESS */
-
-static void
in6_sin6_2_sin(struct sockaddr_in *sin, struct sockaddr_in6 *sin6)
{
bzero(sin, sizeof(*sin));
@@ -171,12 +101,11 @@
sctp_connectx(int sd, const struct sockaddr *addrs, int addrcnt,
sctp_assoc_t * id)
{
- char buf[SCTP_STACK_BUF_SIZE];
- int i, ret, cnt, *aa;
+ char *buf;
+ int i, ret, *aa;
char *cpto;
const struct sockaddr *at;
- sctp_assoc_t *p_id;
- size_t len = sizeof(int);
+ size_t len;
/* validate the address count and list */
if ((addrs == NULL) || (addrcnt <= 0)) {
@@ -183,59 +112,57 @@
errno = EINVAL;
return (-1);
}
+ if ((buf = malloc(sizeof(int) + (size_t)addrcnt * sizeof(struct sockaddr_in6))) == NULL) {
+ errno = E2BIG;
+ return (-1);
+ }
+ len = sizeof(int);
at = addrs;
- cnt = 0;
- cpto = ((caddr_t)buf + sizeof(int));
+ cpto = buf + sizeof(int);
/* validate all the addresses and get the size */
for (i = 0; i < addrcnt; i++) {
- if (at->sa_family == AF_INET) {
+ switch (at->sa_family) {
+ case AF_INET:
if (at->sa_len != sizeof(struct sockaddr_in)) {
+ free(buf);
errno = EINVAL;
return (-1);
}
- memcpy(cpto, at, at->sa_len);
- cpto = ((caddr_t)cpto + at->sa_len);
- len += at->sa_len;
- } else if (at->sa_family == AF_INET6) {
+ memcpy(cpto, at, sizeof(struct sockaddr_in));
+ cpto = ((caddr_t)cpto + sizeof(struct sockaddr_in));
+ len += sizeof(struct sockaddr_in);
+ break;
+ case AF_INET6:
if (at->sa_len != sizeof(struct sockaddr_in6)) {
+ free(buf);
errno = EINVAL;
return (-1);
}
if (IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)at)->sin6_addr)) {
- len += sizeof(struct sockaddr_in);
in6_sin6_2_sin((struct sockaddr_in *)cpto, (struct sockaddr_in6 *)at);
cpto = ((caddr_t)cpto + sizeof(struct sockaddr_in));
len += sizeof(struct sockaddr_in);
} else {
- memcpy(cpto, at, at->sa_len);
- cpto = ((caddr_t)cpto + at->sa_len);
- len += at->sa_len;
+ memcpy(cpto, at, sizeof(struct sockaddr_in6));
+ cpto = ((caddr_t)cpto + sizeof(struct sockaddr_in6));
+ len += sizeof(struct sockaddr_in6);
}
- } else {
+ break;
+ default:
+ free(buf);
errno = EINVAL;
return (-1);
}
- if (len > (sizeof(buf) - sizeof(int))) {
- /* Never enough memory */
- errno = E2BIG;
- return (-1);
- }
at = (struct sockaddr *)((caddr_t)at + at->sa_len);
- cnt++;
}
- /* do we have any? */
- if (cnt == 0) {
- errno = EINVAL;
- return (-1);
- }
aa = (int *)buf;
- *aa = cnt;
+ *aa = addrcnt;
ret = setsockopt(sd, IPPROTO_SCTP, SCTP_CONNECT_X, (void *)buf,
(socklen_t) len);
- if ((ret == 0) && id) {
- p_id = (sctp_assoc_t *) buf;
- *id = *p_id;
+ if ((ret == 0) && (id != NULL)) {
+ *id = *(sctp_assoc_t *) buf;
}
+ free(buf);
return (ret);
}
@@ -261,19 +188,15 @@
errno = EINVAL;
return (-1);
}
- argsz = (sizeof(struct sockaddr_storage) +
- sizeof(struct sctp_getaddresses));
- gaddrs = (struct sctp_getaddresses *)calloc(1, argsz);
- if (gaddrs == NULL) {
- errno = ENOMEM;
- return (-1);
- }
/* First pre-screen the addresses */
sa = addrs;
for (i = 0; i < addrcnt; i++) {
- if (sa->sa_family == AF_INET) {
- if (sa->sa_len != sizeof(struct sockaddr_in))
- goto out_error;
+ switch (sa->sa_family) {
+ case AF_INET:
+ if (sa->sa_len != sizeof(struct sockaddr_in)) {
+ errno = EINVAL;
+ return (-1);
+ }
sin = (struct sockaddr_in *)sa;
if (sin->sin_port) {
/* non-zero port, check or save */
@@ -280,7 +203,8 @@
if (sport) {
/* Check against our port */
if (sport != sin->sin_port) {
- goto out_error;
+ errno = EINVAL;
+ return (-1);
}
} else {
/* save off the port */
@@ -287,9 +211,12 @@
sport = sin->sin_port;
}
}
- } else if (sa->sa_family == AF_INET6) {
- if (sa->sa_len != sizeof(struct sockaddr_in6))
- goto out_error;
+ break;
+ case AF_INET6:
+ if (sa->sa_len != sizeof(struct sockaddr_in6)) {
+ errno = EINVAL;
+ return (-1);
+ }
sin6 = (struct sockaddr_in6 *)sa;
if (sin6->sin6_port) {
/* non-zero port, check or save */
@@ -296,7 +223,8 @@
if (sport) {
/* Check against our port */
if (sport != sin6->sin6_port) {
- goto out_error;
+ errno = EINVAL;
+ return (-1);
}
} else {
/* save off the port */
@@ -303,39 +231,42 @@
sport = sin6->sin6_port;
}
}
- } else {
- /* invalid address family specified */
- goto out_error;
+ break;
+ default:
+ /* Invalid address family specified. */
+ errno = EAFNOSUPPORT;
+ return (-1);
}
-
sa = (struct sockaddr *)((caddr_t)sa + sa->sa_len);
}
+ argsz = sizeof(struct sctp_getaddresses) +
+ sizeof(struct sockaddr_storage);
+ if ((gaddrs = (struct sctp_getaddresses *)malloc(argsz)) == NULL) {
+ errno = ENOMEM;
+ return (-1);
+ }
sa = addrs;
- /*
- * Now if there was a port mentioned, assure that the first address
- * has that port to make sure it fails or succeeds correctly.
- */
- if (sport) {
- sin = (struct sockaddr_in *)sa;
- sin->sin_port = sport;
- }
for (i = 0; i < addrcnt; i++) {
- if (sa->sa_family == AF_INET) {
- if (sa->sa_len != sizeof(struct sockaddr_in))
- goto out_error;
- } else if (sa->sa_family == AF_INET6) {
- if (sa->sa_len != sizeof(struct sockaddr_in6))
- goto out_error;
- } else {
- /* invalid address family specified */
- out_error:
- free(gaddrs);
- errno = EINVAL;
- return (-1);
- }
memset(gaddrs, 0, argsz);
gaddrs->sget_assoc_id = 0;
memcpy(gaddrs->addr, sa, sa->sa_len);
+ /*
+ * Now, if there was a port mentioned, assure that the first
+ * address has that port to make sure it fails or succeeds
+ * correctly.
+ */
+ if ((i == 0) && (sport != 0)) {
+ switch (gaddrs->addr->sa_family) {
+ case AF_INET:
+ sin = (struct sockaddr_in *)gaddrs->addr;
+ sin->sin_port = sport;
+ break;
+ case AF_INET6:
+ sin6 = (struct sockaddr_in6 *)gaddrs->addr;
+ sin6->sin6_port = sport;
+ break;
+ }
+ }
if (setsockopt(sd, IPPROTO_SCTP, flags, gaddrs,
(socklen_t) argsz) != 0) {
free(gaddrs);
@@ -347,7 +278,6 @@
return (0);
}
-
int
sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t * size)
{
@@ -355,6 +285,11 @@
errno = EINVAL;
return (-1);
}
+ if ((id == SCTP_CURRENT_ASSOC) ||
+ (id == SCTP_ALL_ASSOC)) {
+ errno = EINVAL;
+ return (-1);
+ }
switch (opt) {
case SCTP_RTOINFO:
((struct sctp_rtoinfo *)arg)->srto_assoc_id = id;
@@ -416,9 +351,42 @@
case SCTP_REMOTE_UDP_ENCAPS_PORT:
((struct sctp_udpencaps *)arg)->sue_assoc_id = id;
break;
+ case SCTP_ECN_SUPPORTED:
+ ((struct sctp_assoc_value *)arg)->assoc_id = id;
+ break;
+ case SCTP_PR_SUPPORTED:
+ ((struct sctp_assoc_value *)arg)->assoc_id = id;
+ break;
+ case SCTP_AUTH_SUPPORTED:
+ ((struct sctp_assoc_value *)arg)->assoc_id = id;
+ break;
+ case SCTP_ASCONF_SUPPORTED:
+ ((struct sctp_assoc_value *)arg)->assoc_id = id;
+ break;
+ case SCTP_RECONFIG_SUPPORTED:
+ ((struct sctp_assoc_value *)arg)->assoc_id = id;
+ break;
+ case SCTP_NRSACK_SUPPORTED:
+ ((struct sctp_assoc_value *)arg)->assoc_id = id;
+ break;
+ case SCTP_PKTDROP_SUPPORTED:
+ ((struct sctp_assoc_value *)arg)->assoc_id = id;
+ break;
case SCTP_MAX_BURST:
((struct sctp_assoc_value *)arg)->assoc_id = id;
break;
+ case SCTP_ENABLE_STREAM_RESET:
+ ((struct sctp_assoc_value *)arg)->assoc_id = id;
+ break;
+ case SCTP_PR_STREAM_STATUS:
+ ((struct sctp_prstatus *)arg)->sprstat_assoc_id = id;
+ break;
+ case SCTP_PR_ASSOC_STATUS:
+ ((struct sctp_prstatus *)arg)->sprstat_assoc_id = id;
+ break;
+ case SCTP_MAX_CWND:
+ ((struct sctp_assoc_value *)arg)->assoc_id = id;
+ break;
default:
break;
}
@@ -449,6 +417,7 @@
opt_len = (socklen_t) ((size_t)asoc + sizeof(struct sctp_getaddresses));
addrs = calloc(1, (size_t)opt_len);
if (addrs == NULL) {
+ errno = ENOMEM;
return (-1);
}
addrs->sget_assoc_id = id;
@@ -472,9 +441,9 @@
void
sctp_freepaddrs(struct sockaddr *addrs)
{
- /* Take away the hidden association id */
void *fr_addr;
+ /* Take away the hidden association id */
fr_addr = (void *)((caddr_t)addrs - sizeof(sctp_assoc_t));
/* Now free it */
free(fr_addr);
@@ -535,15 +504,14 @@
void
sctp_freeladdrs(struct sockaddr *addrs)
{
- /* Take away the hidden association id */
void *fr_addr;
+ /* Take away the hidden association id */
fr_addr = (void *)((caddr_t)addrs - sizeof(sctp_assoc_t));
/* Now free it */
free(fr_addr);
}
-
ssize_t
sctp_sendmsg(int s,
const void *data,
@@ -569,11 +537,10 @@
return (syscall(SYS_sctp_generic_sendmsg, s,
data, len, to, tolen, &sinfo, 0));
#else
- ssize_t sz;
struct msghdr msg;
- struct sctp_sndrcvinfo *s_info;
+ struct sctp_sndrcvinfo *sinfo;
struct iovec iov;
- char controlVector[SCTP_CONTROL_VEC_SIZE_RCV];
+ char cmsgbuf[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))];
struct cmsghdr *cmsg;
struct sockaddr *who = NULL;
union {
@@ -584,36 +551,39 @@
if ((tolen > 0) &&
((to == NULL) || (tolen < sizeof(struct sockaddr)))) {
errno = EINVAL;
- return -1;
+ return (-1);
}
- if (to && (tolen > 0)) {
- if (to->sa_family == AF_INET) {
+ if ((to != NULL) && (tolen > 0)) {
+ switch (to->sa_family) {
+ case AF_INET:
if (tolen != sizeof(struct sockaddr_in)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
if ((to->sa_len > 0) &&
(to->sa_len != sizeof(struct sockaddr_in))) {
errno = EINVAL;
- return -1;
+ return (-1);
}
memcpy(&addr, to, sizeof(struct sockaddr_in));
addr.in.sin_len = sizeof(struct sockaddr_in);
- } else if (to->sa_family == AF_INET6) {
+ break;
+ case AF_INET6:
if (tolen != sizeof(struct sockaddr_in6)) {
errno = EINVAL;
- return -1;
+ return (-1);
}
if ((to->sa_len > 0) &&
(to->sa_len != sizeof(struct sockaddr_in6))) {
errno = EINVAL;
- return -1;
+ return (-1);
}
memcpy(&addr, to, sizeof(struct sockaddr_in6));
addr.in6.sin6_len = sizeof(struct sockaddr_in6);
- } else {
+ break;
+ default:
errno = EAFNOSUPPORT;
- return -1;
+ return (-1);
}
who = (struct sockaddr *)&addr;
}
@@ -629,26 +599,23 @@
}
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
- msg.msg_control = (caddr_t)controlVector;
-
- cmsg = (struct cmsghdr *)controlVector;
-
+ msg.msg_control = cmsgbuf;
+ msg.msg_controllen = CMSG_SPACE(sizeof(struct sctp_sndrcvinfo));
+ msg.msg_flags = 0;
+ cmsg = (struct cmsghdr *)cmsgbuf;
cmsg->cmsg_level = IPPROTO_SCTP;
cmsg->cmsg_type = SCTP_SNDRCV;
cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
- s_info = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg);
-
- s_info->sinfo_stream = stream_no;
- s_info->sinfo_ssn = 0;
- s_info->sinfo_flags = flags;
- s_info->sinfo_ppid = ppid;
- s_info->sinfo_context = context;
- s_info->sinfo_assoc_id = 0;
- s_info->sinfo_timetolive = timetolive;
- errno = 0;
- msg.msg_controllen = cmsg->cmsg_len;
- sz = sendmsg(s, &msg, 0);
- return (sz);
+ sinfo = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg);
+ memset(sinfo, 0, sizeof(struct sctp_sndrcvinfo));
+ sinfo->sinfo_stream = stream_no;
+ sinfo->sinfo_ssn = 0;
+ sinfo->sinfo_flags = flags;
+ sinfo->sinfo_ppid = ppid;
+ sinfo->sinfo_context = context;
+ sinfo->sinfo_assoc_id = 0;
+ sinfo->sinfo_timetolive = timetolive;
+ return (sendmsg(s, &msg, 0));
#endif
}
@@ -663,12 +630,11 @@
siz = sizeof(sp);
memset(&sp, 0, sizeof(sp));
memcpy((caddr_t)&sp.spinfo_address, sa, sa->sa_len);
- errno = 0;
if (getsockopt(sd, IPPROTO_SCTP,
SCTP_GET_PEER_ADDR_INFO, &sp, &siz) != 0) {
+ /* We depend on the fact that 0 can never be returned */
return ((sctp_assoc_t) 0);
}
- /* We depend on the fact that 0 can never be returned */
return (sp.spinfo_assoc_id);
}
@@ -684,11 +650,9 @@
return (syscall(SYS_sctp_generic_sendmsg, sd,
data, len, to, 0, sinfo, flags));
#else
- ssize_t sz;
struct msghdr msg;
struct iovec iov;
- struct sctp_sndrcvinfo *s_info;
- char controlVector[SCTP_CONTROL_VEC_SIZE_SND];
+ char cmsgbuf[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))];
struct cmsghdr *cmsg;
if (sinfo == NULL) {
@@ -698,24 +662,19 @@
iov.iov_base = (char *)data;
iov.iov_len = len;
- msg.msg_name = 0;
+ msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
- msg.msg_control = (caddr_t)controlVector;
-
- cmsg = (struct cmsghdr *)controlVector;
-
+ msg.msg_control = cmsgbuf;
+ msg.msg_controllen = CMSG_SPACE(sizeof(struct sctp_sndrcvinfo));
+ msg.msg_flags = 0;
+ cmsg = (struct cmsghdr *)cmsgbuf;
cmsg->cmsg_level = IPPROTO_SCTP;
cmsg->cmsg_type = SCTP_SNDRCV;
cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
- s_info = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg);
- /* copy in the data */
- *s_info = *sinfo;
- errno = 0;
- msg.msg_controllen = cmsg->cmsg_len;
- sz = sendmsg(sd, &msg, flags);
- return (sz);
+ memcpy(CMSG_DATA(cmsg), sinfo, sizeof(struct sctp_sndrcvinfo));
+ return (sendmsg(sd, &msg, flags));
#endif
}
@@ -742,6 +701,7 @@
#ifdef SYS_sctp_generic_sendmsg
if (addrcnt == 1) {
socklen_t l;
+ ssize_t ret;
/*
* Quick way, we don't need to do a connectx so lets use the
@@ -748,8 +708,12 @@
* syscall directly.
*/
l = addrs->sa_len;
- return (syscall(SYS_sctp_generic_sendmsg, sd,
- msg, msg_len, addrs, l, sinfo, flags));
+ ret = syscall(SYS_sctp_generic_sendmsg, sd,
+ msg, msg_len, addrs, l, sinfo, flags);
+ if ((ret >= 0) && (sinfo != NULL)) {
+ sinfo->sinfo_assoc_id = sctp_getassocid(sd, addrs);
+ }
+ return (ret);
}
#endif
@@ -777,6 +741,7 @@
}
buf = malloc(len);
if (buf == NULL) {
+ errno = ENOMEM;
return (-1);
}
aa = (int *)buf;
@@ -836,7 +801,7 @@
sinfo.sinfo_ssn = stream_no;
sinfo.sinfo_timetolive = timetolive;
sinfo.sinfo_context = context;
- return sctp_sendx(sd, msg, len, addrs, addrcnt, &sinfo, 0);
+ return (sctp_sendx(sd, msg, len, addrs, addrcnt, &sinfo, 0));
}
ssize_t
@@ -856,11 +821,10 @@
return (syscall(SYS_sctp_generic_recvmsg, s,
&iov, 1, from, fromlen, sinfo, msg_flags));
#else
- struct sctp_sndrcvinfo *s_info;
ssize_t sz;
struct msghdr msg;
struct iovec iov;
- char controlVector[SCTP_CONTROL_VEC_SIZE_RCV];
+ char cmsgbuf[SCTP_CONTROL_VEC_SIZE_RCV];
struct cmsghdr *cmsg;
if (msg_flags == NULL) {
@@ -867,7 +831,6 @@
errno = EINVAL;
return (-1);
}
- msg.msg_flags = 0;
iov.iov_base = dbuf;
iov.iov_len = len;
msg.msg_name = (caddr_t)from;
@@ -877,52 +840,39 @@
msg.msg_namelen = *fromlen;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
- msg.msg_control = (caddr_t)controlVector;
- msg.msg_controllen = sizeof(controlVector);
- errno = 0;
+ msg.msg_control = cmsgbuf;
+ msg.msg_controllen = sizeof(cmsgbuf);
+ msg.msg_flags = 0;
sz = recvmsg(s, &msg, *msg_flags);
*msg_flags = msg.msg_flags;
if (sz <= 0) {
return (sz);
}
- s_info = NULL;
if (sinfo) {
sinfo->sinfo_assoc_id = 0;
}
- if ((msg.msg_controllen) && sinfo) {
+ if ((msg.msg_controllen > 0) && (sinfo != NULL)) {
/*
* parse through and see if we find the sctp_sndrcvinfo (if
* the user wants it).
*/
- cmsg = (struct cmsghdr *)controlVector;
- while (cmsg) {
- if ((cmsg->cmsg_len == 0) || (cmsg->cmsg_len > msg.msg_controllen)) {
+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+ if (cmsg->cmsg_level != IPPROTO_SCTP) {
+ continue;
+ }
+ if (cmsg->cmsg_type == SCTP_SNDRCV) {
+ memcpy(sinfo, CMSG_DATA(cmsg), sizeof(struct sctp_sndrcvinfo));
break;
}
- if (cmsg->cmsg_level == IPPROTO_SCTP) {
- if (cmsg->cmsg_type == SCTP_SNDRCV) {
- /* Got it */
- s_info = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg);
- /* Copy it to the user */
- if (sinfo)
- *sinfo = *s_info;
- break;
- } else if (cmsg->cmsg_type == SCTP_EXTRCV) {
- /*
- * Got it, presumably the user has
- * asked for this extra info, so the
- * structure holds more room :-D
- */
- s_info = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg);
- /* Copy it to the user */
- if (sinfo) {
- memcpy(sinfo, s_info, sizeof(struct sctp_extrcvinfo));
- }
- break;
-
- }
+ if (cmsg->cmsg_type == SCTP_EXTRCV) {
+ /*
+ * Let's hope that the user provided enough
+ * enough memory. At least he asked for more
+ * information.
+ */
+ memcpy(sinfo, CMSG_DATA(cmsg), sizeof(struct sctp_extrcvinfo));
+ break;
}
- cmsg = CMSG_NXTHDR(&msg, cmsg);
}
}
return (sz);
@@ -940,14 +890,14 @@
unsigned int *infotype,
int *flags)
{
- char ctlbuf[SCTP_CONTROL_VEC_SIZE_RCV];
+ char cmsgbuf[SCTP_CONTROL_VEC_SIZE_RCV];
struct msghdr msg;
struct cmsghdr *cmsg;
- ssize_t n;
+ ssize_t ret;
struct sctp_rcvinfo *rcvinfo;
struct sctp_nxtinfo *nxtinfo;
- if (((info != NULL) && (infolen == NULL)) |
+ if (((info != NULL) && (infolen == NULL)) ||
((info == NULL) && (infolen != NULL) && (*infolen != 0)) ||
((info != NULL) && (infotype == NULL))) {
errno = EINVAL;
@@ -964,12 +914,12 @@
}
msg.msg_iov = (struct iovec *)iov;
msg.msg_iovlen = iovlen;
- msg.msg_control = ctlbuf;
- msg.msg_controllen = sizeof(ctlbuf);
- errno = 0;
- n = recvmsg(sd, &msg, *flags);
+ msg.msg_control = cmsgbuf;
+ msg.msg_controllen = sizeof(cmsgbuf);
+ msg.msg_flags = 0;
+ ret = recvmsg(sd, &msg, *flags);
*flags = msg.msg_flags;
- if ((n > 0) &&
+ if ((ret > 0) &&
(msg.msg_controllen > 0) &&
(infotype != NULL) &&
(infolen != NULL) &&
@@ -982,34 +932,37 @@
}
if (cmsg->cmsg_type == SCTP_RCVINFO) {
rcvinfo = (struct sctp_rcvinfo *)CMSG_DATA(cmsg);
+ if (nxtinfo != NULL) {
+ break;
+ } else {
+ continue;
+ }
}
if (cmsg->cmsg_type == SCTP_NXTINFO) {
nxtinfo = (struct sctp_nxtinfo *)CMSG_DATA(cmsg);
+ if (rcvinfo != NULL) {
+ break;
+ } else {
+ continue;
+ }
}
- if (rcvinfo && nxtinfo) {
- break;
- }
}
- if (rcvinfo) {
- if (nxtinfo) {
- if (*infolen >= sizeof(struct sctp_recvv_rn)) {
- struct sctp_recvv_rn *rn_info;
+ if (rcvinfo != NULL) {
+ if ((nxtinfo != NULL) && (*infolen >= sizeof(struct sctp_recvv_rn))) {
+ struct sctp_recvv_rn *rn_info;
- rn_info = (struct sctp_recvv_rn *)info;
- rn_info->recvv_rcvinfo = *rcvinfo;
- rn_info->recvv_nxtinfo = *nxtinfo;
- *infolen = (socklen_t) sizeof(struct sctp_recvv_rn);
- *infotype = SCTP_RECVV_RN;
- }
- } else {
- if (*infolen >= sizeof(struct sctp_rcvinfo)) {
- memcpy(info, rcvinfo, sizeof(struct sctp_rcvinfo));
- *infolen = (socklen_t) sizeof(struct sctp_rcvinfo);
- *infotype = SCTP_RECVV_RCVINFO;
- }
+ rn_info = (struct sctp_recvv_rn *)info;
+ rn_info->recvv_rcvinfo = *rcvinfo;
+ rn_info->recvv_nxtinfo = *nxtinfo;
+ *infolen = (socklen_t) sizeof(struct sctp_recvv_rn);
+ *infotype = SCTP_RECVV_RN;
+ } else if (*infolen >= sizeof(struct sctp_rcvinfo)) {
+ memcpy(info, rcvinfo, sizeof(struct sctp_rcvinfo));
+ *infolen = (socklen_t) sizeof(struct sctp_rcvinfo);
+ *infotype = SCTP_RECVV_RCVINFO;
}
- } else if (nxtinfo) {
- if (*infolen >= sizeof(struct sctp_rcvinfo)) {
+ } else if (nxtinfo != NULL) {
+ if (*infolen >= sizeof(struct sctp_nxtinfo)) {
memcpy(info, nxtinfo, sizeof(struct sctp_nxtinfo));
*infolen = (socklen_t) sizeof(struct sctp_nxtinfo);
*infotype = SCTP_RECVV_NXTINFO;
@@ -1016,7 +969,7 @@
}
}
}
- return (n);
+ return (ret);
}
ssize_t
@@ -1037,6 +990,7 @@
struct sockaddr *addr;
struct sockaddr_in *addr_in;
struct sockaddr_in6 *addr_in6;
+ sctp_assoc_t *assoc_id;
if ((addrcnt < 0) ||
(iovcnt < 0) ||
@@ -1052,9 +1006,10 @@
CMSG_SPACE(sizeof(struct sctp_authinfo)) +
(size_t)addrcnt * CMSG_SPACE(sizeof(struct in6_addr)));
if (cmsgbuf == NULL) {
- errno = ENOBUFS;
+ errno = ENOMEM;
return (-1);
}
+ assoc_id = NULL;
msg.msg_control = cmsgbuf;
msg.msg_controllen = 0;
cmsg = (struct cmsghdr *)cmsgbuf;
@@ -1078,6 +1033,7 @@
memcpy(CMSG_DATA(cmsg), info, sizeof(struct sctp_sndinfo));
msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_sndinfo));
cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_sndinfo)));
+ assoc_id = &(((struct sctp_sndinfo *)info)->snd_assoc_id);
break;
case SCTP_SENDV_PRINFO:
if ((info == NULL) || (infolen < sizeof(struct sctp_prinfo))) {
@@ -1119,6 +1075,7 @@
memcpy(CMSG_DATA(cmsg), &spa_info->sendv_sndinfo, sizeof(struct sctp_sndinfo));
msg.msg_controllen += CMSG_SPACE(sizeof(struct sctp_sndinfo));
cmsg = (struct cmsghdr *)((caddr_t)cmsg + CMSG_SPACE(sizeof(struct sctp_sndinfo)));
+ assoc_id = &(spa_info->sendv_sndinfo.snd_assoc_id);
}
if (spa_info->sendv_flags & SCTP_SEND_PRINFO_VALID) {
cmsg->cmsg_level = IPPROTO_SCTP;
@@ -1217,6 +1174,9 @@
msg.msg_flags = 0;
ret = sendmsg(sd, &msg, flags);
free(cmsgbuf);
+ if ((ret >= 0) && (addrs != NULL) && (assoc_id != NULL)) {
+ *assoc_id = sctp_getassocid(sd, addrs);
+ }
return (ret);
}
@@ -1241,7 +1201,4 @@
#endif
-
-#undef SCTP_CONTROL_VEC_SIZE_SND
#undef SCTP_CONTROL_VEC_SIZE_RCV
-#undef SCTP_STACK_BUF_SIZE
Modified: trunk/lib/libc/net/send.c
===================================================================
--- trunk/lib/libc/net/send.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/send.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,14 +32,12 @@
static char sccsid[] = "@(#)send.c 8.2 (Berkeley) 2/21/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/net/send.c 251575 2013-06-09 14:31:59Z jilles $");
-#include "namespace.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <stddef.h>
-#include "un-namespace.h"
ssize_t
send(s, msg, len, flags)
@@ -46,5 +45,9 @@
size_t len;
const void *msg;
{
- return (_sendto(s, msg, len, flags, NULL, 0));
+ /*
+ * POSIX says send() shall be a cancellation point, so call the
+ * cancellation-enabled sendto() and not _sendto().
+ */
+ return (sendto(s, msg, len, flags, NULL, 0));
}
Modified: trunk/lib/libc/net/sockatmark.3
===================================================================
--- trunk/lib/libc/net/sockatmark.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/sockatmark.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2002 William C. Fenner. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -21,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/sockatmark.3 108087 2002-12-19 09:40:28Z ru $
.\"
.Dd October 13, 2002
.Dt SOCKATMARK 3
Modified: trunk/lib/libc/net/sockatmark.c
===================================================================
--- trunk/lib/libc/net/sockatmark.c 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/sockatmark.c 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 2002 William C. Fenner. All rights reserved.
*
@@ -22,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/net/sockatmark.c 107836 2002-12-13 22:22:55Z fenner $
*/
#include <sys/ioctl.h>
Modified: trunk/lib/libc/net/sourcefilter.3
===================================================================
--- trunk/lib/libc/net/sourcefilter.3 2018-06-08 01:45:32 UTC (rev 10573)
+++ trunk/lib/libc/net/sourcefilter.3 2018-06-08 01:46:18 UTC (rev 10574)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2007-2009 Bruce Simpson.
.\" All rights reserved.
.\"
@@ -22,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/lib/libc/net/sourcefilter.3 235286 2012-05-11 20:06:46Z gjb $
.\"
.Dd February 13, 2009
.Dt SOURCEFILTER 3
@@ -158,7 +159,7 @@
.Fn getsourcefilter
and
.Fn setsourcefilter ,
-the argument
+the
.Fa grouplen
argument specifies the size of the structure pointed to by
.Fa group .
@@ -220,7 +221,7 @@
.Sh SEE ALSO
.Xr ip 4 ,
.Xr ip6 4 ,
-.Xr multicast 4,
+.Xr multicast 4 ,
.Xr ifmcstat 8
.Rs
.%A D. Thaler
More information about the Midnightbsd-cvs
mailing list