mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-06-18 07:10:25 +08:00
add component: ControlParameter*
This commit is contained in:
@@ -10,7 +10,6 @@ import encoding.*;
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class CongestionMark implements TlvComponentBase, InitialAble, IEncodingAble {
|
||||
// 成员变量 todo: 越界问题
|
||||
private long congestionMark;
|
||||
|
||||
public CongestionMark(){
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description: 表示一个控制命令参数 Capacity
|
||||
* @Version: 1.0.0
|
||||
* @Date: 17:25 2021/4/12
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class ControlParameterCapacity implements TlvComponentBase,InitialAble, IEncodingAble {
|
||||
private long capacity;
|
||||
|
||||
public long getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
public void setCapacity(long capacity) {
|
||||
this.capacity = capacity;
|
||||
this.doInitial();
|
||||
}
|
||||
|
||||
// 接口实现-变量区
|
||||
private boolean initial = false;
|
||||
|
||||
// 接口实现-方法区
|
||||
@Override
|
||||
public void doInitial() {
|
||||
initial = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 ControlParameterCapacity 线速编码为一个TLV
|
||||
* @param encoder
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) throws ComponentException{
|
||||
try {
|
||||
int totalLength = 0;
|
||||
|
||||
// 编码 TLV-VALUE
|
||||
int tmplen = encoder.prependNonNegativeInteger(this.capacity);
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-LENGTH
|
||||
tmplen += encoder.prependVarNumber(new VlInt(totalLength));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-TYPE
|
||||
tmplen += encoder.prependVarNumber(new VlInt(TLV.TlvManagementCapacity));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
return totalLength;
|
||||
} catch (EncoderException e) {
|
||||
throw new ComponentException("ControlParameterCapacity.wireEncode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 TLV Block 中解码出一个 ControlParameterCapacity
|
||||
* @param block
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public boolean wireDecode(Block block) throws ComponentException {
|
||||
try {
|
||||
// 检查 Type 是否正确
|
||||
if (!TLV.expectType(block.getType(), new VlInt(TLV.TlvManagementCapacity))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 读取 value
|
||||
long value = TLV.readNonNegativeInteger(block.getValue(), 0, block.getLength().getVlIntValue2Int());
|
||||
if (value < 0) {
|
||||
return false;
|
||||
}
|
||||
this.setCapacity(value);
|
||||
|
||||
return true;
|
||||
} catch (TLVException | VlIntException e) {
|
||||
throw new ComponentException("ControlParameterCapacity.wireDecode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description: 表示一个控制命令参数 Cost
|
||||
* @Version: 1.0.0
|
||||
* @Date: 19:32 2021/4/12
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class ControlParameterCost implements TlvComponentBase,InitialAble,IEncodingAble{
|
||||
private long cost;
|
||||
|
||||
public long getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
public void setCost(long cost) {
|
||||
this.cost = cost;
|
||||
this.doInitial();
|
||||
}
|
||||
|
||||
// 接口实现-变量区
|
||||
private boolean initial = false;
|
||||
|
||||
// 接口实现-方法区
|
||||
@Override
|
||||
public void doInitial() {
|
||||
initial = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 ControlParameterCost 线速编码为一个TLV
|
||||
* @param encoder
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) throws ComponentException{
|
||||
try {
|
||||
int totalLength = 0;
|
||||
|
||||
// 编码 TLV-VALUE
|
||||
int tmplen = encoder.prependNonNegativeInteger(this.cost);
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-LENGTH
|
||||
tmplen += encoder.prependVarNumber(new VlInt(totalLength));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-TYPE
|
||||
tmplen += encoder.prependVarNumber(new VlInt(TLV.TlvManagementCost));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
return totalLength;
|
||||
} catch (EncoderException e) {
|
||||
throw new ComponentException("ControlParameterCost.wireEncode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 TLV Block 中解码出一个 ControlParameterCost
|
||||
* @param block
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public boolean wireDecode(Block block) throws ComponentException {
|
||||
try {
|
||||
// 检查 Type 是否正确
|
||||
if (!TLV.expectType(block.getType(), new VlInt(TLV.TlvManagementCost))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 读取 value
|
||||
long value = TLV.readNonNegativeInteger(block.getValue(), 0, block.getLength().getVlIntValue2Int());
|
||||
if (value < 0) {
|
||||
return false;
|
||||
}
|
||||
this.setCost(value);
|
||||
|
||||
return true;
|
||||
} catch (TLVException | VlIntException e) {
|
||||
throw new ComponentException("ControlParameterCost.wireDecode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description: 表示一个控制命令参数 Count
|
||||
* @Version: 1.0.0
|
||||
* @Date: 19:36 2021/4/12
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class ControlParameterCount implements TlvComponentBase,InitialAble, IEncodingAble {
|
||||
private long count;
|
||||
|
||||
public long getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(long count) {
|
||||
this.count = count;
|
||||
this.doInitial();
|
||||
}
|
||||
|
||||
// 接口实现-变量区
|
||||
private boolean initial = false;
|
||||
|
||||
// 接口实现-方法区
|
||||
@Override
|
||||
public void doInitial() {
|
||||
initial = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 ControlParameterCount 线速编码为一个TLV
|
||||
* @param encoder
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) throws ComponentException{
|
||||
try {
|
||||
int totalLength = 0;
|
||||
|
||||
// 编码 TLV-VALUE
|
||||
int tmplen = encoder.prependNonNegativeInteger(this.count);
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-LENGTH
|
||||
tmplen += encoder.prependVarNumber(new VlInt(totalLength));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-TYPE
|
||||
tmplen += encoder.prependVarNumber(new VlInt(TLV.TlvManagementCount));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
return totalLength;
|
||||
} catch (EncoderException e) {
|
||||
throw new ComponentException("ControlParameterCount.wireEncode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 TLV Block 中解码出一个 ControlParameterCount
|
||||
* @param block
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public boolean wireDecode(Block block) throws ComponentException {
|
||||
try {
|
||||
// 检查 Type 是否正确
|
||||
if (!TLV.expectType(block.getType(), new VlInt(TLV.TlvManagementCount))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 读取 value
|
||||
long value = TLV.readNonNegativeInteger(block.getValue(), 0, block.getLength().getVlIntValue2Int());
|
||||
if (value < 0) {
|
||||
return false;
|
||||
}
|
||||
this.setCount(value);
|
||||
|
||||
return true;
|
||||
} catch (TLVException | VlIntException e) {
|
||||
throw new ComponentException("ControlParameterCount.wireDecode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description: 表示一个控制命令参数 ExpireTime
|
||||
* @Version: 1.0.0
|
||||
* @Date: 19:36 2021/4/12
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class ControlParameterExpireTime implements TlvComponentBase,InitialAble, IEncodingAble {
|
||||
private long expireTime;
|
||||
|
||||
public long getExpireTime() {
|
||||
return expireTime;
|
||||
}
|
||||
|
||||
public void setExpireTime(long expireTime) {
|
||||
this.expireTime = expireTime;
|
||||
this.doInitial();
|
||||
}
|
||||
|
||||
// 接口实现-变量区
|
||||
private boolean initial = false;
|
||||
|
||||
// 接口实现-方法区
|
||||
@Override
|
||||
public void doInitial() {
|
||||
initial = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 ControlParameterExpireTime 线速编码为一个TLV
|
||||
* @param encoder
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) throws ComponentException{
|
||||
try {
|
||||
int totalLength = 0;
|
||||
|
||||
// 编码 TLV-VALUE
|
||||
int tmplen = encoder.prependNonNegativeInteger(this.expireTime);
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-LENGTH
|
||||
tmplen += encoder.prependVarNumber(new VlInt(totalLength));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-TYPE
|
||||
tmplen += encoder.prependVarNumber(new VlInt(TLV.TlvManagementExpireTime));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
return totalLength;
|
||||
} catch (EncoderException e) {
|
||||
throw new ComponentException("ControlParameterExpireTime.wireEncode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 TLV Block 中解码出一个 ControlParameterExpireTime
|
||||
* @param block
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public boolean wireDecode(Block block) throws ComponentException {
|
||||
try {
|
||||
// 检查 Type 是否正确
|
||||
if (!TLV.expectType(block.getType(), new VlInt(TLV.TlvManagementExpireTime))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 读取 value
|
||||
long value = TLV.readNonNegativeInteger(block.getValue(), 0, block.getLength().getVlIntValue2Int());
|
||||
if (value < 0) {
|
||||
return false;
|
||||
}
|
||||
this.setExpireTime(value);
|
||||
|
||||
return true;
|
||||
} catch (TLVException | VlIntException e) {
|
||||
throw new ComponentException("ControlParameterExpireTime.wireDecode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description: 表示一个控制命令参数 Uri
|
||||
* @Version: 1.0.0
|
||||
* @Date: 19:43 2021/4/12
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class ControlParameterLocalUri implements TlvComponentBase, InitialAble, IEncodingAble {
|
||||
private String localUri;
|
||||
|
||||
public String getLocalUri() {
|
||||
return localUri;
|
||||
}
|
||||
|
||||
public void setLocalUri(String localUri) {
|
||||
this.localUri = localUri;
|
||||
this.doInitial();
|
||||
}
|
||||
|
||||
// 接口实现-变量区
|
||||
private boolean initial = false;
|
||||
|
||||
// 接口实现-方法区
|
||||
@Override
|
||||
public void doInitial() {
|
||||
initial = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 ControlParameterLocalUri 线速编码为一个TLV
|
||||
*
|
||||
* @param encoder
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) throws ComponentException {
|
||||
try {
|
||||
int totalLength = 0;
|
||||
|
||||
// 编码 TLV-VALUE
|
||||
byte[] strBytes = this.localUri.getBytes(StandardCharsets.UTF_8);
|
||||
int tmplen = encoder.prependByteArray(strBytes, new SizeT(strBytes.length));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-LENGTH
|
||||
tmplen += encoder.prependVarNumber(new VlInt(totalLength));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-TYPE
|
||||
tmplen += encoder.prependVarNumber(new VlInt(TLV.TlvManagementLocalUri));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
return totalLength;
|
||||
} catch (EncoderException e) {
|
||||
throw new ComponentException("ControlParameterLocalUri.wireEncode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 TLV Block 中解码出一个 ControlParameterLocalUri
|
||||
*
|
||||
* @param block
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public boolean wireDecode(Block block) throws ComponentException {
|
||||
// 检查 Type 是否正确
|
||||
if (!TLV.expectType(block.getType(), new VlInt(TLV.TlvManagementLocalUri))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.setLocalUri(new String(block.getValue()));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description: 表示一个控制命令参数 LogicFaceId
|
||||
* @Version: 1.0.0
|
||||
* @Date: 19:32 2021/4/12
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class ControlParameterLogicFaceId implements TlvComponentBase,InitialAble,IEncodingAble{
|
||||
private long logicFaceId;
|
||||
|
||||
public long getLogicFaceId() {
|
||||
return logicFaceId;
|
||||
}
|
||||
|
||||
public void setLogicFaceId(long logicFaceId) {
|
||||
this.logicFaceId = logicFaceId;
|
||||
this.doInitial();
|
||||
}
|
||||
|
||||
// 接口实现-变量区
|
||||
private boolean initial = false;
|
||||
|
||||
// 接口实现-方法区
|
||||
@Override
|
||||
public void doInitial() {
|
||||
initial = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 ControlParameterLogicFaceId 线速编码为一个TLV
|
||||
* @param encoder
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) throws ComponentException{
|
||||
try {
|
||||
int totalLength = 0;
|
||||
|
||||
// 编码 TLV-VALUE
|
||||
int tmplen = encoder.prependNonNegativeInteger(this.logicFaceId);
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-LENGTH
|
||||
tmplen += encoder.prependVarNumber(new VlInt(totalLength));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-TYPE
|
||||
tmplen += encoder.prependVarNumber(new VlInt(TLV.TlvManagementLogicFaceId));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
return totalLength;
|
||||
} catch (EncoderException e) {
|
||||
throw new ComponentException("ControlParameterLogicFaceId.wireEncode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 TLV Block 中解码出一个 ControlParameterLogicFaceId
|
||||
* @param block
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public boolean wireDecode(Block block) throws ComponentException {
|
||||
try {
|
||||
// 检查 Type 是否正确
|
||||
if (!TLV.expectType(block.getType(), new VlInt(TLV.TlvManagementLogicFaceId))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 读取 value
|
||||
long value = TLV.readNonNegativeInteger(block.getValue(), 0, block.getLength().getVlIntValue2Int());
|
||||
if (value < 0) {
|
||||
return false;
|
||||
}
|
||||
this.setLogicFaceId(value);
|
||||
|
||||
return true;
|
||||
} catch (TLVException | VlIntException e) {
|
||||
throw new ComponentException("ControlParameterLogicFaceId.wireDecode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description: 表示一个控制命令参数 LogicFacePersistency
|
||||
* @Version: 1.0.0
|
||||
* @Date: 19:54 2021/4/12
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class ControlParameterLogicFacePersistency implements TlvComponentBase,InitialAble, IEncodingAble {
|
||||
private long persistency;
|
||||
|
||||
public long getPersistency() {
|
||||
return persistency;
|
||||
}
|
||||
|
||||
public void setPersistency(long persistency) {
|
||||
this.persistency = persistency;
|
||||
this.doInitial();
|
||||
}
|
||||
|
||||
// 接口实现-变量区
|
||||
private boolean initial = false;
|
||||
|
||||
// 接口实现-方法区
|
||||
@Override
|
||||
public void doInitial() {
|
||||
initial = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 ControlParameterLogicFacePersistency 线速编码为一个TLV
|
||||
* @param encoder
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) throws ComponentException{
|
||||
try {
|
||||
int totalLength = 0;
|
||||
|
||||
// 编码 TLV-VALUE
|
||||
int tmplen = encoder.prependNonNegativeInteger(this.persistency);
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-LENGTH
|
||||
tmplen += encoder.prependVarNumber(new VlInt(totalLength));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-TYPE
|
||||
tmplen += encoder.prependVarNumber(new VlInt(TLV.TlvManagementLogicFacePersistency));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
return totalLength;
|
||||
} catch (EncoderException e) {
|
||||
throw new ComponentException("ControlParameterLogicFacePersistency.wireEncode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 TLV Block 中解码出一个 ControlParameterLogicFacePersistency
|
||||
* @param block
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public boolean wireDecode(Block block) throws ComponentException {
|
||||
try {
|
||||
// 检查 Type 是否正确
|
||||
if (!TLV.expectType(block.getType(), new VlInt(TLV.TlvManagementLogicFacePersistency))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 读取 value
|
||||
long value = TLV.readNonNegativeInteger(block.getValue(), 0, block.getLength().getVlIntValue2Int());
|
||||
if (value < 0) {
|
||||
return false;
|
||||
}
|
||||
this.setPersistency(value);
|
||||
|
||||
return true;
|
||||
} catch (TLVException | VlIntException e) {
|
||||
throw new ComponentException("ControlParameterLogicFacePersistency.wireDecode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description: 表示一个控制命令参数 Mtu
|
||||
* @Version: 1.0.0
|
||||
* @Date: 19:32 2021/4/12
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class ControlParameterMtu implements TlvComponentBase,InitialAble,IEncodingAble{
|
||||
private long mtu;
|
||||
|
||||
public long getMtu() {
|
||||
return mtu;
|
||||
}
|
||||
|
||||
public void setMtu(long mtu) {
|
||||
this.mtu = mtu;
|
||||
this.doInitial();
|
||||
}
|
||||
|
||||
// 接口实现-变量区
|
||||
private boolean initial = false;
|
||||
|
||||
// 接口实现-方法区
|
||||
@Override
|
||||
public void doInitial() {
|
||||
initial = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 ControlParameterMtu 线速编码为一个TLV
|
||||
* @param encoder
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) throws ComponentException{
|
||||
try {
|
||||
int totalLength = 0;
|
||||
|
||||
// 编码 TLV-VALUE
|
||||
int tmplen = encoder.prependNonNegativeInteger(this.mtu);
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-LENGTH
|
||||
tmplen += encoder.prependVarNumber(new VlInt(totalLength));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-TYPE
|
||||
tmplen += encoder.prependVarNumber(new VlInt(TLV.TlvManagementMtu));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
return totalLength;
|
||||
} catch (EncoderException e) {
|
||||
throw new ComponentException("ControlParameterMtu.wireEncode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 TLV Block 中解码出一个 ControlParameterMtu
|
||||
* @param block
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public boolean wireDecode(Block block) throws ComponentException {
|
||||
try {
|
||||
// 检查 Type 是否正确
|
||||
if (!TLV.expectType(block.getType(), new VlInt(TLV.TlvManagementMtu))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 读取 value
|
||||
long value = TLV.readNonNegativeInteger(block.getValue(), 0, block.getLength().getVlIntValue2Int());
|
||||
if (value < 0) {
|
||||
return false;
|
||||
}
|
||||
this.setMtu(value);
|
||||
|
||||
return true;
|
||||
} catch (TLVException | VlIntException e) {
|
||||
throw new ComponentException("ControlParameterMtu.wireDecode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description: 表示一个控制命令参数 Prefix
|
||||
* @Version: 1.0.0
|
||||
* @Date: 20:04 2021/4/12
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class ControlParameterPrefix implements TlvComponentBase,InitialAble, IEncodingAble {
|
||||
private Identifier prefix;
|
||||
|
||||
public Identifier getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(Identifier prefix) {
|
||||
this.prefix = prefix;
|
||||
this.doInitial();
|
||||
}
|
||||
|
||||
// 接口实现-变量区
|
||||
private boolean initial = false;
|
||||
|
||||
// 接口实现-方法区
|
||||
@Override
|
||||
public void doInitial() {
|
||||
initial = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 ControlParameterPrefix 线速编码为一个TLV
|
||||
* @param encoder
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) throws ComponentException{
|
||||
try {
|
||||
int totalLength = 0;
|
||||
|
||||
// 编码 TLV-VALUE
|
||||
int tmplen = this.prefix.wireEncode(encoder);
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-LENGTH
|
||||
tmplen += encoder.prependVarNumber(new VlInt(totalLength));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-TYPE
|
||||
tmplen += encoder.prependVarNumber(new VlInt(TLV.TlvManagementPrefix));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
return totalLength;
|
||||
} catch (EncoderException e) {
|
||||
throw new ComponentException("ControlParameterPrefix.wireEncode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 TLV Block 中解码出一个 ControlParameterPrefix
|
||||
* @param block
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public boolean wireDecode(Block block) throws ComponentException {
|
||||
try {
|
||||
// 检查 Type 是否正确
|
||||
if (!TLV.expectType(block.getType(), new VlInt(TLV.TlvManagementPrefix))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 解析子 Block
|
||||
if(!block.parseSubElements()){
|
||||
return false;
|
||||
}
|
||||
|
||||
Identifier identifier = new Identifier();
|
||||
if(!identifier.wireDecode(block.getElement(new VlInt(TLV.TlvIdentifier)))){
|
||||
return false;
|
||||
}
|
||||
this.setPrefix(identifier);
|
||||
|
||||
return true;
|
||||
} catch (BlockException e) {
|
||||
throw new ComponentException("ControlParameterPrefix.wireDecode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description: 表示一个控制命令参数 Uri
|
||||
* @Version: 1.0.0
|
||||
* @Date: 19:43 2021/4/12
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class ControlParameterUri implements TlvComponentBase, InitialAble, IEncodingAble {
|
||||
private String uri;
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
this.doInitial();
|
||||
}
|
||||
|
||||
// 接口实现-变量区
|
||||
private boolean initial = false;
|
||||
|
||||
// 接口实现-方法区
|
||||
@Override
|
||||
public void doInitial() {
|
||||
initial = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 ControlParameterUri 线速编码为一个TLV
|
||||
*
|
||||
* @param encoder
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) throws ComponentException {
|
||||
try {
|
||||
int totalLength = 0;
|
||||
|
||||
// 编码 TLV-VALUE
|
||||
byte[] strBytes = this.uri.getBytes(StandardCharsets.UTF_8);
|
||||
int tmplen = encoder.prependByteArray(strBytes, new SizeT(strBytes.length));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-LENGTH
|
||||
tmplen += encoder.prependVarNumber(new VlInt(totalLength));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-TYPE
|
||||
tmplen += encoder.prependVarNumber(new VlInt(TLV.TlvManagementUri));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
return totalLength;
|
||||
} catch (EncoderException e) {
|
||||
throw new ComponentException("ControlParameterUri.wireEncode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 TLV Block 中解码出一个 ControlParameterUri
|
||||
*
|
||||
* @param block
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public boolean wireDecode(Block block) throws ComponentException {
|
||||
// 检查 Type 是否正确
|
||||
if (!TLV.expectType(block.getType(), new VlInt(TLV.TlvManagementUri))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.setUri(new String(block.getValue()));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package component;
|
||||
|
||||
import encoding.*;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description: 表示一个控制命令参数 UriScheme
|
||||
* @Version: 1.0.0
|
||||
* @Date: 19:32 2021/4/12
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class ControlParameterUriScheme implements TlvComponentBase,InitialAble,IEncodingAble{
|
||||
private long uriScheme;
|
||||
|
||||
public long getUriScheme() {
|
||||
return uriScheme;
|
||||
}
|
||||
|
||||
public void setUriScheme(long uriScheme) {
|
||||
this.uriScheme = uriScheme;
|
||||
this.doInitial();
|
||||
}
|
||||
|
||||
// 接口实现-变量区
|
||||
private boolean initial = false;
|
||||
|
||||
// 接口实现-方法区
|
||||
@Override
|
||||
public void doInitial() {
|
||||
initial = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 ControlParameterUriScheme 线速编码为一个TLV
|
||||
* @param encoder
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public int wireEncode(Encoder encoder) throws ComponentException{
|
||||
try {
|
||||
int totalLength = 0;
|
||||
|
||||
// 编码 TLV-VALUE
|
||||
int tmplen = encoder.prependNonNegativeInteger(this.uriScheme);
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-LENGTH
|
||||
tmplen += encoder.prependVarNumber(new VlInt(totalLength));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
// 编码 TLV-TYPE
|
||||
tmplen += encoder.prependVarNumber(new VlInt(TLV.TlvManagementUriScheme));
|
||||
if (tmplen < 0) {
|
||||
return -1;
|
||||
}
|
||||
totalLength += tmplen;
|
||||
|
||||
return totalLength;
|
||||
} catch (EncoderException e) {
|
||||
throw new ComponentException("ControlParameterUriScheme.wireEncode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 TLV Block 中解码出一个 ControlParameterUriScheme
|
||||
* @param block
|
||||
* @return
|
||||
* @throws ComponentException
|
||||
*/
|
||||
@Override
|
||||
public boolean wireDecode(Block block) throws ComponentException {
|
||||
try {
|
||||
// 检查 Type 是否正确
|
||||
if (!TLV.expectType(block.getType(), new VlInt(TLV.TlvManagementUriScheme))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 读取 value
|
||||
long value = TLV.readNonNegativeInteger(block.getValue(), 0, block.getLength().getVlIntValue2Int());
|
||||
if (value < 0) {
|
||||
return false;
|
||||
}
|
||||
this.setUriScheme(value);
|
||||
|
||||
return true;
|
||||
} catch (TLVException | VlIntException e) {
|
||||
throw new ComponentException("ControlParameterUriScheme.wireDecode: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,17 +53,33 @@ public class TLV {
|
||||
public static final int TlvTTL = 212; // Time to live
|
||||
public static final int TlvNackHeader = 213; // Nack header
|
||||
|
||||
// 管理通信协议(old version)
|
||||
// public static final int TlvSliceNumber = 211; // 分片数量
|
||||
// public static final int TlvSliceSize = 212; // 分片大小
|
||||
// public static final int TlvTlvLogicFaceId = 213; // 逻辑接口id
|
||||
// public static final int TlvRemoteAddr = 214; // 源端地址
|
||||
// public static final int TlvLocalAddr = 215; // 本地地址
|
||||
// public static final int TlvMtu = 216; // 最大传输单元
|
||||
// public static final int TlvRet = 217; // bool类型,成功或失败
|
||||
// public static final int TlvOrigin = 218; //
|
||||
// public static final int TlvCost = 219; // 链路开销
|
||||
// public static final int TlvExpires = 220; // LogicFace超时时间,-1为不超时(never)
|
||||
|
||||
// 管理通信协议
|
||||
public static final int TlvSliceNumber = 211; // 分片数量
|
||||
public static final int TlvSliceSize = 212; // 分片大小
|
||||
public static final int TlvTlvLogicFaceId = 213; // 逻辑接口id
|
||||
public static final int TlvRemoteAddr = 214; // 源端地址
|
||||
public static final int TlvLocalAddr = 215; // 本地地址
|
||||
public static final int TlvMtu = 216; // 最大传输单元
|
||||
public static final int TlvRet = 217; // bool类型,成功或失败
|
||||
public static final int TlvOrigin = 218; //
|
||||
public static final int TlvCost = 219; // 链路开销
|
||||
public static final int TlvExpires = 220; // LogicFace超时时间,-1为不超时(never)
|
||||
public static final int TlvManagementControlParameters = 220; // 控制命令参数
|
||||
public static final int TlvManagementLogicFaceId = 221; // 逻辑接口Id
|
||||
public static final int TlvManagementUri = 222; // 逻辑接口地址,例如: tcp://192.168.1.1:13899,存在localUri时,也可表示remoteUri
|
||||
|
||||
// 管理通信协议 -> LogicFaceManager
|
||||
public static final int TlvManagementCost = 223; // 链路开销
|
||||
public static final int TlvManagementLogicFacePersistency = 224; // 逻辑接口持久性
|
||||
public static final int TlvManagementUriScheme = 225; // 逻辑接口地址采用的模式,例如:tcp
|
||||
public static final int TlvManagementMtu = 226; // 最大传输单元
|
||||
public static final int TlvManagementCapacity = 227; // CS容量
|
||||
public static final int TlvManagementCount = 228; // 删除的CS条目的数量
|
||||
public static final int TlvManagementExpireTime = 229; // 超时时间
|
||||
public static final int TlvManagementLocalUri = 230; // 逻辑接口地址,例如: tcp://192.168.1.1:13899,存在localUri时,也可表示remoteUri
|
||||
public static final int TlvManagementPrefix = 240; // 前缀
|
||||
|
||||
// LpPacket
|
||||
public static final int TlvLpPacket = 250; // LpPacket
|
||||
|
||||
Reference in New Issue
Block a user