xref: /csrg-svn/sys/netinet/ip.h (revision 4647)
1 /* ip.h 1.4 81/10/28 */
2 
3 struct ip {
4 	u_char	ip_hl:4,		/* header length */
5 		ip_v:4;			/* version */
6 	u_char	ip_tos;			/* type of service */
7 #define	ip_mff	ip_tos			/* more fragments flag (input) */
8 /* by rights, ip_len should be a u_short, but this makes operations */
9 /* on it very dangerous as comparisons become unsigned and comparing */
10 /* against negative numbers then fails... we don't expect any > 32767 */
11 /* byte packets, so pragmatically delcare it to be a short */
12 	short	ip_len;			/* total length */
13 	u_short	ip_id;			/* identification */
14 /* ip_off should also, by rights, be u_short, ala ip_len */
15 	short	ip_off;			/* fragment offset field */
16 #define	ip_df 0x4000			/* dont fragment flag */
17 #define	ip_mf 0x2000			/* more fragments flag (output) */
18 	u_char	ip_ttl;			/* time to live */
19 	u_char	ip_p;			/* protocol */
20 	u_short	ip_sum;			/* checksum */
21 #define	ip_end	ip_sum			/* fragment end */
22 	union {
23 		struct socket ip_s;	/* source address */
24 		struct ip *ip_nxt;	/* next fragment */
25 	} I_sun;
26 #define	ip_src	I_sun.ip_s
27 #define	ip_next	I_sun.ip_nxt
28 	union {
29 		struct socket ip_d;	/* destination address */
30 		struct ip *ip_prv;	/* prev fragment */
31 	} I_dun;
32 #define	ip_dst	I_dun.ip_d
33 #define	ip_prev I_dun.ip_prv
34 };
35 
36 /*
37  * Ip reassembly queue.
38  */
39 struct ipq {
40 	struct	ip iqx;		/* dummy ip element for top of list */
41 	struct	ipq *iq_next;	/* -> next chain on q */
42 	struct	ipq *iq_prev;	/* -> prev chain on q */
43 	struct	ip iqh;		/* fragment header */
44 };
45 
46 #define	IPVERSION	4		/* internet protocol version number */
47 #define	IPLOLINK	155		/* internet link numbers */
48 #define	IPHILINK	158
49 #define	IPLINK		IPLOLINK
50 #define	MAXTTL		255		/* maximum time to live (seconds) */
51 
52 #define	ip_bswap(p) { \
53 	p->ip_len = ntohs(p->ip_len); \
54 	p->ip_id = ntohs(p->ip_id); \
55 	p->ip_off = ntohs(p->ip_off); }
56 
57