mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-06-18 03:40:25 +08:00
add logicface: MgmtCommand
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package logicface;
|
||||
|
||||
import component.*;
|
||||
import encoding.Encoder;
|
||||
import encoding.EncoderException;
|
||||
import encoding.SizeT;
|
||||
import mgmt.ControlParameters;
|
||||
import mgmt.MgmtException;
|
||||
import packet.Interest;
|
||||
|
||||
/*
|
||||
* @Author: Wang Feng
|
||||
* @Description:
|
||||
* @Version: 1.0.0
|
||||
* @Date: 15:39 2021/4/16
|
||||
* @Copyright: MIN-Group;国家重大科技基础设施——未来网络北大实验室;深圳市信息论与未来网络重点实验室
|
||||
*/
|
||||
public class MgmtCommand {
|
||||
/**
|
||||
*
|
||||
* @param identifier
|
||||
* @return
|
||||
*/
|
||||
public static Interest createRegisterIdentifierInterest(Identifier identifier) throws LogicFaceException {
|
||||
try {
|
||||
// /min-mir/mgmt/localhop/<模块名称>/<命令>/<参数>/[版本号]/[分片号]
|
||||
Interest interest=new Interest();
|
||||
IdentifierComponentContainer componentContainer=new IdentifierComponentContainer();
|
||||
componentContainer.addElement(new IdentifierComponent("min-mir"));
|
||||
componentContainer.addElement(new IdentifierComponent("mgmt"));
|
||||
componentContainer.addElement(new IdentifierComponent("localhop"));
|
||||
componentContainer.addElement(new IdentifierComponent("fib-mgmt"));
|
||||
componentContainer.addElement(new IdentifierComponent("add-next-hop"));
|
||||
|
||||
ControlParameters controlParameters=new ControlParameters();
|
||||
controlParameters.controlParameterPrefix.setPrefix(identifier);
|
||||
controlParameters.controlParameterCost.setCost(25);
|
||||
|
||||
Encoder encoder=new Encoder();
|
||||
if(!encoder.encoderReset(new SizeT(Encoder.MaxPacketSize),new SizeT(0))){
|
||||
return null;
|
||||
}
|
||||
if(controlParameters.wireEncode(encoder)<0){
|
||||
return null;
|
||||
}
|
||||
byte[] controlParametersbuf=encoder.getBuffer();
|
||||
componentContainer.addElement(new IdentifierComponent(controlParametersbuf));
|
||||
Identifier commandIdentifier=new Identifier(componentContainer);
|
||||
interest.setName(commandIdentifier);
|
||||
return interest;
|
||||
} catch (EncoderException | MgmtException | ComponentException e) {
|
||||
throw new LogicFaceException("MgmtCommand.createRegisterIdentifierInterest: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user