Beispiel #1
0
        /// <summary>
        /// Get the collection of HTTP messages for the given flow. Single flow
        /// can contain several messages if persistent HTTP mode is used.
        /// </summary>
        /// <param name="tcpFlow">Collection of flow's frames.</param>
        /// <returns>A collection of HTTP messages.</returns>
        private IEnumerable <HttpPacketList> GetHttpMessages(IEnumerable <FrameData> tcpFlow)
        {
            ICollection <HttpPacketList> Empty()
            {
                return(new List <HttpPacketList> {
                    new HttpPacketList()
                });
            }

            ICollection <HttpPacketList> Accumulate(ICollection <HttpPacketList> acc, (HttpPacket Packet, PosixTime Time) arg)
            {
                if (arg.Packet.PacketType == HttpPacketType.Data)
                {
                    acc.Last().Add(arg);
                }
                else
                {
                    acc.Add(new HttpPacketList {
                        arg
                    });
                }
                return(acc);
            }

            return(tcpFlow.Select(f => (Packet: ParseHttpPacket(f), PosixTime.FromUnixTimeMilliseconds(f.Timestamp))).Aggregate(Empty(), Accumulate));
        }
        public FrameData GetNextPacket()
        {
            if (m_reader.BaseStream.Position + 16 <= m_reader.BaseStream.Length)
            {
                var tsSeconds      = m_reader.ReadUInt32();
                var tsMicroseconds = m_reader.ReadUInt32();
                var timeval        = new PosixTime(tsSeconds, tsMicroseconds);
                var includedLength = m_reader.ReadUInt32();
                var originalLength = m_reader.ReadUInt32();

                if ((m_reader.BaseStream.Position + includedLength) <= m_reader.BaseStream.Length)
                {
                    var frameBytes = new byte[includedLength];
                    m_reader.BaseStream.Read(frameBytes, 0, (int)includedLength);
                    return(new FrameData {
                        LinkLayer = m_network, Timestamp = timeval.ToUnixTimeMilliseconds(), Data = frameBytes
                    });
                }
                return(null);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
 public PosixTimeRange(PosixTime a, PosixTime b)
 {
     if (a < b) {
         _low = a;
         _high = b;
     }
     else {
         _low = b;
         _high = a;
     }
 }