source: vendor/emx/current/include/netinet/in.h

Last change on this file was 18, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.3 KB
Line 
1/* Modified for emx by hv and em 1994,1996
2 *
3 * Copyright (c) 1982, 1986, 1990 Regents of the University of California.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by the University of
17 * California, Berkeley and its contributors.
18 * 4. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * from: @(#)in.h 7.11 (Berkeley) 4/20/91
35 * $Id: in.h,v 1.8 1994/01/28 13:46:02 deraadt Exp $
36 */
37
38#ifndef _NETINET_IN_H_
39#define _NETINET_IN_H_
40
41#ifndef _EMX_TCPIP
42#define _EMX_TCPIP
43#endif
44
45#include <sys/param.h> /* htons() etc. */
46
47#if defined (__cplusplus)
48extern "C" {
49#endif
50
51/*
52 * Constants and structures defined by the internet system,
53 * Per RFC 790, September 1981.
54 */
55
56/*
57 * Protocols
58 */
59#define IPPROTO_IP 0 /* dummy for IP */
60#define IPPROTO_ICMP 1 /* control message protocol */
61#define IPPROTO_IGMP 2 /* group mgmt protocol */
62#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
63#define IPPROTO_TCP 6 /* tcp */
64#define IPPROTO_EGP 8 /* exterior gateway protocol */
65#define IPPROTO_PUP 12 /* pup */
66#define IPPROTO_UDP 17 /* user datagram protocol */
67#define IPPROTO_IDP 22 /* xns idp */
68#define IPPROTO_TP 29 /* tp-4 w/ class negotiation */
69#define IPPROTO_EON 80 /* ISO cnlp */
70
71#define IPPROTO_RAW 255 /* raw IP packet */
72#define IPPROTO_MAX 256
73
74
75/*
76 * Local port number conventions:
77 * Ports < IPPORT_RESERVED are reserved for
78 * privileged processes (e.g. root).
79 * Ports > IPPORT_USERRESERVED are reserved
80 * for servers, not necessarily privileged.
81 */
82#define IPPORT_RESERVED 1024
83#define IPPORT_USERRESERVED 5000
84
85/*
86 * Internet address (a structure for historical reasons)
87 */
88struct in_addr {
89 u_long s_addr;
90};
91
92/*
93 * Definitions of bits in internet address integers.
94 * On subnets, the decomposition of addresses to host and net parts
95 * is done according to subnet mask, not the masks here.
96 */
97#define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
98#define IN_CLASSA_NET 0xff000000
99#define IN_CLASSA_NSHIFT 24
100#define IN_CLASSA_HOST 0x00ffffff
101#define IN_CLASSA_MAX 128
102
103#define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
104#define IN_CLASSB_NET 0xffff0000
105#define IN_CLASSB_NSHIFT 16
106#define IN_CLASSB_HOST 0x0000ffff
107#define IN_CLASSB_MAX 65536
108
109#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
110#define IN_CLASSC_NET 0xffffff00
111#define IN_CLASSC_NSHIFT 8
112#define IN_CLASSC_HOST 0x000000ff
113
114#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
115#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
116#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
117#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
118#define IN_MULTICAST(i) IN_CLASSD(i)
119
120#define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000)
121#define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000)
122
123#define INADDR_ANY (u_long)0x00000000
124#define INADDR_LOOPBACK (u_long)0x7f000001
125#define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */
126#ifndef KERNEL
127#define INADDR_NONE 0xffffffff /* -1 return */
128#endif
129
130#define INADDR_UNSPEC_GROUP (u_long)0xe0000000 /* 224.0.0.0 */
131#define INADDR_ALLHOSTS_GROUP (u_long)0xe0000001 /* 224.0.0.1 */
132#define INADDR_MAX_LOCAL_GROUP (u_long)0xe00000ff /* 224.0.0.255 */
133
134#define IN_LOOPBACKNET 127 /* official! */
135
136/*
137 * Define a macro to stuff the loopback address into an Internet address
138 */
139#define IN_SET_LOOPBACK_ADDR(a) { \
140 (a)->sin_addr.s_addr = htonl(INADDR_LOOPBACK); \
141 (a)->sin_family = AF_INET; }
142/*
143 * Socket address, internet style. 4.3BSD
144 */
145struct sockaddr_in {
146 short sin_family;
147 u_short sin_port;
148 struct in_addr sin_addr;
149 char sin_zero[8];
150};
151
152/*
153 * Structure used to describe IP options.
154 * Used to store options internally, to pass them to a process,
155 * or to restore options retrieved earlier.
156 * The ip_dst is used for the first-hop gateway when using a source route
157 * (this gets put into the header proper).
158 */
159struct ip_opts {
160 struct in_addr ip_dst; /* first hop, 0 w/o src rt */
161 char ip_opts[40]; /* actually variable in size */
162};
163
164/*
165 * Options for use with [gs]etsockopt at the IP level.
166 * First word of comment is data type; bool is stored in int.
167 */
168#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */
169
170#define IP_MULTICAST_IF 2 /* u_char; set/get IP mcast i/f */
171#define IP_MULTICAST_TTL 3 /* u_char; set/get IP mcast ttl */
172#define IP_MULTICAST_LOOP 4 /* u_char; set/get IP mcast loopback */
173#define IP_ADD_MEMBERSHIP 5 /* ip_mreq; add IP group membership */
174#define IP_DROP_MEMBERSHIP 6 /* ip_mreq; drop IP group membership */
175
176#ifndef __EMX__ /* not supported so far */
177#define IP_HDRINCL 2 /* int; header is included with data */
178#define IP_TOS 3 /* int; IP type of service and preced */
179#define IP_TTL 4 /* int; IP time to live */
180#define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */
181#define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */
182#define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */
183#define IP_RETOPTS 8 /* ip_opts; set/get IP options */
184#endif
185
186#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */
187#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
188#define IP_MAX_MEMBERSHIPS 20 /* per socket; must fit in one mbuf */
189
190/*
191 * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
192 */
193struct ip_mreq {
194 struct in_addr imr_multiaddr; /* IP multicast address of group */
195 struct in_addr imr_interface; /* local IP address of interface */
196};
197
198/* prototypes for functions in inet(3) */
199extern u_long inet_addr(__const__ char*);
200extern struct in_addr inet_makeaddr(u_long, u_long);
201extern u_long inet_network(__const__ char*);
202extern char *inet_ntoa(struct in_addr);
203extern u_long inet_netof(struct in_addr);
204extern u_long inet_lnaof(struct in_addr);
205
206#if defined (__cplusplus)
207}
208#endif
209
210#endif /* !_NETINET_IN_H_ */
Note: See TracBrowser for help on using the repository browser.