📄 swpkt.h
字号:
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This software is copyrighted by and is the sole property of
* VIA Networking Technologies, Inc. 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 software is provided by VIA Networking Technologies, Inc. "as is"
* and any express or implied warranties, including, but not limited to, the
* implied warranties of merchantability and fitness for a particular purpose
* are disclaimed. In no event shall VIA Networking Technologies, Inc.
* be liable for any direct, indirect, incidental, special, exemplary, or
* consequential damages.
*
*
* File: swpkt.h
*
* Purpose:
*
* Author: Henry Lin
*
* Date: May 05, 2005
*
*/
#ifndef __SWPKT_H__
#define __SWPKT_H__
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
/*--------------------- Export Definitions ------------------------*/
#define RBUF_BUF_SIZE 1536
#define EPKT_ETH_TYPE_OFST 12 // Ethernet Buffer: Ethernet type offset
#define EPKT_ETH_DATA_OFST 14 // Ethernet Buffer: Ethernet data offset
#define EPKT_VLAN_TAG_OFST 14 // Ethernet Buffer: Vlan tag offset, if tagged packet
#define EPKT_IP_DATA_OFST 34 // Ethernet Buffer: IP data offset
#define EPKT_UDP_DATA_OFST 42 // Ethernet Buffer: UDP data offset
#define EPKT_TCP_DATA_OFST 54 // Ethernet Buffer: TCP data offset
#define HDR_LEN_IP (EPKT_IP_DATA_OFST - EPKT_ETH_DATA_OFST)
// IP header length, without option field
#define HDR_LEN_UDP (EPKT_UDP_DATA_OFST - EPKT_IP_DATA_OFST)
// UDP header length
#define HDR_LEN_TCP (EPKT_TCP_DATA_OFST - EPKT_IP_DATA_OFST)
// TCP header length, without option field
#define __SWITCH_CPUIF_PKT8 0
#define __PKT_PIO 0
#define __PBUS_DMA_2_CHNNL 0
/*--------------------- Export Types ------------------------------*/
struct tagSRBuf {
UINT8 pkb_au8Buffer[RBUF_BUF_SIZE];
// packet buffer contains incoming packets
UINT16 pkb_u16BufLen; // length of packet data
PUINT8 pu8AppData; // the pointer points to application data.
UINT16 u16AppDataOffset; // the offset which from the top of au8TxBuf[] to pu8AppData point at
UINT8 pkb_u8SrcPortId; // source port id
BOOL pkb_bTagged; // if tagged packet?
UINT16 pkb_u16VID; // VID, VLAN tag value
UINT8 pkb_u8Priority; // tag priority
// the following fields are used by tx only
UINT32 pkb_u32TxMbrPrtMsk; // member port mask for tx
UINT32 pkb_u32TxTagPrtMsk; // tag port mask for tx
};
typedef struct tagSRBuf SRBuf, *PSRBuf;
struct tagSNetStat {
UINT32 u32PktRxGood; // rx good packet
UINT32 u32PktRxBad; // rx bad packet
UINT32 u32PktTxGood; // tx good packet
UINT32 u32PktTxBad; // tx bad packet
// error counter
UINT32 u32ErrorRxBufDrop; // packet dropped bcs rx buffer full
UINT32 u32ErrorTxBufDrop; // packet dropped bcs tx buffer full
UINT32 u32ErrorTxMacDrop; // tx packet dropped bcs mac busy
UINT32 u32ErrorTxSize; // tx packet dropped bcs size too big or too small
};
typedef struct tagSNetStat SNetStat;
/*--------------------- Export Macros -----------------------------*/
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
extern SNetStat g_NetStat;
/*--------------------- Export Functions --------------------------*/
void ISR_vRecvPkt(void);
void ISR_vSendPkt(void);
void ISR_vRdPktDmaCompleted(void);
void ISR_vWrPktDmaCompleted(void);
void SWPKT_vDrvOpen(void);
void SWPKT_vDrvClose(void);
void SWPKT_vSetHookFnRx(PFN_HOOK_PV pfnHook);
void SWPKT_vGetMacAddress(UINT8* pu8MacAddr);
void SWPKT_vSetMacAddress(UINT8* pu8MacAddr);
BOOL SWPKT_bRecvPkt(SRBuf* pPktBuf);
BOOL SWPKT_bSendPkt(SRBuf* pPktBuf);
#endif /* __SWPKT_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -