]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
d7e50217 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
d7e50217 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
d7e50217 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * Copyright (C) 1993-1997 by Darren Reed. | |
27 | * | |
28 | * Redistribution and use in source and binary forms are permitted | |
29 | * provided that this notice is preserved and due credit is given | |
30 | * to the original author and the contributors. | |
31 | * | |
32 | * @(#)ip_compat.h 1.8 1/14/96 | |
33 | */ | |
9bccf70c | 34 | #include <sys/appleapiopts.h> |
1c79356b A |
35 | |
36 | #if 0 | |
37 | ||
38 | #ifndef __IP_COMPAT_H__ | |
39 | #define __IP_COMPAT_H__ | |
40 | ||
41 | #ifndef __P | |
42 | # ifdef __STDC__ | |
43 | # define __P(x) x | |
44 | # else | |
45 | # define __P(x) () | |
46 | # define const | |
47 | # endif | |
48 | #endif | |
49 | ||
50 | #ifndef SOLARIS | |
51 | #define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4))) | |
52 | #endif | |
53 | ||
54 | #if defined(_KERNEL) && !defined(KERNEL) | |
55 | # define KERNEL | |
56 | #endif | |
57 | #if defined(KERNEL) && !defined(_KERNEL) | |
58 | # define _KERNEL | |
59 | #endif | |
60 | #if!defined(__KERNEL__) && defined(KERNEL) | |
61 | # define __KERNEL__ | |
62 | #endif | |
63 | ||
64 | #if defined(__SVR4) || defined(__svr4__) || defined(__sgi) | |
65 | #define index strchr | |
66 | # if !defined(_KERNEL) | |
67 | # define bzero(a,b) memset(a,0,b) | |
68 | # define bcmp memcmp | |
69 | # define bcopy(a,b,c) memmove(b,a,c) | |
70 | # endif | |
71 | #endif | |
72 | ||
73 | struct ether_addr { | |
74 | u_char ether_addr_octet[6]; | |
75 | }; | |
76 | ||
1c79356b A |
77 | #ifdef linux |
78 | # include <sys/sysmacros.h> | |
79 | #endif | |
80 | #if SOLARIS | |
81 | # define MTYPE(m) ((m)->b_datap->db_type) | |
82 | # include <sys/ioccom.h> | |
83 | # include <sys/sysmacros.h> | |
84 | # include <sys/kmem.h> | |
85 | /* | |
86 | * because Solaris 2 defines these in two places :-/ | |
87 | */ | |
88 | # undef IPOPT_EOL | |
89 | # undef IPOPT_NOP | |
90 | # undef IPOPT_LSRR | |
91 | # undef IPOPT_RR | |
92 | # undef IPOPT_SSRR | |
93 | # ifndef _KERNEL | |
94 | # define _KERNEL | |
95 | # undef RES_INIT | |
96 | # include <inet/common.h> | |
97 | # include <inet/ip.h> | |
98 | # include <inet/ip_ire.h> | |
99 | # undef _KERNEL | |
100 | # else /* _KERNEL */ | |
101 | # include <inet/common.h> | |
102 | # include <inet/ip.h> | |
103 | # include <inet/ip_ire.h> | |
104 | # endif /* _KERNEL */ | |
105 | #endif /* SOLARIS */ | |
106 | #define IPMINLEN(i, h) ((i)->ip_len >= ((i)->ip_hl * 4 + sizeof(struct h))) | |
107 | ||
108 | #ifndef IP_OFFMASK | |
109 | #define IP_OFFMASK 0x1fff | |
110 | #endif | |
111 | ||
112 | #if BSD > 199306 | |
113 | # define USE_QUAD_T | |
114 | # define U_QUAD_T u_quad_t | |
115 | # define QUAD_T quad_t | |
116 | #else /* BSD > 199306 */ | |
117 | # define U_QUAD_T u_long | |
118 | # define QUAD_T long | |
119 | #endif /* BSD > 199306 */ | |
120 | ||
121 | /* | |
122 | * These operating systems already take care of the problem for us. | |
123 | */ | |
124 | #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || \ | |
125 | defined(__sgi) | |
126 | typedef u_int32_t u_32_t; | |
127 | #else | |
128 | /* | |
129 | * Really, any arch where sizeof(long) != sizeof(int). | |
130 | */ | |
131 | # if defined(__alpha__) || defined(__alpha) | |
132 | typedef unsigned int u_32_t; | |
133 | # else | |
134 | typedef unsigned long u_32_t; | |
135 | # endif | |
136 | #endif /* __NetBSD__ || __OpenBSD__ || __FreeBSD__ || __sgi */ | |
137 | ||
138 | #ifndef MAX | |
139 | #define MAX(a,b) (((a) > (b)) ? (a) : (b)) | |
140 | #endif | |
141 | ||
142 | /* | |
143 | * Security Options for Intenet Protocol (IPSO) as defined in RFC 1108. | |
144 | * | |
145 | * Basic Option | |
146 | * | |
147 | * 00000001 - (Reserved 4) | |
148 | * 00111101 - Top Secret | |
149 | * 01011010 - Secret | |
150 | * 10010110 - Confidential | |
151 | * 01100110 - (Reserved 3) | |
152 | * 11001100 - (Reserved 2) | |
153 | * 10101011 - Unclassified | |
154 | * 11110001 - (Reserved 1) | |
155 | */ | |
156 | #define IPSO_CLASS_RES4 0x01 | |
157 | #define IPSO_CLASS_TOPS 0x3d | |
158 | #define IPSO_CLASS_SECR 0x5a | |
159 | #define IPSO_CLASS_CONF 0x96 | |
160 | #define IPSO_CLASS_RES3 0x66 | |
161 | #define IPSO_CLASS_RES2 0xcc | |
162 | #define IPSO_CLASS_UNCL 0xab | |
163 | #define IPSO_CLASS_RES1 0xf1 | |
164 | ||
165 | #define IPSO_AUTH_GENSER 0x80 | |
166 | #define IPSO_AUTH_ESI 0x40 | |
167 | #define IPSO_AUTH_SCI 0x20 | |
168 | #define IPSO_AUTH_NSA 0x10 | |
169 | #define IPSO_AUTH_DOE 0x08 | |
170 | #define IPSO_AUTH_UN 0x06 | |
171 | #define IPSO_AUTH_FTE 0x01 | |
172 | ||
173 | /* | |
174 | * IP option #defines | |
175 | */ | |
176 | /*#define IPOPT_RR 7 */ | |
177 | #define IPOPT_ZSU 10 /* ZSU */ | |
178 | #define IPOPT_MTUP 11 /* MTUP */ | |
179 | #define IPOPT_MTUR 12 /* MTUR */ | |
180 | #define IPOPT_ENCODE 15 /* ENCODE */ | |
181 | /*#define IPOPT_TS 68 */ | |
182 | #define IPOPT_TR 82 /* TR */ | |
183 | /*#define IPOPT_SECURITY 130 */ | |
184 | /*#define IPOPT_LSRR 131 */ | |
185 | #define IPOPT_E_SEC 133 /* E-SEC */ | |
186 | #define IPOPT_CIPSO 134 /* CIPSO */ | |
187 | /*#define IPOPT_SATID 136 */ | |
188 | #ifndef IPOPT_SID | |
189 | # define IPOPT_SID IPOPT_SATID | |
190 | #endif | |
191 | /*#define IPOPT_SSRR 137 */ | |
192 | #define IPOPT_ADDEXT 147 /* ADDEXT */ | |
193 | #define IPOPT_VISA 142 /* VISA */ | |
194 | #define IPOPT_IMITD 144 /* IMITD */ | |
195 | #define IPOPT_EIP 145 /* EIP */ | |
196 | #define IPOPT_FINN 205 /* FINN */ | |
197 | ||
198 | ||
199 | #if defined(__FreeBSD__) && defined(KERNEL) | |
200 | # if __FreeBSD__ < 3 | |
201 | # include <machine/spl.h> | |
202 | # endif | |
1c79356b A |
203 | #endif /* __FreeBSD__ && KERNEL */ |
204 | ||
205 | /* | |
206 | * Build some macros and #defines to enable the same code to compile anywhere | |
207 | * Well, that's the idea, anyway :-) | |
208 | */ | |
9bccf70c | 209 | #ifdef KERNEL |
1c79356b A |
210 | # if SOLARIS |
211 | # define MUTEX_ENTER(x) mutex_enter(x) | |
212 | # define MUTEX_EXIT(x) mutex_exit(x) | |
213 | # define MTOD(m,t) (t)((m)->b_rptr) | |
214 | # define IRCOPY(a,b,c) copyin((a), (b), (c)) | |
215 | # define IWCOPY(a,b,c) copyout((a), (b), (c)) | |
216 | # define FREE_MB_T(m) freemsg(m) | |
217 | # define SPL_NET(x) ; | |
218 | # define SPL_IMP(x) ; | |
219 | # undef SPL_X | |
220 | # define SPL_X(x) ; | |
221 | # ifdef sparc | |
222 | # define ntohs(x) (x) | |
223 | # define ntohl(x) (x) | |
224 | # define htons(x) (x) | |
225 | # define htonl(x) (x) | |
226 | # endif /* sparc */ | |
227 | # define KMALLOC(a,b,c) (a) = (b)kmem_alloc((c), KM_NOSLEEP) | |
228 | # define GET_MINOR(x) getminor(x) | |
229 | typedef struct qif { | |
230 | struct qif *qf_next; | |
231 | ill_t *qf_ill; | |
232 | kmutex_t qf_lock; | |
233 | void *qf_iptr; | |
234 | void *qf_optr; | |
235 | queue_t *qf_in; | |
236 | queue_t *qf_out; | |
237 | struct qinit *qf_wqinfo; | |
238 | struct qinit *qf_rqinfo; | |
239 | struct qinit qf_wqinit; | |
240 | struct qinit qf_rqinit; | |
241 | mblk_t *qf_m; /* These three fields are for passing data up from */ | |
242 | queue_t *qf_q; /* fr_qin and fr_qout to the packet processing. */ | |
243 | int qf_off; | |
244 | int qf_len; /* this field is used for in ipfr_fastroute */ | |
245 | char qf_name[8]; | |
246 | /* | |
247 | * in case the ILL has disappeared... | |
248 | */ | |
249 | int qf_hl; /* header length */ | |
250 | } qif_t; | |
251 | extern ill_t *get_unit __P((char *)); | |
252 | # define GETUNIT(n) get_unit((n)) | |
253 | # else /* SOLARIS */ | |
254 | # if defined(__sgi) | |
255 | # include <sys/ksynch.h> | |
256 | # define IPF_LOCK_PL plhi | |
257 | # include <sys/sema.h> | |
258 | #undef kmutex_t | |
259 | typedef struct { | |
260 | lock_t *l; | |
261 | int pl; | |
262 | } kmutex_t; | |
263 | # define MUTEX_ENTER(x) (x)->pl = LOCK((x)->l, IPF_LOCK_PL); | |
264 | # define MUTEX_EXIT(x) UNLOCK((x)->l, (x)->pl); | |
265 | # else /* __sgi */ | |
266 | # define MUTEX_ENTER(x) ; | |
267 | # define MUTEX_EXIT(x) ; | |
268 | # endif /* __sgi */ | |
269 | # ifndef linux | |
270 | # define FREE_MB_T(m) m_freem(m) | |
271 | # define MTOD(m,t) mtod(m,t) | |
272 | # define IRCOPY(a,b,c) bcopy((a), (b), (c)) | |
273 | # define IWCOPY(a,b,c) bcopy((a), (b), (c)) | |
274 | # endif /* !linux */ | |
275 | # endif /* SOLARIS */ | |
276 | ||
277 | # ifdef sun | |
278 | # if !SOLARIS | |
279 | # include <sys/kmem_alloc.h> | |
280 | # define GETUNIT(n) ifunit((n), IFNAMSIZ) | |
281 | # endif | |
282 | # else | |
283 | # ifndef linux | |
284 | # define GETUNIT(n) ifunit((n)) | |
285 | # endif | |
286 | # endif /* sun */ | |
287 | ||
288 | # if defined(sun) && !defined(linux) || defined(__sgi) | |
289 | # define UIOMOVE(a,b,c,d) uiomove((caddr_t)a,b,c,d) | |
290 | # define SLEEP(id, n) sleep((id), PZERO+1) | |
291 | # define WAKEUP(id) wakeup(id) | |
292 | # define KFREE(x) kmem_free((char *)(x), sizeof(*(x))) | |
293 | # define KFREES(x,s) kmem_free((char *)(x), (s)) | |
294 | # if !SOLARIS | |
295 | extern void m_copydata __P((struct mbuf *, int, int, caddr_t)); | |
296 | extern void m_copyback __P((struct mbuf *, int, int, caddr_t)); | |
297 | # endif | |
298 | # ifdef __sgi | |
299 | # include <sys/kmem.h> | |
300 | # include <sys/ddi.h> | |
301 | # define KMALLOC(a,b,c) (a) = (b)kmem_alloc((c), KM_NOSLEEP) | |
302 | # define GET_MINOR(x) getminor(x) | |
303 | # else | |
304 | # if !SOLARIS | |
305 | # define KMALLOC(a,b,c) (a) = (b)new_kmem_alloc((c), KMEM_NOSLEEP) | |
306 | # endif /* SOLARIS */ | |
307 | # endif /* __sgi */ | |
308 | # endif /* sun && !linux */ | |
309 | # ifndef GET_MINOR | |
310 | # define GET_MINOR(x) minor(x) | |
311 | # endif | |
312 | # if (BSD >= 199306) || defined(__FreeBSD__) | |
313 | # include <vm/vm.h> | |
314 | # if !defined(__FreeBSD__) || (defined (__FreeBSD__) && __FreeBSD__>=3) | |
315 | # include <vm/vm_extern.h> | |
316 | # include <sys/proc.h> | |
317 | extern vm_map_t kmem_map; | |
318 | # else /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD__>=3) */ | |
319 | # include <vm/vm_kern.h> | |
320 | # endif /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD__>=3) */ | |
321 | # ifdef M_PFIL | |
322 | # define KMALLOC(a, b, c) MALLOC((a), b, (c), M_PFIL, M_NOWAIT) | |
323 | # define KFREE(x) FREE((x), M_PFIL) | |
324 | # define KFREES(x,s) FREE((x), M_PFIL) | |
325 | # else | |
326 | # define KMALLOC(a, b, c) MALLOC((a), b, (c), M_TEMP, M_NOWAIT) | |
327 | # define KFREE(x) FREE((x), M_TEMP) | |
328 | # define KFREES(x,s) FREE((x), M_TEMP) | |
329 | # endif /* M_PFIL */ | |
330 | # define UIOMOVE(a,b,c,d) uiomove(a,b,d) | |
331 | # define SLEEP(id, n) tsleep((id), PPAUSE|PCATCH, n, 0) | |
332 | # define WAKEUP(id) wakeup(id) | |
333 | # endif /* BSD */ | |
334 | # if defined(NetBSD) && NetBSD <= 1991011 && NetBSD >= 199407 | |
335 | # define SPL_NET(x) x = splsoftnet() | |
336 | # define SPL_X(x) (void) splx(x) | |
337 | # else | |
338 | # if !SOLARIS && !defined(linux) | |
339 | # define SPL_IMP(x) x = splimp() | |
340 | # define SPL_NET(x) x = splnet() | |
341 | # define SPL_X(x) (void) splx(x) | |
342 | # endif | |
343 | # endif /* NetBSD && NetBSD <= 1991011 && NetBSD >= 199407 */ | |
344 | # define PANIC(x,y) if (x) panic y | |
345 | #else /* KERNEL */ | |
346 | # define SLEEP(x,y) ; | |
347 | # define WAKEUP(x) ; | |
348 | # define PANIC(x,y) ; | |
349 | # define MUTEX_ENTER(x) ; | |
350 | # define MUTEX_EXIT(x) ; | |
351 | # define SPL_NET(x) ; | |
352 | # define SPL_IMP(x) ; | |
353 | # undef SPL_X | |
354 | # define SPL_X(x) ; | |
355 | /*# define KMALLOC(a,b,c) (a) = (b)malloc(c) */ | |
356 | # define KFREE(x) FREE(x) | |
357 | # define KFREES(x,s) FREE(x) | |
358 | # define GETUNIT(x) get_unit(x) | |
359 | # define IRCOPY(a,b,c) bcopy((a), (b), (c)) | |
360 | # define IWCOPY(a,b,c) bcopy((a), (b), (c)) | |
361 | #endif /* KERNEL */ | |
362 | ||
363 | #if SOLARIS | |
364 | typedef mblk_t mb_t; | |
365 | #else | |
366 | # ifdef linux | |
367 | typedef struct sk_buff mb_t; | |
368 | # else | |
369 | typedef struct mbuf mb_t; | |
370 | # endif | |
371 | #endif /* SOLARIS */ | |
372 | ||
373 | #if defined(linux) || defined(__sgi) | |
374 | /* | |
375 | * These #ifdef's are here mainly for linux, but who knows, they may | |
376 | * not be in other places or maybe one day linux will grow up and some | |
377 | * of these will turn up there too. | |
378 | */ | |
379 | #ifndef ICMP_MINLEN | |
380 | # define ICMP_MINLEN 8 | |
381 | #endif | |
382 | #ifndef ICMP_UNREACH | |
383 | # define ICMP_UNREACH ICMP_DEST_UNREACH | |
384 | #endif | |
385 | #ifndef ICMP_SOURCEQUENCH | |
386 | # define ICMP_SOURCEQUENCH ICMP_SOURCE_QUENCH | |
387 | #endif | |
388 | #ifndef ICMP_TIMXCEED | |
389 | # define ICMP_TIMXCEED ICMP_TIME_EXCEEDED | |
390 | #endif | |
391 | #ifndef ICMP_PARAMPROB | |
392 | # define ICMP_PARAMPROB ICMP_PARAMETERPROB | |
393 | #endif | |
394 | #ifndef ICMP_TSTAMP | |
395 | # define ICMP_TSTAMP ICMP_TIMESTAMP | |
396 | #endif | |
397 | #ifndef ICMP_TSTAMPREPLY | |
398 | # define ICMP_TSTAMPREPLY ICMP_TIMESTAMPREPLY | |
399 | #endif | |
400 | #ifndef ICMP_IREQ | |
401 | # define ICMP_IREQ ICMP_INFO_REQUEST | |
402 | #endif | |
403 | #ifndef ICMP_IREQREPLY | |
404 | # define ICMP_IREQREPLY ICMP_INFO_REPLY | |
405 | #endif | |
406 | #ifndef ICMP_MASKREQ | |
407 | # define ICMP_MASKREQ ICMP_ADDRESS | |
408 | #endif | |
409 | #ifndef ICMP_MASKREPLY | |
410 | # define ICMP_MASKREPLY ICMP_ADDRESSREPLY | |
411 | #endif | |
412 | #ifndef IPVERSION | |
413 | # define IPVERSION 4 | |
414 | #endif | |
415 | #ifndef IPOPT_MINOFF | |
416 | # define IPOPT_MINOFF 4 | |
417 | #endif | |
418 | #ifndef IPOPT_COPIED | |
419 | # define IPOPT_COPIED(x) ((x)&0x80) | |
420 | #endif | |
421 | #ifndef IPOPT_EOL | |
422 | # define IPOPT_EOL 0 | |
423 | #endif | |
424 | #ifndef IPOPT_NOP | |
425 | # define IPOPT_NOP 1 | |
426 | #endif | |
427 | #ifndef IP_MF | |
428 | # define IP_MF ((u_short)0x2000) | |
429 | #endif | |
430 | #ifndef ETHERTYPE_IP | |
431 | # define ETHERTYPE_IP ((u_short)0x0800) | |
432 | #endif | |
433 | #ifndef TH_FIN | |
434 | # define TH_FIN 0x01 | |
435 | #endif | |
436 | #ifndef TH_SYN | |
437 | # define TH_SYN 0x02 | |
438 | #endif | |
439 | #ifndef TH_RST | |
440 | # define TH_RST 0x04 | |
441 | #endif | |
442 | #ifndef TH_PUSH | |
443 | # define TH_PUSH 0x08 | |
444 | #endif | |
445 | #ifndef TH_ACK | |
446 | # define TH_ACK 0x10 | |
447 | #endif | |
448 | #ifndef TH_URG | |
449 | # define TH_URG 0x20 | |
450 | #endif | |
451 | #ifndef IPOPT_EOL | |
452 | # define IPOPT_EOL 0 | |
453 | #endif | |
454 | #ifndef IPOPT_NOP | |
455 | # define IPOPT_NOP 1 | |
456 | #endif | |
457 | #ifndef IPOPT_RR | |
458 | # define IPOPT_RR 7 | |
459 | #endif | |
460 | #ifndef IPOPT_TS | |
461 | # define IPOPT_TS 68 | |
462 | #endif | |
463 | #ifndef IPOPT_SECURITY | |
464 | # define IPOPT_SECURITY 130 | |
465 | #endif | |
466 | #ifndef IPOPT_LSRR | |
467 | # define IPOPT_LSRR 131 | |
468 | #endif | |
469 | #ifndef IPOPT_SATID | |
470 | # define IPOPT_SATID 136 | |
471 | #endif | |
472 | #ifndef IPOPT_SSRR | |
473 | # define IPOPT_SSRR 137 | |
474 | #endif | |
475 | #ifndef IPOPT_SECUR_UNCLASS | |
476 | # define IPOPT_SECUR_UNCLASS ((u_short)0x0000) | |
477 | #endif | |
478 | #ifndef IPOPT_SECUR_CONFID | |
479 | # define IPOPT_SECUR_CONFID ((u_short)0xf135) | |
480 | #endif | |
481 | #ifndef IPOPT_SECUR_EFTO | |
482 | # define IPOPT_SECUR_EFTO ((u_short)0x789a) | |
483 | #endif | |
484 | #ifndef IPOPT_SECUR_MMMM | |
485 | # define IPOPT_SECUR_MMMM ((u_short)0xbc4d) | |
486 | #endif | |
487 | #ifndef IPOPT_SECUR_RESTR | |
488 | # define IPOPT_SECUR_RESTR ((u_short)0xaf13) | |
489 | #endif | |
490 | #ifndef IPOPT_SECUR_SECRET | |
491 | # define IPOPT_SECUR_SECRET ((u_short)0xd788) | |
492 | #endif | |
493 | #ifndef IPOPT_SECUR_TOPSECRET | |
494 | # define IPOPT_SECUR_TOPSECRET ((u_short)0x6bc5) | |
495 | #endif | |
496 | #ifndef IPOPT_OLEN | |
497 | # define IPOPT_OLEN 1 | |
498 | #endif | |
499 | #endif /* linux || __sgi */ | |
500 | ||
501 | #ifdef linux | |
502 | /* | |
503 | * TCP States | |
504 | */ | |
505 | #define TCPS_CLOSED 0 /* closed */ | |
506 | #define TCPS_LISTEN 1 /* listening for connection */ | |
507 | #define TCPS_SYN_SENT 2 /* active, have sent syn */ | |
508 | #define TCPS_SYN_RECEIVED 3 /* have send and received syn */ | |
509 | /* states < TCPS_ESTABLISHED are those where connections not established */ | |
510 | #define TCPS_ESTABLISHED 4 /* established */ | |
511 | #define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */ | |
512 | /* states > TCPS_CLOSE_WAIT are those where user has closed */ | |
513 | #define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */ | |
514 | #define TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */ | |
515 | #define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */ | |
516 | /* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ | |
517 | #define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ | |
518 | #define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ | |
519 | ||
520 | /* | |
521 | * file flags. | |
522 | */ | |
523 | #define FWRITE WRITE | |
524 | #define FREAD READ | |
525 | /* | |
526 | * mbuf related problems. | |
527 | */ | |
528 | #define mtod(m,t) (t)((m)->data) | |
529 | #define m_len len | |
530 | #define m_next next | |
531 | ||
532 | #define IP_DF 0x8000 | |
533 | ||
534 | typedef struct { | |
535 | __u16 th_sport; | |
536 | __u16 th_dport; | |
537 | __u32 th_seq; | |
538 | __u32 th_ack; | |
539 | # if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\ | |
540 | defined(vax) | |
541 | __u8 th_res:4; | |
542 | __u8 th_off:4; | |
543 | #else | |
544 | __u8 th_off:4; | |
545 | __u8 th_res:4; | |
546 | #endif | |
547 | __u8 th_flags; | |
548 | __u16 th_win; | |
549 | __u16 th_sum; | |
550 | __u16 th_urp; | |
551 | } tcphdr_t; | |
552 | ||
553 | typedef struct { | |
554 | __u16 uh_sport; | |
555 | __u16 uh_dport; | |
556 | __u16 uh_ulen; | |
557 | __u16 uh_sum; | |
558 | } udphdr_t; | |
559 | ||
560 | typedef struct { | |
561 | # if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\ | |
562 | defined(vax) | |
563 | __u8 ip_hl:4; | |
564 | __u8 ip_v:4; | |
565 | # else | |
566 | __u8 ip_hl:4; | |
567 | __u8 ip_v:4; | |
568 | # endif | |
569 | __u8 ip_tos; | |
570 | __u16 ip_len; | |
571 | __u16 ip_id; | |
572 | __u16 ip_off; | |
573 | __u8 ip_ttl; | |
574 | __u8 ip_p; | |
575 | __u16 ip_sum; | |
576 | struct in_addr ip_src; | |
577 | struct in_addr ip_dst; | |
578 | } ip_t; | |
579 | ||
580 | /* | |
581 | * Structure of an icmp header. | |
582 | */ | |
583 | typedef struct icmp { | |
584 | u_char icmp_type; /* type of message, see below */ | |
585 | u_char icmp_code; /* type sub code */ | |
586 | u_short icmp_cksum; /* ones complement cksum of struct */ | |
587 | union { | |
588 | u_char ih_pptr; /* ICMP_PARAMPROB */ | |
589 | struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ | |
590 | struct ih_idseq { | |
591 | n_short icd_id; | |
592 | n_short icd_seq; | |
593 | } ih_idseq; | |
594 | int ih_void; | |
595 | } icmp_hun; | |
596 | # define icmp_pptr icmp_hun.ih_pptr | |
597 | # define icmp_gwaddr icmp_hun.ih_gwaddr | |
598 | # define icmp_id icmp_hun.ih_idseq.icd_id | |
599 | # define icmp_seq icmp_hun.ih_idseq.icd_seq | |
600 | # define icmp_void icmp_hun.ih_void | |
601 | union { | |
602 | struct id_ts { | |
603 | n_time its_otime; | |
604 | n_time its_rtime; | |
605 | n_time its_ttime; | |
606 | } id_ts; | |
607 | struct id_ip { | |
608 | ip_t idi_ip; | |
609 | /* options and then 64 bits of data */ | |
610 | } id_ip; | |
611 | u_long id_mask; | |
612 | char id_data[1]; | |
613 | } icmp_dun; | |
614 | # define icmp_otime icmp_dun.id_ts.its_otime | |
615 | # define icmp_rtime icmp_dun.id_ts.its_rtime | |
616 | # define icmp_ttime icmp_dun.id_ts.its_ttime | |
617 | # define icmp_ip icmp_dun.id_ip.idi_ip | |
618 | # define icmp_mask icmp_dun.id_mask | |
619 | # define icmp_data icmp_dun.id_data | |
620 | } icmphdr_t; | |
621 | ||
622 | # ifndef LINUX_IPOVLY | |
623 | # define LINUX_IPOVLY | |
624 | struct ipovly { | |
625 | caddr_t ih_next, ih_prev; /* for protocol sequence q's */ | |
626 | u_char ih_x1; /* (unused) */ | |
627 | u_char ih_pr; /* protocol */ | |
628 | short ih_len; /* protocol length */ | |
629 | struct in_addr ih_src; /* source internet address */ | |
630 | struct in_addr ih_dst; /* destination internet address */ | |
631 | }; | |
632 | # endif | |
633 | ||
634 | typedef struct { | |
635 | __u8 ether_dhost[6]; | |
636 | __u8 ether_shost[6]; | |
637 | __u16 ether_type; | |
638 | } ether_header_t; | |
639 | ||
640 | typedef struct uio { | |
641 | int uio_resid; | |
642 | int uio_rw; | |
643 | caddr_t uio_buf; | |
644 | } uio_t; | |
645 | ||
646 | # define UIO_READ 0 | |
647 | # define UIO_WRITE 1 | |
648 | # define UIOMOVE(a, b, c, d) uiomove(a,b,c,d) | |
649 | ||
650 | /* | |
651 | * For masking struct ifnet onto struct device | |
652 | */ | |
653 | # define if_name name | |
654 | ||
655 | # ifdef KERNEL | |
656 | # define GETUNIT(x) dev_get(x) | |
657 | # define FREE_MB_T(m) kfree_skb(m, FREE_WRITE) | |
658 | # define uniqtime do_gettimeofday | |
659 | # undef INT_MAX | |
660 | # undef UINT_MAX | |
661 | # undef LONG_MAX | |
662 | # undef ULONG_MAX | |
663 | # include <linux/netdevice.h> | |
664 | # define SPL_X(x) | |
665 | # define SPL_NET(x) | |
666 | # define SPL_IMP(x) | |
667 | ||
668 | # define bcmp(a,b,c) memcmp(a,b,c) | |
669 | # define bcopy(a,b,c) memcpy(b,a,c) | |
670 | # define bzero(a,c) memset(a,0,c) | |
671 | ||
672 | # define UNITNAME(n) dev_get((n)) | |
673 | ||
674 | # define KMALLOC(a,b,c) (a) = (b)kmalloc((c), GFP_ATOMIC) | |
675 | # define KFREE(x) kfree_s((x), sizeof(*(x))) | |
676 | # define KFREES(x,s) kfree_s((x), (s)) | |
677 | # define IRCOPY(a,b,c) { \ | |
678 | error = verify_area(VERIFY_READ, (a) ,(c)); \ | |
679 | if (!error) \ | |
680 | memcpy_fromfs((b), (a), (c)); \ | |
681 | } | |
682 | # define IWCOPY(a,b,c) { \ | |
683 | error = verify_area(VERIFY_WRITE, (b), (c)); \ | |
684 | if (!error) \ | |
685 | memcpy_tofs((b), (a), (c)); \ | |
686 | } | |
687 | # else | |
688 | # define __KERNEL__ | |
689 | # undef INT_MAX | |
690 | # undef UINT_MAX | |
691 | # undef LONG_MAX | |
692 | # undef ULONG_MAX | |
693 | # define s8 __s8 | |
694 | # define u8 __u8 | |
695 | # define s16 __s16 | |
696 | # define u16 __u16 | |
697 | # define s32 __s32 | |
698 | # define u32 __u32 | |
699 | # include <linux/netdevice.h> | |
700 | # undef __KERNEL__ | |
701 | # endif | |
702 | # define ifnet device | |
703 | #else | |
704 | typedef struct tcphdr tcphdr_t; | |
705 | typedef struct udphdr udphdr_t; | |
706 | typedef struct icmp icmphdr_t; | |
707 | typedef struct ip ip_t; | |
708 | typedef struct ether_header ether_header_t; | |
709 | #endif /* linux */ | |
710 | typedef struct tcpiphdr tcpiphdr_t; | |
711 | ||
712 | #if defined(hpux) || defined(linux) | |
713 | struct ether_addr { | |
714 | char ether_addr_octet[6]; | |
715 | }; | |
716 | #endif | |
717 | ||
718 | /* | |
719 | * XXX - This is one of those *awful* hacks which nobody likes | |
720 | */ | |
721 | #ifdef ultrix | |
722 | #define A_A | |
723 | #else | |
724 | #define A_A & | |
725 | #endif | |
726 | ||
727 | #ifndef ICMP_ROUTERADVERT | |
728 | # define ICMP_ROUTERADVERT 9 | |
729 | #endif | |
730 | #ifndef ICMP_ROUTERSOLICIT | |
731 | # define ICMP_ROUTERSOLICIT 10 | |
732 | #endif | |
733 | ||
734 | #endif /* __IP_COMPAT_H__ */ | |
735 | ||
736 | #endif /* #if 0 */ |