xref: /linux/include/uapi/linux/ipv6.h (revision a1c613ae4c322ddd58d5a8539dbfba2a0380a8c0)
16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells #ifndef _UAPI_IPV6_H
3607ca46eSDavid Howells #define _UAPI_IPV6_H
4607ca46eSDavid Howells 
5c66ad9caSWillem de Bruijn #include <linux/libc-compat.h>
6607ca46eSDavid Howells #include <linux/types.h>
703702d4dSHerton R. Krzesinski #include <linux/stddef.h>
8607ca46eSDavid Howells #include <linux/in6.h>
9607ca46eSDavid Howells #include <asm/byteorder.h>
10607ca46eSDavid Howells 
11607ca46eSDavid Howells /* The latest drafts declared increase in minimal mtu up to 1280. */
12607ca46eSDavid Howells 
13607ca46eSDavid Howells #define IPV6_MIN_MTU	1280
14607ca46eSDavid Howells 
15607ca46eSDavid Howells /*
16607ca46eSDavid Howells  *	Advanced API
17607ca46eSDavid Howells  *	source interface/address selection, source routing, etc...
18607ca46eSDavid Howells  *	*under construction*
19607ca46eSDavid Howells  */
20607ca46eSDavid Howells 
213b50d902SWANG Cong #if __UAPI_DEF_IN6_PKTINFO
22607ca46eSDavid Howells struct in6_pktinfo {
23607ca46eSDavid Howells 	struct in6_addr	ipi6_addr;
24607ca46eSDavid Howells 	int		ipi6_ifindex;
25607ca46eSDavid Howells };
263b50d902SWANG Cong #endif
27607ca46eSDavid Howells 
283b50d902SWANG Cong #if __UAPI_DEF_IP6_MTUINFO
29607ca46eSDavid Howells struct ip6_mtuinfo {
30607ca46eSDavid Howells 	struct sockaddr_in6	ip6m_addr;
31607ca46eSDavid Howells 	__u32			ip6m_mtu;
32607ca46eSDavid Howells };
333b50d902SWANG Cong #endif
34607ca46eSDavid Howells 
35607ca46eSDavid Howells struct in6_ifreq {
36607ca46eSDavid Howells 	struct in6_addr	ifr6_addr;
37607ca46eSDavid Howells 	__u32		ifr6_prefixlen;
38607ca46eSDavid Howells 	int		ifr6_ifindex;
39607ca46eSDavid Howells };
40607ca46eSDavid Howells 
41607ca46eSDavid Howells #define IPV6_SRCRT_STRICT	0x01	/* Deprecated; will be removed */
42607ca46eSDavid Howells #define IPV6_SRCRT_TYPE_0	0	/* Deprecated; will be removed */
43607ca46eSDavid Howells #define IPV6_SRCRT_TYPE_2	2	/* IPv6 type 2 Routing Header	*/
448610c7c6SAlexander Aring #define IPV6_SRCRT_TYPE_3	3	/* RPL Segment Routing with IPv6 */
451ababebaSDavid Lebrun #define IPV6_SRCRT_TYPE_4	4	/* Segment Routing with IPv6 */
46607ca46eSDavid Howells 
47607ca46eSDavid Howells /*
48607ca46eSDavid Howells  *	routing header
49607ca46eSDavid Howells  */
50607ca46eSDavid Howells struct ipv6_rt_hdr {
51607ca46eSDavid Howells 	__u8		nexthdr;
52607ca46eSDavid Howells 	__u8		hdrlen;
53607ca46eSDavid Howells 	__u8		type;
54607ca46eSDavid Howells 	__u8		segments_left;
55607ca46eSDavid Howells 
56607ca46eSDavid Howells 	/*
57607ca46eSDavid Howells 	 *	type specific data
58607ca46eSDavid Howells 	 *	variable length field
59607ca46eSDavid Howells 	 */
60607ca46eSDavid Howells };
61607ca46eSDavid Howells 
62607ca46eSDavid Howells 
63607ca46eSDavid Howells struct ipv6_opt_hdr {
64607ca46eSDavid Howells 	__u8 		nexthdr;
65607ca46eSDavid Howells 	__u8 		hdrlen;
66607ca46eSDavid Howells 	/*
67607ca46eSDavid Howells 	 * TLV encoded option data follows.
68607ca46eSDavid Howells 	 */
69607ca46eSDavid Howells } __attribute__((packed));	/* required for some archs */
70607ca46eSDavid Howells 
71607ca46eSDavid Howells #define ipv6_destopt_hdr ipv6_opt_hdr
72607ca46eSDavid Howells #define ipv6_hopopt_hdr  ipv6_opt_hdr
73607ca46eSDavid Howells 
74dd3332bfSYOSHIFUJI Hideaki / 吉藤英明 /* Router Alert option values (RFC2711) */
75dd3332bfSYOSHIFUJI Hideaki / 吉藤英明 #define IPV6_OPT_ROUTERALERT_MLD	0x0000	/* MLD(RFC2710) */
76607ca46eSDavid Howells 
77607ca46eSDavid Howells /*
78607ca46eSDavid Howells  *	routing header type 0 (used in cmsghdr struct)
79607ca46eSDavid Howells  */
80607ca46eSDavid Howells 
81607ca46eSDavid Howells struct rt0_hdr {
82607ca46eSDavid Howells 	struct ipv6_rt_hdr	rt_hdr;
83607ca46eSDavid Howells 	__u32			reserved;
8400168b41SGustavo A. R. Silva 	struct in6_addr		addr[];
85607ca46eSDavid Howells 
86607ca46eSDavid Howells #define rt0_type		rt_hdr.type
87607ca46eSDavid Howells };
88607ca46eSDavid Howells 
89607ca46eSDavid Howells /*
90607ca46eSDavid Howells  *	routing header type 2
91607ca46eSDavid Howells  */
92607ca46eSDavid Howells 
93607ca46eSDavid Howells struct rt2_hdr {
94607ca46eSDavid Howells 	struct ipv6_rt_hdr	rt_hdr;
95607ca46eSDavid Howells 	__u32			reserved;
96607ca46eSDavid Howells 	struct in6_addr		addr;
97607ca46eSDavid Howells 
98607ca46eSDavid Howells #define rt2_type		rt_hdr.type
99607ca46eSDavid Howells };
100607ca46eSDavid Howells 
101607ca46eSDavid Howells /*
102607ca46eSDavid Howells  *	home address option in destination options header
103607ca46eSDavid Howells  */
104607ca46eSDavid Howells 
105607ca46eSDavid Howells struct ipv6_destopt_hao {
106607ca46eSDavid Howells 	__u8			type;
107607ca46eSDavid Howells 	__u8			length;
108607ca46eSDavid Howells 	struct in6_addr		addr;
109607ca46eSDavid Howells } __attribute__((packed));
110607ca46eSDavid Howells 
111607ca46eSDavid Howells /*
112607ca46eSDavid Howells  *	IPv6 fixed header
113607ca46eSDavid Howells  *
114607ca46eSDavid Howells  *	BEWARE, it is incorrect. The first 4 bits of flow_lbl
115607ca46eSDavid Howells  *	are glued to priority now, forming "class".
116607ca46eSDavid Howells  */
117607ca46eSDavid Howells 
118607ca46eSDavid Howells struct ipv6hdr {
119607ca46eSDavid Howells #if defined(__LITTLE_ENDIAN_BITFIELD)
120607ca46eSDavid Howells 	__u8			priority:4,
121607ca46eSDavid Howells 				version:4;
122607ca46eSDavid Howells #elif defined(__BIG_ENDIAN_BITFIELD)
123607ca46eSDavid Howells 	__u8			version:4,
124607ca46eSDavid Howells 				priority:4;
125607ca46eSDavid Howells #else
126607ca46eSDavid Howells #error	"Please fix <asm/byteorder.h>"
127607ca46eSDavid Howells #endif
128607ca46eSDavid Howells 	__u8			flow_lbl[3];
129607ca46eSDavid Howells 
130607ca46eSDavid Howells 	__be16			payload_len;
131607ca46eSDavid Howells 	__u8			nexthdr;
132607ca46eSDavid Howells 	__u8			hop_limit;
133607ca46eSDavid Howells 
13458e0be1eSHangbin Liu 	__struct_group(/* no tag */, addrs, /* no attrs */,
135607ca46eSDavid Howells 		struct	in6_addr	saddr;
136607ca46eSDavid Howells 		struct	in6_addr	daddr;
13758e0be1eSHangbin Liu 	);
138607ca46eSDavid Howells };
139607ca46eSDavid Howells 
140607ca46eSDavid Howells 
141607ca46eSDavid Howells /* index values for the variables in ipv6_devconf */
142607ca46eSDavid Howells enum {
143607ca46eSDavid Howells 	DEVCONF_FORWARDING = 0,
144607ca46eSDavid Howells 	DEVCONF_HOPLIMIT,
145607ca46eSDavid Howells 	DEVCONF_MTU6,
146607ca46eSDavid Howells 	DEVCONF_ACCEPT_RA,
147607ca46eSDavid Howells 	DEVCONF_ACCEPT_REDIRECTS,
148607ca46eSDavid Howells 	DEVCONF_AUTOCONF,
149607ca46eSDavid Howells 	DEVCONF_DAD_TRANSMITS,
150607ca46eSDavid Howells 	DEVCONF_RTR_SOLICITS,
151607ca46eSDavid Howells 	DEVCONF_RTR_SOLICIT_INTERVAL,
152607ca46eSDavid Howells 	DEVCONF_RTR_SOLICIT_DELAY,
153607ca46eSDavid Howells 	DEVCONF_USE_TEMPADDR,
154607ca46eSDavid Howells 	DEVCONF_TEMP_VALID_LFT,
155607ca46eSDavid Howells 	DEVCONF_TEMP_PREFERED_LFT,
156607ca46eSDavid Howells 	DEVCONF_REGEN_MAX_RETRY,
157607ca46eSDavid Howells 	DEVCONF_MAX_DESYNC_FACTOR,
158607ca46eSDavid Howells 	DEVCONF_MAX_ADDRESSES,
159607ca46eSDavid Howells 	DEVCONF_FORCE_MLD_VERSION,
160607ca46eSDavid Howells 	DEVCONF_ACCEPT_RA_DEFRTR,
161607ca46eSDavid Howells 	DEVCONF_ACCEPT_RA_PINFO,
162607ca46eSDavid Howells 	DEVCONF_ACCEPT_RA_RTR_PREF,
163607ca46eSDavid Howells 	DEVCONF_RTR_PROBE_INTERVAL,
164607ca46eSDavid Howells 	DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN,
165607ca46eSDavid Howells 	DEVCONF_PROXY_NDP,
166607ca46eSDavid Howells 	DEVCONF_OPTIMISTIC_DAD,
167607ca46eSDavid Howells 	DEVCONF_ACCEPT_SOURCE_ROUTE,
168607ca46eSDavid Howells 	DEVCONF_MC_FORWARDING,
169607ca46eSDavid Howells 	DEVCONF_DISABLE_IPV6,
170607ca46eSDavid Howells 	DEVCONF_ACCEPT_DAD,
171607ca46eSDavid Howells 	DEVCONF_FORCE_TLLAO,
1725cb04436SHannes Frederic Sowa 	DEVCONF_NDISC_NOTIFY,
173fc4eba58SHannes Frederic Sowa 	DEVCONF_MLDV1_UNSOLICITED_REPORT_INTERVAL,
174fc4eba58SHannes Frederic Sowa 	DEVCONF_MLDV2_UNSOLICITED_REPORT_INTERVAL,
175b800c3b9SHannes Frederic Sowa 	DEVCONF_SUPPRESS_FRAG_NDISC,
176d9333196SBen Greear 	DEVCONF_ACCEPT_RA_FROM_LOCAL,
1777fd2561eSErik Kline 	DEVCONF_USE_OPTIMISTIC,
178c2943f14SHarout Hedeshian 	DEVCONF_ACCEPT_RA_MTU,
1793d1bec99SHannes Frederic Sowa 	DEVCONF_STABLE_SECRET,
1803985e8a3SErik Kline 	DEVCONF_USE_OIF_ADDRS_ONLY,
1818013d1d7SHangbin Liu 	DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT,
18235103d11SAndy Gospodarek 	DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN,
183abbc3043SJohannes Berg 	DEVCONF_DROP_UNICAST_IN_L2_MULTICAST,
1847a02bf89SJohannes Berg 	DEVCONF_DROP_UNSOLICITED_NA,
185f1705ec1SDavid Ahern 	DEVCONF_KEEP_ADDR_ON_DOWN,
186bd11f074SMaciej Żenczykowski 	DEVCONF_RTR_SOLICIT_MAX_INTERVAL,
1871ababebaSDavid Lebrun 	DEVCONF_SEG6_ENABLED,
188bf355b8dSDavid Lebrun 	DEVCONF_SEG6_REQUIRE_HMAC,
189adc176c5SErik Nordmark 	DEVCONF_ENHANCED_DAD,
190d35a00b8SFelix Jia 	DEVCONF_ADDR_GEN_MODE,
191df789fe7SDavid Forster 	DEVCONF_DISABLE_POLICY,
192bbea124bSJoel Scherpelz 	DEVCONF_ACCEPT_RA_RT_INFO_MIN_PLEN,
1932210d6b2SMaciej Żenczykowski 	DEVCONF_NDISC_TCLASS,
1948610c7c6SAlexander Aring 	DEVCONF_RPL_SEG_ENABLED,
1956b2e04bcSPraveen Chaudhary 	DEVCONF_RA_DEFRTR_METRIC,
1969ee11f0fSJustin Iurman 	DEVCONF_IOAM6_ENABLED,
1979ee11f0fSJustin Iurman 	DEVCONF_IOAM6_ID,
1989ee11f0fSJustin Iurman 	DEVCONF_IOAM6_ID_WIDE,
19918ac597aSJames Prestwood 	DEVCONF_NDISC_EVICT_NOCARRIER,
2003e0b8f52SArun Ajith S 	DEVCONF_ACCEPT_UNTRACKED_NA,
201*5027d54aSPatrick Rohr 	DEVCONF_ACCEPT_RA_MIN_LFT,
202607ca46eSDavid Howells 	DEVCONF_MAX
203607ca46eSDavid Howells };
204607ca46eSDavid Howells 
205607ca46eSDavid Howells 
206607ca46eSDavid Howells #endif /* _UAPI_IPV6_H */
207