mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
update all wireEncode & add packet test: CPacket
This commit is contained in:
1 parent
424d182d60
commit
2bf431af9c
33 files changed
+335
-317
No files matched your search
@@ -78,36 +78,30 @@ public class MutableDangerousField implements TlvComponentBase, IEncodingAble {
|
||||
try {
|
||||
// 如果可变非受保护区没有任何子 TLV,则可以去掉可变非受保护区 TLV
|
||||
if (this.blocks.length() == 0) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int totalLength = 0;
|
||||
// 编码TLV-VALUE
|
||||
// 反向遍历,可以保证解码的时候正向输出
|
||||
for (int i = this.blocks.length() - 1; i >= 0; i--) {
|
||||
int tmplen = 0;
|
||||
tmplen = encoder.prependBlock(this.blocks.getBlock(i));
|
||||
if (tmplen <= 0) {
|
||||
int tmplen = encoder.prependBlock(this.blocks.getBlock(i));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
}
|
||||
|
||||
// 编码 TLV-LENGTH
|
||||
int tmplen = 0;
|
||||
tmplen = encoder.prependVarNumber(new VlInt(totalLength));
|
||||
if (tmplen <= 0) {
|
||||
int tmplen = encoder.prependVarNumber(new VlInt(totalLength));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-TYPE
|
||||
try {
|
||||
tmplen = encoder.prependVarNumber(new VlInt(TLV.TlvMutableDangerousField));
|
||||
} catch (EncoderException e) {
|
||||
throw new ComponentException("MutableDangerousField.wireEncode: " + e.getMessage());
|
||||
}
|
||||
if (tmplen <= 0) {
|
||||
tmplen = encoder.prependVarNumber(new VlInt(TLV.TlvMutableDangerousField));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
Reference in new issue
Block a user