Exemple #1
0
        public override IEnumerable <AbstractPacket> GetSubPackets(bool includeSelfReference)
        {
            if (includeSelfReference)
            {
                yield return(this);
            }
            AbstractPacket packet          = null;
            int            erfHeaderLength = 16;

            if (this.extensionHeadersPresent)
            {
                erfHeaderLength += 4;//correct?
            }
            if (PacketStartIndex + 16 < PacketEndIndex)
            {
                if (type == (byte)RecordTypes.ERF_TYPE_ETH || type == (byte)RecordTypes.ERF_TYPE_COLOR_ETH || type == (byte)RecordTypes.ERF_TYPE_DSM_COLOR_ETH)
                {
                    packet = new Ethernet2Packet(this.ParentFrame, this.PacketStartIndex + erfHeaderLength + 2, this.PacketEndIndex);
                }
                else if (type == (byte)RecordTypes.ERF_TYPE_IPV4)
                {
                    IPv4Packet.TryParse(this.ParentFrame, this.PacketStartIndex + erfHeaderLength, this.PacketEndIndex, out packet);
                    //packet = new IPv4Packet(this.ParentFrame, this.PacketStartIndex + erfHeaderLength, this.PacketEndIndex);
                }
                else if (type == (byte)RecordTypes.ERF_TYPE_IPV6)
                {
                    packet = new IPv6Packet(this.ParentFrame, this.PacketStartIndex + erfHeaderLength, this.PacketEndIndex);
                }
                else if (
                    type == (byte)RecordTypes.ERF_TYPE_HDLC_POS ||
                    type == (byte)RecordTypes.ERF_TYPE_COLOR_HDLC_POS ||
                    type == (byte)RecordTypes.ERF_TYPE_DSM_COLOR_HDLC_POS ||
                    type == (byte)RecordTypes.ERF_TYPE_COLOR_MC_HDLC_POS)
                {
                    int firstByte = this.ParentFrame.Data[this.PacketStartIndex];
                    if (firstByte == 0x0f || firstByte == 0x8f)
                    {
                        packet = new CiscoHdlcPacket(this.ParentFrame, this.PacketStartIndex + erfHeaderLength, this.PacketEndIndex);
                    }
                    else
                    {
                        packet = new PointToPointPacket(this.ParentFrame, this.PacketStartIndex + erfHeaderLength, this.PacketEndIndex);
                    }
                }

                if (packet != null)
                {
                    yield return(packet);

                    foreach (AbstractPacket subPacket in packet.GetSubPackets(false))
                    {
                        yield return(subPacket);
                    }
                }
            }
        }
        public override IEnumerable <AbstractPacket> GetSubPackets(bool includeSelfReference)
        {
            if (includeSelfReference)
            {
                yield return(this);
            }
            if (this.payloadLength > 0 && this.code == (byte)CODE.SessionData)
            {
                int pppEndIndex = this.PacketStartIndex + PAYLOAD_OFFSET + this.payloadLength - 1;
                if (pppEndIndex <= this.PacketEndIndex)
                {
                    PointToPointPacket packet = new PointToPointPacket(this.ParentFrame, this.PacketStartIndex + PAYLOAD_OFFSET, pppEndIndex);
                    yield return(packet);

                    foreach (AbstractPacket subPacket in packet.GetSubPackets(false))
                    {
                        yield return(subPacket);
                    }
                }
            }
        }