tcpdump  4.99.1
About: tcpdump is a tool for network monitoring and data acquisition.
  Fossies Dox: tcpdump-4.99.1.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ip.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1982, 1986, 1993
3  * The Regents of the University of California. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  * must display the following acknowledgement:
15  * This product includes software developed by the University of
16  * California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  * may be used to endorse or promote products derived from this software
19  * without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * @(#)ip.h 8.2 (Berkeley) 6/1/94
34  */
35 
36 #ifndef netdissect_ip_h
37 #define netdissect_ip_h
38 
39 /*
40  * Definitions for internet protocol version 4.
41  * Per RFC 791, September 1981.
42  */
43 #define IPVERSION 4
44 
45 /*
46  * Structure of an internet header, naked of options.
47  *
48  * We declare ip_len and ip_off to be short, rather than u_short
49  * pragmatically since otherwise unsigned comparisons can result
50  * against negative integers quite easily, and fail in subtle ways.
51  */
52 struct ip {
53  nd_uint8_t ip_vhl; /* header length, version */
54 #define IP_V(ip) ((GET_U_1((ip)->ip_vhl) & 0xf0) >> 4)
55 #define IP_HL(ip) (GET_U_1((ip)->ip_vhl) & 0x0f)
56  nd_uint8_t ip_tos; /* type of service */
57  nd_uint16_t ip_len; /* total length */
58  nd_uint16_t ip_id; /* identification */
59  nd_uint16_t ip_off; /* fragment offset field */
60 #define IP_DF 0x4000 /* don't fragment flag */
61 #define IP_MF 0x2000 /* more fragments flag */
62 #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
63  nd_uint8_t ip_ttl; /* time to live */
64  nd_uint8_t ip_p; /* protocol */
65  nd_uint16_t ip_sum; /* checksum */
66  nd_ipv4 ip_src,ip_dst; /* source and dest address */
67 };
68 
69 #define IP_MAXPACKET 65535 /* maximum packet size */
70 
71 /*
72  * Definitions for IP type of service (ip_tos)
73  */
74 #define IPTOS_LOWDELAY 0x10
75 #define IPTOS_THROUGHPUT 0x08
76 #define IPTOS_RELIABILITY 0x04
77 
78 /*
79  * Definitions for IP precedence (also in ip_tos) (hopefully unused)
80  */
81 #define IPTOS_PREC_NETCONTROL 0xe0
82 #define IPTOS_PREC_INTERNETCONTROL 0xc0
83 #define IPTOS_PREC_CRITIC_ECP 0xa0
84 #define IPTOS_PREC_FLASHOVERRIDE 0x80
85 #define IPTOS_PREC_FLASH 0x60
86 #define IPTOS_PREC_IMMEDIATE 0x40
87 #define IPTOS_PREC_PRIORITY 0x20
88 #define IPTOS_PREC_ROUTINE 0x00
89 
90 /*
91  * Definitions for options.
92  */
93 #define IPOPT_COPIED(o) ((o)&0x80)
94 #define IPOPT_CLASS(o) ((o)&0x60)
95 #define IPOPT_NUMBER(o) ((o)&0x1f)
96 
97 #define IPOPT_CONTROL 0x00
98 #define IPOPT_RESERVED1 0x20
99 #define IPOPT_DEBMEAS 0x40
100 #define IPOPT_RESERVED2 0x60
101 
102 #define IPOPT_EOL 0 /* end of option list */
103 #define IPOPT_NOP 1 /* no operation */
104 
105 #define IPOPT_RR 7 /* record packet route */
106 #define IPOPT_TS 68 /* timestamp */
107 #define IPOPT_RFC1393 82 /* traceroute RFC 1393 */
108 #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
109 #define IPOPT_LSRR 131 /* loose source route */
110 #define IPOPT_SATID 136 /* satnet id */
111 #define IPOPT_SSRR 137 /* strict source route */
112 #define IPOPT_RA 148 /* router-alert, rfc2113 */
113 
114 /*
115  * Offsets to fields in options other than EOL and NOP.
116  */
117 #define IPOPT_OPTVAL 0 /* option ID */
118 #define IPOPT_OLEN 1 /* option length */
119 #define IPOPT_OFFSET 2 /* offset within option */
120 #define IPOPT_MINOFF 4 /* min value of above */
121 
122 /*
123  * Time stamp option structure.
124  */
125 struct ip_timestamp {
126  nd_uint8_t ipt_code; /* IPOPT_TS */
127  nd_uint8_t ipt_len; /* size of structure (variable) */
128  nd_uint8_t ipt_ptr; /* index of current entry */
129  nd_uint8_t ipt_oflwflg; /* flags, overflow counter */
130 #define IPTS_OFLW(ip) (((ipt)->ipt_oflwflg & 0xf0) >> 4)
131 #define IPTS_FLG(ip) ((ipt)->ipt_oflwflg & 0x0f)
134  struct ipt_ta {
137  } ipt_ta[1];
139 };
140 
141 /* flag bits for ipt_flg */
142 #define IPOPT_TS_TSONLY 0 /* timestamps only */
143 #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
144 #define IPOPT_TS_PRESPEC 3 /* specified modules only */
145 
146 /* bits for security (not byte swapped) */
147 #define IPOPT_SECUR_UNCLASS 0x0000
148 #define IPOPT_SECUR_CONFID 0xf135
149 #define IPOPT_SECUR_EFTO 0x789a
150 #define IPOPT_SECUR_MMMM 0xbc4d
151 #define IPOPT_SECUR_RESTR 0xaf13
152 #define IPOPT_SECUR_SECRET 0xd788
153 #define IPOPT_SECUR_TOPSECRET 0x6bc5
154 
155 /*
156  * Internet implementation parameters.
157  */
158 #define MAXTTL 255 /* maximum time to live (seconds) */
159 #define IPDEFTTL 64 /* default ttl, from RFC 1340 */
160 #define IPFRAGTTL 60 /* time to live for frags, slowhz */
161 #define IPTTLDEC 1 /* subtracted when forwarding */
162 
163 #define IP_MSS 576 /* default maximum segment size */
164 #endif /* netdissect_ip_h */
unsigned char nd_uint16_t[2]
Definition: netdissect.h:47
unsigned char nd_ipv4[4]
Definition: netdissect.h:92
unsigned char nd_uint32_t[4]
Definition: netdissect.h:49
unsigned char nd_uint8_t[1]
Definition: netdissect.h:46
nd_uint8_t ipt_code
Definition: ip.h:126
nd_uint8_t ipt_oflwflg
Definition: ip.h:129
union ip_timestamp::ipt_timestamp ipt_timestamp
nd_uint8_t ipt_ptr
Definition: ip.h:128
nd_uint8_t ipt_len
Definition: ip.h:127
Definition: ip.h:52
nd_uint16_t ip_len
Definition: ip.h:57
nd_uint8_t ip_tos
Definition: ip.h:56
nd_uint8_t ip_ttl
Definition: ip.h:63
nd_ipv4 ip_dst
Definition: ip.h:66
nd_uint8_t ip_vhl
Definition: ip.h:53
nd_uint8_t ip_p
Definition: ip.h:64
nd_uint16_t ip_id
Definition: ip.h:58
nd_ipv4 ip_src
Definition: ip.h:66
nd_uint16_t ip_off
Definition: ip.h:59
nd_uint16_t ip_sum
Definition: ip.h:65
nd_uint32_t ipt_time[1]
Definition: ip.h:133
struct ip_timestamp::ipt_timestamp::ipt_ta ipt_ta[1]