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