#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously public override async Task IndexFrame(IPmCaptureProcessorBlockBase captureProcessorBlockBase) { }
/// <summary> /// Fill L3, L4, L7 offsets and other useful information related to IP fragmentation or TCP reassembling /// BEAWARE Runns in Parallel /// </summary> /// <returns>Everything went fine ? true : false</returns> public virtual async Task IndexFrame(IPmCaptureProcessorBlockBase captureProcessorBlockBase) { try { this.PmCaptureRefId = this.PmCapture.Id; //TODO: After Packet.Extract refactor, what is current efficiency of this method? var packet = this.PmPacket; this.L3Offset = this.L2Offset + packet.PacketHeaderOffset; this.L4Offset = this.L2Offset + packet.SegmentHeaderOffset; //Verify that L4Payload has some data, if not then leave L7Offset uninitialized //TODO: Vesely - What about frames with L4Payload + padding? For them IncludedLength shoud be recounted! this.L7Offset = packet.SegmentPayloadLength != 0 ? this.L2Offset + packet.SegmentPayloadOffset : -1; this.IpProtocol = packet.ProtocolIdentifier; //Create virtual frame from tunel protocol payload switch (packet.ProtocolIdentifier) { case IPProtocolType.IP: case IPProtocolType.TCP: case IPProtocolType.UDP: this.SrcAddress = packet.SourceAddress; this.DstAddress = packet.DestinationAddress; break; case IPProtocolType.GRE: await captureProcessorBlockBase.CreateAndAddToMetaFramesVirtualFrame(this, packet); break; //Possible 6in4 case IPProtocolType.IPV6: this.SrcAddress = packet.SourceAddress; this.DstAddress = packet.DestinationAddress; if (packet.IpVersion == IpVersion.IPv4) { await captureProcessorBlockBase.CreateAndAddToMetaFramesVirtualFrame(this, packet); } break; //Possible Teredo // TODO: Looooot of exceptions //case IPProtocolType.UDP: // if(packet.IpVersion == IpVersion.IPv4) { this.CreateAndAddToMetaFramesVirtualFrame(this, packet); } // break; } this.SrcPort = packet.SourceTransportPort; this.DstPort = packet.DestinationTransportPort; this.Ipv4FIdentification = packet.Ipv4Identification; this.Ipv4FMf = packet.Ipv4MFbit; this.Ipv4FragmentOffset = packet.Ipv4FragmentOffset; this.TcpFAck = packet.TcpFAck; this.TcpFCwr = packet.TcpFCwr; this.TcpFEce = packet.TcpFEce; this.TcpFFin = packet.TcpFFin; // TODO: PacketDotNet can't read NS this.TcpFNs = false; // packet.TcpFNs; this.TcpFPsh = packet.TcpFPsh; this.TcpFRst = packet.TcpFRst; this.TcpFSyn = packet.TcpFSyn; this.TcpFUrg = packet.TcpFUrg; this.TcpSequenceNumber = packet.TcpSequenceNumber; this.TcpAcknowledgementNumber = packet.TcpAcknowledgmentNumber; this.L7PayloadLength = packet.SegmentPayloadLength; } catch (Exception ex) //TODO To general, it would be better to catch more and specific exceptions { this.IsMalformed = true; //Debugger.Break(); //todo fix //Log.Error( //"PmCaptureProcessorBase Cannot parse frame: " + (this.FrameIndex) + " in file: " + this.GetFileName() + // ". It is marked as malformed!", ex); PmConsolePrinter.PrintError("Cannot parse frame: " + (this.FrameIndex) + " in file: " + this.PmCapture.FileInfo.Name + ". It is marked as malformed!\n" + ex.Message); } }