xref: /csrg-svn/sys/netinet/ip.h (revision 4647)
1*4647Swnj /* ip.h 1.4 81/10/28 */
24571Swnj 
34571Swnj struct ip {
44571Swnj 	u_char	ip_hl:4,		/* header length */
54571Swnj 		ip_v:4;			/* version */
64571Swnj 	u_char	ip_tos;			/* type of service */
74571Swnj #define	ip_mff	ip_tos			/* more fragments flag (input) */
8*4647Swnj /* by rights, ip_len should be a u_short, but this makes operations */
9*4647Swnj /* on it very dangerous as comparisons become unsigned and comparing */
10*4647Swnj /* against negative numbers then fails... we don't expect any > 32767 */
11*4647Swnj /* byte packets, so pragmatically delcare it to be a short */
12*4647Swnj 	short	ip_len;			/* total length */
134571Swnj 	u_short	ip_id;			/* identification */
14*4647Swnj /* ip_off should also, by rights, be u_short, ala ip_len */
15*4647Swnj 	short	ip_off;			/* fragment offset field */
164571Swnj #define	ip_df 0x4000			/* dont fragment flag */
174571Swnj #define	ip_mf 0x2000			/* more fragments flag (output) */
184571Swnj 	u_char	ip_ttl;			/* time to live */
194571Swnj 	u_char	ip_p;			/* protocol */
204571Swnj 	u_short	ip_sum;			/* checksum */
214571Swnj #define	ip_end	ip_sum			/* fragment end */
224498Swnj 	union {
234571Swnj 		struct socket ip_s;	/* source address */
244571Swnj 		struct ip *ip_nxt;	/* next fragment */
254498Swnj 	} I_sun;
264571Swnj #define	ip_src	I_sun.ip_s
274571Swnj #define	ip_next	I_sun.ip_nxt
284498Swnj 	union {
294571Swnj 		struct socket ip_d;	/* destination address */
304571Swnj 		struct ip *ip_prv;	/* prev fragment */
314498Swnj 	} I_dun;
324571Swnj #define	ip_dst	I_dun.ip_d
334571Swnj #define	ip_prev I_dun.ip_prv
344498Swnj };
354498Swnj 
364571Swnj /*
374571Swnj  * Ip reassembly queue.
384571Swnj  */
394571Swnj struct ipq {
404571Swnj 	struct	ip iqx;		/* dummy ip element for top of list */
414571Swnj 	struct	ipq *iq_next;	/* -> next chain on q */
424571Swnj 	struct	ipq *iq_prev;	/* -> prev chain on q */
434571Swnj 	struct	ip iqh;		/* fragment header */
444498Swnj };
454498Swnj 
464571Swnj #define	IPVERSION	4		/* internet protocol version number */
474571Swnj #define	IPLOLINK	155		/* internet link numbers */
484571Swnj #define	IPHILINK	158
494571Swnj #define	IPLINK		IPLOLINK
504571Swnj #define	MAXTTL		255		/* maximum time to live (seconds) */
514498Swnj 
524501Swnj #define	ip_bswap(p) { \
534501Swnj 	p->ip_len = ntohs(p->ip_len); \
544501Swnj 	p->ip_id = ntohs(p->ip_id); \
554501Swnj 	p->ip_off = ntohs(p->ip_off); }
564501Swnj 
57