📄 mbuf_pub.h
字号:
U32 mbuf_pullup(MBUF_S * pstMBuf, U32 ulLength, U32 mpe);U32 mbuf_prepend_db(MBUF_S * pstMBuf, U32 ulLength, U32 mpe);VOID mbuf_cut_head(MBUF_S * pstMBuf, U32 ulLength);U32 mbuf_align_dword(MBUF_S *pMBuf);U32 mbuf_compress(MBUF_S * pstMBuf, U32 ulDataBlockNumber, U32 mpe);typedef struct tagMBufQueue{ MBUF_S * pstHeadMBuf; MBUF_S * pstTailMBuf; U32 ulCurrentLength; U32 ulMaxLength;}MBUF_QUEUE_S;#define MBUF_QUE_INIT(pstMBufQueueM, ulMaxLengthM)\{\ (pstMBufQueueM)->pstHeadMBuf = NULL;\ (pstMBufQueueM)->pstTailMBuf = NULL;\ (pstMBufQueueM)->ulCurrentLength = 0;\ (pstMBufQueueM)->ulMaxLength = (ulMaxLengthM);\}#define MBUF_QUE_NOT_EMPTY(pstMBufQueueM) ( (pstMBufQueueM)->ulCurrentLength )#define MBUF_QUE_IS_FULL(pstMBufQueueM) ( (pstMBufQueueM)->ulCurrentLength >= (pstMBufQueueM)->ulMaxLength )#define MBUF_QUE_ENQUEUE(pstMBufQueueM, pstMBufM)\{\ MBUF_ASSIGN_PTR_NEXT_MBUF( (pstMBufM), NULL);\ if( (pstMBufQueueM)->pstTailMBuf != NULL)\ {\ MBUF_ASSIGN_PTR_NEXT_MBUF( (pstMBufQueueM)->pstTailMBuf, (pstMBufM) );\ }\ else\ {\ (pstMBufQueueM)->pstHeadMBuf = (pstMBufM);\ }\ (pstMBufQueueM)->pstTailMBuf = (pstMBufM);\ (pstMBufQueueM)->ulCurrentLength++;\}#define MBUF_QUE_DEQUEUE(pstMBufQueueM, pstMBufM)\{\ (pstMBufM) = (pstMBufQueueM)->pstHeadMBuf;\ if((pstMBufM) != NULL)\ {\ (pstMBufQueueM)->pstHeadMBuf = MBUF_GET_PTR_NEXT_MBUF( (pstMBufM) );\ (pstMBufQueueM)->ulCurrentLength--;\ if( (pstMBufQueueM)->pstTailMBuf == (pstMBufM) )\ {\ (pstMBufQueueM)->pstTailMBuf = NULL;\ }\ }\}#define MBUF_QUE_CATENATE(pstDestinationMBufQueueM, pstSourceMBufQueueM)\{\ if( (pstDestinationMBufQueueM)->pstTailMBuf == NULL)\ {\ \ (pstDestinationMBufQueueM)->pstHeadMBuf = (pstSourceMBufQueueM)->pstHeadMBuf;\ (pstDestinationMBufQueueM)->pstTailMBuf = (pstSourceMBufQueueM)->pstTailMBuf;\ (pstDestinationMBufQueueM)->ulCurrentLength = (pstSourceMBufQueueM)->ulCurrentLength;\ }\ else\ {\ if( (pstSourceMBufQueueM)->pstHeadMBuf != NULL)\ {\ MBUF_ASSIGN_PTR_NEXT_MBUF( (pstDestinationMBufQueueM)->pstTailMBuf, (pstSourceMBufQueueM)->pstHeadMBuf);\ (pstDestinationMBufQueueM)->pstTailMBuf = (pstSourceMBufQueueM)->pstTailMBuf;\ (pstDestinationMBufQueueM)->ulCurrentLength += (pstSourceMBufQueueM)->ulCurrentLength;\ }\ \ }\ (pstSourceMBufQueueM)->pstHeadMBuf = NULL;\ (pstSourceMBufQueueM)->pstTailMBuf = NULL;\ (pstSourceMBufQueueM)->ulCurrentLength = 0;\} #define MBUF_QUE_PEEK(pstMBufQueueM) (pstMBufQueueM)->pstHeadMBuf#define MBUF_QUE_GET_CURRENT_LENGTH(pstMBufQueueM) (pstMBufQueueM)->ulCurrentLength#define MBUF_QUE_GET_MAX_LENGTH(pstMBufQueueM) (pstMBufQueueM)->ulMaxLength#define MBUF_QUE_GET_ALL( pstMBufQueueM, pstMBufM)\{\ ( pstMBufM )= ( pstMBufQueueM )->pstHeadMBuf;\ ( pstMBufQueueM )->pstHeadMBuf = NULL;\ ( pstMBufQueueM )->pstTailMBuf = NULL;\ ( pstMBufQueueM )->ulCurrentLength = 0;\}#define MBUF_QUE_DEAL_PACKET(pstMBufQueueM, ulCountM, pfDeal)\{\ MBUF_S * pstMBufM;\ MBUF_S * pstTempMBuf;\ U32 ulCount;\ \ ulCount = (ulCountM);\ pstTempMBuf = (pstMBufQueueM)->pstHeadMBuf;\ (pstMBufQueueM)->ulCurrentLength -= ulCount;\ for(; ulCount > 0; ulCount-- )\ {\ pstMBufM = pstTempMBuf;\ pstTempMBuf = MBUF_GET_PTR_NEXT_MBUF(pstMBufM);\ MBUF_ASSIGN_PTR_NEXT_MBUF( pstMBufM, NULL );\ (VOID)pfDeal(pstMBufM);\ }\ (pstMBufQueueM)->pstHeadMBuf = pstTempMBuf;\}#define MBUF_QUE_PREPEND(pstMBufQueueM, pstMBufM)\{\ MBUF_ASSIGN_PTR_NEXT_MBUF(pstMBufM, ( pstMBufQueueM )->pstHeadMBuf);\ ( pstMBufQueueM )->pstHeadMBuf = pstMBufM;\ if( ( pstMBufQueueM )->pstTailMBuf == NULL )\ {\ ( pstMBufQueueM )->pstTailMBuf = pstMBufM;\ }\ ( pstMBufQueueM )->ulCurrentLength ++;\}#define MBUF_QUE_FREE(pstMBufQueueM)\{\ MBUF_S * pstMBuf;\ MBUF_S * pstNextMBuf;\ \ pstMBuf = ( pstMBufQueueM )->pstHeadMBuf;\ while(pstMBuf != NULL)\ {\ pstNextMBuf = MBUF_GET_PTR_NEXT_MBUF(pstMBuf);\ (VOID)mbuf_destroy(pstMBuf);\ pstMBuf = pstNextMBuf;\ }\ ( pstMBufQueueM )->pstHeadMBuf = NULL;\ ( pstMBufQueueM )->pstTailMBuf = NULL;\ ( pstMBufQueueM )->ulCurrentLength = 0;\}#define MBUF_FLAG_BROADCAST 0x00000001#define MBUF_FLAG_MULTICAST 0x00000002#define MBUF_FLAG_URGENT_PACKET 0x00000004#define MBUF_FLAG_MFORWARD_IO 0x00000008#define MBUF_FLAG_CONF 0x00000010 #define MBUF_FLAG_AUTH 0x00000020 #define MBUF_FLAG_TUNNEL 0x00000040 #define MBUF_FLAG_COMPRESSED_TCP_PACKET 0x00000100#define MBUF_FLAG_ORDER_PACKET 0x00000200#define MBUF_FLAG_IP_OPTION 0x00010000 #define MBUF_FLAG_IPOA_ARP 0x00020000 #define MBUF_FLAG_PPPOE_MAC_BRML 0x00030000 #define MBUF_FLAG_PPPOE_DISC 0x00040000 #define MBUF_FLAG_PPPOE_PPP_CTRL 0x00050000 #define MBUF_FLAG_PPPOA_PPP_CTRL 0x00060000 #define MBUF_FLAG_IPOE_MAC_BRML 0x00070000 #define MBUF_FLAG_IPOE_ARP 0x00080000 #define MBUF_FLAG_UPCID_INVALID 0x00090000 #define MBUF_FLAG_IP_TTL 0x000a0000 #define MBUF_FLAG_FRAGMENT 0x000b0000 #define MBUF_FLAG_NO_ROUTE 0x000c0000 #define MBUF_FLAG_EIB_IVALID 0x000d0000 #define MBUF_FLAG_DNS 0x000e0000 #define MBUF_FLAG_DOWNCID_INVALID 0x000f0000#define MBUF_FLAG_ACTIONFLAG_INDICATE 0x00100000 #define MBUF_FLAG_DHCP_RESPOND 0x00300000 #define MBUF_FLAG_IP_BROADCAST 0x01000000 #define MBUF_FLAG_IP_MULTICAST 0x02000000 #define MBUF_FLAG_IP_LOCAL 0x04000000 #define MBUF_FLAG_TOMPU 0x08000000 #define MBUF_FLAG_GATEWAY 0x10000000 #define MBUF_GET_RECEIVE_IFNET_INDEX(pstMBufM) ( (pstMBufM)->stUserTagData.stCommonInfo.ulReceiveIfnetIndex )#define MBUF_ASSIGN_RECEIVE_IFNET_INDEX(pstMBufM, ulReceiveIfnetIndexM) \ (pstMBufM)->stUserTagData.stCommonInfo.ulReceiveIfnetIndex = (ulReceiveIfnetIndexM)#define MBUF_GET_SEND_IFNET_INDEX(pstMBufM) ( (pstMBufM)->stUserTagData.stCommonInfo.ulSendIfnetIndex )#define MBUF_ASSIGN_SEND_IFNET_INDEX(pstMBufM, ulSendIfnetIndexM) \ (pstMBufM)->stUserTagData.stCommonInfo.ulSendIfnetIndex = (ulSendIfnetIndexM)#define MBUF_GET_SEND_AT_INDEX(pstMBufM) ( (pstMBufM)->stUserTagData.stCommonInfo.ulSendAtIndex )#define MBUF_ASSIGN_SEND_AT_INDEX(pstMBufM, ulSendAtIndexM) \ (pstMBufM)->stUserTagData.stCommonInfo.ulSendAtIndex = (ulSendAtIndexM)#define MBUF_GET_FLAG(pstMBufM) ( (pstMBufM)->stUserTagData.stCommonInfo.ulFlag )#define MBUF_SET_FLAG(pstMBufM, ulFlagM) (pstMBufM)->stUserTagData.stCommonInfo.ulFlag |= (ulFlagM)#define MBUF_CLEAR_FLAG(pstMBufM, ulFlagM) (pstMBufM)->stUserTagData.stCommonInfo.ulFlag &= ( ~(ulFlagM) )#define MBUF_GET_QUEUE_ID(pstMBufM) (pstMBufM)->stUserTagData.stCommonInfo.ulQueueID#define MBUF_ASSIGN_QUEUE_ID(pstMBufM, ulQueIDM) \ (pstMBufM)->stUserTagData.stCommonInfo.ulQueueID = (ulQueIDM)#define MBUF_GET_RECEIVE_VCCINDEX(pstMBufM) ((pstMBufM)->stUserTagData.stCommonInfo.ulVccIndex)#define MBUF_ASSIGN_RECEIVE_VCCINDEX(pstMBufM, ulVccIndexM) \ (pstMBufM)->stUserTagData.stCommonInfo.ulVccIndex = (ulVccIndexM)#define MBUF_LINK_TYPE_X25 1#define MBUF_LINK_TYPE_ETHERNET 2#define MBUF_LINK_TYPE_FRAME_RELAY 3#define MBUF_GET_TAG_LINK_TYPE(pstMBufM) (pstMBufM)->stUserTagData.ulLinkType#define MBUF_ASSIGN_TAG_LINK_TYPE(pstMBufM, ulLinkTypeM) (pstMBufM)->stUserTagData.ulLinkType = ulLinkTypeM#define MBUF_GET_TAG_LINK_X25_PTR(pstMBufM) (& ( (pstMBufM)->stUserTagData.unPacketInfoRelevantToLink.stX25Info ))#define MBUF_GET_TAG_LINK_ETHERNET_PTR(pstMBufM) (& ( (pstMBufM)->stUserTagData.unPacketInfoRelevantToLink.stEthernetInfo ))#define MBUF_GET_TAG_LINK_FRAME_RELAY_PTR(pstMBufM) (& ( (pstMBufM)->stUserTagData.unPacketInfoRelevantToLink.stFrameRelayInfo ))#define MBUF_NETWORK_TYPE_IP 1#define MBUF_NETWORK_TYPE_IPX 2#define MBUF_GET_TAG_NETWORK_TYPE(pstMBufM) (pstMBufM)->stUserTagData.ulNetworkType#define MBUF_ASSIGN_TAG_NETWORK_TYPE(pstMBufM, ulNetworkTypeM) (pstMBufM)->stUserTagData.ulNetworkType = ulNetworkTypeM#define MBUF_GET_TAG_NETWORK_IP_PTR(pstMBufM) (& ( (pstMBufM)->stUserTagData.unPacketInfoRelevantToNetwork.stIpPacketInfo ))#define MBUF_GET_TAG_MPLS_PTR(pstMBufM) (& ( (pstMBufM)->stUserTagData.stMplsPacketInfo )) #define MBUF_GET_CHANNELCIDS(pstMBufM) ( (pstMBufM)->stUserTagData.stCommonInfo.ulChannelCID)#define MBUF_ASSIGN_CHANNELCID(pstMBufM, ulChannelCID) \ ((pstMBufM)->stUserTagData.stCommonInfo.ulChannelCID = (ulChannelCID))#define MBUF_GET_MAINSLOTINFO(pstMBufM) (((pstMBufM)->stUserTagData.stCommonInfo.ulSlotInfo) >> 16)#define MBUF_ASSIGN_MAINSLOTINFO(pstMBufM, ulMainSlotInfo) \ ((pstMBufM)->stUserTagData.stCommonInfo.ulSlotInfo = \ ((pstMBufM)->stUserTagData.stCommonInfo.ulSlotInfo & 0xFFFF) + ((ulMainSlotInfo) << 16))#define MBUF_GET_SUBSLOTINFO(pstMBufM) (((pstMBufM)->stUserTagData.stCommonInfo.ulSlotInfo)&0xFFFF)#define MBUF_ASSIGN_SUBSLOTINFO(pstMBufM, ulSubSlotInfo) \ ((pstMBufM)->stUserTagData.stCommonInfo.ulSlotInfo = \ ((pstMBufM)->stUserTagData.stCommonInfo.ulSlotInfo & 0xFFFF0000) + (ulSubSlotInfo))#define MBUF_GET_VPNID(pstMBufM) ((pstMBufM)->stUserTagData.stExtraInfo.ucVpnIndex)#define MBUF_SET_VPNID(pstMBufM,vpnid) ((pstMBufM)->stUserTagData.stExtraInfo.ucVpnIndex=(vpnid)) #endif#ifdef __cplusplus#if __cplusplus}#endif #endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -