18#include "NetSim_utility.h"
20#define DEFAULT_ARP_RETRY_INTERVAL 10
21#define DEFAULT_ARP_RETRY_LIMIT 3
24#define HARDWARE_ADDRESS_LENGTH 6
25#define ARP_ETHERNET_HEADER_LENGTH 14
26#define IPV4_PROTOCOL_ADDREES_LENGTH 4
27#define IPV4_ARP_PACKET_SIZE 28
28#define IPV4_ARP_PACKET_SIZE_WITH_ETH_HEADER 42
29#define IPV4_NETWORK_OVERHEADS 20
30#define IPV6_PROTOCOL_ADDREES_LENGTH 16
31#define IPV6_ARP_PACKET_SIZE 52
32#define IPV6_ARP_PACKET_SIZE_WITH_ETH_HEADER 66
33#define IPV6_NETWORK_OVERHEADS 40
44typedef enum enum_ARP_Subevent_Type SUB_EVENT;
45typedef enum enum_ARP_opcode OPCODE;
46typedef enum enum_ARP_EthernetFrameType ETHERNET_TYPE;
47typedef enum enum_ARP_HardwareType HARDWARETYPE;
48typedef enum enum_ARP_PrptocolType PROTOCOLTYPE;
49typedef enum enum_ArpControlPacket_Type ARP_CONTROL_PACKET;
50typedef enum enum_Transmission_Type ARP_FRAME_TX_FLAG;
51typedef enum enum_ARP_Table_Entries_Type ENTRY_TYPE;
52typedef enum enum_Static_Arp_Status STATIC_ARP_STATUS;
55 enum enum_ARP_Subevent_Type
57 READ_ARP_TABLE = NW_PROTOCOL_ARP*100+1,
60 UPDATE_ARP_TABLE_FWD_PKT,
70 enum enum_ARP_EthernetFrameType
72 ADDRESS_RESOLUTION = 0x8060
75 enum enum_ARP_HardwareType
81 enum enum_ARP_PrptocolType
83 ARP_TO_RESOLVE_IP = 0x8000
86 enum enum_ArpControlPacket_Type
88 REQUEST_PACKET = NW_PROTOCOL_ARP*100+1,
92enum enum_ARP_Table_Entries_Type
98enum enum_Static_Arp_Status
144 int nPacketDropCount;
150 ARP_TABLE *pstruArpTable;
156 ARP_BUFFER *pstruPacketBuffer;
163 STATIC_ARP_STATUS nStaticArpFlag;
168NETSIM_IPAddress szBroadcastIPaddress;
171STATIC_TABLE_CONFIG *g_pstruStaticTableConfig;
174int fn_NetSim_StaticArpTable_Read(
char* pszARPstasticTablePath);
176int fn_NetSim_Add_IP_MAC_AddressTo_ARP_Table(ARP_TABLE** ,NETSIM_IPAddress , PNETSIM_MACADDRESS ,
int );
178ARP_TABLE* fn_Netsim_CopyArpTable(ARP_TABLE* );
180void fn_NetSim_DeleteArpTable(ARP_TABLE** );
186int fn_Netsim_ARP_CheckDestinationDevice(NetSim_EVENTDETAILS* ,
struct stru_NetSim_Network*);
187int fn_NetSim_Arp_Drop_Buffered_Packet(NETSIM_ID nDeviceId, NETSIM_ID nInterfaceId,NETSIM_IPAddress szDestIPadd,
int *nPacketDropCount);
188int fn_NetSim_Add_PacketTo_Buffer(NETSIM_ID nDeviceId, NetSim_PACKET* pstruNewPacket,NETSIM_IPAddress szDestIPadd, NETSIM_ID nInterfaceId);
194_declspec(dllexport)
int fn_NetSim_ARP_Configure(
void** var);
195int fn_NetSim_ARP_Configure_F(
void** var);
197_declspec (dllexport)
int fn_NetSim_ARP_Init(
struct stru_NetSim_Network *NETWORK_Formal,NetSim_EVENTDETAILS *pstruEventDetails_Formal,
char *pszAppPath_Formal,
char *pszWritePath_Formal,
int nVersion_Type,
void **fnPointer);
198int fn_NetSim_ARP_Init_F(
struct stru_NetSim_Network *,NetSim_EVENTDETAILS *,
char *,
char *,
int ,
void **fnPointer);
200_declspec (dllexport)
int fn_NetSim_ARP_Run();
202_declspec(dllexport)
int fn_NetSim_ARP_Finish();
203int fn_NetSim_ARP_Finish_F();
205_declspec (dllexport)
char *fn_NetSim_ARP_Trace(
int nSubEvent);
206char *fn_NetSim_ARP_Trace_F(
int nSubEvent);
208_declspec(dllexport)
int fn_NetSim_ARP_FreePacket(NetSim_PACKET*);
209int fn_NetSim_ARP_FreePacket_F(NetSim_PACKET* );
211_declspec(dllexport)
int fn_NetSim_ARP_CopyPacket(NetSim_PACKET* ,NetSim_PACKET* );
212int fn_NetSim_ARP_CopyPacket_F(NetSim_PACKET* ,NetSim_PACKET* );
214_declspec(dllexport)
int fn_NetSim_ARP_Metrics(
char* );
215int fn_NetSim_ARP_Metrics_F(
char* );
216_declspec(dllexport)
char* fn_NetSim_ARP_ConfigPacketTrace();
218_declspec(dllexport)
char* fn_NetSim_ARP_WritePacketTrace(NetSim_PACKET* pstruPacket,
char** ppszTrace);
222int fn_NetSim_ipv4_network_check(
char* ,
char* ,
char* );
224int fn_NetSim_Generate_ARP_Request(NetSim_EVENTDETAILS *pstruEventDetails,
struct stru_NetSim_Network *NETWORK);
225int fn_NetSim_Read_ARP_Table(NetSim_EVENTDETAILS *pstruEventDetails,
struct stru_NetSim_Network *NETWORK);
226int fn_NetSim_ARP_Request_Timeout(NetSim_EVENTDETAILS *pstruEventDetails,
struct stru_NetSim_Network *NETWORK);
227int fn_NetSim_Generate_ARP_Reply(NetSim_EVENTDETAILS *pstruEventDetails,
struct stru_NetSim_Network *NETWORK);
228int fn_NetSim_Update_ARP_Table_ForwardPacket(NetSim_EVENTDETAILS *pstruEventDetails,
struct stru_NetSim_Network *NETWORK);
int * pnArpRequestFlag
Set when generate Request.
int * pnArpRetryCount
To keep track of number of retries.
int nArpRetryLimit
Store the ARP_RETRY_LIMIT from the config file.
int nStaticTableFlag
Check ARP_TABLE intialized by static table or not.
ARP_METRICS * pstruArpMetrics
NetSim specific ARP metrics structure.
int nArpRetryInterval
Store the ARP_RETRY_INTERVAL from the config file.
int * pnArpReplyFlag
Set when receive the Reply.
int nArpRequestSentCount
Number of requests sent from the source.
int nPacketsInBuffer
Number of packets in the buffer.
int nArpReplyReceivedCount
Number of replies received from destination.
int nArpReplySentCount
Number of replies sent from the destination.
Structure for Static ARP Table configuration.
char * pszFilePath
Stores File path.
char * pszFileName
Stores File Name.
PNETSIM_MACADDRESS szMACAddress
MAC address or Hardware address of the device.
ENTRY_TYPE nType
0-Static,1-Dynamic.
struct stru_ARP_Table * pstruNextEntry
Next entry pointer.
NETSIM_IPAddress szIPAddress
IP address of the deivce.
This Arp packet structure is according to RFC 826.
PNETSIM_MACADDRESS szDestMac
Destination MAC address.
unsigned short int usn_ar$pln
Protocol address length 1 byte,specifies the sizes of the protocol address in bytes.
ETHERNET_TYPE nEther_type
Ethernet Type.
NETSIM_IPAddress sz_ar$spa
Protocol address of the sender.
PNETSIM_MACADDRESS sz_ar$tha
Hardware address of target (if know) otherwise empty 6 bytes.
OPCODE n_ar$op
Operation REQUEST/REPLY 2 bytes.
unsigned short int usn_ar$hln
H/W address length 1 byte ,specifies the sizes of the H/W address in bytes.
HARDWARETYPE n_ar$hrd
Hardware Type 2 bytes.
PNETSIM_MACADDRESS sz_ar$sha
Hardware address of the sender.
PNETSIM_MACADDRESS szSrcMac
Source MAC address.
PROTOCOLTYPE n_ar$pro
Protocol Type 2 bytes.
NETSIM_IPAddress sz_ar$tpa
Protocol address of target.
NETSIM_IPAddress szDestAdd
Store the destination IP address.
NetSim_PACKET * pstruPacket
Store the packet.
NETSIM_ID nBufferInterfaceID
Store the InterfaceId while buffering the packet.