public int getNestedTLVBuf(int aiType, TLVPack appoVal) { if (appoVal == null) { return(-4); } if (this.m_iUsedSize == this.m_ptHeader.getSize()) { return(-6); } FixedSizeTLVBody body = new FixedSizeTLVBody(); tVariableSizeTLVItem item = new tVariableSizeTLVItem(); TLVBody body2 = null; if (this.m_eDefaultMode == 0) { body2 = body; } else if (this.m_eDefaultMode == 1) { body2 = item; } else { return(-8); } if (body2.MapTo(this.m_pcBuf, this.m_iUsedSize, this.m_ptHeader.getSize())) { while ((body2.iType != aiType) && (body2.iNextOffset != 0)) { if (!body2.MapTo(this.m_pcBuf, this.m_iUsedSize, body2.iNextOffset)) { return(-5); } } if (body2.iType != aiType) { return(-6); } if ((body2.iLength > 0) && (0 > appoVal.CopyFrom(body2.pcValPtr, body2.iLength, body2.pcValPtrOffset))) { appoVal.m_pcBuf = null; appoVal.m_ptHeader.h_pcBuf = null; return(-5); } return(0); } return(-5); }
public static bool UnPack(byte[] packBuf, ref MMTLVHeader tlvHeader, ref byte[] cipherText) { if ((packBuf == null) || (packBuf.Length < 2)) { Log.e("MMPack", " UnPack failed: invlaide args"); return(false); } if ((190 != packBuf[0]) || (0xed != packBuf[packBuf.Length - 1])) { Log.e("MMPack", " UnPack failed: invalid args packBuf"); return(false); } TLVPack pack = new TLVPack(0, 1); if (pack.CopyFrom(packBuf, packBuf.Length - 2, 1) != 0) { return(false); } int apiVal = 0; if (pack.GetInt(2, ref apiVal) != 0) { Log.e("MMPack", " UnPack failed : uin"); return(false); } tlvHeader.Uin = (uint)apiVal; short aphVal = 0; if (pack.GetShort(3, ref aphVal) != 0) { Log.e("MMPack", " UnPack failed : cmdId"); return(false); } tlvHeader.CmdId = (ushort)aphVal; byte[] apoVal = null; if (pack.getByteArray(5, ref apoVal) != 0) { Log.e("MMPack", " UnPack failed : serverId"); return(false); } tlvHeader.ServerId = apoVal; byte[] buffer2 = null; if (pack.getByteArray(6, ref buffer2) != 0) { Log.e("MMPack", " UnPack failed : deviceId"); return(false); } tlvHeader.DeviceId = buffer2; short num3 = 0; if (pack.GetShort(7, ref num3) != 0) { Log.e("MMPack", " UnPack failed : compressVersion"); return(false); } tlvHeader.CompressVersion = num3; short num4 = 0; if (pack.GetShort(8, ref num4) != 0) { Log.e("MMPack", " UnPack failed : compressAlgorithm"); return(false); } tlvHeader.CompressAlogrithm = num4; short num5 = 0; if (pack.GetShort(9, ref num5) != 0) { Log.e("MMPack", " UnPack failed : cryptAlgorithm"); return(false); } tlvHeader.CryptAlgorithm = num5; uint apuVal = 0; if (pack.GetUInt(10, ref apuVal) != 0) { Log.e("MMPack", " UnPack failed : compressLen"); return(false); } tlvHeader.CompressLen = apuVal; uint num7 = 0; if (pack.GetUInt(11, ref num7) != 0) { Log.e("MMPack", " UnPack failed : compressedLen"); return(false); } tlvHeader.CompressedLen = num7; if (pack.getByteArray(12, ref cipherText) != 0) { Log.e("MMPack", " UnPack failed : cipherText"); return(false); } int num8 = 0; if (pack.GetInt(13, ref num8) != 0) { Log.e("MMPack", " UnPack failed : ret"); return(false); } tlvHeader.Ret = num8; uint num9 = 0; if (pack.GetUInt(15, ref num9) != 0) { Log.e("MMPack", " UnPack failed : certversion"); return(false); } tlvHeader.CertVersion = num9; return(true); }