14 Star 9 Fork 0

zhangruoxu/demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
switch_data.h 2.61 KB
一键复制 编辑 原始数据 按行查看 历史
zhangruoxu 提交于 2023-11-23 17:14 . 头文件守卫
#ifndef SWITCH_DATA_H__
#define SWITCH_DATA_H__
#define IF_TYPE_ACCESS 0
#define IF_TYPE_TRUNK 1
#define IF_TYPE_NULL 2
#define SW_MACNODE_IS_DYNAMIC(age) (0 != ((age) & 0x80000000))
#define SW_MACNODE_IS_STATIC(age) (0 == ((age) & 0x80000000))
#define SW_MACNODE_SET_STATIC(age) ((age) |= 0x80000000)
#define SW_MACNODE_RESET_STATIC(age) ((age) &= (~0x80000000))
typedef struct tagSwitchMacnode
{
UINT8 aucMacAddr[MAC_BYTE]; /* MAC地址(6字节) */
UINT16 usSwitchPortNum; /* 交换机的端口号,从小到大 */
UINT32 uiAgingTime; /* 静态表项,为0x80000000;动态表项,此字段存储的是添加的时刻(ms) */
} SWITCH_MACNODE_S;
typedef struct TagSwithMactable
{
SWITCH_MACNODE_S astMacNode[SWITCH_MACTABLE_MAXNODE]; /* mac地址表 */
UINT16 usMacCount; /* 总的mac地址数目 */
UINT16 usVlanId; /* vlan id */
UINT16 usFlag; /* 0表示未配置该VLAN */
} MAC_TABLE_S;
typedef struct tagInterfaceNode
{
UINT16 usPortMode; /* 接口类型access:0 trunk:1 */
UINT16 usVlanCount; /* access:1 trunk视配置决定 */
UINT16 astPermitVlanId[DEVICE_MAX_VLAN]; /* permit vlanid */
} SWITCH_IFCFG_S;
typedef struct tagSwitchDevice
{
UINT32 uiDeviceId; /* 交换机标识 */
SWITCH_IFCFG_S astIfCfg[DEVICE_MAX_VLAN_IF];
MAC_TABLE_S astMacTable[DEVICE_MAX_VLAN]; /* mac地址表每个vlan一个 */
struct tagSwtichDevice* pstNextDevice;
} SWITCH_DEVICE_S;
INT32 MacData_Init(VOID);
INT32 MacData_AddDevice(IN UINT32 uiDeviceId);
INT32 MacData_DeleteDevice(IN UINT32 uiDeviceId);
SWITCH_DEVICE_S* MacData_FindDevice(IN UINT32 uiDeviceId);
INT32 MacData_Add(IN UINT16 usDeviceId, IN UINT8* pucMacAddr, IN UINT32 uiAgingTime, IN UINT16 usSwitchPortNum, IN UINT16 usVlanId);
INT32 MacData_Delete(IN UINT32 uiDeviceId, IN UINT8* aucMacAddr, IN UINT16 usSwitchPortNum, IN UINT16 uiVlanId);
INT32 MacData_Print(IN SWITCH_DEVICE_S* pstSwitchDevice, IN UINT16 usVlanid);
SWITCH_MACNODE_S* MacData_BestMatch(UINT8* aucMacaddr, UINT16 uiDeviceId, IN UINT16 usVlanid, IN UINT16 usifIndex);
INT32 Vlan_Add(IN UINT16 usDeviceId, IN UINT16 usVlanid);
INT32 Vlan_Delete(IN UINT16 usDeviceId, IN UINT16 usVlanid);
INT32 Port_AddPermitVlan(IN UINT16 usDeviceId, IN UINT16 usVlanid, IN UINT16 usSwitchPortNum, IN UINT16 usPortMode);
INT32 Port_DeletePermitVlan(IN UINT16 usDeviceId, IN UINT16 usVlanid, IN UINT16 usSwitchPortNum, IN UINT16 usPortMode);
INT32 Port_SetMode(IN UINT16 usDeviceId, IN UINT16 usPortMode, IN UINT16 usSwitchPortNum, IN UINT16 usVlanid);
INT32 Port_DeleteMode(IN UINT16 usDeviceId, IN UINT16 usSwitchPortNum, IN UINT16 usPortMode);
#endif // !SWITCH_DATA_H__
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangruoxudada/demo.git
git@gitee.com:zhangruoxudada/demo.git
zhangruoxudada
demo
demo
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385