not doing *anything* while waiting for input; add substate
[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 *
2b6b6284
KB
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of California at Berkeley. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
11 *
233ed7a5 12 * @(#)ip.h 7.6.1.1 (Berkeley) %G%
8ae0e4b4 13 */
233ed7a5
MK
14#ifndef BYTE_ORDER
15/*
16 * Definitions for byte order,
17 * according to byte significance from low address to high.
18 */
19#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax) */
20#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
21#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */
22
23#ifdef vax
24#define BYTE_ORDER LITTLE_ENDIAN
25#else
26#define BYTE_ORDER BIG_ENDIAN /* mc68000, tahoe, most others */
27#endif
28#endif BYTE_ORDER
6e8b2eca 29
dad64fdf
BJ
30/*
31 * Definitions for internet protocol version 4.
32 * Per RFC 791, September 1981.
33 */
34#define IPVERSION 4
35
36/*
37 * Structure of an internet header, naked of options.
38 *
53a5409e
BJ
39 * We declare ip_len and ip_off to be short, rather than u_short
40 * pragmatically since otherwise unsigned comparisons can result
41 * against negative integers quite easily, and fail in subtle ways.
dad64fdf 42 */
6e8b2eca 43struct ip {
f8b9a4f5 44#if BYTE_ORDER == LITTLE_ENDIAN
6e8b2eca
BJ
45 u_char ip_hl:4, /* header length */
46 ip_v:4; /* version */
f112c673 47#endif
f8b9a4f5 48#if BYTE_ORDER == BIG_ENDIAN
f112c673
MK
49 u_char ip_v:4, /* version */
50 ip_hl:4; /* header length */
498aff44 51#endif
6e8b2eca 52 u_char ip_tos; /* type of service */
82422b42 53 short ip_len; /* total length */
6e8b2eca 54 u_short ip_id; /* identification */
82422b42 55 short ip_off; /* fragment offset field */
dad64fdf
BJ
56#define IP_DF 0x4000 /* dont fragment flag */
57#define IP_MF 0x2000 /* more fragments flag */
6e8b2eca
BJ
58 u_char ip_ttl; /* time to live */
59 u_char ip_p; /* protocol */
60 u_short ip_sum; /* checksum */
2b4b57cd 61 struct in_addr ip_src,ip_dst; /* source and dest address */
0fcb2ae6
BJ
62};
63
9d059868
MK
64#define IP_MAXPACKET 65535 /* maximum packet size */
65
6e8b2eca 66/*
dad64fdf
BJ
67 * Definitions for options.
68 */
69#define IPOPT_COPIED(o) ((o)&0x80)
579b0a35
MK
70#define IPOPT_CLASS(o) ((o)&0x60)
71#define IPOPT_NUMBER(o) ((o)&0x1f)
dad64fdf
BJ
72
73#define IPOPT_CONTROL 0x00
579b0a35
MK
74#define IPOPT_RESERVED1 0x20
75#define IPOPT_DEBMEAS 0x40
76#define IPOPT_RESERVED2 0x60
dad64fdf
BJ
77
78#define IPOPT_EOL 0 /* end of option list */
79#define IPOPT_NOP 1 /* no operation */
80
81#define IPOPT_RR 7 /* record packet route */
82#define IPOPT_TS 68 /* timestamp */
83#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
84#define IPOPT_LSRR 131 /* loose source route */
85#define IPOPT_SATID 136 /* satnet id */
86#define IPOPT_SSRR 137 /* strict source route */
87
f52643db
MK
88/*
89 * Offsets to fields in options other than EOL and NOP.
90 */
91#define IPOPT_OPTVAL 0 /* option ID */
92#define IPOPT_OLEN 1 /* option length */
93#define IPOPT_OFFSET 2 /* offset within option */
94#define IPOPT_MINOFF 4 /* min value of above */
95
dad64fdf
BJ
96/*
97 * Time stamp option structure.
98 */
99struct ip_timestamp {
100 u_char ipt_code; /* IPOPT_TS */
101 u_char ipt_len; /* size of structure (variable) */
102 u_char ipt_ptr; /* index of current entry */
f8b9a4f5 103#if BYTE_ORDER == LITTLE_ENDIAN
dad64fdf
BJ
104 u_char ipt_flg:4, /* flags, see below */
105 ipt_oflw:4; /* overflow counter */
f112c673 106#endif
f8b9a4f5 107#if BYTE_ORDER == BIG_ENDIAN
f112c673
MK
108 u_char ipt_oflw:4, /* overflow counter */
109 ipt_flg:4; /* flags, see below */
110#endif
f8b9a4f5 111 union ipt_timestamp {
dad64fdf
BJ
112 n_long ipt_time[1];
113 struct ipt_ta {
2b4b57cd 114 struct in_addr ipt_addr;
dad64fdf
BJ
115 n_long ipt_time;
116 } ipt_ta[1];
f8b9a4f5 117 } ipt_timestamp;
dad64fdf
BJ
118};
119
120/* flag bits for ipt_flg */
121#define IPOPT_TS_TSONLY 0 /* timestamps only */
122#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
123#define IPOPT_TS_PRESPEC 2 /* specified modules only */
124
125/* bits for security (not byte swapped) */
126#define IPOPT_SECUR_UNCLASS 0x0000
127#define IPOPT_SECUR_CONFID 0xf135
128#define IPOPT_SECUR_EFTO 0x789a
129#define IPOPT_SECUR_MMMM 0xbc4d
130#define IPOPT_SECUR_RESTR 0xaf13
131#define IPOPT_SECUR_SECRET 0xd788
132#define IPOPT_SECUR_TOPSECRET 0x6bc5
133
dad64fdf
BJ
134/*
135 * Internet implementation parameters.
136 */
6e8b2eca 137#define MAXTTL 255 /* maximum time to live (seconds) */
e3138fb8 138#define IPFRAGTTL 60 /* time to live for frags, slowhz */
b3caeaac 139#define IPTTLDEC 1 /* subtracted when forwarding */
99578149
MK
140
141#define IP_MSS 576 /* default maximum segment size */