trailing comment after #else or #endif
[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 *
33eacfa5 7 * @(#)ip.h 7.12 (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 */
8f277b0e 53#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
6e8b2eca
BJ
54 u_char ip_ttl; /* time to live */
55 u_char ip_p; /* protocol */
56 u_short ip_sum; /* checksum */
2b4b57cd 57 struct in_addr ip_src,ip_dst; /* source and dest address */
0fcb2ae6
BJ
58};
59
9d059868
MK
60#define IP_MAXPACKET 65535 /* maximum packet size */
61
3e3821e4
MK
62/*
63 * Definitions for IP type of service (ip_tos)
64 */
65#define IPTOS_LOWDELAY 0x10
66#define IPTOS_THROUGHPUT 0x08
67#define IPTOS_RELIABILITY 0x04
68
69/*
70 * Definitions for IP precedence (also in ip_tos) (hopefully unused)
71 */
72#define IPTOS_PREC_NETCONTROL 0xe0
73#define IPTOS_PREC_INTERNETCONTROL 0xc0
74#define IPTOS_PREC_CRITIC_ECP 0xa0
75#define IPTOS_PREC_FLASHOVERRIDE 0x80
76#define IPTOS_PREC_FLASH 0x60
77#define IPTOS_PREC_IMMEDIATE 0x40
78#define IPTOS_PREC_PRIORITY 0x20
79#define IPTOS_PREC_ROUTINE 0x10
80
6e8b2eca 81/*
dad64fdf
BJ
82 * Definitions for options.
83 */
84#define IPOPT_COPIED(o) ((o)&0x80)
579b0a35
MK
85#define IPOPT_CLASS(o) ((o)&0x60)
86#define IPOPT_NUMBER(o) ((o)&0x1f)
dad64fdf
BJ
87
88#define IPOPT_CONTROL 0x00
579b0a35
MK
89#define IPOPT_RESERVED1 0x20
90#define IPOPT_DEBMEAS 0x40
91#define IPOPT_RESERVED2 0x60
dad64fdf
BJ
92
93#define IPOPT_EOL 0 /* end of option list */
94#define IPOPT_NOP 1 /* no operation */
95
96#define IPOPT_RR 7 /* record packet route */
97#define IPOPT_TS 68 /* timestamp */
98#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
99#define IPOPT_LSRR 131 /* loose source route */
100#define IPOPT_SATID 136 /* satnet id */
101#define IPOPT_SSRR 137 /* strict source route */
102
f52643db
MK
103/*
104 * Offsets to fields in options other than EOL and NOP.
105 */
106#define IPOPT_OPTVAL 0 /* option ID */
107#define IPOPT_OLEN 1 /* option length */
108#define IPOPT_OFFSET 2 /* offset within option */
109#define IPOPT_MINOFF 4 /* min value of above */
110
dad64fdf
BJ
111/*
112 * Time stamp option structure.
113 */
114struct ip_timestamp {
115 u_char ipt_code; /* IPOPT_TS */
116 u_char ipt_len; /* size of structure (variable) */
117 u_char ipt_ptr; /* index of current entry */
f8b9a4f5 118#if BYTE_ORDER == LITTLE_ENDIAN
dad64fdf
BJ
119 u_char ipt_flg:4, /* flags, see below */
120 ipt_oflw:4; /* overflow counter */
f112c673 121#endif
f8b9a4f5 122#if BYTE_ORDER == BIG_ENDIAN
f112c673
MK
123 u_char ipt_oflw:4, /* overflow counter */
124 ipt_flg:4; /* flags, see below */
125#endif
f8b9a4f5 126 union ipt_timestamp {
dad64fdf
BJ
127 n_long ipt_time[1];
128 struct ipt_ta {
2b4b57cd 129 struct in_addr ipt_addr;
dad64fdf
BJ
130 n_long ipt_time;
131 } ipt_ta[1];
f8b9a4f5 132 } ipt_timestamp;
dad64fdf
BJ
133};
134
135/* flag bits for ipt_flg */
136#define IPOPT_TS_TSONLY 0 /* timestamps only */
137#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
f959ef3e 138#define IPOPT_TS_PRESPEC 3 /* specified modules only */
dad64fdf
BJ
139
140/* bits for security (not byte swapped) */
141#define IPOPT_SECUR_UNCLASS 0x0000
142#define IPOPT_SECUR_CONFID 0xf135
143#define IPOPT_SECUR_EFTO 0x789a
144#define IPOPT_SECUR_MMMM 0xbc4d
145#define IPOPT_SECUR_RESTR 0xaf13
146#define IPOPT_SECUR_SECRET 0xd788
147#define IPOPT_SECUR_TOPSECRET 0x6bc5
148
dad64fdf
BJ
149/*
150 * Internet implementation parameters.
151 */
6e8b2eca 152#define MAXTTL 255 /* maximum time to live (seconds) */
33eacfa5 153#define IPDEFTTL 64 /* default ttl, from RFC 1340 */
e3138fb8 154#define IPFRAGTTL 60 /* time to live for frags, slowhz */
b3caeaac 155#define IPTTLDEC 1 /* subtracted when forwarding */
99578149
MK
156
157#define IP_MSS 576 /* default maximum segment size */