private void SendARPRequest(IPAddress ipaDestination, IPAddress ipaSource) { eExNetworkLibrary.ARP.ARPFrame arpRequest = new eExNetworkLibrary.ARP.ARPFrame(); arpRequest.SourceIP = ipaSource; arpRequest.SourceMAC = this.PrimaryMACAddress; arpRequest.DestinationMAC = MACAddress.Empty; arpRequest.HardwareAddressType = HardwareAddressType.Ethernet; arpRequest.DestinationIP = ipaDestination; if (ipaSource.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { arpRequest.ProtocolAddressType = EtherType.IPv4; } else if (ipaSource.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6) { arpRequest.ProtocolAddressType = EtherType.IPv6; } EthernetFrame ethFrame = new EthernetFrame(); ethFrame.Source = this.PrimaryMACAddress; ethFrame.Destination = new MACAddress(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }); ethFrame.EncapsulatedFrame = arpRequest; ethFrame.EtherType = eExNetworkLibrary.EtherType.ARP; TrafficDescriptionFrame tdf = new TrafficDescriptionFrame(null, DateTime.Now); tdf.EncapsulatedFrame = ethFrame; this.Send(ethFrame); }
/// <summary> /// Checks for available ARP messages and updates the ARP table. /// </summary> /// <param name="fInputFrame">A frame to analyze.</param> private void AnalyzeARP(Frame fInputFrame) { ARP.ARPFrame fArpFrame = GetARPFrame(fInputFrame); if (fArpFrame != null) { MACAddress macMacAddress = fArpFrame.SourceMAC; IPAddress ipAddress = fArpFrame.SourceIP; if (!macMacAddress.IsEmpty) //Check the addresses { if (!this.UsesSpoofedAddress(macMacAddress)) //If none of the addresses is contained in the spoof lists { UpdateAddressTable(macMacAddress, ipAddress); } } } }