Beispiel #1
0
        /// <summary>
        /// Returns the encapsulated ARPPacket 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="ARPPacket"/>
        /// </returns>
        public static ARPPacket GetEncapsulated(Packet p)
        {
            if (p is InternetLinkLayerPacket)
            {
                var payload = InternetLinkLayerPacket.GetInnerPayload((InternetLinkLayerPacket)p);
                if (payload is ARPPacket)
                {
                    return((ARPPacket)payload);
                }
            }

            return(null);
        }
Beispiel #2
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)
        {
            log.Debug("");

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

            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// Returns the UdpPacket 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="UdpPacket"/>
        /// </returns>
        public static UdpPacket GetEncapsulated(Packet p)
        {
            if (p is InternetLinkLayerPacket)
            {
                var payload = InternetLinkLayerPacket.GetInnerPayload((InternetLinkLayerPacket)p);
                if (payload is IpPacket)
                {
                    var innerPayload = payload.PayloadPacket;
                    if (innerPayload is UdpPacket)
                    {
                        return((UdpPacket)innerPayload);
                    }
                }
            }

            return(null);
        }
Beispiel #4
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);
        }