Commit | Line | Data |
---|---|---|
8ae0e4b4 | 1 | /* |
0880b18e | 2 | * Copyright (c) 1982, 1986 Regents of the University of California. |
8ae0e4b4 KM |
3 | * All rights reserved. The Berkeley software License Agreement |
4 | * specifies the terms and conditions for redistribution. | |
5 | * | |
e3138fb8 | 6 | * @(#)ip.h 7.3 (Berkeley) %G% |
8ae0e4b4 | 7 | */ |
6e8b2eca | 8 | |
dad64fdf BJ |
9 | /* |
10 | * Definitions for internet protocol version 4. | |
11 | * Per RFC 791, September 1981. | |
12 | */ | |
13 | #define IPVERSION 4 | |
14 | ||
15 | /* | |
16 | * Structure of an internet header, naked of options. | |
17 | * | |
53a5409e BJ |
18 | * We declare ip_len and ip_off to be short, rather than u_short |
19 | * pragmatically since otherwise unsigned comparisons can result | |
20 | * against negative integers quite easily, and fail in subtle ways. | |
dad64fdf | 21 | */ |
6e8b2eca | 22 | struct ip { |
f112c673 | 23 | #if ENDIAN == LITTLE |
6e8b2eca BJ |
24 | u_char ip_hl:4, /* header length */ |
25 | ip_v:4; /* version */ | |
f112c673 MK |
26 | #endif |
27 | #if ENDIAN == BIG | |
28 | u_char ip_v:4, /* version */ | |
29 | ip_hl:4; /* header length */ | |
498aff44 | 30 | #endif |
6e8b2eca | 31 | u_char ip_tos; /* type of service */ |
82422b42 | 32 | short ip_len; /* total length */ |
6e8b2eca | 33 | u_short ip_id; /* identification */ |
82422b42 | 34 | short ip_off; /* fragment offset field */ |
dad64fdf BJ |
35 | #define IP_DF 0x4000 /* dont fragment flag */ |
36 | #define IP_MF 0x2000 /* more fragments flag */ | |
6e8b2eca BJ |
37 | u_char ip_ttl; /* time to live */ |
38 | u_char ip_p; /* protocol */ | |
39 | u_short ip_sum; /* checksum */ | |
2b4b57cd | 40 | struct in_addr ip_src,ip_dst; /* source and dest address */ |
0fcb2ae6 BJ |
41 | }; |
42 | ||
6e8b2eca | 43 | /* |
dad64fdf BJ |
44 | * Definitions for options. |
45 | */ | |
46 | #define IPOPT_COPIED(o) ((o)&0x80) | |
579b0a35 MK |
47 | #define IPOPT_CLASS(o) ((o)&0x60) |
48 | #define IPOPT_NUMBER(o) ((o)&0x1f) | |
dad64fdf BJ |
49 | |
50 | #define IPOPT_CONTROL 0x00 | |
579b0a35 MK |
51 | #define IPOPT_RESERVED1 0x20 |
52 | #define IPOPT_DEBMEAS 0x40 | |
53 | #define IPOPT_RESERVED2 0x60 | |
dad64fdf BJ |
54 | |
55 | #define IPOPT_EOL 0 /* end of option list */ | |
56 | #define IPOPT_NOP 1 /* no operation */ | |
57 | ||
58 | #define IPOPT_RR 7 /* record packet route */ | |
59 | #define IPOPT_TS 68 /* timestamp */ | |
60 | #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ | |
61 | #define IPOPT_LSRR 131 /* loose source route */ | |
62 | #define IPOPT_SATID 136 /* satnet id */ | |
63 | #define IPOPT_SSRR 137 /* strict source route */ | |
64 | ||
f52643db MK |
65 | /* |
66 | * Offsets to fields in options other than EOL and NOP. | |
67 | */ | |
68 | #define IPOPT_OPTVAL 0 /* option ID */ | |
69 | #define IPOPT_OLEN 1 /* option length */ | |
70 | #define IPOPT_OFFSET 2 /* offset within option */ | |
71 | #define IPOPT_MINOFF 4 /* min value of above */ | |
72 | ||
dad64fdf BJ |
73 | /* |
74 | * Time stamp option structure. | |
75 | */ | |
76 | struct ip_timestamp { | |
77 | u_char ipt_code; /* IPOPT_TS */ | |
78 | u_char ipt_len; /* size of structure (variable) */ | |
79 | u_char ipt_ptr; /* index of current entry */ | |
f112c673 | 80 | #if ENDIAN == LITTLE |
dad64fdf BJ |
81 | u_char ipt_flg:4, /* flags, see below */ |
82 | ipt_oflw:4; /* overflow counter */ | |
f112c673 MK |
83 | #endif |
84 | #if ENDIAN == BIG | |
85 | u_char ipt_oflw:4, /* overflow counter */ | |
86 | ipt_flg:4; /* flags, see below */ | |
87 | #endif | |
dad64fdf BJ |
88 | union { |
89 | n_long ipt_time[1]; | |
90 | struct ipt_ta { | |
2b4b57cd | 91 | struct in_addr ipt_addr; |
dad64fdf BJ |
92 | n_long ipt_time; |
93 | } ipt_ta[1]; | |
94 | } | |
95 | }; | |
96 | ||
97 | /* flag bits for ipt_flg */ | |
98 | #define IPOPT_TS_TSONLY 0 /* timestamps only */ | |
99 | #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ | |
100 | #define IPOPT_TS_PRESPEC 2 /* specified modules only */ | |
101 | ||
102 | /* bits for security (not byte swapped) */ | |
103 | #define IPOPT_SECUR_UNCLASS 0x0000 | |
104 | #define IPOPT_SECUR_CONFID 0xf135 | |
105 | #define IPOPT_SECUR_EFTO 0x789a | |
106 | #define IPOPT_SECUR_MMMM 0xbc4d | |
107 | #define IPOPT_SECUR_RESTR 0xaf13 | |
108 | #define IPOPT_SECUR_SECRET 0xd788 | |
109 | #define IPOPT_SECUR_TOPSECRET 0x6bc5 | |
110 | ||
dad64fdf BJ |
111 | /* |
112 | * Internet implementation parameters. | |
113 | */ | |
6e8b2eca | 114 | #define MAXTTL 255 /* maximum time to live (seconds) */ |
e3138fb8 | 115 | #define IPFRAGTTL 60 /* time to live for frags, slowhz */ |
b3caeaac | 116 | #define IPTTLDEC 1 /* subtracted when forwarding */ |
99578149 MK |
117 | |
118 | #define IP_MSS 576 /* default maximum segment size */ |