Пример #1
0
        public int GetWord(int aiType, ref int apwVal)
        {
            byte[] apoVal = null;
            int    num    = this.getByteArray(aiType, ref apoVal);

            if (num < 0)
            {
                return(num);
            }
            apwVal = TLVUtil.byte2int(apoVal, 0, 4, this.m_eDefaultMode == 0);
            return(0);
        }
Пример #2
0
        public int GetBool(int aiType, ref bool apbVal)
        {
            byte[] apoVal = null;
            int    num    = this.getByteArray(aiType, ref apoVal);

            if (num < 0)
            {
                return(num);
            }
            if (TLVUtil.byte2int(apoVal, 0, 4, this.m_eDefaultMode == 0) == 0)
            {
                apbVal = false;
            }
            else
            {
                apbVal = true;
            }
            return(0);
        }
Пример #3
0
        public static int mmpkg_mini_head_ntoh(byte[] packBuf, out MMPKG_mini_header header)
        {
            header = null;
            if ((packBuf == null) || (packBuf.Length <= 2))
            {
                return(-1);
            }
            int offSet = 0;

            header = new MMPKG_mini_header();
            header.setHHeaderBits(packBuf);
            if ((header.len == 0) || (packBuf.Length < header.len))
            {
                return(-4);
            }
            offSet    += 2;
            header.ret = TLVUtil.byte2int(packBuf, offSet, 4, true);
            offSet    += 4;
            header.uin = (uint)TLVUtil.byte2int(packBuf, offSet, 4, true);
            offSet    += 4;
            if (header.server_id_len > 0)
            {
                header.server_id = new byte[header.server_id_len];
                Buffer.BlockCopy(packBuf, offSet, header.server_id, 0, header.server_id_len);
                offSet += header.server_id_len;
            }
            int dstInt = 0;

            getIntFrombuf(packBuf, ref offSet, ref dstInt);
            header.cmd_id = (ushort)dstInt;
            getIntFrombuf(packBuf, ref offSet, ref dstInt);
            header.compress_len = (uint)dstInt;
            getIntFrombuf(packBuf, ref offSet, ref dstInt);
            header.compressed_len = (uint)dstInt;
            getIntFrombuf(packBuf, ref offSet, ref dstInt);
            header.cert_version = (ushort)dstInt;
            dstInt = 0;
            getIntFrombuf(packBuf, ref offSet, ref dstInt);
            header.device_type = (ushort)dstInt;
            return(0);
        }
Пример #4
0
            public override bool MapTo(byte[] apcSrc, int aiSrcSize, int aiOffset)
            {
                if (((apcSrc == null) || (aiSrcSize <= 0)) || ((aiOffset < 0) || (aiOffset >= aiSrcSize)))
                {
                    return(false);
                }
                int num  = TLVUtil.byte2int(apcSrc, aiOffset, 4, true);
                int num2 = TLVUtil.byte2int(apcSrc, aiOffset + 4, 4, true);

                base.pcValPtr       = apcSrc;
                base.pcValPtrOffset = (aiOffset + 4) + 4;
                int num3 = ((aiOffset + 4) + 4) + num2;

                if (num2 < 0)
                {
                    return(false);
                }
                if (base.pcValPtrOffset > aiSrcSize)
                {
                    return(false);
                }
                if (num3 > aiSrcSize)
                {
                    return(false);
                }
                if (num3 == aiSrcSize)
                {
                    base.iNextOffset = 0;
                }
                else
                {
                    base.iNextOffset = num3;
                }
                base.iType    = num;
                base.iLength  = num2;
                base.pcValPtr = apcSrc;
                return(true);
            }