xref: /csrg-svn/sys/netinet/ip.h (revision 9991)
1 /* ip.h 1.11 82/12/28 */
2 
3 /*
4  * Definitions for internet protocol version 4.
5  * Per RFC 791, September 1981.
6  */
7 #define	IPVERSION	4
8 
9 /*
10  * Structure of an internet header, naked of options.
11  *
12  * We declare ip_len and ip_off to be short, rather than u_short
13  * pragmatically since otherwise unsigned comparisons can result
14  * against negative integers quite easily, and fail in subtle ways.
15  */
16 struct ip {
17 #ifdef vax
18 	u_char	ip_hl:4,		/* header length */
19 		ip_v:4;			/* version */
20 #endif
21 #ifdef sun
22 	u_char	ip_v:4,			/* version */
23 		ip_hl:4;		/* header length */
24 #endif
25 	u_char	ip_tos;			/* type of service */
26 	short	ip_len;			/* total length */
27 	u_short	ip_id;			/* identification */
28 	short	ip_off;			/* fragment offset field */
29 #define	IP_DF 0x4000			/* dont fragment flag */
30 #define	IP_MF 0x2000			/* more fragments flag */
31 	u_char	ip_ttl;			/* time to live */
32 	u_char	ip_p;			/* protocol */
33 	u_short	ip_sum;			/* checksum */
34 	struct	in_addr ip_src,ip_dst;	/* source and dest address */
35 };
36 
37 /*
38  * Definitions for options.
39  */
40 #define	IPOPT_COPIED(o)		((o)&0x80)
41 #define	IPOPT_CLASS(o)		((o)&0x40)
42 #define	IPOPT_NUMBER(o)		((o)&0x3f)
43 
44 #define	IPOPT_CONTROL		0x00
45 #define	IPOPT_RESERVED1		0x10
46 #define	IPOPT_DEBMEAS		0x20
47 #define	IPOPT_RESERVED2		0x30
48 
49 #define	IPOPT_EOL		0		/* end of option list */
50 #define	IPOPT_NOP		1		/* no operation */
51 
52 #define	IPOPT_RR		7		/* record packet route */
53 #define	IPOPT_TS		68		/* timestamp */
54 #define	IPOPT_SECURITY		130		/* provide s,c,h,tcc */
55 #define	IPOPT_LSRR		131		/* loose source route */
56 #define	IPOPT_SATID		136		/* satnet id */
57 #define	IPOPT_SSRR		137		/* strict source route */
58 
59 /*
60  * Time stamp option structure.
61  */
62 struct	ip_timestamp {
63 	u_char	ipt_code;		/* IPOPT_TS */
64 	u_char	ipt_len;		/* size of structure (variable) */
65 	u_char	ipt_ptr;		/* index of current entry */
66 	u_char	ipt_flg:4,		/* flags, see below */
67 		ipt_oflw:4;		/* overflow counter */
68 	union {
69 		n_long	ipt_time[1];
70 		struct	ipt_ta {
71 			struct in_addr ipt_addr;
72 			n_long ipt_time;
73 		} ipt_ta[1];
74 	}
75 };
76 
77 /* flag bits for ipt_flg */
78 #define	IPOPT_TS_TSONLY		0		/* timestamps only */
79 #define	IPOPT_TS_TSANDADDR	1		/* timestamps and addresses */
80 #define	IPOPT_TS_PRESPEC	2		/* specified modules only */
81 
82 /* bits for security (not byte swapped) */
83 #define	IPOPT_SECUR_UNCLASS	0x0000
84 #define	IPOPT_SECUR_CONFID	0xf135
85 #define	IPOPT_SECUR_EFTO	0x789a
86 #define	IPOPT_SECUR_MMMM	0xbc4d
87 #define	IPOPT_SECUR_RESTR	0xaf13
88 #define	IPOPT_SECUR_SECRET	0xd788
89 #define	IPOPT_SECUR_TOPSECRET	0x6bc5
90 
91 /*
92  * Internet implementation parameters.
93  */
94 #define	MAXTTL		255		/* maximum time to live (seconds) */
95 #define	IPFRAGTTL	15		/* time to live for frag chains */
96 #define	IPTTLDEC	5		/* subtracted when forwarding */
97