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