Ejemplo n.º 1
0
        /// <summary>
        /// Converts a ASN.1 ObjectIdentifier to a System String
        /// </summary>
        /// <returns></returns>
        public string ToObjectIdentifier()
        {
            int         pos = 0;
            List <byte> tlv = ToBytes();

            return(BasicEncodingRules.DecodeObjectId(ref tlv, ref pos));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a Varaible from a List of bytes
        /// </summary>
        /// <param name="bytes">The List of bytes</param>
        /// <returns>A Variable constructs from the given bytes</returns>
        public static Variable FromBytes(List <byte> bytes)
        {
            int      position = 0;
            Variable result   = new Variable();

            if (bytes[position].ToSnmpType() == SnmpType.ObjectIdentifier)
            {
                result.Identifier = BasicEncodingRules.DecodeObjectId(ref bytes, ref position);
            }
            result.TypeCode = bytes[position].ToSnmpType();
            int Length = BasicEncodingRules.DecodeLength(ref bytes, ref position, result.TypeCode);

            result.Value = bytes.GetRange(position, Length);
            return(result);
        }