first listing, remove CHAOS and mpxip
[unix-history] / usr / src / sys / netinet / ip.h
CommitLineData
d52566dd 1/* ip.h 1.6 81/11/08 */
6e8b2eca 2
dad64fdf
BJ
3/*
4 * Definitions for internet protocol version 4.
5 * Per RFC 791, September 1981.
6 */
7#define IPVERSION 4
8
9/*
10 * Structure of an internet header, naked of options.
11 *
12 * SHOULD MAKE A VERSION OF THIS FOR KERNEL SO USER
13 * VERSION CAN BE union FREE AND INITIALIZABLE.
14 */
6e8b2eca
BJ
15struct ip {
16 u_char ip_hl:4, /* header length */
17 ip_v:4; /* version */
18 u_char ip_tos; /* type of service */
dad64fdf
BJ
19/* we copy the IP_MF to ip_tos on input */
20#define ip_mff ip_tos /* more fragments flag */
82422b42
BJ
21/* by rights, ip_len should be a u_short, but this makes operations */
22/* on it very dangerous as comparisons become unsigned and comparing */
23/* against negative numbers then fails... we don't expect any > 32767 */
24/* byte packets, so pragmatically delcare it to be a short */
25 short ip_len; /* total length */
6e8b2eca 26 u_short ip_id; /* identification */
82422b42
BJ
27/* ip_off should also, by rights, be u_short, ala ip_len */
28 short ip_off; /* fragment offset field */
dad64fdf
BJ
29#define IP_DF 0x4000 /* dont fragment flag */
30#define IP_MF 0x2000 /* more fragments flag */
6e8b2eca
BJ
31 u_char ip_ttl; /* time to live */
32 u_char ip_p; /* protocol */
33 u_short ip_sum; /* checksum */
0fcb2ae6 34 union {
d52566dd 35 struct ip_addr ip_s; /* source address */
6e8b2eca 36 struct ip *ip_nxt; /* next fragment */
0fcb2ae6 37 } I_sun;
6e8b2eca
BJ
38#define ip_src I_sun.ip_s
39#define ip_next I_sun.ip_nxt
0fcb2ae6 40 union {
d52566dd 41 struct ip_addr ip_d; /* destination address */
6e8b2eca 42 struct ip *ip_prv; /* prev fragment */
0fcb2ae6 43 } I_dun;
6e8b2eca
BJ
44#define ip_dst I_dun.ip_d
45#define ip_prev I_dun.ip_prv
0fcb2ae6
BJ
46};
47
6e8b2eca 48/*
dad64fdf
BJ
49 * Definitions for options.
50 */
51#define IPOPT_COPIED(o) ((o)&0x80)
52#define IPOPT_CLASS(o) ((o)&0x40)
53#define IPOPT_NUMBER(o) ((o)&0x3f)
54
55#define IPOPT_CONTROL 0x00
56#define IPOPT_RESERVED1 0x10
57#define IPOPT_DEBMEAS 0x20
58#define IPOPT_RESERVED2 0x30
59
60#define IPOPT_EOL 0 /* end of option list */
61#define IPOPT_NOP 1 /* no operation */
62
63#define IPOPT_RR 7 /* record packet route */
64#define IPOPT_TS 68 /* timestamp */
65#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
66#define IPOPT_LSRR 131 /* loose source route */
67#define IPOPT_SATID 136 /* satnet id */
68#define IPOPT_SSRR 137 /* strict source route */
69
70/*
71 * Time stamp option structure.
72 */
73struct ip_timestamp {
74 u_char ipt_code; /* IPOPT_TS */
75 u_char ipt_len; /* size of structure (variable) */
76 u_char ipt_ptr; /* index of current entry */
77 u_char ipt_flg:4, /* flags, see below */
78 ipt_oflw:4; /* overflow counter */
79 union {
80 n_long ipt_time[1];
81 struct ipt_ta {
d52566dd 82 struct ip_addr ipt_addr;
dad64fdf
BJ
83 n_long ipt_time;
84 } ipt_ta[1];
85 }
86};
87
88/* flag bits for ipt_flg */
89#define IPOPT_TS_TSONLY 0 /* timestamps only */
90#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
91#define IPOPT_TS_PRESPEC 2 /* specified modules only */
92
93/* bits for security (not byte swapped) */
94#define IPOPT_SECUR_UNCLASS 0x0000
95#define IPOPT_SECUR_CONFID 0xf135
96#define IPOPT_SECUR_EFTO 0x789a
97#define IPOPT_SECUR_MMMM 0xbc4d
98#define IPOPT_SECUR_RESTR 0xaf13
99#define IPOPT_SECUR_SECRET 0xd788
100#define IPOPT_SECUR_TOPSECRET 0x6bc5
101
102/*
103 * Ip reassembly queue structure. Each fragment
104 * being reassambled is attached to one of these structures.
105 * They are timed out after ipq_ttl drops to 0, and may also
106 * be reclaimed if memory becomes tight.
6e8b2eca
BJ
107 */
108struct ipq {
dad64fdf
BJ
109 struct ipq *next,*prev; /* to other reass headers */
110 u_char ipq_ttl; /* time for reass q to live */
111 u_char ipq_p; /* protocol of this fragment */
112 u_short ipq_id; /* sequence id for reassembly */
113 struct ip *ipq_next,*ipq_prev; /* to ip headers of fragments */
d52566dd 114 struct ip_addr ipq_src,ipq_dst;
0fcb2ae6
BJ
115};
116
dad64fdf
BJ
117/*
118 * Internet implementation parameters.
119 */
6e8b2eca 120#define MAXTTL 255 /* maximum time to live (seconds) */
dad64fdf 121#define IPFRAGTTL 15 /* time to live for frag chains */
0fcb2ae6 122
dad64fdf
BJ
123#ifdef KERNEL
124struct ipq ipq; /* ip reass. queue */
125struct ipq *ip_freef();
126u_short ip_id; /* ip packet ctr, for ids */
127#endif