public TdrError.ErrorType packTLV(long selector, ref TdrWriteBuf destBuf, bool useVarInt) { if (destBuf == null) { return(TdrError.ErrorType.TDR_ERR_ARG_IS_NULL); } TdrError.ErrorType errorType; if (selector >= 0L && selector <= 2L) { switch ((int)selector) { case 0: if (useVarInt) { uint src = TdrTLV.makeTag(0, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_VARINT); errorType = destBuf.writeVarUInt32(src); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } errorType = destBuf.writeVarInt32(this.iNilCmd); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } } else { uint src2 = TdrTLV.makeTag(0, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_4_BYTE); errorType = destBuf.writeVarUInt32(src2); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } errorType = destBuf.writeInt32(this.iNilCmd); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } } return(errorType); case 1: { if (this.szStrCmd == null) { return(TdrError.ErrorType.TDR_ERR_UNION_SELECTE_FIELD_IS_NULL); } uint src3 = TdrTLV.makeTag(1, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_LENGTH_DELIMITED); errorType = destBuf.writeVarUInt32(src3); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } int usedSize = destBuf.getUsedSize(); errorType = destBuf.reserve(4); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } int num = TdrTypeUtil.cstrlen(this.szStrCmd); if (num >= 64) { return(TdrError.ErrorType.TDR_ERR_STR_LEN_TOO_BIG); } errorType = destBuf.writeCString(this.szStrCmd, num); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } int src4 = destBuf.getUsedSize() - usedSize - 4; errorType = destBuf.writeInt32(src4, usedSize); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } return(errorType); } case 2: if (useVarInt) { uint src5 = TdrTLV.makeTag(2, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_VARINT); errorType = destBuf.writeVarUInt32(src5); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } errorType = destBuf.writeVarInt32(this.iIntCmd); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } } else { uint src6 = TdrTLV.makeTag(2, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_4_BYTE); errorType = destBuf.writeVarUInt32(src6); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } errorType = destBuf.writeInt32(this.iIntCmd); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } } return(errorType); } } errorType = TdrError.ErrorType.TDR_ERR_SUSPICIOUS_SELECTOR; return(errorType); }
public TdrError.ErrorType unpackTLV(ref TdrReadBuf srcBuf, int length, bool useVarInt) { if ((srcBuf == null) || (length <= 0)) { return(TdrError.ErrorType.TDR_ERR_ARG_IS_NULL); } TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR; uint dest = 0; int num3 = 0; int num4 = srcBuf.getUsedSize(); while (srcBuf.getUsedSize() < (num4 + length)) { type = srcBuf.readVarUInt32(ref dest); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } switch (TdrTLV.getFieldId(dest)) { case 1: { if (!this.has_HttpVersion()) { this.set_has_HttpVersion(); } int num5 = 0; type = srcBuf.readInt32(ref num5); if (type == TdrError.ErrorType.TDR_NO_ERROR) { if (num5 >= 0x20) { return(TdrError.ErrorType.TDR_ERR_STR_LEN_TOO_BIG); } type = srcBuf.readCString(ref this.szHttpVersion, num5); if (type == TdrError.ErrorType.TDR_NO_ERROR) { continue; } } return(type); } case 2: { if (!this.has_StatusCode()) { this.set_has_StatusCode(); } int num6 = 0; type = srcBuf.readInt32(ref num6); if (type == TdrError.ErrorType.TDR_NO_ERROR) { if (num6 >= 0x10) { return(TdrError.ErrorType.TDR_ERR_STR_LEN_TOO_BIG); } type = srcBuf.readCString(ref this.szStatusCode, num6); if (type == TdrError.ErrorType.TDR_NO_ERROR) { continue; } } return(type); } case 3: { if (!this.has_ReasonPhrase()) { this.set_has_ReasonPhrase(); } int num7 = 0; type = srcBuf.readInt32(ref num7); if (type == TdrError.ErrorType.TDR_NO_ERROR) { if (num7 >= 0x40) { return(TdrError.ErrorType.TDR_ERR_STR_LEN_TOO_BIG); } type = srcBuf.readCString(ref this.szReasonPhrase, num7); if (type == TdrError.ErrorType.TDR_NO_ERROR) { continue; } } return(type); } } uint num8 = TdrTLV.getTypeId(dest); type = TdrTLV.skipUnknownFields(ref srcBuf, (TdrTLV.TdrTLVTypeId)num8); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } } if (srcBuf.getUsedSize() > (num4 + length)) { return(TdrError.ErrorType.TDR_ERR_UNMATCHED_LENGTH); } if (num3 < this.requiredFieldNum()) { return(TdrError.ErrorType.TDR_ERR_LOST_REQUIRED_FIELD); } return(type); }
public TdrError.ErrorType unpackTLV(ref long selector, ref TdrReadBuf srcBuf, int length, bool useVarInt) { if (srcBuf == null || length == 0) { return(TdrError.ErrorType.TDR_ERR_INVALID_BUFFER_PARAMETER); } int usedSize = srcBuf.getUsedSize(); uint tagid = 0u; TdrError.ErrorType errorType = srcBuf.readVarUInt32(ref tagid); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } uint fieldId = TdrTLV.getFieldId(tagid); switch (fieldId) { case 0u: if (useVarInt) { errorType = srcBuf.readVarInt32(ref this.iNilCmd); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } } else { errorType = srcBuf.readInt32(ref this.iNilCmd); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } } break; case 1u: { if (this.szStrCmd == null) { this.szStrCmd = new byte[64]; } int num = 0; errorType = srcBuf.readInt32(ref num); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } if (num >= 64) { return(TdrError.ErrorType.TDR_ERR_STR_LEN_TOO_BIG); } errorType = srcBuf.readCString(ref this.szStrCmd, num); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } break; } case 2u: if (useVarInt) { errorType = srcBuf.readVarInt32(ref this.iIntCmd); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } } else { errorType = srcBuf.readInt32(ref this.iIntCmd); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } } break; default: errorType = TdrError.ErrorType.TDR_ERR_SUSPICIOUS_SELECTOR; break; } if (srcBuf.getUsedSize() > usedSize + length) { return(TdrError.ErrorType.TDR_ERR_UNMATCHED_LENGTH); } selector = (long)((ulong)fieldId); return(errorType); }
public TdrError.ErrorType packTLV(ref TdrWriteBuf destBuf, bool useVarInt) { TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR; uint src = TdrTLV.makeTag(1, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_LENGTH_DELIMITED); type = destBuf.writeVarUInt32(src); if (type == TdrError.ErrorType.TDR_NO_ERROR) { int pos = destBuf.getUsedSize(); type = destBuf.reserve(4); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } type = this.stResponseStatus.packTLV(ref destBuf, useVarInt); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int num3 = (destBuf.getUsedSize() - pos) - 4; type = destBuf.writeInt32(num3, pos); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } uint num4 = TdrTLV.makeTag(2, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_LENGTH_DELIMITED); type = destBuf.writeVarUInt32(num4); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int num5 = destBuf.getUsedSize(); type = destBuf.reserve(4); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } type = this.stHttpHeaders.packTLV(ref destBuf, useVarInt); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int num6 = (destBuf.getUsedSize() - num5) - 4; type = destBuf.writeInt32(num6, num5); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } uint num7 = TdrTLV.makeTag(3, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_LENGTH_DELIMITED); type = destBuf.writeVarUInt32(num7); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int num8 = destBuf.getUsedSize(); type = destBuf.reserve(4); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } type = this.stResponseContent.packTLV(ref destBuf, useVarInt); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int num9 = (destBuf.getUsedSize() - num8) - 4; type = destBuf.writeInt32(num9, num8); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } } return(type); }
public TdrError.ErrorType packTLV(ref TdrWriteBuf destBuf, bool useVarInt) { TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR; uint src = TdrTLV.makeTag(1, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_LENGTH_DELIMITED); type = destBuf.writeVarUInt32(src); if (type == TdrError.ErrorType.TDR_NO_ERROR) { int pos = destBuf.getUsedSize(); type = destBuf.reserve(4); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int count = TdrTypeUtil.cstrlen(this.szHttpVersion); if (count >= 0x20) { return(TdrError.ErrorType.TDR_ERR_STR_LEN_TOO_BIG); } type = destBuf.writeCString(this.szHttpVersion, count); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int num4 = (destBuf.getUsedSize() - pos) - 4; type = destBuf.writeInt32(num4, pos); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } uint num5 = TdrTLV.makeTag(2, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_LENGTH_DELIMITED); type = destBuf.writeVarUInt32(num5); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int num6 = destBuf.getUsedSize(); type = destBuf.reserve(4); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int num7 = TdrTypeUtil.cstrlen(this.szStatusCode); if (num7 >= 0x10) { return(TdrError.ErrorType.TDR_ERR_STR_LEN_TOO_BIG); } type = destBuf.writeCString(this.szStatusCode, num7); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int num8 = (destBuf.getUsedSize() - num6) - 4; type = destBuf.writeInt32(num8, num6); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } uint num9 = TdrTLV.makeTag(3, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_LENGTH_DELIMITED); type = destBuf.writeVarUInt32(num9); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int num10 = destBuf.getUsedSize(); type = destBuf.reserve(4); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int num11 = TdrTypeUtil.cstrlen(this.szReasonPhrase); if (num11 >= 0x40) { return(TdrError.ErrorType.TDR_ERR_STR_LEN_TOO_BIG); } type = destBuf.writeCString(this.szReasonPhrase, num11); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int num12 = (destBuf.getUsedSize() - num10) - 4; type = destBuf.writeInt32(num12, num10); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } } return(type); }
public TdrError.ErrorType packTLV(ref TdrWriteBuf destBuf, bool useVarInt) { TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR; if (useVarInt) { uint num = TdrTLV.makeTag(1, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_VARINT); type = destBuf.writeVarUInt32(num); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } type = destBuf.writeVarUInt32(this.dwAsync); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } } else { uint num2 = TdrTLV.makeTag(1, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_4_BYTE); type = destBuf.writeVarUInt32(num2); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } type = destBuf.writeUInt32(this.dwAsync); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } } uint src = TdrTLV.makeTag(2, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_1_BYTE); type = destBuf.writeVarUInt32(src); if (type == TdrError.ErrorType.TDR_NO_ERROR) { type = destBuf.writeUInt8(this.bFlag); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } uint num4 = TdrTLV.makeTag(3, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_1_BYTE); type = destBuf.writeVarUInt32(num4); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } type = destBuf.writeUInt8(this.bDomain); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } uint num5 = TdrTLV.makeTag(4, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_1_BYTE); type = destBuf.writeVarUInt32(num5); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } type = destBuf.writeUInt8(this.bCmdFmt); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } uint num6 = TdrTLV.makeTag(5, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_LENGTH_DELIMITED); type = destBuf.writeVarUInt32(num6); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int pos = destBuf.getUsedSize(); type = destBuf.reserve(4); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } type = this.stCommand.packTLV((long)this.bCmdFmt, ref destBuf, useVarInt); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int num8 = (destBuf.getUsedSize() - pos) - 4; type = destBuf.writeInt32(num8, pos); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } } return(type); }
public TdrError.ErrorType unpackTLV(ref TdrReadBuf srcBuf, int length, bool useVarInt) { if ((srcBuf == null) || (length <= 0)) { return(TdrError.ErrorType.TDR_ERR_ARG_IS_NULL); } TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR; uint dest = 0; int num3 = 0; int num4 = srcBuf.getUsedSize(); while (srcBuf.getUsedSize() < (num4 + length)) { type = srcBuf.readVarUInt32(ref dest); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } switch (TdrTLV.getFieldId(dest)) { case 1: { if (!this.has_ResponseStatus()) { this.set_has_ResponseStatus(); } int num5 = 0; type = srcBuf.readInt32(ref num5); if (type == TdrError.ErrorType.TDR_NO_ERROR) { type = this.stResponseStatus.unpackTLV(ref srcBuf, num5, useVarInt); if (type == TdrError.ErrorType.TDR_NO_ERROR) { continue; } } return(type); } case 2: { if (!this.has_HttpHeaders()) { this.set_has_HttpHeaders(); } int num6 = 0; type = srcBuf.readInt32(ref num6); if (type == TdrError.ErrorType.TDR_NO_ERROR) { type = this.stHttpHeaders.unpackTLV(ref srcBuf, num6, useVarInt); if (type == TdrError.ErrorType.TDR_NO_ERROR) { continue; } } return(type); } case 3: { if (!this.has_ResponseContent()) { this.set_has_ResponseContent(); } int num7 = 0; type = srcBuf.readInt32(ref num7); if (type == TdrError.ErrorType.TDR_NO_ERROR) { type = this.stResponseContent.unpackTLV(ref srcBuf, num7, useVarInt); if (type == TdrError.ErrorType.TDR_NO_ERROR) { continue; } } return(type); } } uint num8 = TdrTLV.getTypeId(dest); type = TdrTLV.skipUnknownFields(ref srcBuf, (TdrTLV.TdrTLVTypeId)num8); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } } if (srcBuf.getUsedSize() > (num4 + length)) { return(TdrError.ErrorType.TDR_ERR_UNMATCHED_LENGTH); } if (num3 < this.requiredFieldNum()) { return(TdrError.ErrorType.TDR_ERR_LOST_REQUIRED_FIELD); } return(type); }
public TdrError.ErrorType unpackTLV(ref TdrReadBuf srcBuf, int length, bool useVarInt) { if (srcBuf == null || length <= 0) { return(TdrError.ErrorType.TDR_ERR_ARG_IS_NULL); } TdrError.ErrorType errorType = TdrError.ErrorType.TDR_NO_ERROR; uint tagid = 0u; int num = 0; int usedSize = srcBuf.getUsedSize(); while (srcBuf.getUsedSize() < usedSize + length) { errorType = srcBuf.readVarUInt32(ref tagid); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } uint fieldId = TdrTLV.getFieldId(tagid); uint num2 = fieldId; if (num2 != 1u) { if (num2 != 2u) { uint typeId = TdrTLV.getTypeId(tagid); errorType = TdrTLV.skipUnknownFields(ref srcBuf, (TdrTLV.TdrTLVTypeId)typeId); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } } else { if (!this.has_Data()) { this.set_has_Data(); } int num3 = 0; errorType = srcBuf.readInt32(ref num3); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } if (num3 == 0) { return(TdrError.ErrorType.TDR_ERR_NULL_ARRAY); } int usedSize2 = srcBuf.getUsedSize(); for (int i = 0; i < 8096; i++) { errorType = srcBuf.readUInt8(ref this.szData[i]); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } if (srcBuf.getUsedSize() > usedSize2 + num3) { return(TdrError.ErrorType.TDR_ERR_UNMATCHED_LENGTH); } if (srcBuf.getUsedSize() == usedSize2 + num3) { this.dwDataLen = (uint)(i + 1); break; } } } } else { if (!this.has_DataLen()) { this.set_has_DataLen(); } if (useVarInt) { errorType = srcBuf.readVarUInt32(ref this.dwDataLen); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } } else { errorType = srcBuf.readUInt32(ref this.dwDataLen); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } } } } if (srcBuf.getUsedSize() > usedSize + length) { return(TdrError.ErrorType.TDR_ERR_UNMATCHED_LENGTH); } if (num < this.requiredFieldNum()) { return(TdrError.ErrorType.TDR_ERR_LOST_REQUIRED_FIELD); } return(errorType); }
public TdrError.ErrorType unpackTLV(ref TdrReadBuf srcBuf, int length, bool useVarInt) { if ((srcBuf == null) || (length <= 0)) { return(TdrError.ErrorType.TDR_ERR_ARG_IS_NULL); } TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR; uint dest = 0; int num3 = 0; int num4 = srcBuf.getUsedSize(); while (srcBuf.getUsedSize() < (num4 + length)) { int num5; uint num7; type = srcBuf.readVarUInt32(ref dest); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } switch (TdrTLV.getFieldId(dest)) { case 1: if (!this.has_Async()) { this.set_has_Async(); } if (useVarInt) { type = srcBuf.readVarUInt32(ref this.dwAsync); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } continue; } type = srcBuf.readUInt32(ref this.dwAsync); if (type == TdrError.ErrorType.TDR_NO_ERROR) { continue; } return(type); case 2: if (!this.has_Flag()) { this.set_has_Flag(); } type = srcBuf.readUInt8(ref this.bFlag); if (type == TdrError.ErrorType.TDR_NO_ERROR) { continue; } return(type); case 3: if (!this.has_Domain()) { this.set_has_Domain(); } type = srcBuf.readUInt8(ref this.bDomain); if (type == TdrError.ErrorType.TDR_NO_ERROR) { continue; } return(type); case 4: if (!this.has_CmdFmt()) { this.set_has_CmdFmt(); } type = srcBuf.readUInt8(ref this.bCmdFmt); if (type == TdrError.ErrorType.TDR_NO_ERROR) { continue; } return(type); case 5: num5 = 0; type = srcBuf.readInt32(ref num5); if (type == TdrError.ErrorType.TDR_NO_ERROR) { break; } return(type); default: goto Label_0177; } long selector = 0L; type = this.stCommand.unpackTLV(ref selector, ref srcBuf, num5, useVarInt); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } this.bCmdFmt = (byte)selector; continue; Label_0177: num7 = TdrTLV.getTypeId(dest); type = TdrTLV.skipUnknownFields(ref srcBuf, (TdrTLV.TdrTLVTypeId)num7); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } } if (srcBuf.getUsedSize() > (num4 + length)) { return(TdrError.ErrorType.TDR_ERR_UNMATCHED_LENGTH); } if (num3 < this.requiredFieldNum()) { return(TdrError.ErrorType.TDR_ERR_LOST_REQUIRED_FIELD); } return(type); }
public TdrError.ErrorType packTLV(ref TdrWriteBuf destBuf, bool useVarInt) { TdrError.ErrorType errorType; if (useVarInt) { uint src = TdrTLV.makeTag(1, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_VARINT); errorType = destBuf.writeVarUInt32(src); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } errorType = destBuf.writeVarUInt32(this.dwDataLen); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } } else { uint src2 = TdrTLV.makeTag(1, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_4_BYTE); errorType = destBuf.writeVarUInt32(src2); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } errorType = destBuf.writeUInt32(this.dwDataLen); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } } if (this.dwDataLen > 8096u) { return(TdrError.ErrorType.TDR_ERR_REFER_SURPASS_COUNT); } if (this.dwDataLen > 0u) { uint src3 = TdrTLV.makeTag(2, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_LENGTH_DELIMITED); errorType = destBuf.writeVarUInt32(src3); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } int usedSize = destBuf.getUsedSize(); errorType = destBuf.reserve(4); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } int num = 0; while ((long)num < (long)((ulong)this.dwDataLen)) { errorType = destBuf.writeUInt8(this.szData[num]); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } num++; } int src4 = destBuf.getUsedSize() - usedSize - 4; errorType = destBuf.writeInt32(src4, usedSize); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } } return(errorType); }
public TdrError.ErrorType unpackTLV(ref TdrReadBuf srcBuf, int length, bool useVarInt) { if (srcBuf == null || length <= 0) { return(TdrError.ErrorType.TDR_ERR_ARG_IS_NULL); } TdrError.ErrorType errorType = TdrError.ErrorType.TDR_NO_ERROR; uint tagid = 0u; int num = 0; int usedSize = srcBuf.getUsedSize(); while (srcBuf.getUsedSize() < usedSize + length) { errorType = srcBuf.readVarUInt32(ref tagid); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } switch (TdrTLV.getFieldId(tagid)) { case 1u: { if (!this.has_ResponseStatus()) { this.set_has_ResponseStatus(); } int length2 = 0; errorType = srcBuf.readInt32(ref length2); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } errorType = this.stResponseStatus.unpackTLV(ref srcBuf, length2, useVarInt); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } break; } case 2u: { if (!this.has_HttpHeaders()) { this.set_has_HttpHeaders(); } int length3 = 0; errorType = srcBuf.readInt32(ref length3); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } errorType = this.stHttpHeaders.unpackTLV(ref srcBuf, length3, useVarInt); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } break; } case 3u: { if (!this.has_ResponseContent()) { this.set_has_ResponseContent(); } int length4 = 0; errorType = srcBuf.readInt32(ref length4); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } errorType = this.stResponseContent.unpackTLV(ref srcBuf, length4, useVarInt); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } break; } default: { uint typeId = TdrTLV.getTypeId(tagid); errorType = TdrTLV.skipUnknownFields(ref srcBuf, (TdrTLV.TdrTLVTypeId)typeId); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } break; } } } if (srcBuf.getUsedSize() > usedSize + length) { return(TdrError.ErrorType.TDR_ERR_UNMATCHED_LENGTH); } if (num < this.requiredFieldNum()) { return(TdrError.ErrorType.TDR_ERR_LOST_REQUIRED_FIELD); } return(errorType); }
public TdrError.ErrorType packTLV(ref TdrWriteBuf destBuf, bool useVarInt) { uint src = TdrTLV.makeTag(1, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_LENGTH_DELIMITED); TdrError.ErrorType errorType = destBuf.writeVarUInt32(src); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } int usedSize = destBuf.getUsedSize(); errorType = destBuf.reserve(4); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } errorType = this.stResponseStatus.packTLV(ref destBuf, useVarInt); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } int src2 = destBuf.getUsedSize() - usedSize - 4; errorType = destBuf.writeInt32(src2, usedSize); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } uint src3 = TdrTLV.makeTag(2, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_LENGTH_DELIMITED); errorType = destBuf.writeVarUInt32(src3); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } int usedSize2 = destBuf.getUsedSize(); errorType = destBuf.reserve(4); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } errorType = this.stHttpHeaders.packTLV(ref destBuf, useVarInt); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } int src4 = destBuf.getUsedSize() - usedSize2 - 4; errorType = destBuf.writeInt32(src4, usedSize2); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } uint src5 = TdrTLV.makeTag(3, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_LENGTH_DELIMITED); errorType = destBuf.writeVarUInt32(src5); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } int usedSize3 = destBuf.getUsedSize(); errorType = destBuf.reserve(4); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } errorType = this.stResponseContent.packTLV(ref destBuf, useVarInt); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } int src6 = destBuf.getUsedSize() - usedSize3 - 4; errorType = destBuf.writeInt32(src6, usedSize3); if (errorType != TdrError.ErrorType.TDR_NO_ERROR) { return(errorType); } return(errorType); }
public TdrError.ErrorType packTLV(long selector, ref TdrWriteBuf destBuf, bool useVarInt) { if (destBuf == null) { return(TdrError.ErrorType.TDR_ERR_ARG_IS_NULL); } TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR; long num9 = selector; if ((num9 >= 0L) && (num9 <= 2L)) { switch (((int)num9)) { case 0: { if (!useVarInt) { uint num2 = TdrTLV.makeTag(0, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_4_BYTE); type = destBuf.writeVarUInt32(num2); if (type == TdrError.ErrorType.TDR_NO_ERROR) { type = destBuf.writeInt32(this.iNilCmd); if (type == TdrError.ErrorType.TDR_NO_ERROR) { return(type); } } return(type); } uint src = TdrTLV.makeTag(0, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_VARINT); type = destBuf.writeVarUInt32(src); if (type == TdrError.ErrorType.TDR_NO_ERROR) { type = destBuf.writeVarInt32(this.iNilCmd); if (type == TdrError.ErrorType.TDR_NO_ERROR) { } return(type); } return(type); } case 1: if (this.szStrCmd != null) { uint num3 = TdrTLV.makeTag(1, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_LENGTH_DELIMITED); type = destBuf.writeVarUInt32(num3); if (type == TdrError.ErrorType.TDR_NO_ERROR) { int pos = destBuf.getUsedSize(); type = destBuf.reserve(4); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int count = TdrTypeUtil.cstrlen(this.szStrCmd); if (count >= 0x40) { return(TdrError.ErrorType.TDR_ERR_STR_LEN_TOO_BIG); } type = destBuf.writeCString(this.szStrCmd, count); if (type != TdrError.ErrorType.TDR_NO_ERROR) { return(type); } int num6 = (destBuf.getUsedSize() - pos) - 4; type = destBuf.writeInt32(num6, pos); if (type == TdrError.ErrorType.TDR_NO_ERROR) { return(type); } } return(type); } return(TdrError.ErrorType.TDR_ERR_UNION_SELECTE_FIELD_IS_NULL); case 2: { if (!useVarInt) { uint num8 = TdrTLV.makeTag(2, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_4_BYTE); type = destBuf.writeVarUInt32(num8); if (type == TdrError.ErrorType.TDR_NO_ERROR) { type = destBuf.writeInt32(this.iIntCmd); if (type == TdrError.ErrorType.TDR_NO_ERROR) { return(type); } } return(type); } uint num7 = TdrTLV.makeTag(2, TdrTLV.TdrTLVTypeId.TDR_TYPE_ID_VARINT); type = destBuf.writeVarUInt32(num7); if (type == TdrError.ErrorType.TDR_NO_ERROR) { type = destBuf.writeVarInt32(this.iIntCmd); if (type == TdrError.ErrorType.TDR_NO_ERROR) { } return(type); } return(type); } } } return(TdrError.ErrorType.TDR_ERR_SUSPICIOUS_SELECTOR); }
public TdrError.ErrorType unpackTLV(ref long selector, ref TdrReadBuf srcBuf, int length, bool useVarInt) { if ((srcBuf == null) || (length == 0)) { return(TdrError.ErrorType.TDR_ERR_INVALID_BUFFER_PARAMETER); } TdrError.ErrorType type = TdrError.ErrorType.TDR_NO_ERROR; int num = srcBuf.getUsedSize(); uint dest = 0; type = srcBuf.readVarUInt32(ref dest); if (type == TdrError.ErrorType.TDR_NO_ERROR) { uint num3 = TdrTLV.getFieldId(dest); switch (num3) { case 0: if (!useVarInt) { type = srcBuf.readInt32(ref this.iNilCmd); if (type == TdrError.ErrorType.TDR_NO_ERROR) { break; } return(type); } type = srcBuf.readVarInt32(ref this.iNilCmd); if (type == TdrError.ErrorType.TDR_NO_ERROR) { break; } return(type); case 1: { if (this.szStrCmd == null) { this.szStrCmd = new byte[0x40]; } int num4 = 0; type = srcBuf.readInt32(ref num4); if (type == TdrError.ErrorType.TDR_NO_ERROR) { if (num4 >= 0x40) { return(TdrError.ErrorType.TDR_ERR_STR_LEN_TOO_BIG); } type = srcBuf.readCString(ref this.szStrCmd, num4); if (type == TdrError.ErrorType.TDR_NO_ERROR) { break; } } return(type); } case 2: if (!useVarInt) { type = srcBuf.readInt32(ref this.iIntCmd); if (type == TdrError.ErrorType.TDR_NO_ERROR) { break; } return(type); } type = srcBuf.readVarInt32(ref this.iIntCmd); if (type == TdrError.ErrorType.TDR_NO_ERROR) { break; } return(type); default: type = TdrError.ErrorType.TDR_ERR_SUSPICIOUS_SELECTOR; break; } if (srcBuf.getUsedSize() > (num + length)) { return(TdrError.ErrorType.TDR_ERR_UNMATCHED_LENGTH); } selector = num3; } return(type); }