25#define _CRT_SECURE_NO_DEPRECATE
49static PNETSIM_MACADDRESS read_table(ARP_VARIABLES* arp,NETSIM_IPAddress ip)
51 ARP_TABLE* table = arp->pstruArpTable;
61int fn_NetSim_Read_ARP_Table()
64 NETSIM_ID nInterfaceId, nDestinationId=0;
65 NETSIM_IPAddress szDestIPadd;
66 PNETSIM_MACADDRESS szDestMAC=NULL;
69 NetSim_PACKET *pstruTemp_Data;
70 ARP_TABLE *pstruTableHead, *pstruCurrentTable;
71 ARP_VARIABLES *pstruArpVariables;
74 pstruTemp_Data =pstruEventDetails->pPacket;
77 nInterfaceId = pstruEventDetails->nInterfaceId;
78 nDeviceId = pstruEventDetails->nDeviceId;
79 szDestIPadd = pstruTemp_Data->pstruNetworkData->szNextHopIp;
81 if (isBroadcastIP(szDestIPadd))
83 szDestMAC = BROADCAST_MAC;
85 else if (isMulticastIP(szDestIPadd))
87 szDestMAC = multicastIP_to_Mac(szDestIPadd);
91 pstruArpVariables = DEVICE_INTERFACE(nDeviceId, nInterfaceId)->ipVar;
92 pstruTableHead = pstruArpVariables->pstruArpTable;
94 szDestMAC = read_table(pstruArpVariables, szDestIPadd);
99 nDestinationId = get_first_dest_from_packet(pstruTemp_Data);
104 pstruTemp_Data->pstruMacData->szDestMac = szDestMAC;
105 pstruTemp_Data->pstruMacData->szSourceMac = DEVICE_INTERFACE(nDeviceId,nInterfaceId)->pstruMACLayer->szMacAddress;
107 if(!fn_NetSim_GetBufferStatus(DEVICE_INTERFACE(nDeviceId,nInterfaceId)->pstruAccessInterface->pstruAccessBuffer))
109 pstruEventDetails->nProtocolId = fn_NetSim_Stack_GetMacProtocol(nDeviceId,nInterfaceId);
110 pstruEventDetails->dEventTime = pstruEventDetails->dEventTime;
111 pstruEventDetails->nSubEventType = 0;
112 pstruEventDetails->dPacketSize = pstruTemp_Data->pstruNetworkData->dPacketSize;
113 pstruEventDetails->nEventType=MAC_OUT_EVENT;
114 pstruEventDetails->pPacket=NULL;
115 fnpAddEvent( pstruEventDetails);
117 fn_NetSim_Packet_AddPacketToList(DEVICE_INTERFACE(nDeviceId,nInterfaceId)->pstruAccessInterface->pstruAccessBuffer,pstruTemp_Data,0);
124 fn_NetSim_Add_PacketTo_Buffer(nDeviceId,pstruTemp_Data,szDestIPadd,nInterfaceId);
128 pstruEventDetails->nSubEventType = GENERATE_ARP_REQUEST;
129 fnpAddEvent(pstruEventDetails);
134 fn_NetSim_Add_PacketTo_Buffer(nDeviceId,pstruTemp_Data,szDestIPadd,nInterfaceId);
int * pnArpRequestFlag
Set when generate Request.
ARP_METRICS * pstruArpMetrics
NetSim specific ARP metrics structure.
int nPacketsInBuffer
Number of packets in the buffer.
PNETSIM_MACADDRESS szMACAddress
MAC address or Hardware address of the device.
struct stru_ARP_Table * pstruNextEntry
Next entry pointer.
NETSIM_IPAddress szIPAddress
IP address of the deivce.