示例#1
0
 public static byte[] ReadTLV(byte[] src, ref int offset, out SnmpTag tag)
 {
     int o = offset;
     SnmpTag t;
     int len;
     ReadTL(src, ref o, out t, out len);
     byte[] v = new byte[len];
     Buffer.BlockCopy(src, o, v, 0, len);
     tag = t;
     offset = o + len;
     return v;
 }
示例#2
0
        public static void ReadTL(byte[] src, ref int offset, out SnmpTag tag, out int length)
        {
            tag = (SnmpTag)src[offset];
            offset++;

            int len = 0;
            if((src[offset] & 0x80) > 0) {
                int nl = src[offset] & 0x7f;
                offset++;
                for(int i = 0; i < nl; i++) {
                    len = (len << 8) + src[offset];
                    offset++;
                }
            }
            else {
                len = src[offset];
                offset++;
            }
            length = len;
        }