コード例 #1
0
 private void HandleFailure(Variable failure)
 {
     var defaultPair = DefaultPrivacyProvider.DefaultPair;
     var time = Group.EngineTimeData;
     Response = new ReportMessage(
         Request.Version,
         new Header(
             new Integer32(Request.MessageId()),
             new Integer32(Messenger.MaxMessageSize),
             0), // no need to encrypt.
         new SecurityParameters(
             Group.EngineId,
             new Integer32(time[0]),
             new Integer32(time[1]),
             Request.Parameters.UserName,
             defaultPair.AuthenticationProvider.CleanDigest,
             defaultPair.Salt),
         new Scope(
             Group.EngineId,
             OctetString.Empty,
             new ReportPdu(
                 Request.RequestId(),
                 ErrorCode.NoError,
                 0,
                 new List<Variable>(1) { failure })),
         defaultPair,
         null);
     if (TooBig)
     {
         GenerateTooBig();
     }
 }
コード例 #2
0
ファイル: Discoverer.cs プロジェクト: agluque62/svn-dev_TFT
        private void HandleMessage(MessageParams param)
        {
            foreach (ISnmpMessage message in MessageFactory.ParseMessages(param.GetBytes(), 0, param.Number, Empty))
            {
                EventHandler <AgentFoundEventArgs> handler;
                var code = message.TypeCode();
                if (code == SnmpType.ReportPdu)
                {
                    ReportMessage report = (ReportMessage)message;
                    if (report.RequestId() != _requestId)
                    {
                        continue;
                    }

                    if (report.Pdu().ErrorStatus.ToErrorCode() != ErrorCode.NoError)
                    {
                        continue;
                    }

                    handler = AgentFound;
                    if (handler != null)
                    {
                        handler(this, new AgentFoundEventArgs(param.Sender, null));
                    }
                }

                if (code != SnmpType.ResponsePdu)
                {
                    continue;
                }

                ResponseMessage response = (ResponseMessage)message;
                if (response.RequestId() != _requestId)
                {
                    continue;
                }

                if (response.ErrorStatus != ErrorCode.NoError)
                {
                    continue;
                }

                handler = AgentFound;
                if (handler != null)
                {
                    handler(this, new AgentFoundEventArgs(param.Sender, response.Variables()[0]));
                }
            }
        }
コード例 #3
0
 private void HandleDiscovery()
 {         
     // discovery message received.
     var time = Group.EngineTimeData;
     Response = new ReportMessage(
         VersionCode.V3,
         new Header(
             new Integer32(Request.MessageId()),
             new Integer32(Messenger.MaxMessageSize),
             0), // no need to encrypt for discovery.
         new SecurityParameters(
             Group.EngineId,
             TimeIncluded ? new Integer32(time[0]) : Integer32.Zero,
             TimeIncluded ? new Integer32(time[1]) : Integer32.Zero,
             OctetString.Empty,
             OctetString.Empty,
             OctetString.Empty),
         new Scope(
             Group.EngineId,
             OctetString.Empty,
             new ReportPdu(
                 Request.RequestId(),
                 ErrorCode.NoError,
                 0,
                 new List<Variable>(1) { Group.UnknownEngineId })),
         DefaultPrivacyProvider.DefaultPair,
         null);
     if (TooBig)
     {
         GenerateTooBig();
     }
 }
コード例 #4
0
 private void HandleDiscovery()
 {
     Group.ReportCount++;
     
     // discovery message received.
     Response = new ReportMessage(
         VersionCode.V3,
         new Header(
             new Integer32(Request.MessageId()),
             new Integer32(Messenger.MaxMessageSize),
             0), // no need to encrypt for discovery.
         new SecurityParameters(
             Group.EngineId,
             Integer32.Zero,
             new Integer32(Environment.TickCount),
             OctetString.Empty,
             OctetString.Empty,
             OctetString.Empty),
         new Scope(
             Group.EngineId,
             OctetString.Empty,
             new ReportPdu(
                 Request.RequestId(),
                 ErrorCode.NoError,
                 0,
                 new List<Variable>(1)
                     {
                         new Variable(
                             ReportId,
                             new Counter32(Group.ReportCount))
                     })),
         DefaultPrivacyProvider.DefaultPair,
         null);
     if (TooBig)
     {
         GenerateTooBig();
     }
 }
コード例 #5
0
 private void HandleDiscovery()
 {         
     // discovery message received.
     // TODO: pick up time information from Group instead of using raw data.
     Response = new ReportMessage(
         VersionCode.V3,
         new Header(
             new Integer32(Request.MessageId()),
             new Integer32(Messenger.MaxMessageSize),
             0), // no need to encrypt for discovery.
         new SecurityParameters(
             Group.EngineId,
             TimeIncluded ? Integer32.Zero : Integer32.Zero,
             TimeIncluded ? new Integer32(Environment.TickCount) : Integer32.Zero,
             OctetString.Empty,
             OctetString.Empty,
             OctetString.Empty),
         new Scope(
             Group.EngineId,
             OctetString.Empty,
             new ReportPdu(
                 Request.RequestId(),
                 ErrorCode.NoError,
                 0,
                 new List<Variable>(1) { Group.UnknownEngineID })),
         DefaultPrivacyProvider.DefaultPair,
         null);
     if (TooBig)
     {
         GenerateTooBig();
     }
 }
コード例 #6
0
 public void TestConstructorV3Auth1()
 {
     const string bytes = "30 73" +
                          "02 01  03 " +
                          "30 0F " +
                          "02  02 35 41 " +
                          "02  03 00 FF E3" +
                          "04 01 05" +
                          "02  01 03" +
                          "04 2E  " +
                          "30 2C" +
                          "04 0D  80 00 1F 88 80 E9 63 00  00 D6 1F F4  49 " +
                          "02 01 0D  " +
                          "02 01 57 " +
                          "04 05 6C 65 78  6C 69 " +
                          "04 0C  1C 6D 67 BF  B2 38 ED 63 DF 0A 05 24  " +
                          "04 00 " +
                          "30 2D  " +
                          "04 0D 80 00  1F 88 80 E9 63 00 00 D6  1F F4 49 " +
                          "04  00 " +
                          "A0 1A 02  02 01 AF 02 01 00 02 01  00 30 0E 30  0C 06 08 2B  06 01 02 01 01 03 00 05  00";
     ReportMessage report = new ReportMessage(
         VersionCode.V3,
         new Header(
             new Integer32(13633),
             new Integer32(0xFFE3),
             new OctetString(new byte[] { 0x0 }),
             new Integer32(3)),
         new SecurityParameters(
             new OctetString(ByteTool.Convert("80 00 1F 88 80 E9 63 00  00 D6 1F F4  49")),
             new Integer32(0x0d),
             new Integer32(0x57),
             new OctetString("lexli"),
             new OctetString(new byte[12]),
             OctetString.Empty),
         new Scope(
             new OctetString(ByteTool.Convert("80 00 1F 88 80 E9 63 00  00 D6 1F F4  49")),
             OctetString.Empty,
             new ReportPdu(
                 0x01AF,
                 ErrorCode.NoError,
                 0,
                 new List<Variable>(1) { new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.3.0")) })),
         DefaultPrivacyProvider.DefaultPair);
     
     IPrivacyProvider privacy = new DefaultPrivacyProvider(new MD5AuthenticationProvider(new OctetString("testpass")));
     GetRequestMessage request = new GetRequestMessage(
         VersionCode.V3,
         13633,
         0x01AF,
         new OctetString("lexli"),
         new List<Variable>(1) { new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.3.0")) },
         privacy,
         Messenger.MaxMessageSize,
         report);
     
     Assert.AreEqual(Levels.Authentication, request.Level);
     Assert.AreEqual(ByteTool.Convert(bytes), request.ToBytes());
 }
コード例 #7
0
 private void HandleDiscovery()
 {
     Group.ReportCount++;
     
     // discovery message received.
     Response = new ReportMessage(
         VersionCode.V3,
         new Header(
             new Integer32(Request.MessageId),
             new Integer32(Messenger.MaxMessageSize),
             new OctetString(new[] { (byte)Levels.Reportable }),
             new Integer32(3)),
         new SecurityParameters(
             Group.EngineId,
             new Integer32(0),
             new Integer32(Environment.TickCount),
             OctetString.Empty,
             OctetString.Empty,
             OctetString.Empty),
         new Scope(
             Group.EngineId,
             OctetString.Empty,
             new ReportPdu(
                 Request.RequestId,
                 ErrorCode.NoError,
                 0,
                 new List<Variable>(1)
                     {
                         new Variable(
                             new ObjectIdentifier("1.3.6.1.6.3.15.1.1.4.0"),
                             new Counter32(Group.ReportCount))
                     })),
         DefaultPrivacyProvider.DefaultPair);
     if (TooBig)
     {
         GenerateTooBig();
     }
 }