internal static void UpdateArpNode(TreeView treeView, ARPPacket arpPacket) { TreeNode arpNode = treeView.Nodes["ARP"]; if (arpNode == null) { arpNode = AddArpNode(treeView); } arpNode.Text = String.Format("Address Resolution Protocol ({0})", DataStructures.GetARPOpDescription(arpPacket.ARPOperation)); arpNode.Nodes["HwType"].Text = String.Format("Hardware type: {0} (0x{1:X4})", DataStructures.GetARPHwTypeDescription(arpPacket.ARPHwType), arpPacket.ARPHwType); arpNode.Nodes["ProtocolType"].Text = String.Format("Protocol type: {0} (0x{1:X4})", DataStructures.GetEtherTypeDescription((EthernetPacketType)arpPacket.ARPProtocolType), arpPacket.ARPProtocolType); arpNode.Nodes["HwSize"].Text = String.Format("Hardware size: {0}", arpPacket.ARPHwLength); arpNode.Nodes["ProtocolSize"].Text = String.Format("Protocol size: {0}", arpPacket.ARPProtocolLength); arpNode.Nodes["Opcode"].Text = String.Format("Operation: {0} (0x{1:X4})", DataStructures.GetARPOpDescription(arpPacket.ARPOperation), arpPacket.ARPOperation); arpNode.Nodes["SenderHwAddress"].Text = String.Format("Sender MAC address: {0}", GetHyphenatedHwAddress(arpPacket.ARPSenderHwAddress)); arpNode.Nodes["SenderIPAddress"].Text = String.Format("Sender IP address: {0}", arpPacket.ARPSenderProtoAddress); arpNode.Nodes["TargetHwAddress"].Text = String.Format("Target MAC address: {0}", GetHyphenatedHwAddress(arpPacket.ARPTargetHwAddress)); arpNode.Nodes["TargetIPAddress"].Text = String.Format("Target IP address: {0}", arpPacket.ARPTargetProtoAddress); }
internal static void UpdateEthernetNode(TreeView treeView, EthernetPacket ethPacket) { TreeNode ethNode = treeView.Nodes["Ethernet"]; if (ethNode == null) { ethNode = AddEthernetNode(treeView); } ethNode.Text = String.Format("Ethernet II, Src: {0}, Dst: {1}", GetHyphenatedHwAddress(ethPacket.SourceHwAddress), GetHyphenatedHwAddress(ethPacket.DestinationHwAddress)); ethNode.Nodes["Destination"].Text = String.Format("Destination: {0}", GetHyphenatedHwAddress(ethPacket.DestinationHwAddress)); ethNode.Nodes["Source"].Text = String.Format("Source: {0}", GetHyphenatedHwAddress(ethPacket.SourceHwAddress)); ethNode.Nodes["Type"].Text = String.Format("Type: {0} (0x{1:X4})", DataStructures.GetEtherTypeDescription(ethPacket.EthernetProtocol), (int)ethPacket.EthernetProtocol); }