Beispiel #1
0
        internal static PacketOrByteArraySegment ParseEncapsulatedBytes(ByteArraySegment Header,
                                                                        PPPProtocol Protocol)
        {
            // slice off the payload
            var payload = Header.EncapsulatedBytes();


            var payloadPacketOrData = new PacketOrByteArraySegment();

            switch (Protocol)
            {
            case PPPProtocol.IPv4:
                payloadPacketOrData.ThePacket = new IPv4Packet(payload);
                break;

            case PPPProtocol.IPv6:
                payloadPacketOrData.ThePacket = new IPv6Packet(payload);
                break;

            default:
                throw new System.NotImplementedException("Protocol of " + Protocol + " is not implemented");
            }

            return(payloadPacketOrData);
        }
Beispiel #2
0
        /// <summary>
        /// Construct a new PPPPacket from source and destination mac addresses
        /// </summary>
        public PPPPacket(PPPoECode Code,
                         UInt16 SessionId)
        {
            // allocate memory for this packet
            int offset      = 0;
            int length      = PPPFields.HeaderLength;
            var headerBytes = new byte[length];

            header = new ByteArraySegment(headerBytes, offset, length);

            // setup some typical values and default values
            this.Protocol = PPPProtocol.Padding;
        }
Beispiel #3
0
        internal static PacketOrByteArraySegment ParseEncapsulatedBytes(ByteArraySegment Header, PosixTimeval Timeval, PPPProtocol Protocol)
        {
            ByteArraySegment         segment  = Header.EncapsulatedBytes();
            PacketOrByteArraySegment segment2 = new PacketOrByteArraySegment();
            PPPProtocol protocol = Protocol;

            if (protocol != PPPProtocol.IPv4)
            {
                if (protocol != PPPProtocol.IPv6)
                {
                    throw new NotImplementedException("Protocol of " + Protocol + " is not implemented");
                }
            }
            else
            {
                segment2.ThePacket = new IPv4Packet(segment.Bytes, segment.Offset, Timeval);
                return(segment2);
            }
            segment2.ThePacket = new IPv6Packet(segment.Bytes, segment.Offset, Timeval);
            return(segment2);
        }