ip_fil_compat.h
来自「eCos操作系统源码」· C头文件 代码 · 共 869 行 · 第 1/2 页
H
869 行
//==========================================================================//// include/netinet/ip_compat.h//// ////==========================================================================//####BSDCOPYRIGHTBEGIN####//// -------------------------------------------//// Portions of this software may have been derived from OpenBSD or other sources,// and are covered by the appropriate copyright disclaimers included herein.//// -------------------------------------------////####BSDCOPYRIGHTEND####//==========================================================================//#####DESCRIPTIONBEGIN####//// Author(s): gthomas// Contributors: gthomas// Date: 2000-01-10// Purpose: // Description: // ////####DESCRIPTIONEND####////==========================================================================/* $OpenBSD: ip_fil_compat.h,v 1.11 1999/12/15 05:20:21 kjell Exp $ *//* * Copyright (C) 1993-1998 by Darren Reed. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and due credit is given * to the original author and the contributors. * * @(#)ip_compat.h 1.8 1/14/96 */#ifndef _NETINET_IP_COMPAT_H__#define _NETINET_IP_COMPAT_H__#ifndef __P# ifdef __STDC__# define __P(x) x# else# define __P(x) ()# endif#endif#ifndef __STDC__# undef const# define const#endif#ifndef SOLARIS#define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4)))#endif#if defined(_KERNEL) || defined(KERNEL) || defined(__KERNEL__)# undef KERNEL# undef _KERNEL# undef __KERNEL__# define KERNEL# define _KERNEL# define __KERNEL__#endif#if defined(__SVR4) || defined(__svr4__) || defined(__sgi)#define index strchr# if !defined(KERNEL)# define bzero(a,b) memset(a,0,b)# define bcmp memcmp# define bcopy(a,b,c) memmove(b,a,c)# endif#endif#ifndef offsetof#define offsetof(t,m) (int)((&((t *)0L)->m))#endif#if defined(__sgi) || defined(bsdi)struct ether_addr { u_char ether_addr_octet[6];};#endif#if defined(__sgi) && !defined(IPFILTER_LKM)# ifdef __STDC__# define IPL_EXTERN(ep) ipfilter##ep# else# define IPL_EXTERN(ep) ipfilter/**/ep# endif#else# ifdef __STDC__# define IPL_EXTERN(ep) ipl##ep# else# define IPL_EXTERN(ep) ipl/**/ep# endif#endif#ifdef linux# include <sys/sysmacros.h>#endif#if SOLARIS# define MTYPE(m) ((m)->b_datap->db_type)# include <sys/isa_defs.h># include <sys/ioccom.h># include <sys/sysmacros.h># include <sys/kmem.h>/* * because Solaris 2 defines these in two places :-/ */# undef IPOPT_EOL# undef IPOPT_NOP# undef IPOPT_LSRR# undef IPOPT_RR# undef IPOPT_SSRR# ifndef KERNEL# define _KERNEL# undef RES_INIT# include <inet/common.h># include <inet/ip.h># include <inet/ip_ire.h># undef _KERNEL# else /* _KERNEL */# include <inet/common.h># include <inet/ip.h># include <inet/ip_ire.h># endif /* _KERNEL */# if SOLARIS2 >= 8# include <netinet/ip6.h># include <inet/ip6.h># define ipif_local_addr ipif_lcl_addr# endif#else# if !defined(__sgi)typedef int minor_t;#endif#endif /* SOLARIS */#define IPMINLEN(i, h) ((i)->ip_len >= ((i)->ip_hl * 4 + sizeof(struct h)))#ifndef IP_OFFMASK#define IP_OFFMASK 0x1fff#endif#if BSD > 199306# define USE_QUAD_T# define U_QUAD_T u_quad_t# define QUAD_T quad_t#else /* BSD > 199306 */# define U_QUAD_T u_long# define QUAD_T long#endif /* BSD > 199306 *//* * These operating systems already take care of the problem for us. */#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || \ defined(__sgi)typedef u_int32_t u_32_t;#else/* * Really, any arch where sizeof(long) != sizeof(int). */# if defined(__alpha__) || defined(__alpha) || defined(_LP64)typedef unsigned int u_32_t;# elsetypedef unsigned long u_32_t;# endif#endif /* __NetBSD__ || __OpenBSD__ || __FreeBSD__ || __sgi */#ifndef MAX#define MAX(a,b) (((a) > (b)) ? (a) : (b))#endif/* * Security Options for Intenet Protocol (IPSO) as defined in RFC 1108. * * Basic Option * * 00000001 - (Reserved 4) * 00111101 - Top Secret * 01011010 - Secret * 10010110 - Confidential * 01100110 - (Reserved 3) * 11001100 - (Reserved 2) * 10101011 - Unclassified * 11110001 - (Reserved 1) */#define IPSO_CLASS_RES4 0x01#define IPSO_CLASS_TOPS 0x3d#define IPSO_CLASS_SECR 0x5a#define IPSO_CLASS_CONF 0x96#define IPSO_CLASS_RES3 0x66#define IPSO_CLASS_RES2 0xcc#define IPSO_CLASS_UNCL 0xab#define IPSO_CLASS_RES1 0xf1#define IPSO_AUTH_GENSER 0x80#define IPSO_AUTH_ESI 0x40#define IPSO_AUTH_SCI 0x20#define IPSO_AUTH_NSA 0x10#define IPSO_AUTH_DOE 0x08#define IPSO_AUTH_UN 0x06#define IPSO_AUTH_FTE 0x01/* * IP option #defines *//*#define IPOPT_RR 7 */#define IPOPT_ZSU 10 /* ZSU */#define IPOPT_MTUP 11 /* MTUP */#define IPOPT_MTUR 12 /* MTUR */#define IPOPT_ENCODE 15 /* ENCODE *//*#define IPOPT_TS 68 */#define IPOPT_TR 82 /* TR *//*#define IPOPT_SECURITY 130 *//*#define IPOPT_LSRR 131 */#define IPOPT_E_SEC 133 /* E-SEC */#define IPOPT_CIPSO 134 /* CIPSO *//*#define IPOPT_SATID 136 */#ifndef IPOPT_SID# define IPOPT_SID IPOPT_SATID#endif/*#define IPOPT_SSRR 137 */#define IPOPT_ADDEXT 147 /* ADDEXT */#define IPOPT_VISA 142 /* VISA */#define IPOPT_IMITD 144 /* IMITD */#define IPOPT_EIP 145 /* EIP */#define IPOPT_FINN 205 /* FINN */#if defined(__FreeBSD__) && defined(KERNEL)# if __FreeBSD__ < 3# include <machine/spl.h># endif# if defined(IPFILTER_LKM) && !defined(ACTUALLY_LKM_NOT_KERNEL)# define ACTUALLY_LKM_NOT_KERNEL# endif#endif /* __FreeBSD__ && KERNEL *//* * Build some macros and #defines to enable the same code to compile anywhere * Well, that's the idea, anyway :-) */#ifdef KERNEL# if SOLARIS# define ATOMIC_INC(x) { mutex_enter(&ipf_rw); (x)++; \ mutex_exit(&ipf_rw); }# define ATOMIC_DEC(x) { mutex_enter(&ipf_rw); (x)--; \ mutex_exit(&ipf_rw); }# define MUTEX_ENTER(x) mutex_enter(x)# if 1# define KRWLOCK_T krwlock_t# define READ_ENTER(x) rw_enter(x, RW_READER)# define WRITE_ENTER(x) rw_enter(x, RW_WRITER)# define RW_UPGRADE(x) { if (rw_tryupgrade(x) == 0) { \ rw_exit(x); \ rw_enter(x, RW_WRITER); } \ }# define MUTEX_DOWNGRADE(x) rw_downgrade(x)# define RWLOCK_INIT(x, y, z) rw_init((x), (y), RW_DRIVER, (z))# define RWLOCK_EXIT(x) rw_exit(x)# define RW_DESTROY(x) rw_destroy(x)# else# define KRWLOCK_T kmutex_t# define READ_ENTER(x) mutex_enter(x)# define WRITE_ENTER(x) mutex_enter(x)# define MUTEX_DOWNGRADE(x) ;# define RWLOCK_INIT(x, y, z) mutex_init((x), (y), MUTEX_DRIVER, (z))# define RWLOCK_EXIT(x) mutex_exit(x)# define RW_DESTROY(x) mutex_destroy(x)# endif# define MUTEX_EXIT(x) mutex_exit(x)# define MTOD(m,t) (t)((m)->b_rptr)# define IRCOPY(a,b,c) copyin((a), (b), (c))# define IWCOPY(a,b,c) copyout((a), (b), (c))# define FREE_MB_T(m) freemsg(m)# define SPL_NET(x) ;# define SPL_IMP(x) ;# undef SPL_X# define SPL_X(x) ;# ifdef sparc# define ntohs(x) (x)# define ntohl(x) (x)# define htons(x) (x)# define htonl(x) (x)# endif /* sparc */# define KMALLOC(a,b) (a) = (b)kmem_alloc(sizeof(*(a)), KM_NOSLEEP)# define KMALLOCS(a,b,c) (a) = (b)kmem_alloc((c), KM_NOSLEEP)# define GET_MINOR(x) getminor(x)typedef struct qif { struct qif *qf_next; ill_t *qf_ill; kmutex_t qf_lock; void *qf_iptr; void *qf_optr; queue_t *qf_in; queue_t *qf_out; struct qinit *qf_wqinfo; struct qinit *qf_rqinfo; struct qinit qf_wqinit; struct qinit qf_rqinit; mblk_t *qf_m; /* These three fields are for passing data up from */ queue_t *qf_q; /* fr_qin and fr_qout to the packet processing. */ size_t qf_off; size_t qf_len; /* this field is used for in ipfr_fastroute */ char qf_name[8]; /* * in case the ILL has disappeared... */ size_t qf_hl; /* header length */} qif_t;extern ill_t *get_unit __P((char *));# define GETUNIT(n) get_unit((n))# else /* SOLARIS */# if defined(__sgi)# define hz HZ# include <sys/ksynch.h># define IPF_LOCK_PL plhi# include <sys/sema.h>#undef kmutex_ttypedef struct { lock_t *l; int pl;} kmutex_t;# define ATOMIC_INC(x) { MUTEX_ENTER(&ipf_rw); \ (x)++; MUTEX_EXIT(&ipf_rw); }# define ATOMIC_DEC(x) { MUTEX_ENTER(&ipf_rw); \ (x)--; MUTEX_EXIT(&ipf_rw); }# define MUTEX_ENTER(x) (x)->pl = LOCK((x)->l, IPF_LOCK_PL);# define KRWLOCK_T kmutex_t# define READ_ENTER(x) MUTEX_ENTER(x)# define WRITE_ENTER(x) MUTEX_ENTER(x)# define RW_UPGRADE(x) ;# define MUTEX_DOWNGRADE(x) ;# define RWLOCK_EXIT(x) MUTEX_EXIT(x)# define MUTEX_EXIT(x) UNLOCK((x)->l, (x)->pl);# else /* __sgi */# define ATOMIC_INC(x) (x)++# define ATOMIC_DEC(x) (x)--# define MUTEX_ENTER(x) ;# define READ_ENTER(x) ;# define WRITE_ENTER(x) ;# define RW_UPGRADE(x) ;# define MUTEX_DOWNGRADE(x) ;# define RWLOCK_EXIT(x) ;# define MUTEX_EXIT(x) ;# endif /* __sgi */# ifndef linux# define FREE_MB_T(m) m_freem(m)# define MTOD(m,t) mtod(m,t)# define IRCOPY(a,b,c) bcopy((a), (b), (c))# define IWCOPY(a,b,c) bcopy((a), (b), (c))# endif /* !linux */# endif /* SOLARIS */# ifdef sun# if !SOLARIS# include <sys/kmem_alloc.h># define GETUNIT(n) ifunit((n), IFNAMSIZ)# endif# else# ifndef linux# define GETUNIT(n) ifunit((n))# endif# endif /* sun */# if defined(sun) && !defined(linux) || defined(__sgi)# define UIOMOVE(a,b,c,d) uiomove((caddr_t)a,b,c,d)# define SLEEP(id, n) sleep((id), PZERO+1)# define WAKEUP(id) wakeup(id)# define KFREE(x) kmem_free((char *)(x), sizeof(*(x)))# define KFREES(x,s) kmem_free((char *)(x), (s))# if !SOLARISextern void m_copydata __P((struct mbuf *, int, int, caddr_t));extern void m_copyback __P((struct mbuf *, int, int, caddr_t));# endif# ifdef __sgi# include <sys/kmem.h># include <sys/ddi.h># define KMALLOC(a,b) (a) = (b)kmem_alloc(sizeof(*(a)), KM_NOSLEEP)# define KMALLOCS(a,b,c) (a) = (b)kmem_alloc((c), KM_NOSLEEP)# define GET_MINOR(x) getminor(x)# else# if !SOLARIS# define KMALLOC(a,b) (a) = (b)new_kmem_alloc(sizeof(*(a)), \ KMEM_NOSLEEP)# define KMALLOCS(a,b,c) (a) = (b)new_kmem_alloc((c), KMEM_NOSLEEP)# endif /* SOLARIS */# endif /* __sgi */# endif /* sun && !linux */# ifndef GET_MINOR# define GET_MINOR(x) minor(x)# endif# if (BSD >= 199306) || defined(__FreeBSD__)# include <vm/vm.h># if !defined(__FreeBSD__) || (defined (__FreeBSD__) && __FreeBSD__>=3)# include <vm/vm_extern.h># include <sys/proc.h>extern vm_map_t kmem_map;# else /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD__>=3) */# include <vm/vm_kern.h># endif /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD__>=3) */# ifdef M_PFIL# define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), M_PFIL, M_NOWAIT)# define KMALLOCS(a, b, c) MALLOC((a), b, (c), M_PFIL, M_NOWAIT)# define KFREE(x) FREE((x), M_PFIL)# define KFREES(x,s) FREE((x), M_PFIL)# else# define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), M_TEMP, M_NOWAIT)# define KMALLOCS(a, b, c) MALLOC((a), b, (c), M_TEMP, M_NOWAIT)# define KFREE(x) FREE((x), M_TEMP)# define KFREES(x,s) FREE((x), M_TEMP)# endif /* M_PFIL */# define UIOMOVE(a,b,c,d) uiomove(a,b,d)# define SLEEP(id, n) tsleep((id), PPAUSE|PCATCH, n, 0)# define WAKEUP(id) wakeup(id)# endif /* BSD */# if defined(NetBSD) && NetBSD <= 1991011 && NetBSD >= 199407# define SPL_NET(x) x = splsoftnet()# define SPL_X(x) (void) splx(x)# else# if !SOLARIS && !defined(linux)# define SPL_IMP(x) x = splimp()# define SPL_NET(x) x = splnet()# define SPL_X(x) (void) splx(x)# endif# endif /* NetBSD && NetBSD <= 1991011 && NetBSD >= 199407 */# define PANIC(x,y) if (x) panic y#else /* KERNEL */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?