source: trunk/src/emx/include/netinet/in.h@ 1505

Last change on this file since 1505 was 1505, checked in by bird, 21 years ago

Adding BSD stuff like there was no tomorrow.

  • Property cvs2svn:cvs-rev set to 1.3
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 9.3 KB
Line 
1/* Modified for emx by hv and em 1994,1996
2 * Modified for gcc/os2 by bird 2003
3 *
4 * Copyright (c) 1982, 1986, 1990 Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * from: @(#)in.h 7.11 (Berkeley) 4/20/91
36 * $Id: in.h,v 1.8 1994/01/28 13:46:02 deraadt Exp $
37 */
38
39#ifndef _NETINET_IN_H_
40#define _NETINET_IN_H_
41
42#ifndef _EMX_TCPIP
43#define _EMX_TCPIP
44#endif
45
46#include <sys/param.h> /* htons() etc. */
47
48#if defined (__cplusplus)
49extern "C" {
50#endif
51
52/*
53 * Constants and structures defined by the internet system,
54 * Per RFC 790, September 1981.
55 */
56
57/*
58 * Protocols
59 */
60#define IPPROTO_IP 0 /* dummy for IP */
61#define IPPROTO_ICMP 1 /* control message protocol */
62#define IPPROTO_IGMP 2 /* group mgmt protocol */
63#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
64#define IPPROTO_TCP 6 /* tcp */
65#define IPPROTO_EGP 8 /* exterior gateway protocol */
66#define IPPROTO_PUP 12 /* pup */
67#define IPPROTO_UDP 17 /* user datagram protocol */
68#define IPPROTO_IDP 22 /* xns idp */
69#ifndef TCPV40HDRS
70#define IPPROTO_TP 29 /* tp-4 w/ class negotiation */
71#define IPPROTO_EON 80 /* ISO cnlp */
72#define IPPROTO_ENCAP 98 /* encapsulation header */
73#endif
74
75#define IPPROTO_RAW 255 /* raw IP packet */
76#define IPPROTO_MAX 256
77
78
79/*
80 * Local port number conventions:
81 * Ports < IPPORT_RESERVED are reserved for
82 * privileged processes (e.g. root).
83 * Ports > IPPORT_USERRESERVED are reserved
84 * for servers, not necessarily privileged.
85 */
86#ifdef TCPV40HDRS
87#define IPPORT_RESERVED 1024
88#define IPPORT_USERRESERVED 5000
89#else
90 /* Changing the ephemeral port #s as per Internet Assigned Numbers Authority's
91 * update as found in JUL '97. [Ref: http://www.isi.edu/div7/iana/descript/html] */
92#define IPPORT_RESERVED 49152 /* Old 1024. Changed as per IANA draft */
93#define IPPORT_USERRESERVED 65535 /* Old 5000. Changed as per IANA draft */
94#endif
95
96#ifdef TCPV40HDRS
97/*
98 * Link numbers
99 */
100#define IMPLINK_IP 155
101#define IMPLINK_LOWEXPER 156
102#define IMPLINK_HIGHEXPER 158
103#endif
104
105/*
106 * Internet address (a structure for historical reasons)
107 */
108#ifndef _STRUCT_IN_ADDR_DECLARED
109struct in_addr {
110 u_long s_addr;
111};
112#define _STRUCT_IN_ADDR_DECLARED
113#endif
114
115
116/*
117 * Definitions of bits in internet address integers.
118 * On subnets, the decomposition of addresses to host and net parts
119 * is done according to subnet mask, not the masks here.
120 */
121#define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
122#define IN_CLASSA_NET 0xff000000
123#define IN_CLASSA_NSHIFT 24
124#define IN_CLASSA_HOST 0x00ffffff
125#define IN_CLASSA_MAX 128
126
127#define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
128#define IN_CLASSB_NET 0xffff0000
129#define IN_CLASSB_NSHIFT 16
130#define IN_CLASSB_HOST 0x0000ffff
131#define IN_CLASSB_MAX 65536
132
133#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
134#define IN_CLASSC_NET 0xffffff00
135#define IN_CLASSC_NSHIFT 8
136#define IN_CLASSC_HOST 0x000000ff
137
138#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
139#ifdef TCPV40HDRS
140#define IN_CLASSD_NET 0xffffffff
141#define IN_CLASSD_HOST 0
142#else
143#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
144#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
145#endif
146#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
147#define IN_MULTICAST(i) IN_CLASSD(i)
148
149#ifdef TCPV40HDRS
150#define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000)
151#else
152#define IN_EXPERIMENTAL(i) (((long)(i) & 0xf0000000) == 0xe0000000)
153#endif
154#define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000)
155
156#define INADDR_ANY (u_long)0x00000000
157#ifndef TCPV40HDRS
158#define INADDR_LOOPBACK (u_long)0x7f000001
159#endif
160#define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */
161
162#define INADDR_UNSPEC_GROUP (u_long)0xe0000000 /* 224.0.0.0 */
163#define INADDR_ALLHOSTS_GROUP (u_long)0xe0000001 /* 224.0.0.1 */
164#define INADDR_MAX_LOCAL_GROUP (u_long)0xe00000ff /* 224.0.0.255 */
165
166#ifndef KERNEL
167#define INADDR_NONE 0xffffffff /* -1 return */
168#endif
169
170#define IN_LOOPBACKNET 127 /* official! */
171
172
173/*
174 * Socket address, internet style. 4.3BSD
175 */
176#ifdef TCPV40HDRS
177struct sockaddr_in {
178 short sin_family;
179 u_short sin_port;
180 struct in_addr sin_addr;
181 char sin_zero[8];
182};
183#else
184#pragma pack(1)
185struct sockaddr_in {
186 u_char sin_len;
187 u_char sin_family;
188 u_short sin_port;
189 struct in_addr sin_addr;
190 char sin_zero[8];
191};
192#pragma pack()
193#endif
194
195/*
196 * Structure used to describe IP options.
197 * Used to store options internally, to pass them to a process,
198 * or to restore options retrieved earlier.
199 * The ip_dst is used for the first-hop gateway when using a source route
200 * (this gets put into the header proper).
201 */
202#ifndef TCPV40HDRS
203#pragma pack(1)
204#endif
205struct ip_opts {
206 struct in_addr ip_dst; /* first hop, 0 w/o src rt */
207 char ip_opts[40]; /* actually variable in size */
208};
209#ifndef TCPV40HDRS
210#pragma pack()
211#endif
212
213/*
214 * Options for use with [gs]etsockopt at the IP level.
215 * First word of comment is data type; bool is stored in int.
216 */
217#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */
218#define IP_MULTICAST_IF 2 /* u_char; set/get IP mcast i/f */
219#define IP_MULTICAST_TTL 3 /* u_char; set/get IP mcast ttl */
220#define IP_MULTICAST_LOOP 4 /* u_char; set/get IP mcast loopback */
221#define IP_ADD_MEMBERSHIP 5 /* ip_mreq; add IP group membership */
222#define IP_DROP_MEMBERSHIP 6 /* ip_mreq; drop IP group membership */
223#ifndef TCPV40HDRS
224#define IP_HDRINCL 7 /* int; header is included with data */
225#define IP_TOS 8 /* int; IP type of service and preced. */
226#define IP_TTL 9 /* int; IP time to live */
227#define IP_RECVOPTS 10 /* bool; receive all IP opts w/dgram */
228#define IP_RECVRETOPTS 11 /* bool; receive IP opts for response */
229#define IP_RECVDSTADDR 12 /* bool; receive IP dst addr w/dgram */
230#define IP_RETOPTS 13 /* ip_opts; set/get IP options */
231#define IP_RECVTRRI 14 /* bool; receive token ring routing inf */
232#endif
233
234/*
235 * Defaults and limits for options
236 */
237#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */
238#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
239#define IP_MAX_MEMBERSHIPS 20 /* per socket; must fit in one mbuf */
240#ifndef TCPV40HDRS
241#define MAX_IN_MULTI 16*IP_MAX_MEMBERSHIPS /* 320 max per os2 */
242extern u_short CntInMulti;
243#endif
244
245/*
246 * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
247 */
248#ifndef TCPV40HDRS
249#pragma pack(1)
250#endif
251struct ip_mreq {
252 struct in_addr imr_multiaddr; /* IP multicast address of group */
253 struct in_addr imr_interface; /* local IP address of interface */
254};
255#ifndef TCPV40HDRS
256#pragma pack()
257#endif
258
259#ifdef TCPV40HDRS
260/* for functions */
261#include <arpa/inet.h>
262
263#else
264
265/*
266 * Definitions for inet sysctl operations.
267 *
268 * Third level is protocol number.
269 * Fourth level is desired variable within that protocol.
270 */
271#define IPPROTO_MAXID (IPPROTO_IDP + 1) /* don't list to IPPROTO_MAX */
272
273#define CTL_IPPROTO_NAMES { \
274 { "ip", CTLTYPE_NODE }, \
275 { "icmp", CTLTYPE_NODE }, \
276 { "igmp", CTLTYPE_NODE }, \
277 { "ggp", CTLTYPE_NODE }, \
278 { 0, 0 }, \
279 { 0, 0 }, \
280 { "tcp", CTLTYPE_NODE }, \
281 { 0, 0 }, \
282 { "egp", CTLTYPE_NODE }, \
283 { 0, 0 }, \
284 { 0, 0 }, \
285 { 0, 0 }, \
286 { "pup", CTLTYPE_NODE }, \
287 { 0, 0 }, \
288 { 0, 0 }, \
289 { 0, 0 }, \
290 { 0, 0 }, \
291 { "udp", CTLTYPE_NODE }, \
292 { 0, 0 }, \
293 { 0, 0 }, \
294 { 0, 0 }, \
295 { 0, 0 }, \
296 { "idp", CTLTYPE_NODE }, \
297}
298#endif /*TCPV40HDRS (else) */
299
300#if defined (__cplusplus)
301}
302#endif
303
304#endif /* !_NETINET_IN_H_ */
Note: See TracBrowser for help on using the repository browser.