]> sourceware.org Git - newlib-cygwin.git/commitdiff
Add some POSIX header files for RTEMS
authorSebastian Huber <sebastian.huber@embedded-brains.de>
Mon, 22 May 2017 08:42:39 +0000 (10:42 +0200)
committerJeff Johnston <jjohnstn@redhat.com>
Thu, 25 May 2017 16:41:33 +0000 (12:41 -0400)
Add the POSIX header files

  * arpa/inet.h
  * net/if.h
  * netdb.h
  * netinet/in.h
  * netinet/tcp.h
  * sys/socket.h
  * sys/syslog.h
  * sys/uio.h
  * sys/un.h
  * syslog.h
  * termios.h

and their dependencies for RTEMS.  The origin of these files is the
latest FreeBSD.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
20 files changed:
newlib/libc/sys/rtems/Makefile.am
newlib/libc/sys/rtems/Makefile.in
newlib/libc/sys/rtems/include/arpa/inet.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/net/if.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/netdb.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/netinet/in.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/netinet/tcp.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/netinet6/in6.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/sys/_iovec.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/sys/_sockaddr_storage.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/sys/_termios.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/sys/ioccom.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/sys/socket.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/sys/syslog.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/sys/ttycom.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/sys/ttydefaults.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/sys/uio.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/sys/un.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/syslog.h [new file with mode: 0644]
newlib/libc/sys/rtems/include/termios.h [new file with mode: 0644]

index e6febfee4d2f498bf565370e9692177abf455952..f166564cef65596e22dbc630055ad4571d684f21 100644 (file)
@@ -16,3 +16,21 @@ all-local: crt0.o
 
 ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
+
+install-data-local:
+       $(mkinstalldirs) $(DESTDIR)$(tooldir)/include/arpa; \
+       for i in $(srcdir)/include/arpa/*.h; do \
+         $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/arpa/`basename $$i`; \
+       done; \
+       $(mkinstalldirs) $(DESTDIR)$(tooldir)/include/net; \
+       for i in $(srcdir)/include/net/*.h; do \
+         $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/net/`basename $$i`; \
+       done; \
+       $(mkinstalldirs) $(DESTDIR)$(tooldir)/include/netinet; \
+       for i in $(srcdir)/include/netinet/*.h; do \
+         $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/netinet/`basename $$i`; \
+       done; \
+       $(mkinstalldirs) $(DESTDIR)$(tooldir)/include/netinet6; \
+       for i in $(srcdir)/include/netinet6/*.h; do \
+         $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/netinet6/`basename $$i`; \
+       done
index 13dffd476abdf739856d1b165d8fe2e163b39cd2..a24d53bb267c8aa983bf27ee7c60764b3b18c359 100644 (file)
@@ -382,7 +382,7 @@ info: info-am
 
 info-am:
 
-install-data-am:
+install-data-am: install-data-local
 
 install-dvi: install-dvi-am
 
@@ -436,11 +436,11 @@ uninstall-am:
        clean clean-generic clean-noinstLIBRARIES ctags distclean \
        distclean-compile distclean-generic distclean-tags dvi dvi-am \
        html html-am info info-am install install-am install-data \
-       install-data-am install-dvi install-dvi-am install-exec \
-       install-exec-am install-html install-html-am install-info \
-       install-info-am install-man install-pdf install-pdf-am \
-       install-ps install-ps-am install-strip installcheck \
-       installcheck-am installdirs maintainer-clean \
+       install-data-am install-data-local install-dvi install-dvi-am \
+       install-exec install-exec-am install-html install-html-am \
+       install-info install-info-am install-man install-pdf \
+       install-pdf-am install-ps install-ps-am install-strip \
+       installcheck installcheck-am installdirs maintainer-clean \
        maintainer-clean-generic mostlyclean mostlyclean-compile \
        mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
        uninstall-am
@@ -448,6 +448,24 @@ uninstall-am:
 
 all-local: crt0.o
 
+install-data-local:
+       $(mkinstalldirs) $(DESTDIR)$(tooldir)/include/arpa; \
+       for i in $(srcdir)/include/arpa/*.h; do \
+         $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/arpa/`basename $$i`; \
+       done; \
+       $(mkinstalldirs) $(DESTDIR)$(tooldir)/include/net; \
+       for i in $(srcdir)/include/net/*.h; do \
+         $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/net/`basename $$i`; \
+       done; \
+       $(mkinstalldirs) $(DESTDIR)$(tooldir)/include/netinet; \
+       for i in $(srcdir)/include/netinet/*.h; do \
+         $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/netinet/`basename $$i`; \
+       done; \
+       $(mkinstalldirs) $(DESTDIR)$(tooldir)/include/netinet6; \
+       for i in $(srcdir)/include/netinet6/*.h; do \
+         $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/netinet6/`basename $$i`; \
+       done
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/newlib/libc/sys/rtems/include/arpa/inet.h b/newlib/libc/sys/rtems/include/arpa/inet.h
new file mode 100644 (file)
index 0000000..d71c927
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ * ++Copyright++ 1983, 1993
+ * -
+ * Copyright (c) 1983, 1993
+ *    The Regents of the University of California.  All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * -
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ * 
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * -
+ * --Copyright--
+ */
+
+/*%
+ *     @(#)inet.h      8.1 (Berkeley) 6/2/93
+ *     $Id: inet.h,v 1.3 2005/04/27 04:56:16 sra Exp $
+ * $FreeBSD: head/include/arpa/inet.h 269867 2014-08-12 12:36:06Z ume $
+ */
+
+#ifndef _ARPA_INET_H_
+#define        _ARPA_INET_H_
+
+/* External definitions for functions in inet(3). */
+
+#include <sys/cdefs.h>
+#include <sys/_types.h>
+
+/* Required for byteorder(3) functions. */
+#include <machine/endian.h>
+
+#define        INET_ADDRSTRLEN         16
+#define        INET6_ADDRSTRLEN        46
+
+#ifndef _UINT16_T_DECLARED
+typedef        __uint16_t      uint16_t;
+#define        _UINT16_T_DECLARED
+#endif
+
+#ifndef _UINT32_T_DECLARED
+typedef        __uint32_t      uint32_t;
+#define        _UINT32_T_DECLARED
+#endif
+
+#ifndef _IN_ADDR_T_DECLARED
+typedef        uint32_t        in_addr_t;
+#define        _IN_ADDR_T_DECLARED
+#endif
+
+#ifndef _IN_PORT_T_DECLARED
+typedef        uint16_t        in_port_t;
+#define        _IN_PORT_T_DECLARED
+#endif
+
+#if __BSD_VISIBLE
+#ifndef _SIZE_T_DECLARED
+typedef        __size_t        size_t;
+#define        _SIZE_T_DECLARED
+#endif
+#endif
+
+/*
+ * XXX socklen_t is used by a POSIX.1-2001 interface, but not required by
+ * POSIX.1-2001.
+ */
+#ifndef _SOCKLEN_T_DECLARED
+typedef        __socklen_t     socklen_t;
+#define        _SOCKLEN_T_DECLARED
+#endif
+
+#ifndef _STRUCT_IN_ADDR_DECLARED
+struct in_addr {
+       in_addr_t s_addr;
+};
+#define        _STRUCT_IN_ADDR_DECLARED
+#endif
+
+/* XXX all new diversions!! argh!! */
+#if __BSD_VISIBLE
+#define        inet_addr               __inet_addr
+#define        inet_aton               __inet_aton
+#define        inet_lnaof              __inet_lnaof
+#define        inet_makeaddr           __inet_makeaddr
+#define        inet_neta               __inet_neta
+#define        inet_netof              __inet_netof
+#define        inet_network            __inet_network
+#define        inet_net_ntop           __inet_net_ntop
+#define        inet_net_pton           __inet_net_pton
+#define        inet_cidr_ntop          __inet_cidr_ntop
+#define        inet_cidr_pton          __inet_cidr_pton
+#define        inet_ntoa               __inet_ntoa
+#define        inet_ntoa_r             __inet_ntoa_r
+#define        inet_pton               __inet_pton
+#define        inet_ntop               __inet_ntop
+#define        inet_nsap_addr          __inet_nsap_addr
+#define        inet_nsap_ntoa          __inet_nsap_ntoa
+#endif /* __BSD_VISIBLE */
+
+__BEGIN_DECLS
+#ifndef _BYTEORDER_PROTOTYPED
+#define        _BYTEORDER_PROTOTYPED
+uint32_t        htonl(uint32_t);
+uint16_t        htons(uint16_t);
+uint32_t        ntohl(uint32_t);
+uint16_t        ntohs(uint16_t);
+#endif
+
+in_addr_t       inet_addr(const char *);
+/*const*/ char *inet_ntoa(struct in_addr);
+const char     *inet_ntop(int, const void * __restrict, char * __restrict,
+                   socklen_t);
+int             inet_pton(int, const char * __restrict, void * __restrict);
+
+#if __BSD_VISIBLE
+int             inet_aton(const char *, struct in_addr *);
+in_addr_t       inet_lnaof(struct in_addr);
+struct in_addr  inet_makeaddr(in_addr_t, in_addr_t);
+char *          inet_neta(in_addr_t, char *, size_t);
+in_addr_t       inet_netof(struct in_addr);
+in_addr_t       inet_network(const char *);
+char           *inet_net_ntop(int, const void *, int, char *, size_t);
+int             inet_net_pton(int, const char *, void *, size_t);
+char           *inet_ntoa_r(struct in_addr, char *buf, socklen_t size);
+char           *inet_cidr_ntop(int, const void *, int, char *, size_t);
+int             inet_cidr_pton(int, const char *, void *, int *);
+unsigned        inet_nsap_addr(const char *, unsigned char *, int);
+char           *inet_nsap_ntoa(int, const unsigned char *, char *);
+#endif /* __BSD_VISIBLE */
+__END_DECLS
+
+#ifndef _BYTEORDER_FUNC_DEFINED
+#define        _BYTEORDER_FUNC_DEFINED
+#define        htonl(x)        __htonl(x)
+#define        htons(x)        __htons(x)
+#define        ntohl(x)        __ntohl(x)
+#define        ntohs(x)        __ntohs(x)
+#endif
+
+#endif /* !_ARPA_INET_H_ */
+
+/*! \file */
diff --git a/newlib/libc/sys/rtems/include/net/if.h b/newlib/libc/sys/rtems/include/net/if.h
new file mode 100644 (file)
index 0000000..a059e3f
--- /dev/null
@@ -0,0 +1,551 @@
+/*-
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)if.h        8.1 (Berkeley) 6/10/93
+ * $FreeBSD: head/sys/net/if.h 314436 2017-02-28 23:42:47Z imp $
+ */
+
+#ifndef _NET_IF_H_
+#define        _NET_IF_H_
+
+#include <sys/cdefs.h>
+
+#if __BSD_VISIBLE
+/*
+ * <net/if.h> does not depend on <sys/time.h> on most other systems.  This
+ * helps userland compatibility.  (struct timeval ifi_lastchange)
+ * The same holds for <sys/socket.h>.  (struct sockaddr ifru_addr)
+ */
+#ifndef _KERNEL
+#include <sys/time.h>
+#include <sys/socket.h>
+#endif
+#endif
+
+/*
+ * Length of interface external name, including terminating '\0'.
+ * Note: this is the same size as a generic device's external name.
+ */
+#define                IF_NAMESIZE     16
+#if __BSD_VISIBLE
+#define                IFNAMSIZ        IF_NAMESIZE
+#define                IF_MAXUNIT      0x7fff  /* historical value */
+#endif
+#if __BSD_VISIBLE
+
+/*
+ * Structure used to query names of interface cloners.
+ */
+
+struct if_clonereq {
+       int     ifcr_total;             /* total cloners (out) */
+       int     ifcr_count;             /* room for this many in user buffer */
+       char    *ifcr_buffer;           /* buffer for cloner names */
+};
+
+/*
+ * Structure describing information about an interface
+ * which may be of interest to management entities.
+ */
+struct if_data {
+       /* generic interface information */
+       uint8_t ifi_type;               /* ethernet, tokenring, etc */
+       uint8_t ifi_physical;           /* e.g., AUI, Thinnet, 10base-T, etc */
+       uint8_t ifi_addrlen;            /* media address length */
+       uint8_t ifi_hdrlen;             /* media header length */
+       uint8_t ifi_link_state;         /* current link state */
+       uint8_t ifi_vhid;               /* carp vhid */
+       uint16_t        ifi_datalen;    /* length of this data struct */
+       uint32_t        ifi_mtu;        /* maximum transmission unit */
+       uint32_t        ifi_metric;     /* routing metric (external only) */
+       uint64_t        ifi_baudrate;   /* linespeed */
+       /* volatile statistics */
+       uint64_t        ifi_ipackets;   /* packets received on interface */
+       uint64_t        ifi_ierrors;    /* input errors on interface */
+       uint64_t        ifi_opackets;   /* packets sent on interface */
+       uint64_t        ifi_oerrors;    /* output errors on interface */
+       uint64_t        ifi_collisions; /* collisions on csma interfaces */
+       uint64_t        ifi_ibytes;     /* total number of octets received */
+       uint64_t        ifi_obytes;     /* total number of octets sent */
+       uint64_t        ifi_imcasts;    /* packets received via multicast */
+       uint64_t        ifi_omcasts;    /* packets sent via multicast */
+       uint64_t        ifi_iqdrops;    /* dropped on input */
+       uint64_t        ifi_oqdrops;    /* dropped on output */
+       uint64_t        ifi_noproto;    /* destined for unsupported protocol */
+       uint64_t        ifi_hwassist;   /* HW offload capabilities, see IFCAP */
+
+       /* Unions are here to make sizes MI. */
+       union {                         /* uptime at attach or stat reset */
+               time_t          tt;
+               uint64_t        ph;
+       } __ifi_epoch;
+#define        ifi_epoch       __ifi_epoch.tt
+       union {                         /* time of last administrative change */
+               struct timeval  tv;
+               struct {
+                       uint64_t ph1;
+                       uint64_t ph2;
+               } ph;
+       } __ifi_lastchange;
+#define        ifi_lastchange  __ifi_lastchange.tv
+};
+
+/*-
+ * Interface flags are of two types: network stack owned flags, and driver
+ * owned flags.  Historically, these values were stored in the same ifnet
+ * flags field, but with the advent of fine-grained locking, they have been
+ * broken out such that the network stack is responsible for synchronizing
+ * the stack-owned fields, and the device driver the device-owned fields.
+ * Both halves can perform lockless reads of the other half's field, subject
+ * to accepting the involved races.
+ *
+ * Both sets of flags come from the same number space, and should not be
+ * permitted to conflict, as they are exposed to user space via a single
+ * field.
+ *
+ * The following symbols identify read and write requirements for fields:
+ *
+ * (i) if_flags field set by device driver before attach, read-only there
+ *     after.
+ * (n) if_flags field written only by the network stack, read by either the
+ *     stack or driver.
+ * (d) if_drv_flags field written only by the device driver, read by either
+ *     the stack or driver.
+ */
+#define        IFF_UP          0x1             /* (n) interface is up */
+#define        IFF_BROADCAST   0x2             /* (i) broadcast address valid */
+#define        IFF_DEBUG       0x4             /* (n) turn on debugging */
+#define        IFF_LOOPBACK    0x8             /* (i) is a loopback net */
+#define        IFF_POINTOPOINT 0x10            /* (i) is a point-to-point link */
+/*                     0x20               was IFF_SMART */
+#define        IFF_DRV_RUNNING 0x40            /* (d) resources allocated */
+#define        IFF_NOARP       0x80            /* (n) no address resolution protocol */
+#define        IFF_PROMISC     0x100           /* (n) receive all packets */
+#define        IFF_ALLMULTI    0x200           /* (n) receive all multicast packets */
+#define        IFF_DRV_OACTIVE 0x400           /* (d) tx hardware queue is full */
+#define        IFF_SIMPLEX     0x800           /* (i) can't hear own transmissions */
+#define        IFF_LINK0       0x1000          /* per link layer defined bit */
+#define        IFF_LINK1       0x2000          /* per link layer defined bit */
+#define        IFF_LINK2       0x4000          /* per link layer defined bit */
+#define        IFF_ALTPHYS     IFF_LINK2       /* use alternate physical connection */
+#define        IFF_MULTICAST   0x8000          /* (i) supports multicast */
+#define        IFF_CANTCONFIG  0x10000         /* (i) unconfigurable using ioctl(2) */
+#define        IFF_PPROMISC    0x20000         /* (n) user-requested promisc mode */
+#define        IFF_MONITOR     0x40000         /* (n) user-requested monitor mode */
+#define        IFF_STATICARP   0x80000         /* (n) static ARP */
+#define        IFF_DYING       0x200000        /* (n) interface is winding down */
+#define        IFF_RENAMING    0x400000        /* (n) interface is being renamed */
+/*
+ * Old names for driver flags so that user space tools can continue to use
+ * the old (portable) names.
+ */
+#ifndef _KERNEL
+#define        IFF_RUNNING     IFF_DRV_RUNNING
+#define        IFF_OACTIVE     IFF_DRV_OACTIVE
+#endif
+
+/* flags set internally only: */
+#define        IFF_CANTCHANGE \
+       (IFF_BROADCAST|IFF_POINTOPOINT|IFF_DRV_RUNNING|IFF_DRV_OACTIVE|\
+           IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_PROMISC|\
+           IFF_DYING|IFF_CANTCONFIG)
+
+/*
+ * Values for if_link_state.
+ */
+#define        LINK_STATE_UNKNOWN      0       /* link invalid/unknown */
+#define        LINK_STATE_DOWN         1       /* link is down */
+#define        LINK_STATE_UP           2       /* link is up */
+
+/*
+ * Some convenience macros used for setting ifi_baudrate.
+ * XXX 1000 vs. 1024? --thorpej@netbsd.org
+ */
+#define        IF_Kbps(x)      ((uintmax_t)(x) * 1000) /* kilobits/sec. */
+#define        IF_Mbps(x)      (IF_Kbps((x) * 1000))   /* megabits/sec. */
+#define        IF_Gbps(x)      (IF_Mbps((x) * 1000))   /* gigabits/sec. */
+
+/*
+ * Capabilities that interfaces can advertise.
+ *
+ * struct ifnet.if_capabilities
+ *   contains the optional features & capabilities a particular interface
+ *   supports (not only the driver but also the detected hw revision).
+ *   Capabilities are defined by IFCAP_* below.
+ * struct ifnet.if_capenable
+ *   contains the enabled (either by default or through ifconfig) optional
+ *   features & capabilities on this interface.
+ *   Capabilities are defined by IFCAP_* below.
+ * struct if_data.ifi_hwassist in mbuf CSUM_ flag form, controlled by above
+ *   contains the enabled optional feature & capabilites that can be used
+ *   individually per packet and are specified in the mbuf pkthdr.csum_flags
+ *   field.  IFCAP_* and CSUM_* do not match one to one and CSUM_* may be
+ *   more detailed or differenciated than IFCAP_*.
+ *   Hwassist features are defined CSUM_* in sys/mbuf.h
+ *
+ * Capabilities that cannot be arbitrarily changed with ifconfig/ioctl
+ * are listed in IFCAP_CANTCHANGE, similar to IFF_CANTCHANGE.
+ * This is not strictly necessary because the common code never
+ * changes capabilities, and it is left to the individual driver
+ * to do the right thing. However, having the filter here
+ * avoids replication of the same code in all individual drivers.
+ */
+#define        IFCAP_RXCSUM            0x00001  /* can offload checksum on RX */
+#define        IFCAP_TXCSUM            0x00002  /* can offload checksum on TX */
+#define        IFCAP_NETCONS           0x00004  /* can be a network console */
+#define        IFCAP_VLAN_MTU          0x00008 /* VLAN-compatible MTU */
+#define        IFCAP_VLAN_HWTAGGING    0x00010 /* hardware VLAN tag support */
+#define        IFCAP_JUMBO_MTU         0x00020 /* 9000 byte MTU supported */
+#define        IFCAP_POLLING           0x00040 /* driver supports polling */
+#define        IFCAP_VLAN_HWCSUM       0x00080 /* can do IFCAP_HWCSUM on VLANs */
+#define        IFCAP_TSO4              0x00100 /* can do TCP Segmentation Offload */
+#define        IFCAP_TSO6              0x00200 /* can do TCP6 Segmentation Offload */
+#define        IFCAP_LRO               0x00400 /* can do Large Receive Offload */
+#define        IFCAP_WOL_UCAST         0x00800 /* wake on any unicast frame */
+#define        IFCAP_WOL_MCAST         0x01000 /* wake on any multicast frame */
+#define        IFCAP_WOL_MAGIC         0x02000 /* wake on any Magic Packet */
+#define        IFCAP_TOE4              0x04000 /* interface can offload TCP */
+#define        IFCAP_TOE6              0x08000 /* interface can offload TCP6 */
+#define        IFCAP_VLAN_HWFILTER     0x10000 /* interface hw can filter vlan tag */
+#define        IFCAP_POLLING_NOCOUNT   0x20000 /* polling ticks cannot be fragmented */
+#define        IFCAP_VLAN_HWTSO        0x40000 /* can do IFCAP_TSO on VLANs */
+#define        IFCAP_LINKSTATE         0x80000 /* the runtime link state is dynamic */
+#define        IFCAP_NETMAP            0x100000 /* netmap mode supported/enabled */
+#define        IFCAP_RXCSUM_IPV6       0x200000  /* can offload checksum on IPv6 RX */
+#define        IFCAP_TXCSUM_IPV6       0x400000  /* can offload checksum on IPv6 TX */
+#define        IFCAP_HWSTATS           0x800000 /* manages counters internally */
+#define        IFCAP_TXRTLMT           0x1000000 /* hardware supports TX rate limiting */
+
+#define IFCAP_HWCSUM_IPV6      (IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6)
+
+#define IFCAP_HWCSUM   (IFCAP_RXCSUM | IFCAP_TXCSUM)
+#define        IFCAP_TSO       (IFCAP_TSO4 | IFCAP_TSO6)
+#define        IFCAP_WOL       (IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC)
+#define        IFCAP_TOE       (IFCAP_TOE4 | IFCAP_TOE6)
+
+#define        IFCAP_CANTCHANGE        (IFCAP_NETMAP)
+
+#define        IFQ_MAXLEN      50
+#define        IFNET_SLOWHZ    1               /* granularity is 1 second */
+
+/*
+ * Message format for use in obtaining information about interfaces
+ * from getkerninfo and the routing socket
+ * For the new, extensible interface see struct if_msghdrl below.
+ */
+struct if_msghdr {
+       u_short ifm_msglen;     /* to skip over non-understood messages */
+       u_char  ifm_version;    /* future binary compatibility */
+       u_char  ifm_type;       /* message type */
+       int     ifm_addrs;      /* like rtm_addrs */
+       int     ifm_flags;      /* value of if_flags */
+       u_short ifm_index;      /* index for associated ifp */
+       struct  if_data ifm_data;/* statistics and other data about if */
+};
+
+/*
+ * The 'l' version shall be used by new interfaces, like NET_RT_IFLISTL.  It is
+ * extensible after ifm_data_off or within ifm_data.  Both the if_msghdr and
+ * if_data now have a member field detailing the struct length in addition to
+ * the routing message length.  Macros are provided to find the start of
+ * ifm_data and the start of the socket address strucutres immediately following
+ * struct if_msghdrl given a pointer to struct if_msghdrl.
+ */
+#define        IF_MSGHDRL_IFM_DATA(_l) \
+    (struct if_data *)((char *)(_l) + (_l)->ifm_data_off)
+#define        IF_MSGHDRL_RTA(_l) \
+    (void *)((uintptr_t)(_l) + (_l)->ifm_len)
+struct if_msghdrl {
+       u_short ifm_msglen;     /* to skip over non-understood messages */
+       u_char  ifm_version;    /* future binary compatibility */
+       u_char  ifm_type;       /* message type */
+       int     ifm_addrs;      /* like rtm_addrs */
+       int     ifm_flags;      /* value of if_flags */
+       u_short ifm_index;      /* index for associated ifp */
+       u_short _ifm_spare1;    /* spare space to grow if_index, see if_var.h */
+       u_short ifm_len;        /* length of if_msghdrl incl. if_data */
+       u_short ifm_data_off;   /* offset of if_data from beginning */
+       struct  if_data ifm_data;/* statistics and other data about if */
+};
+
+/*
+ * Message format for use in obtaining information about interface addresses
+ * from getkerninfo and the routing socket
+ * For the new, extensible interface see struct ifa_msghdrl below.
+ */
+struct ifa_msghdr {
+       u_short ifam_msglen;    /* to skip over non-understood messages */
+       u_char  ifam_version;   /* future binary compatibility */
+       u_char  ifam_type;      /* message type */
+       int     ifam_addrs;     /* like rtm_addrs */
+       int     ifam_flags;     /* value of ifa_flags */
+       u_short ifam_index;     /* index for associated ifp */
+       int     ifam_metric;    /* value of ifa_ifp->if_metric */
+};
+
+/*
+ * The 'l' version shall be used by new interfaces, like NET_RT_IFLISTL.  It is
+ * extensible after ifam_metric or within ifam_data.  Both the ifa_msghdrl and
+ * if_data now have a member field detailing the struct length in addition to
+ * the routing message length.  Macros are provided to find the start of
+ * ifm_data and the start of the socket address strucutres immediately following
+ * struct ifa_msghdrl given a pointer to struct ifa_msghdrl.
+ */
+#define        IFA_MSGHDRL_IFAM_DATA(_l) \
+    (struct if_data *)((char *)(_l) + (_l)->ifam_data_off)
+#define        IFA_MSGHDRL_RTA(_l) \
+    (void *)((uintptr_t)(_l) + (_l)->ifam_len)
+struct ifa_msghdrl {
+       u_short ifam_msglen;    /* to skip over non-understood messages */
+       u_char  ifam_version;   /* future binary compatibility */
+       u_char  ifam_type;      /* message type */
+       int     ifam_addrs;     /* like rtm_addrs */
+       int     ifam_flags;     /* value of ifa_flags */
+       u_short ifam_index;     /* index for associated ifp */
+       u_short _ifam_spare1;   /* spare space to grow if_index, see if_var.h */
+       u_short ifam_len;       /* length of ifa_msghdrl incl. if_data */
+       u_short ifam_data_off;  /* offset of if_data from beginning */
+       int     ifam_metric;    /* value of ifa_ifp->if_metric */
+       struct  if_data ifam_data;/* statistics and other data about if or
+                                * address */
+};
+
+/*
+ * Message format for use in obtaining information about multicast addresses
+ * from the routing socket
+ */
+struct ifma_msghdr {
+       u_short ifmam_msglen;   /* to skip over non-understood messages */
+       u_char  ifmam_version;  /* future binary compatibility */
+       u_char  ifmam_type;     /* message type */
+       int     ifmam_addrs;    /* like rtm_addrs */
+       int     ifmam_flags;    /* value of ifa_flags */
+       u_short ifmam_index;    /* index for associated ifp */
+};
+
+/*
+ * Message format announcing the arrival or departure of a network interface.
+ */
+struct if_announcemsghdr {
+       u_short ifan_msglen;    /* to skip over non-understood messages */
+       u_char  ifan_version;   /* future binary compatibility */
+       u_char  ifan_type;      /* message type */
+       u_short ifan_index;     /* index for associated ifp */
+       char    ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */
+       u_short ifan_what;      /* what type of announcement */
+};
+
+#define        IFAN_ARRIVAL    0       /* interface arrival */
+#define        IFAN_DEPARTURE  1       /* interface departure */
+
+/*
+ * Buffer with length to be used in SIOCGIFDESCR/SIOCSIFDESCR requests
+ */
+struct ifreq_buffer {
+       size_t  length;
+       void    *buffer;
+};
+
+/*
+ * Interface request structure used for socket
+ * ioctl's.  All interface ioctl's must have parameter
+ * definitions which begin with ifr_name.  The
+ * remainder may be interface specific.
+ */
+struct ifreq {
+       char    ifr_name[IFNAMSIZ];             /* if name, e.g. "en0" */
+       union {
+               struct  sockaddr ifru_addr;
+               struct  sockaddr ifru_dstaddr;
+               struct  sockaddr ifru_broadaddr;
+               struct  ifreq_buffer ifru_buffer;
+               short   ifru_flags[2];
+               short   ifru_index;
+               int     ifru_jid;
+               int     ifru_metric;
+               int     ifru_mtu;
+               int     ifru_phys;
+               int     ifru_media;
+               caddr_t ifru_data;
+               int     ifru_cap[2];
+               u_int   ifru_fib;
+               u_char  ifru_vlan_pcp;
+       } ifr_ifru;
+#define        ifr_addr        ifr_ifru.ifru_addr      /* address */
+#define        ifr_dstaddr     ifr_ifru.ifru_dstaddr   /* other end of p-to-p link */
+#define        ifr_broadaddr   ifr_ifru.ifru_broadaddr /* broadcast address */
+#define        ifr_buffer      ifr_ifru.ifru_buffer    /* user supplied buffer with its length */
+#define        ifr_flags       ifr_ifru.ifru_flags[0]  /* flags (low 16 bits) */
+#define        ifr_flagshigh   ifr_ifru.ifru_flags[1]  /* flags (high 16 bits) */
+#define        ifr_jid         ifr_ifru.ifru_jid       /* jail/vnet */
+#define        ifr_metric      ifr_ifru.ifru_metric    /* metric */
+#define        ifr_mtu         ifr_ifru.ifru_mtu       /* mtu */
+#define ifr_phys       ifr_ifru.ifru_phys      /* physical wire */
+#define ifr_media      ifr_ifru.ifru_media     /* physical media */
+#define        ifr_data        ifr_ifru.ifru_data      /* for use by interface */
+#define        ifr_reqcap      ifr_ifru.ifru_cap[0]    /* requested capabilities */
+#define        ifr_curcap      ifr_ifru.ifru_cap[1]    /* current capabilities */
+#define        ifr_index       ifr_ifru.ifru_index     /* interface index */
+#define        ifr_fib         ifr_ifru.ifru_fib       /* interface fib */
+#define        ifr_vlan_pcp    ifr_ifru.ifru_vlan_pcp  /* VLAN priority */
+};
+
+#define        _SIZEOF_ADDR_IFREQ(ifr) \
+       ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \
+        (sizeof(struct ifreq) - sizeof(struct sockaddr) + \
+         (ifr).ifr_addr.sa_len) : sizeof(struct ifreq))
+
+struct ifaliasreq {
+       char    ifra_name[IFNAMSIZ];            /* if name, e.g. "en0" */
+       struct  sockaddr ifra_addr;
+       struct  sockaddr ifra_broadaddr;
+       struct  sockaddr ifra_mask;
+       int     ifra_vhid;
+};
+
+/* 9.x compat */
+struct oifaliasreq {
+       char    ifra_name[IFNAMSIZ];
+       struct  sockaddr ifra_addr;
+       struct  sockaddr ifra_broadaddr;
+       struct  sockaddr ifra_mask;
+};
+
+struct ifmediareq {
+       char    ifm_name[IFNAMSIZ];     /* if name, e.g. "en0" */
+       int     ifm_current;            /* current media options */
+       int     ifm_mask;               /* don't care mask */
+       int     ifm_status;             /* media status */
+       int     ifm_active;             /* active options */
+       int     ifm_count;              /* # entries in ifm_ulist array */
+       int     *ifm_ulist;             /* media words */
+};
+
+struct  ifdrv {
+       char            ifd_name[IFNAMSIZ];     /* if name, e.g. "en0" */
+       unsigned long   ifd_cmd;
+       size_t          ifd_len;
+       void            *ifd_data;
+};
+
+/* 
+ * Structure used to retrieve aux status data from interfaces.
+ * Kernel suppliers to this interface should respect the formatting
+ * needed by ifconfig(8): each line starts with a TAB and ends with
+ * a newline.  The canonical example to copy and paste is in if_tun.c.
+ */
+
+#define        IFSTATMAX       800             /* 10 lines of text */
+struct ifstat {
+       char    ifs_name[IFNAMSIZ];     /* if name, e.g. "en0" */
+       char    ascii[IFSTATMAX + 1];
+};
+
+/*
+ * Structure used in SIOCGIFCONF request.
+ * Used to retrieve interface configuration
+ * for machine (useful for programs which
+ * must know all networks accessible).
+ */
+struct ifconf {
+       int     ifc_len;                /* size of associated buffer */
+       union {
+               caddr_t ifcu_buf;
+               struct  ifreq *ifcu_req;
+       } ifc_ifcu;
+#define        ifc_buf ifc_ifcu.ifcu_buf       /* buffer address */
+#define        ifc_req ifc_ifcu.ifcu_req       /* array of structures returned */
+};
+
+/*
+ * interface groups
+ */
+
+#define        IFG_ALL         "all"           /* group contains all interfaces */
+/* XXX: will we implement this? */
+#define        IFG_EGRESS      "egress"        /* if(s) default route(s) point to */
+
+struct ifg_req {
+       union {
+               char                     ifgrqu_group[IFNAMSIZ];
+               char                     ifgrqu_member[IFNAMSIZ];
+       } ifgrq_ifgrqu;
+#define        ifgrq_group     ifgrq_ifgrqu.ifgrqu_group
+#define        ifgrq_member    ifgrq_ifgrqu.ifgrqu_member
+};
+
+/*
+ * Used to lookup groups for an interface
+ */
+struct ifgroupreq {
+       char    ifgr_name[IFNAMSIZ];
+       u_int   ifgr_len;
+       union {
+               char    ifgru_group[IFNAMSIZ];
+               struct  ifg_req *ifgru_groups;
+       } ifgr_ifgru;
+#define ifgr_group     ifgr_ifgru.ifgru_group
+#define ifgr_groups    ifgr_ifgru.ifgru_groups
+};
+
+/*
+ * Structure used to request i2c data
+ * from interface transceivers.
+ */
+struct ifi2creq {
+       uint8_t dev_addr;       /* i2c address (0xA0, 0xA2) */
+       uint8_t offset;         /* read offset */
+       uint8_t len;            /* read length */
+       uint8_t spare0;
+       uint32_t spare1;
+       uint8_t data[8];        /* read buffer */
+}; 
+
+#endif /* __BSD_VISIBLE */
+
+#ifdef _KERNEL
+#ifdef MALLOC_DECLARE
+MALLOC_DECLARE(M_IFADDR);
+MALLOC_DECLARE(M_IFMADDR);
+#endif
+#endif
+
+#ifndef _KERNEL
+struct if_nameindex {
+       unsigned int    if_index;       /* 1, 2, ... */
+       char            *if_name;       /* null terminated name: "le0", ... */
+};
+
+__BEGIN_DECLS
+void                    if_freenameindex(struct if_nameindex *);
+char                   *if_indextoname(unsigned int, char *);
+struct if_nameindex    *if_nameindex(void);
+unsigned int            if_nametoindex(const char *);
+__END_DECLS
+#endif
+#endif /* !_NET_IF_H_ */
diff --git a/newlib/libc/sys/rtems/include/netdb.h b/newlib/libc/sys/rtems/include/netdb.h
new file mode 100644 (file)
index 0000000..ff7a7ab
--- /dev/null
@@ -0,0 +1,304 @@
+/*-
+ * Copyright (c) 1980, 1983, 1988, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * -
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * -
+ * --Copyright--
+ */
+
+/*
+ *      @(#)netdb.h    8.1 (Berkeley) 6/2/93
+ *      From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $
+ * $FreeBSD: head/include/netdb.h 303428 2016-07-28 10:05:41Z ed $
+ */
+
+#ifndef _NETDB_H_
+#define _NETDB_H_
+
+#include <sys/cdefs.h>
+#include <sys/_types.h>
+
+#ifndef _IN_ADDR_T_DECLARED
+typedef        __uint32_t      in_addr_t;
+#define        _IN_ADDR_T_DECLARED
+#endif
+
+#ifndef _IN_PORT_T_DECLARED
+typedef        __uint16_t      in_port_t;
+#define        _IN_PORT_T_DECLARED
+#endif
+
+#ifndef _SIZE_T_DECLARED
+typedef        __size_t        size_t;
+#define        _SIZE_T_DECLARED
+#endif
+
+#ifndef _SOCKLEN_T_DECLARED
+typedef        __socklen_t     socklen_t;
+#define        _SOCKLEN_T_DECLARED
+#endif
+
+#ifndef _UINT32_T_DECLARED
+typedef        __uint32_t      uint32_t;
+#define        _UINT32_T_DECLARED
+#endif
+
+#ifndef _PATH_HEQUIV
+# define       _PATH_HEQUIV    "/etc/hosts.equiv"
+#endif
+#define        _PATH_HOSTS     "/etc/hosts"
+#define        _PATH_NETWORKS  "/etc/networks"
+#define        _PATH_PROTOCOLS "/etc/protocols"
+#define        _PATH_SERVICES  "/etc/services"
+#define        _PATH_SERVICES_DB "/var/db/services.db"
+
+#define        h_errno (*__h_errno())
+
+/*
+ * Structures returned by network data base library.  All addresses are
+ * supplied in host order, and returned in network order (suitable for
+ * use in system calls).
+ */
+struct hostent {
+       char    *h_name;        /* official name of host */
+       char    **h_aliases;    /* alias list */
+       int     h_addrtype;     /* host address type */
+       int     h_length;       /* length of address */
+       char    **h_addr_list;  /* list of addresses from name server */
+#define        h_addr  h_addr_list[0]  /* address, for backward compatibility */
+};
+
+struct netent {
+       char            *n_name;        /* official name of net */
+       char            **n_aliases;    /* alias list */
+       int             n_addrtype;     /* net address type */
+       uint32_t        n_net;          /* network # */
+};
+
+struct servent {
+       char    *s_name;        /* official service name */
+       char    **s_aliases;    /* alias list */
+       int     s_port;         /* port # */
+       char    *s_proto;       /* protocol to use */
+};
+
+struct protoent {
+       char    *p_name;        /* official protocol name */
+       char    **p_aliases;    /* alias list */
+       int     p_proto;        /* protocol # */
+};
+
+struct addrinfo {
+       int     ai_flags;       /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
+       int     ai_family;      /* AF_xxx */
+       int     ai_socktype;    /* SOCK_xxx */
+       int     ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
+       socklen_t ai_addrlen;   /* length of ai_addr */
+       char    *ai_canonname;  /* canonical name for hostname */
+       struct  sockaddr *ai_addr;      /* binary address */
+       struct  addrinfo *ai_next;      /* next structure in linked list */
+};
+
+#define        IPPORT_RESERVED 1024
+
+/*
+ * Error return codes from gethostbyname() and gethostbyaddr()
+ * (left in h_errno).
+ */
+
+#define        NETDB_INTERNAL  -1      /* see errno */
+#define        NETDB_SUCCESS   0       /* no problem */
+#define        HOST_NOT_FOUND  1 /* Authoritative Answer Host not found */
+#define        TRY_AGAIN       2 /* Non-Authoritative Host not found, or SERVERFAIL */
+#define        NO_RECOVERY     3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
+#define        NO_DATA         4 /* Valid name, no data record of requested type */
+#define        NO_ADDRESS      NO_DATA         /* no address, look for MX record */
+
+/*
+ * Error return codes from getaddrinfo()
+ */
+#if 0
+/* obsoleted */
+#define        EAI_ADDRFAMILY   1      /* address family for hostname not supported */
+#endif
+#define        EAI_AGAIN        2      /* temporary failure in name resolution */
+#define        EAI_BADFLAGS     3      /* invalid value for ai_flags */
+#define        EAI_FAIL         4      /* non-recoverable failure in name resolution */
+#define        EAI_FAMILY       5      /* ai_family not supported */
+#define        EAI_MEMORY       6      /* memory allocation failure */
+#if 0
+/* obsoleted */
+#define        EAI_NODATA       7      /* no address associated with hostname */
+#endif
+#define        EAI_NONAME       8      /* hostname nor servname provided, or not known */
+#define        EAI_SERVICE      9      /* servname not supported for ai_socktype */
+#define        EAI_SOCKTYPE    10      /* ai_socktype not supported */
+#define        EAI_SYSTEM      11      /* system error returned in errno */
+#define        EAI_BADHINTS    12      /* invalid value for hints */
+#define        EAI_PROTOCOL    13      /* resolved protocol is unknown */
+#define        EAI_OVERFLOW    14      /* argument buffer overflow */
+#define        EAI_MAX         15
+
+/*
+ * Flag values for getaddrinfo()
+ */
+#define        AI_PASSIVE      0x00000001 /* get address to use bind() */
+#define        AI_CANONNAME    0x00000002 /* fill ai_canonname */
+#define        AI_NUMERICHOST  0x00000004 /* prevent host name resolution */
+#define        AI_NUMERICSERV  0x00000008 /* prevent service name resolution */
+/* valid flags for addrinfo (not a standard def, apps should not use it) */
+#define AI_MASK \
+    (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | \
+    AI_ADDRCONFIG | AI_ALL | AI_V4MAPPED)
+
+#define        AI_ALL          0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
+#define        AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
+#define        AI_ADDRCONFIG   0x00000400 /* only if any address is assigned */
+#define        AI_V4MAPPED     0x00000800 /* accept IPv4-mapped IPv6 address */
+/* special recommended flags for getipnodebyname */
+#define        AI_DEFAULT      (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
+
+/*
+ * Constants for getnameinfo()
+ */
+#define        NI_MAXHOST      1025
+#define        NI_MAXSERV      32
+
+/*
+ * Flag values for getnameinfo()
+ */
+#define        NI_NOFQDN       0x00000001
+#define        NI_NUMERICHOST  0x00000002
+#define        NI_NAMEREQD     0x00000004
+#define        NI_NUMERICSERV  0x00000008
+#define        NI_DGRAM        0x00000010
+#define        NI_NUMERICSCOPE 0x00000020
+
+/*
+ * Scope delimit character
+ */
+#define        SCOPE_DELIMITER '%'
+
+__BEGIN_DECLS
+void           endhostent(void);
+void           endnetent(void);
+void           endprotoent(void);
+void           endservent(void);
+#if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE <= 200112)
+struct hostent *gethostbyaddr(const void *, socklen_t, int);
+struct hostent *gethostbyname(const char *);
+#endif
+struct hostent *gethostent(void);
+struct netent  *getnetbyaddr(uint32_t, int);
+struct netent  *getnetbyname(const char *);
+struct netent  *getnetent(void);
+struct protoent        *getprotobyname(const char *);
+struct protoent        *getprotobynumber(int);
+struct protoent        *getprotoent(void);
+struct servent *getservbyname(const char *, const char *);
+struct servent *getservbyport(int, const char *);
+struct servent *getservent(void);
+void           sethostent(int);
+/* void                sethostfile(const char *); */
+void           setnetent(int);
+void           setprotoent(int);
+int            getaddrinfo(const char *, const char *,
+                           const struct addrinfo *, struct addrinfo **);
+int            getnameinfo(const struct sockaddr *, socklen_t, char *,
+                           size_t, char *, size_t, int);
+void           freeaddrinfo(struct addrinfo *);
+const char     *gai_strerror(int);
+void           setservent(int);
+
+#if __BSD_VISIBLE
+void           endnetgrent(void);
+void           freehostent(struct hostent *);
+int            gethostbyaddr_r(const void *, socklen_t, int, struct hostent *,
+    char *, size_t, struct hostent **, int *);
+int            gethostbyname_r(const char *, struct hostent *, char *, size_t,
+    struct hostent **, int *);
+struct hostent *gethostbyname2(const char *, int);
+int            gethostbyname2_r(const char *, int, struct hostent *, char *,
+    size_t, struct hostent **, int *);
+int            gethostent_r(struct hostent *, char *, size_t,
+    struct hostent **, int *);
+struct hostent *getipnodebyaddr(const void *, size_t, int, int *);
+struct hostent *getipnodebyname(const char *, int, int, int *);
+int            getnetbyaddr_r(uint32_t, int, struct netent *, char *, size_t,
+    struct netent**, int *);
+int            getnetbyname_r(const char *, struct netent *, char *, size_t,
+    struct netent **, int *);
+int            getnetent_r(struct netent *, char *, size_t, struct netent **,
+    int *);
+int            getnetgrent(char **, char **, char **);
+int            getnetgrent_r(char **, char **, char **, char *, size_t);
+int            getprotobyname_r(const char *, struct protoent *, char *,
+    size_t, struct protoent **);
+int            getprotobynumber_r(int, struct protoent *, char *, size_t,
+    struct protoent **);
+int            getprotoent_r(struct protoent *, char *, size_t,
+    struct protoent **);
+int            getservbyname_r(const char *, const char *, struct servent *,
+    char *, size_t, struct servent **);
+int            getservbyport_r(int, const char *, struct servent *, char *,
+    size_t, struct servent **);
+int            getservent_r(struct servent *, char *, size_t,
+    struct servent **);
+void           herror(const char *);
+const char     *hstrerror(int);
+int            innetgr(const char *, const char *, const char *, const char *);
+void           setnetgrent(const char *);
+#endif
+
+
+/*
+ * PRIVATE functions specific to the FreeBSD implementation
+ */
+
+/* DO NOT USE THESE, THEY ARE SUBJECT TO CHANGE AND ARE NOT PORTABLE!!! */
+int    * __h_errno(void);
+__END_DECLS
+
+#endif /* !_NETDB_H_ */
diff --git a/newlib/libc/sys/rtems/include/netinet/in.h b/newlib/libc/sys/rtems/include/netinet/in.h
new file mode 100644 (file)
index 0000000..1a3e752
--- /dev/null
@@ -0,0 +1,674 @@
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)in.h        8.3 (Berkeley) 1/3/94
+ * $FreeBSD: head/sys/netinet/in.h 316715 2017-04-11 19:20:20Z ae $
+ */
+
+#ifndef _NETINET_IN_H_
+#define        _NETINET_IN_H_
+
+#include <sys/cdefs.h>
+#include <sys/_types.h>
+#include <machine/endian.h>
+
+/* Protocols common to RFC 1700, POSIX, and X/Open. */
+#define        IPPROTO_IP              0               /* dummy for IP */
+#define        IPPROTO_ICMP            1               /* control message protocol */
+#define        IPPROTO_TCP             6               /* tcp */
+#define        IPPROTO_UDP             17              /* user datagram protocol */
+
+#define        INADDR_ANY              ((in_addr_t)0x00000000)
+#define        INADDR_BROADCAST        ((in_addr_t)0xffffffff) /* must be masked */
+
+#ifndef _UINT8_T_DECLARED
+typedef        __uint8_t               uint8_t;
+#define        _UINT8_T_DECLARED
+#endif
+
+#ifndef _UINT16_T_DECLARED
+typedef        __uint16_t              uint16_t;
+#define        _UINT16_T_DECLARED
+#endif
+
+#ifndef _UINT32_T_DECLARED
+typedef        __uint32_t              uint32_t;
+#define        _UINT32_T_DECLARED
+#endif
+
+#ifndef _IN_ADDR_T_DECLARED
+typedef        uint32_t                in_addr_t;
+#define        _IN_ADDR_T_DECLARED
+#endif
+
+#ifndef _IN_PORT_T_DECLARED
+typedef        uint16_t                in_port_t;
+#define        _IN_PORT_T_DECLARED
+#endif
+
+#ifndef _SA_FAMILY_T_DECLARED
+typedef        __sa_family_t           sa_family_t;
+#define        _SA_FAMILY_T_DECLARED
+#endif
+
+/* Internet address (a structure for historical reasons). */
+#ifndef        _STRUCT_IN_ADDR_DECLARED
+struct in_addr {
+       in_addr_t s_addr;
+};
+#define        _STRUCT_IN_ADDR_DECLARED
+#endif
+
+#ifndef        _SOCKLEN_T_DECLARED
+typedef        __socklen_t     socklen_t;
+#define        _SOCKLEN_T_DECLARED
+#endif
+
+#include <sys/_sockaddr_storage.h>
+
+/* Socket address, internet style. */
+struct sockaddr_in {
+       uint8_t sin_len;
+       sa_family_t     sin_family;
+       in_port_t       sin_port;
+       struct  in_addr sin_addr;
+       char    sin_zero[8];
+};
+
+#if !defined(_KERNEL) && __POSIX_VISIBLE >= 200112
+
+#ifndef _BYTEORDER_PROTOTYPED
+#define        _BYTEORDER_PROTOTYPED
+__BEGIN_DECLS
+uint32_t       htonl(uint32_t);
+uint16_t       htons(uint16_t);
+uint32_t       ntohl(uint32_t);
+uint16_t       ntohs(uint16_t);
+__END_DECLS
+#endif
+
+#ifndef _BYTEORDER_FUNC_DEFINED
+#define        _BYTEORDER_FUNC_DEFINED
+#define        htonl(x)        __htonl(x)
+#define        htons(x)        __htons(x)
+#define        ntohl(x)        __ntohl(x)
+#define        ntohs(x)        __ntohs(x)
+#endif
+
+#endif /* !_KERNEL && __POSIX_VISIBLE >= 200112 */
+
+#if __POSIX_VISIBLE >= 200112
+#define        IPPROTO_IPV6            41              /* IP6 header */
+#define        IPPROTO_RAW             255             /* raw IP packet */
+#define        INET_ADDRSTRLEN         16
+#endif
+
+#if __BSD_VISIBLE
+/*
+ * Constants and structures defined by the internet system,
+ * Per RFC 790, September 1981, and numerous additions.
+ */
+
+/*
+ * Protocols (RFC 1700)
+ */
+#define        IPPROTO_HOPOPTS         0               /* IP6 hop-by-hop options */
+#define        IPPROTO_IGMP            2               /* group mgmt protocol */
+#define        IPPROTO_GGP             3               /* gateway^2 (deprecated) */
+#define        IPPROTO_IPV4            4               /* IPv4 encapsulation */
+#define        IPPROTO_IPIP            IPPROTO_IPV4    /* for compatibility */
+#define        IPPROTO_ST              7               /* Stream protocol II */
+#define        IPPROTO_EGP             8               /* exterior gateway protocol */
+#define        IPPROTO_PIGP            9               /* private interior gateway */
+#define        IPPROTO_RCCMON          10              /* BBN RCC Monitoring */
+#define        IPPROTO_NVPII           11              /* network voice protocol*/
+#define        IPPROTO_PUP             12              /* pup */
+#define        IPPROTO_ARGUS           13              /* Argus */
+#define        IPPROTO_EMCON           14              /* EMCON */
+#define        IPPROTO_XNET            15              /* Cross Net Debugger */
+#define        IPPROTO_CHAOS           16              /* Chaos*/
+#define        IPPROTO_MUX             18              /* Multiplexing */
+#define        IPPROTO_MEAS            19              /* DCN Measurement Subsystems */
+#define        IPPROTO_HMP             20              /* Host Monitoring */
+#define        IPPROTO_PRM             21              /* Packet Radio Measurement */
+#define        IPPROTO_IDP             22              /* xns idp */
+#define        IPPROTO_TRUNK1          23              /* Trunk-1 */
+#define        IPPROTO_TRUNK2          24              /* Trunk-2 */
+#define        IPPROTO_LEAF1           25              /* Leaf-1 */
+#define        IPPROTO_LEAF2           26              /* Leaf-2 */
+#define        IPPROTO_RDP             27              /* Reliable Data */
+#define        IPPROTO_IRTP            28              /* Reliable Transaction */
+#define        IPPROTO_TP              29              /* tp-4 w/ class negotiation */
+#define        IPPROTO_BLT             30              /* Bulk Data Transfer */
+#define        IPPROTO_NSP             31              /* Network Services */
+#define        IPPROTO_INP             32              /* Merit Internodal */
+#define        IPPROTO_SEP             33              /* Sequential Exchange */
+#define        IPPROTO_3PC             34              /* Third Party Connect */
+#define        IPPROTO_IDPR            35              /* InterDomain Policy Routing */
+#define        IPPROTO_XTP             36              /* XTP */
+#define        IPPROTO_DDP             37              /* Datagram Delivery */
+#define        IPPROTO_CMTP            38              /* Control Message Transport */
+#define        IPPROTO_TPXX            39              /* TP++ Transport */
+#define        IPPROTO_IL              40              /* IL transport protocol */
+#define        IPPROTO_SDRP            42              /* Source Demand Routing */
+#define        IPPROTO_ROUTING         43              /* IP6 routing header */
+#define        IPPROTO_FRAGMENT        44              /* IP6 fragmentation header */
+#define        IPPROTO_IDRP            45              /* InterDomain Routing*/
+#define        IPPROTO_RSVP            46              /* resource reservation */
+#define        IPPROTO_GRE             47              /* General Routing Encap. */
+#define        IPPROTO_MHRP            48              /* Mobile Host Routing */
+#define        IPPROTO_BHA             49              /* BHA */
+#define        IPPROTO_ESP             50              /* IP6 Encap Sec. Payload */
+#define        IPPROTO_AH              51              /* IP6 Auth Header */
+#define        IPPROTO_INLSP           52              /* Integ. Net Layer Security */
+#define        IPPROTO_SWIPE           53              /* IP with encryption */
+#define        IPPROTO_NHRP            54              /* Next Hop Resolution */
+#define        IPPROTO_MOBILE          55              /* IP Mobility */
+#define        IPPROTO_TLSP            56              /* Transport Layer Security */
+#define        IPPROTO_SKIP            57              /* SKIP */
+#define        IPPROTO_ICMPV6          58              /* ICMP6 */
+#define        IPPROTO_NONE            59              /* IP6 no next header */
+#define        IPPROTO_DSTOPTS         60              /* IP6 destination option */
+#define        IPPROTO_AHIP            61              /* any host internal protocol */
+#define        IPPROTO_CFTP            62              /* CFTP */
+#define        IPPROTO_HELLO           63              /* "hello" routing protocol */
+#define        IPPROTO_SATEXPAK        64              /* SATNET/Backroom EXPAK */
+#define        IPPROTO_KRYPTOLAN       65              /* Kryptolan */
+#define        IPPROTO_RVD             66              /* Remote Virtual Disk */
+#define        IPPROTO_IPPC            67              /* Pluribus Packet Core */
+#define        IPPROTO_ADFS            68              /* Any distributed FS */
+#define        IPPROTO_SATMON          69              /* Satnet Monitoring */
+#define        IPPROTO_VISA            70              /* VISA Protocol */
+#define        IPPROTO_IPCV            71              /* Packet Core Utility */
+#define        IPPROTO_CPNX            72              /* Comp. Prot. Net. Executive */
+#define        IPPROTO_CPHB            73              /* Comp. Prot. HeartBeat */
+#define        IPPROTO_WSN             74              /* Wang Span Network */
+#define        IPPROTO_PVP             75              /* Packet Video Protocol */
+#define        IPPROTO_BRSATMON        76              /* BackRoom SATNET Monitoring */
+#define        IPPROTO_ND              77              /* Sun net disk proto (temp.) */
+#define        IPPROTO_WBMON           78              /* WIDEBAND Monitoring */
+#define        IPPROTO_WBEXPAK         79              /* WIDEBAND EXPAK */
+#define        IPPROTO_EON             80              /* ISO cnlp */
+#define        IPPROTO_VMTP            81              /* VMTP */
+#define        IPPROTO_SVMTP           82              /* Secure VMTP */
+#define        IPPROTO_VINES           83              /* Banyon VINES */
+#define        IPPROTO_TTP             84              /* TTP */
+#define        IPPROTO_IGP             85              /* NSFNET-IGP */
+#define        IPPROTO_DGP             86              /* dissimilar gateway prot. */
+#define        IPPROTO_TCF             87              /* TCF */
+#define        IPPROTO_IGRP            88              /* Cisco/GXS IGRP */
+#define        IPPROTO_OSPFIGP         89              /* OSPFIGP */
+#define        IPPROTO_SRPC            90              /* Strite RPC protocol */
+#define        IPPROTO_LARP            91              /* Locus Address Resoloution */
+#define        IPPROTO_MTP             92              /* Multicast Transport */
+#define        IPPROTO_AX25            93              /* AX.25 Frames */
+#define        IPPROTO_IPEIP           94              /* IP encapsulated in IP */
+#define        IPPROTO_MICP            95              /* Mobile Int.ing control */
+#define        IPPROTO_SCCSP           96              /* Semaphore Comm. security */
+#define        IPPROTO_ETHERIP         97              /* Ethernet IP encapsulation */
+#define        IPPROTO_ENCAP           98              /* encapsulation header */
+#define        IPPROTO_APES            99              /* any private encr. scheme */
+#define        IPPROTO_GMTP            100             /* GMTP*/
+#define        IPPROTO_IPCOMP          108             /* payload compression (IPComp) */
+#define        IPPROTO_SCTP            132             /* SCTP */
+#define        IPPROTO_MH              135             /* IPv6 Mobility Header */
+#define        IPPROTO_UDPLITE         136             /* UDP-Lite */
+#define        IPPROTO_HIP             139             /* IP6 Host Identity Protocol */
+#define        IPPROTO_SHIM6           140             /* IP6 Shim6 Protocol */
+/* 101-254: Partly Unassigned */
+#define        IPPROTO_PIM             103             /* Protocol Independent Mcast */
+#define        IPPROTO_CARP            112             /* CARP */
+#define        IPPROTO_PGM             113             /* PGM */
+#define        IPPROTO_MPLS            137             /* MPLS-in-IP */
+#define        IPPROTO_PFSYNC          240             /* PFSYNC */
+#define        IPPROTO_RESERVED_253    253             /* Reserved */
+#define        IPPROTO_RESERVED_254    254             /* Reserved */
+/* 255: Reserved */
+/* BSD Private, local use, namespace incursion, no longer used */
+#define        IPPROTO_OLD_DIVERT      254             /* OLD divert pseudo-proto */
+#define        IPPROTO_MAX             256
+
+/* last return value of *_input(), meaning "all job for this pkt is done".  */
+#define        IPPROTO_DONE            257
+
+/* Only used internally, so can be outside the range of valid IP protocols. */
+#define        IPPROTO_DIVERT          258             /* divert pseudo-protocol */
+#define        IPPROTO_SEND            259             /* SeND pseudo-protocol */
+
+/*
+ * Defined to avoid confusion.  The master value is defined by
+ * PROTO_SPACER in sys/protosw.h.
+ */
+#define        IPPROTO_SPACER          32767           /* spacer for loadable protos */
+
+/*
+ * Local port number conventions:
+ *
+ * When a user does a bind(2) or connect(2) with a port number of zero,
+ * a non-conflicting local port address is chosen.
+ * The default range is IPPORT_HIFIRSTAUTO through
+ * IPPORT_HILASTAUTO, although that is settable by sysctl.
+ *
+ * A user may set the IPPROTO_IP option IP_PORTRANGE to change this
+ * default assignment range.
+ *
+ * The value IP_PORTRANGE_DEFAULT causes the default behavior.
+ *
+ * The value IP_PORTRANGE_HIGH changes the range of candidate port numbers
+ * into the "high" range.  These are reserved for client outbound connections
+ * which do not want to be filtered by any firewalls.
+ *
+ * The value IP_PORTRANGE_LOW changes the range to the "low" are
+ * that is (by convention) restricted to privileged processes.  This
+ * convention is based on "vouchsafe" principles only.  It is only secure
+ * if you trust the remote host to restrict these ports.
+ *
+ * The default range of ports and the high range can be changed by
+ * sysctl(3).  (net.inet.ip.port{hi,low}{first,last}_auto)
+ *
+ * Changing those values has bad security implications if you are
+ * using a stateless firewall that is allowing packets outside of that
+ * range in order to allow transparent outgoing connections.
+ *
+ * Such a firewall configuration will generally depend on the use of these
+ * default values.  If you change them, you may find your Security
+ * Administrator looking for you with a heavy object.
+ *
+ * For a slightly more orthodox text view on this:
+ *
+ *            ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers
+ *
+ *    port numbers are divided into three ranges:
+ *
+ *                0 -  1023 Well Known Ports
+ *             1024 - 49151 Registered Ports
+ *            49152 - 65535 Dynamic and/or Private Ports
+ *
+ */
+
+/*
+ * Ports < IPPORT_RESERVED are reserved for
+ * privileged processes (e.g. root).         (IP_PORTRANGE_LOW)
+ */
+#define        IPPORT_RESERVED         1024
+
+/*
+ * Default local port range, used by IP_PORTRANGE_DEFAULT
+ */
+#define IPPORT_EPHEMERALFIRST  10000
+#define IPPORT_EPHEMERALLAST   65535 
+/*
+ * Dynamic port range, used by IP_PORTRANGE_HIGH.
+ */
+#define        IPPORT_HIFIRSTAUTO      49152
+#define        IPPORT_HILASTAUTO       65535
+
+/*
+ * Scanning for a free reserved port return a value below IPPORT_RESERVED,
+ * but higher than IPPORT_RESERVEDSTART.  Traditionally the start value was
+ * 512, but that conflicts with some well-known-services that firewalls may
+ * have a fit if we use.
+ */
+#define        IPPORT_RESERVEDSTART    600
+
+#define        IPPORT_MAX              65535
+
+/*
+ * Definitions of bits in internet address integers.
+ * On subnets, the decomposition of addresses to host and net parts
+ * is done according to subnet mask, not the masks here.
+ */
+#define        IN_CLASSA(i)            (((in_addr_t)(i) & 0x80000000) == 0)
+#define        IN_CLASSA_NET           0xff000000
+#define        IN_CLASSA_NSHIFT        24
+#define        IN_CLASSA_HOST          0x00ffffff
+#define        IN_CLASSA_MAX           128
+
+#define        IN_CLASSB(i)            (((in_addr_t)(i) & 0xc0000000) == 0x80000000)
+#define        IN_CLASSB_NET           0xffff0000
+#define        IN_CLASSB_NSHIFT        16
+#define        IN_CLASSB_HOST          0x0000ffff
+#define        IN_CLASSB_MAX           65536
+
+#define        IN_CLASSC(i)            (((in_addr_t)(i) & 0xe0000000) == 0xc0000000)
+#define        IN_CLASSC_NET           0xffffff00
+#define        IN_CLASSC_NSHIFT        8
+#define        IN_CLASSC_HOST          0x000000ff
+
+#define        IN_CLASSD(i)            (((in_addr_t)(i) & 0xf0000000) == 0xe0000000)
+#define        IN_CLASSD_NET           0xf0000000      /* These ones aren't really */
+#define        IN_CLASSD_NSHIFT        28              /* net and host fields, but */
+#define        IN_CLASSD_HOST          0x0fffffff      /* routing needn't know.    */
+#define        IN_MULTICAST(i)         IN_CLASSD(i)
+
+#define        IN_EXPERIMENTAL(i)      (((in_addr_t)(i) & 0xf0000000) == 0xf0000000)
+#define        IN_BADCLASS(i)          (((in_addr_t)(i) & 0xf0000000) == 0xf0000000)
+
+#define IN_LINKLOCAL(i)                (((in_addr_t)(i) & 0xffff0000) == 0xa9fe0000)
+#define IN_LOOPBACK(i)         (((in_addr_t)(i) & 0xff000000) == 0x7f000000)
+#define IN_ZERONET(i)          (((in_addr_t)(i) & 0xff000000) == 0)
+
+#define        IN_PRIVATE(i)   ((((in_addr_t)(i) & 0xff000000) == 0x0a000000) || \
+                        (((in_addr_t)(i) & 0xfff00000) == 0xac100000) || \
+                        (((in_addr_t)(i) & 0xffff0000) == 0xc0a80000))
+
+#define        IN_LOCAL_GROUP(i)       (((in_addr_t)(i) & 0xffffff00) == 0xe0000000)
+#define        IN_ANY_LOCAL(i)         (IN_LINKLOCAL(i) || IN_LOCAL_GROUP(i))
+
+#define        INADDR_LOOPBACK         ((in_addr_t)0x7f000001)
+#ifndef _KERNEL
+#define        INADDR_NONE             ((in_addr_t)0xffffffff) /* -1 return */
+#endif
+
+#define        INADDR_UNSPEC_GROUP     ((in_addr_t)0xe0000000) /* 224.0.0.0 */
+#define        INADDR_ALLHOSTS_GROUP   ((in_addr_t)0xe0000001) /* 224.0.0.1 */
+#define        INADDR_ALLRTRS_GROUP    ((in_addr_t)0xe0000002) /* 224.0.0.2 */
+#define        INADDR_ALLRPTS_GROUP    ((in_addr_t)0xe0000016) /* 224.0.0.22, IGMPv3 */
+#define        INADDR_CARP_GROUP       ((in_addr_t)0xe0000012) /* 224.0.0.18 */
+#define        INADDR_PFSYNC_GROUP     ((in_addr_t)0xe00000f0) /* 224.0.0.240 */
+#define        INADDR_ALLMDNS_GROUP    ((in_addr_t)0xe00000fb) /* 224.0.0.251 */
+#define        INADDR_MAX_LOCAL_GROUP  ((in_addr_t)0xe00000ff) /* 224.0.0.255 */
+
+#define        IN_LOOPBACKNET          127                     /* official! */
+
+#define        IN_RFC3021_MASK         ((in_addr_t)0xfffffffe)
+
+/*
+ * Options for use with [gs]etsockopt at the IP level.
+ * First word of comment is data type; bool is stored in int.
+ */
+#define        IP_OPTIONS              1    /* buf/ip_opts; set/get IP options */
+#define        IP_HDRINCL              2    /* int; header is included with data */
+#define        IP_TOS                  3    /* int; IP type of service and preced. */
+#define        IP_TTL                  4    /* int; IP time to live */
+#define        IP_RECVOPTS             5    /* bool; receive all IP opts w/dgram */
+#define        IP_RECVRETOPTS          6    /* bool; receive IP opts for response */
+#define        IP_RECVDSTADDR          7    /* bool; receive IP dst addr w/dgram */
+#define        IP_SENDSRCADDR          IP_RECVDSTADDR /* cmsg_type to set src addr */
+#define        IP_RETOPTS              8    /* ip_opts; set/get IP options */
+#define        IP_MULTICAST_IF         9    /* struct in_addr *or* struct ip_mreqn;
+                                     * set/get IP multicast i/f  */
+#define        IP_MULTICAST_TTL        10   /* u_char; set/get IP multicast ttl */
+#define        IP_MULTICAST_LOOP       11   /* u_char; set/get IP multicast loopback */
+#define        IP_ADD_MEMBERSHIP       12   /* ip_mreq; add an IP group membership */
+#define        IP_DROP_MEMBERSHIP      13   /* ip_mreq; drop an IP group membership */
+#define        IP_MULTICAST_VIF        14   /* set/get IP mcast virt. iface */
+#define        IP_RSVP_ON              15   /* enable RSVP in kernel */
+#define        IP_RSVP_OFF             16   /* disable RSVP in kernel */
+#define        IP_RSVP_VIF_ON          17   /* set RSVP per-vif socket */
+#define        IP_RSVP_VIF_OFF         18   /* unset RSVP per-vif socket */
+#define        IP_PORTRANGE            19   /* int; range to choose for unspec port */
+#define        IP_RECVIF               20   /* bool; receive reception if w/dgram */
+/* for IPSEC */
+#define        IP_IPSEC_POLICY         21   /* int; set/get security policy */
+                                    /* unused; was IP_FAITH */
+#define        IP_ONESBCAST            23   /* bool: send all-ones broadcast */
+#define        IP_BINDANY              24   /* bool: allow bind to any address */
+#define        IP_BINDMULTI            25   /* bool: allow multiple listeners on a tuple */
+#define        IP_RSS_LISTEN_BUCKET    26   /* int; set RSS listen bucket */
+#define        IP_ORIGDSTADDR          27   /* bool: receive IP dst addr/port w/dgram */
+#define        IP_RECVORIGDSTADDR      IP_ORIGDSTADDR
+
+/*
+ * Options for controlling the firewall and dummynet.
+ * Historical options (from 40 to 64) will eventually be
+ * replaced by only two options, IP_FW3 and IP_DUMMYNET3.
+ */
+#define        IP_FW_TABLE_ADD         40   /* add entry */
+#define        IP_FW_TABLE_DEL         41   /* delete entry */
+#define        IP_FW_TABLE_FLUSH       42   /* flush table */
+#define        IP_FW_TABLE_GETSIZE     43   /* get table size */
+#define        IP_FW_TABLE_LIST        44   /* list table contents */
+
+#define        IP_FW3                  48   /* generic ipfw v.3 sockopts */
+#define        IP_DUMMYNET3            49   /* generic dummynet v.3 sockopts */
+
+#define        IP_FW_ADD               50   /* add a firewall rule to chain */
+#define        IP_FW_DEL               51   /* delete a firewall rule from chain */
+#define        IP_FW_FLUSH             52   /* flush firewall rule chain */
+#define        IP_FW_ZERO              53   /* clear single/all firewall counter(s) */
+#define        IP_FW_GET               54   /* get entire firewall rule chain */
+#define        IP_FW_RESETLOG          55   /* reset logging counters */
+
+#define IP_FW_NAT_CFG           56   /* add/config a nat rule */
+#define IP_FW_NAT_DEL           57   /* delete a nat rule */
+#define IP_FW_NAT_GET_CONFIG    58   /* get configuration of a nat rule */
+#define IP_FW_NAT_GET_LOG       59   /* get log of a nat rule */
+
+#define        IP_DUMMYNET_CONFIGURE   60   /* add/configure a dummynet pipe */
+#define        IP_DUMMYNET_DEL         61   /* delete a dummynet pipe from chain */
+#define        IP_DUMMYNET_FLUSH       62   /* flush dummynet */
+#define        IP_DUMMYNET_GET         64   /* get entire dummynet pipes */
+
+#define        IP_RECVTTL              65   /* bool; receive IP TTL w/dgram */
+#define        IP_MINTTL               66   /* minimum TTL for packet or drop */
+#define        IP_DONTFRAG             67   /* don't fragment packet */
+#define        IP_RECVTOS              68   /* bool; receive IP TOS w/dgram */
+
+/* IPv4 Source Filter Multicast API [RFC3678] */
+#define        IP_ADD_SOURCE_MEMBERSHIP        70   /* join a source-specific group */
+#define        IP_DROP_SOURCE_MEMBERSHIP       71   /* drop a single source */
+#define        IP_BLOCK_SOURCE                 72   /* block a source */
+#define        IP_UNBLOCK_SOURCE               73   /* unblock a source */
+
+/* The following option is private; do not use it from user applications. */
+#define        IP_MSFILTER                     74   /* set/get filter list */
+
+/* Protocol Independent Multicast API [RFC3678] */
+#define        MCAST_JOIN_GROUP                80   /* join an any-source group */
+#define        MCAST_LEAVE_GROUP               81   /* leave all sources for group */
+#define        MCAST_JOIN_SOURCE_GROUP         82   /* join a source-specific group */
+#define        MCAST_LEAVE_SOURCE_GROUP        83   /* leave a single source */
+#define        MCAST_BLOCK_SOURCE              84   /* block a source */
+#define        MCAST_UNBLOCK_SOURCE            85   /* unblock a source */
+
+/* Flow and RSS definitions */
+#define        IP_FLOWID               90   /* get flow id for the given socket/inp */
+#define        IP_FLOWTYPE             91   /* get flow type (M_HASHTYPE) */
+#define        IP_RSSBUCKETID          92   /* get RSS flowid -> bucket mapping */
+#define        IP_RECVFLOWID           93   /* bool; receive IP flowid/flowtype w/ datagram */
+#define        IP_RECVRSSBUCKETID      94   /* bool; receive IP RSS bucket id w/ datagram */
+
+/*
+ * Defaults and limits for options
+ */
+#define        IP_DEFAULT_MULTICAST_TTL  1     /* normally limit m'casts to 1 hop  */
+#define        IP_DEFAULT_MULTICAST_LOOP 1     /* normally hear sends if a member  */
+
+/*
+ * The imo_membership vector for each socket is now dynamically allocated at
+ * run-time, bounded by USHRT_MAX, and is reallocated when needed, sized
+ * according to a power-of-two increment.
+ */
+#define        IP_MIN_MEMBERSHIPS      31
+#define        IP_MAX_MEMBERSHIPS      4095
+#define        IP_MAX_SOURCE_FILTER    1024    /* XXX to be unused */
+
+/*
+ * Default resource limits for IPv4 multicast source filtering.
+ * These may be modified by sysctl.
+ */
+#define        IP_MAX_GROUP_SRC_FILTER         512     /* sources per group */
+#define        IP_MAX_SOCK_SRC_FILTER          128     /* sources per socket/group */
+#define        IP_MAX_SOCK_MUTE_FILTER         128     /* XXX no longer used */
+
+/*
+ * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
+ */
+struct ip_mreq {
+       struct  in_addr imr_multiaddr;  /* IP multicast address of group */
+       struct  in_addr imr_interface;  /* local IP address of interface */
+};
+
+/*
+ * Modified argument structure for IP_MULTICAST_IF, obtained from Linux.
+ * This is used to specify an interface index for multicast sends, as
+ * the IPv4 legacy APIs do not support this (unless IP_SENDIF is available).
+ */
+struct ip_mreqn {
+       struct  in_addr imr_multiaddr;  /* IP multicast address of group */
+       struct  in_addr imr_address;    /* local IP address of interface */
+       int             imr_ifindex;    /* Interface index; cast to uint32_t */
+};
+
+/*
+ * Argument structure for IPv4 Multicast Source Filter APIs. [RFC3678]
+ */
+struct ip_mreq_source {
+       struct  in_addr imr_multiaddr;  /* IP multicast address of group */
+       struct  in_addr imr_sourceaddr; /* IP address of source */
+       struct  in_addr imr_interface;  /* local IP address of interface */
+};
+
+/*
+ * Argument structures for Protocol-Independent Multicast Source
+ * Filter APIs. [RFC3678]
+ */
+struct group_req {
+       uint32_t                gr_interface;   /* interface index */
+       struct sockaddr_storage gr_group;       /* group address */
+};
+
+struct group_source_req {
+       uint32_t                gsr_interface;  /* interface index */
+       struct sockaddr_storage gsr_group;      /* group address */
+       struct sockaddr_storage gsr_source;     /* source address */
+};
+
+#ifndef __MSFILTERREQ_DEFINED
+#define __MSFILTERREQ_DEFINED
+/*
+ * The following structure is private; do not use it from user applications.
+ * It is used to communicate IP_MSFILTER/IPV6_MSFILTER information between
+ * the RFC 3678 libc functions and the kernel.
+ */
+struct __msfilterreq {
+       uint32_t                 msfr_ifindex;  /* interface index */
+       uint32_t                 msfr_fmode;    /* filter mode for group */
+       uint32_t                 msfr_nsrcs;    /* # of sources in msfr_srcs */
+       struct sockaddr_storage  msfr_group;    /* group address */
+       struct sockaddr_storage *msfr_srcs;     /* pointer to the first member
+                                                * of a contiguous array of
+                                                * sources to filter in full.
+                                                */
+};
+#endif
+
+struct sockaddr;
+
+/*
+ * Advanced (Full-state) APIs [RFC3678]
+ * The RFC specifies uint_t for the 6th argument to [sg]etsourcefilter().
+ * We use uint32_t here to be consistent.
+ */
+int    setipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t,
+           uint32_t, struct in_addr *);
+int    getipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t *,
+           uint32_t *, struct in_addr *);
+int    setsourcefilter(int, uint32_t, struct sockaddr *, socklen_t,
+           uint32_t, uint32_t, struct sockaddr_storage *);
+int    getsourcefilter(int, uint32_t, struct sockaddr *, socklen_t,
+           uint32_t *, uint32_t *, struct sockaddr_storage *);
+
+/*
+ * Filter modes; also used to represent per-socket filter mode internally.
+ */
+#define        MCAST_UNDEFINED 0       /* fmode: not yet defined */
+#define        MCAST_INCLUDE   1       /* fmode: include these source(s) */
+#define        MCAST_EXCLUDE   2       /* fmode: exclude these source(s) */
+
+/*
+ * Argument for IP_PORTRANGE:
+ * - which range to search when port is unspecified at bind() or connect()
+ */
+#define        IP_PORTRANGE_DEFAULT    0       /* default range */
+#define        IP_PORTRANGE_HIGH       1       /* "high" - request firewall bypass */
+#define        IP_PORTRANGE_LOW        2       /* "low" - vouchsafe security */
+
+/*
+ * Identifiers for IP sysctl nodes
+ */
+#define        IPCTL_FORWARDING        1       /* act as router */
+#define        IPCTL_SENDREDIRECTS     2       /* may send redirects when forwarding */
+#define        IPCTL_DEFTTL            3       /* default TTL */
+#ifdef notyet
+#define        IPCTL_DEFMTU            4       /* default MTU */
+#endif
+/*     IPCTL_RTEXPIRE          5       deprecated */
+/*     IPCTL_RTMINEXPIRE       6       deprecated */
+/*     IPCTL_RTMAXCACHE        7       deprecated */
+#define        IPCTL_SOURCEROUTE       8       /* may perform source routes */
+#define        IPCTL_DIRECTEDBROADCAST 9       /* may re-broadcast received packets */
+#define        IPCTL_INTRQMAXLEN       10      /* max length of netisr queue */
+#define        IPCTL_INTRQDROPS        11      /* number of netisr q drops */
+#define        IPCTL_STATS             12      /* ipstat structure */
+#define        IPCTL_ACCEPTSOURCEROUTE 13      /* may accept source routed packets */
+#define        IPCTL_FASTFORWARDING    14      /* use fast IP forwarding code */
+                                       /* 15, unused, was: IPCTL_KEEPFAITH  */
+#define        IPCTL_GIF_TTL           16      /* default TTL for gif encap packet */
+#define        IPCTL_INTRDQMAXLEN      17      /* max length of direct netisr queue */
+#define        IPCTL_INTRDQDROPS       18      /* number of direct netisr q drops */
+
+#endif /* __BSD_VISIBLE */
+
+#ifdef _KERNEL
+
+struct ifnet; struct mbuf;     /* forward declarations for Standard C */
+struct in_ifaddr;
+
+int     in_broadcast(struct in_addr, struct ifnet *);
+int     in_ifaddr_broadcast(struct in_addr, struct in_ifaddr *);
+int     in_canforward(struct in_addr);
+int     in_localaddr(struct in_addr);
+int     in_localip(struct in_addr);
+int     in_ifhasaddr(struct ifnet *, struct in_addr);
+int     inet_aton(const char *, struct in_addr *); /* in libkern */
+char   *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */
+char   *inet_ntop(int, const void *, char *, socklen_t); /* in libkern */
+int     inet_pton(int af, const char *, void *); /* in libkern */
+void    in_ifdetach(struct ifnet *);
+
+#define        in_hosteq(s, t) ((s).s_addr == (t).s_addr)
+#define        in_nullhost(x)  ((x).s_addr == INADDR_ANY)
+#define        in_allhosts(x)  ((x).s_addr == htonl(INADDR_ALLHOSTS_GROUP))
+
+#define        satosin(sa)     ((struct sockaddr_in *)(sa))
+#define        sintosa(sin)    ((struct sockaddr *)(sin))
+#define        ifatoia(ifa)    ((struct in_ifaddr *)(ifa))
+#endif /* _KERNEL */
+
+/* INET6 stuff */
+#if __POSIX_VISIBLE >= 200112
+#define        __KAME_NETINET_IN_H_INCLUDED_
+#include <netinet6/in6.h>
+#undef __KAME_NETINET_IN_H_INCLUDED_
+#endif
+
+#endif /* !_NETINET_IN_H_*/
diff --git a/newlib/libc/sys/rtems/include/netinet/tcp.h b/newlib/libc/sys/rtems/include/netinet/tcp.h
new file mode 100644 (file)
index 0000000..4fd597f
--- /dev/null
@@ -0,0 +1,261 @@
+/*-
+ * Copyright (c) 1982, 1986, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)tcp.h       8.1 (Berkeley) 6/10/93
+ * $FreeBSD: head/sys/netinet/tcp.h 314436 2017-02-28 23:42:47Z imp $
+ */
+
+#ifndef _NETINET_TCP_H_
+#define _NETINET_TCP_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#if __BSD_VISIBLE
+
+typedef        u_int32_t tcp_seq;
+
+#define tcp6_seq       tcp_seq /* for KAME src sync over BSD*'s */
+#define tcp6hdr                tcphdr  /* for KAME src sync over BSD*'s */
+
+/*
+ * TCP header.
+ * Per RFC 793, September, 1981.
+ */
+struct tcphdr {
+       u_short th_sport;               /* source port */
+       u_short th_dport;               /* destination port */
+       tcp_seq th_seq;                 /* sequence number */
+       tcp_seq th_ack;                 /* acknowledgement number */
+#if BYTE_ORDER == LITTLE_ENDIAN
+       u_char  th_x2:4,                /* (unused) */
+               th_off:4;               /* data offset */
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+       u_char  th_off:4,               /* data offset */
+               th_x2:4;                /* (unused) */
+#endif
+       u_char  th_flags;
+#define        TH_FIN  0x01
+#define        TH_SYN  0x02
+#define        TH_RST  0x04
+#define        TH_PUSH 0x08
+#define        TH_ACK  0x10
+#define        TH_URG  0x20
+#define        TH_ECE  0x40
+#define        TH_CWR  0x80
+#define        TH_FLAGS        (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|TH_ECE|TH_CWR)
+#define        PRINT_TH_FLAGS  "\20\1FIN\2SYN\3RST\4PUSH\5ACK\6URG\7ECE\10CWR"
+
+       u_short th_win;                 /* window */
+       u_short th_sum;                 /* checksum */
+       u_short th_urp;                 /* urgent pointer */
+};
+
+#define        TCPOPT_EOL              0
+#define           TCPOLEN_EOL                  1
+#define        TCPOPT_PAD              0               /* padding after EOL */
+#define           TCPOLEN_PAD                  1
+#define        TCPOPT_NOP              1
+#define           TCPOLEN_NOP                  1
+#define        TCPOPT_MAXSEG           2
+#define    TCPOLEN_MAXSEG              4
+#define TCPOPT_WINDOW          3
+#define    TCPOLEN_WINDOW              3
+#define TCPOPT_SACK_PERMITTED  4
+#define    TCPOLEN_SACK_PERMITTED      2
+#define TCPOPT_SACK            5
+#define           TCPOLEN_SACKHDR              2
+#define    TCPOLEN_SACK                        8       /* 2*sizeof(tcp_seq) */
+#define TCPOPT_TIMESTAMP       8
+#define    TCPOLEN_TIMESTAMP           10
+#define    TCPOLEN_TSTAMP_APPA         (TCPOLEN_TIMESTAMP+2) /* appendix A */
+#define        TCPOPT_SIGNATURE        19              /* Keyed MD5: RFC 2385 */
+#define           TCPOLEN_SIGNATURE            18
+#define        TCPOPT_FAST_OPEN        34
+#define           TCPOLEN_FAST_OPEN_EMPTY      2
+#define           TCPOLEN_FAST_OPEN_MIN        6
+#define           TCPOLEN_FAST_OPEN_MAX        18
+
+/* Miscellaneous constants */
+#define        MAX_SACK_BLKS   6       /* Max # SACK blocks stored at receiver side */
+#define        TCP_MAX_SACK    4       /* MAX # SACKs sent in any segment */
+
+
+/*
+ * The default maximum segment size (MSS) to be used for new TCP connections
+ * when path MTU discovery is not enabled.
+ *
+ * RFC879 derives the default MSS from the largest datagram size hosts are
+ * minimally required to handle directly or through IP reassembly minus the
+ * size of the IP and TCP header.  With IPv6 the minimum MTU is specified
+ * in RFC2460.
+ *
+ * For IPv4 the MSS is 576 - sizeof(struct tcpiphdr)
+ * For IPv6 the MSS is IPV6_MMTU - sizeof(struct ip6_hdr) - sizeof(struct tcphdr)
+ *
+ * We use explicit numerical definition here to avoid header pollution.
+ */
+#define        TCP_MSS         536
+#define        TCP6_MSS        1220
+
+/*
+ * Limit the lowest MSS we accept for path MTU discovery and the TCP SYN MSS
+ * option.  Allowing low values of MSS can consume significant resources and
+ * be used to mount a resource exhaustion attack.
+ * Connections requesting lower MSS values will be rounded up to this value
+ * and the IP_DF flag will be cleared to allow fragmentation along the path.
+ *
+ * See tcp_subr.c tcp_minmss SYSCTL declaration for more comments.  Setting
+ * it to "0" disables the minmss check.
+ *
+ * The default value is fine for TCP across the Internet's smallest official
+ * link MTU (256 bytes for AX.25 packet radio).  However, a connection is very
+ * unlikely to come across such low MTU interfaces these days (anno domini 2003).
+ */
+#define        TCP_MINMSS 216
+
+#define        TCP_MAXWIN      65535   /* largest value for (unscaled) window */
+#define        TTCP_CLIENT_SND_WND     4096    /* dflt send window for T/TCP client */
+
+#define TCP_MAX_WINSHIFT       14      /* maximum window shift */
+
+#define TCP_MAXBURST           4       /* maximum segments in a burst */
+
+#define TCP_MAXHLEN    (0xf<<2)        /* max length of header in bytes */
+#define TCP_MAXOLEN    (TCP_MAXHLEN - sizeof(struct tcphdr))
+                                       /* max space left for options */
+#endif /* __BSD_VISIBLE */
+
+/*
+ * User-settable options (used with setsockopt).  These are discrete
+ * values and are not masked together.  Some values appear to be
+ * bitmasks for historical reasons.
+ */
+#define        TCP_NODELAY     1       /* don't delay send to coalesce packets */
+#if __BSD_VISIBLE
+#define        TCP_MAXSEG      2       /* set maximum segment size */
+#define TCP_NOPUSH     4       /* don't push last block of write */
+#define TCP_NOOPT      8       /* don't use TCP options */
+#define TCP_MD5SIG     16      /* use MD5 digests (RFC2385) */
+#define        TCP_INFO        32      /* retrieve tcp_info structure */
+#define        TCP_CONGESTION  64      /* get/set congestion control algorithm */
+#define        TCP_CCALGOOPT   65      /* get/set cc algorithm specific options */
+#define        TCP_KEEPINIT    128     /* N, time to establish connection */
+#define        TCP_KEEPIDLE    256     /* L,N,X start keeplives after this period */
+#define        TCP_KEEPINTVL   512     /* L,N interval between keepalives */
+#define        TCP_KEEPCNT     1024    /* L,N number of keepalives before close */
+#define        TCP_FASTOPEN    1025    /* enable TFO / was created via TFO */
+#define        TCP_PCAP_OUT    2048    /* number of output packets to keep */
+#define        TCP_PCAP_IN     4096    /* number of input packets to keep */
+#define TCP_FUNCTION_BLK 8192  /* Set the tcp function pointers to the specified stack */
+/* Start of reserved space for third-party user-settable options. */
+#define        TCP_VENDOR      SO_VENDOR
+
+#define        TCP_CA_NAME_MAX 16      /* max congestion control name length */
+
+#define        TCPI_OPT_TIMESTAMPS     0x01
+#define        TCPI_OPT_SACK           0x02
+#define        TCPI_OPT_WSCALE         0x04
+#define        TCPI_OPT_ECN            0x08
+#define        TCPI_OPT_TOE            0x10
+
+/*
+ * The TCP_INFO socket option comes from the Linux 2.6 TCP API, and permits
+ * the caller to query certain information about the state of a TCP
+ * connection.  We provide an overlapping set of fields with the Linux
+ * implementation, but since this is a fixed size structure, room has been
+ * left for growth.  In order to maximize potential future compatibility with
+ * the Linux API, the same variable names and order have been adopted, and
+ * padding left to make room for omitted fields in case they are added later.
+ *
+ * XXX: This is currently an unstable ABI/API, in that it is expected to
+ * change.
+ */
+struct tcp_info {
+       u_int8_t        tcpi_state;             /* TCP FSM state. */
+       u_int8_t        __tcpi_ca_state;
+       u_int8_t        __tcpi_retransmits;
+       u_int8_t        __tcpi_probes;
+       u_int8_t        __tcpi_backoff;
+       u_int8_t        tcpi_options;           /* Options enabled on conn. */
+       u_int8_t        tcpi_snd_wscale:4,      /* RFC1323 send shift value. */
+                       tcpi_rcv_wscale:4;      /* RFC1323 recv shift value. */
+
+       u_int32_t       tcpi_rto;               /* Retransmission timeout (usec). */
+       u_int32_t       __tcpi_ato;
+       u_int32_t       tcpi_snd_mss;           /* Max segment size for send. */
+       u_int32_t       tcpi_rcv_mss;           /* Max segment size for receive. */
+
+       u_int32_t       __tcpi_unacked;
+       u_int32_t       __tcpi_sacked;
+       u_int32_t       __tcpi_lost;
+       u_int32_t       __tcpi_retrans;
+       u_int32_t       __tcpi_fackets;
+
+       /* Times; measurements in usecs. */
+       u_int32_t       __tcpi_last_data_sent;
+       u_int32_t       __tcpi_last_ack_sent;   /* Also unimpl. on Linux? */
+       u_int32_t       tcpi_last_data_recv;    /* Time since last recv data. */
+       u_int32_t       __tcpi_last_ack_recv;
+
+       /* Metrics; variable units. */
+       u_int32_t       __tcpi_pmtu;
+       u_int32_t       __tcpi_rcv_ssthresh;
+       u_int32_t       tcpi_rtt;               /* Smoothed RTT in usecs. */
+       u_int32_t       tcpi_rttvar;            /* RTT variance in usecs. */
+       u_int32_t       tcpi_snd_ssthresh;      /* Slow start threshold. */
+       u_int32_t       tcpi_snd_cwnd;          /* Send congestion window. */
+       u_int32_t       __tcpi_advmss;
+       u_int32_t       __tcpi_reordering;
+
+       u_int32_t       __tcpi_rcv_rtt;
+       u_int32_t       tcpi_rcv_space;         /* Advertised recv window. */
+
+       /* FreeBSD extensions to tcp_info. */
+       u_int32_t       tcpi_snd_wnd;           /* Advertised send window. */
+       u_int32_t       tcpi_snd_bwnd;          /* No longer used. */
+       u_int32_t       tcpi_snd_nxt;           /* Next egress seqno */
+       u_int32_t       tcpi_rcv_nxt;           /* Next ingress seqno */
+       u_int32_t       tcpi_toe_tid;           /* HWTID for TOE endpoints */
+       u_int32_t       tcpi_snd_rexmitpack;    /* Retransmitted packets */
+       u_int32_t       tcpi_rcv_ooopack;       /* Out-of-order packets */
+       u_int32_t       tcpi_snd_zerowin;       /* Zero-sized windows sent */
+       
+       /* Padding to grow without breaking ABI. */
+       u_int32_t       __tcpi_pad[26];         /* Padding. */
+};
+#endif
+#define TCP_FUNCTION_NAME_LEN_MAX 32
+
+struct tcp_function_set {
+       char function_set_name[TCP_FUNCTION_NAME_LEN_MAX];
+       uint32_t pcbcnt;
+};
+
+#endif /* !_NETINET_TCP_H_ */
diff --git a/newlib/libc/sys/rtems/include/netinet6/in6.h b/newlib/libc/sys/rtems/include/netinet6/in6.h
new file mode 100644 (file)
index 0000000..f9207e8
--- /dev/null
@@ -0,0 +1,748 @@
+/*-
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project 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 PROJECT 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 PROJECT 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.
+ *
+ *     $KAME: in6.h,v 1.89 2001/05/27 13:28:35 itojun Exp $
+ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)in.h        8.3 (Berkeley) 1/3/94
+ * $FreeBSD: head/sys/netinet6/in6.h 314722 2017-03-06 04:01:58Z eri $
+ */
+
+#ifndef __KAME_NETINET_IN_H_INCLUDED_
+#error "do not include netinet6/in6.h directly, include netinet/in.h.  see RFC2553"
+#endif
+
+#ifndef _NETINET6_IN6_H_
+#define _NETINET6_IN6_H_
+
+/*
+ * Identification of the network protocol stack
+ * for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE
+ * has the table of implementation/integration differences.
+ */
+#define __KAME__
+#define __KAME_VERSION         "FreeBSD"
+
+/*
+ * IPv6 port allocation rules should mirror the IPv4 rules and are controlled
+ * by the net.inet.ip.portrange sysctl tree. The following defines exist
+ * for compatibility with userland applications that need them.
+ */
+#if __BSD_VISIBLE
+#define        IPV6PORT_RESERVED       1024
+#define        IPV6PORT_ANONMIN        49152
+#define        IPV6PORT_ANONMAX        65535
+#define        IPV6PORT_RESERVEDMIN    600
+#define        IPV6PORT_RESERVEDMAX    (IPV6PORT_RESERVED-1)
+#endif
+
+/*
+ * IPv6 address
+ */
+struct in6_addr {
+       union {
+               uint8_t         __u6_addr8[16];
+               uint16_t        __u6_addr16[8];
+               uint32_t        __u6_addr32[4];
+       } __u6_addr;                    /* 128-bit IP6 address */
+};
+
+#define s6_addr   __u6_addr.__u6_addr8
+#ifdef _KERNEL /* XXX nonstandard */
+#define s6_addr8  __u6_addr.__u6_addr8
+#define s6_addr16 __u6_addr.__u6_addr16
+#define s6_addr32 __u6_addr.__u6_addr32
+#endif
+
+#define INET6_ADDRSTRLEN       46
+
+/*
+ * XXX missing POSIX.1-2001 macro IPPROTO_IPV6.
+ */
+
+/*
+ * Socket address for IPv6
+ */
+#if __BSD_VISIBLE
+#define SIN6_LEN
+#endif
+
+struct sockaddr_in6 {
+       uint8_t         sin6_len;       /* length of this struct */
+       sa_family_t     sin6_family;    /* AF_INET6 */
+       in_port_t       sin6_port;      /* Transport layer port # */
+       uint32_t        sin6_flowinfo;  /* IP6 flow information */
+       struct in6_addr sin6_addr;      /* IP6 address */
+       uint32_t        sin6_scope_id;  /* scope zone index */
+};
+
+/*
+ * Local definition for masks
+ */
+#ifdef _KERNEL /* XXX nonstandard */
+#define IN6MASK0       {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}}
+#define IN6MASK32      {{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \
+                           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
+#define IN6MASK64      {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+                           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
+#define IN6MASK96      {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+                           0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}}
+#define IN6MASK128     {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
+                           0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}}
+#endif
+
+#ifdef _KERNEL
+extern const struct sockaddr_in6 sa6_any;
+
+extern const struct in6_addr in6mask0;
+extern const struct in6_addr in6mask32;
+extern const struct in6_addr in6mask64;
+extern const struct in6_addr in6mask96;
+extern const struct in6_addr in6mask128;
+#endif /* _KERNEL */
+
+/*
+ * Macros started with IPV6_ADDR is KAME local
+ */
+#ifdef _KERNEL /* XXX nonstandard */
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define IPV6_ADDR_INT32_ONE    1
+#define IPV6_ADDR_INT32_TWO    2
+#define IPV6_ADDR_INT32_MNL    0xff010000
+#define IPV6_ADDR_INT32_MLL    0xff020000
+#define IPV6_ADDR_INT32_SMP    0x0000ffff
+#define IPV6_ADDR_INT16_ULL    0xfe80
+#define IPV6_ADDR_INT16_USL    0xfec0
+#define IPV6_ADDR_INT16_MLL    0xff02
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
+#define IPV6_ADDR_INT32_ONE    0x01000000
+#define IPV6_ADDR_INT32_TWO    0x02000000
+#define IPV6_ADDR_INT32_MNL    0x000001ff
+#define IPV6_ADDR_INT32_MLL    0x000002ff
+#define IPV6_ADDR_INT32_SMP    0xffff0000
+#define IPV6_ADDR_INT16_ULL    0x80fe
+#define IPV6_ADDR_INT16_USL    0xc0fe
+#define IPV6_ADDR_INT16_MLL    0x02ff
+#endif
+#endif
+
+/*
+ * Definition of some useful macros to handle IP6 addresses
+ */
+#if __BSD_VISIBLE
+#define IN6ADDR_ANY_INIT \
+       {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
+#define IN6ADDR_LOOPBACK_INIT \
+       {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
+#define IN6ADDR_NODELOCAL_ALLNODES_INIT \
+       {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
+#define IN6ADDR_INTFACELOCAL_ALLNODES_INIT \
+       {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
+#define IN6ADDR_LINKLOCAL_ALLNODES_INIT \
+       {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
+#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \
+       {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}}
+#define IN6ADDR_LINKLOCAL_ALLV2ROUTERS_INIT \
+       {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16 }}}
+#endif
+
+extern const struct in6_addr in6addr_any;
+extern const struct in6_addr in6addr_loopback;
+#if __BSD_VISIBLE
+extern const struct in6_addr in6addr_nodelocal_allnodes;
+extern const struct in6_addr in6addr_linklocal_allnodes;
+extern const struct in6_addr in6addr_linklocal_allrouters;
+extern const struct in6_addr in6addr_linklocal_allv2routers;
+#endif
+
+/*
+ * Equality
+ * NOTE: Some of kernel programming environment (for example, openbsd/sparc)
+ * does not supply memcmp().  For userland memcmp() is preferred as it is
+ * in ANSI standard.
+ */
+#ifdef _KERNEL
+#define IN6_ARE_ADDR_EQUAL(a, b)                       \
+    (bcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
+#else
+#if __BSD_VISIBLE
+#define IN6_ARE_ADDR_EQUAL(a, b)                       \
+    (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
+#endif
+#endif
+
+/*
+ * Unspecified
+ */
+#define IN6_IS_ADDR_UNSPECIFIED(a)     \
+       ((a)->__u6_addr.__u6_addr32[0] == 0 &&  \
+        (a)->__u6_addr.__u6_addr32[1] == 0 &&  \
+        (a)->__u6_addr.__u6_addr32[2] == 0 &&  \
+        (a)->__u6_addr.__u6_addr32[3] == 0)
+
+/*
+ * Loopback
+ */
+#define IN6_IS_ADDR_LOOPBACK(a)                \
+       ((a)->__u6_addr.__u6_addr32[0] == 0 &&  \
+        (a)->__u6_addr.__u6_addr32[1] == 0 &&  \
+        (a)->__u6_addr.__u6_addr32[2] == 0 &&  \
+        (a)->__u6_addr.__u6_addr32[3] == ntohl(1))
+
+/*
+ * IPv4 compatible
+ */
+#define IN6_IS_ADDR_V4COMPAT(a)                \
+       ((a)->__u6_addr.__u6_addr32[0] == 0 &&  \
+        (a)->__u6_addr.__u6_addr32[1] == 0 &&  \
+        (a)->__u6_addr.__u6_addr32[2] == 0 &&  \
+        (a)->__u6_addr.__u6_addr32[3] != 0 &&  \
+        (a)->__u6_addr.__u6_addr32[3] != ntohl(1))
+
+/*
+ * Mapped
+ */
+#define IN6_IS_ADDR_V4MAPPED(a)                      \
+       ((a)->__u6_addr.__u6_addr32[0] == 0 &&  \
+        (a)->__u6_addr.__u6_addr32[1] == 0 &&  \
+        (a)->__u6_addr.__u6_addr32[2] == ntohl(0x0000ffff))
+
+/*
+ * KAME Scope Values
+ */
+
+#ifdef _KERNEL /* XXX nonstandard */
+#define IPV6_ADDR_SCOPE_NODELOCAL      0x01
+#define IPV6_ADDR_SCOPE_INTFACELOCAL   0x01
+#define IPV6_ADDR_SCOPE_LINKLOCAL      0x02
+#define IPV6_ADDR_SCOPE_SITELOCAL      0x05
+#define IPV6_ADDR_SCOPE_ORGLOCAL       0x08    /* just used in this file */
+#define IPV6_ADDR_SCOPE_GLOBAL         0x0e
+#else
+#define __IPV6_ADDR_SCOPE_NODELOCAL    0x01
+#define __IPV6_ADDR_SCOPE_INTFACELOCAL 0x01
+#define __IPV6_ADDR_SCOPE_LINKLOCAL    0x02
+#define __IPV6_ADDR_SCOPE_SITELOCAL    0x05
+#define __IPV6_ADDR_SCOPE_ORGLOCAL     0x08    /* just used in this file */
+#define __IPV6_ADDR_SCOPE_GLOBAL       0x0e
+#endif
+
+/*
+ * Unicast Scope
+ * Note that we must check topmost 10 bits only, not 16 bits (see RFC2373).
+ */
+#define IN6_IS_ADDR_LINKLOCAL(a)       \
+       (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
+#define IN6_IS_ADDR_SITELOCAL(a)       \
+       (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
+
+/*
+ * Multicast
+ */
+#define IN6_IS_ADDR_MULTICAST(a)       ((a)->s6_addr[0] == 0xff)
+
+#ifdef _KERNEL /* XXX nonstandard */
+#define IPV6_ADDR_MC_SCOPE(a)          ((a)->s6_addr[1] & 0x0f)
+#else
+#define __IPV6_ADDR_MC_SCOPE(a)                ((a)->s6_addr[1] & 0x0f)
+#endif
+
+/*
+ * Multicast Scope
+ */
+#ifdef _KERNEL /* refers nonstandard items */
+#define IN6_IS_ADDR_MC_NODELOCAL(a)    \
+       (IN6_IS_ADDR_MULTICAST(a) &&    \
+        (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL))
+#define IN6_IS_ADDR_MC_INTFACELOCAL(a) \
+       (IN6_IS_ADDR_MULTICAST(a) &&    \
+        (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL))
+#define IN6_IS_ADDR_MC_LINKLOCAL(a)    \
+       (IN6_IS_ADDR_MULTICAST(a) &&    \
+        (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL))
+#define IN6_IS_ADDR_MC_SITELOCAL(a)    \
+       (IN6_IS_ADDR_MULTICAST(a) &&    \
+        (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL))
+#define IN6_IS_ADDR_MC_ORGLOCAL(a)     \
+       (IN6_IS_ADDR_MULTICAST(a) &&    \
+        (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL))
+#define IN6_IS_ADDR_MC_GLOBAL(a)       \
+       (IN6_IS_ADDR_MULTICAST(a) &&    \
+        (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL))
+#else
+#define IN6_IS_ADDR_MC_NODELOCAL(a)    \
+       (IN6_IS_ADDR_MULTICAST(a) &&    \
+        (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL))
+#define IN6_IS_ADDR_MC_LINKLOCAL(a)    \
+       (IN6_IS_ADDR_MULTICAST(a) &&    \
+        (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL))
+#define IN6_IS_ADDR_MC_SITELOCAL(a)    \
+       (IN6_IS_ADDR_MULTICAST(a) &&    \
+        (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
+#define IN6_IS_ADDR_MC_ORGLOCAL(a)     \
+       (IN6_IS_ADDR_MULTICAST(a) &&    \
+        (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
+#define IN6_IS_ADDR_MC_GLOBAL(a)       \
+       (IN6_IS_ADDR_MULTICAST(a) &&    \
+        (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL))
+#endif
+
+#ifdef _KERNEL /* nonstandard */
+/*
+ * KAME Scope
+ */
+#define IN6_IS_SCOPE_LINKLOCAL(a)      \
+       ((IN6_IS_ADDR_LINKLOCAL(a)) ||  \
+        (IN6_IS_ADDR_MC_LINKLOCAL(a)))
+#define        IN6_IS_SCOPE_EMBED(a)                   \
+       ((IN6_IS_ADDR_LINKLOCAL(a)) ||          \
+        (IN6_IS_ADDR_MC_LINKLOCAL(a)) ||       \
+        (IN6_IS_ADDR_MC_INTFACELOCAL(a)))
+
+#define IFA6_IS_DEPRECATED(a) \
+       ((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \
+        (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
+        (a)->ia6_lifetime.ia6t_pltime)
+#define IFA6_IS_INVALID(a) \
+       ((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \
+        (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
+        (a)->ia6_lifetime.ia6t_vltime)
+#endif /* _KERNEL */
+
+/*
+ * IP6 route structure
+ */
+#if __BSD_VISIBLE
+struct route_in6 {
+       struct  rtentry *ro_rt;
+       struct  llentry *ro_lle;
+       /*
+        * ro_prepend and ro_plen are only used for bpf to pass in a
+        * preformed header.  They are not cacheable.
+        */
+       char            *ro_prepend;
+       uint16_t        ro_plen;
+       uint16_t        ro_flags;
+       uint16_t        ro_mtu; /* saved ro_rt mtu */
+       uint16_t        spare;
+       struct  sockaddr_in6 ro_dst;
+};
+#endif
+
+#ifdef _KERNEL
+#define MTAG_ABI_IPV6          1444287380      /* IPv6 ABI */
+#define IPV6_TAG_DIRECT                0               /* direct-dispatch IPv6 */
+#endif /* _KERNEL */
+
+/*
+ * Options for use with [gs]etsockopt at the IPV6 level.
+ * First word of comment is data type; bool is stored in int.
+ */
+/* no hdrincl */
+#if 0 /* the followings are relic in IPv4 and hence are disabled */
+#define IPV6_OPTIONS           1  /* buf/ip6_opts; set/get IP6 options */
+#define IPV6_RECVOPTS          5  /* bool; receive all IP6 opts w/dgram */
+#define IPV6_RECVRETOPTS       6  /* bool; receive IP6 opts for response */
+#define IPV6_RECVDSTADDR       7  /* bool; receive IP6 dst addr w/dgram */
+#define IPV6_RETOPTS           8  /* ip6_opts; set/get IP6 options */
+#endif
+#define IPV6_SOCKOPT_RESERVED1 3  /* reserved for future use */
+#define IPV6_UNICAST_HOPS      4  /* int; IP6 hops */
+#define IPV6_MULTICAST_IF      9  /* u_int; set/get IP6 multicast i/f  */
+#define IPV6_MULTICAST_HOPS    10 /* int; set/get IP6 multicast hops */
+#define IPV6_MULTICAST_LOOP    11 /* u_int; set/get IP6 multicast loopback */
+#define IPV6_JOIN_GROUP                12 /* ipv6_mreq; join a group membership */
+#define IPV6_LEAVE_GROUP       13 /* ipv6_mreq; leave a group membership */
+#define IPV6_PORTRANGE         14 /* int; range to choose for unspec port */
+#define ICMP6_FILTER           18 /* icmp6_filter; icmp6 filter */
+/* RFC2292 options */
+#ifdef _KERNEL
+#define IPV6_2292PKTINFO       19 /* bool; send/recv if, src/dst addr */
+#define IPV6_2292HOPLIMIT      20 /* bool; hop limit */
+#define IPV6_2292NEXTHOP       21 /* bool; next hop addr */
+#define IPV6_2292HOPOPTS       22 /* bool; hop-by-hop option */
+#define IPV6_2292DSTOPTS       23 /* bool; destinaion option */
+#define IPV6_2292RTHDR         24 /* bool; routing header */
+#define IPV6_2292PKTOPTIONS    25 /* buf/cmsghdr; set/get IPv6 options */
+#endif
+
+#define IPV6_CHECKSUM          26 /* int; checksum offset for raw socket */
+#define IPV6_V6ONLY            27 /* bool; make AF_INET6 sockets v6 only */
+#ifndef _KERNEL
+#define IPV6_BINDV6ONLY                IPV6_V6ONLY
+#endif
+
+#define IPV6_IPSEC_POLICY      28 /* struct; get/set security policy */
+                                  /* 29; unused; was IPV6_FAITH */
+#if 1 /* IPV6FIREWALL */
+#define IPV6_FW_ADD            30 /* add a firewall rule to chain */
+#define IPV6_FW_DEL            31 /* delete a firewall rule from chain */
+#define IPV6_FW_FLUSH          32 /* flush firewall rule chain */
+#define IPV6_FW_ZERO           33 /* clear single/all firewall counter(s) */
+#define IPV6_FW_GET            34 /* get entire firewall rule chain */
+#endif
+
+/* new socket options introduced in RFC3542 */
+#define IPV6_RTHDRDSTOPTS      35 /* ip6_dest; send dst option before rthdr */
+
+#define IPV6_RECVPKTINFO       36 /* bool; recv if, dst addr */
+#define IPV6_RECVHOPLIMIT      37 /* bool; recv hop limit */
+#define IPV6_RECVRTHDR         38 /* bool; recv routing header */
+#define IPV6_RECVHOPOPTS       39 /* bool; recv hop-by-hop option */
+#define IPV6_RECVDSTOPTS       40 /* bool; recv dst option after rthdr */
+#ifdef _KERNEL
+#define IPV6_RECVRTHDRDSTOPTS  41 /* bool; recv dst option before rthdr */
+#endif
+
+#define IPV6_USE_MIN_MTU       42 /* bool; send packets at the minimum MTU */
+#define IPV6_RECVPATHMTU       43 /* bool; notify an according MTU */
+
+#define IPV6_PATHMTU           44 /* mtuinfo; get the current path MTU (sopt),
+                                     4 bytes int; MTU notification (cmsg) */
+#if 0 /*obsoleted during 2292bis -> 3542*/
+#define IPV6_REACHCONF         45 /* no data; ND reachability confirm
+                                     (cmsg only/not in of RFC3542) */
+#endif
+
+/* more new socket options introduced in RFC3542 */
+#define IPV6_PKTINFO           46 /* in6_pktinfo; send if, src addr */
+#define IPV6_HOPLIMIT          47 /* int; send hop limit */
+#define IPV6_NEXTHOP           48 /* sockaddr; next hop addr */
+#define IPV6_HOPOPTS           49 /* ip6_hbh; send hop-by-hop option */
+#define IPV6_DSTOPTS           50 /* ip6_dest; send dst option befor rthdr */
+#define IPV6_RTHDR             51 /* ip6_rthdr; send routing header */
+#if 0
+#define IPV6_PKTOPTIONS                52 /* buf/cmsghdr; set/get IPv6 options */
+                                  /* obsoleted by RFC3542 */
+#endif
+
+#define IPV6_RECVTCLASS                57 /* bool; recv traffic class values */
+
+#define IPV6_AUTOFLOWLABEL     59 /* bool; attach flowlabel automagically */
+
+#define IPV6_TCLASS            61 /* int; send traffic class value */
+#define IPV6_DONTFRAG          62 /* bool; disable IPv6 fragmentation */
+
+#define IPV6_PREFER_TEMPADDR   63 /* int; prefer temporary addresses as
+                                   * the source address.
+                                   */
+
+#define        IPV6_BINDANY            64 /* bool: allow bind to any address */
+
+#define        IPV6_BINDMULTI          65 /* bool; allow multibind to same addr/port */
+#define        IPV6_RSS_LISTEN_BUCKET  66 /* int; set RSS listen bucket */
+#define        IPV6_FLOWID             67 /* int; flowid of given socket */
+#define        IPV6_FLOWTYPE           68 /* int; flowtype of given socket */
+#define        IPV6_RSSBUCKETID        69 /* int; RSS bucket ID of given socket */
+#define        IPV6_RECVFLOWID         70 /* bool; receive IP6 flowid/flowtype w/ datagram */
+#define        IPV6_RECVRSSBUCKETID    71 /* bool; receive IP6 RSS bucket id w/ datagram */
+
+#define        IPV6_ORIGDSTADDR        72 /* bool: allow getting dstaddr /port info */
+#define        IPV6_RECVORIGDSTADDR    IPV6_ORIGDSTADDR
+
+/*
+ * The following option is private; do not use it from user applications.
+ * It is deliberately defined to the same value as IP_MSFILTER.
+ */
+#define        IPV6_MSFILTER           74 /* struct __msfilterreq;
+                                   * set/get multicast source filter list.
+                                   */
+
+/* to define items, should talk with KAME guys first, for *BSD compatibility */
+
+#define IPV6_RTHDR_LOOSE     0 /* this hop need not be a neighbor. XXX old spec */
+#define IPV6_RTHDR_STRICT    1 /* this hop must be a neighbor. XXX old spec */
+#define IPV6_RTHDR_TYPE_0    0 /* IPv6 routing header type 0 */
+
+/*
+ * Defaults and limits for options
+ */
+#define IPV6_DEFAULT_MULTICAST_HOPS 1  /* normally limit m'casts to 1 hop */
+#define IPV6_DEFAULT_MULTICAST_LOOP 1  /* normally hear sends if a member */
+
+/*
+ * The im6o_membership vector for each socket is now dynamically allocated at
+ * run-time, bounded by USHRT_MAX, and is reallocated when needed, sized
+ * according to a power-of-two increment.
+ */
+#define        IPV6_MIN_MEMBERSHIPS    31
+#define        IPV6_MAX_MEMBERSHIPS    4095
+
+/*
+ * Default resource limits for IPv6 multicast source filtering.
+ * These may be modified by sysctl.
+ */
+#define        IPV6_MAX_GROUP_SRC_FILTER       512     /* sources per group */
+#define        IPV6_MAX_SOCK_SRC_FILTER        128     /* sources per socket/group */
+
+/*
+ * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP.
+ */
+struct ipv6_mreq {
+       struct in6_addr ipv6mr_multiaddr;
+       unsigned int    ipv6mr_interface;
+};
+
+/*
+ * IPV6_PKTINFO: Packet information(RFC2292 sec 5)
+ */
+struct in6_pktinfo {
+       struct in6_addr ipi6_addr;      /* src/dst IPv6 address */
+       unsigned int    ipi6_ifindex;   /* send/recv interface index */
+};
+
+/*
+ * Control structure for IPV6_RECVPATHMTU socket option.
+ */
+struct ip6_mtuinfo {
+       struct sockaddr_in6 ip6m_addr;  /* or sockaddr_storage? */
+       uint32_t ip6m_mtu;
+};
+
+/*
+ * Argument for IPV6_PORTRANGE:
+ * - which range to search when port is unspecified at bind() or connect()
+ */
+#define        IPV6_PORTRANGE_DEFAULT  0       /* default range */
+#define        IPV6_PORTRANGE_HIGH     1       /* "high" - request firewall bypass */
+#define        IPV6_PORTRANGE_LOW      2       /* "low" - vouchsafe security */
+
+#if __BSD_VISIBLE
+/*
+ * Definitions for inet6 sysctl operations.
+ *
+ * Third level is protocol number.
+ * Fourth level is desired variable within that protocol.
+ */
+#define IPV6PROTO_MAXID        (IPPROTO_PIM + 1)       /* don't list to IPV6PROTO_MAX */
+
+/*
+ * Names for IP sysctl objects
+ */
+#define IPV6CTL_FORWARDING     1       /* act as router */
+#define IPV6CTL_SENDREDIRECTS  2       /* may send redirects when forwarding*/
+#define IPV6CTL_DEFHLIM                3       /* default Hop-Limit */
+#ifdef notyet
+#define IPV6CTL_DEFMTU         4       /* default MTU */
+#endif
+#define IPV6CTL_FORWSRCRT      5       /* forward source-routed dgrams */
+#define IPV6CTL_STATS          6       /* stats */
+#define IPV6CTL_MRTSTATS       7       /* multicast forwarding stats */
+#define IPV6CTL_MRTPROTO       8       /* multicast routing protocol */
+#define IPV6CTL_MAXFRAGPACKETS 9       /* max packets reassembly queue */
+#define IPV6CTL_SOURCECHECK    10      /* verify source route and intf */
+#define IPV6CTL_SOURCECHECK_LOGINT 11  /* minimume logging interval */
+#define IPV6CTL_ACCEPT_RTADV   12
+                                       /* 13; unused; was: IPV6CTL_KEEPFAITH */
+#define IPV6CTL_LOG_INTERVAL   14
+#define IPV6CTL_HDRNESTLIMIT   15
+#define IPV6CTL_DAD_COUNT      16
+#define IPV6CTL_AUTO_FLOWLABEL 17
+#define IPV6CTL_DEFMCASTHLIM   18
+#define IPV6CTL_GIF_HLIM       19      /* default HLIM for gif encap packet */
+#define IPV6CTL_KAME_VERSION   20
+#define IPV6CTL_USE_DEPRECATED 21      /* use deprecated addr (RFC2462 5.5.4) */
+#define IPV6CTL_RR_PRUNE       22      /* walk timer for router renumbering */
+#if 0  /* obsolete */
+#define IPV6CTL_MAPPED_ADDR    23
+#endif
+#define IPV6CTL_V6ONLY         24
+/*     IPV6CTL_RTEXPIRE        25      deprecated */
+/*     IPV6CTL_RTMINEXPIRE     26      deprecated */
+/*     IPV6CTL_RTMAXCACHE      27      deprecated */
+
+#define IPV6CTL_USETEMPADDR    32      /* use temporary addresses (RFC3041) */
+#define IPV6CTL_TEMPPLTIME     33      /* preferred lifetime for tmpaddrs */
+#define IPV6CTL_TEMPVLTIME     34      /* valid lifetime for tmpaddrs */
+#define IPV6CTL_AUTO_LINKLOCAL 35      /* automatic link-local addr assign */
+#define IPV6CTL_RIP6STATS      36      /* raw_ip6 stats */
+#define IPV6CTL_PREFER_TEMPADDR        37      /* prefer temporary addr as src */
+#define IPV6CTL_ADDRCTLPOLICY  38      /* get/set address selection policy */
+#define IPV6CTL_USE_DEFAULTZONE        39      /* use default scope zone */
+
+#define IPV6CTL_MAXFRAGS       41      /* max fragments */
+#if 0
+#define IPV6CTL_IFQ            42      /* ip6intrq node */
+#define IPV6CTL_ISATAPRTR      43      /* isatap router */
+#endif
+#define IPV6CTL_MCAST_PMTU     44      /* enable pMTU discovery for multicast? */
+
+/* New entries should be added here from current IPV6CTL_MAXID value. */
+/* to define items, should talk with KAME guys first, for *BSD compatibility */
+#define IPV6CTL_STEALTH                45
+
+#define        ICMPV6CTL_ND6_ONLINKNSRFC4861   47
+#define        IPV6CTL_NO_RADR         48      /* No defroute from RA */
+#define        IPV6CTL_NORBIT_RAIF     49      /* Disable R-bit in NA on RA
+                                        * receiving IF. */
+#define        IPV6CTL_RFC6204W3       50      /* Accept defroute even when forwarding
+                                          enabled */
+#define        IPV6CTL_INTRQMAXLEN     51      /* max length of IPv6 netisr queue */
+#define        IPV6CTL_INTRDQMAXLEN    52      /* max length of direct IPv6 netisr
+                                        * queue */
+#define        IPV6CTL_MAXID           53
+#endif /* __BSD_VISIBLE */
+
+/*
+ * Since both netinet/ and netinet6/ call into netipsec/ and netpfil/,
+ * the protocol specific mbuf flags are shared between them.
+ */
+#define        M_FASTFWD_OURS          M_PROTO1        /* changed dst to local */
+#define        M_IP6_NEXTHOP           M_PROTO2        /* explicit ip nexthop */
+#define        M_IP_NEXTHOP            M_PROTO2        /* explicit ip nexthop */
+#define        M_SKIP_FIREWALL         M_PROTO3        /* skip firewall processing */
+#define        M_AUTHIPHDR             M_PROTO4
+#define        M_DECRYPTED             M_PROTO5
+#define        M_LOOP                  M_PROTO6
+#define        M_AUTHIPDGM             M_PROTO7
+#define        M_RTALERT_MLD           M_PROTO8
+
+#ifdef _KERNEL
+struct cmsghdr;
+struct ip6_hdr;
+
+int    in6_cksum_pseudo(struct ip6_hdr *, uint32_t, uint8_t, uint16_t);
+int    in6_cksum(struct mbuf *, u_int8_t, u_int32_t, u_int32_t);
+int    in6_cksum_partial(struct mbuf *, u_int8_t, u_int32_t, u_int32_t,
+                         u_int32_t);
+int    in6_localaddr(struct in6_addr *);
+int    in6_localip(struct in6_addr *);
+int    in6_ifhasaddr(struct ifnet *, struct in6_addr *);
+int    in6_addrscope(const struct in6_addr *);
+char   *ip6_sprintf(char *, const struct in6_addr *);
+struct in6_ifaddr *in6_ifawithifp(struct ifnet *, struct in6_addr *);
+extern void in6_if_up(struct ifnet *);
+struct sockaddr;
+extern u_char  ip6_protox[];
+
+void   in6_sin6_2_sin(struct sockaddr_in *sin,
+                           struct sockaddr_in6 *sin6);
+void   in6_sin_2_v4mapsin6(struct sockaddr_in *sin,
+                                struct sockaddr_in6 *sin6);
+void   in6_sin6_2_sin_in_sock(struct sockaddr *nam);
+void   in6_sin_2_v4mapsin6_in_sock(struct sockaddr **nam);
+extern void addrsel_policy_init(void);
+
+#define        satosin6(sa)    ((struct sockaddr_in6 *)(sa))
+#define        sin6tosa(sin6)  ((struct sockaddr *)(sin6))
+#define        ifatoia6(ifa)   ((struct in6_ifaddr *)(ifa))
+
+#endif /* _KERNEL */
+
+#ifndef _SIZE_T_DECLARED
+typedef        __size_t        size_t;
+#define        _SIZE_T_DECLARED
+#endif
+
+#ifndef _SOCKLEN_T_DECLARED
+typedef        __socklen_t     socklen_t;
+#define        _SOCKLEN_T_DECLARED
+#endif
+
+#if __BSD_VISIBLE
+
+__BEGIN_DECLS
+struct cmsghdr;
+
+extern int inet6_option_space(int);
+extern int inet6_option_init(void *, struct cmsghdr **, int);
+extern int inet6_option_append(struct cmsghdr *, const uint8_t *,
+       int, int);
+extern uint8_t *inet6_option_alloc(struct cmsghdr *, int, int, int);
+extern int inet6_option_next(const struct cmsghdr *, uint8_t **);
+extern int inet6_option_find(const struct cmsghdr *, uint8_t **, int);
+
+extern size_t inet6_rthdr_space(int, int);
+extern struct cmsghdr *inet6_rthdr_init(void *, int);
+extern int inet6_rthdr_add(struct cmsghdr *, const struct in6_addr *,
+       unsigned int);
+extern int inet6_rthdr_lasthop(struct cmsghdr *, unsigned int);
+#if 0 /* not implemented yet */
+extern int inet6_rthdr_reverse(const struct cmsghdr *, struct cmsghdr *);
+#endif
+extern int inet6_rthdr_segments(const struct cmsghdr *);
+extern struct in6_addr *inet6_rthdr_getaddr(struct cmsghdr *, int);
+extern int inet6_rthdr_getflags(const struct cmsghdr *, int);
+
+extern int inet6_opt_init(void *, socklen_t);
+extern int inet6_opt_append(void *, socklen_t, int, uint8_t, socklen_t,
+       uint8_t, void **);
+extern int inet6_opt_finish(void *, socklen_t, int);
+extern int inet6_opt_set_val(void *, int, void *, socklen_t);
+
+extern int inet6_opt_next(void *, socklen_t, int, uint8_t *, socklen_t *,
+       void **);
+extern int inet6_opt_find(void *, socklen_t, int, uint8_t, socklen_t *,
+       void **);
+extern int inet6_opt_get_val(void *, int, void *, socklen_t);
+extern socklen_t inet6_rth_space(int, int);
+extern void *inet6_rth_init(void *, socklen_t, int, int);
+extern int inet6_rth_add(void *, const struct in6_addr *);
+extern int inet6_rth_reverse(const void *, void *);
+extern int inet6_rth_segments(const void *);
+extern struct in6_addr *inet6_rth_getaddr(const void *, int);
+__END_DECLS
+
+#endif /* __BSD_VISIBLE */
+
+#endif /* !_NETINET6_IN6_H_ */
diff --git a/newlib/libc/sys/rtems/include/sys/_iovec.h b/newlib/libc/sys/rtems/include/sys/_iovec.h
new file mode 100644 (file)
index 0000000..7f53bb2
--- /dev/null
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 1982, 1986, 1993, 1994
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)uio.h       8.5 (Berkeley) 2/22/94
+ * $FreeBSD: head/sys/sys/_iovec.h 314436 2017-02-28 23:42:47Z imp $
+ */
+
+#ifndef _SYS__IOVEC_H_
+#define        _SYS__IOVEC_H_
+
+#include <sys/_types.h>
+
+#ifndef _SIZE_T_DECLARED
+typedef        __size_t        size_t;
+#define        _SIZE_T_DECLARED
+#endif
+
+struct iovec {
+       void    *iov_base;      /* Base address. */
+       size_t   iov_len;       /* Length. */
+};
+
+#endif /* !_SYS__IOVEC_H_ */
diff --git a/newlib/libc/sys/rtems/include/sys/_sockaddr_storage.h b/newlib/libc/sys/rtems/include/sys/_sockaddr_storage.h
new file mode 100644 (file)
index 0000000..97af76c
--- /dev/null
@@ -0,0 +1,54 @@
+/*-
+ * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)socket.h    8.4 (Berkeley) 2/21/94
+ * $FreeBSD: head/sys/sys/_sockaddr_storage.h 314436 2017-02-28 23:42:47Z imp $
+ */
+
+#ifndef _SYS__SOCKADDR_STORAGE_H_
+#define        _SYS__SOCKADDR_STORAGE_H_
+
+/*
+ * RFC 2553: protocol-independent placeholder for socket addresses
+ */
+#define        _SS_MAXSIZE     128U
+#define        _SS_ALIGNSIZE   (sizeof(__int64_t))
+#define        _SS_PAD1SIZE    (_SS_ALIGNSIZE - sizeof(unsigned char) - \
+                           sizeof(sa_family_t))
+#define        _SS_PAD2SIZE    (_SS_MAXSIZE - sizeof(unsigned char) - \
+                           sizeof(sa_family_t) - _SS_PAD1SIZE - _SS_ALIGNSIZE)
+
+struct sockaddr_storage {
+       unsigned char   ss_len;         /* address length */
+       sa_family_t     ss_family;      /* address family */
+       char            __ss_pad1[_SS_PAD1SIZE];
+       __int64_t       __ss_align;     /* force desired struct alignment */
+       char            __ss_pad2[_SS_PAD2SIZE];
+};
+
+#endif /* !_SYS__SOCKADDR_STORAGE_H_ */
diff --git a/newlib/libc/sys/rtems/include/sys/_termios.h b/newlib/libc/sys/rtems/include/sys/_termios.h
new file mode 100644 (file)
index 0000000..2fb4014
--- /dev/null
@@ -0,0 +1,222 @@
+/*-
+ * Copyright (c) 1988, 1989, 1993, 1994
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)termios.h   8.3 (Berkeley) 3/28/94
+ * $FreeBSD: head/sys/sys/_termios.h 318780 2017-05-24 09:25:13Z kib $
+ */
+
+#ifndef _SYS__TERMIOS_H_
+#define        _SYS__TERMIOS_H_
+
+/*
+ * Special Control Characters
+ *
+ * Index into c_cc[] character array.
+ *
+ *     Name         Subscript  Enabled by
+ */
+#define        VEOF            0       /* ICANON */
+#define        VEOL            1       /* ICANON */
+#if __BSD_VISIBLE
+#define        VEOL2           2       /* ICANON together with IEXTEN */
+#endif
+#define        VERASE          3       /* ICANON */
+#if __BSD_VISIBLE
+#define        VWERASE         4       /* ICANON together with IEXTEN */
+#endif
+#define        VKILL           5       /* ICANON */
+#if __BSD_VISIBLE
+#define        VREPRINT        6       /* ICANON together with IEXTEN */
+#define        VERASE2         7       /* ICANON */
+#endif
+/*                     7          ex-spare 1 */
+#define        VINTR           8       /* ISIG */
+#define        VQUIT           9       /* ISIG */
+#define        VSUSP           10      /* ISIG */
+#if __BSD_VISIBLE
+#define        VDSUSP          11      /* ISIG together with IEXTEN */
+#endif
+#define        VSTART          12      /* IXON, IXOFF */
+#define        VSTOP           13      /* IXON, IXOFF */
+#if __BSD_VISIBLE
+#define        VLNEXT          14      /* IEXTEN */
+#define        VDISCARD        15      /* IEXTEN */
+#endif
+#define        VMIN            16      /* !ICANON */
+#define        VTIME           17      /* !ICANON */
+#if __BSD_VISIBLE
+#define        VSTATUS         18      /* ICANON together with IEXTEN */
+/*                     19         spare 2 */
+#endif
+#define        NCCS            20
+
+#define        _POSIX_VDISABLE 0xff
+
+/*
+ * Input flags - software input processing
+ */
+#define        IGNBRK          0x00000001      /* ignore BREAK condition */
+#define        BRKINT          0x00000002      /* map BREAK to SIGINTR */
+#define        IGNPAR          0x00000004      /* ignore (discard) parity errors */
+#define        PARMRK          0x00000008      /* mark parity and framing errors */
+#define        INPCK           0x00000010      /* enable checking of parity errors */
+#define        ISTRIP          0x00000020      /* strip 8th bit off chars */
+#define        INLCR           0x00000040      /* map NL into CR */
+#define        IGNCR           0x00000080      /* ignore CR */
+#define        ICRNL           0x00000100      /* map CR to NL (ala CRMOD) */
+#define        IXON            0x00000200      /* enable output flow control */
+#define        IXOFF           0x00000400      /* enable input flow control */
+#if __BSD_VISIBLE
+#define        IXANY           0x00000800      /* any char will restart after stop */
+#define        IMAXBEL         0x00002000      /* ring bell on input queue full */
+#endif
+
+/*
+ * Output flags - software output processing
+ */
+#define        OPOST           0x00000001      /* enable following output processing */
+#if __BSD_VISIBLE
+#define        ONLCR           0x00000002      /* map NL to CR-NL (ala CRMOD) */
+#define        TABDLY          0x00000004      /* tab delay mask */
+#define            TAB0            0x00000000      /* no tab delay and expansion */
+#define            TAB3            0x00000004      /* expand tabs to spaces */
+#define        ONOEOT          0x00000008      /* discard EOT's (^D) on output) */
+#define        OCRNL           0x00000010      /* map CR to NL on output */
+#define        ONOCR           0x00000020      /* no CR output at column 0 */
+#define        ONLRET          0x00000040      /* NL performs CR function */
+#endif
+
+/*
+ * Control flags - hardware control of terminal
+ */
+#if __BSD_VISIBLE
+#define        CIGNORE         0x00000001      /* ignore control flags */
+#endif
+#define        CSIZE           0x00000300      /* character size mask */
+#define            CS5             0x00000000      /* 5 bits (pseudo) */
+#define            CS6             0x00000100      /* 6 bits */
+#define            CS7             0x00000200      /* 7 bits */
+#define            CS8             0x00000300      /* 8 bits */
+#define        CSTOPB          0x00000400      /* send 2 stop bits */
+#define        CREAD           0x00000800      /* enable receiver */
+#define        PARENB          0x00001000      /* parity enable */
+#define        PARODD          0x00002000      /* odd parity, else even */
+#define        HUPCL           0x00004000      /* hang up on last close */
+#define        CLOCAL          0x00008000      /* ignore modem status lines */
+#if __BSD_VISIBLE
+#define        CCTS_OFLOW      0x00010000      /* CTS flow control of output */
+#define        CRTSCTS         (CCTS_OFLOW | CRTS_IFLOW)
+#define        CRTS_IFLOW      0x00020000      /* RTS flow control of input */
+#define        CDTR_IFLOW      0x00040000      /* DTR flow control of input */
+#define        CDSR_OFLOW      0x00080000      /* DSR flow control of output */
+#define        CCAR_OFLOW      0x00100000      /* DCD flow control of output */
+#endif
+
+
+/*
+ * "Local" flags - dumping ground for other state
+ *
+ * Warning: some flags in this structure begin with
+ * the letter "I" and look like they belong in the
+ * input flag.
+ */
+
+#if __BSD_VISIBLE
+#define        ECHOKE          0x00000001      /* visual erase for line kill */
+#endif
+#define        ECHOE           0x00000002      /* visually erase chars */
+#define        ECHOK           0x00000004      /* echo NL after line kill */
+#define        ECHO            0x00000008      /* enable echoing */
+#define        ECHONL          0x00000010      /* echo NL even if ECHO is off */
+#if __BSD_VISIBLE
+#define        ECHOPRT         0x00000020      /* visual erase mode for hardcopy */
+#define        ECHOCTL         0x00000040      /* echo control chars as ^(Char) */
+#endif
+#define        ISIG            0x00000080      /* enable signals INTR, QUIT, [D]SUSP */
+#define        ICANON          0x00000100      /* canonicalize input lines */
+#if __BSD_VISIBLE
+#define        ALTWERASE       0x00000200      /* use alternate WERASE algorithm */
+#endif
+#define        IEXTEN          0x00000400      /* enable DISCARD and LNEXT */
+#define        EXTPROC         0x00000800      /* external processing */
+#define        TOSTOP          0x00400000      /* stop background jobs from output */
+#if __BSD_VISIBLE
+#define        FLUSHO          0x00800000      /* output being flushed (state) */
+#define        NOKERNINFO      0x02000000      /* no kernel output from VSTATUS */
+#define        PENDIN          0x20000000      /* XXX retype pending input (state) */
+#endif
+#define        NOFLSH          0x80000000      /* don't flush after interrupt */
+
+/*
+ * Standard speeds
+ */
+#define        B0      0
+#define        B50     50
+#define        B75     75
+#define        B110    110
+#define        B134    134
+#define        B150    150
+#define        B200    200
+#define        B300    300
+#define        B600    600
+#define        B1200   1200
+#define        B1800   1800
+#define        B2400   2400
+#define        B4800   4800
+#define        B9600   9600
+#define        B19200  19200
+#define        B38400  38400
+#if __BSD_VISIBLE
+#define        B7200   7200
+#define        B14400  14400
+#define        B28800  28800
+#define        B57600  57600
+#define        B76800  76800
+#define        B115200 115200
+#define        B230400 230400
+#define        B460800 460800
+#define        B921600 921600
+#define        EXTA    19200
+#define        EXTB    38400
+#endif
+
+typedef unsigned int   tcflag_t;
+typedef unsigned char  cc_t;
+typedef unsigned int   speed_t;
+
+struct termios {
+       tcflag_t        c_iflag;        /* input flags */
+       tcflag_t        c_oflag;        /* output flags */
+       tcflag_t        c_cflag;        /* control flags */
+       tcflag_t        c_lflag;        /* local flags */
+       cc_t            c_cc[NCCS];     /* control chars */
+       speed_t         c_ispeed;       /* input speed */
+       speed_t         c_ospeed;       /* output speed */
+};
+
+#endif /* !_SYS__TERMIOS_H_ */
diff --git a/newlib/libc/sys/rtems/include/sys/ioccom.h b/newlib/libc/sys/rtems/include/sys/ioccom.h
new file mode 100644 (file)
index 0000000..9c5350d
--- /dev/null
@@ -0,0 +1,87 @@
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993, 1994
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)ioccom.h    8.2 (Berkeley) 3/28/94
+ * $FreeBSD: head/sys/sys/ioccom.h 314436 2017-02-28 23:42:47Z imp $
+ */
+
+#ifndef        _SYS_IOCCOM_H_
+#define        _SYS_IOCCOM_H_
+
+#include <sys/types.h>
+#include <stdint.h>
+
+typedef uint32_t ioctl_command_t;
+
+/*
+ * Ioctl's have the command encoded in the lower word, and the size of
+ * any in or out parameters in the upper word.  The high 3 bits of the
+ * upper word are used to encode the in/out status of the parameter.
+ */
+#define        IOCPARM_SHIFT   13              /* number of bits for ioctl size */
+#define        IOCPARM_MASK    ((1 << IOCPARM_SHIFT) - 1) /* parameter length mask */
+#define        IOCPARM_LEN(x)  (((x) >> 16) & IOCPARM_MASK)
+#define        IOCBASECMD(x)   ((x) & ~(IOCPARM_MASK << 16))
+#define        IOCGROUP(x)     (((x) >> 8) & 0xff)
+
+#define        IOCPARM_MAX     (1 << IOCPARM_SHIFT) /* max size of ioctl */
+#define        IOC_VOID        0x20000000      /* no parameters */
+#define        IOC_OUT         0x40000000      /* copy out parameters */
+#define        IOC_IN          0x80000000      /* copy in parameters */
+#define        IOC_INOUT       (IOC_IN|IOC_OUT)
+#define        IOC_DIRMASK     (IOC_VOID|IOC_OUT|IOC_IN)
+
+#define        _IOC(inout,group,num,len)                                       \
+    ((ioctl_command_t)((ioctl_command_t)(inout) | (((ioctl_command_t)(len) & \
+    IOCPARM_MASK) << 16) | ((ioctl_command_t)(group) << 8) | \
+    (ioctl_command_t)(num)))
+#define        _IO(g,n)        _IOC(IOC_VOID,  (g), (n), 0)
+#define        _IOWINT(g,n)    _IOC(IOC_VOID,  (g), (n), sizeof(int))
+#define        _IOR(g,n,t)     _IOC(IOC_OUT,   (g), (n), sizeof(t))
+#define        _IOW(g,n,t)     _IOC(IOC_IN,    (g), (n), sizeof(t))
+/* this should be _IORW, but stdio got there first */
+#define        _IOWR(g,n,t)    _IOC(IOC_INOUT, (g), (n), sizeof(t))
+
+#ifdef _KERNEL
+
+#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
+    defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
+#define        IOCPARM_IVAL(x) ((int)(intptr_t)(void *)*(caddr_t *)(void *)(x))
+#endif
+
+#else
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int    ioctl(int, unsigned long, ...);
+__END_DECLS
+
+#endif
+
+#endif /* !_SYS_IOCCOM_H_ */
diff --git a/newlib/libc/sys/rtems/include/sys/socket.h b/newlib/libc/sys/rtems/include/sys/socket.h
new file mode 100644 (file)
index 0000000..cec6a24
--- /dev/null
@@ -0,0 +1,712 @@
+/*-
+ * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)socket.h    8.4 (Berkeley) 2/21/94
+ * $FreeBSD: head/sys/sys/socket.h 314436 2017-02-28 23:42:47Z imp $
+ */
+
+#ifndef _SYS_SOCKET_H_
+#define        _SYS_SOCKET_H_
+
+#include <sys/cdefs.h>
+#include <sys/_types.h>
+#include <sys/_iovec.h>
+#include <machine/_align.h>
+
+/*
+ * Definitions related to sockets: types, address families, options.
+ */
+
+/*
+ * Data types.
+ */
+#if __BSD_VISIBLE
+#ifndef _GID_T_DECLARED
+typedef        __gid_t         gid_t;
+#define        _GID_T_DECLARED
+#endif
+
+#ifndef _OFF_T_DECLARED
+typedef        __off_t         off_t;
+#define        _OFF_T_DECLARED
+#endif
+
+#ifndef _PID_T_DECLARED
+typedef        __pid_t         pid_t;
+#define        _PID_T_DECLARED
+#endif
+#endif
+
+#ifndef _SA_FAMILY_T_DECLARED
+typedef        __sa_family_t   sa_family_t;
+#define        _SA_FAMILY_T_DECLARED
+#endif
+
+#ifndef _SOCKLEN_T_DECLARED
+typedef        __socklen_t     socklen_t;
+#define        _SOCKLEN_T_DECLARED
+#endif
+#ifndef _SSIZE_T_DECLARED
+typedef        __ssize_t       ssize_t;
+#define        _SSIZE_T_DECLARED
+#endif
+
+#if __BSD_VISIBLE 
+#ifndef _UID_T_DECLARED
+typedef        __uid_t         uid_t;
+#define        _UID_T_DECLARED
+#endif
+#endif
+
+#ifndef _UINT32_T_DECLARED
+typedef        __uint32_t      uint32_t;
+#define        _UINT32_T_DECLARED
+#endif
+
+#ifndef _UINTPTR_T_DECLARED
+typedef        __uintptr_t     uintptr_t;
+#define        _UINTPTR_T_DECLARED
+#endif
+
+/*
+ * Types
+ */
+#define        SOCK_STREAM     1               /* stream socket */
+#define        SOCK_DGRAM      2               /* datagram socket */
+#define        SOCK_RAW        3               /* raw-protocol interface */
+#if __BSD_VISIBLE
+#define        SOCK_RDM        4               /* reliably-delivered message */
+#endif
+#define        SOCK_SEQPACKET  5               /* sequenced packet stream */
+
+#if __BSD_VISIBLE
+/*
+ * Creation flags, OR'ed into socket() and socketpair() type argument.
+ */
+#define        SOCK_CLOEXEC    0x10000000
+#define        SOCK_NONBLOCK   0x20000000
+#endif
+
+/*
+ * Option flags per-socket.
+ */
+#define        SO_DEBUG        0x0001          /* turn on debugging info recording */
+#define        SO_ACCEPTCONN   0x0002          /* socket has had listen() */
+#define        SO_REUSEADDR    0x0004          /* allow local address reuse */
+#define        SO_KEEPALIVE    0x0008          /* keep connections alive */
+#define        SO_DONTROUTE    0x0010          /* just use interface addresses */
+#define        SO_BROADCAST    0x0020          /* permit sending of broadcast msgs */
+#if __BSD_VISIBLE
+#define        SO_USELOOPBACK  0x0040          /* bypass hardware when possible */
+#endif
+#define        SO_LINGER       0x0080          /* linger on close if data present */
+#define        SO_OOBINLINE    0x0100          /* leave received OOB data in line */
+#if __BSD_VISIBLE
+#define        SO_REUSEPORT    0x0200          /* allow local address & port reuse */
+#define        SO_TIMESTAMP    0x0400          /* timestamp received dgram traffic */
+#define        SO_NOSIGPIPE    0x0800          /* no SIGPIPE from EPIPE */
+#define        SO_ACCEPTFILTER 0x1000          /* there is an accept filter */
+#define        SO_BINTIME      0x2000          /* timestamp received dgram traffic */
+#endif
+#define        SO_NO_OFFLOAD   0x4000          /* socket cannot be offloaded */
+#define        SO_NO_DDP       0x8000          /* disable direct data placement */
+
+/*
+ * Additional options, not kept in so_options.
+ */
+#define        SO_SNDBUF       0x1001          /* send buffer size */
+#define        SO_RCVBUF       0x1002          /* receive buffer size */
+#define        SO_SNDLOWAT     0x1003          /* send low-water mark */
+#define        SO_RCVLOWAT     0x1004          /* receive low-water mark */
+#define        SO_SNDTIMEO     0x1005          /* send timeout */
+#define        SO_RCVTIMEO     0x1006          /* receive timeout */
+#define        SO_ERROR        0x1007          /* get error status and clear */
+#define        SO_TYPE         0x1008          /* get socket type */
+#if __BSD_VISIBLE
+#define        SO_LABEL        0x1009          /* socket's MAC label */
+#define        SO_PEERLABEL    0x1010          /* socket's peer's MAC label */
+#define        SO_LISTENQLIMIT 0x1011          /* socket's backlog limit */
+#define        SO_LISTENQLEN   0x1012          /* socket's complete queue length */
+#define        SO_LISTENINCQLEN        0x1013  /* socket's incomplete queue length */
+#define        SO_SETFIB       0x1014          /* use this FIB to route */
+#define        SO_USER_COOKIE  0x1015          /* user cookie (dummynet etc.) */
+#define        SO_PROTOCOL     0x1016          /* get socket protocol (Linux name) */
+#define        SO_PROTOTYPE    SO_PROTOCOL     /* alias for SO_PROTOCOL (SunOS name) */
+#define        SO_TS_CLOCK     0x1017          /* clock type used for SO_TIMESTAMP */
+#define        SO_MAX_PACING_RATE      0x1018  /* socket's max TX pacing rate (Linux name) */
+#endif
+
+#if __BSD_VISIBLE
+#define        SO_TS_REALTIME_MICRO    0       /* microsecond resolution, realtime */
+#define        SO_TS_BINTIME           1       /* sub-nanosecond resolution, realtime */
+#define        SO_TS_REALTIME          2       /* nanosecond resolution, realtime */
+#define        SO_TS_MONOTONIC         3       /* nanosecond resolution, monotonic */
+#define        SO_TS_DEFAULT           SO_TS_REALTIME_MICRO
+#define        SO_TS_CLOCK_MAX         SO_TS_MONOTONIC
+#endif
+
+/*
+ * Space reserved for new socket options added by third-party vendors.
+ * This range applies to all socket option levels.  New socket options
+ * in FreeBSD should always use an option value less than SO_VENDOR.
+ */
+#if __BSD_VISIBLE
+#define        SO_VENDOR       0x80000000
+#endif
+
+/*
+ * Structure used for manipulating linger option.
+ */
+struct linger {
+       int     l_onoff;                /* option on/off */
+       int     l_linger;               /* linger time */
+};
+
+#if __BSD_VISIBLE
+struct accept_filter_arg {
+       char    af_name[16];
+       char    af_arg[256-16];
+};
+#endif
+
+/*
+ * Level number for (get/set)sockopt() to apply to socket itself.
+ */
+#define        SOL_SOCKET      0xffff          /* options for socket level */
+
+/*
+ * Address families.
+ */
+#define        AF_UNSPEC       0               /* unspecified */
+#if __BSD_VISIBLE
+#define        AF_LOCAL        AF_UNIX         /* local to host (pipes, portals) */
+#endif
+#define        AF_UNIX         1               /* standardized name for AF_LOCAL */
+#define        AF_INET         2               /* internetwork: UDP, TCP, etc. */
+#if __BSD_VISIBLE
+#define        AF_IMPLINK      3               /* arpanet imp addresses */
+#define        AF_PUP          4               /* pup protocols: e.g. BSP */
+#define        AF_CHAOS        5               /* mit CHAOS protocols */
+#define        AF_NETBIOS      6               /* SMB protocols */
+#define        AF_ISO          7               /* ISO protocols */
+#define        AF_OSI          AF_ISO
+#define        AF_ECMA         8               /* European computer manufacturers */
+#define        AF_DATAKIT      9               /* datakit protocols */
+#define        AF_CCITT        10              /* CCITT protocols, X.25 etc */
+#define        AF_SNA          11              /* IBM SNA */
+#define AF_DECnet      12              /* DECnet */
+#define AF_DLI         13              /* DEC Direct data link interface */
+#define AF_LAT         14              /* LAT */
+#define        AF_HYLINK       15              /* NSC Hyperchannel */
+#define        AF_APPLETALK    16              /* Apple Talk */
+#define        AF_ROUTE        17              /* Internal Routing Protocol */
+#define        AF_LINK         18              /* Link layer interface */
+#define        pseudo_AF_XTP   19              /* eXpress Transfer Protocol (no AF) */
+#define        AF_COIP         20              /* connection-oriented IP, aka ST II */
+#define        AF_CNT          21              /* Computer Network Technology */
+#define pseudo_AF_RTIP 22              /* Help Identify RTIP packets */
+#define        AF_IPX          23              /* Novell Internet Protocol */
+#define        AF_SIP          24              /* Simple Internet Protocol */
+#define        pseudo_AF_PIP   25              /* Help Identify PIP packets */
+#define        AF_ISDN         26              /* Integrated Services Digital Network*/
+#define        AF_E164         AF_ISDN         /* CCITT E.164 recommendation */
+#define        pseudo_AF_KEY   27              /* Internal key-management function */
+#endif
+#define        AF_INET6        28              /* IPv6 */
+#if __BSD_VISIBLE
+#define        AF_NATM         29              /* native ATM access */
+#define        AF_ATM          30              /* ATM */
+#define pseudo_AF_HDRCMPLT 31          /* Used by BPF to not rewrite headers
+                                        * in interface output routine
+                                        */
+#define        AF_NETGRAPH     32              /* Netgraph sockets */
+#define        AF_SLOW         33              /* 802.3ad slow protocol */
+#define        AF_SCLUSTER     34              /* Sitara cluster protocol */
+#define        AF_ARP          35
+#define        AF_BLUETOOTH    36              /* Bluetooth sockets */
+#define        AF_IEEE80211    37              /* IEEE 802.11 protocol */
+#define        AF_INET_SDP     40              /* OFED Socket Direct Protocol ipv4 */
+#define        AF_INET6_SDP    42              /* OFED Socket Direct Protocol ipv6 */
+#define        AF_MAX          42
+/*
+ * When allocating a new AF_ constant, please only allocate
+ * even numbered constants for FreeBSD until 134 as odd numbered AF_
+ * constants 39-133 are now reserved for vendors.
+ */
+#define AF_VENDOR00 39
+#define AF_VENDOR01 41
+#define AF_VENDOR02 43
+#define AF_VENDOR03 45
+#define AF_VENDOR04 47
+#define AF_VENDOR05 49
+#define AF_VENDOR06 51
+#define AF_VENDOR07 53
+#define AF_VENDOR08 55
+#define AF_VENDOR09 57
+#define AF_VENDOR10 59
+#define AF_VENDOR11 61
+#define AF_VENDOR12 63
+#define AF_VENDOR13 65
+#define AF_VENDOR14 67
+#define AF_VENDOR15 69
+#define AF_VENDOR16 71
+#define AF_VENDOR17 73
+#define AF_VENDOR18 75
+#define AF_VENDOR19 77
+#define AF_VENDOR20 79
+#define AF_VENDOR21 81
+#define AF_VENDOR22 83
+#define AF_VENDOR23 85
+#define AF_VENDOR24 87
+#define AF_VENDOR25 89
+#define AF_VENDOR26 91
+#define AF_VENDOR27 93
+#define AF_VENDOR28 95
+#define AF_VENDOR29 97
+#define AF_VENDOR30 99
+#define AF_VENDOR31 101
+#define AF_VENDOR32 103
+#define AF_VENDOR33 105
+#define AF_VENDOR34 107
+#define AF_VENDOR35 109
+#define AF_VENDOR36 111
+#define AF_VENDOR37 113
+#define AF_VENDOR38 115
+#define AF_VENDOR39 117
+#define AF_VENDOR40 119
+#define AF_VENDOR41 121
+#define AF_VENDOR42 123
+#define AF_VENDOR43 125
+#define AF_VENDOR44 127
+#define AF_VENDOR45 129
+#define AF_VENDOR46 131
+#define AF_VENDOR47 133
+#endif
+
+/*
+ * Structure used by kernel to store most
+ * addresses.
+ */
+struct sockaddr {
+       unsigned char   sa_len;         /* total length */
+       sa_family_t     sa_family;      /* address family */
+       char            sa_data[14];    /* actually longer; address value */
+};
+#if __BSD_VISIBLE
+#define        SOCK_MAXADDRLEN 255             /* longest possible addresses */
+
+/*
+ * Structure used by kernel to pass protocol
+ * information in raw sockets.
+ */
+struct sockproto {
+       unsigned short  sp_family;              /* address family */
+       unsigned short  sp_protocol;            /* protocol */
+};
+#endif
+
+#include <sys/_sockaddr_storage.h>
+
+#if __BSD_VISIBLE
+/*
+ * Protocol families, same as address families for now.
+ */
+#define        PF_UNSPEC       AF_UNSPEC
+#define        PF_LOCAL        AF_LOCAL
+#define        PF_UNIX         PF_LOCAL        /* backward compatibility */
+#define        PF_INET         AF_INET
+#define        PF_IMPLINK      AF_IMPLINK
+#define        PF_PUP          AF_PUP
+#define        PF_CHAOS        AF_CHAOS
+#define        PF_NETBIOS      AF_NETBIOS
+#define        PF_ISO          AF_ISO
+#define        PF_OSI          AF_ISO
+#define        PF_ECMA         AF_ECMA
+#define        PF_DATAKIT      AF_DATAKIT
+#define        PF_CCITT        AF_CCITT
+#define        PF_SNA          AF_SNA
+#define PF_DECnet      AF_DECnet
+#define PF_DLI         AF_DLI
+#define PF_LAT         AF_LAT
+#define        PF_HYLINK       AF_HYLINK
+#define        PF_APPLETALK    AF_APPLETALK
+#define        PF_ROUTE        AF_ROUTE
+#define        PF_LINK         AF_LINK
+#define        PF_XTP          pseudo_AF_XTP   /* really just proto family, no AF */
+#define        PF_COIP         AF_COIP
+#define        PF_CNT          AF_CNT
+#define        PF_SIP          AF_SIP
+#define        PF_IPX          AF_IPX
+#define PF_RTIP                pseudo_AF_RTIP  /* same format as AF_INET */
+#define PF_PIP         pseudo_AF_PIP
+#define        PF_ISDN         AF_ISDN
+#define        PF_KEY          pseudo_AF_KEY
+#define        PF_INET6        AF_INET6
+#define        PF_NATM         AF_NATM
+#define        PF_ATM          AF_ATM
+#define        PF_NETGRAPH     AF_NETGRAPH
+#define        PF_SLOW         AF_SLOW
+#define PF_SCLUSTER    AF_SCLUSTER
+#define        PF_ARP          AF_ARP
+#define        PF_BLUETOOTH    AF_BLUETOOTH
+#define        PF_IEEE80211    AF_IEEE80211
+#define        PF_INET_SDP     AF_INET_SDP
+#define        PF_INET6_SDP    AF_INET6_SDP
+
+#define        PF_MAX          AF_MAX
+
+/*
+ * Definitions for network related sysctl, CTL_NET.
+ *
+ * Second level is protocol family.
+ * Third level is protocol number.
+ *
+ * Further levels are defined by the individual families.
+ */
+
+/*
+ * PF_ROUTE - Routing table
+ *
+ * Three additional levels are defined:
+ *     Fourth: address family, 0 is wildcard
+ *     Fifth: type of info, defined below
+ *     Sixth: flag(s) to mask with for NET_RT_FLAGS
+ */
+#define NET_RT_DUMP    1               /* dump; may limit to a.f. */
+#define NET_RT_FLAGS   2               /* by flags, e.g. RESOLVING */
+#define NET_RT_IFLIST  3               /* survey interface list */
+#define        NET_RT_IFMALIST 4               /* return multicast address list */
+#define        NET_RT_IFLISTL  5               /* Survey interface list, using 'l'en
+                                        * versions of msghdr structs. */
+#endif /* __BSD_VISIBLE */
+
+/*
+ * Maximum queue length specifiable by listen.
+ */
+#define        SOMAXCONN       128
+
+/*
+ * Message header for recvmsg and sendmsg calls.
+ * Used value-result for recvmsg, value only for sendmsg.
+ */
+struct msghdr {
+       void            *msg_name;              /* optional address */
+       socklen_t        msg_namelen;           /* size of address */
+       struct iovec    *msg_iov;               /* scatter/gather array */
+       int              msg_iovlen;            /* # elements in msg_iov */
+       void            *msg_control;           /* ancillary data, see below */
+       socklen_t        msg_controllen;        /* ancillary data buffer len */
+       int              msg_flags;             /* flags on received message */
+};
+
+#define        MSG_OOB          0x00000001     /* process out-of-band data */
+#define        MSG_PEEK         0x00000002     /* peek at incoming message */
+#define        MSG_DONTROUTE    0x00000004     /* send without using routing tables */
+#define        MSG_EOR          0x00000008     /* data completes record */
+#define        MSG_TRUNC        0x00000010     /* data discarded before delivery */
+#define        MSG_CTRUNC       0x00000020     /* control data lost before delivery */
+#define        MSG_WAITALL      0x00000040     /* wait for full request or error */
+#if __BSD_VISIBLE
+#define        MSG_DONTWAIT     0x00000080     /* this message should be nonblocking */
+#define        MSG_EOF          0x00000100     /* data completes connection */
+/*                      0x00000200        unused */
+/*                      0x00000400        unused */
+/*                      0x00000800        unused */
+/*                      0x00001000        unused */
+#define        MSG_NOTIFICATION 0x00002000     /* SCTP notification */
+#define        MSG_NBIO         0x00004000     /* FIONBIO mode, used by fifofs */
+#define        MSG_COMPAT       0x00008000             /* used in sendit() */
+#endif
+#ifdef _KERNEL
+#define        MSG_SOCALLBCK    0x00010000     /* for use by socket callbacks - soreceive (TCP) */
+#endif
+#if __POSIX_VISIBLE >= 200809
+#define        MSG_NOSIGNAL     0x00020000     /* do not generate SIGPIPE on EOF */
+#endif
+#if __BSD_VISIBLE
+#define        MSG_CMSG_CLOEXEC 0x00040000     /* make received fds close-on-exec */
+#define        MSG_WAITFORONE   0x00080000     /* for recvmmsg() */
+#endif
+#ifdef _KERNEL
+#define        MSG_MORETOCOME   0x00100000     /* additional data pending */
+#endif
+
+/*
+ * Header for ancillary data objects in msg_control buffer.
+ * Used for additional information with/about a datagram
+ * not expressible by flags.  The format is a sequence
+ * of message elements headed by cmsghdr structures.
+ */
+struct cmsghdr {
+       socklen_t       cmsg_len;               /* data byte count, including hdr */
+       int             cmsg_level;             /* originating protocol */
+       int             cmsg_type;              /* protocol-specific type */
+/* followed by u_char  cmsg_data[]; */
+};
+
+#if __BSD_VISIBLE
+/*
+ * While we may have more groups than this, the cmsgcred struct must
+ * be able to fit in an mbuf and we have historically supported a
+ * maximum of 16 groups.
+*/
+#define CMGROUP_MAX 16
+
+/*
+ * Credentials structure, used to verify the identity of a peer
+ * process that has sent us a message. This is allocated by the
+ * peer process but filled in by the kernel. This prevents the
+ * peer from lying about its identity. (Note that cmcred_groups[0]
+ * is the effective GID.)
+ */
+struct cmsgcred {
+       pid_t   cmcred_pid;             /* PID of sending process */
+       uid_t   cmcred_uid;             /* real UID of sending process */
+       uid_t   cmcred_euid;            /* effective UID of sending process */
+       gid_t   cmcred_gid;             /* real GID of sending process */
+       short   cmcred_ngroups;         /* number or groups */
+       gid_t   cmcred_groups[CMGROUP_MAX];     /* groups */
+};
+
+/*
+ * Socket credentials.
+ */
+struct sockcred {
+       uid_t   sc_uid;                 /* real user id */
+       uid_t   sc_euid;                /* effective user id */
+       gid_t   sc_gid;                 /* real group id */
+       gid_t   sc_egid;                /* effective group id */
+       int     sc_ngroups;             /* number of supplemental groups */
+       gid_t   sc_groups[1];           /* variable length */
+};
+
+/*
+ * Compute size of a sockcred structure with groups.
+ */
+#define        SOCKCREDSIZE(ngrps) \
+       (sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1)))
+
+#endif /* __BSD_VISIBLE */
+
+/* given pointer to struct cmsghdr, return pointer to data */
+#define        CMSG_DATA(cmsg)         ((unsigned char *)(cmsg) + \
+                                _ALIGN(sizeof(struct cmsghdr)))
+
+/* given pointer to struct cmsghdr, return pointer to next cmsghdr */
+#define        CMSG_NXTHDR(mhdr, cmsg) \
+       ((char *)(cmsg) == (char *)0 ? CMSG_FIRSTHDR(mhdr) : \
+           ((char *)(cmsg) + _ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len) + \
+         _ALIGN(sizeof(struct cmsghdr)) > \
+           (char *)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \
+           (struct cmsghdr *)0 : \
+           (struct cmsghdr *)(void *)((char *)(cmsg) + \
+           _ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len)))
+
+/*
+ * RFC 2292 requires to check msg_controllen, in case that the kernel returns
+ * an empty list for some reasons.
+ */
+#define        CMSG_FIRSTHDR(mhdr) \
+       ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
+        (struct cmsghdr *)(mhdr)->msg_control : \
+        (struct cmsghdr *)0)
+
+#if __BSD_VISIBLE
+/* RFC 2292 additions */
+#define        CMSG_SPACE(l)           (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l))
+#define        CMSG_LEN(l)             (_ALIGN(sizeof(struct cmsghdr)) + (l))
+#endif
+
+#ifdef _KERNEL
+#define        CMSG_ALIGN(n)   _ALIGN(n)
+#endif
+
+/* "Socket"-level control message types: */
+#define        SCM_RIGHTS      0x01            /* access rights (array of int) */
+#if __BSD_VISIBLE
+#define        SCM_TIMESTAMP   0x02            /* timestamp (struct timeval) */
+#define        SCM_CREDS       0x03            /* process creds (struct cmsgcred) */
+#define        SCM_BINTIME     0x04            /* timestamp (struct bintime) */
+#define        SCM_REALTIME    0x05            /* timestamp (struct timespec) */
+#define        SCM_MONOTONIC   0x06            /* timestamp (struct timespec) */
+#endif
+
+#if __BSD_VISIBLE
+/*
+ * 4.3 compat sockaddr, move to compat file later
+ */
+struct osockaddr {
+       unsigned short sa_family;       /* address family */
+       char    sa_data[14];            /* up to 14 bytes of direct address */
+};
+
+/*
+ * 4.3-compat message header (move to compat file later).
+ */
+struct omsghdr {
+       char    *msg_name;              /* optional address */
+       int     msg_namelen;            /* size of address */
+       struct  iovec *msg_iov;         /* scatter/gather array */
+       int     msg_iovlen;             /* # elements in msg_iov */
+       char    *msg_accrights;         /* access rights sent/received */
+       int     msg_accrightslen;
+};
+#endif
+
+/*
+ * howto arguments for shutdown(2), specified by Posix.1g.
+ */
+#define        SHUT_RD         0               /* shut down the reading side */
+#define        SHUT_WR         1               /* shut down the writing side */
+#define        SHUT_RDWR       2               /* shut down both sides */
+
+#if __BSD_VISIBLE
+/* for SCTP */
+/* we cheat and use the SHUT_XX defines for these */
+#define PRU_FLUSH_RD     SHUT_RD
+#define PRU_FLUSH_WR     SHUT_WR
+#define PRU_FLUSH_RDWR   SHUT_RDWR
+#endif
+
+
+#if __BSD_VISIBLE
+/*
+ * sendfile(2) header/trailer struct
+ */
+struct sf_hdtr {
+       struct iovec *headers;  /* pointer to an array of header struct iovec's */
+       int hdr_cnt;            /* number of header iovec's */
+       struct iovec *trailers; /* pointer to an array of trailer struct iovec's */
+       int trl_cnt;            /* number of trailer iovec's */
+};
+
+/*
+ * Sendfile-specific flag(s)
+ */
+#define        SF_NODISKIO     0x00000001
+#define        SF_MNOWAIT      0x00000002      /* obsolete */
+#define        SF_SYNC         0x00000004
+#define        SF_USER_READAHEAD       0x00000008
+#define        SF_NOCACHE      0x00000010
+#define        SF_FLAGS(rh, flags)     (((rh) << 16) | (flags))
+
+#ifdef _KERNEL
+#define        SF_READAHEAD(flags)     ((flags) >> 16)
+#endif /* _KERNEL */
+
+/*
+ * Sendmmsg/recvmmsg specific structure(s)
+ */
+struct mmsghdr {
+       struct msghdr   msg_hdr;                /* message header */
+       ssize_t         msg_len;                /* message length */
+};
+#endif /* __BSD_VISIBLE */
+
+#ifndef        _KERNEL
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int    accept(int, struct sockaddr * __restrict, socklen_t * __restrict);
+int    bind(int, const struct sockaddr *, socklen_t);
+int    connect(int, const struct sockaddr *, socklen_t);
+#if __BSD_VISIBLE
+int    accept4(int, struct sockaddr * __restrict, socklen_t * __restrict, int);
+int    bindat(int, int, const struct sockaddr *, socklen_t);
+int    connectat(int, int, const struct sockaddr *, socklen_t);
+#endif
+int    getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict);
+int    getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict);
+int    getsockopt(int, int, int, void * __restrict, socklen_t * __restrict);
+int    listen(int, int);
+ssize_t        recv(int, void *, size_t, int);
+ssize_t        recvfrom(int, void *, size_t, int, struct sockaddr * __restrict, socklen_t * __restrict);
+ssize_t        recvmsg(int, struct msghdr *, int);
+#if __BSD_VISIBLE
+struct timespec;
+ssize_t        recvmmsg(int, struct mmsghdr * __restrict, size_t, int,
+    const struct timespec * __restrict);
+#endif
+ssize_t        send(int, const void *, size_t, int);
+ssize_t        sendto(int, const void *,
+           size_t, int, const struct sockaddr *, socklen_t);
+ssize_t        sendmsg(int, const struct msghdr *, int);
+#if __BSD_VISIBLE
+int    sendfile(int, int, off_t, size_t, struct sf_hdtr *, off_t *, int);
+ssize_t        sendmmsg(int, struct mmsghdr * __restrict, size_t, int);
+int    setfib(int);
+#endif
+int    setsockopt(int, int, int, const void *, socklen_t);
+int    shutdown(int, int);
+int    sockatmark(int);
+int    socket(int, int, int);
+int    socketpair(int, int, int, int *);
+__END_DECLS
+
+#endif /* !_KERNEL */
+
+#ifdef _KERNEL
+struct socket;
+
+struct tcpcb *so_sototcpcb(struct socket *so);
+struct inpcb *so_sotoinpcb(struct socket *so);
+struct sockbuf *so_sockbuf_snd(struct socket *);
+struct sockbuf *so_sockbuf_rcv(struct socket *);
+
+int so_state_get(const struct socket *);
+void so_state_set(struct socket *, int);
+
+int so_options_get(const struct socket *);
+void so_options_set(struct socket *, int);
+
+int so_error_get(const struct socket *);
+void so_error_set(struct socket *, int);
+
+int so_linger_get(const struct socket *);
+void so_linger_set(struct socket *, int);
+
+struct protosw *so_protosw_get(const struct socket *);
+void so_protosw_set(struct socket *, struct protosw *);
+
+void so_sorwakeup_locked(struct socket *so);
+void so_sowwakeup_locked(struct socket *so);
+
+void so_sorwakeup(struct socket *so);
+void so_sowwakeup(struct socket *so);
+
+void so_lock(struct socket *so);
+void so_unlock(struct socket *so);
+
+void so_listeners_apply_all(struct socket *so, void (*func)(struct socket *, void *), void *arg);
+
+#endif
+
+
+#endif /* !_SYS_SOCKET_H_ */
diff --git a/newlib/libc/sys/rtems/include/sys/syslog.h b/newlib/libc/sys/rtems/include/sys/syslog.h
new file mode 100644 (file)
index 0000000..8a3738d
--- /dev/null
@@ -0,0 +1,203 @@
+/*-
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)syslog.h    8.1 (Berkeley) 6/2/93
+ * $FreeBSD: head/sys/sys/syslog.h 314436 2017-02-28 23:42:47Z imp $
+ */
+
+#ifndef _SYS_SYSLOG_H_
+#define _SYS_SYSLOG_H_
+
+#define        _PATH_LOG       "/var/run/log"
+#define        _PATH_LOG_PRIV  "/var/run/logpriv"
+#define        _PATH_OLDLOG    "/dev/log"      /* backward compatibility */
+
+/*
+ * priorities/facilities are encoded into a single 32-bit quantity, where the
+ * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
+ * (0-big number).  Both the priorities and the facilities map roughly
+ * one-to-one to strings in the syslogd(8) source code.  This mapping is
+ * included in this file.
+ *
+ * priorities (these are ordered)
+ */
+#define        LOG_EMERG       0       /* system is unusable */
+#define        LOG_ALERT       1       /* action must be taken immediately */
+#define        LOG_CRIT        2       /* critical conditions */
+#define        LOG_ERR         3       /* error conditions */
+#define        LOG_WARNING     4       /* warning conditions */
+#define        LOG_NOTICE      5       /* normal but significant condition */
+#define        LOG_INFO        6       /* informational */
+#define        LOG_DEBUG       7       /* debug-level messages */
+
+#define        LOG_PRIMASK     0x07    /* mask to extract priority part (internal) */
+                               /* extract priority */
+#define        LOG_PRI(p)      ((p) & LOG_PRIMASK)
+#define        LOG_MAKEPRI(fac, pri)   ((fac) | (pri))
+
+#ifdef SYSLOG_NAMES
+#define        INTERNAL_NOPRI  0x10    /* the "no priority" priority */
+                               /* mark "facility" */
+#define        INTERNAL_MARK   LOG_MAKEPRI((LOG_NFACILITIES<<3), 0)
+typedef struct _code {
+       const char      *c_name;
+       int             c_val;
+} CODE;
+
+static const CODE prioritynames[] = {
+       { "alert",      LOG_ALERT,      },
+       { "crit",       LOG_CRIT,       },
+       { "debug",      LOG_DEBUG,      },
+       { "emerg",      LOG_EMERG,      },
+       { "err",        LOG_ERR,        },
+       { "error",      LOG_ERR,        },      /* DEPRECATED */
+       { "info",       LOG_INFO,       },
+       { "none",       INTERNAL_NOPRI, },      /* INTERNAL */
+       { "notice",     LOG_NOTICE,     },
+       { "panic",      LOG_EMERG,      },      /* DEPRECATED */
+       { "warn",       LOG_WARNING,    },      /* DEPRECATED */
+       { "warning",    LOG_WARNING,    },
+       { NULL,         -1,             }
+};
+#endif
+
+/* facility codes */
+#define        LOG_KERN        (0<<3)  /* kernel messages */
+#define        LOG_USER        (1<<3)  /* random user-level messages */
+#define        LOG_MAIL        (2<<3)  /* mail system */
+#define        LOG_DAEMON      (3<<3)  /* system daemons */
+#define        LOG_AUTH        (4<<3)  /* authorization messages */
+#define        LOG_SYSLOG      (5<<3)  /* messages generated internally by syslogd */
+#define        LOG_LPR         (6<<3)  /* line printer subsystem */
+#define        LOG_NEWS        (7<<3)  /* network news subsystem */
+#define        LOG_UUCP        (8<<3)  /* UUCP subsystem */
+#define        LOG_CRON        (9<<3)  /* clock daemon */
+#define        LOG_AUTHPRIV    (10<<3) /* authorization messages (private) */
+                               /* Facility #10 clashes in DEC UNIX, where */
+                               /* it's defined as LOG_MEGASAFE for AdvFS  */
+                               /* event logging.                          */
+#define        LOG_FTP         (11<<3) /* ftp daemon */
+#define        LOG_NTP         (12<<3) /* NTP subsystem */
+#define        LOG_SECURITY    (13<<3) /* security subsystems (firewalling, etc.) */
+#define        LOG_CONSOLE     (14<<3) /* /dev/console output */
+
+       /* other codes through 15 reserved for system use */
+#define        LOG_LOCAL0      (16<<3) /* reserved for local use */
+#define        LOG_LOCAL1      (17<<3) /* reserved for local use */
+#define        LOG_LOCAL2      (18<<3) /* reserved for local use */
+#define        LOG_LOCAL3      (19<<3) /* reserved for local use */
+#define        LOG_LOCAL4      (20<<3) /* reserved for local use */
+#define        LOG_LOCAL5      (21<<3) /* reserved for local use */
+#define        LOG_LOCAL6      (22<<3) /* reserved for local use */
+#define        LOG_LOCAL7      (23<<3) /* reserved for local use */
+
+#define        LOG_NFACILITIES 24      /* current number of facilities */
+#define        LOG_FACMASK     0x03f8  /* mask to extract facility part */
+                               /* facility of pri */
+#define        LOG_FAC(p)      (((p) & LOG_FACMASK) >> 3)
+
+#ifdef SYSLOG_NAMES
+static const CODE facilitynames[] = {
+       { "auth",       LOG_AUTH,       },
+       { "authpriv",   LOG_AUTHPRIV,   },
+       { "console",    LOG_CONSOLE,    },
+       { "cron",       LOG_CRON,       },
+       { "daemon",     LOG_DAEMON,     },
+       { "ftp",        LOG_FTP,        },
+       { "kern",       LOG_KERN,       },
+       { "lpr",        LOG_LPR,        },
+       { "mail",       LOG_MAIL,       },
+       { "mark",       INTERNAL_MARK,  },      /* INTERNAL */
+       { "news",       LOG_NEWS,       },
+       { "ntp",        LOG_NTP,        },
+       { "security",   LOG_SECURITY,   },
+       { "syslog",     LOG_SYSLOG,     },
+       { "user",       LOG_USER,       },
+       { "uucp",       LOG_UUCP,       },
+       { "local0",     LOG_LOCAL0,     },
+       { "local1",     LOG_LOCAL1,     },
+       { "local2",     LOG_LOCAL2,     },
+       { "local3",     LOG_LOCAL3,     },
+       { "local4",     LOG_LOCAL4,     },
+       { "local5",     LOG_LOCAL5,     },
+       { "local6",     LOG_LOCAL6,     },
+       { "local7",     LOG_LOCAL7,     },
+       { NULL,         -1,             }
+};
+#endif
+
+#ifdef _KERNEL
+#define        LOG_PRINTF      -1      /* pseudo-priority to indicate use of printf */
+#endif
+
+/*
+ * arguments to setlogmask.
+ */
+#define        LOG_MASK(pri)   (1 << (pri))            /* mask for one priority */
+#define        LOG_UPTO(pri)   ((1 << ((pri)+1)) - 1)  /* all priorities through pri */
+
+/*
+ * Option flags for openlog.
+ *
+ * LOG_ODELAY no longer does anything.
+ * LOG_NDELAY is the inverse of what it used to be.
+ */
+#define        LOG_PID         0x01    /* log the pid with each message */
+#define        LOG_CONS        0x02    /* log on the console if errors in sending */
+#define        LOG_ODELAY      0x04    /* delay open until first syslog() (default) */
+#define        LOG_NDELAY      0x08    /* don't delay open */
+#define        LOG_NOWAIT      0x10    /* don't wait for console forks: DEPRECATED */
+#define        LOG_PERROR      0x20    /* log to stderr as well */
+
+#ifdef _KERNEL
+
+#else /* not _KERNEL */
+
+/*
+ * Don't use va_list in the vsyslog() prototype.   Va_list is typedef'd in two
+ * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one
+ * of them here we may collide with the utility's includes.  It's unreasonable
+ * for utilities to have to include one of them to include syslog.h, so we get
+ * __va_list from <sys/_types.h> and use it.
+ */
+#include <sys/cdefs.h>
+#include <sys/_types.h>
+
+__BEGIN_DECLS
+void   closelog(void);
+void   openlog(const char *, int, int);
+int    setlogmask(int);
+void   syslog(int, const char *, ...) __printflike(2, 3);
+#if __BSD_VISIBLE
+void   vsyslog(int, const char *, __va_list) __printflike(2, 0);
+#endif
+__END_DECLS
+
+#endif /* !_KERNEL */
+
+#endif
diff --git a/newlib/libc/sys/rtems/include/sys/ttycom.h b/newlib/libc/sys/rtems/include/sys/ttycom.h
new file mode 100644 (file)
index 0000000..dec8620
--- /dev/null
@@ -0,0 +1,145 @@
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993, 1994
+ *     The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)ttycom.h    8.1 (Berkeley) 3/28/94
+ * $FreeBSD: head/sys/sys/ttycom.h 314436 2017-02-28 23:42:47Z imp $
+ */
+
+#ifndef        _SYS_TTYCOM_H_
+#define        _SYS_TTYCOM_H_
+
+#include <sys/ioccom.h>
+
+/*
+ * Tty ioctl's except for those supported only for backwards compatibility
+ * with the old tty driver.
+ */
+
+/*
+ * Window/terminal size structure.  This information is stored by the kernel
+ * in order to provide a consistent interface, but is not used by the kernel.
+ */
+struct winsize {
+       unsigned short  ws_row;         /* rows, in characters */
+       unsigned short  ws_col;         /* columns, in characters */
+       unsigned short  ws_xpixel;      /* horizontal size, pixels */
+       unsigned short  ws_ypixel;      /* vertical size, pixels */
+};
+
+                                               /* 0-2 compat */
+                                               /* 3-7 unused */
+                                               /* 8-10 compat */
+                                               /* 11-12 unused */
+#define        TIOCEXCL         _IO('t', 13)           /* set exclusive use of tty */
+#define        TIOCNXCL         _IO('t', 14)           /* reset exclusive use of tty */
+#define        TIOCGPTN        _IOR('t', 15, int)      /* Get pts number. */
+#define        TIOCFLUSH       _IOW('t', 16, int)      /* flush buffers */
+                                               /* 17-18 compat */
+#define        TIOCGETA        _IOR('t', 19, struct termios) /* get termios struct */
+#define        TIOCSETA        _IOW('t', 20, struct termios) /* set termios struct */
+#define        TIOCSETAW       _IOW('t', 21, struct termios) /* drain output, set */
+#define        TIOCSETAF       _IOW('t', 22, struct termios) /* drn out, fls in, set */
+                                               /* 23-25 unused */
+#define        TIOCGETD        _IOR('t', 26, int)      /* get line discipline */
+#define        TIOCSETD        _IOW('t', 27, int)      /* set line discipline */
+#define        TIOCPTMASTER     _IO('t', 28)           /* pts master validation */
+                                               /* 29-85 unused */
+#define        TIOCGDRAINWAIT  _IOR('t', 86, int)      /* get ttywait timeout */
+#define        TIOCSDRAINWAIT  _IOW('t', 87, int)      /* set ttywait timeout */
+                                               /* 88 unused */
+                                               /* 89-91 conflicts: tun and tap */
+#define        TIOCTIMESTAMP   _IOR('t', 89, struct timeval)   /* enable/get timestamp
+                                                * of last input event */
+#define        TIOCMGDTRWAIT   _IOR('t', 90, int)      /* modem: get wait on close */
+#define        TIOCMSDTRWAIT   _IOW('t', 91, int)      /* modem: set wait on close */
+                                               /* 92-93 tun and tap */
+                                               /* 94-97 conflicts: tun and tap */
+#define        TIOCDRAIN        _IO('t', 94)           /* wait till output drained */
+#define        TIOCSIG         _IOWINT('t', 95)        /* pty: generate signal */
+#define        TIOCEXT         _IOW('t', 96, int)      /* pty: external processing */
+#define        TIOCSCTTY        _IO('t', 97)           /* become controlling tty */
+#define        TIOCCONS        _IOW('t', 98, int)      /* become virtual console */
+#define        TIOCGSID        _IOR('t', 99, int)      /* get session id */
+                                               /* 100 unused */
+#define        TIOCSTAT         _IO('t', 101)          /* simulate ^T status message */
+#define        TIOCUCNTL       _IOW('t', 102, int)     /* pty: set/clr usr cntl mode */
+#define                UIOCCMD(n)      _IO('u', n)     /* usr cntl op "n" */
+#define        TIOCSWINSZ      _IOW('t', 103, struct winsize)  /* set window size */
+#define        TIOCGWINSZ      _IOR('t', 104, struct winsize)  /* get window size */
+                                               /* 105 unused */
+#define        TIOCMGET        _IOR('t', 106, int)     /* get all modem bits */
+#define                TIOCM_LE        0001            /* line enable */
+#define                TIOCM_DTR       0002            /* data terminal ready */
+#define                TIOCM_RTS       0004            /* request to send */
+#define                TIOCM_ST        0010            /* secondary transmit */
+#define                TIOCM_SR        0020            /* secondary receive */
+#define                TIOCM_CTS       0040            /* clear to send */
+#define                TIOCM_DCD       0100            /* data carrier detect */
+#define                TIOCM_RI        0200            /* ring indicate */
+#define                TIOCM_DSR       0400            /* data set ready */
+#define                TIOCM_CD        TIOCM_DCD
+#define                TIOCM_CAR       TIOCM_DCD
+#define                TIOCM_RNG       TIOCM_RI
+#define        TIOCMBIC        _IOW('t', 107, int)     /* bic modem bits */
+#define        TIOCMBIS        _IOW('t', 108, int)     /* bis modem bits */
+#define        TIOCMSET        _IOW('t', 109, int)     /* set all modem bits */
+#define        TIOCSTART        _IO('t', 110)          /* start output, like ^Q */
+#define        TIOCSTOP         _IO('t', 111)          /* stop output, like ^S */
+#define        TIOCPKT         _IOW('t', 112, int)     /* pty: set/clear packet mode */
+#define                TIOCPKT_DATA            0x00    /* data packet */
+#define                TIOCPKT_FLUSHREAD       0x01    /* flush packet */
+#define                TIOCPKT_FLUSHWRITE      0x02    /* flush packet */
+#define                TIOCPKT_STOP            0x04    /* stop output */
+#define                TIOCPKT_START           0x08    /* start output */
+#define                TIOCPKT_NOSTOP          0x10    /* no more ^S, ^Q */
+#define                TIOCPKT_DOSTOP          0x20    /* now do ^S ^Q */
+#define                TIOCPKT_IOCTL           0x40    /* state change of pty driver */
+#define        TIOCNOTTY        _IO('t', 113)          /* void tty association */
+#define        TIOCSTI         _IOW('t', 114, char)    /* simulate terminal input */
+#define        TIOCOUTQ        _IOR('t', 115, int)     /* output queue size */
+                                               /* 116-117 compat */
+#define        TIOCSPGRP       _IOW('t', 118, int)     /* set pgrp of tty */
+#define        TIOCGPGRP       _IOR('t', 119, int)     /* get pgrp of tty */
+#define        TIOCCDTR         _IO('t', 120)          /* clear data terminal ready */
+#define        TIOCSDTR         _IO('t', 121)          /* set data terminal ready */
+#define        TIOCCBRK         _IO('t', 122)          /* clear break bit */
+#define        TIOCSBRK         _IO('t', 123)          /* set break bit */
+                                               /* 124-127 compat */
+
+#define        TTYDISC         0               /* termios tty line discipline */
+#define        SLIPDISC        4               /* serial IP discipline */
+#define        PPPDISC         5               /* PPP discipline */
+#define        NETGRAPHDISC    6               /* Netgraph tty node discipline */
+#define        H4DISC          7               /* Netgraph Bluetooth H4 discipline */
+
+#endif /* !_SYS_TTYCOM_H_ */
diff --git a/newlib/libc/sys/rtems/include/sys/ttydefaults.h b/newlib/libc/sys/rtems/include/sys/ttydefaults.h
new file mode 100644 (file)
index 0000000..29464d0
--- /dev/null
@@ -0,0 +1,111 @@
+/*-
+ * Copyright (c) 1982, 1986, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)ttydefaults.h       8.4 (Berkeley) 1/21/94
+ * $FreeBSD: head/sys/sys/ttydefaults.h 314436 2017-02-28 23:42:47Z imp $
+ */
+
+/*
+ * System wide defaults for terminal state.
+ */
+#ifndef _SYS_TTYDEFAULTS_H_
+#define        _SYS_TTYDEFAULTS_H_
+
+/*
+ * Defaults on "first" open.
+ */
+#define        TTYDEF_IFLAG    (BRKINT | ICRNL | IMAXBEL | IXON | IXANY)
+#define        TTYDEF_OFLAG    (OPOST | ONLCR)
+#define        TTYDEF_LFLAG_NOECHO (ICANON | ISIG | IEXTEN)
+#define        TTYDEF_LFLAG_ECHO (TTYDEF_LFLAG_NOECHO \
+       | ECHO | ECHOE | ECHOKE | ECHOCTL)
+#define        TTYDEF_LFLAG TTYDEF_LFLAG_ECHO
+#define        TTYDEF_CFLAG    (CREAD | CS8 | HUPCL)
+#define        TTYDEF_SPEED    (B9600)
+
+/*
+ * Control Character Defaults
+ */
+/*
+ * XXX: A lot of code uses lowercase characters, but control-character
+ * conversion is actually only valid when applied to uppercase
+ * characters. We just treat lowercase characters as if they were
+ * inserted as uppercase.
+ */
+#define        CTRL(x) ((x) >= 'a' && (x) <= 'z' ? \
+       ((x) - 'a' + 1) : (((x) - 'A' + 1) & 0x7f))
+#define        CEOF            CTRL('D')
+#define        CEOL            0xff            /* XXX avoid _POSIX_VDISABLE */
+#define        CERASE          CTRL('?')
+#define        CERASE2         CTRL('H')
+#define        CINTR           CTRL('C')
+#define        CSTATUS         CTRL('T')
+#define        CKILL           CTRL('U')
+#define        CMIN            1
+#define        CQUIT           CTRL('\\')
+#define        CSUSP           CTRL('Z')
+#define        CTIME           0
+#define        CDSUSP          CTRL('Y')
+#define        CSTART          CTRL('Q')
+#define        CSTOP           CTRL('S')
+#define        CLNEXT          CTRL('V')
+#define        CDISCARD        CTRL('O')
+#define        CWERASE         CTRL('W')
+#define        CREPRINT        CTRL('R')
+#define        CEOT            CEOF
+/* compat */
+#define        CBRK            CEOL
+#define        CRPRNT          CREPRINT
+#define        CFLUSH          CDISCARD
+
+/* PROTECTED INCLUSION ENDS HERE */
+#endif /* !_SYS_TTYDEFAULTS_H_ */
+
+/*
+ * #define TTYDEFCHARS to include an array of default control characters.
+ */
+#ifdef TTYDEFCHARS
+
+#include <sys/cdefs.h>
+#include <sys/_termios.h>
+
+static const cc_t ttydefchars[] = {
+       CEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT, CERASE2, CINTR,
+       CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT, CDISCARD, CMIN, CTIME,
+       CSTATUS, _POSIX_VDISABLE
+};
+_Static_assert(sizeof(ttydefchars) / sizeof(cc_t) == NCCS,
+    "Size of ttydefchars does not match NCCS");
+
+#undef TTYDEFCHARS
+#endif /* TTYDEFCHARS */
diff --git a/newlib/libc/sys/rtems/include/sys/uio.h b/newlib/libc/sys/rtems/include/sys/uio.h
new file mode 100644 (file)
index 0000000..a01492a
--- /dev/null
@@ -0,0 +1,126 @@
+/*-
+ * Copyright (c) 1982, 1986, 1993, 1994
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)uio.h       8.5 (Berkeley) 2/22/94
+ * $FreeBSD: head/sys/sys/uio.h 314436 2017-02-28 23:42:47Z imp $
+ */
+
+#ifndef _SYS_UIO_H_
+#define        _SYS_UIO_H_
+
+#include <sys/cdefs.h>
+#include <sys/_types.h>
+#include <sys/_iovec.h>
+
+#ifndef _SSIZE_T_DECLARED
+typedef        __ssize_t       ssize_t;
+#define        _SSIZE_T_DECLARED
+#endif
+
+#ifndef _OFF_T_DECLARED
+typedef        __off_t off_t;
+#define        _OFF_T_DECLARED
+#endif
+
+#if __BSD_VISIBLE
+enum   uio_rw { UIO_READ, UIO_WRITE };
+
+/* Segment flag values. */
+enum uio_seg {
+       UIO_USERSPACE,          /* from user data space */
+       UIO_SYSSPACE,           /* from system space */
+       UIO_NOCOPY              /* don't copy, already in object */
+};
+#endif
+
+#ifdef _KERNEL
+
+struct uio {
+       struct  iovec *uio_iov;         /* scatter/gather list */
+       int     uio_iovcnt;             /* length of scatter/gather list */
+       off_t   uio_offset;             /* offset in target object */
+       ssize_t uio_resid;              /* remaining bytes to process */
+       enum    uio_seg uio_segflg;     /* address space */
+       enum    uio_rw uio_rw;          /* operation */
+       struct  thread *uio_td;         /* owner */
+};
+
+/*
+ * Limits
+ *
+ * N.B.: UIO_MAXIOV must be no less than IOV_MAX from <sys/syslimits.h>
+ * which in turn must be no less than _XOPEN_IOV_MAX from <limits.h>.  If
+ * we ever make this tunable (probably pointless), then IOV_MAX should be
+ * removed from <sys/syslimits.h> and applications would be expected to use
+ * sysconf(3) to find out the correct value, or else assume the worst
+ * (_XOPEN_IOV_MAX).  Perhaps UIO_MAXIOV should be simply defined as
+ * IOV_MAX.
+ */
+#define UIO_MAXIOV     1024            /* max 1K of iov's */
+
+struct vm_object;
+struct vm_page;
+struct bus_dma_segment;
+
+struct uio *cloneuio(struct uio *uiop);
+int    copyinfrom(const void * __restrict src, void * __restrict dst,
+           size_t len, int seg);
+int    copyiniov(const struct iovec *iovp, u_int iovcnt, struct iovec **iov,
+           int error);
+int    copyinstrfrom(const void * __restrict src, void * __restrict dst,
+           size_t len, size_t * __restrict copied, int seg);
+int    copyinuio(const struct iovec *iovp, u_int iovcnt, struct uio **uiop);
+int    copyout_map(struct thread *td, vm_offset_t *addr, size_t sz);
+int    copyout_unmap(struct thread *td, vm_offset_t addr, size_t sz);
+int    physcopyin(void *src, vm_paddr_t dst, size_t len);
+int    physcopyout(vm_paddr_t src, void *dst, size_t len);
+int    physcopyin_vlist(struct bus_dma_segment *src, off_t offset,
+           vm_paddr_t dst, size_t len);
+int    physcopyout_vlist(vm_paddr_t src, struct bus_dma_segment *dst,
+           off_t offset, size_t len);
+int    uiomove(void *cp, int n, struct uio *uio);
+int    uiomove_frombuf(void *buf, int buflen, struct uio *uio);
+int    uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, int n,
+           struct uio *uio);
+int    uiomove_nofault(void *cp, int n, struct uio *uio);
+int    uiomove_object(struct vm_object *obj, off_t obj_size, struct uio *uio);
+
+#else /* !_KERNEL */
+
+__BEGIN_DECLS
+ssize_t        readv(int, const struct iovec *, int);
+ssize_t        writev(int, const struct iovec *, int);
+#if __BSD_VISIBLE
+ssize_t        preadv(int, const struct iovec *, int, off_t);
+ssize_t        pwritev(int, const struct iovec *, int, off_t);
+#endif
+__END_DECLS
+
+#endif /* _KERNEL */
+
+#endif /* !_SYS_UIO_H_ */
diff --git a/newlib/libc/sys/rtems/include/sys/un.h b/newlib/libc/sys/rtems/include/sys/un.h
new file mode 100644 (file)
index 0000000..df6d783
--- /dev/null
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 1982, 1986, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)un.h        8.3 (Berkeley) 2/19/95
+ * $FreeBSD: head/sys/sys/un.h 314436 2017-02-28 23:42:47Z imp $
+ */
+
+#ifndef _SYS_UN_H_
+#define _SYS_UN_H_
+
+#include <sys/cdefs.h>
+#include <sys/_types.h>
+
+#ifndef _SA_FAMILY_T_DECLARED
+typedef        __sa_family_t   sa_family_t;
+#define        _SA_FAMILY_T_DECLARED
+#endif
+
+/*
+ * Definitions for UNIX IPC domain.
+ */
+struct sockaddr_un {
+       unsigned char   sun_len;        /* sockaddr len including null */
+       sa_family_t     sun_family;     /* AF_UNIX */
+       char    sun_path[104];          /* path name (gag) */
+};
+
+#if __BSD_VISIBLE
+
+/* Socket options. */
+#define        LOCAL_PEERCRED          1       /* retrieve peer credentials */
+#define        LOCAL_CREDS             2       /* pass credentials to receiver */
+#define        LOCAL_CONNWAIT          4       /* connects block until accepted */
+
+/* Start of reserved space for third-party socket options. */
+#define        LOCAL_VENDOR            SO_VENDOR
+
+#ifndef _KERNEL
+
+/* actual length of an initialized sockaddr_un */
+#define SUN_LEN(su) \
+       (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
+
+#endif /* !_KERNEL */
+
+#endif /* __BSD_VISIBLE */
+
+#endif /* !_SYS_UN_H_ */
diff --git a/newlib/libc/sys/rtems/include/syslog.h b/newlib/libc/sys/rtems/include/syslog.h
new file mode 100644 (file)
index 0000000..830b492
--- /dev/null
@@ -0,0 +1 @@
+#include <sys/syslog.h>
diff --git a/newlib/libc/sys/rtems/include/termios.h b/newlib/libc/sys/rtems/include/termios.h
new file mode 100644 (file)
index 0000000..0e8918e
--- /dev/null
@@ -0,0 +1,101 @@
+/*-
+ * Copyright (c) 1988, 1989, 1993, 1994
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)termios.h   8.3 (Berkeley) 3/28/94
+ * $FreeBSD: head/include/termios.h 318780 2017-05-24 09:25:13Z kib $
+ */
+
+#ifndef _TERMIOS_H_
+#define        _TERMIOS_H_
+
+#include <sys/cdefs.h>
+#include <sys/_termios.h>
+#include <sys/_types.h>
+
+#ifndef _PID_T_DECLARED
+typedef        __pid_t         pid_t;
+#define        _PID_T_DECLARED
+#endif
+
+#if __BSD_VISIBLE
+#define        OXTABS          TAB3
+#define        MDMBUF          CCAR_OFLOW
+#endif 
+
+#if __BSD_VISIBLE
+#define        CCEQ(val, c)    ((c) == (val) && (val) != _POSIX_VDISABLE)
+#endif
+
+/*
+ * Commands passed to tcsetattr() for setting the termios structure.
+ */
+#define        TCSANOW         0               /* make change immediate */
+#define        TCSADRAIN       1               /* drain output, then change */
+#define        TCSAFLUSH       2               /* drain output, flush input */
+#if __BSD_VISIBLE
+#define        TCSASOFT        0x10            /* flag - don't alter h.w. state */
+#endif
+
+#define        TCIFLUSH        1
+#define        TCOFLUSH        2
+#define        TCIOFLUSH       3
+#define        TCOOFF          1
+#define        TCOON           2
+#define        TCIOFF          3
+#define        TCION           4
+
+__BEGIN_DECLS
+speed_t        cfgetispeed(const struct termios *);
+speed_t        cfgetospeed(const struct termios *);
+int    cfsetispeed(struct termios *, speed_t);
+int    cfsetospeed(struct termios *, speed_t);
+int    tcgetattr(int, struct termios *);
+int    tcsetattr(int, int, const struct termios *);
+int    tcdrain(int);
+int    tcflow(int, int);
+int    tcflush(int, int);
+int    tcsendbreak(int, int);
+
+#if __POSIX_VISIBLE >= 200112
+pid_t  tcgetsid(int);
+#endif
+#if __BSD_VISIBLE
+int    tcsetsid(int, pid_t);
+
+void   cfmakeraw(struct termios *);
+void   cfmakesane(struct termios *);
+int    cfsetspeed(struct termios *, speed_t);
+#endif
+__END_DECLS
+
+#endif /* !_TERMIOS_H_ */
+
+#if __BSD_VISIBLE
+#include <sys/ttycom.h>
+#include <sys/ttydefaults.h>
+#endif
This page took 0.153714 seconds and 5 git commands to generate.