📄 ip_types.h
字号:
/** Copyright (c) 1998-2001 by NETsilicon Inc.** This software is copyrighted by and is the sole property of* NETsilicon. All rights, title, ownership, or other interests* in the software remain the property of NETsilicon. This* software may only be used in accordance with the corresponding* license agreement. Any unauthorized use, duplication, transmission,* distribution, or disclosure of this software is expressly forbidden.** This Copyright notice may not be removed or modified without prior* written consent of NETsilicon.** NETsilicon, reserves the right to modify this software* without notice.** NETsilicon* 411 Waverley Oaks Road USA 781.647.1234* Suite 227 http://www.netsilicon.com* Waltham, MA 02452 AmericaSales@netsilicon.com*************************************************************************** $Name: Fusion 6.52 Fusion 6.51 $* $Date: 2001/11/29 14:08:04 $* $Source: M:/psisrc/routing/incl/rcs/ip_types.h $* $Revision: 1.8 $************************************************************************** File Description: Definitions for IP data types *************************************************************************/#ifndef _ip_types_h#define _ip_types_h/* ip network address and mask *//* NOTE: data is stored in these structs in net native order, ie MSB first, which may not correspond to machine order. A magnitude comparison of ipaddresses is therefore not possible. However, masks can be compared because we require no "holes" in subnet masks.*//* a 128 bit address */typedef struct v6addr { union { unsigned char b[16]; unsigned long l[4]; } u;} V6ADDR;typedef struct ipnetaddr{ rripa ip_add; /* 32 bit address */ rripa ip_mask; /* subnet mask */} IPNA, *ipna_pt;typedef struct ipng_address{ unsigned short ina_family; union{ rripa v4; V6ADDR v6; }ina_u; unsigned short ina_port;}IPNGADDR;#define AF_INET4 1#define AF_INET6 2/* option type codes used by IP */#define ISOC_IPA 0x84 /* ip addresses */#define ISOC_RTID 0x86 /* router ID for ptpt */#define ISOC_IREACH 0x80 /* internal reachability */#define ISOC_EREACH 0x82 /* external reachability */#define ISOC_IDRP 0x83 /* inter-domain info *//* NLPID for IP */#define IP_NPID 0xcc/* class related *//* we always store in net order (MSB first) */#define IP_CLASS_A_MAX 127#define IP_CLASS_B_MAX 191#define IP_EXT_ADD 224#define IP_LOOP SWAP32(0x7f000000)#define IP_CLASS_A_MSK SWAP32(0xff000000)#define IP_CLASS_B_MSK SWAP32(0xffff0000)#define IP_CLASS_C_MSK SWAP32(0xffffff00)#define IP_MCAST 0xe0#define IP_CLASS_MASK(ipadd,res) { \ if( *(unsigned char *)(ipadd) <= IP_CLASS_A_MAX ) *(rripa *)(res) = IP_CLASS_A_MSK; \ else if( *(unsigned char *)(ipadd) <= IP_CLASS_B_MAX ) *(rripa *)(res) = IP_CLASS_B_MSK; \ else *(rripa *)(res) = IP_CLASS_C_MSK; }/* macro to set router ID */#define SET_RTID(x) SWAP32( (unsigned long)(x) )/* transmit attributes */typedef struct ipng_attrib{ int ttl; int prio; unsigned long flow; unsigned long spi; unsigned char tos; unsigned long flags; int ecode; unsigned long eval;}IPNGATT; #define IPTXFL_DF 1 /* dont fragment */#define IPTXERR_2BIG 1/* define if remote CPUs need to be notified of route changes*//* #define IP_RT_SIGNAL *//* route redistribution info, passed to protocol importing a route*/typedef struct iproute_redist{ rripa tag; dword community; int level; dword loc_pref; int met; int met_type; rripa nexthop; int origin;}IPRT_REDIST;/* struct passed to ipApplyRedist command.*/typedef struct redist_parms{ int src_level; int met; int met_type; dword tag; int rmapid; /* 0 no rmap */ int subnets; /* Boolean. Do we redistribute subnets or must a route have the natural class mask? */}REDIST_PARMS;/* struct used to store parms passed in to iprtRedistribute command.*/typedef struct redist_template{ int valid; /* if false, no redist */ /* match params */ int src_level; int rmapid; int subnets; /* set params */ IPRT_REDIST rdi;}REDIST_TMPL;/** ip to client IPC message types **/#define IPMSG_REG 1 /* register as ip client */#define IPMSG_UNREG 2 /* unregister as ip client */#define IPMSG_CCREATE 3 /* circuit create */#define IPMSG_CDELETE 4 /* circuit create */#define IPMSG_CEVENT 5 /* circuit event */#define IPMSG_TX 6 /* transmit */#define IPMSG_RX 7 /* receive */#define IPMSG_MCAST_REG 8 /* local multicast addr */#define IPMSG_MCAST_UNREG 9 /* local multicast addr */#define IPMSG_RTREG 10#define IPMSG_RTUNREG 11#define IPMSG_UDP_REG 12#define IPMSG_UDP_UNREG 13/**a generic message **/typedef struct ipmsg_msg{ word m_id; word m_type;}IPM_MSG;/**register message**/typedef struct ipmsg_register{ word m_id; word m_type; /* when using direct callback, m_callid is a function pointer to caller's dispatch function for all inbound events. when using message passing, m_id is a thread_id or other identifier so the system can identify a target message queue. */ void *m_callid; void *m_cerr; /* err callback if udp */ int m_direct; /* if true, function call i/f */ byte m_prot; /* protocol */ word m_port; /* udp port */}IPM_REG;/**unregister message**/typedef struct ipmsg_unregister{ word m_id; word m_type; /* only registerd caller can unregister */ void *m_callid; byte m_prot; /* protocol */}IPM_UNREG;/**an ip circuit create message**/typedef struct ipmsg_circcreate{ word m_id; word m_type; int m_ctype; void *m_intf; /* an interface ID */ IPNA m_ipna; /* addr/mask */ dword m_mtu; dword m_ifspeed;}IPM_CCREATE;/**an ip circuit delete message **/typedef struct ipmsg_circdelete{ word m_id; word m_type; void *m_intf; /* an interface ID */}IPM_CDELETE;/**a circuit event message **/typedef struct ipmsg_circevent{ word m_id; word m_type; void *m_intf; int m_state; /* circuit state */ IPNA m_ipna; /* new ip addr */}IPM_CEVENT;/**a packet receive message **/typedef struct ipmsg_prx{ word m_id; word m_type; ibd_pt m_bd; void *m_intf; rripa m_sipa; rripa m_dipa; byte m_proto;}IPM_RX;/**a transmit message **/typedef struct ipmsg_iptx{ word m_id; word m_type; ibd_pt m_bd; int m_isbcast; rripa m_dst; rripa m_src; void *m_intf; byte m_prot; IPNGATT m_attrib; /* tx attributes */}IPM_TX; /** a multicast address reg or unreg**/typedef struct ipmsg_mcaddr{ word m_id; word m_type; rripa m_mcaddr;}IPM_MCADDR;/**routing protocol register/unregister**/typedef struct ipmsg_rtreg{ word m_id; word m_type; int m_rtype;}IPM_RTREG;#define IP_MAX_SIMUL_PING 1/* structure for each outstanding ping request */typedef struct ipping_ent{ rripa p_ipa; /* dest */ int p_ttl; /* ttl */ int p_busy; /* in use */ int p_id; /* ident */ void (*p_cent)(int,byte*,int,byte,byte); /*client entry */}IPPING, *ipping_pt;#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -