📄 nu_xm2301_api.h
字号:
#ifndef NU_XM2301_API_H
#define NU_XM2301_API_H
#include "Nu_Types.h"
#include "Nu_SYS_API.h"
#define XM2301_COUNTERREPORT_ID 0x0100
#define XM2301_PKTCAPTURED_ID 0x0200
#define XM2301_LINKSTATUSREPORT_ID 0x80FC
#define XM2301_BOARDSTATUSREPORT_ID 0x0500
#define XM2301_READPHYREPORT_ID 0x0600
#define XM2301_PINGREPORT_ID 0x0700
#define XM2301_RXXTRAILERREPORT_ID 0x0D00
#define XM2301_CARDTYPE 2
#define XM2301_PADPATTERN_LEN 1514
/* *****************************************************************************
* ++ XM2301 Packet Format Structure ++
******************************************************************************/
// Simple command packet format
typedef struct{
UI16_T chasid;
UI8_T boardid;
UI8_T portid;
}XM2301_SIMPLETYPE_T;
// FILLTXPKT Packet Format
typedef struct{
UI16_T chasid;
UI8_T boardid;
UI8_T portid;
UI8_T frame_type;
UI8_T frame_802_hdr[4];
UI8_T DA[6];
UI8_T SA[6];
UI8_T ether_type_len[2];
UI16_T DA_mask[6];
UI16_T DA_ctrl;
UI64_T DA_loop_cnt; // only use 6 bytes
UI64_T DA_step_cnt; // only use 6 bytes
UI16_T SA_mask[6];
UI16_T SA_ctrl;
UI64_T SA_loop_cnt; // only use 6 bytes
UI64_T SA_step_cnt; // only use 6 bytes
BOOLEAN_T Tx_vlan_frame;
UI8_T vlan_tag[4];
UI8_T vlan_tag_mask[4];
UI16_T vlan_cos_ctrl;
UI16_T vlan_vid_ctrl;
UI16_T vlan_cos_loop_cnt;
UI16_T vlan_vid_loop_cnt;
BOOLEAN_T Tx_IP_frame;
UI8_T IPhdr_ver_len;
UI8_T IPhdr_tos;
UI16_T IPhdr_total_len;
UI16_T IPhdr_id;
UI16_T IPhdr_frag;
UI8_T IPhdr_ttl;
UI8_T IPhdr_protocol;
UI16_T IPhdr_chksum;
UI8_T IPhdr_SIP[4];
UI8_T IPhdr_DIP[4];
UI8_T SIP_mask[4];
UI16_T SIP_ctrl;
UI32_T SIP_loop_cnt;
UI8_T DIP_mask[4];
UI16_T DIP_ctrl;
UI32_T DIP_loop_cnt;
UI8_T IP_tos_ctrl;
UI8_T IP_diffsrv_ctrl;
UI8_T IP_ttl_ctrl;
UI8_T IP_flag;
UI8_T IP_tos_loop_cnt;
UI8_T IP_diffsrv_loop_cnt;
UI8_T IP_ttl_loop_cnt;
UI8_T IP_tos_mask;
UI8_T IP_diffsrv_mask;
UI8_T IP_ttl_mask;
UI8_T DIP_class;
UI8_T SIP_class;
BOOLEAN_T Tx_MPLS_frame;
UI8_T tagB[4];
UI8_T tagB_mask[4];
UI16_T tagB_label_ctrl;
UI16_T tagB_cos_ctrl;
UI32_T tagB_label_loop;
UI32_T tagB_cos_loop;
UI16_T tagB_ttl_ctrl;
UI16_T tagB_ttl_loop;
BOOLEAN_T Tx_MPLS_Tunnel_frame;
UI8_T tagC[4];
UI8_T tagC_mask[4];
UI16_T tagC_label_ctrl;
UI16_T tagC_cos_ctrl;
UI32_T tagC_label_loop;
UI32_T tagC_cos_loop;
UI16_T tagC_ttl_ctrl;
UI16_T tagC_ttl_loop;
UI16_T Tx_ctrl;
UI8_T IPhdr_offset;
UI16_T DI_offset;
UI64_T frame_cnt;
UI16_T frame_len_ctrl;
UI16_T frame_len;
UI16_T frame_len_bgn;
UI16_T frame_len_end;
UI8_T frame_len_mask[4];
UI16_T frame_gap_ctrl;
UI32_T frame_gap;
UI32_T frame_gap_bgn;
UI32_T frame_gap_end;
UI8_T frame_gap_mask[4];
UI16_T preamble_cnt;
UI16_T payload_ctrl;
UI8_T user_pad_patn[XM2301_PADPATTERN_LEN];
UI32_T user_pad_patn_len;
UI8_T pad_patn_offset_random;
UI16_T pad_patn_offset;
UI8_T backoff_ctu;
UI8_T backoff_cnt;
UI16_T backoff_delay_time;
UI16_T col_rxframe_offset;
UI32_T burst_cnt;
UI16_T burst_gap_ctrl;
UI32_T interburst_gap;
UI32_T burst_gap_bgn;
UI32_T burst_gap_end;
UI8_T burst_gap_mask[4];
UI8_T burst_reinit;
UI8_T usr_loop_frame_len_mode;
UI16_T usr_loop_frame_len1;
UI16_T usr_loop_frame_len2;
UI16_T usr_loop_frame_len3;
UI16_T usr_loop_frame_len4;
UI16_T udf_pkt_index;
UI32_T udf_pkt_cnt;
}XM2301_TXOP_T;
// STARTRXCAPTURE Packet Format
typedef struct{
UI16_T chasid;
UI8_T boardid;
UI8_T portid;
UI32_T trigger1_offset;
UI32_T trigger2_offset;
UI32_T trigger3_offset;
UI32_T trigger4_offset;
UI8_T trigger1[6];
UI8_T trigger2[6];
UI8_T trigger3[6];
UI8_T trigger4[6];
UI16_T trigger1_len;
UI16_T trigger2_len;
UI16_T trigger3_len;
UI16_T trigger4_len;
UI32_T capture_ctrl;
UI8_T capture_mode;
UI16_T capture_small_size;
UI16_T capture_big_size;
}XM2301_RXOP_T;
// PING Packet Format
typedef struct{
UI16_T chasid;
UI8_T boardid;
UI8_T portid;
UI8_T DIP[4];
UI8_T SIP[4];
UI32_T num_of_ping;
}XM2301_PING_T;
// SETRXXTRAILER Packet Format
typedef struct{
UI16_T chasid;
UI8_T boardid;
UI8_T portid;
BOOLEAN_T enable_DI;
BOOLEAN_T enable_serialnum;
UI16_T DI_offset;
}XM2301_SETRXXTRAILER_T;
// STARTTRIGGERCOUNTER Packet Format
typedef struct{
UI16_T chasid;
UI8_T boardid;
UI8_T portid;
UI32_T trigger1_offset;
UI32_T trigger2_offset;
UI32_T trigger3_offset;
UI32_T trigger4_offset;
UI8_T trigger1[6];
UI8_T trigger2[6];
UI8_T trigger3[6];
UI8_T trigger4[6];
UI16_T trigger1_len;
UI16_T trigger2_len;
UI16_T trigger3_len;
UI16_T trigger4_len;
UI32_T trigger_ctrl;
}XM2301_STARTTGRCTR_T;
// SETLOOPBACK Packet Format
typedef struct{
UI16_T chasid;
UI8_T boardid;
UI8_T portid;
UI8_T mode;
UI8_T speed;
}XM2301_SETLOOPBACK_T;
// STARTAUTOARPREPLY Packet Format
typedef struct{
UI16_T chasid;
UI8_T boardid;
UI8_T portid;
UI8_T SIP[4];
UI8_T SIP_mask[4];
UI8_T gateway_IP[4];
UI8_T SA[6];
}XM2301_STARTAUTOARPREPLY_T;
// COUNTERREPORT Packet Format
typedef struct{
UI16_T chasid;
UI8_T boardid;
UI8_T portid;
UI64_T TxPkt;
UI64_T TxCol;
UI64_T TxMultiCol;
UI64_T TxExcCol;
UI64_T TxLateCol;
UI64_T TxTotalCol;
UI64_T TxByte;
UI64_T RxPkt;
UI64_T RxBcast;
UI64_T RxMcast;
UI64_T RxUnicast;
UI64_T RxPause;
UI64_T RxVLAN;
UI64_T RxCRCErr;
UI64_T RxChkSumErr;
UI64_T RxSerNumErr;
UI64_T RxAlignErr;
UI64_T RxOverSize;
UI64_T RxUnderSize;
UI64_T RxTrigger1;
UI64_T RxTrigger2;
UI64_T RxTrigger3;
UI64_T RxTrigger4;
UI64_T RxIPChkSumErr;
UI64_T RxByte;
UI64_T RxDribbleError;
UI64_T RxCapture;
UI64_T TxARPReply;
UI64_T TxARPRequest;
UI64_T TxICMPReply;
UI64_T TxICMPRequest;
UI64_T RxARPReply;
UI64_T RxARPRequest;
UI64_T RxICMPReply;
UI64_T RxICMPRequest;
UI32_T TimeStamp;
}XM2301_COUNTERREPORT_T;
// PKTCAPTURED Packet Format
typedef struct{
UI16_T chasid;
UI8_T boardid;
UI8_T portid;
UI16_T frame_len;
UI16_T capture_type;
UI32_T timestamp;
UI8_T captured[ETHERNET_PKT_LEN + 20];
}XM2301_PKTCAPTURED_T;
// LINKSTATUSREPORT Packet Format
typedef struct{
UI16_T chasid;
UI8_T boardid;
UI8_T portid;
UI8_T linkstatus;
UI8_T force_flag;
}XM2301_LINKSTATUSREPORT_T;
// BOARDSTATUSREPORT Packet Format
typedef struct{
UI16_T chasid;
UI8_T boardid;
UI8_T portid;
UI16_T generalstatus;
UI16_T FWMajorVersion;
UI16_T FWMinorVersion;
UI16_T PROMMajorVersion;
UI16_T PROMMinorVersion;
UI16_T HWMajorVersion;
UI16_T HWMinorVerion;
UI16_T PCBVersion;
UI32_T reserved;
}XM2301_BOARDSTATUSREPORT_T;
// READPHYREPORT Packet Format
typedef struct{
UI16_T chasid;
UI8_T boardid;
UI8_T portid;
UI16_T phy_addr;
UI16_T phy_data;
UI16_T reg_addr;
}XM2301_READPHYREPORT_T;
// RXXTRAILERREPORT Packet Format
typedef struct{
UI16_T chasid;
UI8_T boardid;
UI8_T portid;
UI16_T DI_serialnum;
UI16_T DI_offset;
}XM2301_RXXTRAILERREPORT_T;
// Overall Packet Format
typedef struct{
UI16_T cmdid;
UI16_T clientid;
UI32_T seqnum;
UI16_T cardtype;
UI16_T reserved;
UI8_T reserved1[7];
UI8_T groupid;
union{
XM2301_SIMPLETYPE_T simple;
XM2301_COUNTERREPORT_T ctr;
XM2301_PKTCAPTURED_T pkt_cap;
XM2301_BOARDSTATUSREPORT_T boardstatus_rpt;
XM2301_READPHYREPORT_T phy_rpt;
XM2301_RXXTRAILERREPORT_T rxxtrailer_rpt;
UI8_T data[2000];
}para;
}XM2301_PKT_FORMAT_T;
/*******************************************************************************
* ++ XM2301 API Function ++
******************************************************************************/
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_MediaType(UI16_T, UI8_T, UI8_T, UI16_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_FillTxPkt(UI16_T, UI8_T, UI8_T, XM2301_TXOP_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_StartTxPkt(UI16_T, UI8_T, UI8_T, UI16_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_StopTxPkt(UI16_T, UI8_T, UI8_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_PauseTxPkt(UI16_T, UI8_T, UI8_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_ResumeTxPkt(UI16_T, UI8_T, UI8_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_StartRxCapture(UI16_T, UI8_T, UI8_T, XM2301_RXOP_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_StopRxCapture(UI16_T, UI8_T, UI8_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_StartCounterStatistics(UI16_T, UI8_T, UI8_T, UI16_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_ClearCounterStatistics(UI16_T, UI8_T, UI8_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_ReadCounterStatistics(UI16_T, UI8_T, UI8_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_StopCounterStatistics(UI16_T, UI8_T, UI8_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_LinkStatus(UI16_T, UI8_T, UI8_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_BoardStatus(UI16_T, UI8_T, UI8_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_WritePhy(UI16_T, UI8_T, UI8_T, UI16_T, UI16_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_ReadPhy(UI16_T, UI8_T, UI8_T, UI16_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_Ping(UI16_T, UI8_T, UI8_T, XM2301_PING_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_SetTimeStamp(UI16_T, UI8_T, UI8_T, UI32_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_SetRxXTrailer(UI16_T, UI8_T, UI8_T, XM2301_SETRXXTRAILER_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_GetRxXTrailer(UI16_T, UI8_T, UI8_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_StartTriggerCounter(UI16_T, UI8_T, UI8_T, XM2301_STARTTGRCTR_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_StopTriggerCounter(UI16_T, UI8_T, UI8_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_SetLoopBack(UI16_T, UI8_T, UI8_T, XM2301_SETLOOPBACK_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_StartAutoARPReply(UI16_T, UI8_T, UI8_T, XM2301_STARTAUTOARPREPLY_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_StopAutoARPReply(UI16_T, UI8_T, UI8_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_PauseControl(UI16_T, UI8_T, UI8_T, BOOLEAN_T);
extern "C" __declspec (dllimport) BOOLEAN_T __stdcall Nu_XM2301_CheckTxEnd(UI16_T, UI8_T, UI8_T, UI16_T);
/*******************************************************************************
* -- XM2301 API Function --
******************************************************************************/
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -