xref: /csrg-svn/sys/netinet/ip.h (revision 16051)
1*16051Skarels /*	ip.h	6.2	84/02/15	*/
24571Swnj 
34662Swnj /*
44662Swnj  * Definitions for internet protocol version 4.
54662Swnj  * Per RFC 791, September 1981.
64662Swnj  */
74662Swnj #define	IPVERSION	4
84662Swnj 
94662Swnj /*
104662Swnj  * Structure of an internet header, naked of options.
114662Swnj  *
124884Swnj  * We declare ip_len and ip_off to be short, rather than u_short
134884Swnj  * pragmatically since otherwise unsigned comparisons can result
144884Swnj  * against negative integers quite easily, and fail in subtle ways.
154662Swnj  */
164571Swnj struct ip {
179991Ssam #ifdef vax
184571Swnj 	u_char	ip_hl:4,		/* header length */
194571Swnj 		ip_v:4;			/* version */
209991Ssam #endif
214571Swnj 	u_char	ip_tos;			/* type of service */
224647Swnj 	short	ip_len;			/* total length */
234571Swnj 	u_short	ip_id;			/* identification */
244647Swnj 	short	ip_off;			/* fragment offset field */
254662Swnj #define	IP_DF 0x4000			/* dont fragment flag */
264662Swnj #define	IP_MF 0x2000			/* more fragments flag */
274571Swnj 	u_char	ip_ttl;			/* time to live */
284571Swnj 	u_char	ip_p;			/* protocol */
294571Swnj 	u_short	ip_sum;			/* checksum */
304923Swnj 	struct	in_addr ip_src,ip_dst;	/* source and dest address */
314498Swnj };
324498Swnj 
334571Swnj /*
344662Swnj  * Definitions for options.
354571Swnj  */
364662Swnj #define	IPOPT_COPIED(o)		((o)&0x80)
37*16051Skarels #define	IPOPT_CLASS(o)		((o)&0x60)
38*16051Skarels #define	IPOPT_NUMBER(o)		((o)&0x1f)
394662Swnj 
404662Swnj #define	IPOPT_CONTROL		0x00
41*16051Skarels #define	IPOPT_RESERVED1		0x20
42*16051Skarels #define	IPOPT_DEBMEAS		0x40
43*16051Skarels #define	IPOPT_RESERVED2		0x60
444662Swnj 
454662Swnj #define	IPOPT_EOL		0		/* end of option list */
464662Swnj #define	IPOPT_NOP		1		/* no operation */
474662Swnj 
484662Swnj #define	IPOPT_RR		7		/* record packet route */
494662Swnj #define	IPOPT_TS		68		/* timestamp */
504662Swnj #define	IPOPT_SECURITY		130		/* provide s,c,h,tcc */
514662Swnj #define	IPOPT_LSRR		131		/* loose source route */
524662Swnj #define	IPOPT_SATID		136		/* satnet id */
534662Swnj #define	IPOPT_SSRR		137		/* strict source route */
544662Swnj 
554662Swnj /*
564662Swnj  * Time stamp option structure.
574662Swnj  */
584662Swnj struct	ip_timestamp {
594662Swnj 	u_char	ipt_code;		/* IPOPT_TS */
604662Swnj 	u_char	ipt_len;		/* size of structure (variable) */
614662Swnj 	u_char	ipt_ptr;		/* index of current entry */
624662Swnj 	u_char	ipt_flg:4,		/* flags, see below */
634662Swnj 		ipt_oflw:4;		/* overflow counter */
644662Swnj 	union {
654662Swnj 		n_long	ipt_time[1];
664662Swnj 		struct	ipt_ta {
674923Swnj 			struct in_addr ipt_addr;
684662Swnj 			n_long ipt_time;
694662Swnj 		} ipt_ta[1];
704662Swnj 	}
714662Swnj };
724662Swnj 
734662Swnj /* flag bits for ipt_flg */
744662Swnj #define	IPOPT_TS_TSONLY		0		/* timestamps only */
754662Swnj #define	IPOPT_TS_TSANDADDR	1		/* timestamps and addresses */
764662Swnj #define	IPOPT_TS_PRESPEC	2		/* specified modules only */
774662Swnj 
784662Swnj /* bits for security (not byte swapped) */
794662Swnj #define	IPOPT_SECUR_UNCLASS	0x0000
804662Swnj #define	IPOPT_SECUR_CONFID	0xf135
814662Swnj #define	IPOPT_SECUR_EFTO	0x789a
824662Swnj #define	IPOPT_SECUR_MMMM	0xbc4d
834662Swnj #define	IPOPT_SECUR_RESTR	0xaf13
844662Swnj #define	IPOPT_SECUR_SECRET	0xd788
854662Swnj #define	IPOPT_SECUR_TOPSECRET	0x6bc5
864662Swnj 
874662Swnj /*
884662Swnj  * Internet implementation parameters.
894662Swnj  */
904571Swnj #define	MAXTTL		255		/* maximum time to live (seconds) */
914662Swnj #define	IPFRAGTTL	15		/* time to live for frag chains */
926367Ssam #define	IPTTLDEC	5		/* subtracted when forwarding */
93