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