Пример #1
0
        private void listFieldEx(ref PacketDotNet.Packet targetPack)
        {
            //Get packet type name
            var packetTypeName = targetPack.GetType().Name;
            var packetFieldTypeName = packetTypeName.Substring(0, packetTypeName.Length - 6) + "Fields";
            var packetFieldsType = Program.getPacketType("PacketDotNet." + packetFieldTypeName);
            //Get packet fields
            var fieldList = packetFieldsType.GetFields();

            foreach (var i in fieldList)
            {
                var fieldTypeName = i.Name;
                if (fieldTypeName.EndsWith("Position"))
                {
                    int foffset = (int)i.GetValue(null);
                    var fieldName = fieldTypeName.Substring(0, fieldTypeName.Length - 8);
                    offsetDict.Add(fieldName, offset + foffset);
                }
                else if (fieldTypeName.EndsWith("Length"))
                {
                    int length = (int)i.GetValue(null);
                    var fieldName = fieldTypeName.Substring(0, fieldTypeName.Length - 6);
                    lengthDict.Add(fieldName, length);
                }
            }
        }
Пример #2
-1
        public sPacket(ref PacketDotNet.Packet p)
        {
            timestamp = DateTime.Now;

            PacketDotNet.Packet c;
            for (c = p; c.PayloadPacket != null; c = c.PayloadPacket) ;
            finalType = c.GetType();

            packet = p;
        }
Пример #3
-1
 private void listField(ref PacketDotNet.Packet targetPack)
 {
     if (targetPack is PacketDotNet.InternetLinkLayerPacket)
         this.BackColor = Color.FromArgb(0xffffff);
     else if (targetPack is PacketDotNet.InternetPacket)
         this.BackColor = Color.FromArgb(0xccffff);
     else if (targetPack is TransportPacket)
         this.BackColor = Color.FromArgb(0xccccff);
     
        
     switch (targetPack.GetType().Name)
     {
         case "EthernetPacket":
             EthernetPacket eth = targetPack as EthernetPacket;
             listField(ref eth);
             break;
         case "ARPPacket":
             ARPPacket arp = targetPack as ARPPacket;
             listField(ref arp);
             break;
         case "IPv4Packet":
             var ipv4 = targetPack as IPv4Packet;
             listField(ref ipv4);
             break;
         case "ICMPv4Packet":
             var ICMPv4 = targetPack as ICMPv4Packet;
             listField(ref ICMPv4);
             break;
         case "TcpPacket":
             var tcp = targetPack as TcpPacket;
             listField(ref tcp);
             break;
         case "UdpPacket":
             var udp = targetPack as UdpPacket;
             listField(ref udp);
             break;
         case "HLPacket":
             var hlp = targetPack as HLPacket;
             listField(ref hlp);
             Text = hlp.packetType;
             break;
     }
     if (targetPack.PayloadPacket == null && targetPack.PayloadData != null)
     {
         addField("Payload Data", targetPack.PayloadData, targetPack.Header.Length, targetPack.BytesHighPerformance.BytesLength-targetPack.Header.Length);
     }
 }