📄 rrport.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: 2002/01/22 14:11:00 $ * $Source: M:/psisrc/routing/incl/rcs/rrport.h $ * $Revision: 1.18 $ *************************************************************************** - Revision Log - ** Who When Why** FND 10/02/02 Mapped SWAP32 macro to function becaue it will not* always work as a macro in little endian mode.***************************************************************************** File Description: porting definitions for common code **************************************************************************/#ifndef _RRPORT_#define _RRPORT_#include "config.h"#include "fns_mem.h"#include "fns_heap.h"#include "debug.h"#include "ccdep.h" /* for i32 */#define rrTimerAlloc(xlen) h_calloc((i32)(xlen), (int *)0, (int)0)#define rrTimerFree(xpt) h_free((i32 *)xpt)/* function prototyping. use fnc_prot(a,c,b) a b() if your compiler doesn't support prototypes a=return value b=function name c=argument list*//* prototype version */#define PROTO 1#define fnc_prot(a,b,c) a b c;/* non-prototype version *//*#define PROTO 0#define fnc_prot(a,b,c) a b();*/#define ASSERT(c,m) if (!(c)) OS_PANIC0(m); else/* true if assert on cannot initialize. if 0, protocol init returns -1 on init fail.*/#define INIT_FAIL_ASSERT 1/* NOTE: this mem copy assumes a 0 len copy is valid !!! */#define rrCopyMem(xdst,xsrc,xlen) OS_MEMCPY((char *)(xdst),(const char *)(xsrc),xlen)#define rrFillMem(xdst,xdata,xlen) OS_MEMSET((char *)xdst,xdata,xlen) /*fill *//*#define rrFillMem(xdst,xdata,xlen) md_bzero((char *)xdst, (unsigned long)xlen) *//*fill */#define rrCmpMem(xdst,xsrc,xlen) OS_MEMCMP((byte *)(xdst),(byte *)(xsrc),xlen)#define u16_2n(add,val) HostToNet16((u8 *)add, val)/* This macro really is used to write into a 3 byte array so HostToNet32 couldn't be used. This is the original p2 macro.*/#define u24_2n(add,val) { (val) &= 0x00ffffff; \ *((byte *)(add) +0)=(byte )(((val) >>16)&0xff); \ *((byte *)(add) +1)=(byte )(((val) >> 8)&0xff); \ *((byte *)(add) +2)=(byte )((val) &0xff);}#define u32_2n(add,val) HostToNet32((u8 *)add, val)#define s32_2n(add,val) HostToNet32((u8 *)add, val)#define n2u16(add) NetToHost16((u8 *)add)/* The following macro converts a 3 byte in net order into a 4 byte long in host order. It is the original p2 macro.*/#define n2u24(add) ( \ (( (dword)*((byte *)(add) )<<16)&0xff0000) |\ (( (dword)*((byte *)(add) +1)<<8)&0xff00) |\ ( (dword)*((byte *)(add) +2)) )/* Note: the following will also work for n2u24 in most embedded systems but strictly speaking is a bad idea since it reads one extra byte and on a memory protected system could cause an exception if that byte was outside of the address space of the process doing the reading.#define n2u24(add) ((NetToHost32((u8 *)add) >> 8) & 0x00FFFFFF)*/#define n2u32(add) NetToHost32((u8 *)add)#define n2s32(add) NetToHost32((u8 *)add)/* non-swap short/long macros for use by platforms */#define uns_l2p HostToMem32#define uns_s2p HostToMem16#define uns_p2l MemToHost32#define uns_p2s MemToHost16#ifdef CPU_IS_BIG_ENDIAN#define SWAP32(val) (val)#else#define SWAP32(val) htonl(val)/*#define SWAP32(val) ( (dword)((val & 0xff) << 24) |\ (dword)((val & 0xff00) << 8) |\ (dword)((val & 0xff0000) >> 8) |\ (dword)((val & 0xff000000) >> 24) )*/#endif /* CPU_IS_BIG_ENDIAN *//****************************************************MULTI_THREADED ENVIRONMENT SECTION****************************************************//*******************************************************resource interlocks:The ability to provide locked access to shared datastructures is required if the following 2 conditionsare met:1) The entities shared the data are running in different threads or tasks.2) The OS scheduler is preemptive.The code calls the functions below to provide locking.If the above are true, you need to implement the lockingfunctions. The functions could be as simple as interruptdisable/enable or they could implement write once/readmany per resource. The xxrsc argument refers to theresource to lock***************************************************//* resources */#define rrRSC_IPRT 1 /* ip routing table */#define rrRSC_IPACC 2 /* ip access lists/rmaps */#define rrRSC_IPCIRC 3 /* ip circuits */#define rrRSC_REDIST 4 /* route redistribution */#define rrRSC_SKT 5 /* sockets *//* the following are logical thread ID's for protocols. they are only used by conditional compile to determine whether 2 protocols share the same thread and therefore if function calls can be used between protocols or a messaging interface is required. */#define rr_TID_IP 1#define rr_TID_OSPF 1#define rr_TID_TCP 1#define rr_TID_BGP 1#define rr_TID_ISAKMP 1#define rr_TID_IRIP 1/*If messaging is used,the value is used in passing messages to parse whichfunction in a protocol should be called upon messagereceipt. NOT platform dependent and should not be changed.*/#define rr_ID_IP 1#define rr_ID_OSPF 2#define rr_ID_TCP 3#define rr_ID_BGP 4#define rr_ID_ISAKMP 5#define rr_ID_FWD 6#define rr_ID_IRIP 7#define rr_ID_SKT 8/* determine qid of local thread: define or your function */#define rr_MY_QID() 1/* platform specific well-known message queue identifiers.Is platform specific and should be edited. Note: thesewell-known QIDs may or may not be a problem if you runmultiple instances of a virtual router. If so, you mayneed to perform some QID mapping in your implementationof rrSendMsg (below). */#define rr_QID_IP 1#define rr_QID_OSPF 1#define rr_QID_TCP 1#define rr_QID_BGP 1#define rr_QID_ISAKMP 1#define rr_QID_IRIP 1/* only need to change this if you are using multi-threading and need to pass IPC messages between threads (ie if there is more than 1 TID value above*/#define rrSendMsg(msg,mlen,dst_q_id)#define rrRecvMsg(msg,mlen,dst_q_id) /**a generic message**/typedef struct rr_message{ /* ID, from above, of protocol that defined m_type. this is used so we dont need one global .h file including all possible message types. (this should help decrease those nasty global recompiles). for example, if isakmp sends ip a message, it has has the isakmp TID because ip is an isakmp client and therefore isakmp defines the messages related to it. */ unsigned short m_id; unsigned short m_type;}rr_MSG;/****** end MULTI_THREADED section ********************/#endif /* rrport_h */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -