public TrapV2Pdu(Tuple <int, byte[]> length, Stream stream)
        {
            if (length == null)
            {
                throw new ArgumentNullException("length");
            }

            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            RequestId = (Integer32)DataFactory.CreateSnmpData(stream);              // request
#pragma warning disable 168
            var temp1 = (Integer32)DataFactory.CreateSnmpData(stream);              // 0
            var temp2 = (Integer32)DataFactory.CreateSnmpData(stream);              // 0
#pragma warning restore 168
            _varbindSection = (Sequence)DataFactory.CreateSnmpData(stream);
            Variables       = Variable.Transform(_varbindSection);        // v[0] is timestamp. v[1] oid, v[2] value.
            _time           = (TimeTicks)Variables[0].Data;
            Variables.RemoveAt(0);
            Enterprise = (ObjectIdentifier)Variables[0].Data;
            Variables.RemoveAt(0);
            _length = length.Item2;
        }
예제 #2
0
 public TrapV2Pdu(int requestId, ObjectIdentifier enterprise, uint time, IList <Variable> variables)
 {
     Enterprise      = enterprise ?? throw new ArgumentNullException(nameof(enterprise));
     RequestId       = new Integer32(requestId);
     _time           = new TimeTicks(time);
     Variables       = variables ?? throw new ArgumentNullException(nameof(variables));
     _varbindSection = Variable.Transform(Decorate(variables));
 }
예제 #3
0
 /// <summary>
 /// Creates a <see cref="InformRequestPdu"/> instance for discovery.
 /// </summary>
 /// <param name="requestId">The request id.</param>
 public InformRequestPdu(int requestId)
 {
     Enterprise      = null;
     RequestId       = new Integer32(requestId);
     _time           = new TimeTicks(0);
     Variables       = new List <Variable>();
     _varbindSection = Variable.Transform(Variables);
 }
예제 #4
0
        public TrapV2Pdu(int requestId, ObjectIdentifier enterprise, uint time, IList <Variable> variables)
        {
            Enterprise = enterprise;
            RequestId  = new Integer32(requestId);
            _time      = new TimeTicks(time);
            Variables  = variables;
            IList <Variable> full = new List <Variable>(variables);

            full.Insert(0, new Variable(new uint[] { 1, 3, 6, 1, 2, 1, 1, 3, 0 }, _time));
            full.Insert(1, new Variable(new uint[] { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 }, Enterprise));
            _varbindSection = Variable.Transform(full);
        }
        public InformRequestPdu(int requestId, ObjectIdentifier enterprise, uint time, IList <Variable> variables)
        {
            Enterprise = enterprise;
            RequestId  = new Integer32(requestId);
            _time      = new TimeTicks(time);
            Variables  = variables;
            IList <Variable> full = new List <Variable>(variables);

            full.Insert(0, new Variable(new uint[] { 1, 3, 6, 1, 2, 1, 1, 3, 0 }, _time));
            full.Insert(1, new Variable(new uint[] { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 }, Enterprise));
            _varbindSection = Variable.Transform(full);
            ////_raw = ByteTool.ParseItems(_seq, new Integer32(0), new Integer32(0), _varbindSection);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="InformRequestPdu"/> class.
 /// </summary>
 /// <param name="stream">The stream.</param>
 public InformRequestPdu(Stream stream)
 {
     RequestId       = (Integer32)DataFactory.CreateSnmpData(stream);
     ErrorStatus     = (Integer32)DataFactory.CreateSnmpData(stream);
     ErrorIndex      = (Integer32)DataFactory.CreateSnmpData(stream);
     _varbindSection = (Sequence)DataFactory.CreateSnmpData(stream);
     Variables       = Variable.Transform(_varbindSection);
     _time           = (TimeTicks)Variables[0].Data;
     Variables.RemoveAt(0);
     Enterprise = (ObjectIdentifier)Variables[0].Data;
     Variables.RemoveAt(0);
     ////_raw = ByteTool.ParseItems(_seq, _errorStatus, _errorIndex, _varbindSection);
     ////Debug.Assert(length >= _raw.Length, "length not match");
 }
예제 #7
0
        public InformRequestPdu(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            RequestId = (Integer32)DataFactory.CreateSnmpData(stream);
#pragma warning disable 168
            var temp1 = (Integer32)DataFactory.CreateSnmpData(stream); // 0
            var temp2 = (Integer32)DataFactory.CreateSnmpData(stream); // 0
#pragma warning restore 168
            _varbindSection = (Sequence)DataFactory.CreateSnmpData(stream);
            Variables       = Variable.Transform(_varbindSection);
            _time           = (TimeTicks)Variables[0].Data;
            Variables.RemoveAt(0);
            Enterprise = (ObjectIdentifier)Variables[0].Data;
            Variables.RemoveAt(0);
        }
예제 #8
0
        /// <summary>
        /// Creates a <see cref="TrapV1Pdu"/> instance with PDU elements.
        /// </summary>
        /// <param name="enterprise">Enterprise</param>
        /// <param name="agent">Agent address</param>
        /// <param name="generic">Generic trap type</param>
        /// <param name="specific">Specific trap type</param>
        /// <param name="timestamp">Time stamp</param>
        /// <param name="variables">Variable binds</param>
        public TrapV1Pdu(ObjectIdentifier enterprise, IP agent, Integer32 generic, Integer32 specific, TimeTicks timestamp, IList <Variable> variables)
        {
            if (enterprise == null)
            {
                throw new ArgumentNullException("enterprise");
            }

            if (agent == null)
            {
                throw new ArgumentNullException("agent");
            }

            if (generic == null)
            {
                throw new ArgumentNullException("generic");
            }

            if (specific == null)
            {
                throw new ArgumentNullException("specific");
            }

            if (timestamp == null)
            {
                throw new ArgumentNullException("timestamp");
            }

            if (variables == null)
            {
                throw new ArgumentNullException("variables");
            }

            Enterprise      = enterprise;
            AgentAddress    = agent;
            _generic        = generic;
            _specific       = specific;
            TimeStamp       = timestamp;
            _varbindSection = Variable.Transform(variables);
            Variables       = variables;
        }
        public TrapV2Pdu(int requestId, ObjectIdentifier enterprise, uint time, IList <Variable> variables)
        {
            if (enterprise == null)
            {
                throw new ArgumentNullException("enterprise");
            }

            if (variables == null)
            {
                throw new ArgumentNullException("variables");
            }

            Enterprise = enterprise;
            RequestId  = new Integer32(requestId);
            _time      = new TimeTicks(time);
            Variables  = variables;
            IList <Variable> full = new List <Variable> (variables);

            full.Insert(0, new Variable(_timeId, _time));
            full.Insert(1, new Variable(_enterpriseId, Enterprise));
            _varbindSection = Variable.Transform(full);
        }
예제 #10
0
        public InformRequestPdu(Tuple <int, byte[]> length, Stream stream)
        {
            if (length == null)
            {
                throw new ArgumentNullException(nameof(length));
            }

            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            RequestId = (Integer32)DataFactory.CreateSnmpData(stream);
#pragma warning disable 168
            var temp1 = (Integer32)DataFactory.CreateSnmpData(stream); // 0
            var temp2 = (Integer32)DataFactory.CreateSnmpData(stream); // 0
#pragma warning restore 168
            _varbindSection = (Sequence)DataFactory.CreateSnmpData(stream);
            Variables       = Variable.Transform(_varbindSection);
            if (Variables.Count >= 2)
            {
                _time = (TimeTicks)Variables[0].Data;
                Variables.RemoveAt(0);
                Enterprise = (ObjectIdentifier)Variables[0].Data;
                Variables.RemoveAt(0);
            }
            else if (Variables.Count == 0)
            {
                _time      = new TimeTicks(0);
                Enterprise = null;
            }
            else
            {
                throw new ArgumentException("Malformed inform message.", nameof(stream));
            }

            _length = length.Item2;
        }
예제 #11
0
 public TrapV1Pdu(uint[] enterprise, IP agent, Integer32 generic, Integer32 specific, TimeTicks timestamp, IList <Variable> variables)
     : this(new ObjectIdentifier(enterprise), agent, generic, specific, timestamp, variables)
 {
 }
예제 #12
0
        /// <summary>
        /// Creates a <see cref="TrapV1Pdu"/> instance with PDU elements.
        /// </summary>
        /// <param name="enterprise">Enterprise</param>
        /// <param name="agent">Agent address</param>
        /// <param name="generic">Generic trap type</param>
        /// <param name="specific">Specific trap type</param>
        /// <param name="timestamp">Time stamp</param>
        /// <param name="variables">Variable binds</param>
        public TrapV1Pdu(ObjectIdentifier enterprise, IP agent, Integer32 generic, Integer32 specific, TimeTicks timestamp, IList <Variable> variables)
        {
            if (variables == null)
            {
                throw new ArgumentNullException(nameof(variables));
            }

            Enterprise      = enterprise ?? throw new ArgumentNullException(nameof(enterprise));
            AgentAddress    = agent ?? throw new ArgumentNullException(nameof(agent));
            _generic        = generic ?? throw new ArgumentNullException(nameof(generic));
            _specific       = specific ?? throw new ArgumentNullException(nameof(specific));
            TimeStamp       = timestamp ?? throw new ArgumentNullException(nameof(timestamp));
            _varbindSection = Variable.Transform(variables);
            Variables       = variables;
        }