]>
Commit | Line | Data |
---|---|---|
04277e02 | 1 | /* Copyright (C) 1991-2019 Free Software Foundation, Inc. |
0501d603 UD |
2 | This file is part of the GNU C Library. |
3 | ||
478b92f0 | 4 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either | |
7 | version 2.1 of the License, or (at your option) any later version. | |
0501d603 UD |
8 | |
9 | The GNU C Library is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
478b92f0 | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
41bdb6e2 | 12 | Lesser General Public License for more details. |
0501d603 | 13 | |
41bdb6e2 | 14 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
15 | License along with the GNU C Library; if not, see |
16 | <http://www.gnu.org/licenses/>. */ | |
0501d603 UD |
17 | |
18 | /* Linux version. */ | |
19 | ||
f4017d20 UD |
20 | #ifndef _NETINET_IN_H |
21 | # error "Never use <bits/in.h> directly; include <netinet/in.h> instead." | |
22 | #endif | |
0501d603 | 23 | |
6c82a2f8 CD |
24 | /* If the application has already included linux/in6.h from a linux-based |
25 | kernel then we will not define the IPv6 IPPROTO_* defines, in6_addr (nor the | |
cb43bb0d CW |
26 | defines), sockaddr_in6, or ipv6_mreq. Same for in6_ptkinfo or ip6_mtuinfo |
27 | in linux/ipv6.h. The ABI used by the linux-kernel and glibc match exactly. | |
c9bd40da CD |
28 | Neither the linux kernel nor glibc should break this ABI without coordination. |
29 | In upstream kernel 56c176c9 the _UAPI prefix was stripped so we need to check | |
30 | for _LINUX_IN6_H and _IPV6_H now, and keep checking the old versions for | |
31 | maximum backwards compatibility. */ | |
32 | #if defined _UAPI_LINUX_IN6_H \ | |
33 | || defined _UAPI_IPV6_H \ | |
34 | || defined _LINUX_IN6_H \ | |
35 | || defined _IPV6_H | |
6c82a2f8 CD |
36 | /* This is not quite the same API since the kernel always defines s6_addr16 and |
37 | s6_addr32. This is not a violation of POSIX since POSIX says "at least the | |
38 | following member" and that holds true. */ | |
1c1e7fb6 CD |
39 | # define __USE_KERNEL_IPV6_DEFS 1 |
40 | #else | |
41 | # define __USE_KERNEL_IPV6_DEFS 0 | |
6c82a2f8 CD |
42 | #endif |
43 | ||
0501d603 UD |
44 | /* Options for use with `getsockopt' and `setsockopt' at the IP level. |
45 | The first word in the comment at the right is the data type used; | |
46 | "bool" means a boolean value stored in an `int'. */ | |
b84515a1 RM |
47 | #define IP_OPTIONS 4 /* ip_opts; IP per-packet options. */ |
48 | #define IP_HDRINCL 3 /* int; Header is included with data. */ | |
49 | #define IP_TOS 1 /* int; IP type of service and precedence. */ | |
50 | #define IP_TTL 2 /* int; IP time to live. */ | |
51 | #define IP_RECVOPTS 6 /* bool; Receive all IP options w/datagram. */ | |
52 | /* For BSD compatibility. */ | |
53 | #define IP_RECVRETOPTS IP_RETOPTS /* bool; Receive IP options for response. */ | |
54 | #define IP_RETOPTS 7 /* ip_opts; Set/get IP per-packet options. */ | |
70682735 | 55 | #define IP_MULTICAST_IF 32 /* in_addr; set/get IP multicast i/f */ |
11160cb7 ZW |
56 | #define IP_MULTICAST_TTL 33 /* unsigned char; set/get IP multicast ttl */ |
57 | #define IP_MULTICAST_LOOP 34 /* bool; set/get IP multicast loopback */ | |
70682735 UD |
58 | #define IP_ADD_MEMBERSHIP 35 /* ip_mreq; add an IP group membership */ |
59 | #define IP_DROP_MEMBERSHIP 36 /* ip_mreq; drop an IP group membership */ | |
60 | #define IP_UNBLOCK_SOURCE 37 /* ip_mreq_source: unblock data from source */ | |
61 | #define IP_BLOCK_SOURCE 38 /* ip_mreq_source: block data from source */ | |
62 | #define IP_ADD_SOURCE_MEMBERSHIP 39 /* ip_mreq_source: join source group */ | |
63 | #define IP_DROP_SOURCE_MEMBERSHIP 40 /* ip_mreq_source: leave source group */ | |
64 | #define IP_MSFILTER 41 | |
acd7f096 | 65 | #ifdef __USE_MISC |
a53d3f82 UD |
66 | # define MCAST_JOIN_GROUP 42 /* group_req: join any-source group */ |
67 | # define MCAST_BLOCK_SOURCE 43 /* group_source_req: block from given group */ | |
68 | # define MCAST_UNBLOCK_SOURCE 44 /* group_source_req: unblock from given group*/ | |
69 | # define MCAST_LEAVE_GROUP 45 /* group_req: leave any-source group */ | |
70 | # define MCAST_JOIN_SOURCE_GROUP 46 /* group_source_req: join source-spec gr */ | |
71 | # define MCAST_LEAVE_SOURCE_GROUP 47 /* group_source_req: leave source-spec gr*/ | |
72 | # define MCAST_MSFILTER 48 | |
be08eda5 AJ |
73 | # define IP_MULTICAST_ALL 49 |
74 | # define IP_UNICAST_IF 50 | |
a53d3f82 UD |
75 | |
76 | # define MCAST_EXCLUDE 0 | |
77 | # define MCAST_INCLUDE 1 | |
78 | #endif | |
b84515a1 | 79 | |
d8c34cd1 UD |
80 | #define IP_ROUTER_ALERT 5 /* bool */ |
81 | #define IP_PKTINFO 8 /* bool */ | |
82 | #define IP_PKTOPTIONS 9 | |
83 | #define IP_PMTUDISC 10 /* obsolete name? */ | |
84 | #define IP_MTU_DISCOVER 10 /* int; see below */ | |
85 | #define IP_RECVERR 11 /* bool */ | |
86 | #define IP_RECVTTL 12 /* bool */ | |
87 | #define IP_RECVTOS 13 /* bool */ | |
88 | #define IP_MTU 14 /* int */ | |
89 | #define IP_FREEBIND 15 | |
90 | #define IP_IPSEC_POLICY 16 | |
91 | #define IP_XFRM_POLICY 17 | |
92 | #define IP_PASSSEC 18 | |
93 | #define IP_TRANSPARENT 19 | |
2840865d | 94 | #define IP_MULTICAST_ALL 49 /* bool */ |
d8c34cd1 UD |
95 | |
96 | /* TProxy original addresses */ | |
97 | #define IP_ORIGDSTADDR 20 | |
98 | #define IP_RECVORIGDSTADDR IP_ORIGDSTADDR | |
99 | ||
100 | #define IP_MINTTL 21 | |
7c70f227 | 101 | #define IP_NODEFRAG 22 |
31545c23 | 102 | #define IP_CHECKSUM 23 |
04d9a38b | 103 | #define IP_BIND_ADDRESS_NO_PORT 24 |
72aaa20b | 104 | #define IP_RECVFRAGSIZE 25 |
c10bb795 UD |
105 | |
106 | /* IP_MTU_DISCOVER arguments. */ | |
107 | #define IP_PMTUDISC_DONT 0 /* Never send DF frames. */ | |
108 | #define IP_PMTUDISC_WANT 1 /* Use per route hints. */ | |
109 | #define IP_PMTUDISC_DO 2 /* Always DF. */ | |
f081b451 | 110 | #define IP_PMTUDISC_PROBE 3 /* Ignore dst pmtu. */ |
7c70f227 MF |
111 | /* Always use interface mtu (ignores dst pmtu) but don't set DF flag. |
112 | Also incoming ICMP frag_needed notifications will be ignored on | |
113 | this socket to prevent accepting spoofed ones. */ | |
114 | #define IP_PMTUDISC_INTERFACE 4 | |
76e5216e JM |
115 | /* Like IP_PMTUDISC_INTERFACE but allow packets to be fragmented. */ |
116 | #define IP_PMTUDISC_OMIT 5 | |
7c70f227 MF |
117 | |
118 | #define IP_MULTICAST_IF 32 | |
119 | #define IP_MULTICAST_TTL 33 | |
120 | #define IP_MULTICAST_LOOP 34 | |
121 | #define IP_ADD_MEMBERSHIP 35 | |
122 | #define IP_DROP_MEMBERSHIP 36 | |
123 | #define IP_UNBLOCK_SOURCE 37 | |
124 | #define IP_BLOCK_SOURCE 38 | |
125 | #define IP_ADD_SOURCE_MEMBERSHIP 39 | |
126 | #define IP_DROP_SOURCE_MEMBERSHIP 40 | |
127 | #define IP_MSFILTER 41 | |
7c70f227 MF |
128 | #define IP_MULTICAST_ALL 49 |
129 | #define IP_UNICAST_IF 50 | |
c10bb795 | 130 | |
0501d603 UD |
131 | /* To select the IP level. */ |
132 | #define SOL_IP 0 | |
133 | ||
c10bb795 UD |
134 | #define IP_DEFAULT_MULTICAST_TTL 1 |
135 | #define IP_DEFAULT_MULTICAST_LOOP 1 | |
136 | #define IP_MAX_MEMBERSHIPS 20 | |
137 | ||
acd7f096 | 138 | #ifdef __USE_MISC |
b84515a1 RM |
139 | /* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS. |
140 | The `ip_dst' field is used for the first-hop gateway when using a | |
141 | source route (this gets put into the header proper). */ | |
0501d603 UD |
142 | struct ip_opts |
143 | { | |
144 | struct in_addr ip_dst; /* First hop; zero without source route. */ | |
145 | char ip_opts[40]; /* Actually variable in size. */ | |
146 | }; | |
147 | ||
8f73811b | 148 | /* Like `struct ip_mreq' but including interface specification by index. */ |
c10bb795 UD |
149 | struct ip_mreqn |
150 | { | |
151 | struct in_addr imr_multiaddr; /* IP multicast address of group */ | |
152 | struct in_addr imr_address; /* local IP address of interface */ | |
153 | int imr_ifindex; /* Interface index */ | |
154 | }; | |
155 | ||
ef5d6645 UD |
156 | /* Structure used for IP_PKTINFO. */ |
157 | struct in_pktinfo | |
158 | { | |
159 | int ipi_ifindex; /* Interface index */ | |
160 | struct in_addr ipi_spec_dst; /* Routing destination address */ | |
161 | struct in_addr ipi_addr; /* Header destination address */ | |
162 | }; | |
a53d3f82 | 163 | #endif |
ef5d6645 | 164 | |
c10bb795 UD |
165 | /* Options for use with `getsockopt' and `setsockopt' at the IPv6 level. |
166 | The first word in the comment at the right is the data type used; | |
167 | "bool" means a boolean value stored in an `int'. */ | |
0501d603 | 168 | #define IPV6_ADDRFORM 1 |
c2280dc0 UD |
169 | #define IPV6_2292PKTINFO 2 |
170 | #define IPV6_2292HOPOPTS 3 | |
171 | #define IPV6_2292DSTOPTS 4 | |
172 | #define IPV6_2292RTHDR 5 | |
173 | #define IPV6_2292PKTOPTIONS 6 | |
0501d603 | 174 | #define IPV6_CHECKSUM 7 |
c2280dc0 | 175 | #define IPV6_2292HOPLIMIT 8 |
b84515a1 RM |
176 | |
177 | #define SCM_SRCRT IPV6_RXSRCRT | |
178 | ||
c10bb795 UD |
179 | #define IPV6_NEXTHOP 9 |
180 | #define IPV6_AUTHHDR 10 | |
0501d603 UD |
181 | #define IPV6_UNICAST_HOPS 16 |
182 | #define IPV6_MULTICAST_IF 17 | |
183 | #define IPV6_MULTICAST_HOPS 18 | |
184 | #define IPV6_MULTICAST_LOOP 19 | |
e7c036b3 UD |
185 | #define IPV6_JOIN_GROUP 20 |
186 | #define IPV6_LEAVE_GROUP 21 | |
ec986e23 | 187 | #define IPV6_ROUTER_ALERT 22 |
ad483238 UD |
188 | #define IPV6_MTU_DISCOVER 23 |
189 | #define IPV6_MTU 24 | |
190 | #define IPV6_RECVERR 25 | |
2229b771 UD |
191 | #define IPV6_V6ONLY 26 |
192 | #define IPV6_JOIN_ANYCAST 27 | |
193 | #define IPV6_LEAVE_ANYCAST 28 | |
6ef3d225 | 194 | #define IPV6_MULTICAST_ALL 29 |
cf274686 | 195 | #define IPV6_ROUTER_ALERT_ISOLATE 30 |
2229b771 UD |
196 | #define IPV6_IPSEC_POLICY 34 |
197 | #define IPV6_XFRM_POLICY 35 | |
981569c7 | 198 | #define IPV6_HDRINCL 36 |
c10bb795 | 199 | |
1c1e3125 | 200 | /* Advanced API (RFC3542) (1). */ |
c2280dc0 UD |
201 | #define IPV6_RECVPKTINFO 49 |
202 | #define IPV6_PKTINFO 50 | |
203 | #define IPV6_RECVHOPLIMIT 51 | |
204 | #define IPV6_HOPLIMIT 52 | |
205 | #define IPV6_RECVHOPOPTS 53 | |
206 | #define IPV6_HOPOPTS 54 | |
207 | #define IPV6_RTHDRDSTOPTS 55 | |
208 | #define IPV6_RECVRTHDR 56 | |
209 | #define IPV6_RTHDR 57 | |
210 | #define IPV6_RECVDSTOPTS 58 | |
211 | #define IPV6_DSTOPTS 59 | |
1c1e3125 CD |
212 | #define IPV6_RECVPATHMTU 60 |
213 | #define IPV6_PATHMTU 61 | |
214 | #define IPV6_DONTFRAG 62 | |
c2280dc0 | 215 | |
1c1e3125 | 216 | /* Advanced API (RFC3542) (2). */ |
c2280dc0 UD |
217 | #define IPV6_RECVTCLASS 66 |
218 | #define IPV6_TCLASS 67 | |
219 | ||
53a4608f JM |
220 | #define IPV6_AUTOFLOWLABEL 70 |
221 | ||
222 | /* RFC5014. */ | |
223 | #define IPV6_ADDR_PREFERENCES 72 | |
224 | ||
225 | /* RFC5082. */ | |
226 | #define IPV6_MINHOPCOUNT 73 | |
227 | ||
228 | #define IPV6_ORIGDSTADDR 74 | |
229 | #define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR | |
230 | #define IPV6_TRANSPARENT 75 | |
231 | #define IPV6_UNICAST_IF 76 | |
232 | #define IPV6_RECVFRAGSIZE 77 | |
41376f8c | 233 | #define IPV6_FREEBIND 78 |
53a4608f | 234 | |
e7c036b3 | 235 | /* Obsolete synonyms for the above. */ |
c9bd40da CD |
236 | #if !__USE_KERNEL_IPV6_DEFS |
237 | # define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP | |
238 | # define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP | |
239 | #endif | |
b84515a1 RM |
240 | #define IPV6_RXHOPOPTS IPV6_HOPOPTS |
241 | #define IPV6_RXDSTOPTS IPV6_DSTOPTS | |
c10bb795 UD |
242 | |
243 | /* IPV6_MTU_DISCOVER values. */ | |
244 | #define IPV6_PMTUDISC_DONT 0 /* Never send DF frames. */ | |
245 | #define IPV6_PMTUDISC_WANT 1 /* Use per route hints. */ | |
246 | #define IPV6_PMTUDISC_DO 2 /* Always DF. */ | |
f081b451 | 247 | #define IPV6_PMTUDISC_PROBE 3 /* Ignore dst pmtu. */ |
76e5216e JM |
248 | #define IPV6_PMTUDISC_INTERFACE 4 /* See IP_PMTUDISC_INTERFACE. */ |
249 | #define IPV6_PMTUDISC_OMIT 5 /* See IP_PMTUDISC_OMIT. */ | |
c10bb795 UD |
250 | |
251 | /* Socket level values for IPv6. */ | |
252 | #define SOL_IPV6 41 | |
253 | #define SOL_ICMPV6 58 | |
bfaf0bbb UD |
254 | |
255 | /* Routing header options for IPv6. */ | |
256 | #define IPV6_RTHDR_LOOSE 0 /* Hop doesn't need to be neighbour. */ | |
257 | #define IPV6_RTHDR_STRICT 1 /* Hop must be a neighbour. */ | |
258 | ||
259 | #define IPV6_RTHDR_TYPE_0 0 /* IPv6 Routing header type 0. */ |