]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/Include/netinet/ip.h
StdLib: Remove EfiSocketLib and Ip4Config Protocol dependency.
[mirror_edk2.git] / StdLib / Include / netinet / ip.h
CommitLineData
d7ce7006 1/*\r
2 * Copyright (c) 1982, 1986, 1993\r
3 * The Regents of the University of California. All rights reserved.\r
4 *\r
5 * Portions copyright (c) 1999, 2000\r
6 * Intel Corporation.\r
7 * All rights reserved.\r
8 * \r
9 * Redistribution and use in source and binary forms, with or without\r
10 * modification, are permitted provided that the following conditions\r
11 * are met:\r
12 * \r
13 * 1. Redistributions of source code must retain the above copyright\r
14 * notice, this list of conditions and the following disclaimer.\r
15 * \r
16 * 2. Redistributions in binary form must reproduce the above copyright\r
17 * notice, this list of conditions and the following disclaimer in the\r
18 * documentation and/or other materials provided with the distribution.\r
19 * \r
20 * 3. All advertising materials mentioning features or use of this software\r
21 * must display the following acknowledgement:\r
22 * \r
23 * This product includes software developed by the University of\r
24 * California, Berkeley, Intel Corporation, and its contributors.\r
25 * \r
26 * 4. Neither the name of University, Intel Corporation, or their respective\r
27 * contributors may be used to endorse or promote products derived from\r
28 * this software without specific prior written permission.\r
29 * \r
30 * THIS SOFTWARE IS PROVIDED BY THE REGENTS, INTEL CORPORATION AND\r
31 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\r
32 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
33 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS,\r
34 * INTEL CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
35 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
36 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
40 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
41 *\r
42 * @(#)ip.h 8.2 (Berkeley) 6/1/94\r
43 * $Id: ip.h,v 1.1.1.1 2006/05/30 06:12:48 hhzhou Exp $\r
44 */\r
45\r
46#ifndef _NETINET_IP_H_\r
47#define _NETINET_IP_H_\r
48\r
49#ifndef _ORG_FREEBSD_\r
50#define _IP_VHL\r
51#endif\r
52\r
53/*\r
54 * Definitions for internet protocol version 4.\r
55 * Per RFC 791, September 1981.\r
56 */\r
57#define IPVERSION 4\r
58\r
59/*\r
60 * Structure of an internet header, naked of options.\r
61 */\r
62struct ip {\r
63#ifdef _IP_VHL\r
64 u_char ip_vhl; /* version << 4 | header length >> 2 */\r
65#else\r
66#if BYTE_ORDER == LITTLE_ENDIAN\r
67 u_int ip_hl:4, /* header length */\r
68 ip_v:4; /* version */\r
69#endif\r
70#if BYTE_ORDER == BIG_ENDIAN\r
71 u_int ip_v:4, /* version */\r
72 ip_hl:4; /* header length */\r
73#endif\r
74#endif /* not _IP_VHL */\r
75 u_char ip_tos; /* type of service */\r
76 u_short ip_len; /* total length */\r
77 u_short ip_id; /* identification */\r
78 u_short ip_off; /* fragment offset field */\r
79#define IP_RF 0x8000 /* reserved fragment flag */\r
80#define IP_DF 0x4000 /* dont fragment flag */\r
81#define IP_MF 0x2000 /* more fragments flag */\r
82#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */\r
83 u_char ip_ttl; /* time to live */\r
84 u_char ip_p; /* protocol */\r
85 u_short ip_sum; /* checksum */\r
86 struct in_addr ip_src,ip_dst; /* source and dest address */\r
87};\r
88\r
89#ifdef _IP_VHL\r
90#define IP_MAKE_VHL(v, hl) ((v) << 4 | (hl))\r
91#define IP_VHL_HL(vhl) ((vhl) & 0x0f)\r
92#define IP_VHL_V(vhl) ((vhl) >> 4)\r
93#define IP_VHL_BORING 0x45\r
94#endif\r
95\r
96#define IP_MAXPACKET 65535 /* maximum packet size */\r
97\r
98/*\r
99 * Definitions for IP type of service (ip_tos)\r
100 */\r
101#define IPTOS_LOWDELAY 0x10\r
102#define IPTOS_THROUGHPUT 0x08\r
103#define IPTOS_RELIABILITY 0x04\r
104#define IPTOS_MINCOST 0x02\r
105\r
106/*\r
107 * Definitions for IP precedence (also in ip_tos) (hopefully unused)\r
108 */\r
109#define IPTOS_PREC_NETCONTROL 0xe0\r
110#define IPTOS_PREC_INTERNETCONTROL 0xc0\r
111#define IPTOS_PREC_CRITIC_ECP 0xa0\r
112#define IPTOS_PREC_FLASHOVERRIDE 0x80\r
113#define IPTOS_PREC_FLASH 0x60\r
114#define IPTOS_PREC_IMMEDIATE 0x40\r
115#define IPTOS_PREC_PRIORITY 0x20\r
116#define IPTOS_PREC_ROUTINE 0x00\r
117\r
118/*\r
119 * Definitions for options.\r
120 */\r
121#define IPOPT_COPIED(o) ((o)&0x80)\r
122#define IPOPT_CLASS(o) ((o)&0x60)\r
123#define IPOPT_NUMBER(o) ((o)&0x1f)\r
124\r
125#define IPOPT_CONTROL 0x00\r
126#define IPOPT_RESERVED1 0x20\r
127#define IPOPT_DEBMEAS 0x40\r
128#define IPOPT_RESERVED2 0x60\r
129\r
130#define IPOPT_EOL 0 /* end of option list */\r
131#define IPOPT_NOP 1 /* no operation */\r
132\r
133#define IPOPT_RR 7 /* record packet route */\r
134#define IPOPT_TS 68 /* timestamp */\r
135#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */\r
136#define IPOPT_LSRR 131 /* loose source route */\r
137#define IPOPT_SATID 136 /* satnet id */\r
138#define IPOPT_SSRR 137 /* strict source route */\r
139#define IPOPT_RA 148 /* router alert */\r
140\r
141/*\r
142 * Offsets to fields in options other than EOL and NOP.\r
143 */\r
144#define IPOPT_OPTVAL 0 /* option ID */\r
145#define IPOPT_OLEN 1 /* option length */\r
146#define IPOPT_OFFSET 2 /* offset within option */\r
147#define IPOPT_MINOFF 4 /* min value of above */\r
148\r
149/*\r
150 * Time stamp option structure.\r
151 */\r
152struct ip_timestamp {\r
153 u_char ipt_code; /* IPOPT_TS */\r
154 u_char ipt_len; /* size of structure (variable) */\r
155 u_char ipt_ptr; /* index of current entry */\r
156#if BYTE_ORDER == LITTLE_ENDIAN\r
157 u_int ipt_flg:4, /* flags, see below */\r
158 ipt_oflw:4; /* overflow counter */\r
159#endif\r
160#if BYTE_ORDER == BIG_ENDIAN\r
161 u_int ipt_oflw:4, /* overflow counter */\r
162 ipt_flg:4; /* flags, see below */\r
163#endif\r
164 union ipt_timestamp {\r
165 n_long ipt_time[1];\r
166 struct ipt_ta {\r
167 struct in_addr ipt_addr;\r
168 n_long ipt_time;\r
169 } ipt_ta[1];\r
170 } ipt_timestamp;\r
171};\r
172\r
173/* flag bits for ipt_flg */\r
174#define IPOPT_TS_TSONLY 0 /* timestamps only */\r
175#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */\r
176#define IPOPT_TS_PRESPEC 3 /* specified modules only */\r
177\r
178/* bits for security (not byte swapped) */\r
179#define IPOPT_SECUR_UNCLASS 0x0000\r
180#define IPOPT_SECUR_CONFID 0xf135\r
181#define IPOPT_SECUR_EFTO 0x789a\r
182#define IPOPT_SECUR_MMMM 0xbc4d\r
183#define IPOPT_SECUR_RESTR 0xaf13\r
184#define IPOPT_SECUR_SECRET 0xd788\r
185#define IPOPT_SECUR_TOPSECRET 0x6bc5\r
186\r
187/*\r
188 * Internet implementation parameters.\r
189 */\r
190#define MAXTTL 255 /* maximum time to live (seconds) */\r
191#define IPDEFTTL 64 /* default ttl, from RFC 1340 */\r
192#define IPFRAGTTL 60 /* time to live for frags, slowhz */\r
193#define IPTTLDEC 1 /* subtracted when forwarding */\r
194\r
195#define IP_MSS 576 /* default maximum segment size */\r
196\r
197#endif\r