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