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