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