1 in.h |
1 /* IN.H |
|
2 * |
|
3 * Portions copyright (c) 1997-2006 Symbian Software Ltd. All rights reserved. |
|
4 */ |
|
5 |
|
6 /** @file |
|
7 @internalComponent |
|
8 */ |
|
9 |
|
10 /* |
|
11 * Copyright (c) 1982, 1986 Regents of the University of California. |
|
12 * All rights reserved. |
|
13 * |
|
14 * Redistribution and use in source and binary forms are permitted |
|
15 * provided that this notice is preserved and that due credit is given |
|
16 * to the University of California at Berkeley. The name of the University |
|
17 * may not be used to endorse or promote products derived from this |
|
18 * software without specific prior written permission. This software |
|
19 * is provided ``as is'' without express or implied warranty. |
|
20 */ |
|
21 |
|
22 /* |
|
23 * Constants and structures defined by the internet system, |
|
24 * Per RFC 790, September 1981. |
|
25 */ |
|
26 |
|
27 #ifndef _NETINET_IN_H |
|
28 #define _NETINET_IN_H |
|
29 |
|
30 #ifdef __cplusplus |
|
31 extern "C" { |
|
32 #endif |
|
33 #include <_ansi.h> |
|
34 |
|
35 /** |
|
36 Protocols |
|
37 */ |
|
38 #define IPPROTO_IP 0x100 /* dummy for IP */ |
|
39 #define IPPROTO_ICMP 1 /* control message protocol */ |
|
40 #define IPPROTO_IGMP 2 /* group control protocol */ |
|
41 #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ |
|
42 #define IPPROTO_ENCAP 4 /* IP in IP encapsulation */ |
|
43 #define IPPROTO_TCP 6 /* tcp */ |
|
44 #define IPPROTO_EGP 8 /* exterior gateway protocol */ |
|
45 #define IPPROTO_PUP 12 /* pup */ |
|
46 #define IPPROTO_UDP 17 /* user datagram protocol */ |
|
47 #define IPPROTO_IDP 22 /* xns idp */ |
|
48 #define IPPROTO_HELLO 63 /* "hello" routing protocol */ |
|
49 #define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */ |
|
50 #define IPPROTO_EON 80 /* ISO clnp */ |
|
51 #define IPPROTO_RAW 255 /* raw IP packet */ |
|
52 #define IPPROTO_MAX 0x101 |
|
53 |
|
54 /** |
|
55 Port/socket numbers: network standard functions |
|
56 */ |
|
57 #define IPPORT_ECHO 7 |
|
58 #define IPPORT_DISCARD 9 |
|
59 #define IPPORT_SYSTAT 11 |
|
60 #define IPPORT_DAYTIME 13 |
|
61 #define IPPORT_NETSTAT 15 |
|
62 #define IPPORT_FTP 21 |
|
63 #define IPPORT_TELNET 23 |
|
64 #define IPPORT_SMTP 25 |
|
65 #define IPPORT_TIMESERVER 37 |
|
66 #define IPPORT_NAMESERVER 42 |
|
67 #define IPPORT_WHOIS 43 |
|
68 #define IPPORT_MTP 57 |
|
69 |
|
70 /** |
|
71 Port/socket numbers: host specific functions |
|
72 */ |
|
73 #define IPPORT_TFTP 69 |
|
74 #define IPPORT_RJE 77 |
|
75 #define IPPORT_FINGER 79 |
|
76 #define IPPORT_TTYLINK 87 |
|
77 #define IPPORT_SUPDUP 95 |
|
78 |
|
79 /** |
|
80 UNIX TCP sockets |
|
81 */ |
|
82 #define IPPORT_EXECSERVER 512 |
|
83 #define IPPORT_LOGINSERVER 513 |
|
84 #define IPPORT_CMDSERVER 514 |
|
85 #define IPPORT_EFSSERVER 520 |
|
86 |
|
87 /** |
|
88 UNIX UDP sockets |
|
89 */ |
|
90 #define IPPORT_BIFFUDP 512 |
|
91 #define IPPORT_WHOSERVER 513 |
|
92 #define IPPORT_ROUTESERVER 520 /* 520+1 also used */ |
|
93 |
|
94 /** |
|
95 Ports < IPPORT_RESERVED are reserved for |
|
96 privileged processes (e.g. root). |
|
97 Ports > IPPORT_USERRESERVED are reserved |
|
98 for servers, not necessarily privileged. |
|
99 */ |
|
100 #define IPPORT_RESERVED 1024 |
|
101 #define IPPORT_USERRESERVED 5000 |
|
102 |
|
103 /** |
|
104 Link numbers |
|
105 */ |
|
106 #define IMPLINK_IP 155 |
|
107 #define IMPLINK_LOWEXPER 156 |
|
108 #define IMPLINK_HIGHEXPER 158 |
|
109 |
|
110 /** |
|
111 Internet address |
|
112 This definition contains obsolete fields for compatibility |
|
113 with SunOS 3.x and 4.2bsd. The presence of subnets renders |
|
114 divisions into fixed fields misleading at best. New code |
|
115 should use only the s_addr field. |
|
116 @publishedAll |
|
117 @released |
|
118 */ |
|
119 struct in_addr { |
|
120 union { |
|
121 struct { u_char s_b1, s_b2, s_b3, s_b4; } S_un_b; |
|
122 struct { u_short s_w1, s_w2; } S_un_w; |
|
123 u_long S_addr; |
|
124 } S_un; |
|
125 /** |
|
126 @publishedAll |
|
127 @released |
|
128 */ |
|
129 #define s_addr S_un.S_addr /* should be used for all code */ |
|
130 /** |
|
131 @publishedAll |
|
132 @released |
|
133 */ |
|
134 #define s_host S_un.S_un_b.s_b2 /* OBSOLETE: host on imp */ |
|
135 /** |
|
136 @publishedAll |
|
137 @released |
|
138 */ |
|
139 #define s_net S_un.S_un_b.s_b1 /* OBSOLETE: network */ |
|
140 /** |
|
141 @publishedAll |
|
142 @released |
|
143 */ |
|
144 #define s_imp S_un.S_un_w.s_w2 /* OBSOLETE: imp */ |
|
145 /** |
|
146 @publishedAll |
|
147 @released |
|
148 */ |
|
149 #define s_impno S_un.S_un_b.s_b4 /* OBSOLETE: imp # */ |
|
150 /** |
|
151 @publishedAll |
|
152 @released |
|
153 */ |
|
154 #define s_lh S_un.S_un_b.s_b3 /* OBSOLETE: logical host */ |
|
155 }; |
|
156 |
|
157 /** |
|
158 Definitions of bits in internet address integers. |
|
159 On subnets, the decomposition of addresses to host and net parts |
|
160 is done according to subnet mask, not the masks here. |
|
161 */ |
|
162 #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0) |
|
163 #define IN_CLASSA_NET 0xff000000 |
|
164 #define IN_CLASSA_NSHIFT 24 |
|
165 #define IN_CLASSA_HOST 0x00ffffff |
|
166 #define IN_CLASSA_MAX 128 |
|
167 |
|
168 #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000) |
|
169 #define IN_CLASSB_NET 0xffff0000 |
|
170 #define IN_CLASSB_NSHIFT 16 |
|
171 #define IN_CLASSB_HOST 0x0000ffff |
|
172 #define IN_CLASSB_MAX 65536 |
|
173 |
|
174 #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000) |
|
175 #define IN_CLASSC_NET 0xffffff00 |
|
176 #define IN_CLASSC_NSHIFT 8 |
|
177 #define IN_CLASSC_HOST 0x000000ff |
|
178 #define IN_CLASSC_MAX 16777216L |
|
179 |
|
180 #define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000) |
|
181 #define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */ |
|
182 #define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ |
|
183 #define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */ |
|
184 #define IN_MULTICAST(i) IN_CLASSD(i) |
|
185 |
|
186 #define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000) |
|
187 #define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000) |
|
188 |
|
189 #define INADDR_ANY (u_long)0x00000000 |
|
190 #define INADDR_LOOPBACK (u_long)0x7F000001 |
|
191 #define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */ |
|
192 |
|
193 #define INADDR_UNSPEC_GROUP (u_long)0xe0000000 /* 224.0.0.0 */ |
|
194 #define INADDR_ALLHOSTS_GROUP (u_long)0xe0000001 /* 224.0.0.1 */ |
|
195 #define INADDR_MAX_LOCAL_GROUP (u_long)0xe00000ff /* 224.0.0.255 */ |
|
196 |
|
197 #define INADDR_NONE INADDR_BROADCAST /* traditional, but misleading */ |
|
198 |
|
199 #define IN_LOOPBACKNET 127 /* official! */ |
|
200 |
|
201 /** |
|
202 Define a macro to stuff the loopback address into an Internet address |
|
203 0x0100007F is htonl(INADDR_LOOPBACK) without the overhead of a function call. |
|
204 */ |
|
205 #define IN_SET_LOOPBACK_ADDR(a) \ |
|
206 { (a)->sin_addr.s_addr = 0x0100007F; (a)->sin_family = AF_INET; } |
|
207 |
|
208 /** |
|
209 Socket address, internet style. |
|
210 */ |
|
211 struct sockaddr_in { |
|
212 u_short sin_family; |
|
213 u_short sin_port; |
|
214 struct in_addr sin_addr; |
|
215 char sin_zero[20]; |
|
216 }; |
|
217 |
|
218 /** |
|
219 * Options for use with [gs]etsockopt at the IP level. |
|
220 * NB. The negative option values below are not supported and must not |
|
221 * be used in calls to the [gs]etsockopt() API as they will be ignored |
|
222 * or cause an error. |
|
223 */ |
|
224 #define SOL_IP 0x100 /* options for IP level */ |
|
225 |
|
226 #define IP_OPTIONS 0x306 /* set/get IP per-packet options */ |
|
227 #define IP_HDRINCL 0x308 /* int; header is included with data (raw) */ |
|
228 #define IP_TOS 0x309 /* int; IP type of service and precedence */ |
|
229 #define IP_TTL 0x310 /* int; IP time to live */ |
|
230 #define IP_RECVOPTS -1 /* bool; receive all IP options w/datagram */ |
|
231 #define IP_RECVRETOPTS -2 /* bool; receive IP options for response */ |
|
232 #define IP_RECVDSTADDR -3 /* bool; receive IP dst addr w/datagram */ |
|
233 #define IP_RETOPTS -4 /* ip_opts; set/get IP per-packet options */ |
|
234 #define IP_MULTICAST_IF -5 /* set/get IP multicast interface */ |
|
235 #define IP_MULTICAST_TTL -6 /* set/get IP multicast timetolive */ |
|
236 #define IP_MULTICAST_LOOP -7 /* set/get IP multicast loopback */ |
|
237 #define IP_ADD_MEMBERSHIP -8 /* add an IP group membership */ |
|
238 #define IP_DROP_MEMBERSHIP -9 /* drop an IP group membership */ |
|
239 |
|
240 #define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ |
|
241 #define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ |
|
242 |
|
243 /** |
|
244 Options for use with [gs]etsockopt at the TCP level. |
|
245 */ |
|
246 #define SOL_TCP 0x106 /* options for TCP level */ |
|
247 |
|
248 #define TCP_SENDWINDOW 0x301 /* int: send window size in bytes */ |
|
249 #define TCP_RECVWINDOW 0x302 /* int: recv window size in bytes */ |
|
250 #define TCP_NODELAY 0x304 /* disable Nagle's algorithm */ |
|
251 #define TCP_KEEPALIVE 0x305 /* keep connections alive */ |
|
252 |
|
253 /** |
|
254 Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. |
|
255 @publishedAll |
|
256 @released |
|
257 */ |
|
258 struct ip_mreq { |
|
259 struct in_addr imr_multiaddr; /* IP multicast address of group */ |
|
260 struct in_addr imr_interface; /* local IP address of interface */ |
|
261 }; |
|
262 |
|
263 /* |
|
264 EPOC32 is little-endian |
|
265 @publishedAll |
|
266 @released |
|
267 */ |
|
268 IMPORT_C unsigned short htons(unsigned short hs); |
|
269 /** |
|
270 @publishedAll |
|
271 @released |
|
272 */ |
|
273 IMPORT_C unsigned long htonl(unsigned long hl); |
|
274 |
|
275 |
|
276 #define ntohl htonl |
|
277 #define ntohs htons |
|
278 |
|
279 #ifdef __cplusplus |
|
280 } |
|
281 #endif |
|
282 |
|
283 #endif /* _NETINET_IN_H */ |