more-or-less working with new proc & user structs
[unix-history] / usr / src / sys / netinet / ip.h
CommitLineData
8ae0e4b4 1/*
0880b18e 2 * Copyright (c) 1982, 1986 Regents of the University of California.
2b6b6284 3 * All rights reserved.
8ae0e4b4 4 *
dbf0c423 5 * %sccs.include.redist.c%
2b6b6284 6 *
dbf0c423 7 * @(#)ip.h 7.10 (Berkeley) %G%
8ae0e4b4 8 */
233ed7a5
MK
9#ifndef BYTE_ORDER
10/*
11 * Definitions for byte order,
12 * according to byte significance from low address to high.
13 */
14#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax) */
15#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
16#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */
17
18#ifdef vax
19#define BYTE_ORDER LITTLE_ENDIAN
20#else
21#define BYTE_ORDER BIG_ENDIAN /* mc68000, tahoe, most others */
22#endif
23#endif BYTE_ORDER
6e8b2eca 24
dad64fdf
BJ
25/*
26 * Definitions for internet protocol version 4.
27 * Per RFC 791, September 1981.
28 */
29#define IPVERSION 4
30
31/*
32 * Structure of an internet header, naked of options.
33 *
53a5409e
BJ
34 * We declare ip_len and ip_off to be short, rather than u_short
35 * pragmatically since otherwise unsigned comparisons can result
36 * against negative integers quite easily, and fail in subtle ways.
dad64fdf 37 */
6e8b2eca 38struct ip {
f8b9a4f5 39#if BYTE_ORDER == LITTLE_ENDIAN
6e8b2eca
BJ
40 u_char ip_hl:4, /* header length */
41 ip_v:4; /* version */
f112c673 42#endif
f8b9a4f5 43#if BYTE_ORDER == BIG_ENDIAN
f112c673
MK
44 u_char ip_v:4, /* version */
45 ip_hl:4; /* header length */
498aff44 46#endif
6e8b2eca 47 u_char ip_tos; /* type of service */
82422b42 48 short ip_len; /* total length */
6e8b2eca 49 u_short ip_id; /* identification */
82422b42 50 short ip_off; /* fragment offset field */
dad64fdf
BJ
51#define IP_DF 0x4000 /* dont fragment flag */
52#define IP_MF 0x2000 /* more fragments flag */
6e8b2eca
BJ
53 u_char ip_ttl; /* time to live */
54 u_char ip_p; /* protocol */
55 u_short ip_sum; /* checksum */
2b4b57cd 56 struct in_addr ip_src,ip_dst; /* source and dest address */
0fcb2ae6
BJ
57};
58
9d059868
MK
59#define IP_MAXPACKET 65535 /* maximum packet size */
60
3e3821e4
MK
61/*
62 * Definitions for IP type of service (ip_tos)
63 */
64#define IPTOS_LOWDELAY 0x10
65#define IPTOS_THROUGHPUT 0x08
66#define IPTOS_RELIABILITY 0x04
67
68/*
69 * Definitions for IP precedence (also in ip_tos) (hopefully unused)
70 */
71#define IPTOS_PREC_NETCONTROL 0xe0
72#define IPTOS_PREC_INTERNETCONTROL 0xc0
73#define IPTOS_PREC_CRITIC_ECP 0xa0
74#define IPTOS_PREC_FLASHOVERRIDE 0x80
75#define IPTOS_PREC_FLASH 0x60
76#define IPTOS_PREC_IMMEDIATE 0x40
77#define IPTOS_PREC_PRIORITY 0x20
78#define IPTOS_PREC_ROUTINE 0x10
79
6e8b2eca 80/*
dad64fdf
BJ
81 * Definitions for options.
82 */
83#define IPOPT_COPIED(o) ((o)&0x80)
579b0a35
MK
84#define IPOPT_CLASS(o) ((o)&0x60)
85#define IPOPT_NUMBER(o) ((o)&0x1f)
dad64fdf
BJ
86
87#define IPOPT_CONTROL 0x00
579b0a35
MK
88#define IPOPT_RESERVED1 0x20
89#define IPOPT_DEBMEAS 0x40
90#define IPOPT_RESERVED2 0x60
dad64fdf
BJ
91
92#define IPOPT_EOL 0 /* end of option list */
93#define IPOPT_NOP 1 /* no operation */
94
95#define IPOPT_RR 7 /* record packet route */
96#define IPOPT_TS 68 /* timestamp */
97#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
98#define IPOPT_LSRR 131 /* loose source route */
99#define IPOPT_SATID 136 /* satnet id */
100#define IPOPT_SSRR 137 /* strict source route */
101
f52643db
MK
102/*
103 * Offsets to fields in options other than EOL and NOP.
104 */
105#define IPOPT_OPTVAL 0 /* option ID */
106#define IPOPT_OLEN 1 /* option length */
107#define IPOPT_OFFSET 2 /* offset within option */
108#define IPOPT_MINOFF 4 /* min value of above */
109
dad64fdf
BJ
110/*
111 * Time stamp option structure.
112 */
113struct ip_timestamp {
114 u_char ipt_code; /* IPOPT_TS */
115 u_char ipt_len; /* size of structure (variable) */
116 u_char ipt_ptr; /* index of current entry */
f8b9a4f5 117#if BYTE_ORDER == LITTLE_ENDIAN
dad64fdf
BJ
118 u_char ipt_flg:4, /* flags, see below */
119 ipt_oflw:4; /* overflow counter */
f112c673 120#endif
f8b9a4f5 121#if BYTE_ORDER == BIG_ENDIAN
f112c673
MK
122 u_char ipt_oflw:4, /* overflow counter */
123 ipt_flg:4; /* flags, see below */
124#endif
f8b9a4f5 125 union ipt_timestamp {
dad64fdf
BJ
126 n_long ipt_time[1];
127 struct ipt_ta {
2b4b57cd 128 struct in_addr ipt_addr;
dad64fdf
BJ
129 n_long ipt_time;
130 } ipt_ta[1];
f8b9a4f5 131 } ipt_timestamp;
dad64fdf
BJ
132};
133
134/* flag bits for ipt_flg */
135#define IPOPT_TS_TSONLY 0 /* timestamps only */
136#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
f959ef3e 137#define IPOPT_TS_PRESPEC 3 /* specified modules only */
dad64fdf
BJ
138
139/* bits for security (not byte swapped) */
140#define IPOPT_SECUR_UNCLASS 0x0000
141#define IPOPT_SECUR_CONFID 0xf135
142#define IPOPT_SECUR_EFTO 0x789a
143#define IPOPT_SECUR_MMMM 0xbc4d
144#define IPOPT_SECUR_RESTR 0xaf13
145#define IPOPT_SECUR_SECRET 0xd788
146#define IPOPT_SECUR_TOPSECRET 0x6bc5
147
dad64fdf
BJ
148/*
149 * Internet implementation parameters.
150 */
6e8b2eca 151#define MAXTTL 255 /* maximum time to live (seconds) */
e3138fb8 152#define IPFRAGTTL 60 /* time to live for frags, slowhz */
b3caeaac 153#define IPTTLDEC 1 /* subtracted when forwarding */
99578149
MK
154
155#define IP_MSS 576 /* default maximum segment size */