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