private void AddHost(ArpPacket arpPacket) { if (!listViewHosts.Dispatcher.CheckAccess()) { listViewHosts.Dispatcher.Invoke(new Action<ArpPacket>(AddHost), arpPacket); return; } Host host = new Host(arpPacket.SenderMac, arpPacket.SenderIp); _hosts.Add(host); }
public static PacketBase CreateArpRequest(PhysicalAddress senderMac, IPAddress senderIp, IPAddress targetIp) { EthernetPacket ethernetPacket = new EthernetPacket(); ethernetPacket.InternetLayerType = InternetProtocol.Arp; ethernetPacket.Source = senderMac; ethernetPacket.Destination = PhysicalAddress.Parse("FFFFFFFFFFFF"); ArpPacket arpPacket = new ArpPacket(); arpPacket.HardwareType = HardwareType.Ethernet; arpPacket.InternetProtocol = InternetProtocol.Ip; arpPacket.Opcode = ArpOpCode.Request; arpPacket.SenderMac = ethernetPacket.Source; arpPacket.SenderIp = senderIp; arpPacket.TargetMac = ethernetPacket.Destination; arpPacket.TargetIp = targetIp; ethernetPacket.PayloadPacket = arpPacket; return ethernetPacket; }