Пример #1
0
        /// <summary>
        /// Parsing frame from l2 data.
        /// </summary>
        /// <returns></returns>
        /// TODO refactor this to more appropriate place
        public bool ParseFrameForCluster()
        {
            var packet = new PmPacket(this.PmLinkType, (this.L2DataWcf = this.L2Data()));

            this.L3Offset = this.L2Offset + packet.PacketHeaderOffset;

            this.IpProtocol = packet.ProtocolIdentifier;

            switch (packet.ProtocolIdentifier)
            {
            case IPProtocolType.IP:
            case IPProtocolType.TCP:
            case IPProtocolType.UDP:
                this.SrcAddress = packet.SourceAddress;
                this.DstAddress = packet.DestinationAddress;
                break;

            //Possible 6in4
            case IPProtocolType.IPV6:
                this.SrcAddress = packet.SourceAddress;
                this.DstAddress = packet.DestinationAddress;
                break;
            }
            this.SrcPort = packet.SourceTransportPort;
            this.DstPort = packet.DestinationTransportPort;

            this.PmCaptureRefId = this.PmCapture.Id;
            if (this.TimeStamp == DateTime.MinValue)
            {
                this.TimeStamp = DateTime.MinValue.ToUniversalTime();
            }
            return(this.IpProtocol == IPProtocolType.TCP || this.IpProtocol == IPProtocolType.UDP || this.IpProtocol == IPProtocolType.IP ||
                   this.IpProtocol == IPProtocolType.IPV6);
        }
Пример #2
0
        /// <summary>
        /// BEAWARE Runns in parallel
        /// </summary>
        /// <param name="pmFrame"></param>
        /// <param name="parentPacket"></param>
        /// <returns></returns>
        public async Task CreateAndAddToMetaFramesVirtualFrame(PmFrameBase pmFrame, PmPacket parentPacket)
        {
            PmFrameVirtual virtualFrame = null;

            switch (pmFrame.IpProtocol)
            {
            case IPProtocolType.GRE:
                var gre = new GrePacket(new ByteArraySegment(pmFrame.L4Data()));
                virtualFrame = new PmFrameVirtual(pmFrame.PmCapture, pmFrame.FrameIndex, pmFrame.TimeStamp, pmFrame.IncludedLength, (pmFrame.L4Offset + gre.Header.Length));
                break;

            case IPProtocolType.IPV6:
                virtualFrame = new PmFrameVirtual(pmFrame.PmCapture, pmFrame.FrameIndex, pmFrame.TimeStamp, pmFrame.IncludedLength, (pmFrame.L4Offset));
                break;

            case IPProtocolType.UDP:
                var udp = new UdpPacket(new ByteArraySegment(pmFrame.L4Data()));
                //Port 3544 is used to communicate with Teredo Server. We need communication between host and Teredo Relay (temporarily solution)
                if (udp.DestinationPort == 3544 || udp.SourcePort == 3544)
                {
                    break;
                }

                virtualFrame = new PmFrameVirtual(pmFrame.PmCapture, pmFrame.FrameIndex, pmFrame.TimeStamp, pmFrame.IncludedLength,
                                                  (pmFrame.L4Offset + udp.Header.Length));
                break;
            }
            if (virtualFrame != null)
            {
                await this.PmMetaFramesBufferBlock.SendAsync(virtualFrame);
            }
        }