public int Detach(ref byte[] appcBufFather, ref int apiUsedSizeFather, ref int apiAllocSizeFather) { if (((appcBufFather == null) && (apiUsedSizeFather == 0)) && (apiAllocSizeFather == 0)) { this.m_pcBuf = null; this.clear(); return(0); } if (appcBufFather == null) { return(-4); } appcBufFather = null; apiUsedSizeFather = 0; apiAllocSizeFather = 0; appcBufFather = this.m_pcBuf; apiUsedSizeFather = this.m_iUsedSize; apiAllocSizeFather = this.m_iAllocSize; byte[] x = TLVUtil.getCheckSum(this.m_pcBuf, this.m_ptHeader.getSize(), this.m_iUsedSize - this.m_ptHeader.getSize()); this.m_ptHeader.setCheckSum(x); int num = this.m_iUsedSize - this.m_ptHeader.getSize(); this.m_ptHeader.setUsedSize(num); this.m_pcBuf = null; this.clear(); return(0); }
public bool isValidTLVPack(byte[] apcBuf, int aiUsedSize, int offset) { if (apcBuf != null) { if (aiUsedSize < this.m_ptHeader.getSize()) { return(false); } TLVPackHeader header = new TLVPackHeader { h_pcBuf = apcBuf, offset = offset }; if (header.getMagic() != 0x81) { return(false); } int aiSize = aiUsedSize - header.getSize(); if (header.getUsedSize() != aiSize) { return(false); } byte[] buffer = TLVUtil.getCheckSum(apcBuf, offset + header.getSize(), aiSize); byte[] buffer2 = header.getCheckSum(); if ((buffer[0] != buffer2[0]) || (buffer[1] != buffer2[1])) { return(false); } if (aiSize == 0) { return(true); } FixedSizeTLVBody body = new FixedSizeTLVBody(); tVariableSizeTLVItem item = new tVariableSizeTLVItem(); TLVBody body2 = null; if (header.getMode() == 0) { body2 = body; } else if (header.getMode() == 1) { body2 = item; } else { return(false); } if (body2.MapTo(apcBuf, offset + aiUsedSize, offset + header.getSize())) { while (body2.iNextOffset != 0) { if (!body2.MapTo(apcBuf, offset + aiUsedSize, body2.iNextOffset)) { return(false); } } return(true); } } return(false); }
public int CopyTo(byte[] apcBuf, int offset, ref int apiSize) { if ((apcBuf == null) || (apiSize == 0)) { return(-4); } if (apiSize < this.m_iUsedSize) { apiSize = this.m_iUsedSize; return(-7); } byte[] x = TLVUtil.getCheckSum(this.m_pcBuf, this.m_ptHeader.getSize(), this.m_iUsedSize - this.m_ptHeader.getSize()); this.m_ptHeader.setCheckSum(x); int num2 = this.m_iUsedSize - this.m_ptHeader.getSize(); this.m_ptHeader.setUsedSize(num2); if (this.m_iUsedSize > 0) { Buffer.BlockCopy(this.m_pcBuf, 0, apcBuf, offset, this.m_iUsedSize); } apiSize = this.m_iUsedSize; return(0); }