示例#1
0
            public static void SimplePacketBlock_ConvertToByte_Test(bool reorder)
            {
                SimplePacketBlock prePacketBlock, postPacketBlock;

                byte[] byteblock = { 3, 0, 0, 0, 139, 0, 0, 0, 123, 0, 0, 0, 104, 83, 17, 243, 59, 0, 0, 0, 151, 143, 0, 243, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 208, 241, 255, 191, 127, 0, 0, 0, 208, 79, 17, 243, 59, 0, 0, 0, 96, 5, 0, 243, 59, 0, 0, 0, 252, 6, 0, 243, 59, 0, 0, 0, 96, 2, 0, 243, 59, 0, 0, 0, 88, 6, 64, 0, 0, 0, 0, 0, 104, 83, 17, 243, 59, 0, 0, 0, 104, 83, 17, 243, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 139, 0, 0, 0 };
                using (MemoryStream stream = new MemoryStream(byteblock))
                {
                    using (BinaryReader binaryReader = new BinaryReader(stream))
                    {
                        AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, false, null);
                        Assert.IsNotNull(block);
                        prePacketBlock = block as SimplePacketBlock;
                        Assert.IsNotNull(prePacketBlock);
                        byteblock = prePacketBlock.ConvertToByte(reorder, null);
                    }
                }
                using (MemoryStream stream = new MemoryStream(byteblock))
                {
                    using (BinaryReader binaryReader = new BinaryReader(stream))
                    {
                        AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, reorder, null);
                        Assert.IsNotNull(block);
                        postPacketBlock = block as SimplePacketBlock;
                        Assert.IsNotNull(postPacketBlock);

                        Assert.AreEqual(prePacketBlock.BlockType, postPacketBlock.BlockType);
                        Assert.AreEqual(prePacketBlock.Data, postPacketBlock.Data);
                    }
                }
            }
 public static void AbstractBlockFactory_ConvertTo_SimplePacketBlock_Test()
 {
     byte[] byteblock = { 3, 0, 0, 0, 139, 0, 0, 0, 123, 0, 0, 0, 104, 83, 17, 243, 59, 0, 0, 0, 151, 143, 0, 243, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 208, 241, 255, 191, 127, 0, 0, 0, 208, 79, 17, 243, 59, 0, 0, 0, 96, 5, 0, 243, 59, 0, 0, 0, 252, 6, 0, 243, 59, 0, 0, 0, 96, 2, 0, 243, 59, 0, 0, 0, 88, 6, 64, 0, 0, 0, 0, 0, 104, 83, 17, 243, 59, 0, 0, 0, 104, 83, 17, 243, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 139, 0, 0, 0 };
     using (MemoryStream stream = new MemoryStream(byteblock))
     {
         using (BinaryReader binaryReader = new BinaryReader(stream))
         {
             AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, false, null);
             Assert.IsNotNull(block);
             SimplePacketBlock packetBlock = block as SimplePacketBlock;
             Assert.IsNotNull(packetBlock);
             Assert.AreEqual(packetBlock.PacketLength, 123);
         }
     }
 }
            public static void NameResolutionBlock_ConvertToByte_Test(bool reorder)
            {
                byte[] option  = { 1, 0, 12, 0, 84, 101, 115, 116, 32, 67, 111, 109, 109, 101, 110, 116, 2, 0, 8, 0, 68, 110, 115, 32, 78, 97, 109, 101, 3, 0, 4, 0, 127, 0, 0, 1, 4, 0, 16, 0, 32, 1, 13, 219, 0, 0, 0, 0, 0, 0, 0, 0, 20, 40, 87, 171, 0, 0, 0, 0 };
                byte[] records = { 1, 0, 13, 0, 127, 0, 0, 1, 108, 111, 99, 97, 108, 104, 111, 115, 116, 0, 0, 0, 2, 0, 25, 0, 32, 1, 13, 219, 0, 0, 0, 0, 0, 0, 0, 0, 20, 40, 87, 171, 116, 101, 115, 116, 32, 97, 100, 100, 114, 0, 0, 0, 0, 0, 0, 0 };

                NameResolutionBlock prePacketBlock, postPacketBlock;

                using (MemoryStream optionStream = new MemoryStream(option))
                {
                    using (MemoryStream recordsStream = new MemoryStream(records))
                    {
                        using (BinaryReader optionBinaryReader = new BinaryReader(optionStream))
                        {
                            using (BinaryReader recordsBinaryReader = new BinaryReader(recordsStream))
                            {
                                NameResolutionRecord rec = NameResolutionRecord.Parse(recordsBinaryReader, false, null);
                                Assert.IsNotNull(rec);
                                NameResolutionOption opt = NameResolutionOption.Parse(optionBinaryReader, false, null);
                                Assert.IsNotNull(opt);
                                prePacketBlock = new NameResolutionBlock(rec, opt, 0);
                            }
                        }
                    }
                }
                Assert.IsNotNull(prePacketBlock);
                byte[] byteblock = prePacketBlock.ConvertToByte(reorder, null);
                using (MemoryStream stream = new MemoryStream(byteblock))
                {
                    using (BinaryReader binaryReader = new BinaryReader(stream))
                    {
                        AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, reorder, null);
                        Assert.IsNotNull(block);
                        postPacketBlock = block as NameResolutionBlock;
                        Assert.IsNotNull(postPacketBlock);

                        Assert.AreEqual(prePacketBlock.BlockType, postPacketBlock.BlockType);
                        Assert.AreEqual(prePacketBlock.NameResolutionRecords.Count, postPacketBlock.NameResolutionRecords.Count);
                        for (int i = 0; i < prePacketBlock.NameResolutionRecords.Count; i++)
                        {
                            Assert.AreEqual(prePacketBlock.NameResolutionRecords[i], postPacketBlock.NameResolutionRecords[i]);
                        }
                        Assert.AreEqual(prePacketBlock.Options.Comment, postPacketBlock.Options.Comment);
                        Assert.AreEqual(prePacketBlock.Options.DnsName, postPacketBlock.Options.DnsName);
                        Assert.AreEqual(prePacketBlock.Options.DnsIp4Addr, postPacketBlock.Options.DnsIp4Addr);
                        Assert.AreEqual(prePacketBlock.Options.DnsIp6Addr, postPacketBlock.Options.DnsIp6Addr);
                    }
                }
            }
示例#4
0
            public static void InterfaceDescriptionBlock_ConvertToByte_Test(bool reorder)
            {
                InterfaceDescriptionBlock prePacketBlock, postPacketBlock;

                byte[] byteblock = { 1, 0, 0, 0, 136, 0, 0, 0, 1, 0, 0, 0, 255, 255, 0, 0, 2, 0, 50, 0, 92, 68, 101, 118, 105, 99, 101, 92, 78, 80, 70, 95, 123, 68, 65, 51, 70, 56, 65, 55, 54, 45, 55, 49, 55, 69, 45, 52, 69, 65, 55, 45, 57, 69, 68, 53, 45, 48, 51, 57, 56, 68, 68, 69, 57, 67, 49, 55, 69, 125, 0, 0, 9, 0, 1, 0, 6, 0, 0, 0, 12, 0, 43, 0, 54, 52, 45, 98, 105, 116, 32, 87, 105, 110, 100, 111, 119, 115, 32, 55, 32, 83, 101, 114, 118, 105, 99, 101, 32, 80, 97, 99, 107, 32, 49, 44, 32, 98, 117, 105, 108, 100, 32, 55, 54, 48, 49, 0, 0, 0, 0, 0, 136, 0, 0, 0 };
                using (MemoryStream stream = new MemoryStream(byteblock))
                {
                    using (BinaryReader binaryReader = new BinaryReader(stream))
                    {
                        AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, false, null);
                        Assert.IsNotNull(block);
                        prePacketBlock = block as InterfaceDescriptionBlock;
                        Assert.IsNotNull(prePacketBlock);
                        byteblock = prePacketBlock.ConvertToByte(reorder, null);
                    }
                }
                using (MemoryStream stream = new MemoryStream(byteblock))
                {
                    using (BinaryReader binaryReader = new BinaryReader(stream))
                    {
                        AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, reorder, null);
                        Assert.IsNotNull(block);
                        postPacketBlock = block as InterfaceDescriptionBlock;
                        Assert.IsNotNull(postPacketBlock);

                        Assert.AreEqual(prePacketBlock.BlockType, postPacketBlock.BlockType);
                        Assert.AreEqual(prePacketBlock.LinkType, postPacketBlock.LinkType);
                        Assert.AreEqual(prePacketBlock.SnapLength, postPacketBlock.SnapLength);
                        Assert.AreEqual(prePacketBlock.PositionInStream, postPacketBlock.PositionInStream);

                        Assert.AreEqual(prePacketBlock.Options.Comment, postPacketBlock.Options.Comment);
                        Assert.AreEqual(prePacketBlock.Options.Description, postPacketBlock.Options.Description);
                        Assert.AreEqual(prePacketBlock.Options.EuiAddress, postPacketBlock.Options.EuiAddress);
                        Assert.AreEqual(prePacketBlock.Options.Filter, postPacketBlock.Options.Filter);
                        Assert.AreEqual(prePacketBlock.Options.FrameCheckSequence, postPacketBlock.Options.FrameCheckSequence);
                        Assert.AreEqual(prePacketBlock.Options.IPv4Address, postPacketBlock.Options.IPv4Address);
                        Assert.AreEqual(prePacketBlock.Options.IPv6Address, postPacketBlock.Options.IPv6Address);
                        Assert.AreEqual(prePacketBlock.Options.MacAddress, postPacketBlock.Options.MacAddress);
                        Assert.AreEqual(prePacketBlock.Options.Name, postPacketBlock.Options.Name);
                        Assert.AreEqual(prePacketBlock.Options.OperatingSystem, postPacketBlock.Options.OperatingSystem);
                        Assert.AreEqual(prePacketBlock.Options.Speed, postPacketBlock.Options.Speed);
                        Assert.AreEqual(prePacketBlock.Options.TimeOffsetSeconds, postPacketBlock.Options.TimeOffsetSeconds);
                        Assert.AreEqual(prePacketBlock.Options.TimestampResolution, postPacketBlock.Options.TimestampResolution);
                        Assert.AreEqual(prePacketBlock.Options.TimeZone, postPacketBlock.Options.TimeZone);
                    }
                }
            }
 public static void AbstractBlockFactory_ConvertTo_EnchantedPacketBlock_Test()
 {
     byte[] byteblock = { 6, 0, 0, 0, 132, 0, 0, 0, 0, 0, 0, 0, 12, 191, 4, 0, 118, 176, 176, 8, 98, 0, 0, 0, 98, 0, 0, 0, 0, 0, 94, 0, 1, 177, 0, 33, 40, 5, 41, 186, 8, 0, 69, 0, 0, 84, 48, 167, 0, 0, 255, 1, 3, 72, 192, 168, 177, 160, 10, 64, 11, 49, 8, 0, 10, 251, 67, 168, 0, 0, 79, 161, 27, 41, 0, 2, 83, 141, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 0, 132, 0, 0, 0 };
     using (MemoryStream stream = new MemoryStream(byteblock))
     {
         using (BinaryReader binaryReader = new BinaryReader(stream))
         {
             AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, false, null);
             Assert.IsNotNull(block);
             EnchantedPacketBlock packetBlock = block as EnchantedPacketBlock;
             Assert.IsNotNull(packetBlock);
             Assert.AreEqual(packetBlock.InterfaceID, 0);
             Assert.AreEqual(packetBlock.Seconds, 1335958313);
             Assert.AreEqual(packetBlock.Microseconds, 152630);
             Assert.IsTrue(true);
         }
     }
 }
 public static void AbstractBlockFactory_ConvertTo_PacketBlock_Test()
 {
     byte[] byteblock = { 2, 0, 0, 0, 167, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 0, 0, 0, 232, 3, 0, 0, 104, 83, 17, 243, 59, 0, 0, 0, 151, 143, 0, 243, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 208, 241, 255, 191, 127, 0, 0, 0, 208, 79, 17, 243, 59, 0, 0, 0, 96, 5, 0, 243, 59, 0, 0, 0, 252, 6, 0, 243, 59, 0, 0, 0, 96, 2, 0, 243, 59, 0, 0, 0, 88, 6, 64, 0, 0, 0, 0, 0, 104, 83, 17, 243, 59, 0, 0, 0, 104, 83, 17, 243, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 167, 0, 0, 0 };
     using (MemoryStream stream = new MemoryStream(byteblock))
     {
         using (BinaryReader binaryReader = new BinaryReader(stream))
         {
             AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, false, null);
             Assert.IsNotNull(block);
             PacketBlock packetBlock = block as PacketBlock;
             Assert.IsNotNull(packetBlock);
             Assert.AreEqual(packetBlock.PacketLength, 1000);
             Assert.AreEqual(packetBlock.CapturedLength, 123);
             Assert.AreEqual(packetBlock.InterfaceID, 0);
             Assert.AreEqual(packetBlock.Seconds, 0);
             Assert.AreEqual(packetBlock.Microseconds, 0);
         }
     }
 }
 public static void AbstractBlockFactory_ConvertTo_InterfaceDescriptionBlock_Test()
 {
     byte[] byteblock = { 1, 0, 0, 0, 136, 0, 0, 0, 1, 0, 0, 0, 255, 255, 0, 0, 2, 0, 50, 0, 92, 68, 101, 118, 105, 99, 101, 92, 78, 80, 70, 95, 123, 68, 65, 51, 70, 56, 65, 55, 54, 45, 55, 49, 55, 69, 45, 52, 69, 65, 55, 45, 57, 69, 68, 53, 45, 48, 51, 57, 56, 68, 68, 69, 57, 67, 49, 55, 69, 125, 0, 0, 9, 0, 1, 0, 6, 0, 0, 0, 12, 0, 43, 0, 54, 52, 45, 98, 105, 116, 32, 87, 105, 110, 100, 111, 119, 115, 32, 55, 32, 83, 101, 114, 118, 105, 99, 101, 32, 80, 97, 99, 107, 32, 49, 44, 32, 98, 117, 105, 108, 100, 32, 55, 54, 48, 49, 0, 0, 0, 0, 0, 136, 0, 0, 0 };
     using (MemoryStream stream = new MemoryStream(byteblock))
     {
         using (BinaryReader binaryReader = new BinaryReader(stream))
         {
             AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, false, null);
             Assert.IsNotNull(block);
             InterfaceDescriptionBlock interfaceBlock = block as InterfaceDescriptionBlock;
             Assert.IsNotNull(interfaceBlock);
             Assert.AreEqual(interfaceBlock.LinkType, LinkTypes.Ethernet);
             Assert.AreEqual(interfaceBlock.SnapLength, 65535);
             Assert.AreEqual(interfaceBlock.Options.OperatingSystem, "64-bit Windows 7 Service Pack 1, build 7601");
             Assert.AreEqual(interfaceBlock.Options.Name, @"\Device\NPF_{DA3F8A76-717E-4EA7-9ED5-0398DDE9C17E}");
             Assert.AreEqual(interfaceBlock.Options.TimestampResolution, 6);
         }
     }
 }
 public static void AbstractBlockFactory_ConvertTo_SectionHeaderBlock_Test()
 {
     byte[] byteblock = { 10, 13, 13, 10, 136, 0, 0, 0, 77, 60, 43, 26, 1, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 3, 0, 43, 0, 54, 52, 45, 98, 105, 116, 32, 87, 105, 110, 100, 111, 119, 115, 32, 55, 32, 83, 101, 114, 118, 105, 99, 101, 32, 80, 97, 99, 107, 32, 49, 44, 32, 98, 117, 105, 108, 100, 32, 55, 54, 48, 49, 0, 4, 0, 52, 0, 68, 117, 109, 112, 99, 97, 112, 32, 49, 46, 49, 48, 46, 55, 32, 40, 118, 49, 46, 49, 48, 46, 55, 45, 48, 45, 103, 54, 98, 57, 51, 49, 97, 49, 32, 102, 114, 111, 109, 32, 109, 97, 115, 116, 101, 114, 45, 49, 46, 49, 48, 41, 0, 0, 0, 0, 136, 0, 0, 0 };
     using (MemoryStream stream = new MemoryStream(byteblock))
     {
         using (BinaryReader binaryReader = new BinaryReader(stream))
         {
             AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, false, null);
             Assert.IsNotNull(block);
             SectionHeaderBlock headerBlock = block as SectionHeaderBlock;
             Assert.IsNotNull(headerBlock);
             Assert.AreEqual(headerBlock.MagicNumber, SectionHeaderBlock.MagicNumbers.Identical);
             Assert.AreEqual(headerBlock.SectionLength, -1);
             Assert.AreEqual(headerBlock.MajorVersion, 1);
             Assert.AreEqual(headerBlock.MinorVersion, 0);
             Assert.AreEqual(headerBlock.Options.OperatingSystem, "64-bit Windows 7 Service Pack 1, build 7601");
             Assert.AreEqual(headerBlock.Options.UserApplication, "Dumpcap 1.10.7 (v1.10.7-0-g6b931a1 from master-1.10)");
         }
     }
 }
示例#9
0
            public static void PacketBlock_ConvertToByte_Test(bool reorder)
            {
                PacketBlock prePacketBlock, postPacketBlock;

                byte[] byteblock = { 2, 0, 0, 0, 167, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123, 0, 0, 0, 232, 3, 0, 0, 104, 83, 17, 243, 59, 0, 0, 0, 151, 143, 0, 243, 59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 208, 241, 255, 191, 127, 0, 0, 0, 208, 79, 17, 243, 59, 0, 0, 0, 96, 5, 0, 243, 59, 0, 0, 0, 252, 6, 0, 243, 59, 0, 0, 0, 96, 2, 0, 243, 59, 0, 0, 0, 88, 6, 64, 0, 0, 0, 0, 0, 104, 83, 17, 243, 59, 0, 0, 0, 104, 83, 17, 243, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 167, 0, 0, 0 };
                using (MemoryStream stream = new MemoryStream(byteblock))
                {
                    using (BinaryReader binaryReader = new BinaryReader(stream))
                    {
                        AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, false, null);
                        Assert.IsNotNull(block);
                        prePacketBlock = block as PacketBlock;
                        Assert.IsNotNull(prePacketBlock);
                        byteblock = prePacketBlock.ConvertToByte(reorder, null);
                    }
                }
                using (MemoryStream stream = new MemoryStream(byteblock))
                {
                    using (BinaryReader binaryReader = new BinaryReader(stream))
                    {
                        AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, reorder, null);
                        Assert.IsNotNull(block);
                        postPacketBlock = block as PacketBlock;
                        Assert.IsNotNull(postPacketBlock);

                        Assert.AreEqual(prePacketBlock.BlockType, postPacketBlock.BlockType);
                        Assert.AreEqual(prePacketBlock.Data, postPacketBlock.Data);
                        Assert.AreEqual(prePacketBlock.InterfaceID, postPacketBlock.InterfaceID);
                        Assert.AreEqual(prePacketBlock.DropCount, postPacketBlock.DropCount);
                        Assert.AreEqual(prePacketBlock.Microseconds, postPacketBlock.Microseconds);
                        Assert.AreEqual(prePacketBlock.PacketLength, postPacketBlock.PacketLength);
                        Assert.AreEqual(prePacketBlock.PositionInStream, postPacketBlock.PositionInStream);
                        Assert.AreEqual(prePacketBlock.Seconds, postPacketBlock.Seconds);
                        Assert.AreEqual(prePacketBlock.Options.Comment, postPacketBlock.Options.Comment);
                        Assert.AreEqual(prePacketBlock.Options.Hash, postPacketBlock.Options.Hash);
                        Assert.AreEqual(prePacketBlock.Options.PacketFlag, postPacketBlock.Options.PacketFlag);
                    }
                }
            }
示例#10
0
            public static void InterfaceStatisticsBlock_ConvertToByte_Test(bool reorder)
            {
                InterfaceStatisticsBlock preStatisticBlock, postStatisticBlock;

                byte[] byteblock = { 5, 0, 0, 0, 108, 0, 0, 0, 1, 0, 0, 0, 34, 18, 5, 0, 87, 234, 56, 202, 1, 0, 28, 0, 67, 111, 117, 110, 116, 101, 114, 115, 32, 112, 114, 111, 118, 105, 100, 101, 100, 32, 98, 121, 32, 100, 117, 109, 112, 99, 97, 112, 2, 0, 8, 0, 34, 18, 5, 0, 36, 137, 18, 202, 3, 0, 8, 0, 34, 18, 5, 0, 87, 234, 56, 202, 4, 0, 8, 0, 56, 0, 0, 0, 0, 0, 0, 0, 5, 0, 8, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 0, 0, 0 };
                using (MemoryStream stream = new MemoryStream(byteblock))
                {
                    using (BinaryReader binaryReader = new BinaryReader(stream))
                    {
                        AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, false, null);
                        Assert.IsNotNull(block);
                        preStatisticBlock = block as InterfaceStatisticsBlock;
                        Assert.IsNotNull(preStatisticBlock);
                        byteblock = preStatisticBlock.ConvertToByte(reorder, null);
                    }
                }
                using (MemoryStream stream = new MemoryStream(byteblock))
                {
                    using (BinaryReader binaryReader = new BinaryReader(stream))
                    {
                        AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, reorder, null);
                        Assert.IsNotNull(block);
                        postStatisticBlock = block as InterfaceStatisticsBlock;
                        Assert.IsNotNull(postStatisticBlock);

                        Assert.AreEqual(preStatisticBlock.BlockType, postStatisticBlock.BlockType);
                        Assert.AreEqual(preStatisticBlock.InterfaceID, postStatisticBlock.InterfaceID);
                        Assert.AreEqual(preStatisticBlock.Timestamp, postStatisticBlock.Timestamp);
                        Assert.AreEqual(preStatisticBlock.Options.Comment, postStatisticBlock.Options.Comment);
                        Assert.AreEqual(preStatisticBlock.Options.DeliveredToUser, postStatisticBlock.Options.DeliveredToUser);
                        Assert.AreEqual(preStatisticBlock.Options.EndTime, postStatisticBlock.Options.EndTime);
                        Assert.AreEqual(preStatisticBlock.Options.StartTime, postStatisticBlock.Options.StartTime);
                        Assert.AreEqual(preStatisticBlock.Options.FilterAccept, postStatisticBlock.Options.FilterAccept);
                        Assert.AreEqual(preStatisticBlock.Options.InterfaceDrop, postStatisticBlock.Options.InterfaceDrop);
                        Assert.AreEqual(preStatisticBlock.Options.InterfaceReceived, postStatisticBlock.Options.InterfaceReceived);
                        Assert.AreEqual(preStatisticBlock.Options.SystemDrop, postStatisticBlock.Options.SystemDrop);
                    }
                }
            }
示例#11
0
            public static void EnchantedPacketBlock_ConvertToByte_Test(bool reorder)
            {
                EnchantedPacketBlock prePacketBlock, postPacketBlock;

                byte[] byteblock = { 6, 0, 0, 0, 132, 0, 0, 0, 0, 0, 0, 0, 12, 191, 4, 0, 118, 176, 176, 8, 98, 0, 0, 0, 98, 0, 0, 0, 0, 0, 94, 0, 1, 177, 0, 33, 40, 5, 41, 186, 8, 0, 69, 0, 0, 84, 48, 167, 0, 0, 255, 1, 3, 72, 192, 168, 177, 160, 10, 64, 11, 49, 8, 0, 10, 251, 67, 168, 0, 0, 79, 161, 27, 41, 0, 2, 83, 141, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 0, 0, 132, 0, 0, 0 };
                using (MemoryStream stream = new MemoryStream(byteblock))
                {
                    using (BinaryReader binaryReader = new BinaryReader(stream))
                    {
                        AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, false, null);
                        Assert.IsNotNull(block);
                        prePacketBlock = block as EnchantedPacketBlock;
                        Assert.IsNotNull(prePacketBlock);
                        byteblock = prePacketBlock.ConvertToByte(reorder, null);
                    }
                }
                using (MemoryStream stream = new MemoryStream(byteblock))
                {
                    using (BinaryReader binaryReader = new BinaryReader(stream))
                    {
                        AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, reorder, null);
                        Assert.IsNotNull(block);
                        postPacketBlock = block as EnchantedPacketBlock;
                        Assert.IsNotNull(postPacketBlock);

                        Assert.AreEqual(prePacketBlock.BlockType, postPacketBlock.BlockType);
                        Assert.AreEqual(prePacketBlock.Data, postPacketBlock.Data);
                        Assert.AreEqual(prePacketBlock.InterfaceID, postPacketBlock.InterfaceID);
                        Assert.AreEqual(prePacketBlock.Microseconds, postPacketBlock.Microseconds);
                        Assert.AreEqual(prePacketBlock.PacketLength, postPacketBlock.PacketLength);
                        Assert.AreEqual(prePacketBlock.PositionInStream, postPacketBlock.PositionInStream);
                        Assert.AreEqual(prePacketBlock.Seconds, postPacketBlock.Seconds);
                        Assert.AreEqual(prePacketBlock.Options.Comment, postPacketBlock.Options.Comment);
                        Assert.AreEqual(prePacketBlock.Options.DropCount, postPacketBlock.Options.DropCount);
                        Assert.AreEqual(prePacketBlock.Options.Hash, postPacketBlock.Options.Hash);
                        Assert.AreEqual(prePacketBlock.Options.PacketFlag, postPacketBlock.Options.PacketFlag);
                    }
                }
            }
示例#12
0
            public static void SectionHeaderBlock_ConvertToByte_Test(bool reorder)
            {
                SectionHeaderBlock prePacketBlock, postPacketBlock;

                byte[] byteblock = { 10, 13, 13, 10, 136, 0, 0, 0, 77, 60, 43, 26, 1, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 3, 0, 43, 0, 54, 52, 45, 98, 105, 116, 32, 87, 105, 110, 100, 111, 119, 115, 32, 55, 32, 83, 101, 114, 118, 105, 99, 101, 32, 80, 97, 99, 107, 32, 49, 44, 32, 98, 117, 105, 108, 100, 32, 55, 54, 48, 49, 0, 4, 0, 52, 0, 68, 117, 109, 112, 99, 97, 112, 32, 49, 46, 49, 48, 46, 55, 32, 40, 118, 49, 46, 49, 48, 46, 55, 45, 48, 45, 103, 54, 98, 57, 51, 49, 97, 49, 32, 102, 114, 111, 109, 32, 109, 97, 115, 116, 101, 114, 45, 49, 46, 49, 48, 41, 0, 0, 0, 0, 136, 0, 0, 0 };
                using (MemoryStream stream = new MemoryStream(byteblock))
                {
                    using (BinaryReader binaryReader = new BinaryReader(stream))
                    {
                        AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, false, null);
                        Assert.IsNotNull(block);
                        prePacketBlock = block as SectionHeaderBlock;
                        Assert.IsNotNull(prePacketBlock);
                        byteblock = prePacketBlock.ConvertToByte(reorder, null);
                    }
                }
                using (MemoryStream stream = new MemoryStream(byteblock))
                {
                    using (BinaryReader binaryReader = new BinaryReader(stream))
                    {
                        AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, reorder, null);
                        Assert.IsNotNull(block);
                        postPacketBlock = block as SectionHeaderBlock;
                        Assert.IsNotNull(postPacketBlock);

                        Assert.AreEqual(prePacketBlock.BlockType, postPacketBlock.BlockType);
                        Assert.AreEqual(prePacketBlock.MagicNumber, postPacketBlock.MagicNumber);
                        Assert.AreEqual(prePacketBlock.MajorVersion, postPacketBlock.MajorVersion);
                        Assert.AreEqual(prePacketBlock.MinorVersion, postPacketBlock.MinorVersion);
                        Assert.AreEqual(prePacketBlock.SectionLength, postPacketBlock.SectionLength);
                        Assert.AreEqual(prePacketBlock.PositionInStream, postPacketBlock.PositionInStream);
                        Assert.AreEqual(prePacketBlock.Options.Comment, postPacketBlock.Options.Comment);
                        Assert.AreEqual(prePacketBlock.Options.Hardware, postPacketBlock.Options.Hardware);
                        Assert.AreEqual(prePacketBlock.Options.OperatingSystem, postPacketBlock.Options.OperatingSystem);
                        Assert.AreEqual(prePacketBlock.Options.UserApplication, postPacketBlock.Options.UserApplication);
                    }
                }
            }
示例#13
0
 public static void AbstractBlockFactory_ConvertTo_InterfaceStatisticBlock_Test()
 {
     byte[] byteblock = { 5, 0, 0, 0, 108, 0, 0, 0, 1, 0, 0, 0, 34, 18, 5, 0, 87, 234, 56, 202, 1, 0, 28, 0, 67, 111, 117, 110, 116, 101, 114, 115, 32, 112, 114, 111, 118, 105, 100, 101, 100, 32, 98, 121, 32, 100, 117, 109, 112, 99, 97, 112, 2, 0, 8, 0, 34, 18, 5, 0, 36, 137, 18, 202, 3, 0, 8, 0, 34, 18, 5, 0, 87, 234, 56, 202, 4, 0, 8, 0, 56, 0, 0, 0, 0, 0, 0, 0, 5, 0, 8, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 0, 0, 0 };
     using (MemoryStream stream = new MemoryStream(byteblock))
     {
         using (BinaryReader binaryReader = new BinaryReader(stream))
         {
             AbstractBlock block = AbstractBlockFactory.ReadNextBlock(binaryReader, false, null);
             Assert.IsNotNull(block);
             InterfaceStatisticsBlock interfaceBlock = block as InterfaceStatisticsBlock;
             Assert.IsNotNull(interfaceBlock);
             Assert.AreEqual(interfaceBlock.InterfaceID, 1);
             Assert.AreEqual(interfaceBlock.Timestamp.Seconds, 1427315514);
             Assert.AreEqual(interfaceBlock.Timestamp.Microseconds, 468951);
             Assert.AreEqual(interfaceBlock.Options.Comment, "Counters provided by dumpcap");
             Assert.AreEqual(interfaceBlock.Options.InterfaceDrop, 1);
             Assert.AreEqual(interfaceBlock.Options.InterfaceReceived, 56);
             Assert.AreEqual(interfaceBlock.Options.StartTime.Seconds, 1427315511);
             Assert.AreEqual(interfaceBlock.Options.StartTime.Microseconds, 953700);
             Assert.AreEqual(interfaceBlock.Options.EndTime.Seconds, 1427315514);
             Assert.AreEqual(interfaceBlock.Options.EndTime.Microseconds, 468951);
         }
     }
 }