OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [ecos-2.0/] [packages/] [net/] [tcpip/] [v2_0/] [include/] [netinet/] [ip_fil_compat.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.