xref: /titanic_50/usr/src/uts/common/netinet/ip.h (revision 3f7d54a6b84904c8f4d8daa4c7b577bede7df8b9)
1 /*
2  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 1982, 1986 Regents of the University of California.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms are permitted
11  * provided that this notice is preserved and that due credit is given
12  * to the University of California at Berkeley. The name of the University
13  * may not be used to endorse or promote products derived from this
14  * software without specific prior written permission. This software
15  * is provided ``as is'' without express or implied warranty.
16  */
17 
18 /*
19  * Definitions for internet protocol version 4.
20  * Per RFC 791, September 1981.
21  */
22 
23 #ifndef	_NETINET_IP_H
24 #define	_NETINET_IP_H
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 /* ip.h 1.13 88/08/19 SMI; from UCB 7.6.1.1 3/15/88	*/
28 
29 #include <sys/isa_defs.h>
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #define	IPVERSION	4
36 
37 /*
38  * Structure of an internet header, naked of options.
39  */
40 struct ip {
41 #ifdef _BIT_FIELDS_LTOH
42 	uchar_t	ip_hl:4,		/* header length */
43 		ip_v:4;			/* version */
44 #else
45 	uchar_t	ip_v:4,			/* version */
46 		ip_hl:4;		/* header length */
47 #endif
48 	uchar_t	ip_tos;			/* type of service */
49 	ushort_t ip_len;		/* total length */
50 	ushort_t ip_id;			/* identification */
51 	ushort_t ip_off;		/* fragment offset field */
52 #define	IP_DF 0x4000			/* dont fragment flag */
53 #define	IP_MF 0x2000			/* more fragments flag */
54 	uchar_t	ip_ttl;			/* time to live */
55 	uchar_t	ip_p;			/* protocol */
56 	ushort_t ip_sum;		/* checksum */
57 	struct	in_addr ip_src, ip_dst;	/* source and dest address */
58 };
59 
60 #define	IP_MAXPACKET	65535		/* maximum packet size */
61 
62 /*
63  * Definitions for IP type of service (ip_tos)
64  */
65 #define	IPTOS_LOWDELAY		0x10
66 #define	IPTOS_THROUGHPUT	0x08
67 #define	IPTOS_RELIABILITY	0x04
68 #define	IPTOS_ECT		0x02	/* ECN-Capable Transport flag */
69 #define	IPTOS_CE		0x01	/* ECN-Congestion Experienced flag */
70 
71 /*
72  * Definitions for IP precedence (also in ip_tos) (hopefully unused)
73  */
74 #define	IPTOS_PREC_NETCONTROL		0xe0
75 #define	IPTOS_PREC_INTERNETCONTROL	0xc0
76 #define	IPTOS_PREC_CRITIC_ECP		0xa0
77 #define	IPTOS_PREC_FLASHOVERRIDE	0x80
78 #define	IPTOS_PREC_FLASH		0x60
79 #define	IPTOS_PREC_IMMEDIATE		0x40
80 #define	IPTOS_PREC_PRIORITY		0x20
81 #define	IPTOS_PREC_ROUTINE		0x00
82 
83 /*
84  * Definitions for options.
85  */
86 
87 /* Bits in the option value */
88 #define	IPOPT_COPY		0x80
89 
90 #define	IPOPT_COPIED(o)		((o)&0x80)
91 #define	IPOPT_CLASS(o)		((o)&0x60)
92 #define	IPOPT_NUMBER(o)		((o)&0x1f)
93 
94 #define	IPOPT_CONTROL		0x00
95 #define	IPOPT_RESERVED1		0x20
96 #define	IPOPT_DEBMEAS		0x40
97 #define	IPOPT_RESERVED2		0x60
98 
99 #define	IPOPT_EOL		0x00		/* end of option list */
100 #define	IPOPT_NOP		0x01		/* no operation */
101 
102 #define	IPOPT_RR		0x07		/* record packet route */
103 #define	IPOPT_RTRALERT		0x14		/* router alert */
104 #define	IPOPT_TS		0x44		/* timestamp */
105 #define	IPOPT_SECURITY		0x82		/* provide s,c,h,tcc */
106 #define	IPOPT_LSRR		0x83		/* loose source route */
107 #define	IPOPT_EXTSEC		0x85
108 #define	IPOPT_COMSEC		0x86
109 #define	IPOPT_SATID		0x88		/* satnet id */
110 #define	IPOPT_SSRR		0x89		/* strict source route */
111 #define	IPOPT_RA		0x94
112 #define	IPOPT_SDMDD		0x95
113 
114 /*
115  * Offsets to fields in options other than EOL and NOP.
116  */
117 #define	IPOPT_OPTVAL		0		/* option ID */
118 #define	IPOPT_OLEN		1		/* option length */
119 #define	IPOPT_OFFSET		2		/* offset within option */
120 #define	IPOPT_POS_OV_FLG	3
121 #define	IPOPT_MINOFF		4		/* min value of IPOPT_OFFSET */
122 
123 
124 /* Minimum for src and record route options */
125 #define	IPOPT_MINOFF_SR		IPOPT_MINOFF
126 
127 /*
128  * Time stamp option structure.
129  */
130 struct	ip_timestamp {
131 	uchar_t	ipt_code;		/* IPOPT_TS */
132 	uchar_t	ipt_len;		/* size of structure (variable) */
133 	uchar_t	ipt_ptr;		/* index of current entry */
134 #ifdef _BIT_FIELDS_LTOH
135 	uchar_t	ipt_flg:4,		/* flags, see below */
136 		ipt_oflw:4;		/* overflow counter */
137 #else
138 	uchar_t	ipt_oflw:4,		/* overflow counter */
139 		ipt_flg:4;		/* flags, see below */
140 #endif
141 	union ipt_timestamp {
142 		uint32_t	ipt_time[1];
143 		struct	ipt_ta {
144 			struct in_addr	ipt_addr;
145 			uint32_t	ipt_time;
146 		} ipt_ta[1];
147 	} ipt_timestamp;
148 };
149 
150 /* flag bits for ipt_flg */
151 #define	IPOPT_TS_TSONLY		0		/* timestamps only */
152 #define	IPOPT_TS_TSANDADDR	1		/* timestamps and addresses */
153 #define	IPOPT_TS_PRESPEC	2		/* specified modules only */
154 #define	IPOPT_TS_PRESPEC_RFC791	3
155 
156 /* Minimum for timestamp option */
157 #define	IPOPT_MINOFF_IT		5
158 #define	IPOPT_MINLEN_IT		5
159 
160 #define	IPOPT_TS_TIMELEN	4	/* Timestamp size */
161 
162 /* bits for security (not byte swapped) */
163 #define	IPOPT_SECUR_UNCLASS	0x0000
164 #define	IPOPT_SECUR_CONFID	0xf135
165 #define	IPOPT_SECUR_EFTO	0x789a
166 #define	IPOPT_SECUR_MMMM	0xbc4d
167 #define	IPOPT_SECUR_RESTR	0xaf13
168 #define	IPOPT_SECUR_SECRET	0xd788
169 #define	IPOPT_SECUR_TOPSECRET	0x6bc5
170 
171 /*
172  * Internet implementation parameters.
173  */
174 #define	MAXTTL		255		/* maximum time to live (seconds) */
175 #define	IPFRAGTTL	60		/* time to live for frags, slowhz */
176 #define	IPTTLDEC	1		/* subtracted when forwarding */
177 
178 #define	IP_MSS		576		/* default maximum segment size */
179 
180 #ifdef	__cplusplus
181 }
182 #endif
183 
184 #endif	/* _NETINET_IP_H */
185