4 # commit 6c82a2f8d7c8e21e39237225c819f182ae438db3
5 # Author: Carlos O'Donell <carlos@redhat.com>
6 # Date: Fri Sep 6 01:02:30 2013 -0400
8 # Coordinate IPv6 definitions for Linux and glibc
10 # This change synchronizes the glibc headers with the Linux kernel
11 # headers and arranges to coordinate the definition of structures
12 # already defined the Linux kernel UAPI headers.
14 # It is now safe to include glibc's netinet/in.h or Linux's linux/in6.h
15 # in any order in a userspace application and you will get the same
16 # ABI. The ABI is guaranteed by UAPI and glibc.
18 # 2013-09-05 Carlos O'Donell <carlos@redhat.com>
19 # Cong Wang <amwang@redhat.com>
21 # * sysdeps/unix/sysv/linux/bits/in.h
22 # [_UAPI_LINUX_IN6_H]: Define __USE_KERNEL_IPV6_DEFS.
23 # * inet/netinet/in.h: Move in_addr definition and bits/in.h inclusion
24 # before __USE_KERNEL_IPV6_DEFS uses.
25 # * inet/netinet/in.h [!__USE_KERNEL_IPV6_DEFS]: Define IPPROTO_MH, and
27 # [__USE_KERNEL_IPV6_DEFS]: Don't define any of IPPROTO_*, in6_addr,
28 # sockaddr_in6, or ipv6_mreq.
30 diff -urN glibc-2.12-2-gc4ccff1/inet/netinet/in.h glibc-2.12-2-gc4ccff1.mod/inet/netinet/in.h
31 --- glibc-2.12-2-gc4ccff1/inet/netinet/in.h 2010-05-04 07:27:23.000000000 -0400
32 +++ glibc-2.12-2-gc4ccff1.mod/inet/netinet/in.h 2015-02-18 13:06:56.436802873 -0500
37 +/* Internet address. */
38 +typedef uint32_t in_addr_t;
44 +/* Get system-specific definitions. */
47 /* Standard well-defined IP protocols. */
50 IPPROTO_IP = 0, /* Dummy protocol for TCP. */
51 #define IPPROTO_IP IPPROTO_IP
52 - IPPROTO_HOPOPTS = 0, /* IPv6 Hop-by-Hop options. */
53 -#define IPPROTO_HOPOPTS IPPROTO_HOPOPTS
54 IPPROTO_ICMP = 1, /* Internet Control Message Protocol. */
55 #define IPPROTO_ICMP IPPROTO_ICMP
56 IPPROTO_IGMP = 2, /* Internet Group Management Protocol. */
58 #define IPPROTO_DCCP IPPROTO_DCCP
59 IPPROTO_IPV6 = 41, /* IPv6 header. */
60 #define IPPROTO_IPV6 IPPROTO_IPV6
61 - IPPROTO_ROUTING = 43, /* IPv6 routing header. */
62 -#define IPPROTO_ROUTING IPPROTO_ROUTING
63 - IPPROTO_FRAGMENT = 44, /* IPv6 fragmentation header. */
64 -#define IPPROTO_FRAGMENT IPPROTO_FRAGMENT
65 IPPROTO_RSVP = 46, /* Reservation Protocol. */
66 #define IPPROTO_RSVP IPPROTO_RSVP
67 IPPROTO_GRE = 47, /* General Routing Encapsulation. */
69 #define IPPROTO_ESP IPPROTO_ESP
70 IPPROTO_AH = 51, /* authentication header. */
71 #define IPPROTO_AH IPPROTO_AH
72 - IPPROTO_ICMPV6 = 58, /* ICMPv6. */
73 -#define IPPROTO_ICMPV6 IPPROTO_ICMPV6
74 - IPPROTO_NONE = 59, /* IPv6 no next header. */
75 -#define IPPROTO_NONE IPPROTO_NONE
76 - IPPROTO_DSTOPTS = 60, /* IPv6 destination options. */
77 -#define IPPROTO_DSTOPTS IPPROTO_DSTOPTS
78 IPPROTO_MTP = 92, /* Multicast Transport Protocol. */
79 #define IPPROTO_MTP IPPROTO_MTP
80 + IPPROTO_BEETPH = 94, /* IP option pseudo header for BEET. */
81 +#define IPPROTO_BEETPH IPPROTO_BEETPH
82 IPPROTO_ENCAP = 98, /* Encapsulation Header. */
83 #define IPPROTO_ENCAP IPPROTO_ENCAP
84 IPPROTO_PIM = 103, /* Protocol Independent Multicast. */
89 +/* If __USER_KERNEL_IPV6_DEFS is defined then the user has included the kernel
90 + network headers first and we should use those ABI-identical definitions
91 + instead of our own. */
92 +#ifndef __USE_KERNEL_IPV6_DEFS
95 + IPPROTO_HOPOPTS = 0, /* IPv6 Hop-by-Hop options. */
96 +#define IPPROTO_HOPOPTS IPPROTO_HOPOPTS
97 + IPPROTO_ROUTING = 43, /* IPv6 routing header. */
98 +#define IPPROTO_ROUTING IPPROTO_ROUTING
99 + IPPROTO_FRAGMENT = 44, /* IPv6 fragmentation header. */
100 +#define IPPROTO_FRAGMENT IPPROTO_FRAGMENT
101 + IPPROTO_ICMPV6 = 58, /* ICMPv6. */
102 +#define IPPROTO_ICMPV6 IPPROTO_ICMPV6
103 + IPPROTO_NONE = 59, /* IPv6 no next header. */
104 +#define IPPROTO_NONE IPPROTO_NONE
105 + IPPROTO_DSTOPTS = 60, /* IPv6 destination options. */
106 +#define IPPROTO_DSTOPTS IPPROTO_DSTOPTS
107 + IPPROTO_MH = 135, /* IPv6 mobility header. */
108 +#define IPPROTO_MH IPPROTO_MH
110 +#endif /* !__USE_KERNEL_IPV6_DEFS */
112 /* Type to represent a port. */
113 typedef uint16_t in_port_t;
115 IPPORT_USERRESERVED = 5000
119 -/* Internet address. */
120 -typedef uint32_t in_addr_t;
127 /* Definitions of the bits in an Internet address integer.
129 On subnets, host and network parts are found according to
131 #define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002) /* 224.0.0.2 */
132 #define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */
135 +#ifndef __USE_KERNEL_IPV6_DEFS
140 # define s6_addr32 __in6_u.__u6_addr32
143 +#endif /* !__USE_KERNEL_IPV6_DEFS */
145 extern const struct in6_addr in6addr_any; /* :: */
146 extern const struct in6_addr in6addr_loopback; /* ::1 */
148 sizeof (struct in_addr)];
151 +#ifndef __USE_KERNEL_IPV6_DEFS
152 /* Ditto, for IPv6. */
156 struct in6_addr sin6_addr; /* IPv6 address */
157 uint32_t sin6_scope_id; /* IPv6 scope-id */
160 +#endif /* !__USE_KERNEL_IPV6_DEFS */
162 #if defined __USE_MISC || defined __USE_GNU
163 /* IPv4 multicast request. */
169 +#ifndef __USE_KERNEL_IPV6_DEFS
170 /* Likewise, for IPv6. */
174 /* local interface */
175 unsigned int ipv6mr_interface;
178 +#endif /* !__USE_KERNEL_IPV6_DEFS */
180 #if defined __USE_MISC || defined __USE_GNU
181 /* Multicast group request. */
183 * sizeof (struct sockaddr_storage)))
187 -/* Get system-specific definitions. */
188 -#include <bits/in.h>
190 /* Functions to convert between host and network byte order.
192 Please note that these functions normally take `unsigned long int' or
193 diff -urN glibc-2.12-2-gc4ccff1/sysdeps/unix/sysv/linux/bits/in.h glibc-2.12-2-gc4ccff1.mod/sysdeps/unix/sysv/linux/bits/in.h
194 --- glibc-2.12-2-gc4ccff1/sysdeps/unix/sysv/linux/bits/in.h 2015-02-18 13:04:15.547734092 -0500
195 +++ glibc-2.12-2-gc4ccff1.mod/sysdeps/unix/sysv/linux/bits/in.h 2015-02-18 13:06:56.436802873 -0500
197 # error "Never use <bits/in.h> directly; include <netinet/in.h> instead."
200 +/* If the application has already included linux/in6.h from a linux-based
201 + kernel then we will not define the IPv6 IPPROTO_* defines, in6_addr (nor the
202 + defines), sockaddr_in6, or ipv6_mreq. The ABI used by the linux-kernel and
203 + glibc match exactly. Neither the linux kernel nor glibc should break this
204 + ABI without coordination. */
205 +#ifdef _UAPI_LINUX_IN6_H
206 +/* This is not quite the same API since the kernel always defines s6_addr16 and
207 + s6_addr32. This is not a violation of POSIX since POSIX says "at least the
208 + following member" and that holds true. */
209 +# define __USE_KERNEL_IPV6_DEFS
212 /* Options for use with `getsockopt' and `setsockopt' at the IP level.
213 The first word in the comment at the right is the data type used;
214 "bool" means a boolean value stored in an `int'. */