]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Don’t include sys/socket.h from public headers.
authorZack Weinberg <zackw@panix.com>
Thu, 6 Jun 2019 13:49:54 +0000 (09:49 -0400)
committerZack Weinberg <zackw@panix.com>
Wed, 8 Jan 2020 19:15:42 +0000 (14:15 -0500)
No standard public header is required to include sys/socket.h,
although some are allowed to.  Several public headers need the
definitions of socklen_t, struct sockaddr, and/or struct
sockaddr_storage, but nothing else from sys/socket.h.  We already have
a single-type header for socklen_t, so this patch adds single-type
headers for struct sockaddr and struct sockaddr_storage.

The definition of struct sockaddr_storage is subtly different on Linux
than on the Hurd; in order to not need two copies of
bits/types/struct_sockaddr_storage.h, bits/sockaddr.h is now
responsible for defining __ss_aligntype if ‘unsigned long int’ is not
the correct definition.

I also added a single-type header for struct linger, even though only
sys/socket.h is expected to define that, just because all three copies
of bits/socket.h were defining it exactly the same way.  There would
also be a case for defining it directly in sys/socket.h but this
seemed tidier.

I did *not* create single-type headers for struct msghdr and struct
cmsghdr, because those and their helper macros are not consistent
among the three copies of bits/socket.h, and, again, only sys/socket.h
is expected to define them.

The large number of .c files that add an `#include <sys/socket.h>`
might make this look like it’s not worth doing.  However, after this
change, only half of the files in the glibc source tree that include
netinet/in.h also need to include sys/socket.h, and only a third of
the files that include netdb.h need to include sys/socket.h.  Before,
all of the files in both groups were getting sys/socket.h.  That seems
like enough justification to me.

While I was at it I noticed that sys/socketvar.h is yet another
backward compatibility header that does nothing but include some other
header (sys/socket.h, in this case) and also doesn’t need to be
system-dependent.

* socket/bits/types/struct_linger.h
* socket/bits/types/struct_sockaddr.h
* socket/bits/types/struct_sockaddr_storage.h:
New single-type headers, factored out of the various bits/socket.h
headers.

* include/bits/types/struct_linger.h
* include/bits/types/struct_sockaddr.h
* include/bits/types/struct_sockaddr_storage.h:
New wrappers.

* socket/Makefile (headers): Add bits/types/struct_linger.h,
bits/types/struct_sockaddr.h, and bits/types/struct_sockaddr_storage.h.
Alphabetize the list.

* bits/socket.h, sysdeps/mach/hurd/bits/socket.h
* sysdeps/unix/sysv/linux/bits/socket.h:
Don’t define struct sockaddr, struct sockaddr_storage,
__ss_aligntype, or struct linger here.  Minimize inclusions.
* sysdeps/unix/bsd/bits/sockaddr.h: Define __ss_aligntype here.

* socket/sys/socket.h: Include bits/types/struct_linger.h,
bits/sockaddr.h, bits/types/struct_sockaddr.h, and
bits/types/struct_sockaddr_storage.h.  Move inclusion of
bits/socket.h below forward declaration of struct timespec,
and update commentary.

* inet/ifaddrs.h, socket/net/if.h
* sysdeps/mach/hurd/net/if_arp.h
* sysdeps/mach/hurd/net/route.h
* sysdeps/unix/sysv/linux/errqueue.h
* sysdeps/unix/sysv/linux/net/if_arp.h
* sysdeps/unix/sysv/linux/net/route.h:
Include bits/types/struct_sockaddr.h and possibly also bits/types.h,
not sys/socket.h or sys/types.h.

* sysdeps/unix/sysv/linux/errqueue.h:
* sysdeps/unix/sysv/linux/net/route.h:
Use __uint8_t and __uint32_t instead of uint8_t and uint32_t.

* inet/arpa/inet.h: Include bits/types/size_t.h.
* inet/netinet/in.h: Include bits/sockaddr.h,
bits/types/struct_sockaddr.h, and
bits/types/struct_sockaddr_storage.h,
not sys/socket.h.  Use __socklen_t instead of socklen_t.
* inet/netinet/tcp.h: Include bits/types.h and
bits/types/struct_sockaddr_storage.h, not sys/socket.h or
bits/stdint-uintn.h.  Use __uint8_t, __uint16_t, and __uint32_t
instead of uint8_t, uint16_t and uint32_t.
* inet/protocols/routed.h: Include features.h and
bits/types/struct_sockaddr.h, not sys/socket.h.
* resolv/netdb.h: Include bits/types/socklen_t.h.
* sysdeps/unix/sysv/linux/netatalk/at.h: Don’t include sys/socket.h.

* include/ifaddrs.h: Include stddef.h for size_t.
* include/netdb.h: Use __socklen_t instead of socklen_t.

* inet/check_pf.c, inet/gethstbynm.c, inet/gethstbynm_r.c
* inet/getsourcefilter.c, inet/inet6_opt.c, inet/inet6_option.c
        * inet/inet6_rth.c, inet/setsourcefilter.c, inet/test-ifaddrs.c
* inet/test-inet6_opt.c, inet/tst-inet6_rth.c
* inet/tst-inet6_scopeid_pton.c, nis/nss_nis/nis-hosts.c
* nis/nss_nisplus/nisplus-hosts.c, nscd/aicache.c, nscd/cache.c
* nscd/hstcache.c, nscd/initgrcache.c, nscd/netgroupcache.c
* nscd/nscd_gethst_r.c, nscd/servicescache.c, nss/digits_dots.c
* nss/nss_files/files-hosts.c, nss/nss_files/files-network.c
* nss/tst-nss-files-hosts-erange.c, nss/tst-nss-files-hosts-getent.c
* nss/tst-nss-files-hosts-multi.c, posix/tst-getaddrinfo3.c
* resolv/nss_dns/dns-network.c, resolv/resolv_conf.c
* resolv/tst-bug18665-tcp.c, resolv/tst-bug18665.c
* resolv/tst-inet_ntop.c, resolv/tst-inet_pton.c
* resolv/tst-resolv-ai_idn-common.c, resolv/tst-resolv-basic.c
* resolv/tst-resolv-edns.c, resolv/tst-resolv-network.c
* resolv/tst-resolv-nondecimal.c, resolv/tst-resolv-search.c
* resolv/tst-resolv-threads.c, resolv/tst-resolv-trailing.c
* sunrpc/rpc_gethostbyname.c
* support/support_format_address_family.c
* support/support_format_addrinfo.c
* support/support_format_dns_packet.c
* support/support_format_hostent.c, support/support_format_netent.c
* sysdeps/mach/hurd/if_index.c
* sysdeps/unix/sysv/linux/check_native.c: Include sys/socket.h.

* resolv/tst-resolv-binary.c: Include sys/types.h.

* sysdeps/generic/sys/socketvar.h: Move to socket/sys/socketvar.h.
* include/sys/socketvar.h: New wrapper.

* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
Update.

81 files changed:
bits/socket.h
include/bits/types/struct_linger.h [new file with mode: 0644]
include/bits/types/struct_sockaddr.h [new file with mode: 0644]
include/bits/types/struct_sockaddr_storage.h [new file with mode: 0644]
include/ifaddrs.h
include/netdb.h
include/sys/socketvar.h [new file with mode: 0644]
inet/arpa/inet.h
inet/check_pf.c
inet/gethstbynm.c
inet/gethstbynm_r.c
inet/getsourcefilter.c
inet/ifaddrs.h
inet/inet6_opt.c
inet/inet6_option.c
inet/inet6_rth.c
inet/netinet/in.h
inet/netinet/tcp.h
inet/protocols/routed.h
inet/setsourcefilter.c
inet/test-ifaddrs.c
inet/test-inet6_opt.c
inet/tst-inet6_rth.c
inet/tst-inet6_scopeid_pton.c
nis/nss_nis/nis-hosts.c
nis/nss_nisplus/nisplus-hosts.c
nscd/aicache.c
nscd/cache.c
nscd/hstcache.c
nscd/initgrcache.c
nscd/netgroupcache.c
nscd/nscd_gethst_r.c
nscd/servicescache.c
nss/digits_dots.c
nss/nss_files/files-hosts.c
nss/nss_files/files-network.c
nss/tst-nss-files-hosts-erange.c
nss/tst-nss-files-hosts-getent.c
nss/tst-nss-files-hosts-multi.c
posix/tst-getaddrinfo3.c
resolv/netdb.h
resolv/nss_dns/dns-network.c
resolv/resolv_conf.c
resolv/tst-bug18665-tcp.c
resolv/tst-bug18665.c
resolv/tst-inet_ntop.c
resolv/tst-inet_pton.c
resolv/tst-resolv-ai_idn-common.c
resolv/tst-resolv-basic.c
resolv/tst-resolv-binary.c
resolv/tst-resolv-edns.c
resolv/tst-resolv-network.c
resolv/tst-resolv-nondecimal.c
resolv/tst-resolv-search.c
resolv/tst-resolv-threads.c
resolv/tst-resolv-trailing.c
scripts/check-obsolete-constructs.py
socket/Makefile
socket/bits/types/struct_linger.h [new file with mode: 0644]
socket/bits/types/struct_sockaddr.h [new file with mode: 0644]
socket/bits/types/struct_sockaddr_storage.h [new file with mode: 0644]
socket/net/if.h
socket/sys/socket.h
socket/sys/socketvar.h [moved from sysdeps/generic/sys/socketvar.h with 100% similarity]
sunrpc/rpc_gethostbyname.c
support/support_format_address_family.c
support/support_format_addrinfo.c
support/support_format_dns_packet.c
support/support_format_hostent.c
support/support_format_netent.c
sysdeps/mach/hurd/bits/socket.h
sysdeps/mach/hurd/if_index.c
sysdeps/mach/hurd/net/if_arp.h
sysdeps/mach/hurd/net/route.h
sysdeps/unix/bsd/bits/sockaddr.h
sysdeps/unix/sysv/linux/bits/socket.h
sysdeps/unix/sysv/linux/check_native.c
sysdeps/unix/sysv/linux/errqueue.h
sysdeps/unix/sysv/linux/net/if_arp.h
sysdeps/unix/sysv/linux/net/route.h
sysdeps/unix/sysv/linux/netatalk/at.h

index c844429ab85bb1e7df524928a0d087714caf7f37..fb30f9dac4af27e179d07f352d76d6bc1fedf2e2 100644 (file)
 # error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
 #endif
 
-#include <bits/wordsize.h>
-#include <bits/types.h>
-#include <bits/types/size_t.h>
-#include <bits/types/socklen_t.h>
 
 /* Types of sockets.  */
 enum __socket_type
@@ -137,34 +133,6 @@ enum __socket_type
 /* Maximum queue length specifiable by listen.  */
 #define SOMAXCONN      128     /* 5 on the origional 4.4 BSD.  */
 
-/* Get the definition of the macro to define the common sockaddr members.  */
-#include <bits/sockaddr.h>
-
-/* Structure describing a generic socket address.  */
-struct sockaddr
-  {
-    __SOCKADDR_COMMON (sa_);   /* Common data: address family and length.  */
-    char sa_data[14];          /* Address data.  */
-  };
-
-
-/* Structure large enough to hold any socket address (with the historical
-   exception of AF_UNIX).  */
-#if __WORDSIZE == 64
-# define __ss_aligntype        __uint64_t
-#else
-# define __ss_aligntype        __uint32_t
-#endif
-#define _SS_PADSIZE \
-  (_SS_SIZE - __SOCKADDR_COMMON_SIZE - sizeof (__ss_aligntype))
-
-struct sockaddr_storage
-  {
-    __SOCKADDR_COMMON (ss_);   /* Address family, etc.  */
-    char __ss_padding[_SS_PADSIZE];
-    __ss_aligntype __ss_align; /* Force desired alignment.  */
-  };
-
 
 /* Bits in the FLAGS argument to `send', `recv', et al.  */
 enum
@@ -347,11 +315,4 @@ enum
 #define SO_TYPE SO_TYPE
   };
 
-/* Structure used to manipulate the SO_LINGER option.  */
-struct linger
-  {
-    int l_onoff;               /* Nonzero to linger on close.  */
-    int l_linger;              /* Time to linger.  */
-  };
-
 #endif /* bits/socket.h */
diff --git a/include/bits/types/struct_linger.h b/include/bits/types/struct_linger.h
new file mode 100644 (file)
index 0000000..55b2f20
--- /dev/null
@@ -0,0 +1 @@
+#include <socket/bits/types/struct_linger.h>
diff --git a/include/bits/types/struct_sockaddr.h b/include/bits/types/struct_sockaddr.h
new file mode 100644 (file)
index 0000000..641fbcd
--- /dev/null
@@ -0,0 +1 @@
+#include <socket/bits/types/struct_sockaddr.h>
diff --git a/include/bits/types/struct_sockaddr_storage.h b/include/bits/types/struct_sockaddr_storage.h
new file mode 100644 (file)
index 0000000..68f3171
--- /dev/null
@@ -0,0 +1 @@
+#include <socket/bits/types/struct_sockaddr_storage.h>
index 416118f1b38cb580b2d45966d5e29d531f4c81d5..bea810b1612e723c4fe85af7c7dea543e8acdf49 100644 (file)
@@ -3,6 +3,7 @@
 
 # ifndef _ISOMAC
 
+#include <stddef.h>
 #include <stdbool.h>
 #include <stdint.h>
 
index e230b1f4fc72dc7b8570a3620467f71c6c869fba..7853769ebe98060cd68bb4db6e9e2e3f4a6d8f6f 100644 (file)
@@ -39,21 +39,21 @@ extern int __old_gethostent_r (struct hostent *__restrict __result_buf,
                               int *__restrict __h_errnop);
 
 extern int __gethostbyaddr_r (const void *__restrict __addr,
-                             socklen_t __len, int __type,
+                             __socklen_t __len, int __type,
                              struct hostent *__restrict __result_buf,
                              char *__restrict __buf, size_t __buflen,
                              struct hostent **__restrict __result,
                              int *__restrict __h_errnop)
      attribute_hidden;
 extern int __old_gethostbyaddr_r (const void *__restrict __addr,
-                                 socklen_t __len, int __type,
+                                 __socklen_t __len, int __type,
                                  struct hostent *__restrict __result_buf,
                                  char *__restrict __buf, size_t __buflen,
                                  struct hostent **__restrict __result,
                                  int *__restrict __h_errnop);
 
 extern int __gethostbyaddr2_r (const void *__restrict __addr,
-                              socklen_t __len, int __type,
+                              __socklen_t __len, int __type,
                               struct hostent *__restrict __result_buf,
                               char *__restrict __buf, size_t __buflen,
                               struct hostent **__restrict __result,
@@ -246,7 +246,7 @@ extern enum nss_status _nss_ ## service ## _gethostbyname_r               \
                       (const char *name, struct hostent *host, char *buffer, \
                        size_t buflen, int *errnop, int *h_errnop);           \
 extern enum nss_status _nss_ ## service ## _gethostbyaddr_r                  \
-                      (const void *addr, socklen_t addrlen, int af,          \
+                      (const void *addr, __socklen_t addrlen, int af,        \
                        struct hostent *host, char *buffer, size_t buflen,    \
                        int *errnop, int *h_errnop);                          \
 extern enum nss_status _nss_ ## service ## _setservent (int);                \
diff --git a/include/sys/socketvar.h b/include/sys/socketvar.h
new file mode 100644 (file)
index 0000000..658fd10
--- /dev/null
@@ -0,0 +1 @@
+#include <socket/sys/socketvar.h>
index 08837249fad891ab78d8cd067ff35bf3bfb3b1b5..2625d2f2e6426e1cac580cb524510288d24eafea 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <features.h>
 #include <netinet/in.h>                /* To define `struct in_addr'.  */
+#include <bits/types/size_t.h>
 #include <bits/types/socklen_t.h>
 
 __BEGIN_DECLS
index 323bd842f432b0c02d7141fd8fd996982defc497..8c3438eef373a2241f9343a26a7dd70d95bab4d7 100644 (file)
@@ -19,6 +19,7 @@
 #include <ifaddrs.h>
 #include <netdb.h>
 #include <stdint.h>
+#include <sys/socket.h>
 
 void
 attribute_hidden
index e5eb4c9cebbe6fd048cb66f6c1229fe4294afb9e..2cbd31974d25234f4ac02cea79f627d72c3e1a2f 100644 (file)
@@ -20,6 +20,7 @@
 #include <errno.h>
 #include <netdb.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <arpa/inet.h>
 #include <netinet/in.h>
 
index 9e4b9e2e96e56c7a7580c85071f75f97b35cb976..3c3d4cda594cc320afc393800b090c0e1853c2d1 100644 (file)
@@ -20,6 +20,7 @@
 #include <errno.h>
 #include <netdb.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <resolv/res_hconf.h>
index c2e67b0fa5d4fc0f3568c596c21efcc05d1bb7b5..5b1beaf00abccf267c9b3f8eea547c256b0f7616 100644 (file)
@@ -20,6 +20,7 @@
 #include <errno.h>
 #include <netinet/in.h>
 #include <stdint.h>
+#include <sys/socket.h>
 
 int
 getsourcefilter (int s, uint32_t interface, const struct sockaddr *group,
index ffcd66d97c40d0d067bbf0df8b10d7df56023b90..4868942dcd9d31646907d8446fc8dc399b90153c 100644 (file)
@@ -20,7 +20,7 @@
 #define _IFADDRS_H     1
 
 #include <features.h>
-#include <sys/socket.h>
+#include <bits/types/struct_sockaddr.h>
 
 __BEGIN_DECLS
 
index 715f6f83018d9bb8e7b3281ad158aa05ac10f1c2..bc55dc8da9df01e587fba9507cacf53da7a9eee9 100644 (file)
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <string.h>
+#include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/ip6.h>
 
index 48b2aed1ced14cb569509a02ee0d205a2c01c1e2..bdbce502dec74c776cfae3bb197e8cc4e22b952e 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/ip6.h>
 #include <sys/param.h>
index 09ac6b5cfb6a561521d894af01e7882f41d7692e..d53c5a5751b862f559828c3efd2afecc2f1ea32b 100644 (file)
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <string.h>
+#include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/ip6.h>
 
index 993cfe6ae8c56b42a2206fcd97d19864707950d3..81568819a474762e1f15b994ee0afd9eb6cdad94 100644 (file)
 #define        _NETINET_IN_H   1
 
 #include <features.h>
-#include <bits/stdint-uintn.h>
-#include <sys/socket.h>
 #include <bits/types.h>
-
+#include <bits/stdint-uintn.h>
+#include <bits/sockaddr.h>
+#include <bits/types/struct_sockaddr.h>
+#include <bits/types/struct_sockaddr_storage.h>
 
 __BEGIN_DECLS
 
@@ -568,27 +569,27 @@ extern int inet6_option_find (const struct cmsghdr *__cmsg,
 
 
 /* Hop-by-Hop and Destination Options Processing (RFC 3542).  */
-extern int inet6_opt_init (void *__extbuf, socklen_t __extlen) __THROW;
-extern int inet6_opt_append (void *__extbuf, socklen_t __extlen, int __offset,
-                            uint8_t __type, socklen_t __len, uint8_t __align,
+extern int inet6_opt_init (void *__extbuf, __socklen_t __extlen) __THROW;
+extern int inet6_opt_append (void *__extbuf, __socklen_t __extlen, int __offset,
+                            uint8_t __type, __socklen_t __len, uint8_t __align,
                             void **__databufp) __THROW;
-extern int inet6_opt_finish (void *__extbuf, socklen_t __extlen, int __offset)
+extern int inet6_opt_finish (void *__extbuf, __socklen_t __extlen, int __offset)
      __THROW;
 extern int inet6_opt_set_val (void *__databuf, int __offset, void *__val,
-                             socklen_t __vallen) __THROW;
-extern int inet6_opt_next (void *__extbuf, socklen_t __extlen, int __offset,
-                          uint8_t *__typep, socklen_t *__lenp,
+                             __socklen_t __vallen) __THROW;
+extern int inet6_opt_next (void *__extbuf, __socklen_t __extlen, int __offset,
+                          uint8_t *__typep, __socklen_t *__lenp,
                           void **__databufp) __THROW;
-extern int inet6_opt_find (void *__extbuf, socklen_t __extlen, int __offset,
-                          uint8_t __type, socklen_t *__lenp,
+extern int inet6_opt_find (void *__extbuf, __socklen_t __extlen, int __offset,
+                          uint8_t __type, __socklen_t *__lenp,
                           void **__databufp) __THROW;
 extern int inet6_opt_get_val (void *__databuf, int __offset, void *__val,
-                             socklen_t __vallen) __THROW;
+                             __socklen_t __vallen) __THROW;
 
 
 /* Routing Header Option (RFC 3542).  */
-extern socklen_t inet6_rth_space (int __type, int __segments) __THROW;
-extern void *inet6_rth_init (void *__bp, socklen_t __bp_len, int __type,
+extern __socklen_t inet6_rth_space (int __type, int __segments) __THROW;
+extern void *inet6_rth_init (void *__bp, __socklen_t __bp_len, int __type,
                             int __segments) __THROW;
 extern int inet6_rth_add (void *__bp, const struct in6_addr *__addr) __THROW;
 extern int inet6_rth_reverse (const void *__in, void *__out) __THROW;
@@ -616,14 +617,14 @@ extern int setipv4sourcefilter (int __s, struct in_addr __interface_addr,
 /* Get source filter.  */
 extern int getsourcefilter (int __s, uint32_t __interface_addr,
                            const struct sockaddr *__group,
-                           socklen_t __grouplen, uint32_t *__fmode,
+                           __socklen_t __grouplen, uint32_t *__fmode,
                            uint32_t *__numsrc,
                            struct sockaddr_storage *__slist) __THROW;
 
 /* Set source filter.  */
 extern int setsourcefilter (int __s, uint32_t __interface_addr,
                            const struct sockaddr *__group,
-                           socklen_t __grouplen, uint32_t __fmode,
+                           __socklen_t __grouplen, uint32_t __fmode,
                            uint32_t __numsrc,
                            const struct sockaddr_storage *__slist) __THROW;
 #endif /* use GNU */
index 243b55a24c59fb1727f78d9095bc5086dde03ae4..f6aa166c5a11699d5fee7cac0deb175ad63aa3b7 100644 (file)
 #define TCP_REPAIR_OFF_NO_WP    -1
 
 #ifdef __USE_MISC
-# include <bits/stdint-uintn.h>
 # include <bits/endian.h>
-# include <sys/socket.h>
+# include <bits/types.h>
+# include <bits/types/struct_sockaddr_storage.h>
 
-typedef        uint32_t tcp_seq;
+typedef        __uint32_t tcp_seq;
 /*
  * TCP header.
  * Per RFC 793, September, 1981.
@@ -101,61 +101,61 @@ struct tcphdr
     {
       struct
       {
-       uint16_t th_sport;      /* source port */
-       uint16_t th_dport;      /* destination port */
+       __uint16_t th_sport;    /* source port */
+       __uint16_t th_dport;    /* destination port */
        tcp_seq th_seq;         /* sequence number */
        tcp_seq th_ack;         /* acknowledgement number */
 # if __BYTE_ORDER == __LITTLE_ENDIAN
-       uint8_t th_x2:4;        /* (unused) */
-       uint8_t th_off:4;       /* data offset */
+       __uint8_t th_x2:4;      /* (unused) */
+       __uint8_t th_off:4;     /* data offset */
 # endif
 # if __BYTE_ORDER == __BIG_ENDIAN
-       uint8_t th_off:4;       /* data offset */
-       uint8_t th_x2:4;        /* (unused) */
+       __uint8_t th_off:4;     /* data offset */
+       __uint8_t th_x2:4;      /* (unused) */
 # endif
-       uint8_t th_flags;
+       __uint8_t 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
-       uint16_t th_win;        /* window */
-       uint16_t th_sum;        /* checksum */
-       uint16_t th_urp;        /* urgent pointer */
+       __uint16_t th_win;      /* window */
+       __uint16_t th_sum;      /* checksum */
+       __uint16_t th_urp;      /* urgent pointer */
       };
       struct
       {
-       uint16_t source;
-       uint16_t dest;
-       uint32_t seq;
-       uint32_t ack_seq;
+       __uint16_t source;
+       __uint16_t dest;
+       __uint32_t seq;
+       __uint32_t ack_seq;
 # if __BYTE_ORDER == __LITTLE_ENDIAN
-       uint16_t res1:4;
-       uint16_t doff:4;
-       uint16_t fin:1;
-       uint16_t syn:1;
-       uint16_t rst:1;
-       uint16_t psh:1;
-       uint16_t ack:1;
-       uint16_t urg:1;
-       uint16_t res2:2;
+       __uint16_t res1:4;
+       __uint16_t doff:4;
+       __uint16_t fin:1;
+       __uint16_t syn:1;
+       __uint16_t rst:1;
+       __uint16_t psh:1;
+       __uint16_t ack:1;
+       __uint16_t urg:1;
+       __uint16_t res2:2;
 # elif __BYTE_ORDER == __BIG_ENDIAN
-       uint16_t doff:4;
-       uint16_t res1:4;
-       uint16_t res2:2;
-       uint16_t urg:1;
-       uint16_t ack:1;
-       uint16_t psh:1;
-       uint16_t rst:1;
-       uint16_t syn:1;
-       uint16_t fin:1;
+       __uint16_t doff:4;
+       __uint16_t res1:4;
+       __uint16_t res2:2;
+       __uint16_t urg:1;
+       __uint16_t ack:1;
+       __uint16_t psh:1;
+       __uint16_t rst:1;
+       __uint16_t syn:1;
+       __uint16_t fin:1;
 # else
 #  error "Adjust your <bits/endian.h> defines"
 # endif
-       uint16_t window;
-       uint16_t check;
-       uint16_t urg_ptr;
+       __uint16_t window;
+       __uint16_t check;
+       __uint16_t urg_ptr;
       };
     };
 };
@@ -225,45 +225,45 @@ enum tcp_ca_state
 
 struct tcp_info
 {
-  uint8_t      tcpi_state;
-  uint8_t      tcpi_ca_state;
-  uint8_t      tcpi_retransmits;
-  uint8_t      tcpi_probes;
-  uint8_t      tcpi_backoff;
-  uint8_t      tcpi_options;
-  uint8_t      tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
-
-  uint32_t     tcpi_rto;
-  uint32_t     tcpi_ato;
-  uint32_t     tcpi_snd_mss;
-  uint32_t     tcpi_rcv_mss;
-
-  uint32_t     tcpi_unacked;
-  uint32_t     tcpi_sacked;
-  uint32_t     tcpi_lost;
-  uint32_t     tcpi_retrans;
-  uint32_t     tcpi_fackets;
+  __uint8_t    tcpi_state;
+  __uint8_t    tcpi_ca_state;
+  __uint8_t    tcpi_retransmits;
+  __uint8_t    tcpi_probes;
+  __uint8_t    tcpi_backoff;
+  __uint8_t    tcpi_options;
+  __uint8_t    tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
+
+  __uint32_t   tcpi_rto;
+  __uint32_t   tcpi_ato;
+  __uint32_t   tcpi_snd_mss;
+  __uint32_t   tcpi_rcv_mss;
+
+  __uint32_t   tcpi_unacked;
+  __uint32_t   tcpi_sacked;
+  __uint32_t   tcpi_lost;
+  __uint32_t   tcpi_retrans;
+  __uint32_t   tcpi_fackets;
 
   /* Times. */
-  uint32_t     tcpi_last_data_sent;
-  uint32_t     tcpi_last_ack_sent;     /* Not remembered, sorry.  */
-  uint32_t     tcpi_last_data_recv;
-  uint32_t     tcpi_last_ack_recv;
+  __uint32_t   tcpi_last_data_sent;
+  __uint32_t   tcpi_last_ack_sent;     /* Not remembered, sorry.  */
+  __uint32_t   tcpi_last_data_recv;
+  __uint32_t   tcpi_last_ack_recv;
 
   /* Metrics. */
-  uint32_t     tcpi_pmtu;
-  uint32_t     tcpi_rcv_ssthresh;
-  uint32_t     tcpi_rtt;
-  uint32_t     tcpi_rttvar;
-  uint32_t     tcpi_snd_ssthresh;
-  uint32_t     tcpi_snd_cwnd;
-  uint32_t     tcpi_advmss;
-  uint32_t     tcpi_reordering;
-
-  uint32_t     tcpi_rcv_rtt;
-  uint32_t     tcpi_rcv_space;
-
-  uint32_t     tcpi_total_retrans;
+  __uint32_t   tcpi_pmtu;
+  __uint32_t   tcpi_rcv_ssthresh;
+  __uint32_t   tcpi_rtt;
+  __uint32_t   tcpi_rttvar;
+  __uint32_t   tcpi_snd_ssthresh;
+  __uint32_t   tcpi_snd_cwnd;
+  __uint32_t   tcpi_advmss;
+  __uint32_t   tcpi_reordering;
+
+  __uint32_t   tcpi_rcv_rtt;
+  __uint32_t   tcpi_rcv_space;
+
+  __uint32_t   tcpi_total_retrans;
 };
 
 
@@ -276,18 +276,18 @@ struct tcp_info
 struct tcp_md5sig
 {
   struct sockaddr_storage tcpm_addr;           /* Address associated.  */
-  uint8_t      tcpm_flags;                     /* Extension flags.  */
-  uint8_t      tcpm_prefixlen;                 /* Address prefix.  */
-  uint16_t     tcpm_keylen;                    /* Key length.  */
-  uint32_t     __tcpm_pad;                     /* Zero.  */
-  uint8_t      tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* Key (binary).  */
+  __uint8_t    tcpm_flags;                     /* Extension flags.  */
+  __uint8_t    tcpm_prefixlen;                 /* Address prefix.  */
+  __uint16_t   tcpm_keylen;                    /* Key length.  */
+  __uint32_t   __tcpm_pad;                     /* Zero.  */
+  __uint8_t    tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* Key (binary).  */
 };
 
 /* For socket repair options.  */
 struct tcp_repair_opt
 {
-  uint32_t     opt_code;
-  uint32_t     opt_val;
+  __uint32_t   opt_code;
+  __uint32_t   opt_val;
 };
 
 /* Queue to repair, for TCP_REPAIR_QUEUE.  */
@@ -318,30 +318,30 @@ enum
 
 struct tcp_cookie_transactions
 {
-  uint16_t     tcpct_flags;
-  uint8_t      __tcpct_pad1;
-  uint8_t      tcpct_cookie_desired;
-  uint16_t     tcpct_s_data_desired;
-  uint16_t     tcpct_used;
-  uint8_t      tcpct_value[TCP_MSS_DEFAULT];
+  __uint16_t   tcpct_flags;
+  __uint8_t    __tcpct_pad1;
+  __uint8_t    tcpct_cookie_desired;
+  __uint16_t   tcpct_s_data_desired;
+  __uint16_t   tcpct_used;
+  __uint8_t    tcpct_value[TCP_MSS_DEFAULT];
 };
 
 /* For use with TCP_REPAIR_WINDOW.  */
 struct tcp_repair_window
 {
-  uint32_t snd_wl1;
-  uint32_t snd_wnd;
-  uint32_t max_window;
-  uint32_t rcv_wnd;
-  uint32_t rcv_wup;
+  __uint32_t snd_wl1;
+  __uint32_t snd_wnd;
+  __uint32_t max_window;
+  __uint32_t rcv_wnd;
+  __uint32_t rcv_wup;
 };
 
 /* For use with TCP_ZEROCOPY_RECEIVE.  */
 struct tcp_zerocopy_receive
 {
-  uint64_t address; /* In: address of mapping.  */
-  uint32_t length; /* In/out: number of bytes to map/mapped.  */
-  uint32_t recv_skip_hint; /* Out: amount of bytes to skip.  */
+  __uint64_t address; /* In: address of mapping.  */
+  __uint32_t length; /* In/out: number of bytes to map/mapped.  */
+  __uint32_t recv_skip_hint; /* Out: amount of bytes to skip.  */
 };
 
 #endif /* Misc.  */
index adb1767dca1aa2826b274cecea733a7ab46c4886..694c43644555f953298dbecddc4bd920681d2b65 100644 (file)
@@ -32,7 +32,9 @@
 #ifndef _PROTOCOLS_ROUTED_H
 #define        _PROTOCOLS_ROUTED_H 1
 
-#include <sys/socket.h>
+#include <features.h>
+#include <bits/types/struct_sockaddr.h>
+
 /*
  * Routing Information Protocol
  *
index f0975de724a9d6af93d926a71ad326e282ba4567..9ffd42a9e70c7677ba1fe8a8381be0dd772baaf3 100644 (file)
@@ -20,7 +20,7 @@
 #include <errno.h>
 #include <stdint.h>
 #include <netinet/in.h>
-
+#include <sys/socket.h>
 
 int
 setsourcefilter (int s, uint32_t interface, const struct sockaddr *group,
index b7027c2b103d0f81095907fc7c180464dfda874d..751efc55b0adac2c218d5334594911f94143fb72 100644 (file)
@@ -21,6 +21,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ifaddrs.h>
+#include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
index a7ebf006c6ed2e25ee7cb5b47125329ad29707fd..e10680c498b09eeb991c28d4386bcf567b60266b 100644 (file)
@@ -1,3 +1,4 @@
+#include <sys/socket.h>
 #include <netinet/in.h>
 #include <stdio.h>
 #include <stdlib.h>
index 549d717c7de506c1e1069f4fdc4c6cbd9a8c8031..abb85cdf2617aa2def39cdbb5e315cf6372ee9d8 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <arpa/inet.h>
 #include <netinet/ip6.h>
 
index 37ec20b1e231f90e87b0e46fc4c07c0e337a4da9..4c25d23cddf12a714330d168ee7a7d80e8902edb 100644 (file)
@@ -16,6 +16,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/socket.h>
 #include <arpa/inet.h>
 #include <inttypes.h>
 #include <net-internal.h>
index 2d08076382bb24bedc80dd1c59e7e3e60a747d4a..6355663d498c11a4fd3772fa11422a8c61c37d22 100644 (file)
@@ -25,6 +25,7 @@
 #include <netdb.h>
 #undef _nss_nis_endhostent
 #include <string.h>
+#include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <libc-lock.h>
index 1e66e4ff923755a5bc1d4292204e98c8e5dde4c2..b65c27f014bff971141f6bd09bcccc520a48e775 100644 (file)
@@ -23,6 +23,7 @@
 #include <netdb.h>
 #include <nss.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <rpcsvc/nis.h>
index 46db40fceb05fb08dd42c80c2bbe774b879d3f19..8f7e72e65be33e3840e98acff4b8657fe5b7bb98 100644 (file)
@@ -25,6 +25,7 @@
 #include <time.h>
 #include <unistd.h>
 #include <sys/mman.h>
+#include <sys/socket.h>
 #include <resolv/resolv-internal.h>
 #include <resolv/resolv_context.h>
 #include <scratch_buffer.h>
index 0c4dfc0dcf01789eadc14dd1653da8d183ca50a5..41403c990df63e0cdb311ff3b3c002f7332ab879 100644 (file)
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <libintl.h>
 #include <arpa/inet.h>
+#include <sys/socket.h>
 #include <sys/mman.h>
 #include <sys/param.h>
 #include <sys/stat.h>
index 9ade6c1582a051d35090f587833babcf91d04070..d9020f76abee389ba23e37e9f5312e57da84722b 100644 (file)
@@ -33,6 +33,7 @@
 #include <arpa/inet.h>
 #include <arpa/nameser.h>
 #include <sys/mman.h>
+#include <sys/socket.h>
 #include <stackinfo.h>
 #include <scratch_buffer.h>
 
index c37b920fae9cb37f351105dbf12794a528896cd5..ee5e1e21333fd0571beda5e2e75b072d1b7ded58 100644 (file)
@@ -26,6 +26,7 @@
 #include <unistd.h>
 #include <sys/mman.h>
 #include <sys/param.h>
+#include <sys/socket.h>
 #include <scratch_buffer.h>
 #include <config.h>
 
index dacd52315aa0d72a1f3667c188d1dfa1e36206c0..63e903703a3bf47d8fddce1da0b79ff91ed968e1 100644 (file)
@@ -25,6 +25,7 @@
 #include <unistd.h>
 #include <sys/mman.h>
 #include <sys/param.h>
+#include <sys/socket.h>
 
 #include "../inet/netgroup.h"
 #include "nscd.h"
index f08d1d149ae13c00eb959e92727aefc8bf22301b..33e5c7e6198bb8fd79bce34bcb196524d280ccbd 100644 (file)
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
+#include <sys/socket.h>
 #include <arpa/nameser.h>
 #include <not-cancel.h>
 
index cb434ae1ece0a04fa1244ebb47569f5cc99363a8..1dbe57ba6cd58dda69a0fef87f99b0f96369332a 100644 (file)
@@ -23,6 +23,7 @@
 #include <unistd.h>
 #include <stdint.h>
 #include <sys/mman.h>
+#include <sys/socket.h>
 #include <kernel-features.h>
 #include <scratch_buffer.h>
 
index 91b587b5165f62df6e9256d8a746d98f7abbbba0..3dff017b79484f10a7f9f0baf0b24aec1800e36b 100644 (file)
@@ -25,6 +25,7 @@
 #include <resolv/resolv-internal.h>
 #include <resolv/resolv_context.h>
 #include <netdb.h>
+#include <sys/socket.h>
 #include <arpa/inet.h>
 #include "nsswitch.h"
 
index 92c5d9728d982d30cdd8e86906e5a8bd8a478fb7..cbd7f709dacd01a0bbcd2f8f46385c1178b7c96c 100644 (file)
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <assert.h>
+#include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <arpa/nameser.h>
index 6530d51c3b8496f322d436c60d71d268ee782d39..819d4aefbf7a03f61789c81cf21b87f185ad0b27 100644 (file)
@@ -16,6 +16,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <netdb.h>
index 9491fdf24dc7f0e8045f17d78cf39880d1567da8..d5db1df737fc2fe8a62d7aa7523fad9c492de3a9 100644 (file)
@@ -22,6 +22,7 @@
 #include <gnu/lib-names.h>
 #include <netdb.h>
 #include <nss.h>
+#include <sys/socket.h>
 #include <support/check.h>
 #include <support/check_nss.h>
 #include <support/namespace.h>
index 02723d9cc0daa5552371bb3863490d27ca295491..4860d31ee7c6810150a44e8b3742ce9b2efb2a05 100644 (file)
@@ -24,6 +24,7 @@
 #include <nss.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <sys/socket.h>
 #include <support/check.h>
 #include <support/check_nss.h>
 #include <support/namespace.h>
index 1863fff7cec5178901dbb755c0eaad0532bd87e0..10f6228349c60cfb5333fb41bcd4d0aae0a1d751 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <support/check.h>
 #include <support/check_nss.h>
 #include <support/namespace.h>
index 5077f311fcb57d61928d4e36291ec778a61a1c1c..1d1919971a5992cca889fb73e8af766f2bb286d8 100644 (file)
@@ -2,6 +2,7 @@
 #include <netdb.h>
 #include <stdio.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <arpa/inet.h>
 #include <arpa/nameser.h>
 
index 575e416dac199f2e588e3af130cff08350334287..91277fcb86843dce66a5c2615f94e04c4c774a4f 100644 (file)
@@ -25,6 +25,7 @@
 #include <features.h>
 
 #include <netinet/in.h>
+#include <bits/types/socklen_t.h>
 #include <bits/stdint-uintn.h>
 #ifdef __USE_MISC
 /* This is necessary to make this include file properly replace the
index 906a3a6b0635ba0c86b7fd547d3fcf6e1ca11e88..06f187f5ffadb74e7fc1a7e943ca8ba484936aeb 100644 (file)
@@ -65,6 +65,7 @@
 #include <stddef.h>
 
 #include "nsswitch.h"
+#include <sys/socket.h>
 #include <arpa/inet.h>
 #include <arpa/nameser.h>
 #include <resolv/resolv-internal.h>
index 08c50ef19ebc59f291536b41d5b38fc8a29c8d32..316d27fc9604cb22222fdd092b9eee0a2953c818 100644 (file)
@@ -23,6 +23,7 @@
 #include <libc-lock.h>
 #include <resolv-internal.h>
 #include <sys/stat.h>
+#include <sys/socket.h>
 #include <libc-symbols.h>
 
 /* _res._u._ext.__glibc_extension_index is used as an index into a
index 37170675c2c3c8e64c42451b585292214c997671..539b5eb0d4e9da97cc73205d48e47ea69e251d13 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <support/check.h>
 #include <support/check_nss.h>
 #include <support/resolv_test.h>
index 37e28284656f40253a4b09af2914f970f88920ca..c1e29cfec821dd7a68dc6919930561bc4b4efeae 100644 (file)
@@ -21,6 +21,7 @@
 #include <resolv.h>
 #include <stdio.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <support/check.h>
 #include <support/resolv_test.h>
 #include <support/xthread.h>
index f0de06306c20b1c59ea172058fef222ac9782f95..728fd25d7f105a992fd6a4f2db31b98b42e6f9ef 100644 (file)
@@ -3,6 +3,7 @@
 #include <netinet/in.h>
 #include <stdio.h>
 #include <string.h>
+#include <sys/socket.h>
 
 static int
 do_test (void)
index 71c679458a7941364f51237d7c09fb8df117c04f..7092143b07181744b31f0f5ac521194a3d96833b 100644 (file)
@@ -21,6 +21,7 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <support/check.h>
 #include <support/next_to_fault.h>
 #include <support/xunistd.h>
index 9e8ed7611c60e330e8c2ef724cbc2aae2051bb93..ff6ff13bac200a4be18793b3fc5fd175a6eeff31 100644 (file)
@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <support/check.h>
 #include <support/check_nss.h>
 #include <support/resolv_test.h>
index 2ad9ee382a7568bd6bd05730aaed924a16601c3e..deb1e3c5842c7f5e2060c74e54364faa0f3a725c 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <support/check.h>
 #include <support/check_nss.h>
 #include <support/format_nss.h>
index 90a94a50febb492e5fcd86936b4ed3ba99cf9207..c7ad3bd57da7e51533532ebd0b71e4f1bf282cef 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <resolv.h>
 #include <string.h>
+#include <sys/types.h>
 #include <support/check.h>
 #include <support/resolv_test.h>
 
index 4fbb3a056ce30a7c3c67ad0d62165d78b49a5cb8..597520398c93456b2aae265c478058843093348b 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <support/check.h>
 #include <support/resolv_test.h>
 #include <support/support.h>
index a91699c7112aee14d65e578aca1a8adedd138124..2bb5266829fca154f2aaef29f630bfedc43ce5bd 100644 (file)
@@ -19,6 +19,7 @@
 #include <netdb.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <support/check.h>
 #include <support/check_nss.h>
 #include <support/resolv_test.h>
index 5d161a452eb1fe632df1aa3b8e2030233c1da4cf..8b1b162d1b540a36d0e29e8131ff7db71bd35002 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <netdb.h>
 #include <stdlib.h>
+#include <sys/socket.h>
 #include <support/check.h>
 #include <support/check_nss.h>
 #include <support/resolv_test.h>
index 6379147a27838f0ffe7b67c78fa9d9edd29c6dee..545a0a2545f3c3da1569c2ea0123f9027f76e0d4 100644 (file)
@@ -19,6 +19,7 @@
 #include <resolv.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <support/check.h>
 #include <support/check_nss.h>
 #include <support/resolv_test.h>
index a3a874ef4b1483bc23ef1e7f46a653e897aff996..0b4c198cc7f48219554651d7028ea6a5646390c6 100644 (file)
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <support/check.h>
 #include <support/namespace.h>
 #include <support/resolv_test.h>
index f27e110afbf3e8b48aa78bd2a07cb2c1c52bf9e6..b2ec1dffa084975130564422d83391b4d0abc25b 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <array_length.h>
 #include <netdb.h>
+#include <sys/socket.h>
 #include <support/check.h>
 #include <support/check_nss.h>
 #include <support/resolv_test.h>
index 5e528bcc1a2f500584326a6c5c243e6a9ffd0a14..6004cede759eff09a136788a597ce5e70c04a08a 100755 (executable)
@@ -542,9 +542,6 @@ HEADER_ALLOWED_INCLUDES = {
     #          arpa/inet.h -> netinet/in.h
     "netdb.h":                     [ "netinet/in.h", "rpc/netdb.h" ],
     "arpa/inet.h":                 [ "netinet/in.h" ],
-    "net/if.h":                    [ "sys/socket.h" ],
-    "netinet/in.h":                [ "sys/socket.h" ],
-    "netinet/tcp.h":               [ "sys/socket.h" ],
 
     # Nonstandardized top-level headers
     "argp.h":                      [ "ctype.h", "errno.h", "getopt.h",
@@ -580,7 +577,6 @@ HEADER_ALLOWED_INCLUDES = {
     "sys/procfs.h":                [ "sys/ucontext.h", "sys/user.h" ],
     "sys/ptrace.h":                [ "sys/ucontext.h" ],
     "sys/raw.h":                   [ "sys/ioctl.h" ],
-    "sys/socketvar.h":             [ "sys/socket.h" ],
     "sys/timerfd.h":               [ "time.h" ],
     "sys/ttychars.h":              [ "sys/ttydefaults.h" ],
     "sys/ucontext.h":              [ "sys/procfs.h" ],
@@ -598,6 +594,7 @@ HEADER_ALLOWED_INCLUDES = {
     "sys/fcntl.h":                 [ "fcntl.h" ],
     "sys/poll.h":                  [ "poll.h" ],
     "sys/signal.h":                [ "signal.h" ],
+    "sys/socketvar.h":             [ "sys/socket.h" ],
     "sys/syslog.h":                [ "syslog.h" ],
     "sys/termios.h":               [ "termios.h" ],
     "sys/unistd.h":                [ "unistd.h" ],
@@ -606,18 +603,16 @@ HEADER_ALLOWED_INCLUDES = {
     "wait.h":                      [ "sys/wait.h" ],
 
     # Nonstandardized networking headers
-    "ifaddrs.h":                   [ "sys/socket.h" ],
 
     "resolv.h":                    [ "arpa/nameser.h", "netinet/in.h" ],
     "arpa/nameser.h":              [ "arpa/nameser_compat.h" ],
 
     "net/ethernet.h":              [ "net/if_ether.h" ],
-    "net/if_arp.h":                [ "sys/socket.h" ],
     "net/if_ppp.h":                [ "net/if.h", "net/ppp_defs.h",
                                      "sys/ioctl.h" ],
     "net/if_shaper.h":             [ "net/if.h", "sys/ioctl.h" ],
-    "net/route.h":                 [ "netinet/in.h", "sys/socket.h" ],
-    "netatalk/at.h":               [ "sys/socket.h", "sys/ioctl.h" ],
+    "net/route.h":                 [ "netinet/in.h" ],
+    "netatalk/at.h":               [ "sys/ioctl.h" ],
 
     "netinet/ether.h":             [ "netinet/if_ether.h" ],
     "netinet/icmp6.h":             [ "netinet/in.h" ],
@@ -629,7 +624,6 @@ HEADER_ALLOWED_INCLUDES = {
 
     "netrom/netrom.h":             [ "netax25/ax25.h" ],
     "netrose/rose.h":              [ "netax25/ax25.h" ],
-    "protocols/routed.h":          [ "sys/socket.h" ],
     "protocols/rwhod.h":           [ "paths.h" ],
 
     # Internal headers
index 125c042cab76a09b4c09b769d1779df991045db6..c63754812c898f40a490c1afd717ca42e51c5973 100644 (file)
@@ -22,9 +22,11 @@ subdir       := socket
 
 include ../Makeconfig
 
-headers        := sys/socket.h sys/un.h bits/sockaddr.h bits/socket.h \
-          bits/socket2.h bits/types/struct_osockaddr.h \
-          sys/socketvar.h net/if.h
+headers := net/if.h sys/socket.h sys/socketvar.h sys/un.h              \
+          bits/sockaddr.h bits/socket.h bits/socket2.h                 \
+          bits/types/struct_linger.h bits/types/struct_osockaddr.h     \
+          bits/types/struct_sockaddr.h                                 \
+          bits/types/struct_sockaddr_storage.h
 
 routines := accept bind connect getpeername getsockname getsockopt     \
            listen recv recvfrom recvmsg send sendmsg sendto            \
diff --git a/socket/bits/types/struct_linger.h b/socket/bits/types/struct_linger.h
new file mode 100644 (file)
index 0000000..58708e0
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef _BITS_TYPES_STRUCT_LINGER_H
+#define _BITS_TYPES_STRUCT_LINGER_H 1
+
+/* Structure used to manipulate the SO_LINGER option.  */
+struct linger
+  {
+    int l_onoff;               /* Nonzero to linger on close.  */
+    int l_linger;              /* Time to linger.  */
+  };
+
+#endif
diff --git a/socket/bits/types/struct_sockaddr.h b/socket/bits/types/struct_sockaddr.h
new file mode 100644 (file)
index 0000000..8610014
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef __struct_sockaddr_defined
+#define __struct_sockaddr_defined 1
+
+#include <bits/sockaddr.h>
+
+/* Structure describing a generic socket address.  For historical
+   reasons this type is smaller than many address families' concrete
+   socket addresses.  You may want struct sockaddr_storage instead.  */
+struct sockaddr
+  {
+    __SOCKADDR_COMMON (sa_);   /* Common data: family and perhaps length.  */
+    char sa_data[14];          /* Address data.  */
+  };
+
+#endif
diff --git a/socket/bits/types/struct_sockaddr_storage.h b/socket/bits/types/struct_sockaddr_storage.h
new file mode 100644 (file)
index 0000000..47e0513
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef __struct_sockaddr_storage_defined
+#define __struct_sockaddr_storage_defined 1
+
+#include <bits/sockaddr.h>
+
+/* Structure large enough to hold any socket address (with the historical
+   exception of AF_UNIX).  */
+#ifndef __ss_aligntype
+# define __ss_aligntype        unsigned long int
+#endif
+#define _SS_PADSIZE \
+  (_SS_SIZE - __SOCKADDR_COMMON_SIZE - sizeof (__ss_aligntype))
+
+struct sockaddr_storage
+  {
+    __SOCKADDR_COMMON (ss_);   /* Address family, etc.  */
+    char __ss_padding[_SS_PADSIZE];
+    __ss_aligntype __ss_align; /* Force desired alignment.  */
+  };
+
+#endif /* bits/types/struct_sockaddr_storage.h */
index 8431e000a2f9ff764e487c26b1a14ed744b05d0d..852fb8b04bb08c00a8c0f5cd70c998c04754b931 100644 (file)
@@ -32,7 +32,7 @@ struct if_nameindex
 
 
 #ifdef __USE_MISC
-# include <sys/socket.h>  /* for struct sockaddr */
+# include <bits/types/struct_sockaddr.h>
 
 /* Standard interface flags. */
 enum
index 6a68164e3956e67578002c4e2f8e7b0b3c942307..0725fcb6d9e2e6c7700a99f7c665c62a369c1778 100644 (file)
@@ -28,11 +28,11 @@ __BEGIN_DECLS
 #include <bits/types/ssize_t.h>
 #include <bits/types/socklen_t.h>
 #include <bits/types/struct_iovec.h>
+#include <bits/types/struct_linger.h>
 
-/* This operating system-specific header file defines the SOCK_*, PF_*,
-   AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr',
-   `struct msghdr', and `struct linger' types.  */
-#include <bits/socket.h>
+#include <bits/sockaddr.h>
+#include <bits/types/struct_sockaddr.h>
+#include <bits/types/struct_sockaddr_storage.h>
 
 #ifdef __USE_MISC
 # include <bits/types/struct_osockaddr.h>
@@ -42,6 +42,11 @@ __BEGIN_DECLS
 struct timespec;
 #endif
 
+/* This operating system-specific header file defines the SOCK_*, PF_*,
+   AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct msghdr' and
+   `struct cmsghdr' types.  */
+#include <bits/socket.h>
+
 /* The following constants should be used for the second parameter of
    `shutdown'.  */
 enum
index e838d25341e4b6b3f999d9098420da8e2e9fb2a0..24bbaa5d0cb8f065fff9a23089d9a55abc02d509 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <errno.h>
 #include <netdb.h>
+#include <sys/socket.h>
 #include <rpc/rpc.h>
 #include <scratch_buffer.h>
 #include <string.h>
index 29c7834ebe02b3e86d9014392200455538c65630..9ab206669a170ffa1f5312cea249d206b83e4092 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <support/format_nss.h>
 
+#include <sys/socket.h>
 #include <support/support.h>
 
 char *
index fa7d6acefc6c6dde0c2c84f1447247d2a5887286..c74aa53e7e767059c14bd2838ca5e036777d530b 100644 (file)
@@ -22,6 +22,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/socket.h>
 #include <support/support.h>
 #include <support/xmemstream.h>
 
index 918e70808eb30718aa7bd5f4c0e51f592fd8c235..8f599068834bb139730716681c6299ba1f57ec2a 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <support/format_nss.h>
 
+#include <sys/socket.h>
 #include <arpa/inet.h>
 #include <resolv.h>
 #include <stdbool.h>
index 108cd35de613471e7473288ede5585662b030397..5c90692caf2c22047c711d7e863427bd051e9431 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <support/format_nss.h>
 
+#include <sys/socket.h>
 #include <arpa/inet.h>
 #include <errno.h>
 #include <stdio.h>
index 9eea21a4ac423e5a91eff7bdf48e287fcb569775..388f8c0006f80bf06dbab59f092798df6fac468a 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <support/format_nss.h>
 
+#include <sys/socket.h>
 #include <arpa/inet.h>
 #include <stdio.h>
 #include <stdlib.h>
index 828a8efbf22c2eade727b19783d5cba1d1baac7b..56421de952023a8897cf3dd398e7dee10dfe5712 100644 (file)
 #endif
 
 
-#include <bits/types.h>
-#include <bits/types/size_t.h>
-#include <bits/types/socklen_t.h>
-#include <bits/wordsize.h>
-
 /* Types of sockets.  */
 enum __socket_type
 {
@@ -142,34 +137,6 @@ enum __socket_type
 /* Maximum queue length specifiable by listen.  */
 #define SOMAXCONN      128     /* 5 on the origional 4.4 BSD.  */
 
-/* Get the definition of the macro to define the common sockaddr members.  */
-#include <bits/sockaddr.h>
-
-/* Structure describing a generic socket address.  */
-struct sockaddr
-  {
-    __SOCKADDR_COMMON (sa_);   /* Common data: address family and length.  */
-    char sa_data[14];          /* Address data.  */
-  };
-
-
-/* Structure large enough to hold any socket address (with the historical
-   exception of AF_UNIX).  */
-#if __WORDSIZE == 64
-# define __ss_aligntype        __uint64_t
-#else
-# define __ss_aligntype        __uint32_t
-#endif
-#define _SS_PADSIZE \
-  (_SS_SIZE - __SOCKADDR_COMMON_SIZE - sizeof (__ss_aligntype))
-
-struct sockaddr_storage
-  {
-    __SOCKADDR_COMMON (ss_);   /* Address family, etc.  */
-    char __ss_padding[_SS_PADSIZE];
-    __ss_aligntype __ss_align; /* Force desired alignment.  */
-  };
-
 
 /* Bits in the FLAGS argument to `send', `recv', et al.  */
 enum
@@ -352,11 +319,4 @@ enum
 #define SO_TYPE SO_TYPE
   };
 
-/* Structure used to manipulate the SO_LINGER option.  */
-struct linger
-  {
-    int l_onoff;               /* Nonzero to linger on close.  */
-    int l_linger;              /* Time to linger.  */
-  };
-
 #endif /* bits/socket.h */
index 32dceccdbf62b65c095dfe0c957bdab79bdb319a..30b41ef396901af0d55bcf9ad26362054d73a26b 100644 (file)
@@ -19,6 +19,7 @@
 #include <error.h>
 #include <net/if.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
 
index 86dd2ffc3746418ff662896352213a858444c28e..a7e81a9b066b56df203c80eaba6dfdbd5586d15f 100644 (file)
@@ -23,7 +23,8 @@
 #define _NET_IF_ARP_H 1
 
 #include <features.h>
-#include <sys/socket.h>
+#include <bits/types.h>
+#include <bits/types/struct_sockaddr.h>
 
 __BEGIN_DECLS
 
index 8772461da510028ab781bd9350731e40f371494b..3e71e8915aa8401a1592f1258010aa23f52cbb8c 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <features.h>
 
-#include <sys/socket.h>
+#include <bits/types/struct_sockaddr.h>
 #include <netinet/in.h>
 
 
index e2719bbc9cede76f3d7e3ae0de2855bcaf455899..bb7ecffd1bd1110d8a25194fbba0ac251c59c358 100644 (file)
@@ -42,4 +42,13 @@ typedef unsigned char sa_family_t;
 /* Size of struct sockaddr_storage.  */
 #define _SS_SIZE 128
 
+/* Desired alignment for struct sockaddr_storage.  */
+#include <bits/types.h>
+#include <bits/wordsize.h>
+#if __WORDSIZE == 64
+# define __ss_aligntype __uint64_t
+#else
+# define __ss_aligntype __uint32_t
+#endif
+
 #endif /* bits/sockaddr.h */
index e85fb589ce2ea1c4cc4a05bd9ada9053f8e0154e..b7af054e414e17a39703675e327525d8275798cf 100644 (file)
 #endif
 
 
-#include <bits/types.h>
-#include <bits/types/size_t.h>
-#include <bits/types/socklen_t.h>
-
 /* Get the architecture-dependent definition of enum __socket_type.  */
 #include <bits/socket_type.h>
 
 /* Maximum queue length specifiable by listen.  */
 #define SOMAXCONN      4096
 
-/* Get the definition of the macro to define the common sockaddr members.  */
-#include <bits/sockaddr.h>
-
-/* Structure describing a generic socket address.  */
-struct sockaddr
-  {
-    __SOCKADDR_COMMON (sa_);   /* Common data: address family and length.  */
-    char sa_data[14];          /* Address data.  */
-  };
-
-
-/* Structure large enough to hold any socket address (with the historical
-   exception of AF_UNIX).  */
-#define __ss_aligntype unsigned long int
-#define _SS_PADSIZE \
-  (_SS_SIZE - __SOCKADDR_COMMON_SIZE - sizeof (__ss_aligntype))
-
-struct sockaddr_storage
-  {
-    __SOCKADDR_COMMON (ss_);   /* Address family, etc.  */
-    char __ss_padding[_SS_PADSIZE];
-    __ss_aligntype __ss_align; /* Force desired alignment.  */
-  };
-
 
 /* Bits in the FLAGS argument to `send', `recv', et al.  */
 enum
@@ -351,11 +323,4 @@ struct ucred
 # include <bits/socket-constants.h>
 #endif
 
-/* Structure used to manipulate the SO_LINGER option.  */
-struct linger
-  {
-    int l_onoff;               /* Nonzero to linger on close.  */
-    int l_linger;              /* Time to linger.  */
-  };
-
 #endif /* bits/socket.h */
index a2ee2ed42e6334efb146714ddcc5626711c97955..1ffaaa07a4b0b057c5a60d7e4b4d238e8aeb9f92 100644 (file)
@@ -27,6 +27,7 @@
 #include <unistd.h>
 #include <net/if.h>
 #include <net/if_arp.h>
+#include <sys/socket.h>
 #include <sys/ioctl.h>
 
 #include <asm/types.h>
index e99db3037d8e4789a9d847ece4cbe4d48b041d7e..f8cfb073d5d6e2b5d55900d2f42ef1f2a46cbc4c 100644 (file)
 #ifndef _BITS_ERRQUEUE_H
 #define _BITS_ERRQUEUE_H  1
 
-#include <sys/types.h>
-#include <sys/socket.h>
+#include <bits/types.h>
+#include <bits/types/struct_sockaddr.h>
 
 struct sock_extended_err
   {
-    uint32_t ee_errno;
-    uint8_t ee_origin;
-    uint8_t ee_type;
-    uint8_t ee_code;
-    uint8_t ee_pad;
-    uint32_t ee_info;
-    uint32_t ee_data;
+    __uint32_t ee_errno;
+    __uint8_t ee_origin;
+    __uint8_t ee_type;
+    __uint8_t ee_code;
+    __uint8_t ee_pad;
+    __uint32_t ee_info;
+    __uint32_t ee_data;
+    /* A socket address immediately follows.  */
   };
 
 #define SO_EE_ORIGIN_NONE  0
index bbaf95618026eb9114edd6a2e18a0419f6d4186b..83eac3107cf1c08f5afc29d518a6dea0cb346e68 100644 (file)
@@ -23,7 +23,8 @@
 #define _NET_IF_ARP_H 1
 
 #include <features.h>
-#include <sys/socket.h>
+#include <bits/types.h>
+#include <bits/types/struct_sockaddr.h>
 
 __BEGIN_DECLS
 
index 09819c9cae24caed780705a84f202f05b3e5023b..340d994f250a6310155033e0610903e15c196c81 100644 (file)
 
 #include <features.h>
 
-#include <sys/socket.h>
-#include <netinet/in.h>
+#include <bits/types.h>
+#include <bits/types/struct_sockaddr.h>
 #include <bits/wordsize.h>
 
+#include <netinet/in.h>
 
 /* This structure gets passed by the SIOCADDRT and SIOCDELRT calls. */
 struct rtentry
@@ -59,12 +60,12 @@ struct in6_rtmsg
     struct in6_addr rtmsg_dst;
     struct in6_addr rtmsg_src;
     struct in6_addr rtmsg_gateway;
-    uint32_t rtmsg_type;
-    uint16_t rtmsg_dst_len;
-    uint16_t rtmsg_src_len;
-    uint32_t rtmsg_metric;
+    __uint32_t rtmsg_type;
+    __uint16_t rtmsg_dst_len;
+    __uint16_t rtmsg_src_len;
+    __uint32_t rtmsg_metric;
     unsigned long int rtmsg_info;
-    uint32_t rtmsg_flags;
+    __uint32_t rtmsg_flags;
     int rtmsg_ifindex;
   };
 
@@ -113,7 +114,7 @@ struct in6_rtmsg
 #define RTF_NAT                0x08000000
 
 #define RTF_ADDRCLASSMASK      0xF8000000
-#define RT_ADDRCLASS(flags)    ((uint32_t) flags >> 23)
+#define RT_ADDRCLASS(flags)    ((__uint32_t) flags >> 23)
 
 #define RT_TOS(tos)            ((tos) & IPTOS_TOS_MASK)
 
index c4e33a8e42ab435dd71d7f3187ab2541cb37605d..bb5451ec2375eb10c8560c0078cb28a4ad3f2b6e 100644 (file)
@@ -22,8 +22,7 @@
 #include <bits/types.h>
 #include <bits/sockaddr.h>
 
-#include <sys/socket.h>
-#include <sys/ioctl.h>
+#include <sys/ioctl.h> /* for SIOCPROTOPRIVATE */
 
 /* Constants from linux/atalk.h as of kernel version 5.0.  */