Exemplo n.º 1
0
 public IEnumerator <PacketSaveDataNG> GetEnumerator()
 {
     try
     {
         reader = new PcapngFile.Reader(_fileName);
         int interfaceId = 0;
         Dictionary <int, LinkType> interfaceIdToLinkLayer = new Dictionary <int, LinkType>();
         foreach (InterfaceDescriptionBlock readerInterfaceDescriptionBlock in reader.InterfaceDescriptionBlocks)
         {
             interfaceIdToLinkLayer.Add(interfaceId, readerInterfaceDescriptionBlock.LinkType);
         }
         foreach (EnhancedPacketBlock packetBlock in reader.EnhancedPacketBlocks)
         {
             LinkType         linkType    = interfaceIdToLinkLayer[packetBlock.InterfaceID];
             string           linkTypeStr = ((byte)linkType).ToString();
             byte[]           data        = packetBlock.Data;
             PacketSaveDataNG psdng       = new PacketSaveDataNG(HexStreamType.Raw, data.ToHex());
             psdng.Details[PacketSaveDataNGProtoFields.ENCAPS_TYPE] = linkTypeStr;
             yield return(psdng);
         }
     }
     finally
     {
         reader?.Dispose();
     }
 }
Exemplo n.º 2
0
 public IEnumerator <PacketSaveData> GetEnumerator()
 {
     try
     {
         reader = new PcapngFile.Reader(_fileName);
         int interfaceId = 0;
         Dictionary <int, LinkType> interfaceIdToLinkLayer = new Dictionary <int, LinkType>();
         foreach (InterfaceDescriptionBlock readerInterfaceDescriptionBlock in reader.InterfaceDescriptionBlocks)
         {
             interfaceIdToLinkLayer.Add(interfaceId, readerInterfaceDescriptionBlock.LinkType);
         }
         foreach (EnhancedPacketBlock packetBlock in reader.EnhancedPacketBlocks)
         {
             LinkType linkType    = interfaceIdToLinkLayer[packetBlock.InterfaceID];
             string   linkTypeStr = ((byte)linkType).ToString();
             byte[]   data        = packetBlock.Data;
             yield return(new PacketSaveDataV3(data.ToHex(), HexStreamType.Raw, linkTypeStr, "1", "1", ""));
         }
     }
     finally
     {
         reader?.Dispose();
     }
 }