Пример #1
0
        /// <summary>BER encode the variable binding
        /// </summary>
        /// <param name="buffer"><see cref="MutableByte"/> class to the end of which encoded variable
        /// binding values will be added.
        /// </param>
        public override void Encode(MutableByte buffer)
        {
            // encode oid to the temporary buffer
            MutableByte oidbuf = new MutableByte();

            _oid.Encode(oidbuf);
            // encode value to a temporary buffer
            MutableByte valbuf = new MutableByte();

            _value.Encode(valbuf);

            // calculate data content length of the vb
            int vblen = oidbuf.Length + valbuf.Length;

            // encode vb header at the end of the result
            BuildHeader(buffer, Type, vblen);
            // add values to the encoded arrays to the end of the result
            buffer.Append(oidbuf);
            buffer.Append(valbuf);
        }
Пример #2
0
        /// <summary>ASN.1 encode SNMP version 1 trap</summary>
        /// <param name="buffer"><see cref="MutableByte"/> buffer to the end of which encoded values are appended.</param>
        public override void Encode(MutableByte buffer)
        {
            MutableByte trapBuffer = new MutableByte();

            // encode the enterprise id & address
            _enterprise.Encode(trapBuffer);

            _agentAddr.Encode(trapBuffer);

            _generic.Encode(trapBuffer);

            _specific.Encode(trapBuffer);

            _timeStamp.Encode(trapBuffer);

            VbList.Encode(trapBuffer);
            MutableByte tmpBuffer = new MutableByte();

            BuildHeader(tmpBuffer, (byte)PduType.Trap, trapBuffer.Length);
            trapBuffer.Prepend(tmpBuffer);
            buffer.Append(trapBuffer);
        }