xref: /csrg-svn/sys/netinet/ip.h (revision 4923)
1*4923Swnj /* ip.h 1.9 81/11/18 */
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 {
174571Swnj 	u_char	ip_hl:4,		/* header length */
184571Swnj 		ip_v:4;			/* version */
194571Swnj 	u_char	ip_tos;			/* type of service */
204647Swnj 	short	ip_len;			/* total length */
214571Swnj 	u_short	ip_id;			/* identification */
224647Swnj 	short	ip_off;			/* fragment offset field */
234662Swnj #define	IP_DF 0x4000			/* dont fragment flag */
244662Swnj #define	IP_MF 0x2000			/* more fragments flag */
254571Swnj 	u_char	ip_ttl;			/* time to live */
264571Swnj 	u_char	ip_p;			/* protocol */
274571Swnj 	u_short	ip_sum;			/* checksum */
28*4923Swnj 	struct	in_addr ip_src,ip_dst;	/* source and dest address */
294498Swnj };
304498Swnj 
314571Swnj /*
324662Swnj  * Definitions for options.
334571Swnj  */
344662Swnj #define	IPOPT_COPIED(o)		((o)&0x80)
354662Swnj #define	IPOPT_CLASS(o)		((o)&0x40)
364662Swnj #define	IPOPT_NUMBER(o)		((o)&0x3f)
374662Swnj 
384662Swnj #define	IPOPT_CONTROL		0x00
394662Swnj #define	IPOPT_RESERVED1		0x10
404662Swnj #define	IPOPT_DEBMEAS		0x20
414662Swnj #define	IPOPT_RESERVED2		0x30
424662Swnj 
434662Swnj #define	IPOPT_EOL		0		/* end of option list */
444662Swnj #define	IPOPT_NOP		1		/* no operation */
454662Swnj 
464662Swnj #define	IPOPT_RR		7		/* record packet route */
474662Swnj #define	IPOPT_TS		68		/* timestamp */
484662Swnj #define	IPOPT_SECURITY		130		/* provide s,c,h,tcc */
494662Swnj #define	IPOPT_LSRR		131		/* loose source route */
504662Swnj #define	IPOPT_SATID		136		/* satnet id */
514662Swnj #define	IPOPT_SSRR		137		/* strict source route */
524662Swnj 
534662Swnj /*
544662Swnj  * Time stamp option structure.
554662Swnj  */
564662Swnj struct	ip_timestamp {
574662Swnj 	u_char	ipt_code;		/* IPOPT_TS */
584662Swnj 	u_char	ipt_len;		/* size of structure (variable) */
594662Swnj 	u_char	ipt_ptr;		/* index of current entry */
604662Swnj 	u_char	ipt_flg:4,		/* flags, see below */
614662Swnj 		ipt_oflw:4;		/* overflow counter */
624662Swnj 	union {
634662Swnj 		n_long	ipt_time[1];
644662Swnj 		struct	ipt_ta {
65*4923Swnj 			struct in_addr ipt_addr;
664662Swnj 			n_long ipt_time;
674662Swnj 		} ipt_ta[1];
684662Swnj 	}
694662Swnj };
704662Swnj 
714662Swnj /* flag bits for ipt_flg */
724662Swnj #define	IPOPT_TS_TSONLY		0		/* timestamps only */
734662Swnj #define	IPOPT_TS_TSANDADDR	1		/* timestamps and addresses */
744662Swnj #define	IPOPT_TS_PRESPEC	2		/* specified modules only */
754662Swnj 
764662Swnj /* bits for security (not byte swapped) */
774662Swnj #define	IPOPT_SECUR_UNCLASS	0x0000
784662Swnj #define	IPOPT_SECUR_CONFID	0xf135
794662Swnj #define	IPOPT_SECUR_EFTO	0x789a
804662Swnj #define	IPOPT_SECUR_MMMM	0xbc4d
814662Swnj #define	IPOPT_SECUR_RESTR	0xaf13
824662Swnj #define	IPOPT_SECUR_SECRET	0xd788
834662Swnj #define	IPOPT_SECUR_TOPSECRET	0x6bc5
844662Swnj 
854662Swnj /*
864662Swnj  * Internet implementation parameters.
874662Swnj  */
884571Swnj #define	MAXTTL		255		/* maximum time to live (seconds) */
894662Swnj #define	IPFRAGTTL	15		/* time to live for frag chains */
90