예제 #1
0
        public L2(PacketSpan <EthernetHeader> etherSpan)
        {
            this.Ethernet = default;

            this.Type    = PacketL2Type.Ethernet;
            this.Generic = etherSpan.ToGenericSpan();
        }
예제 #2
0
        public L2_VLan(PacketSpan <VLanHeader> tagVlanSpan, EthernetProtocolId tpid)
        {
            this.TagVlan = default;

            this.Type    = tpid;
            this.Generic = tagVlanSpan.ToGenericSpan();
        }
예제 #3
0
        public L7(PacketSpan <GenericHeader> l2tpPayloadSpan, L2TPPacketParsed l2tpPacketParsed)
        {
            this.L2TPPacketParsed = l2tpPacketParsed;

            this.Generic = l2tpPayloadSpan;
            this.Type    = L7Type.L2TP;
        }
예제 #4
0
        public L7(PacketSpan <GenericHeader> payloadSpan, L7Type type)
        {
            this.L2TPPacketParsed = null;

            this.Generic = payloadSpan;
            this.Type    = type;
        }
예제 #5
0
        public L4(PacketSpan <UDPHeader> udpSpan)
        {
            this.TCP = default;
            this.UDP = default;

            this.Type    = IPProtocolNumber.UDP;
            this.Generic = udpSpan.ToGenericSpan();
        }
예제 #6
0
        public L3(PacketSpan <PPPoESessionHeader> pppoeSpan)
        {
            this.IPv4  = default;
            this.PPPoE = default;

            this.Type    = EthernetProtocolId.PPPoE_Session;
            this.Generic = pppoeSpan.ToGenericSpan();
        }
예제 #7
0
        public L3(PacketSpan <IPv4Header> ipv4Span)
        {
            this.IPv4  = default;
            this.PPPoE = default;

            this.Type    = EthernetProtocolId.IPv4;
            this.Generic = ipv4Span.ToGenericSpan();
        }
예제 #8
0
        bool ParseL2_Ethernet(ref Packet pkt, PacketSpan <EthernetHeader> etherSpan)
        {
            if (etherSpan.IsEmpty(ref pkt))
            {
                SetError("Insufficient header data");
                return(false);
            }

            this.L2 = new L2(etherSpan);

            ref EthernetHeader ether = ref etherSpan.GetRefValue(ref pkt);
예제 #9
0
        public PacketParsed(ref Packet pkt, int startPin = DefaultSize, PacketParseOption?options = null, int maxPacketSize = DefaultSize, PacketParseMode mode = PacketParseMode.Layer2, EthernetProtocolId layer3ProtocolId = EthernetProtocolId.Unknown)
        {
            this.ParseOption = options ?? DefaultOption;
            maxPacketSize    = maxPacketSize._DefaultSize(pkt.Length);

            switch (mode)
            {
            case PacketParseMode.Layer2:
                PacketSpan <EthernetHeader> etherSpan = pkt.GetSpan <EthernetHeader>(startPin._DefaultSize(pkt.PinHead), maxPacketSize: maxPacketSize);
                ParseL2_Ethernet(ref pkt, etherSpan);
                break;

            case PacketParseMode.Layer3:
                PacketSpan <GenericHeader> l3Span = pkt.GetSpan <GenericHeader>(startPin._DefaultSize(pkt.PinHead), size: 0, maxPacketSize: maxPacketSize);
                ParseL3(ref pkt, l3Span, layer3ProtocolId);
                break;
            }
        }