diff options
Diffstat (limited to 'inet')
-rw-r--r-- | inet/Makefile | 5 | ||||
-rw-r--r-- | inet/bits/types/in_addr_t.h | 9 | ||||
-rw-r--r-- | inet/bits/types/in_port_t.h | 9 | ||||
-rw-r--r-- | inet/bits/types/struct_in6_addr.h | 30 | ||||
-rw-r--r-- | inet/bits/types/struct_in_addr.h | 18 | ||||
-rw-r--r-- | inet/bits/types/struct_sockaddr_in.h | 28 | ||||
-rw-r--r-- | inet/bits/types/struct_sockaddr_in6.h | 25 | ||||
-rw-r--r-- | inet/netinet/icmp6.h | 2 | ||||
-rw-r--r-- | inet/netinet/igmp.h | 2 | ||||
-rw-r--r-- | inet/netinet/in.h | 102 | ||||
-rw-r--r-- | inet/netinet/ip.h | 2 | ||||
-rw-r--r-- | inet/netinet/ip6.h | 2 | ||||
-rw-r--r-- | inet/netinet/ip_icmp.h | 7 | ||||
-rw-r--r-- | inet/tst-getni1.c | 1 | ||||
-rw-r--r-- | inet/tst-getni2.c | 1 |
15 files changed, 169 insertions, 74 deletions
diff --git a/inet/Makefile b/inet/Makefile index ef12db0..9c47b33 100644 --- a/inet/Makefile +++ b/inet/Makefile @@ -22,7 +22,10 @@ subdir := inet include ../Makeconfig -headers := aliases.h ifaddrs.h bits/in.h \ +headers := aliases.h ifaddrs.h bits/in.h \ + bits/types/in_addr_t.h bits/types/in_port_t.h \ + bits/types/struct_in_addr.h bits/types/struct_in6_addr.h \ + bits/types/struct_sockaddr_in.h bits/types/struct_sockaddr_in6.h \ netinet/ether.h netinet/icmp6.h netinet/if_ether.h netinet/igmp.h \ netinet/in.h netinet/in_systm.h netinet/ip.h netinet/ip6.h \ netinet/ip_icmp.h netinet/tcp.h netinet/udp.h \ diff --git a/inet/bits/types/in_addr_t.h b/inet/bits/types/in_addr_t.h new file mode 100644 index 0000000..63779bb --- /dev/null +++ b/inet/bits/types/in_addr_t.h @@ -0,0 +1,9 @@ +#ifndef __in_addr_t_defined +#define __in_addr_t_defined 1 + +#include <bits/types.h> + +/* Type to represent an IPv4 address. */ +typedef __uint32_t in_addr_t; + +#endif diff --git a/inet/bits/types/in_port_t.h b/inet/bits/types/in_port_t.h new file mode 100644 index 0000000..8fa1a02 --- /dev/null +++ b/inet/bits/types/in_port_t.h @@ -0,0 +1,9 @@ +#ifndef __in_port_t_defined +#define __in_port_t_defined 1 + +#include <bits/types.h> + +/* Type to represent a TCP or UDP port. */ +typedef __uint16_t in_port_t; + +#endif diff --git a/inet/bits/types/struct_in6_addr.h b/inet/bits/types/struct_in6_addr.h new file mode 100644 index 0000000..5aaea39 --- /dev/null +++ b/inet/bits/types/struct_in6_addr.h @@ -0,0 +1,30 @@ +#ifndef __struct_in6_addr_defined +#define __struct_in6_addr_defined 1 + +#include <features.h> +#include <bits/types.h> +#include <bits/uapi-compat.h> + +/* Kernel headers may already have defined this type. */ +#if !defined __UAPI_DEF_IN6_ADDR || __UAPI_DEF_IN6_ADDR == 0 +#define __UAPI_DEF_IN6_ADDR 0 +#define __UAPI_DEF_IN6_ADDR_ALT 0 + +/* Struct representing an IPv6 address. */ +struct in6_addr +{ + union + { + __uint8_t __u6_addr8[16]; + __uint16_t __u6_addr16[8]; + __uint32_t __u6_addr32[4]; + } __in6_u; +#define s6_addr __in6_u.__u6_addr8 +#ifdef __USE_MISC +# define s6_addr16 __in6_u.__u6_addr16 +# define s6_addr32 __in6_u.__u6_addr32 +#endif +}; + +#endif /* __UAPI_DEF_IN6_ADDR is zero or not defined. */ +#endif /* struct_in6_addr.h. */ diff --git a/inet/bits/types/struct_in_addr.h b/inet/bits/types/struct_in_addr.h new file mode 100644 index 0000000..0dbe57f --- /dev/null +++ b/inet/bits/types/struct_in_addr.h @@ -0,0 +1,18 @@ +#ifndef __struct_in_addr_defined +#define __struct_in_addr_defined 1 + +#include <bits/types/in_addr_t.h> +#include <bits/uapi-compat.h> + +/* Kernel headers may already have defined this type. */ +#if !defined __UAPI_DEF_IN_ADDR || __UAPI_DEF_IN_ADDR == 0 +#define __UAPI_DEF_IN_ADDR 0 + +/* Struct representing an IPv4 address. */ +struct in_addr +{ + in_addr_t s_addr; +}; + +#endif /* __UAPI_DEF_IN_ADDR is zero or not defined. */ +#endif /* struct_in_addr.h. */ diff --git a/inet/bits/types/struct_sockaddr_in.h b/inet/bits/types/struct_sockaddr_in.h new file mode 100644 index 0000000..f2289eb --- /dev/null +++ b/inet/bits/types/struct_sockaddr_in.h @@ -0,0 +1,28 @@ +#ifndef __struct_sockaddr_in_defined +#define __struct_sockaddr_in_defined 1 + +#include <bits/types.h> +#include <bits/types/struct_in_addr.h> +#include <bits/types/in_port_t.h> +#include <bits/sockaddr.h> +#include <bits/uapi-compat.h> + +/* Kernel headers may already have defined this type. */ +#if !defined __UAPI_DEF_SOCKADDR_IN || __UAPI_DEF_SOCKADDR_IN == 0 +#define __UAPI_DEF_SOCKADDR_IN 0 + +/* Structure describing an IPv4 socket address. */ +struct sockaddr_in +{ + __SOCKADDR_COMMON (sin_); + in_port_t sin_port; /* Port number. */ + struct in_addr sin_addr; /* IPv4 address. */ + + /* Pad to size of `struct sockaddr'. */ + unsigned char sin_zero[__SOCKADDR_DATA_SIZE + - sizeof (in_port_t) + - sizeof (struct in_addr)]; +}; + +#endif /* __UAPI_DEF_SOCKADDR_IN is zero or not defined. */ +#endif /* struct_sockaddr_in.h. */ diff --git a/inet/bits/types/struct_sockaddr_in6.h b/inet/bits/types/struct_sockaddr_in6.h new file mode 100644 index 0000000..7af109f --- /dev/null +++ b/inet/bits/types/struct_sockaddr_in6.h @@ -0,0 +1,25 @@ +#ifndef __struct_sockaddr_in6_defined +#define __struct_sockaddr_in6_defined 1 + +#include <bits/types.h> +#include <bits/types/struct_in6_addr.h> +#include <bits/types/in_port_t.h> +#include <bits/sockaddr.h> +#include <bits/uapi-compat.h> + +/* Kernel headers may already have defined this type. */ +#if !defined __UAPI_DEF_SOCKADDR_IN6 || __UAPI_DEF_SOCKADDR_IN6 == 0 +#define __UAPI_DEF_SOCKADDR_IN6 0 + +/* Structure describing an IPv6 socket address. */ +struct sockaddr_in6 +{ + __SOCKADDR_COMMON (sin6_); + in_port_t sin6_port; /* Transport layer port # */ + uint32_t sin6_flowinfo; /* IPv6 flow information */ + struct in6_addr sin6_addr; /* IPv6 address */ + uint32_t sin6_scope_id; /* IPv6 scope-id */ +}; + +#endif /* __UAPI_DEF_SOCKADDR_IN6 is zero or not defined. */ +#endif /* struct_sockaddr_in6.h. */ diff --git a/inet/netinet/icmp6.h b/inet/netinet/icmp6.h index 2d1c70b..bb92eb9 100644 --- a/inet/netinet/icmp6.h +++ b/inet/netinet/icmp6.h @@ -22,7 +22,7 @@ #include <bits/endian.h> #include <bits/types.h> #include <bits/types/size_t.h> -#include <netinet/in.h> +#include <bits/types/struct_in6_addr.h> #define ICMP6_FILTER 1 diff --git a/inet/netinet/igmp.h b/inet/netinet/igmp.h index 9e6b3a8..7806440 100644 --- a/inet/netinet/igmp.h +++ b/inet/netinet/igmp.h @@ -22,8 +22,8 @@ #ifdef __USE_MISC -#include <netinet/in.h> #include <bits/types.h> +#include <bits/types/struct_in_addr.h> __BEGIN_DECLS diff --git a/inet/netinet/in.h b/inet/netinet/in.h index 8156881..c5869af 100644 --- a/inet/netinet/in.h +++ b/inet/netinet/in.h @@ -19,24 +19,28 @@ #define _NETINET_IN_H 1 #include <features.h> + #include <bits/types.h> #include <bits/stdint-uintn.h> #include <bits/sockaddr.h> +#include <bits/uapi-compat.h> + +#include <bits/types/in_addr_t.h> +#include <bits/types/in_port_t.h> +#include <bits/types/struct_in_addr.h> +#include <bits/types/struct_in6_addr.h> #include <bits/types/struct_sockaddr.h> +#include <bits/types/struct_sockaddr_in.h> +#include <bits/types/struct_sockaddr_in6.h> #include <bits/types/struct_sockaddr_storage.h> -__BEGIN_DECLS - -/* Internet address. */ -typedef uint32_t in_addr_t; -struct in_addr - { - in_addr_t s_addr; - }; - /* Get system-specific definitions. */ #include <bits/in.h> +__BEGIN_DECLS + +#if !defined __UAPI_DEF_IN_IPPROTO || __UAPI_DEF_IN_IPPROTO == 0 +#define __UAPI_DEF_IN_IPPROTO 0 /* Standard well-defined IP protocols. */ enum { @@ -92,11 +96,10 @@ enum #define IPPROTO_RAW IPPROTO_RAW IPPROTO_MAX }; +#endif -/* If __USE_KERNEL_IPV6_DEFS is 1 then the user has included the kernel - network headers first and we should use those ABI-identical definitions - instead of our own, otherwise 0. */ -#if !__USE_KERNEL_IPV6_DEFS +#if !defined __UAPI_DEF_IPPROTO_V6 || __UAPI_DEF_IPPROTO_V6 == 0 +#define __UAPI_DEF_IPPROTO_V6 0 enum { IPPROTO_HOPOPTS = 0, /* IPv6 Hop-by-Hop options. */ @@ -114,10 +117,7 @@ enum IPPROTO_MH = 135 /* IPv6 mobility header. */ #define IPPROTO_MH IPPROTO_MH }; -#endif /* !__USE_KERNEL_IPV6_DEFS */ - -/* Type to represent a port. */ -typedef uint16_t in_port_t; +#endif /* Standard well-known ports. */ enum @@ -153,7 +153,10 @@ enum IPPORT_ROUTESERVER = 520, /* Ports less than this value are reserved for privileged processes. */ +#ifndef IPPORT_RESERVED /* also defined in netdb.h */ IPPORT_RESERVED = 1024, +#define IPPORT_RESERVED IPPORT_RESERVED +#endif /* Ports greater this value are reserved for (non-privileged) servers. */ IPPORT_USERRESERVED = 5000 @@ -163,6 +166,8 @@ enum On subnets, host and network parts are found according to the subnet mask, not these masks. */ +#if !defined __UAPI_DEF_IN_CLASS || __UAPI_DEF_IN_CLASS == 0 +#define __UAPI_DEF_IN_CLASS 0 #define IN_CLASSA(a) ((((in_addr_t)(a)) & 0x80000000) == 0) #define IN_CLASSA_NET 0xff000000 @@ -200,6 +205,7 @@ enum #ifndef INADDR_LOOPBACK # define INADDR_LOOPBACK ((in_addr_t) 0x7f000001) /* Inet 127.0.0.1. */ #endif +#define IN_LOOPBACK(a) ((((in_addr_t) (a)) & 0xff000000) == 0x7f000000) /* Defines for Multicast INADDR. */ #define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000) /* 224.0.0.0 */ @@ -207,24 +213,7 @@ enum #define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002) /* 224.0.0.2 */ #define INADDR_ALLSNOOPERS_GROUP ((in_addr_t) 0xe000006a) /* 224.0.0.106 */ #define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */ - -#if !__USE_KERNEL_IPV6_DEFS -/* IPv6 address */ -struct in6_addr - { - union - { - uint8_t __u6_addr8[16]; - uint16_t __u6_addr16[8]; - uint32_t __u6_addr32[4]; - } __in6_u; -#define s6_addr __in6_u.__u6_addr8 -#ifdef __USE_MISC -# define s6_addr16 __in6_u.__u6_addr16 -# define s6_addr32 __in6_u.__u6_addr32 -#endif - }; -#endif /* !__USE_KERNEL_IPV6_DEFS */ +#endif /* __UAPI_DEF_IN_CLASS is zero or not defined */ extern const struct in6_addr in6addr_any; /* :: */ extern const struct in6_addr in6addr_loopback; /* ::1 */ @@ -234,34 +223,9 @@ extern const struct in6_addr in6addr_loopback; /* ::1 */ #define INET_ADDRSTRLEN 16 #define INET6_ADDRSTRLEN 46 - -/* Structure describing an Internet socket address. */ -struct sockaddr_in - { - __SOCKADDR_COMMON (sin_); - in_port_t sin_port; /* Port number. */ - struct in_addr sin_addr; /* Internet address. */ - - /* Pad to size of `struct sockaddr'. */ - unsigned char sin_zero[sizeof (struct sockaddr) - - __SOCKADDR_COMMON_SIZE - - sizeof (in_port_t) - - sizeof (struct in_addr)]; - }; - -#if !__USE_KERNEL_IPV6_DEFS -/* Ditto, for IPv6. */ -struct sockaddr_in6 - { - __SOCKADDR_COMMON (sin6_); - in_port_t sin6_port; /* Transport layer port # */ - uint32_t sin6_flowinfo; /* IPv6 flow information */ - struct in6_addr sin6_addr; /* IPv6 address */ - uint32_t sin6_scope_id; /* IPv6 scope-id */ - }; -#endif /* !__USE_KERNEL_IPV6_DEFS */ - #ifdef __USE_MISC +#if !defined __UAPI_DEF_IP_MREQ || __UAPI_DEF_IP_MREQ == 0 +#define __UAPI_DEF_IP_MREQ 0 /* IPv4 multicast request. */ struct ip_mreq { @@ -284,8 +248,10 @@ struct ip_mreq_source struct in_addr imr_sourceaddr; }; #endif +#endif -#if !__USE_KERNEL_IPV6_DEFS +#if !defined __UAPI_DEF_IPV6_MREQ || __UAPI_DEF_IP_MREQ == 0 +#define __UAPI_DEF_IPV6_MREQ 0 /* Likewise, for IPv6. */ struct ipv6_mreq { @@ -295,7 +261,7 @@ struct ipv6_mreq /* local interface */ unsigned int ipv6mr_interface; }; -#endif /* !__USE_KERNEL_IPV6_DEFS */ +#endif #ifdef __USE_MISC /* Multicast group request. */ @@ -533,21 +499,25 @@ extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in) #ifdef __USE_GNU struct cmsghdr; /* Forward declaration. */ -#if !__USE_KERNEL_IPV6_DEFS +#if !defined __UAPI_DEF_IN6_PKTINFO || __UAPI_DEF_IN6_PKTINFO == 0 +#define __UAPI_DEF_IN6_PKTINFO 0 /* IPv6 packet information. */ struct in6_pktinfo { struct in6_addr ipi6_addr; /* src/dst IPv6 address */ unsigned int ipi6_ifindex; /* send/recv interface index */ }; +#endif +#if !defined __UAPI_DEF_IN6_MTUINFO || __UAPI_DEF_IN6_MTUINFO == 0 +#define __UAPI_DEF_IN6_MTUINFO 0 /* IPv6 MTU information. */ struct ip6_mtuinfo { struct sockaddr_in6 ip6m_addr; /* dst address including zone ID */ uint32_t ip6m_mtu; /* path MTU in host byte order */ }; -#endif /* !__USE_KERNEL_IPV6_DEFS */ +#endif /* Obsolete hop-by-hop and Destination Options Processing (RFC 2292). */ extern int inet6_option_space (int __nbytes) diff --git a/inet/netinet/ip.h b/inet/netinet/ip.h index 9184b34..a0b2b2d 100644 --- a/inet/netinet/ip.h +++ b/inet/netinet/ip.h @@ -20,9 +20,9 @@ #include <features.h> -#include <netinet/in.h> #include <bits/endian.h> #include <bits/types.h> +#include <bits/types/struct_in_addr.h> __BEGIN_DECLS diff --git a/inet/netinet/ip6.h b/inet/netinet/ip6.h index 387a33c..4678d47 100644 --- a/inet/netinet/ip6.h +++ b/inet/netinet/ip6.h @@ -19,9 +19,9 @@ #define _NETINET_IP6_H 1 #include <features.h> -#include <netinet/in.h> #include <bits/endian.h> #include <bits/types.h> +#include <bits/types/struct_in6_addr.h> struct ip6_hdr { diff --git a/inet/netinet/ip_icmp.h b/inet/netinet/ip_icmp.h index ae2d37c..fb50d81 100644 --- a/inet/netinet/ip_icmp.h +++ b/inet/netinet/ip_icmp.h @@ -20,6 +20,10 @@ #include <features.h> #include <bits/types.h> +#ifdef __USE_MISC +#include <bits/types/struct_in_addr.h> +#include <netinet/ip.h> +#endif __BEGIN_DECLS @@ -122,9 +126,6 @@ struct icmphdr * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 */ -#include <netinet/in.h> -#include <netinet/ip.h> - /* * Internal of an ICMP Router Advertisement */ diff --git a/inet/tst-getni1.c b/inet/tst-getni1.c index 3960f71..154ee20 100644 --- a/inet/tst-getni1.c +++ b/inet/tst-getni1.c @@ -1,6 +1,7 @@ #include <netdb.h> #include <stdio.h> #include <sys/socket.h> +#include <netinet/in.h> static int do_test (void) diff --git a/inet/tst-getni2.c b/inet/tst-getni2.c index 66e7806..0811e40 100644 --- a/inet/tst-getni2.c +++ b/inet/tst-getni2.c @@ -1,6 +1,7 @@ #include <netdb.h> #include <stdio.h> #include <sys/socket.h> +#include <netinet/in.h> static int do_test (void) |