xref: /linux/include/uapi/linux/in6.h (revision 87adedeba51a822533649b143232418b9e26d08b)
1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2607ca46eSDavid Howells /*
3607ca46eSDavid Howells  *	Types and definitions for AF_INET6
4607ca46eSDavid Howells  *	Linux INET6 implementation
5607ca46eSDavid Howells  *
6607ca46eSDavid Howells  *	Authors:
7607ca46eSDavid Howells  *	Pedro Roque		<roque@di.fc.ul.pt>
8607ca46eSDavid Howells  *
9607ca46eSDavid Howells  *	Sources:
10607ca46eSDavid Howells  *	IPv6 Program Interfaces for BSD Systems
11607ca46eSDavid Howells  *      <draft-ietf-ipngwg-bsd-api-05.txt>
12607ca46eSDavid Howells  *
13607ca46eSDavid Howells  *	Advanced Sockets API for IPv6
14607ca46eSDavid Howells  *	<draft-stevens-advanced-api-00.txt>
15607ca46eSDavid Howells  *
16607ca46eSDavid Howells  *	This program is free software; you can redistribute it and/or
17607ca46eSDavid Howells  *      modify it under the terms of the GNU General Public License
18607ca46eSDavid Howells  *      as published by the Free Software Foundation; either version
19607ca46eSDavid Howells  *      2 of the License, or (at your option) any later version.
20607ca46eSDavid Howells  */
21607ca46eSDavid Howells 
22607ca46eSDavid Howells #ifndef _UAPI_LINUX_IN6_H
23607ca46eSDavid Howells #define _UAPI_LINUX_IN6_H
24607ca46eSDavid Howells 
25607ca46eSDavid Howells #include <linux/types.h>
26cfd280c9SCarlos O'Donell #include <linux/libc-compat.h>
27607ca46eSDavid Howells 
28607ca46eSDavid Howells /*
29607ca46eSDavid Howells  *	IPv6 address structure
30607ca46eSDavid Howells  */
31607ca46eSDavid Howells 
32cfd280c9SCarlos O'Donell #if __UAPI_DEF_IN6_ADDR
33607ca46eSDavid Howells struct in6_addr {
34607ca46eSDavid Howells 	union {
35607ca46eSDavid Howells 		__u8		u6_addr8[16];
36cfd280c9SCarlos O'Donell #if __UAPI_DEF_IN6_ADDR_ALT
37607ca46eSDavid Howells 		__be16		u6_addr16[8];
38607ca46eSDavid Howells 		__be32		u6_addr32[4];
39cfd280c9SCarlos O'Donell #endif
40607ca46eSDavid Howells 	} in6_u;
41607ca46eSDavid Howells #define s6_addr			in6_u.u6_addr8
42cfd280c9SCarlos O'Donell #if __UAPI_DEF_IN6_ADDR_ALT
43607ca46eSDavid Howells #define s6_addr16		in6_u.u6_addr16
44607ca46eSDavid Howells #define s6_addr32		in6_u.u6_addr32
45cfd280c9SCarlos O'Donell #endif
46607ca46eSDavid Howells };
47cfd280c9SCarlos O'Donell #endif /* __UAPI_DEF_IN6_ADDR */
48607ca46eSDavid Howells 
49cfd280c9SCarlos O'Donell #if __UAPI_DEF_SOCKADDR_IN6
50607ca46eSDavid Howells struct sockaddr_in6 {
51607ca46eSDavid Howells 	unsigned short int	sin6_family;    /* AF_INET6 */
52607ca46eSDavid Howells 	__be16			sin6_port;      /* Transport layer port # */
53607ca46eSDavid Howells 	__be32			sin6_flowinfo;  /* IPv6 flow information */
54607ca46eSDavid Howells 	struct in6_addr		sin6_addr;      /* IPv6 address */
55607ca46eSDavid Howells 	__u32			sin6_scope_id;  /* scope id (new in RFC2553) */
56607ca46eSDavid Howells };
57cfd280c9SCarlos O'Donell #endif /* __UAPI_DEF_SOCKADDR_IN6 */
58607ca46eSDavid Howells 
59cfd280c9SCarlos O'Donell #if __UAPI_DEF_IPV6_MREQ
60607ca46eSDavid Howells struct ipv6_mreq {
61607ca46eSDavid Howells 	/* IPv6 multicast address of group */
62607ca46eSDavid Howells 	struct in6_addr ipv6mr_multiaddr;
63607ca46eSDavid Howells 
64607ca46eSDavid Howells 	/* local IPv6 address of interface */
65607ca46eSDavid Howells 	int		ipv6mr_ifindex;
66607ca46eSDavid Howells };
67cfd280c9SCarlos O'Donell #endif /* __UAPI_DEF_IVP6_MREQ */
68607ca46eSDavid Howells 
69607ca46eSDavid Howells #define ipv6mr_acaddr	ipv6mr_multiaddr
70607ca46eSDavid Howells 
71607ca46eSDavid Howells struct in6_flowlabel_req {
72607ca46eSDavid Howells 	struct in6_addr	flr_dst;
73607ca46eSDavid Howells 	__be32	flr_label;
74607ca46eSDavid Howells 	__u8	flr_action;
75607ca46eSDavid Howells 	__u8	flr_share;
76607ca46eSDavid Howells 	__u16	flr_flags;
77607ca46eSDavid Howells 	__u16 	flr_expires;
78607ca46eSDavid Howells 	__u16	flr_linger;
79607ca46eSDavid Howells 	__u32	__flr_pad;
80607ca46eSDavid Howells 	/* Options in format of IPV6_PKTOPTIONS */
81607ca46eSDavid Howells };
82607ca46eSDavid Howells 
83607ca46eSDavid Howells #define IPV6_FL_A_GET	0
84607ca46eSDavid Howells #define IPV6_FL_A_PUT	1
85607ca46eSDavid Howells #define IPV6_FL_A_RENEW	2
86607ca46eSDavid Howells 
87607ca46eSDavid Howells #define IPV6_FL_F_CREATE	1
88607ca46eSDavid Howells #define IPV6_FL_F_EXCL		2
89df3687ffSFlorent Fourcot #define IPV6_FL_F_REFLECT	4
9046e5f401SFlorent Fourcot #define IPV6_FL_F_REMOTE	8
91607ca46eSDavid Howells 
92607ca46eSDavid Howells #define IPV6_FL_S_NONE		0
93607ca46eSDavid Howells #define IPV6_FL_S_EXCL		1
94607ca46eSDavid Howells #define IPV6_FL_S_PROCESS	2
95607ca46eSDavid Howells #define IPV6_FL_S_USER		3
96607ca46eSDavid Howells #define IPV6_FL_S_ANY		255
97607ca46eSDavid Howells 
98607ca46eSDavid Howells 
99607ca46eSDavid Howells /*
100607ca46eSDavid Howells  *	Bitmask constant declarations to help applications select out the
101607ca46eSDavid Howells  *	flow label and priority fields.
102607ca46eSDavid Howells  *
103607ca46eSDavid Howells  *	Note that this are in host byte order while the flowinfo field of
104607ca46eSDavid Howells  *	sockaddr_in6 is in network byte order.
105607ca46eSDavid Howells  */
106607ca46eSDavid Howells 
107607ca46eSDavid Howells #define IPV6_FLOWINFO_FLOWLABEL		0x000fffff
108607ca46eSDavid Howells #define IPV6_FLOWINFO_PRIORITY		0x0ff00000
109607ca46eSDavid Howells 
110607ca46eSDavid Howells /* These definitions are obsolete */
111607ca46eSDavid Howells #define IPV6_PRIORITY_UNCHARACTERIZED	0x0000
112607ca46eSDavid Howells #define IPV6_PRIORITY_FILLER		0x0100
113607ca46eSDavid Howells #define IPV6_PRIORITY_UNATTENDED	0x0200
114607ca46eSDavid Howells #define IPV6_PRIORITY_RESERVED1		0x0300
115607ca46eSDavid Howells #define IPV6_PRIORITY_BULK		0x0400
116607ca46eSDavid Howells #define IPV6_PRIORITY_RESERVED2		0x0500
117607ca46eSDavid Howells #define IPV6_PRIORITY_INTERACTIVE	0x0600
118607ca46eSDavid Howells #define IPV6_PRIORITY_CONTROL		0x0700
119607ca46eSDavid Howells #define IPV6_PRIORITY_8			0x0800
120607ca46eSDavid Howells #define IPV6_PRIORITY_9			0x0900
121607ca46eSDavid Howells #define IPV6_PRIORITY_10		0x0a00
122607ca46eSDavid Howells #define IPV6_PRIORITY_11		0x0b00
123607ca46eSDavid Howells #define IPV6_PRIORITY_12		0x0c00
124607ca46eSDavid Howells #define IPV6_PRIORITY_13		0x0d00
125607ca46eSDavid Howells #define IPV6_PRIORITY_14		0x0e00
126607ca46eSDavid Howells #define IPV6_PRIORITY_15		0x0f00
127607ca46eSDavid Howells 
128607ca46eSDavid Howells /*
129607ca46eSDavid Howells  *	IPV6 extension headers
130607ca46eSDavid Howells  */
131cfd280c9SCarlos O'Donell #if __UAPI_DEF_IPPROTO_V6
132ee262ad8SJan Moskyto Matejka #define IPPROTO_HOPOPTS		0	/* IPv6 hop-by-hop options	*/
133ee262ad8SJan Moskyto Matejka #define IPPROTO_ROUTING		43	/* IPv6 routing header		*/
134ee262ad8SJan Moskyto Matejka #define IPPROTO_FRAGMENT	44	/* IPv6 fragmentation header	*/
135ee262ad8SJan Moskyto Matejka #define IPPROTO_ICMPV6		58	/* ICMPv6			*/
136ee262ad8SJan Moskyto Matejka #define IPPROTO_NONE		59	/* IPv6 no next header		*/
137ee262ad8SJan Moskyto Matejka #define IPPROTO_DSTOPTS		60	/* IPv6 destination options	*/
138ee262ad8SJan Moskyto Matejka #define IPPROTO_MH		135	/* IPv6 mobility header		*/
139cfd280c9SCarlos O'Donell #endif /* __UAPI_DEF_IPPROTO_V6 */
140607ca46eSDavid Howells 
141607ca46eSDavid Howells /*
142607ca46eSDavid Howells  *	IPv6 TLV options.
143607ca46eSDavid Howells  */
144607ca46eSDavid Howells #define IPV6_TLV_PAD1		0
145607ca46eSDavid Howells #define IPV6_TLV_PADN		1
146607ca46eSDavid Howells #define IPV6_TLV_ROUTERALERT	5
147ceba1832SHuw Davies #define IPV6_TLV_CALIPSO	7	/* RFC 5570 */
148*6a200864SJustin Iurman #define IPV6_TLV_IOAM		49	/* RFC 9486 */
149607ca46eSDavid Howells #define IPV6_TLV_JUMBO		194
150607ca46eSDavid Howells #define IPV6_TLV_HAO		201	/* home address option */
151607ca46eSDavid Howells 
152607ca46eSDavid Howells /*
153607ca46eSDavid Howells  *	IPV6 socket options
154607ca46eSDavid Howells  */
1556d08acd2Sstephen hemminger #if __UAPI_DEF_IPV6_OPTIONS
156607ca46eSDavid Howells #define IPV6_ADDRFORM		1
157607ca46eSDavid Howells #define IPV6_2292PKTINFO	2
158607ca46eSDavid Howells #define IPV6_2292HOPOPTS	3
159607ca46eSDavid Howells #define IPV6_2292DSTOPTS	4
160607ca46eSDavid Howells #define IPV6_2292RTHDR		5
161607ca46eSDavid Howells #define IPV6_2292PKTOPTIONS	6
162607ca46eSDavid Howells #define IPV6_CHECKSUM		7
163607ca46eSDavid Howells #define IPV6_2292HOPLIMIT	8
164607ca46eSDavid Howells #define IPV6_NEXTHOP		9
165607ca46eSDavid Howells #define IPV6_AUTHHDR		10	/* obsolete */
166607ca46eSDavid Howells #define IPV6_FLOWINFO		11
167607ca46eSDavid Howells 
168607ca46eSDavid Howells #define IPV6_UNICAST_HOPS	16
169607ca46eSDavid Howells #define IPV6_MULTICAST_IF	17
170607ca46eSDavid Howells #define IPV6_MULTICAST_HOPS	18
171607ca46eSDavid Howells #define IPV6_MULTICAST_LOOP	19
172607ca46eSDavid Howells #define IPV6_ADD_MEMBERSHIP	20
173607ca46eSDavid Howells #define IPV6_DROP_MEMBERSHIP	21
174607ca46eSDavid Howells #define IPV6_ROUTER_ALERT	22
175607ca46eSDavid Howells #define IPV6_MTU_DISCOVER	23
176607ca46eSDavid Howells #define IPV6_MTU		24
177607ca46eSDavid Howells #define IPV6_RECVERR		25
178607ca46eSDavid Howells #define IPV6_V6ONLY		26
179607ca46eSDavid Howells #define IPV6_JOIN_ANYCAST	27
180607ca46eSDavid Howells #define IPV6_LEAVE_ANYCAST	28
18115033f04SAndre Naujoks #define IPV6_MULTICAST_ALL	29
1829036b2feSFrancesco Ruggeri #define IPV6_ROUTER_ALERT_ISOLATE	30
18301370434SWillem de Bruijn #define IPV6_RECVERR_RFC4884	31
184607ca46eSDavid Howells 
185607ca46eSDavid Howells /* IPV6_MTU_DISCOVER values */
186607ca46eSDavid Howells #define IPV6_PMTUDISC_DONT		0
187607ca46eSDavid Howells #define IPV6_PMTUDISC_WANT		1
188607ca46eSDavid Howells #define IPV6_PMTUDISC_DO		2
189607ca46eSDavid Howells #define IPV6_PMTUDISC_PROBE		3
19093b36cf3SHannes Frederic Sowa /* same as IPV6_PMTUDISC_PROBE, provided for symetry with IPv4
19193b36cf3SHannes Frederic Sowa  * also see comments on IP_PMTUDISC_INTERFACE
19293b36cf3SHannes Frederic Sowa  */
19393b36cf3SHannes Frederic Sowa #define IPV6_PMTUDISC_INTERFACE		4
1940b95227aSHannes Frederic Sowa /* weaker version of IPV6_PMTUDISC_INTERFACE, which allows packets to
1950b95227aSHannes Frederic Sowa  * get fragmented if they exceed the interface mtu
1960b95227aSHannes Frederic Sowa  */
1970b95227aSHannes Frederic Sowa #define IPV6_PMTUDISC_OMIT		5
198607ca46eSDavid Howells 
199607ca46eSDavid Howells /* Flowlabel */
200607ca46eSDavid Howells #define IPV6_FLOWLABEL_MGR	32
201607ca46eSDavid Howells #define IPV6_FLOWINFO_SEND	33
202607ca46eSDavid Howells 
203607ca46eSDavid Howells #define IPV6_IPSEC_POLICY	34
204607ca46eSDavid Howells #define IPV6_XFRM_POLICY	35
205715f504bSHannes Frederic Sowa #define IPV6_HDRINCL		36
2066d08acd2Sstephen hemminger #endif
207607ca46eSDavid Howells 
208607ca46eSDavid Howells /*
209607ca46eSDavid Howells  * Multicast:
210607ca46eSDavid Howells  * Following socket options are shared between IPv4 and IPv6.
211607ca46eSDavid Howells  *
212607ca46eSDavid Howells  * MCAST_JOIN_GROUP		42
213607ca46eSDavid Howells  * MCAST_BLOCK_SOURCE		43
214607ca46eSDavid Howells  * MCAST_UNBLOCK_SOURCE		44
215607ca46eSDavid Howells  * MCAST_LEAVE_GROUP		45
216607ca46eSDavid Howells  * MCAST_JOIN_SOURCE_GROUP	46
217607ca46eSDavid Howells  * MCAST_LEAVE_SOURCE_GROUP	47
218607ca46eSDavid Howells  * MCAST_MSFILTER		48
219607ca46eSDavid Howells  */
220607ca46eSDavid Howells 
221607ca46eSDavid Howells /*
222607ca46eSDavid Howells  * Advanced API (RFC3542) (1)
223607ca46eSDavid Howells  *
224607ca46eSDavid Howells  * Note: IPV6_RECVRTHDRDSTOPTS does not exist. see net/ipv6/datagram.c.
225607ca46eSDavid Howells  */
226607ca46eSDavid Howells 
227607ca46eSDavid Howells #define IPV6_RECVPKTINFO	49
228607ca46eSDavid Howells #define IPV6_PKTINFO		50
229607ca46eSDavid Howells #define IPV6_RECVHOPLIMIT	51
230607ca46eSDavid Howells #define IPV6_HOPLIMIT		52
231607ca46eSDavid Howells #define IPV6_RECVHOPOPTS	53
232607ca46eSDavid Howells #define IPV6_HOPOPTS		54
233607ca46eSDavid Howells #define IPV6_RTHDRDSTOPTS	55
234607ca46eSDavid Howells #define IPV6_RECVRTHDR		56
235607ca46eSDavid Howells #define IPV6_RTHDR		57
236607ca46eSDavid Howells #define IPV6_RECVDSTOPTS	58
237607ca46eSDavid Howells #define IPV6_DSTOPTS		59
238607ca46eSDavid Howells #define IPV6_RECVPATHMTU	60
239607ca46eSDavid Howells #define IPV6_PATHMTU		61
240607ca46eSDavid Howells #define IPV6_DONTFRAG		62
241607ca46eSDavid Howells #if 0	/* not yet */
242607ca46eSDavid Howells #define IPV6_USE_MIN_MTU	63
243607ca46eSDavid Howells #endif
244607ca46eSDavid Howells 
245607ca46eSDavid Howells /*
246607ca46eSDavid Howells  * Netfilter (1)
247607ca46eSDavid Howells  *
248607ca46eSDavid Howells  * Following socket options are used in ip6_tables;
249607ca46eSDavid Howells  * see include/linux/netfilter_ipv6/ip6_tables.h.
250607ca46eSDavid Howells  *
251607ca46eSDavid Howells  * IP6T_SO_SET_REPLACE / IP6T_SO_GET_INFO		64
252607ca46eSDavid Howells  * IP6T_SO_SET_ADD_COUNTERS / IP6T_SO_GET_ENTRIES	65
253607ca46eSDavid Howells  */
254607ca46eSDavid Howells 
255607ca46eSDavid Howells /*
256607ca46eSDavid Howells  * Advanced API (RFC3542) (2)
257607ca46eSDavid Howells  */
258607ca46eSDavid Howells #define IPV6_RECVTCLASS		66
259607ca46eSDavid Howells #define IPV6_TCLASS		67
260607ca46eSDavid Howells 
261607ca46eSDavid Howells /*
262607ca46eSDavid Howells  * Netfilter (2)
263607ca46eSDavid Howells  *
264607ca46eSDavid Howells  * Following socket options are used in ip6_tables;
265607ca46eSDavid Howells  * see include/linux/netfilter_ipv6/ip6_tables.h.
266607ca46eSDavid Howells  *
267607ca46eSDavid Howells  * IP6T_SO_GET_REVISION_MATCH	68
268607ca46eSDavid Howells  * IP6T_SO_GET_REVISION_TARGET	69
269121d1e09SFlorian Westphal  * IP6T_SO_ORIGINAL_DST		80
270607ca46eSDavid Howells  */
271607ca46eSDavid Howells 
272753a2ad5SPablo Neira #define IPV6_AUTOFLOWLABEL	70
273607ca46eSDavid Howells /* RFC5014: Source address selection */
274607ca46eSDavid Howells #define IPV6_ADDR_PREFERENCES	72
275607ca46eSDavid Howells 
276607ca46eSDavid Howells #define IPV6_PREFER_SRC_TMP		0x0001
277607ca46eSDavid Howells #define IPV6_PREFER_SRC_PUBLIC		0x0002
278607ca46eSDavid Howells #define IPV6_PREFER_SRC_PUBTMP_DEFAULT	0x0100
279607ca46eSDavid Howells #define IPV6_PREFER_SRC_COA		0x0004
280607ca46eSDavid Howells #define IPV6_PREFER_SRC_HOME		0x0400
281607ca46eSDavid Howells #define IPV6_PREFER_SRC_CGA		0x0008
282607ca46eSDavid Howells #define IPV6_PREFER_SRC_NONCGA		0x0800
283607ca46eSDavid Howells 
284607ca46eSDavid Howells /* RFC5082: Generalized Ttl Security Mechanism */
285607ca46eSDavid Howells #define IPV6_MINHOPCOUNT		73
286607ca46eSDavid Howells 
287607ca46eSDavid Howells #define IPV6_ORIGDSTADDR        74
288607ca46eSDavid Howells #define IPV6_RECVORIGDSTADDR    IPV6_ORIGDSTADDR
289607ca46eSDavid Howells #define IPV6_TRANSPARENT        75
290607ca46eSDavid Howells #define IPV6_UNICAST_IF         76
2910cc0aa61SWillem de Bruijn #define IPV6_RECVFRAGSIZE	77
29284e14fe3SMaciej Żenczykowski #define IPV6_FREEBIND		78
293607ca46eSDavid Howells 
294607ca46eSDavid Howells /*
295607ca46eSDavid Howells  * Multicast Routing:
296bbb923a4SNicolas Dichtel  * see include/uapi/linux/mroute6.h.
297607ca46eSDavid Howells  *
298bbb923a4SNicolas Dichtel  * MRT6_BASE			200
299bbb923a4SNicolas Dichtel  * ...
300bbb923a4SNicolas Dichtel  * MRT6_MAX
301607ca46eSDavid Howells  */
302607ca46eSDavid Howells #endif /* _UAPI_LINUX_IN6_H */
303