xref: /csrg-svn/sys/netinet/ip.h (revision 33283)
123181Smckusick /*
229140Smckusick  * Copyright (c) 1982, 1986 Regents of the University of California.
332787Sbostic  * All rights reserved.
423181Smckusick  *
532787Sbostic  * Redistribution and use in source and binary forms are permitted
632787Sbostic  * provided that this notice is preserved and that due credit is given
732787Sbostic  * to the University of California at Berkeley. The name of the University
832787Sbostic  * may not be used to endorse or promote products derived from this
932787Sbostic  * software without specific prior written permission. This software
1032787Sbostic  * is provided ``as is'' without express or implied warranty.
1132787Sbostic  *
12*33283Skarels  *	@(#)ip.h	7.5 (Berkeley) 01/07/88
1323181Smckusick  */
144571Swnj 
154662Swnj /*
164662Swnj  * Definitions for internet protocol version 4.
174662Swnj  * Per RFC 791, September 1981.
184662Swnj  */
194662Swnj #define	IPVERSION	4
204662Swnj 
214662Swnj /*
224662Swnj  * Structure of an internet header, naked of options.
234662Swnj  *
244884Swnj  * We declare ip_len and ip_off to be short, rather than u_short
254884Swnj  * pragmatically since otherwise unsigned comparisons can result
264884Swnj  * against negative integers quite easily, and fail in subtle ways.
274662Swnj  */
284571Swnj struct ip {
29*33283Skarels #if BYTE_ORDER == LITTLE_ENDIAN
304571Swnj 	u_char	ip_hl:4,		/* header length */
314571Swnj 		ip_v:4;			/* version */
329991Ssam #endif
33*33283Skarels #if BYTE_ORDER == BIG_ENDIAN
3429923Skarels 	u_char	ip_v:4,			/* version */
3529923Skarels 		ip_hl:4;		/* header length */
3629923Skarels #endif
374571Swnj 	u_char	ip_tos;			/* type of service */
384647Swnj 	short	ip_len;			/* total length */
394571Swnj 	u_short	ip_id;			/* identification */
404647Swnj 	short	ip_off;			/* fragment offset field */
414662Swnj #define	IP_DF 0x4000			/* dont fragment flag */
424662Swnj #define	IP_MF 0x2000			/* more fragments flag */
434571Swnj 	u_char	ip_ttl;			/* time to live */
444571Swnj 	u_char	ip_p;			/* protocol */
454571Swnj 	u_short	ip_sum;			/* checksum */
464923Swnj 	struct	in_addr ip_src,ip_dst;	/* source and dest address */
474498Swnj };
484498Swnj 
494571Swnj /*
504662Swnj  * Definitions for options.
514571Swnj  */
524662Swnj #define	IPOPT_COPIED(o)		((o)&0x80)
5316051Skarels #define	IPOPT_CLASS(o)		((o)&0x60)
5416051Skarels #define	IPOPT_NUMBER(o)		((o)&0x1f)
554662Swnj 
564662Swnj #define	IPOPT_CONTROL		0x00
5716051Skarels #define	IPOPT_RESERVED1		0x20
5816051Skarels #define	IPOPT_DEBMEAS		0x40
5916051Skarels #define	IPOPT_RESERVED2		0x60
604662Swnj 
614662Swnj #define	IPOPT_EOL		0		/* end of option list */
624662Swnj #define	IPOPT_NOP		1		/* no operation */
634662Swnj 
644662Swnj #define	IPOPT_RR		7		/* record packet route */
654662Swnj #define	IPOPT_TS		68		/* timestamp */
664662Swnj #define	IPOPT_SECURITY		130		/* provide s,c,h,tcc */
674662Swnj #define	IPOPT_LSRR		131		/* loose source route */
684662Swnj #define	IPOPT_SATID		136		/* satnet id */
694662Swnj #define	IPOPT_SSRR		137		/* strict source route */
704662Swnj 
714662Swnj /*
7224810Skarels  * Offsets to fields in options other than EOL and NOP.
7324810Skarels  */
7424810Skarels #define	IPOPT_OPTVAL		0		/* option ID */
7524810Skarels #define	IPOPT_OLEN		1		/* option length */
7624810Skarels #define IPOPT_OFFSET		2		/* offset within option */
7724810Skarels #define	IPOPT_MINOFF		4		/* min value of above */
7824810Skarels 
7924810Skarels /*
804662Swnj  * Time stamp option structure.
814662Swnj  */
824662Swnj struct	ip_timestamp {
834662Swnj 	u_char	ipt_code;		/* IPOPT_TS */
844662Swnj 	u_char	ipt_len;		/* size of structure (variable) */
854662Swnj 	u_char	ipt_ptr;		/* index of current entry */
86*33283Skarels #if BYTE_ORDER == LITTLE_ENDIAN
874662Swnj 	u_char	ipt_flg:4,		/* flags, see below */
884662Swnj 		ipt_oflw:4;		/* overflow counter */
8929923Skarels #endif
90*33283Skarels #if BYTE_ORDER == BIG_ENDIAN
9129923Skarels 	u_char	ipt_oflw:4,		/* overflow counter */
9229923Skarels 		ipt_flg:4;		/* flags, see below */
9329923Skarels #endif
94*33283Skarels 	union ipt_timestamp {
954662Swnj 		n_long	ipt_time[1];
964662Swnj 		struct	ipt_ta {
974923Swnj 			struct in_addr ipt_addr;
984662Swnj 			n_long ipt_time;
994662Swnj 		} ipt_ta[1];
100*33283Skarels 	} ipt_timestamp;
1014662Swnj };
1024662Swnj 
1034662Swnj /* flag bits for ipt_flg */
1044662Swnj #define	IPOPT_TS_TSONLY		0		/* timestamps only */
1054662Swnj #define	IPOPT_TS_TSANDADDR	1		/* timestamps and addresses */
1064662Swnj #define	IPOPT_TS_PRESPEC	2		/* specified modules only */
1074662Swnj 
1084662Swnj /* bits for security (not byte swapped) */
1094662Swnj #define	IPOPT_SECUR_UNCLASS	0x0000
1104662Swnj #define	IPOPT_SECUR_CONFID	0xf135
1114662Swnj #define	IPOPT_SECUR_EFTO	0x789a
1124662Swnj #define	IPOPT_SECUR_MMMM	0xbc4d
1134662Swnj #define	IPOPT_SECUR_RESTR	0xaf13
1144662Swnj #define	IPOPT_SECUR_SECRET	0xd788
1154662Swnj #define	IPOPT_SECUR_TOPSECRET	0x6bc5
1164662Swnj 
1174662Swnj /*
1184662Swnj  * Internet implementation parameters.
1194662Swnj  */
1204571Swnj #define	MAXTTL		255		/* maximum time to live (seconds) */
12130291Skarels #define	IPFRAGTTL	60		/* time to live for frags, slowhz */
12216523Skarels #define	IPTTLDEC	1		/* subtracted when forwarding */
12317272Skarels 
12417272Skarels #define	IP_MSS		576		/* default maximum segment size */
125