/// <summary>
        /// Creates a <see cref="GetBulkRequestPdu"/> with all contents.
        /// </summary>
        /// <param name="requestId">The request id.</param>
        /// <param name="nonRepeaters">Non-repeaters.</param>
        /// <param name="maxRepetitions">Max repetitions.</param>
        /// <param name="variables">Variables.</param>
        public GetBulkRequestPdu(int requestId, int nonRepeaters, int maxRepetitions, IList <Variable> variables)
        {
            if (variables == null)
            {
                throw new ArgumentNullException("variables");
            }

            RequestId       = new Integer32(requestId);
            ErrorStatus     = new Integer32(nonRepeaters);
            ErrorIndex      = new Integer32(maxRepetitions);
            Variables       = variables;
            _varbindSection = Variable.Transform(variables);
        }
        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);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a <see cref="GetRequestPdu"/> with all contents.
        /// </summary>
        /// <param name="requestId">The request id.</param>
        /// <param name="variables">Variables</param>
        public GetRequestPdu(int requestId, IList <Variable> variables)
        {
            if (variables == null)
            {
                throw new ArgumentNullException("variables");
            }

            RequestId       = new Integer32(requestId);
            ErrorStatus     = Integer32.Zero;
            ErrorIndex      = Integer32.Zero;
            Variables       = variables;
            _varbindSection = Variable.Transform(variables);
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Header"/> class.
        /// </summary>
        /// <param name="messageId">The message id.</param>
        /// <param name="maxMessageSize">Size of the max message.</param>
        /// <param name="securityLevel">The security level.</param>
        /// <remarks>If you want an empty header, please use <see cref="Empty"/>.</remarks>
        public Header(Integer32 messageId, Integer32 maxMessageSize, Levels securityLevel)
        {
            if (maxMessageSize == null)
            {
                throw new ArgumentNullException("maxMessageSize");
            }

            _messageId     = messageId;
            _maxSize       = maxMessageSize;
            SecurityLevel  = securityLevel;
            _flags         = new OctetString(SecurityLevel);
            _securityModel = DefaultSecurityModel;
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a <see cref="ResponsePdu"/> with all contents.
        /// </summary>
        /// <param name="requestId">The request ID.</param>
        /// <param name="errorStatus">Error status.</param>
        /// <param name="errorIndex">Error index.</param>
        /// <param name="variables">Variables.</param>
        public ResponsePdu(int requestId, ErrorCode errorStatus, int errorIndex, IList <Variable> variables)
        {
            if (variables == null)
            {
                throw new ArgumentNullException("variables");
            }

            RequestId       = new Integer32(requestId);
            ErrorStatus     = new Integer32((int)errorStatus);
            ErrorIndex      = new Integer32(errorIndex);
            Variables       = variables;
            _varbindSection = Variable.Transform(variables);
        }
Esempio n. 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SecurityParameters"/> class.
        /// </summary>
        /// <param name="engineId">The engine ID.</param>
        /// <param name="engineBoots">The engine boots.</param>
        /// <param name="engineTime">The engine time.</param>
        /// <param name="userName">The user name.</param>
        /// <param name="authenticationParameters">The authentication parameters.</param>
        /// <param name="privacyParameters">The privacy parameters.</param>
        /// <remarks>Only <paramref name="userName"/> cannot be null.</remarks>
        public SecurityParameters(OctetString engineId, Integer32 engineBoots, Integer32 engineTime, OctetString userName, OctetString authenticationParameters, OctetString privacyParameters)
        {
            if (userName == null)
            {
                throw new ArgumentNullException("userName");
            }

            EngineId    = engineId;
            EngineBoots = engineBoots;
            EngineTime  = engineTime;
            UserName    = userName;
            AuthenticationParameters = authenticationParameters;
            PrivacyParameters        = privacyParameters;
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Header"/> class.
        /// </summary>
        /// <param name="data">The data.</param>
        public Header(ISnmpData data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            _container     = (Sequence)data;
            _messageId     = (Integer32)_container[0];
            _maxSize       = (Integer32)_container[1];
            _flags         = (OctetString)_container[2];
            SecurityLevel  = _flags.ToLevels();
            _securityModel = (Integer32)_container[3];
        }
Esempio n. 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 (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;
        }
Esempio n. 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TrapV1Pdu"/> class.
        /// </summary>
        /// <param name="stream">The stream.</param>
        public TrapV1Pdu(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            Enterprise      = (ObjectIdentifier)DataFactory.CreateSnmpData(stream);
            AgentAddress    = (IP)DataFactory.CreateSnmpData(stream);
            _generic        = (Integer32)DataFactory.CreateSnmpData(stream);
            _specific       = (Integer32)DataFactory.CreateSnmpData(stream);
            TimeStamp       = (TimeTicks)DataFactory.CreateSnmpData(stream);
            _varbindSection = (Sequence)DataFactory.CreateSnmpData(stream);
            Variables       = Variable.Transform(_varbindSection);
        }
Esempio n. 10
0
        public TrapV2Pdu(int requestId, ObjectIdentifier enterprise, uint time, IList <Variable> variables)
        {
            if (enterprise == null)
            {
                throw new ArgumentNullException(nameof(enterprise));
            }

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

            Enterprise      = enterprise;
            RequestId       = new Integer32(requestId);
            _time           = new TimeTicks(time);
            Variables       = variables;
            _varbindSection = Variable.Transform(Decorate(variables));
        }
Esempio n. 11
0
        public TrapV2Pdu(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            RequestId = (Integer32)DataFactory.CreateSnmpData(stream);       // request
#pragma warning disable 168
            Integer32 temp1 = (Integer32)DataFactory.CreateSnmpData(stream); // 0
            Integer32 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);
        }
Esempio n. 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TrapV1Pdu"/> class.
        /// </summary>
        /// <param name="length">The length data.</param>
        /// <param name="stream">The stream.</param>
        public TrapV1Pdu(Tuple <int, byte[]> length, Stream stream)
        {
            if (length == null)
            {
                throw new ArgumentNullException(nameof(length));
            }

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

            Enterprise      = (ObjectIdentifier)DataFactory.CreateSnmpData(stream);
            AgentAddress    = (IP)DataFactory.CreateSnmpData(stream);
            _generic        = (Integer32)DataFactory.CreateSnmpData(stream);
            _specific       = (Integer32)DataFactory.CreateSnmpData(stream);
            TimeStamp       = (TimeTicks)DataFactory.CreateSnmpData(stream);
            _varbindSection = (Sequence)DataFactory.CreateSnmpData(stream);
            Variables       = Variable.Transform(_varbindSection);
            _length         = length.Item2;
        }
Esempio n. 13
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);
        }
Esempio n. 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Header"/> class.
        /// </summary>
        /// <param name="messageId">The message id.</param>
        /// <param name="maxMessageSize">Size of the max message.</param>
        /// <param name="securityBits">The flags.</param>
        /// <remarks>If you want an empty header, please use <see cref="Empty"/>.</remarks>
        public Header(Integer32 messageId, Integer32 maxMessageSize, OctetString securityBits)
        {
            if (messageId == null)
            {
                throw new ArgumentNullException("messageId");
            }

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

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

            _messageId     = messageId;
            _maxSize       = maxMessageSize;
            _flags         = securityBits;
            _securityModel = DefaultSecurityModel;
        }
Esempio n. 16
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)
 {
 }
Esempio n. 17
0
 private Header()
 {
     _maxSize = new Integer32(MaxMessageSize);
 }
Esempio n. 18
0
 internal Header(int messageId)
     : this()
 {
     _messageId = new Integer32(messageId);
 }