xref: /linux/include/uapi/linux/ip.h (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2607ca46eSDavid Howells /*
3607ca46eSDavid Howells  * INET		An implementation of the TCP/IP protocol suite for the LINUX
4607ca46eSDavid Howells  *		operating system.  INET is implemented using the  BSD Socket
5607ca46eSDavid Howells  *		interface as the means of communication with the user level.
6607ca46eSDavid Howells  *
7607ca46eSDavid Howells  *		Definitions for the IP protocol.
8607ca46eSDavid Howells  *
9607ca46eSDavid Howells  * Version:	@(#)ip.h	1.0.2	04/28/93
10607ca46eSDavid Howells  *
11607ca46eSDavid Howells  * Authors:	Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12607ca46eSDavid Howells  *
13607ca46eSDavid Howells  *		This program is free software; you can redistribute it and/or
14607ca46eSDavid Howells  *		modify it under the terms of the GNU General Public License
15607ca46eSDavid Howells  *		as published by the Free Software Foundation; either version
16607ca46eSDavid Howells  *		2 of the License, or (at your option) any later version.
17607ca46eSDavid Howells  */
18607ca46eSDavid Howells #ifndef _UAPI_LINUX_IP_H
19607ca46eSDavid Howells #define _UAPI_LINUX_IP_H
20607ca46eSDavid Howells #include <linux/types.h>
21*03702d4dSHerton R. Krzesinski #include <linux/stddef.h>
22607ca46eSDavid Howells #include <asm/byteorder.h>
23607ca46eSDavid Howells 
24607ca46eSDavid Howells #define IPTOS_TOS_MASK		0x1E
25607ca46eSDavid Howells #define IPTOS_TOS(tos)		((tos)&IPTOS_TOS_MASK)
26607ca46eSDavid Howells #define	IPTOS_LOWDELAY		0x10
27607ca46eSDavid Howells #define	IPTOS_THROUGHPUT	0x08
28607ca46eSDavid Howells #define	IPTOS_RELIABILITY	0x04
29607ca46eSDavid Howells #define	IPTOS_MINCOST		0x02
30607ca46eSDavid Howells 
31607ca46eSDavid Howells #define IPTOS_PREC_MASK		0xE0
32607ca46eSDavid Howells #define IPTOS_PREC(tos)		((tos)&IPTOS_PREC_MASK)
33607ca46eSDavid Howells #define IPTOS_PREC_NETCONTROL           0xe0
34607ca46eSDavid Howells #define IPTOS_PREC_INTERNETCONTROL      0xc0
35607ca46eSDavid Howells #define IPTOS_PREC_CRITIC_ECP           0xa0
36607ca46eSDavid Howells #define IPTOS_PREC_FLASHOVERRIDE        0x80
37607ca46eSDavid Howells #define IPTOS_PREC_FLASH                0x60
38607ca46eSDavid Howells #define IPTOS_PREC_IMMEDIATE            0x40
39607ca46eSDavid Howells #define IPTOS_PREC_PRIORITY             0x20
40607ca46eSDavid Howells #define IPTOS_PREC_ROUTINE              0x00
41607ca46eSDavid Howells 
42607ca46eSDavid Howells 
43607ca46eSDavid Howells /* IP options */
44607ca46eSDavid Howells #define IPOPT_COPY		0x80
45607ca46eSDavid Howells #define IPOPT_CLASS_MASK	0x60
46607ca46eSDavid Howells #define IPOPT_NUMBER_MASK	0x1f
47607ca46eSDavid Howells 
48607ca46eSDavid Howells #define	IPOPT_COPIED(o)		((o)&IPOPT_COPY)
49607ca46eSDavid Howells #define	IPOPT_CLASS(o)		((o)&IPOPT_CLASS_MASK)
50607ca46eSDavid Howells #define	IPOPT_NUMBER(o)		((o)&IPOPT_NUMBER_MASK)
51607ca46eSDavid Howells 
52607ca46eSDavid Howells #define	IPOPT_CONTROL		0x00
53607ca46eSDavid Howells #define	IPOPT_RESERVED1		0x20
54607ca46eSDavid Howells #define	IPOPT_MEASUREMENT	0x40
55607ca46eSDavid Howells #define	IPOPT_RESERVED2		0x60
56607ca46eSDavid Howells 
57607ca46eSDavid Howells #define IPOPT_END	(0 |IPOPT_CONTROL)
58607ca46eSDavid Howells #define IPOPT_NOOP	(1 |IPOPT_CONTROL)
59607ca46eSDavid Howells #define IPOPT_SEC	(2 |IPOPT_CONTROL|IPOPT_COPY)
60607ca46eSDavid Howells #define IPOPT_LSRR	(3 |IPOPT_CONTROL|IPOPT_COPY)
61607ca46eSDavid Howells #define IPOPT_TIMESTAMP	(4 |IPOPT_MEASUREMENT)
62607ca46eSDavid Howells #define IPOPT_CIPSO	(6 |IPOPT_CONTROL|IPOPT_COPY)
63607ca46eSDavid Howells #define IPOPT_RR	(7 |IPOPT_CONTROL)
64607ca46eSDavid Howells #define IPOPT_SID	(8 |IPOPT_CONTROL|IPOPT_COPY)
65607ca46eSDavid Howells #define IPOPT_SSRR	(9 |IPOPT_CONTROL|IPOPT_COPY)
66607ca46eSDavid Howells #define IPOPT_RA	(20|IPOPT_CONTROL|IPOPT_COPY)
67607ca46eSDavid Howells 
68607ca46eSDavid Howells #define IPVERSION	4
69607ca46eSDavid Howells #define MAXTTL		255
70607ca46eSDavid Howells #define IPDEFTTL	64
71607ca46eSDavid Howells 
72607ca46eSDavid Howells #define IPOPT_OPTVAL 0
73607ca46eSDavid Howells #define IPOPT_OLEN   1
74607ca46eSDavid Howells #define IPOPT_OFFSET 2
75607ca46eSDavid Howells #define IPOPT_MINOFF 4
76607ca46eSDavid Howells #define MAX_IPOPTLEN 40
77607ca46eSDavid Howells #define IPOPT_NOP IPOPT_NOOP
78607ca46eSDavid Howells #define IPOPT_EOL IPOPT_END
79607ca46eSDavid Howells #define IPOPT_TS  IPOPT_TIMESTAMP
80607ca46eSDavid Howells 
81607ca46eSDavid Howells #define	IPOPT_TS_TSONLY		0		/* timestamps only */
82607ca46eSDavid Howells #define	IPOPT_TS_TSANDADDR	1		/* timestamps and addresses */
83607ca46eSDavid Howells #define	IPOPT_TS_PRESPEC	3		/* specified modules only */
84607ca46eSDavid Howells 
85607ca46eSDavid Howells #define IPV4_BEET_PHMAXLEN 8
86607ca46eSDavid Howells 
87607ca46eSDavid Howells struct iphdr {
88607ca46eSDavid Howells #if defined(__LITTLE_ENDIAN_BITFIELD)
89607ca46eSDavid Howells 	__u8	ihl:4,
90607ca46eSDavid Howells 		version:4;
91607ca46eSDavid Howells #elif defined (__BIG_ENDIAN_BITFIELD)
92607ca46eSDavid Howells 	__u8	version:4,
93607ca46eSDavid Howells   		ihl:4;
94607ca46eSDavid Howells #else
95607ca46eSDavid Howells #error	"Please fix <asm/byteorder.h>"
96607ca46eSDavid Howells #endif
97607ca46eSDavid Howells 	__u8	tos;
98607ca46eSDavid Howells 	__be16	tot_len;
99607ca46eSDavid Howells 	__be16	id;
100607ca46eSDavid Howells 	__be16	frag_off;
101607ca46eSDavid Howells 	__u8	ttl;
102607ca46eSDavid Howells 	__u8	protocol;
103607ca46eSDavid Howells 	__sum16	check;
10458e0be1eSHangbin Liu 	__struct_group(/* no tag */, addrs, /* no attrs */,
105607ca46eSDavid Howells 		__be32	saddr;
106607ca46eSDavid Howells 		__be32	daddr;
10758e0be1eSHangbin Liu 	);
108607ca46eSDavid Howells 	/*The options start here. */
109607ca46eSDavid Howells };
110607ca46eSDavid Howells 
111607ca46eSDavid Howells 
112607ca46eSDavid Howells struct ip_auth_hdr {
113607ca46eSDavid Howells 	__u8  nexthdr;
114607ca46eSDavid Howells 	__u8  hdrlen;		/* This one is measured in 32 bit units! */
115607ca46eSDavid Howells 	__be16 reserved;
116607ca46eSDavid Howells 	__be32 spi;
117607ca46eSDavid Howells 	__be32 seq_no;		/* Sequence number */
11894dfc73eSGustavo A. R. Silva 	__u8  auth_data[];	/* Variable len but >=4. Mind the 64 bit alignment! */
119607ca46eSDavid Howells };
120607ca46eSDavid Howells 
121607ca46eSDavid Howells struct ip_esp_hdr {
122607ca46eSDavid Howells 	__be32 spi;
123607ca46eSDavid Howells 	__be32 seq_no;		/* Sequence number */
12494dfc73eSGustavo A. R. Silva 	__u8  enc_data[];	/* Variable len but >=8. Mind the 64 bit alignment! */
125607ca46eSDavid Howells };
126607ca46eSDavid Howells 
127607ca46eSDavid Howells struct ip_comp_hdr {
128607ca46eSDavid Howells 	__u8 nexthdr;
129607ca46eSDavid Howells 	__u8 flags;
130607ca46eSDavid Howells 	__be16 cpi;
131607ca46eSDavid Howells };
132607ca46eSDavid Howells 
133607ca46eSDavid Howells struct ip_beet_phdr {
134607ca46eSDavid Howells 	__u8 nexthdr;
135607ca46eSDavid Howells 	__u8 hdrlen;
136607ca46eSDavid Howells 	__u8 padlen;
137607ca46eSDavid Howells 	__u8 reserved;
138607ca46eSDavid Howells };
139607ca46eSDavid Howells 
1404a5a8aa6Sstephen hemminger /* index values for the variables in ipv4_devconf */
1414a5a8aa6Sstephen hemminger enum
1424a5a8aa6Sstephen hemminger {
1434a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_FORWARDING=1,
1444a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_MC_FORWARDING,
1454a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_PROXY_ARP,
1464a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_ACCEPT_REDIRECTS,
1474a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_SECURE_REDIRECTS,
1484a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_SEND_REDIRECTS,
1494a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_SHARED_MEDIA,
1504a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_RP_FILTER,
1514a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_ACCEPT_SOURCE_ROUTE,
1524a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_BOOTP_RELAY,
1534a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_LOG_MARTIANS,
1544a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_TAG,
1554a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_ARPFILTER,
1564a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_MEDIUM_ID,
1574a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_NOXFRM,
1584a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_NOPOLICY,
1594a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_FORCE_IGMP_VERSION,
1604a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_ARP_ANNOUNCE,
1614a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_ARP_IGNORE,
1624a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_PROMOTE_SECONDARIES,
1634a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_ARP_ACCEPT,
1644a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_ARP_NOTIFY,
1654a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_ACCEPT_LOCAL,
1664a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_SRC_VMARK,
1674a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_PROXY_ARP_PVLAN,
1684a5a8aa6Sstephen hemminger 	IPV4_DEVCONF_ROUTE_LOCALNET,
169b05930f5SDavid S. Miller 	IPV4_DEVCONF_IGMPV2_UNSOLICITED_REPORT_INTERVAL,
170b05930f5SDavid S. Miller 	IPV4_DEVCONF_IGMPV3_UNSOLICITED_REPORT_INTERVAL,
1710eeb075fSAndy Gospodarek 	IPV4_DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN,
17212b74dfaSJohannes Berg 	IPV4_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST,
17397daf331SJohannes Berg 	IPV4_DEVCONF_DROP_GRATUITOUS_ARP,
1745cbf777cSXin Long 	IPV4_DEVCONF_BC_FORWARDING,
175fcdb44d0SJames Prestwood 	IPV4_DEVCONF_ARP_EVICT_NOCARRIER,
1764a5a8aa6Sstephen hemminger 	__IPV4_DEVCONF_MAX
1774a5a8aa6Sstephen hemminger };
1784a5a8aa6Sstephen hemminger 
1794a5a8aa6Sstephen hemminger #define IPV4_DEVCONF_MAX (__IPV4_DEVCONF_MAX - 1)
1804a5a8aa6Sstephen hemminger 
181607ca46eSDavid Howells #endif /* _UAPI_LINUX_IP_H */
182