mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
update some code
This commit is contained in:
1 parent
cb79358683
commit
3898220a5c
1 file changed
+15
-9
@@ -115,6 +115,20 @@ public class Interest implements InteractWithField, IEncodingAble {
|
|||||||
this.name = identifier;
|
this.name = identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用字符串设置兴趣包的名字
|
||||||
|
* @param name
|
||||||
|
* @throws PacketException
|
||||||
|
*/
|
||||||
|
public void setNameByString(String name) throws PacketException {
|
||||||
|
try {
|
||||||
|
Identifier identifier = new Identifier(name);
|
||||||
|
this.setName(identifier);
|
||||||
|
} catch (ComponentException e) {
|
||||||
|
throw new PacketException("Interest.setNameByString: "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断一个指定的名字和当前的兴趣包的名字是否匹配
|
* 判断一个指定的名字和当前的兴趣包的名字是否匹配
|
||||||
*
|
*
|
||||||
@@ -198,7 +212,6 @@ public class Interest implements InteractWithField, IEncodingAble {
|
|||||||
|
|
||||||
// 填充可变受保护区
|
// 填充可变受保护区
|
||||||
minPacket.mutableField.mutableProtectField.clearBlocks();
|
minPacket.mutableField.mutableProtectField.clearBlocks();
|
||||||
|
|
||||||
// CongestionMark
|
// CongestionMark
|
||||||
Block block = new SelfEncodingBase().selfWireEncode(this.congestionMark);
|
Block block = new SelfEncodingBase().selfWireEncode(this.congestionMark);
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
@@ -206,7 +219,7 @@ public class Interest implements InteractWithField, IEncodingAble {
|
|||||||
}
|
}
|
||||||
minPacket.mutableField.mutableProtectField.addBlock(block);
|
minPacket.mutableField.mutableProtectField.addBlock(block);
|
||||||
|
|
||||||
// 填充可变非受保护区(无)
|
// 填充可变非受保护区
|
||||||
minPacket.mutableField.mutableDangerousField.clearBlocks();
|
minPacket.mutableField.mutableDangerousField.clearBlocks();
|
||||||
// ttl
|
// ttl
|
||||||
block = new SelfEncodingBase().selfWireEncode(this.ttl);
|
block = new SelfEncodingBase().selfWireEncode(this.ttl);
|
||||||
@@ -227,7 +240,6 @@ public class Interest implements InteractWithField, IEncodingAble {
|
|||||||
//// 填充只读区
|
//// 填充只读区
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
minPacket.readOnlyField.clearBlocks();
|
minPacket.readOnlyField.clearBlocks();
|
||||||
|
|
||||||
// CanBePrefix
|
// CanBePrefix
|
||||||
if (this.canBePrefix.getCanBePrefix()) {
|
if (this.canBePrefix.getCanBePrefix()) {
|
||||||
block = new SelfEncodingBase().selfWireEncode(this.canBePrefix);
|
block = new SelfEncodingBase().selfWireEncode(this.canBePrefix);
|
||||||
@@ -236,7 +248,6 @@ public class Interest implements InteractWithField, IEncodingAble {
|
|||||||
}
|
}
|
||||||
minPacket.readOnlyField.addBlock(block);
|
minPacket.readOnlyField.addBlock(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MustBeRefresh
|
// MustBeRefresh
|
||||||
if (this.mustBeRefresh.getMustBeRefresh()) {
|
if (this.mustBeRefresh.getMustBeRefresh()) {
|
||||||
block = new SelfEncodingBase().selfWireEncode(this.mustBeRefresh);
|
block = new SelfEncodingBase().selfWireEncode(this.mustBeRefresh);
|
||||||
@@ -245,7 +256,6 @@ public class Interest implements InteractWithField, IEncodingAble {
|
|||||||
}
|
}
|
||||||
minPacket.readOnlyField.addBlock(block);
|
minPacket.readOnlyField.addBlock(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
// InterestLifeTime
|
// InterestLifeTime
|
||||||
if (!this.interestLifeTime.isInitial()) {
|
if (!this.interestLifeTime.isInitial()) {
|
||||||
// 默认生存期为4s
|
// 默认生存期为4s
|
||||||
@@ -256,7 +266,6 @@ public class Interest implements InteractWithField, IEncodingAble {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
minPacket.readOnlyField.addBlock(block);
|
minPacket.readOnlyField.addBlock(block);
|
||||||
|
|
||||||
// Nonce
|
// Nonce
|
||||||
if (!this.nonce.isInitial()) {
|
if (!this.nonce.isInitial()) {
|
||||||
// 如果没有指定随机数,随机生成一个随机数
|
// 如果没有指定随机数,随机生成一个随机数
|
||||||
@@ -267,7 +276,6 @@ public class Interest implements InteractWithField, IEncodingAble {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
minPacket.readOnlyField.addBlock(block);
|
minPacket.readOnlyField.addBlock(block);
|
||||||
|
|
||||||
// HopLimit
|
// HopLimit
|
||||||
if (this.hopLimit.isInitial()) {
|
if (this.hopLimit.isInitial()) {
|
||||||
block = new SelfEncodingBase().selfWireEncode(this.hopLimit);
|
block = new SelfEncodingBase().selfWireEncode(this.hopLimit);
|
||||||
@@ -276,7 +284,6 @@ public class Interest implements InteractWithField, IEncodingAble {
|
|||||||
}
|
}
|
||||||
minPacket.readOnlyField.addBlock(block);
|
minPacket.readOnlyField.addBlock(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NackHeader
|
// NackHeader
|
||||||
if(this.nackHeader.isInitial()){
|
if(this.nackHeader.isInitial()){
|
||||||
block = new SelfEncodingBase().selfWireEncode(this.nackHeader);
|
block = new SelfEncodingBase().selfWireEncode(this.nackHeader);
|
||||||
@@ -285,7 +292,6 @@ public class Interest implements InteractWithField, IEncodingAble {
|
|||||||
}
|
}
|
||||||
minPacket.readOnlyField.addBlock(block);
|
minPacket.readOnlyField.addBlock(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Payload
|
// Payload
|
||||||
// if (this.payload.getValue() != null){
|
// if (this.payload.getValue() != null){
|
||||||
block = new SelfEncodingBase().selfWireEncode(this.payload);
|
block = new SelfEncodingBase().selfWireEncode(this.payload);
|
||||||
|
|||||||
Reference in new issue
Block a user