public L4ConversationExtended(IWindsorContainer container, IL7ConversationTrackerFactory conversationTrackerFactory, IPProtocolType ipProtocol, L3Conversation l3Conversation, IPEndPoint sourceEndPoint, IPEndPoint destinationEndPoint, long l4FlowMTU) : base(container, ipProtocol, l3Conversation, sourceEndPoint, destinationEndPoint, l4FlowMTU) { switch (this.L4ProtocolType) { case IPProtocolType.TCP: this.L7ConversationTracker = conversationTrackerFactory.CreateTCPTracker(this); break; case IPProtocolType.UDP: this.L7ConversationTracker = conversationTrackerFactory.CreateUDPTracker(this); break; default: Debugger.Break(); throw new ArgumentOutOfRangeException(); } }
public L7ConversationTrackerBlock(IL7ConversationTrackerFactory l7ConversationTrackerFactory) { this.L7ConversationTrackerFactory = l7ConversationTrackerFactory; this.ProcessFrame = new ActionBlock <PmFrameBase>(async frame => { var l4ConversationExt = frame.L4Conversation as L4ConversationExtended; if (l4ConversationExt != null) { var l7Conversations = l4ConversationExt.L7ConversationTracker.ProcessPmFrame(frame); await this.PostL7ConversationsIfAny(l7Conversations); } else { await this.Frames.SendAsync(frame); } }, new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }); this.ProcessL4Conversation = new ActionBlock <L4ConversationExtended>(async l4Conversation => { this.L4ConversationsForFinishL7Tracking.Add(l4Conversation); await this.L4Conversations.SendAsync(l4Conversation); }); this.ProcessFrame.Completion.ContinueWith(t => { if (t.IsFaulted) { ((IDataflowBlock)this.Frames).Fault(t.Exception); ((IDataflowBlock)this.L7Conversations).Fault(t.Exception); } else { Parallel.ForEach(this.L4ConversationsForFinishL7Tracking, async l4Conversation => { var l7Conversations = l4Conversation.L7ConversationTracker.Complete(); await this.PostL7ConversationsIfAny(l7Conversations); }); this.Frames.Complete(); this.L7Conversations.Complete(); this.L7ConversationStatistics.Complete(); this.L7Pdus.Complete(); this.PmCaptureL7Conversations.Complete(); } }); this.ProcessL4Conversation.Completion.ContinueWith(t => { if (t.IsFaulted) { ((IDataflowBlock)this.L4Conversations).Fault(t.Exception); } else { this.L4Conversations.Complete(); } }); this.Completion = Task.Run(async() => { await this.Frames.Completion; await this.L7Conversations.Completion; await this.L7ConversationStatistics.Completion; await this.L7Pdus.Completion; await this.L4Conversations.Completion; await this.PmCaptureL7Conversations.Completion; }); }