xref: /original-bsd/sys/deprecated/bbnnet/ip.h (revision a95f03a8)
1 #define RCSIPHDR "$Header: ip.h,v 1.4 85/07/31 09:31:22 walsh Exp $"
2 
3 
4 struct ip {                     /* ip leader */
5 	u_char ip_hl:4,			/* header length */
6 #define IP_HLSHIFT 2
7 		ip_v:4;			/* version */
8 	u_char ip_tos;			/* type of service */
9 #define ip_mff ip_tos                   /* more fragments flag (input) */
10 	u_short ip_len;			/* total length */
11 	u_short ip_id;			/* identification */
12 	u_short ip_off;			/* fragment offset field */
13 #define ip_df 0x4000                    /* dont fragment flag */
14 #define ip_mf 0x2000                    /* more fragments flag (output) */
15 #define IP_OFFSHIFT 3
16 	u_char ip_ttl;			/* time to live */
17 	u_char ip_p;			/* protocol */
18 	u_short ip_sum;			/* checksum */
19 #define ip_end ip_sum                   /* fragment end */
20 	union {
21 		struct in_addr ip_s;     /* source address */
22 		struct ip *ip_nxt;      /* ->next fragment */
23 	} I_sun;
24 #define ip_src  I_sun.ip_s
25 #define ip_next I_sun.ip_nxt
26 	union {
27 		struct in_addr ip_d;     /* destination address */
28 		struct ip *ip_prv;      /* ->prev fragment */
29 	} I_dun;
30 #define ip_dst  I_dun.ip_d
31 #define ip_prev I_dun.ip_prv
32 };
33 
34 /* ip options */
35 #define IP_OPT_COPY	0x80		/* option copy type flag */
36 #define IP_OPT_DEBUG	0x40		/* option debug class (2) */
37 
38 #define IP_END_OPT	0		/* end of option list */
39 #define IP_NOP_OPT	1		/* nop option */
40 #define IP_SEC_OPT	(2+IP_OPT_COPY)	/* security option */
41 #define 	IP_SEC_OPTLEN	11		/* length */
42 #define		IP_SEC_OPTHDR	((IP_SEC_OPT<<8)|IP_SEC_OPTLEN)	/* opt/len */
43 #define	IP_LRTE_OPT	(3+IP_OPT_COPY)	/* loose source and record route */
44 #define	IP_TIME_OPT	(4+IP_OPT_DEBUG)/* timestamp */
45 #define IP_RRTE_OPT	7		/* record route */
46 #define IP_STRID_OPT	(8+IP_OPT_COPY)	/* stream ID */
47 #define		IP_STRID_OPTLEN	4		/* length */
48 #define		IP_STRID_OPTHDR	((IP_STRID_OPT<<8)|IP_STRID_OPTLEN) /* opt/len */
49 #define IP_SRTE_OPT	(9+IP_OPT_COPY)	/* strict source and record route */
50 
51 struct ipq {                    /* ip reass.q header */
52 	struct ip iqx;                  /* dummy ip element for top of list */
53 	struct ipq *iq_next;            /* -> next chain on q */
54 	struct ipq *iq_prev;            /* -> prev chain on q */
55 	struct ip iqh;                  /* fragment header */
56 	u_short iq_size		/* maximum fragment size */
57 };
58 
59 #define IPVERSION 4             /* internet protocol version number */
60 #define IPMAX 576		/* maximum spec ip packet length */
61 #define MAXTTL 10		/* maximum time to live (seconds) */
62 
63 /*
64  * ip statistics structure
65  */
66 
67 struct ip_stat {
68     struct in_stat ip_in;
69 #define ip_total	ip_in.in_total
70 #define ip_badsum	ip_in.in_badsum
71 #define ip_tooshort	ip_in.in_tooshort
72 #define ip_drops	ip_in.in_drops
73 	int ip_forwarded;	/* #ip packets not addressed to us */
74 	int ip_broadcast;	/* #broadcast packets received */
75 };
76 
77 
78 #ifdef KERNEL
79 
80 extern struct ip_stat ipstat;
81 extern struct in_stat otherstat;
82 
83 /*
84  * Enqueue a fragment on the reassembly chain.
85  * Can't use insque/remque since prev/next not at head of structure.
86  */
87 #define ip_enq(p, prev)							\
88 {	register struct ip *PREV = prev;				\
89 									\
90 	p->ip_prev = PREV;						\
91 	p->ip_next = PREV->ip_next;					\
92 	PREV->ip_next->ip_prev = p;					\
93 	PREV->ip_next = p;						\
94 }
95 
96 /* Dequeue a fragment from reassembly chain.  */
97 #define ip_deq(p)							\
98 {									\
99 	p->ip_prev->ip_next = p->ip_next;				\
100 	p->ip_next->ip_prev = p->ip_prev;				\
101 }
102 #endif
103