ip_fil_compat.h
来自「eCos操作系统源码」· C头文件 代码 · 共 869 行 · 第 1/2 页
H
869 行
# define SLEEP(x,y) ;# define WAKEUP(x) ;# define PANIC(x,y) ;# 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) ;# define SPL_NET(x) ;# define SPL_IMP(x) ;# undef SPL_X# define SPL_X(x) ;# define KMALLOC(a,b) (a) = (b)malloc(sizeof(*a))# define KMALLOCS(a,b,c) (a) = (b)malloc(c)# define KFREE(x) free(x)# define KFREES(x,s) free(x)# define GETUNIT(x) get_unit(x)# define IRCOPY(a,b,c) bcopy((a), (b), (c))# define IWCOPY(a,b,c) bcopy((a), (b), (c))#endif /* KERNEL */#if SOLARIStypedef mblk_t mb_t;# if SOLARIS2 >= 7# ifdef lint# define ALIGN32(ptr) (ptr ? 0L : 0L)# define ALIGN16(ptr) (ptr ? 0L : 0L)# else# define ALIGN32(ptr) (ptr)# define ALIGN16(ptr) (ptr)# endif# endif#else# ifdef linux# ifndef kerneltypedef struct mb { struct mb *next; u_int len; u_char *data;} mb_t;# elsetypedef struct sk_buff mb_t;# endif# elsetypedef struct mbuf mb_t;# endif#endif /* SOLARIS */#if defined(linux) || defined(__sgi)/* * These #ifdef's are here mainly for linux, but who knows, they may * not be in other places or maybe one day linux will grow up and some * of these will turn up there too. */#ifndef ICMP_MINLEN# define ICMP_MINLEN 8#endif#ifndef ICMP_UNREACH# define ICMP_UNREACH ICMP_DEST_UNREACH#endif#ifndef ICMP_SOURCEQUENCH# define ICMP_SOURCEQUENCH ICMP_SOURCE_QUENCH#endif#ifndef ICMP_TIMXCEED# define ICMP_TIMXCEED ICMP_TIME_EXCEEDED#endif#ifndef ICMP_PARAMPROB# define ICMP_PARAMPROB ICMP_PARAMETERPROB#endif#ifndef ICMP_TSTAMP# define ICMP_TSTAMP ICMP_TIMESTAMP#endif#ifndef ICMP_TSTAMPREPLY# define ICMP_TSTAMPREPLY ICMP_TIMESTAMPREPLY#endif#ifndef ICMP_IREQ# define ICMP_IREQ ICMP_INFO_REQUEST#endif#ifndef ICMP_IREQREPLY# define ICMP_IREQREPLY ICMP_INFO_REPLY#endif#ifndef ICMP_MASKREQ# define ICMP_MASKREQ ICMP_ADDRESS#endif#ifndef ICMP_MASKREPLY# define ICMP_MASKREPLY ICMP_ADDRESSREPLY#endif#ifndef IPVERSION# define IPVERSION 4#endif#ifndef IPOPT_MINOFF# define IPOPT_MINOFF 4#endif#ifndef IPOPT_COPIED# define IPOPT_COPIED(x) ((x)&0x80)#endif#ifndef IPOPT_EOL# define IPOPT_EOL 0#endif#ifndef IPOPT_NOP# define IPOPT_NOP 1#endif#ifndef IP_MF# define IP_MF ((u_short)0x2000)#endif#ifndef ETHERTYPE_IP# define ETHERTYPE_IP ((u_short)0x0800)#endif#ifndef TH_FIN# define TH_FIN 0x01#endif#ifndef TH_SYN# define TH_SYN 0x02#endif#ifndef TH_RST# define TH_RST 0x04#endif#ifndef TH_PUSH# define TH_PUSH 0x08#endif#ifndef TH_ACK# define TH_ACK 0x10#endif#ifndef TH_URG# define TH_URG 0x20#endif#ifndef IPOPT_EOL# define IPOPT_EOL 0#endif#ifndef IPOPT_NOP# define IPOPT_NOP 1#endif#ifndef IPOPT_RR# define IPOPT_RR 7#endif#ifndef IPOPT_TS# define IPOPT_TS 68#endif#ifndef IPOPT_SECURITY# define IPOPT_SECURITY 130#endif#ifndef IPOPT_LSRR# define IPOPT_LSRR 131#endif#ifndef IPOPT_SATID# define IPOPT_SATID 136#endif#ifndef IPOPT_SSRR# define IPOPT_SSRR 137#endif#ifndef IPOPT_SECUR_UNCLASS# define IPOPT_SECUR_UNCLASS ((u_short)0x0000)#endif#ifndef IPOPT_SECUR_CONFID# define IPOPT_SECUR_CONFID ((u_short)0xf135)#endif#ifndef IPOPT_SECUR_EFTO# define IPOPT_SECUR_EFTO ((u_short)0x789a)#endif#ifndef IPOPT_SECUR_MMMM# define IPOPT_SECUR_MMMM ((u_short)0xbc4d)#endif#ifndef IPOPT_SECUR_RESTR# define IPOPT_SECUR_RESTR ((u_short)0xaf13)#endif#ifndef IPOPT_SECUR_SECRET# define IPOPT_SECUR_SECRET ((u_short)0xd788)#endif#ifndef IPOPT_SECUR_TOPSECRET# define IPOPT_SECUR_TOPSECRET ((u_short)0x6bc5)#endif#ifndef IPOPT_OLEN# define IPOPT_OLEN 1#endif#endif /* linux || __sgi */#ifdef linux#include <linux/in_systm.h>/* * TCP States */#define TCPS_CLOSED 0 /* closed */#define TCPS_LISTEN 1 /* listening for connection */#define TCPS_SYN_SENT 2 /* active, have sent syn */#define TCPS_SYN_RECEIVED 3 /* have send and received syn *//* states < TCPS_ESTABLISHED are those where connections not established */#define TCPS_ESTABLISHED 4 /* established */#define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close *//* states > TCPS_CLOSE_WAIT are those where user has closed */#define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */#define TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */#define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK *//* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */#define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */#define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close *//* * file flags. */#ifdef WRITE#define FWRITE WRITE#define FREAD READ#else#define FWRITE _IOC_WRITE#define FREAD _IOC_READ#endif/* * mbuf related problems. */#define mtod(m,t) (t)((m)->data)#define m_len len#define m_next next#ifdef IP_DF#undef IP_DF#endif#define IP_DF 0x4000typedef struct { __u16 th_sport; __u16 th_dport; __u32 th_seq; __u32 th_ack;# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\ defined(vax) __u8 th_res:4; __u8 th_off:4;#else __u8 th_off:4; __u8 th_res:4;#endif __u8 th_flags; __u16 th_win; __u16 th_sum; __u16 th_urp;} tcphdr_t;typedef struct { __u16 uh_sport; __u16 uh_dport; __u16 uh_ulen; __u16 uh_sum;} udphdr_t;typedef struct {# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\ defined(vax) __u8 ip_hl:4; __u8 ip_v:4;# else __u8 ip_v:4; __u8 ip_hl:4;# endif __u8 ip_tos; __u16 ip_len; __u16 ip_id; __u16 ip_off; __u8 ip_ttl; __u8 ip_p; __u16 ip_sum; struct in_addr ip_src; struct in_addr ip_dst;} ip_t;/* * Structure of an icmp header. */typedef struct icmp { __u8 icmp_type; /* type of message, see below */ __u8 icmp_code; /* type sub code */ __u16 icmp_cksum; /* ones complement cksum of struct */ union { __u8 ih_pptr; /* ICMP_PARAMPROB */ struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ struct ih_idseq { __u16 icd_id; __u16 icd_seq; } ih_idseq; int ih_void; } icmp_hun;# define icmp_pptr icmp_hun.ih_pptr# define icmp_gwaddr icmp_hun.ih_gwaddr# define icmp_id icmp_hun.ih_idseq.icd_id# define icmp_seq icmp_hun.ih_idseq.icd_seq# define icmp_void icmp_hun.ih_void union { struct id_ts { n_time its_otime; n_time its_rtime; n_time its_ttime; } id_ts; struct id_ip { ip_t idi_ip; /* options and then 64 bits of data */ } id_ip; u_long id_mask; char id_data[1]; } icmp_dun;# define icmp_otime icmp_dun.id_ts.its_otime# define icmp_rtime icmp_dun.id_ts.its_rtime# define icmp_ttime icmp_dun.id_ts.its_ttime# define icmp_ip icmp_dun.id_ip.idi_ip# define icmp_mask icmp_dun.id_mask# define icmp_data icmp_dun.id_data} icmphdr_t;# ifndef LINUX_IPOVLY# define LINUX_IPOVLYstruct ipovly { caddr_t ih_next, ih_prev; /* for protocol sequence q's */ u_char ih_x1; /* (unused) */ u_char ih_pr; /* protocol */ short ih_len; /* protocol length */ struct in_addr ih_src; /* source internet address */ struct in_addr ih_dst; /* destination internet address */};# endiftypedef struct { __u8 ether_dhost[6]; __u8 ether_shost[6]; __u16 ether_type;} ether_header_t;typedef struct uio { int uio_resid; int uio_rw; caddr_t uio_buf;} uio_t;# define UIO_READ 0# define UIO_WRITE 1# define UIOMOVE(a, b, c, d) uiomove(a,b,c,d)/* * For masking struct ifnet onto struct device */# define if_name name# ifdef KERNEL# define GETUNIT(x) dev_get(x)# define FREE_MB_T(m) kfree_skb(m, FREE_WRITE)# define uniqtime do_gettimeofday# undef INT_MAX# undef UINT_MAX# undef LONG_MAX# undef ULONG_MAX# include <linux/netdevice.h># define SPL_X(x)# define SPL_NET(x)# define SPL_IMP(x) # define bcmp(a,b,c) memcmp(a,b,c)# define bcopy(a,b,c) memcpy(b,a,c)# define bzero(a,c) memset(a,0,c)# define UNITNAME(n) dev_get((n))# define KMALLOC(a,b) (a) = (b)kmalloc(sizeof(*(a)), GFP_ATOMIC)# define KMALLOCS(a,b,c) (a) = (b)kmalloc((c), GFP_ATOMIC)# define KFREE(x) kfree_s((x), sizeof(*(x)))# define KFREES(x,s) kfree_s((x), (s))# define IRCOPY(a,b,c) { \ error = verify_area(VERIFY_READ, (a) ,(c)); \ if (!error) \ memcpy_fromfs((b), (a), (c)); \ }# define IWCOPY(a,b,c) { \ error = verify_area(VERIFY_WRITE, (b), (c)); \ if (!error) \ memcpy_tofs((b), (a), (c)); \ }# else# define __KERNEL__# undef INT_MAX# undef UINT_MAX# undef LONG_MAX# undef ULONG_MAX# define s8 __s8# define u8 __u8# define s16 __s16# define u16 __u16# define s32 __s32# define u32 __u32# include <linux/netdevice.h># undef __KERNEL__# endif# define ifnet device#elsetypedef struct tcphdr tcphdr_t;typedef struct udphdr udphdr_t;typedef struct icmp icmphdr_t;typedef struct ip ip_t;typedef struct ether_header ether_header_t;#endif /* linux */typedef struct tcpiphdr tcpiphdr_t;#if defined(hpux) || defined(linux)struct ether_addr { char ether_addr_octet[6];};#endif/* * XXX - This is one of those *awful* hacks which nobody likes */#ifdef ultrix#define A_A#else#define A_A &#endif#ifndef ICMP_ROUTERADVERT# define ICMP_ROUTERADVERT 9#endif#ifndef ICMP_ROUTERSOLICIT# define ICMP_ROUTERSOLICIT 10#endif/* * ICMP error replies have an IP header (20 bytes), 8 bytes of ICMP data, * another IP header and then 64 bits of data, totalling 56. Of course, * the last 64 bits is dependant on that being available. */#define ICMPERR_ICMPHLEN 8#define ICMPERR_IPICMPHLEN (20 + 8)#define ICMPERR_MINPKTLEN (20 + 8 + 20)#define ICMPERR_MAXPKTLEN (20 + 8 + 20 + 8)#endif /* _NETINET_IP_COMPAT_H__ */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?