Exemplo n.º 1
0
        public IEnumerator <PacketSaveDataNG> GetEnumerator()
        {
            try
            {
                List <PacketSaveDataNG> blockCol = new List <PacketSaveDataNG>();
                pReader = new PcapReader(_fileName);
                string linkLayer = ((int)pReader.Header.LinkType).ToString();
                pReader.OnReadPacketEvent += delegate(object context, IPacket packet)
                {
                    PacketSaveDataNG psdng = new PacketSaveDataNG(HexStreamType.Raw, packet.Data.ToHex());
                    psdng.Details[PacketSaveDataNGProtoFields.ENCAPS_TYPE] = linkLayer;
                    blockCol.Add(psdng);
                };
                pReader.ReadPackets(CancellationToken.None);

                foreach (var packet in blockCol)
                {
                    yield return(packet);
                }
            }
            finally
            {
                pReader?.Dispose();
            }
        }
Exemplo n.º 2
0
        public IEnumerator <PacketSaveData> GetEnumerator()
        {
            try
            {
                List <PacketSaveData> blockCol = new List <PacketSaveData>();
                pReader = new PcapReader(_fileName);
                string linkLayer = ((int)pReader.Header.LinkType).ToString();
                pReader.OnReadPacketEvent += delegate(object context, IPacket packet)
                {
                    PacketSaveData psd = new PacketSaveDataV3(packet.Data.ToHex(), HexStreamType.Raw, linkLayer, "1", "1", "");
                    blockCol.Add(psd);
                };
                pReader.ReadPackets(CancellationToken.None);

                foreach (var packet in blockCol)
                {
                    yield return(packet);
                }
            }
            finally
            {
                pReader?.Dispose();
            }
        }
Exemplo n.º 3
0
 public void Dispose()
 {
     pReader?.Dispose();
 }