Ejemplo n.º 1
0
        /// <summary>
        /// Converts <see cref="OctetString" /> to <see cref="PhysicalAddress" />.
        /// </summary>
        /// <param name="address">The <see cref="OctetString" /> object that holds the address.</param>
        /// <returns>The <see cref="PhysicalAddress" /> object.</returns>
        /// <exception cref="System.InvalidCastException"><paramref name="address"/> length is not equal to 6.</exception>
        public static PhysicalAddress ToPhysicalAddress(this OctetString address)
        {
            var raw = address.GetRaw();

            if (raw.Length != 6)
            {
                throw new InvalidCastException(string.Format(CultureInfo.InvariantCulture, "the data length is not equal to 6: {0}", raw.Length));
            }

            return(new PhysicalAddress(raw));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SecurityParameters"/> class.
        /// </summary>
        /// <param name="parameters">The <see cref="OctetString"/> that contains parameters.</param>
        public SecurityParameters(OctetString parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var data = (Sequence)DataFactory.CreateSnmpData(parameters.GetRaw());

            EngineId    = (OctetString)data[0];
            EngineBoots = (Integer32)data[1];
            EngineTime  = (Integer32)data[2];
            UserName    = (OctetString)data[3];
            AuthenticationParameters = (OctetString)data[4];
            PrivacyParameters        = (OctetString)data[5];
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SecurityParameters"/> class.
        /// </summary>
        /// <param name="parameters">The <see cref="OctetString"/> that contains parameters.</param>
        public SecurityParameters(OctetString parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var container = (Sequence)DataFactory.CreateSnmpData(parameters.GetRaw());

            EngineId    = (OctetString)container[0];
            EngineBoots = (Integer32)container[1];
            EngineTime  = (Integer32)container[2];
            UserName    = (OctetString)container[3];
            AuthenticationParameters = (OctetString)container[4];
            PrivacyParameters        = (OctetString)container[5];
            _length = container.GetLengthBytes();
        }