public UDPDisplayPacket(IpV4Header ipHeader, UdpHeader udpHeader)
        {
            Destination     = ipHeader.DestinationAddress;
            DestinationPort = string.Format("{0} {1}", udpHeader.DestinationPort, UDPPortLookup.GetPortName(udpHeader.DestinationPort));
            Source          = ipHeader.SourceAddress;
            SourcePort      = string.Format("{0} {1}", udpHeader.SourcePort, UDPPortLookup.GetPortName(udpHeader.SourcePort));
            Type            = ipHeader.ProtocolType;
            StringBuilder retVal = new StringBuilder();

            if (udpHeader.SourcePort == 520 || udpHeader.DestinationPort == 520)
            {
                //RIP Protocol
            }
            else if (udpHeader.SourcePort == 161 || udpHeader.DestinationPort == 161 ||
                     udpHeader.SourcePort == 162 || udpHeader.DestinationPort == 162 ||
                     udpHeader.SourcePort == 10161 || udpHeader.DestinationPort == 10161 ||
                     udpHeader.SourcePort == 10162 || udpHeader.DestinationPort == 10162)
            {
                //SNMP Protocol
            }
            else if (udpHeader.SourcePort == 67 || udpHeader.DestinationPort == 67 ||
                     udpHeader.SourcePort == 68 || udpHeader.DestinationPort == 68)
            {
                //DHCP Protocol
            }
            else if (udpHeader.DestinationPort == 53 || udpHeader.SourcePort == 53)
            {
                AppendDNSInfo(udpHeader.Data, retVal);
            }
            AppendUDPInfo(udpHeader, retVal);
            AppendIPInfo(ipHeader, retVal);
            AppendData(udpHeader.Data, retVal);
            Data = retVal.ToString();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            UDPPortLookup.GetPortName(21);

            byte[] tempVal = { 69, 0, 0, 40, 1, 71, 64, 0, 128, 6, 158, 227, 131, 101, 240, 204, 40, 97, 190, 18, 221, 138, 1, 187, 191, 197, 33, 128, 198, 174, 234, 211, 80, 16, 1, 4, 226, 28, 0, 0 };

            var ipPacket = new IpV4Header(tempVal, 2);
        }