예제 #1
0
        public void ParseSnmResponse2()
        {
            var packetVersion = SnmpPacket.GetProtocolVersion(Packet2, Packet2.Length);

            Assert.Equal(ESnmpVersion.Ver1, packetVersion);

            var packet = new SnmpV1Packet();

            packet.Decode(Packet2, Packet2.Length);

            Assert.Equal("public", packet.Community.ToString());

            Assert.False(packet.IsRequest);
            Assert.True(packet.IsResponse);

            Assert.Equal(38, packet.Pdu.RequestId);
            Assert.Equal(EPduErrorStatus.NoError, packet.Pdu.ErrorStatus);
            Assert.Equal(0, packet.Pdu.ErrorIndex);

            Assert.Equal(1, packet.Pdu.VbCount);

            var vb = packet.Pdu.GetVb(0);

            Assert.NotNull(vb);

            Assert.Equal(new Oid("1.3.6.1.2.1.1.2.0"), vb.Oid);
            Assert.Equal((byte)(EAsnType.Constructor | EAsnType.Sequence), vb.Type);
            Assert.Equal((byte)EAsnType.ObjectId, vb.Value.Type);
            Assert.Equal(new Oid("1.3.6.1.4.1.2001.1.1.1.297.93.1.27.2.2.1"), vb.Value);
        }
예제 #2
0
        public void ParseSnmpGet1()
        {
            var packetVersion = SnmpPacket.GetProtocolVersion(Packet1, Packet1.Length);

            Assert.Equal(ESnmpVersion.Ver1, packetVersion);

            var packet = new SnmpV1Packet();

            packet.Decode(Packet1, Packet1.Length);

            Assert.Equal("public", packet.Community.ToString());

            Assert.True(packet.IsRequest);
            Assert.False(packet.IsResponse);

            Assert.Equal(38, packet.Pdu.RequestId);
            Assert.Equal(EPduErrorStatus.NoError, packet.Pdu.ErrorStatus);
            Assert.Equal(0, packet.Pdu.ErrorIndex);

            Assert.Equal(1, packet.Pdu.VbCount);

            var vb = packet.Pdu.GetVb(0);

            Assert.NotNull(vb);

            Assert.Equal(new Oid("1.3.6.1.2.1.1.2.0"), vb.Oid);
        }
예제 #3
0
        public void ParseSnmpGet7()
        {
            var packetVersion = SnmpPacket.GetProtocolVersion(Packet7, Packet7.Length);

            Assert.Equal(ESnmpVersion.Ver1, packetVersion);

            var packet = new SnmpV1Packet();

            packet.Decode(Packet7, Packet7.Length);

            Assert.Equal("public", packet.Community.ToString());

            Assert.True(packet.IsRequest);
            Assert.False(packet.IsResponse);

            Assert.Equal(41, packet.Pdu.RequestId);
            Assert.Equal(EPduErrorStatus.NoError, packet.Pdu.ErrorStatus);
            Assert.Equal(0, packet.Pdu.ErrorIndex);

            Assert.Equal(3, packet.Pdu.VbCount);

            var vb = packet.Pdu.GetVb(0);

            Assert.NotNull(vb);
            Assert.Equal(new Oid("1.3.6.1.4.1.253.8.64.4.2.1.7.10.14130104"), vb.Oid);

            vb = packet.Pdu.GetVb(1);
            Assert.NotNull(vb);
            Assert.Equal(new Oid("1.3.6.1.4.1.253.8.64.4.2.1.7.10.14130102"), vb.Oid);

            vb = packet.Pdu.GetVb(2);
            Assert.NotNull(vb);
            Assert.Equal(new Oid("1.3.6.1.4.1.253.8.64.4.2.1.5.10.14130400"), vb.Oid);
        }
예제 #4
0
        public void ParseSnmpResponse8()
        {
            var packetVersion = SnmpPacket.GetProtocolVersion(Packet8, Packet8.Length);

            Assert.Equal(ESnmpVersion.Ver1, packetVersion);

            var packet = new SnmpV1Packet();

            packet.Decode(Packet8, Packet8.Length);

            Assert.Equal("public", packet.Community.ToString());

            Assert.False(packet.IsRequest);
            Assert.True(packet.IsResponse);

            Assert.Equal(41, packet.Pdu.RequestId);
            Assert.Equal(EPduErrorStatus.NoError, packet.Pdu.ErrorStatus);
            Assert.Equal(0, packet.Pdu.ErrorIndex);

            Assert.Equal(3, packet.Pdu.VbCount);

            var vb = packet.Pdu.GetVb(0);

            Assert.NotNull(vb);
            Assert.Equal(new Oid("1.3.6.1.4.1.253.8.64.4.2.1.7.10.14130104"), vb.Oid);
            Assert.Equal((byte)EAsnType.OctetString, vb.Value.Type);
            Assert.Equal(new byte[] { 0x31, 0x37, 0x32, 0x2e, 0x33, 0x31, 0x2e, 0x31, 0x39, 0x2e, 0x32 }, vb.Value as OctetString);

            vb = packet.Pdu.GetVb(1);
            Assert.NotNull(vb);
            Assert.Equal(new Oid("1.3.6.1.4.1.253.8.64.4.2.1.7.10.14130102"), vb.Oid);
            Assert.Equal((byte)EAsnType.OctetString, vb.Value.Type);
            Assert.Equal(new byte[] { 0x32, 0x35, 0x35, 0x2e, 0x32, 0x35, 0x35, 0x2e, 0x32, 0x35, 0x35, 0x2e, 0x30 }, vb.Value as OctetString);

            vb = packet.Pdu.GetVb(2);
            Assert.NotNull(vb);
            Assert.Equal(new Oid("1.3.6.1.4.1.253.8.64.4.2.1.5.10.14130400"), vb.Oid);
            Assert.Equal((byte)EAsnType.Integer, vb.Value.Type);
            Assert.Equal(1, vb.Value as Integer32);
        }