/// <summary>
        /// Look for the innermost payload. This method is useful because
        /// while some packets are LinuxSSL->IpPacket or
        /// EthernetPacket->IpPacket, there are some packets that are
        /// EthernetPacket->PPPoEPacket->PPPPacket->IpPacket, and for these cases
        /// we really want to get to the IpPacket
        /// </summary>
        /// <returns>
        /// A <see cref="Packet"/>
        /// </returns>
        public static Packet GetInnerPayload(InternetLinkLayerPacket packet)
        {
            // is this an ethernet packet?
            if (packet is EthernetPacket)
            {
                log.Debug("packet is EthernetPacket");

                var thePayload = packet.PayloadPacket;

                // is this packets payload a PPPoEPacket? If so,
                // the PPPoEPacket payload should be a PPPPacket and we want
                // the payload of the PPPPpacket
                if (thePayload is PPPoEPacket)
                {
                    log.Debug("thePayload is PPPoEPacket");
                    return(thePayload.PayloadPacket.PayloadPacket);
                }

                return(thePayload);
            }
            else
            {
                log.Debug("else");
                return(packet.PayloadPacket);
            }
        }
Пример #2
0
 public static LLDPPacket GetType(Packet p)
 {
     if (p is InternetLinkLayerPacket)
     {
         Packet innerPayload = InternetLinkLayerPacket.GetInnerPayload((InternetLinkLayerPacket)p);
         if (innerPayload is LLDPPacket)
         {
             return((LLDPPacket)innerPayload);
         }
     }
     return(null);
 }
Пример #3
0
 public static ARPPacket GetEncapsulated(Packet p)
 {
     if (p is InternetLinkLayerPacket)
     {
         Packet innerPayload = InternetLinkLayerPacket.GetInnerPayload((InternetLinkLayerPacket)p);
         if (innerPayload is ARPPacket)
         {
             return((ARPPacket)innerPayload);
         }
     }
     return(null);
 }
Пример #4
0
        /// <summary>
        /// Returns the IpPacket inside of the Packet p or null if
        /// there is no encapsulated packet
        /// </summary>
        /// <param name="p">
        /// A <see cref="Packet"/>
        /// </param>
        /// <returns>
        /// A <see cref="IpPacket"/>
        /// </returns>
        public static IpPacket GetEncapsulated(Packet p)
        {
            if (p is InternetLinkLayerPacket)
            {
                var payload = InternetLinkLayerPacket.GetInnerPayload((InternetLinkLayerPacket)p);
                if (payload is IpPacket)
                {
                    return((IpPacket)payload);
                }
            }

            return(null);
        }
 public static Packet GetInnerPayload(InternetLinkLayerPacket packet)
 {
     if (!(packet is EthernetPacket))
     {
         return packet.PayloadPacket;
     }
     Packet payloadPacket = packet.PayloadPacket;
     if (payloadPacket is PPPoEPacket)
     {
         return payloadPacket.PayloadPacket.PayloadPacket;
     }
     return payloadPacket;
 }
        public static Packet GetInnerPayload(InternetLinkLayerPacket packet)
        {
            if (!(packet is EthernetPacket))
            {
                return(packet.PayloadPacket);
            }
            Packet payloadPacket = packet.PayloadPacket;

            if (payloadPacket is PPPoEPacket)
            {
                return(payloadPacket.PayloadPacket.PayloadPacket);
            }
            return(payloadPacket);
        }
Пример #7
0
        public static LLDPPacket GetEncapsulated(Packet p)
        {
            log.Debug("");

            if (p is InternetLinkLayerPacket)
            {
                var payload = InternetLinkLayerPacket.GetInnerPayload((InternetLinkLayerPacket)p);
                if (payload is LLDPPacket)
                {
                    return((LLDPPacket)payload);
                }
            }

            return(null);
        }
Пример #8
0
 public static ICMPv4Packet GetEncapsulated(Packet p)
 {
     if (p is InternetLinkLayerPacket)
     {
         Packet innerPayload = InternetLinkLayerPacket.GetInnerPayload((InternetLinkLayerPacket)p);
         if (innerPayload is IpPacket)
         {
             Packet payloadPacket = innerPayload.PayloadPacket;
             if (payloadPacket is ICMPv4Packet)
             {
                 return((ICMPv4Packet)payloadPacket);
             }
         }
     }
     return(null);
 }
Пример #9
0
        /// <summary>
        /// Returns the encapsulated IGMPv2Packet of the Packet p or null if
        /// there is no encapsulated packet
        /// </summary>
        /// <param name="p">
        /// A <see cref="Packet"/>
        /// </param>
        /// <returns>
        /// A <see cref="IGMPv2Packet"/>
        /// </returns>
        public static IGMPv2Packet GetEncapsulated(Packet p)
        {
            if (p is InternetLinkLayerPacket)
            {
                var payload = InternetLinkLayerPacket.GetInnerPayload((InternetLinkLayerPacket)p);
                if (payload is IpPacket)
                {
                    Console.WriteLine("Is an IP packet");
                    var innerPayload = payload.PayloadPacket;
                    if (innerPayload is IGMPv2Packet)
                    {
                        return((IGMPv2Packet)innerPayload);
                    }
                }
            }

            return(null);
        }
Пример #10
0
        public static ICMPv4Packet GetEncapsulated(Packet p)
        {
            log.Debug("");

            if (p is InternetLinkLayerPacket)
            {
                var payload = InternetLinkLayerPacket.GetInnerPayload((InternetLinkLayerPacket)p);
                if (payload is IpPacket)
                {
                    var payload2 = payload.PayloadPacket;
                    if (payload2 is ICMPv4Packet)
                    {
                        return((ICMPv4Packet)payload2);
                    }
                }
            }

            return(null);
        }