mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
writting lpPacket...
This commit is contained in:
1 parent
036c4d3dc9
commit
fa3647f721
14 files changed
+553
-147
No files matched your search
@@ -33,12 +33,12 @@ import encoding.*;
|
||||
// }
|
||||
//
|
||||
public class Data implements IEncodingAble, InteractWithField {
|
||||
private MINPacket minPacket;
|
||||
private FreshnessPeriod freshnessPeriod;
|
||||
private Payload payload;
|
||||
private CongestionMark congestionMark;
|
||||
private NackHeader nackHeader;
|
||||
private Identifier name;
|
||||
public MINPacket minPacket=new MINPacket();
|
||||
public FreshnessPeriod freshnessPeriod=new FreshnessPeriod();
|
||||
public Payload payload=new Payload();
|
||||
public CongestionMark congestionMark=new CongestionMark();
|
||||
public NackHeader nackHeader=new NackHeader();
|
||||
public Identifier name=new Identifier();
|
||||
|
||||
/**
|
||||
* 展示数据包的 URI
|
||||
@@ -88,9 +88,7 @@ public class Data implements IEncodingAble, InteractWithField {
|
||||
this.minPacket.mutableField.mutableProtectField.clearBlocks();
|
||||
|
||||
// CongestionMark
|
||||
Block block = null;
|
||||
block = new SelfEncodingBase().selfWireEncode(this.congestionMark);
|
||||
|
||||
Block block = new SelfEncodingBase().selfWireEncode(this.congestionMark);
|
||||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -110,11 +108,7 @@ public class Data implements IEncodingAble, InteractWithField {
|
||||
|
||||
// FreshnessPeriod
|
||||
if (this.freshnessPeriod.isInitial()) {
|
||||
try {
|
||||
block = new SelfEncodingBase().selfWireEncode(this.freshnessPeriod);
|
||||
} catch (EncoderException | BlockException | ComponentException e) {
|
||||
throw new PacketException("Data.fillDataToFields: " + e.getMessage());
|
||||
}
|
||||
block = new SelfEncodingBase().selfWireEncode(this.freshnessPeriod);
|
||||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -123,11 +117,7 @@ public class Data implements IEncodingAble, InteractWithField {
|
||||
|
||||
// NackHeader
|
||||
if (this.nackHeader.isInitial()) {
|
||||
try {
|
||||
block = new SelfEncodingBase().selfWireEncode(this.nackHeader);
|
||||
} catch (EncoderException | BlockException | ComponentException e) {
|
||||
throw new PacketException("Data.fillDataToFields: " + e.getMessage());
|
||||
}
|
||||
block = new SelfEncodingBase().selfWireEncode(this.nackHeader);
|
||||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -135,11 +125,7 @@ public class Data implements IEncodingAble, InteractWithField {
|
||||
}
|
||||
|
||||
// Payload
|
||||
try {
|
||||
block = new SelfEncodingBase().selfWireEncode(this.payload);
|
||||
} catch (EncoderException | BlockException | ComponentException e) {
|
||||
throw new PacketException("Data.fillDataToFields: " + e.getMessage());
|
||||
}
|
||||
block = new SelfEncodingBase().selfWireEncode(this.payload);
|
||||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -186,7 +172,6 @@ public class Data implements IEncodingAble, InteractWithField {
|
||||
if (!this.congestionMark.wireDecode(block)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
@@ -199,14 +184,8 @@ public class Data implements IEncodingAble, InteractWithField {
|
||||
ElementContainer elementContainer = this.minPacket.readOnlyField.getBlocks();
|
||||
int len = elementContainer.length();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Block newblock = null;
|
||||
try {
|
||||
newblock = elementContainer.getBlock(i);
|
||||
} catch (BlockException e) {
|
||||
throw new PacketException("Data.extraDataFromFields: " + e.getMessage());
|
||||
}
|
||||
int type;
|
||||
type = newblock.getType().getVlIntValue2Int();
|
||||
Block newblock = elementContainer.getBlock(i);
|
||||
int type = newblock.getType().getVlIntValue2Int();
|
||||
switch (type) {
|
||||
case TLV.TlvFreshnessPeriod:
|
||||
if (!this.freshnessPeriod.wireDecode(newblock)) {
|
||||
@@ -235,7 +214,7 @@ public class Data implements IEncodingAble, InteractWithField {
|
||||
this.setName(interestIdentifierWrapper.getIdentifier());
|
||||
|
||||
return true;
|
||||
} catch (ComponentException | VlIntException e) {
|
||||
} catch (ComponentException | VlIntException | BlockException e) {
|
||||
throw new PacketException("Data.extraDataFromFields: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user