xref: /csrg-svn/sys/netinet/ip.h (revision 9991)
1*9991Ssam /* ip.h 1.11 82/12/28 */
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 {
17*9991Ssam #ifdef vax
184571Swnj 	u_char	ip_hl:4,		/* header length */
194571Swnj 		ip_v:4;			/* version */
20*9991Ssam #endif
21*9991Ssam #ifdef sun
22*9991Ssam 	u_char	ip_v:4,			/* version */
23*9991Ssam 		ip_hl:4;		/* header length */
24*9991Ssam #endif
254571Swnj 	u_char	ip_tos;			/* type of service */
264647Swnj 	short	ip_len;			/* total length */
274571Swnj 	u_short	ip_id;			/* identification */
284647Swnj 	short	ip_off;			/* fragment offset field */
294662Swnj #define	IP_DF 0x4000			/* dont fragment flag */
304662Swnj #define	IP_MF 0x2000			/* more fragments flag */
314571Swnj 	u_char	ip_ttl;			/* time to live */
324571Swnj 	u_char	ip_p;			/* protocol */
334571Swnj 	u_short	ip_sum;			/* checksum */
344923Swnj 	struct	in_addr ip_src,ip_dst;	/* source and dest address */
354498Swnj };
364498Swnj 
374571Swnj /*
384662Swnj  * Definitions for options.
394571Swnj  */
404662Swnj #define	IPOPT_COPIED(o)		((o)&0x80)
414662Swnj #define	IPOPT_CLASS(o)		((o)&0x40)
424662Swnj #define	IPOPT_NUMBER(o)		((o)&0x3f)
434662Swnj 
444662Swnj #define	IPOPT_CONTROL		0x00
454662Swnj #define	IPOPT_RESERVED1		0x10
464662Swnj #define	IPOPT_DEBMEAS		0x20
474662Swnj #define	IPOPT_RESERVED2		0x30
484662Swnj 
494662Swnj #define	IPOPT_EOL		0		/* end of option list */
504662Swnj #define	IPOPT_NOP		1		/* no operation */
514662Swnj 
524662Swnj #define	IPOPT_RR		7		/* record packet route */
534662Swnj #define	IPOPT_TS		68		/* timestamp */
544662Swnj #define	IPOPT_SECURITY		130		/* provide s,c,h,tcc */
554662Swnj #define	IPOPT_LSRR		131		/* loose source route */
564662Swnj #define	IPOPT_SATID		136		/* satnet id */
574662Swnj #define	IPOPT_SSRR		137		/* strict source route */
584662Swnj 
594662Swnj /*
604662Swnj  * Time stamp option structure.
614662Swnj  */
624662Swnj struct	ip_timestamp {
634662Swnj 	u_char	ipt_code;		/* IPOPT_TS */
644662Swnj 	u_char	ipt_len;		/* size of structure (variable) */
654662Swnj 	u_char	ipt_ptr;		/* index of current entry */
664662Swnj 	u_char	ipt_flg:4,		/* flags, see below */
674662Swnj 		ipt_oflw:4;		/* overflow counter */
684662Swnj 	union {
694662Swnj 		n_long	ipt_time[1];
704662Swnj 		struct	ipt_ta {
714923Swnj 			struct in_addr ipt_addr;
724662Swnj 			n_long ipt_time;
734662Swnj 		} ipt_ta[1];
744662Swnj 	}
754662Swnj };
764662Swnj 
774662Swnj /* flag bits for ipt_flg */
784662Swnj #define	IPOPT_TS_TSONLY		0		/* timestamps only */
794662Swnj #define	IPOPT_TS_TSANDADDR	1		/* timestamps and addresses */
804662Swnj #define	IPOPT_TS_PRESPEC	2		/* specified modules only */
814662Swnj 
824662Swnj /* bits for security (not byte swapped) */
834662Swnj #define	IPOPT_SECUR_UNCLASS	0x0000
844662Swnj #define	IPOPT_SECUR_CONFID	0xf135
854662Swnj #define	IPOPT_SECUR_EFTO	0x789a
864662Swnj #define	IPOPT_SECUR_MMMM	0xbc4d
874662Swnj #define	IPOPT_SECUR_RESTR	0xaf13
884662Swnj #define	IPOPT_SECUR_SECRET	0xd788
894662Swnj #define	IPOPT_SECUR_TOPSECRET	0x6bc5
904662Swnj 
914662Swnj /*
924662Swnj  * Internet implementation parameters.
934662Swnj  */
944571Swnj #define	MAXTTL		255		/* maximum time to live (seconds) */
954662Swnj #define	IPFRAGTTL	15		/* time to live for frag chains */
966367Ssam #define	IPTTLDEC	5		/* subtracted when forwarding */
97