Beispiel #1
0
 public int addByteArray(int aiType, byte[] aoVal, int size)
 {
     if (0 > this.ensureSpace(aiType, size))
     {
         return(-2);
     }
     if (this.m_eDefaultMode == 0)
     {
         Buffer.BlockCopy(TLVUtil.int2byte(aiType, 4, true), 0, this.m_pcBuf, this.m_iUsedSize, 4);
         this.m_iUsedSize += 4;
         Buffer.BlockCopy(TLVUtil.int2byte(size, 4, true), 0, this.m_pcBuf, this.m_iUsedSize, 4);
         this.m_iUsedSize += 4;
     }
     else if (this.m_eDefaultMode == 1)
     {
         int num = TLVUtil.EncodeVByte32(aiType, this.m_pcBuf, this.m_iUsedSize);
         this.m_iUsedSize += num;
         int num2 = TLVUtil.EncodeVByte32(size, this.m_pcBuf, this.m_iUsedSize);
         this.m_iUsedSize += num2;
     }
     else
     {
         return(-8);
     }
     Buffer.BlockCopy(aoVal, 0, this.m_pcBuf, this.m_iUsedSize, size);
     this.m_iUsedSize += size;
     return(0);
 }
Beispiel #2
0
        public static void appendIntTobuf(byte[] dstBuf, ref int dstOffset, int srcInt)
        {
            byte[] apcBuffer = new byte[4];
            int    count     = TLVUtil.EncodeVByte32(srcInt, apcBuffer, 0);

            Buffer.BlockCopy(apcBuffer, 0, dstBuf, dstOffset, count);
            dstOffset += count;
        }
Beispiel #3
0
 public int SizeNumber(int aiType, int aiSizeOfType, int eTLVMode)
 {
     if (eTLVMode == 0)
     {
         return(8 + aiSizeOfType);
     }
     if (eTLVMode == 1)
     {
         byte[] apcBuffer = new byte[6];
         int    num       = TLVUtil.EncodeVByte32(aiType, apcBuffer, 0);
         int    num2      = TLVUtil.EncodeVByte32(aiSizeOfType, apcBuffer, 0);
         return((num + num2) + aiSizeOfType);
     }
     return(0x7fffffff);
 }
Beispiel #4
0
 public int SizeType(int aiType, int eTLVMode)
 {
     if (eTLVMode == 0)
     {
         return(4);
     }
     if (eTLVMode != 1)
     {
         return(0x7fffffff);
     }
     if (aiType == 0)
     {
         return(0x7fffffff);
     }
     byte[] apcBuffer = new byte[6];
     return(TLVUtil.EncodeVByte32(aiType, apcBuffer, 0));
 }
Beispiel #5
0
 public int SizeLength(int aiLen, int eTLVMode)
 {
     if (eTLVMode == 0)
     {
         return(4);
     }
     if (eTLVMode != 1)
     {
         return(0x7fffffff);
     }
     if (aiLen == -1)
     {
         return(0x7fffffff);
     }
     byte[] apcBuffer = new byte[6];
     return(TLVUtil.EncodeVByte32(aiLen, apcBuffer, 0));
 }
Beispiel #6
0
        public int addNestedTLV(int aiType, TLVPack apoVal)
        {
            if (0 > this.ensureSpace(aiType, apoVal.m_iUsedSize))
            {
                return(-2);
            }
            int iUsedSize = this.m_iUsedSize;

            if (this.m_eDefaultMode == 0)
            {
                Buffer.BlockCopy(TLVUtil.int2byte(aiType, 4, true), 0, this.m_pcBuf, this.m_iUsedSize, 4);
                this.m_iUsedSize += 4;
                Buffer.BlockCopy(TLVUtil.int2byte(apoVal.m_iUsedSize, 4, true), 0, this.m_pcBuf, this.m_iUsedSize, 4);
                this.m_iUsedSize += 4;
            }
            else if (this.m_eDefaultMode == 1)
            {
                int num2 = TLVUtil.EncodeVByte32(aiType, this.m_pcBuf, this.m_iUsedSize);
                this.m_iUsedSize += num2;
                int num3 = TLVUtil.EncodeVByte32(apoVal.m_iUsedSize, this.m_pcBuf, this.m_iUsedSize);
                this.m_iUsedSize += num3;
            }
            else
            {
                return(-8);
            }
            if (apoVal.m_iUsedSize > 0)
            {
                int apiSize = 0;
                apiSize = this.m_iAllocSize - this.m_iUsedSize;
                int num5 = apoVal.CopyTo(this.m_pcBuf, this.m_iUsedSize, ref apiSize);
                if (num5 != 0)
                {
                    this.m_iUsedSize = iUsedSize;
                    return(num5);
                }
            }
            this.m_iUsedSize += apoVal.m_iUsedSize;
            return(0);
        }