xref: /original-bsd/sys/netinet/ip.h (revision 40192f2d)
1 /*	ip.h	6.4	84/10/19	*/
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 	u_char	ip_tos;			/* type of service */
22 	short	ip_len;			/* total length */
23 	u_short	ip_id;			/* identification */
24 	short	ip_off;			/* fragment offset field */
25 #define	IP_DF 0x4000			/* dont fragment flag */
26 #define	IP_MF 0x2000			/* more fragments flag */
27 	u_char	ip_ttl;			/* time to live */
28 	u_char	ip_p;			/* protocol */
29 	u_short	ip_sum;			/* checksum */
30 	struct	in_addr ip_src,ip_dst;	/* source and dest address */
31 };
32 
33 /*
34  * Definitions for options.
35  */
36 #define	IPOPT_COPIED(o)		((o)&0x80)
37 #define	IPOPT_CLASS(o)		((o)&0x60)
38 #define	IPOPT_NUMBER(o)		((o)&0x1f)
39 
40 #define	IPOPT_CONTROL		0x00
41 #define	IPOPT_RESERVED1		0x20
42 #define	IPOPT_DEBMEAS		0x40
43 #define	IPOPT_RESERVED2		0x60
44 
45 #define	IPOPT_EOL		0		/* end of option list */
46 #define	IPOPT_NOP		1		/* no operation */
47 
48 #define	IPOPT_RR		7		/* record packet route */
49 #define	IPOPT_TS		68		/* timestamp */
50 #define	IPOPT_SECURITY		130		/* provide s,c,h,tcc */
51 #define	IPOPT_LSRR		131		/* loose source route */
52 #define	IPOPT_SATID		136		/* satnet id */
53 #define	IPOPT_SSRR		137		/* strict source route */
54 
55 /*
56  * Time stamp option structure.
57  */
58 struct	ip_timestamp {
59 	u_char	ipt_code;		/* IPOPT_TS */
60 	u_char	ipt_len;		/* size of structure (variable) */
61 	u_char	ipt_ptr;		/* index of current entry */
62 	u_char	ipt_flg:4,		/* flags, see below */
63 		ipt_oflw:4;		/* overflow counter */
64 	union {
65 		n_long	ipt_time[1];
66 		struct	ipt_ta {
67 			struct in_addr ipt_addr;
68 			n_long ipt_time;
69 		} ipt_ta[1];
70 	}
71 };
72 
73 /* flag bits for ipt_flg */
74 #define	IPOPT_TS_TSONLY		0		/* timestamps only */
75 #define	IPOPT_TS_TSANDADDR	1		/* timestamps and addresses */
76 #define	IPOPT_TS_PRESPEC	2		/* specified modules only */
77 
78 /* bits for security (not byte swapped) */
79 #define	IPOPT_SECUR_UNCLASS	0x0000
80 #define	IPOPT_SECUR_CONFID	0xf135
81 #define	IPOPT_SECUR_EFTO	0x789a
82 #define	IPOPT_SECUR_MMMM	0xbc4d
83 #define	IPOPT_SECUR_RESTR	0xaf13
84 #define	IPOPT_SECUR_SECRET	0xd788
85 #define	IPOPT_SECUR_TOPSECRET	0x6bc5
86 
87 /*
88  * Internet implementation parameters.
89  */
90 #define	MAXTTL		255		/* maximum time to live (seconds) */
91 #define	IPFRAGTTL	15		/* time to live for frag chains */
92 #define	IPTTLDEC	1		/* subtracted when forwarding */
93 
94 #define	IP_MSS		576		/* default maximum segment size */
95