public PacketItem(EthernetPacket packet) { _packet = packet; _source = packet.Source.PrettyPrint(); _destination = packet.Destination.PrettyPrint(); _protocol = packet.ProtocolString; if (packet.PayloadPacket is IpPacket) { IpPacket ipPacket = (IpPacket)packet.PayloadPacket; _source = ipPacket.Source.ToString(); _destination = ipPacket.Destination.ToString(); } }
private void AddPacket(EthernetPacket packet) { if (!Dispatcher.CheckAccess()) { Dispatcher.Invoke(new AddPacketDelegate(AddPacket), packet); return; } if (!(packet.PayloadPacket is IpPacket)) return; IpPacket ipPacket = (IpPacket)packet.PayloadPacket; int sourcePort; int destinationPort; Protocol ipProtocolType = ipPacket.Protocol; if (ipPacket.PayloadPacket is TCPPacket) { TCPPacket transportPacket = (TCPPacket)ipPacket.PayloadPacket; sourcePort = transportPacket.SourcePort; destinationPort = transportPacket.DestinationPort; } else if (ipPacket.PayloadPacket is UDPPacket) { UDPPacket transportPacket = (UDPPacket)ipPacket.PayloadPacket; sourcePort = transportPacket.SourcePort; destinationPort = transportPacket.DestinationPort; } else { return; } Conversation conversation = _conversations.FirstOrDefault(c => c.Check(ipPacket.Source, sourcePort, ipPacket.Destination, destinationPort, ipProtocolType)); if (conversation == null) { conversation = new Conversation(ipPacket.Source, sourcePort, ipPacket.Destination, destinationPort, ipProtocolType); _conversations.Add(conversation); } conversation.Packets.Add(ipPacket); }
private void AddPacket(EthernetPacket packet) { if (!listViewPackets.Dispatcher.CheckAccess()) { listViewPackets.Dispatcher.Invoke(new Action<EthernetPacket>(AddPacket), packet); return; } PacketItem packetItem = new PacketItem(packet); _packets.Add(packetItem); if (_listViewScrollView == null) { _listViewScrollView = GetScrollView(listViewPackets); if (_listViewScrollView == null) return; } //TODO: autoscroller listViewPackets.ScrollIntoView(packetItem); }
public PacketArrivedEventArgs(EthernetPacket packet) { Packet = packet; }
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; }