use of org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator in project bgpcep by opendaylight.
the class PcRptMessageCodecTest method setUp.
@Before
public void setUp() {
this.ctx = new SimplePCEPExtensionProviderContext();
this.act = new BaseParserExtensionActivator();
this.act.start(this.ctx);
this.statefulAct = new StatefulActivator();
this.statefulAct.start(this.ctx);
this.autoBwActivator = new org.opendaylight.protocol.pcep.auto.bandwidth.extension.Activator(5);
this.autoBwActivator.start(this.ctx);
}
use of org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator in project bgpcep by opendaylight.
the class Main method main.
public static void main(final String[] args) throws UnknownHostException, InterruptedException, ExecutionException {
if (args.length == 0 || (args.length == 1 && args[0].equalsIgnoreCase("--help"))) {
LOG.info(Main.USAGE);
return;
}
InetSocketAddress address = null;
int keepAliveValue = KA_DEFAULT;
int deadTimerValue = 0;
boolean stateful = false;
boolean active = false;
boolean instant = false;
int pos = 0;
while (pos < args.length) {
if (args[pos].equalsIgnoreCase("-a") || args[pos].equalsIgnoreCase("--address")) {
final String[] ip = args[pos + 1].split(":");
address = new InetSocketAddress(InetAddress.getByName(ip[0]), Integer.parseInt(ip[1]));
pos++;
} else if (args[pos].equalsIgnoreCase("-d") || args[pos].equalsIgnoreCase("--deadtimer")) {
deadTimerValue = Integer.parseInt(args[pos + 1]);
pos++;
} else if (args[pos].equalsIgnoreCase("-ka") || args[pos].equalsIgnoreCase("--keepalive")) {
keepAliveValue = Integer.parseInt(args[pos + 1]);
pos++;
} else if (args[pos].equalsIgnoreCase("--stateful")) {
stateful = true;
} else if (args[pos].equalsIgnoreCase("--active")) {
stateful = true;
active = true;
} else if (args[pos].equalsIgnoreCase("--instant")) {
stateful = true;
instant = true;
} else {
LOG.warn("WARNING: Unrecognized argument: {}", args[pos]);
}
pos++;
}
if (deadTimerValue != 0 && deadTimerValue != keepAliveValue * KA_TO_DEADTIMER_RATIO) {
LOG.warn("WARNING: The value of DeadTimer should be 4 times the value of KeepAlive.");
}
if (deadTimerValue == 0) {
deadTimerValue = keepAliveValue * KA_TO_DEADTIMER_RATIO;
}
final List<PCEPCapability> caps = new ArrayList<>();
caps.add(new PCEPStatefulCapability(stateful, active, instant, false, false, false, false));
final PCEPSessionProposalFactory spf = new BasePCEPSessionProposalFactory(deadTimerValue, keepAliveValue, caps);
try (StatefulActivator activator07 = new StatefulActivator()) {
activator07.start(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance());
final PCEPDispatcherImpl dispatcher = new PCEPDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry(), new DefaultPCEPSessionNegotiatorFactory(spf, MAX_UNKNOWN_MESSAGES), new NioEventLoopGroup(), new NioEventLoopGroup());
dispatcher.createServer(new TestToolPCEPDispatcherDependencies(address)).get();
}
}
use of org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testLspObjectWithTLV.
@Test
public void testLspObjectWithTLV() throws IOException, PCEPDeserializerException {
try (StatefulActivator a = new StatefulActivator();
SyncOptimizationsActivator a2 = new SyncOptimizationsActivator()) {
a.start(this.ctx);
a2.start(this.ctx);
final SyncOptimizationsLspObjectParser parser = new SyncOptimizationsLspObjectParser(this.ctx.getTlvHandlerRegistry(), this.ctx.getVendorInformationTlvRegistry());
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspObject1WithTLV.bin"));
final LspBuilder builder = new LspBuilder();
builder.setProcessingRule(true);
builder.setIgnore(true);
builder.setAdministrative(true);
builder.setDelegate(false);
builder.setRemove(true);
builder.setSync(false);
builder.addAugmentation(Lsp1.class, new Lsp1Builder().setCreate(false).build());
builder.setOperational(OperationalStatus.GoingDown);
builder.setPlspId(new PlspId(0x12345L));
final LspErrorCode tlv1 = new LspErrorCodeBuilder().setErrorCode(627610883L).build();
final SymbolicPathName tlv2 = new SymbolicPathNameBuilder().setPathName(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SymbolicPathName("Med".getBytes())).build();
final LspDbVersion lspDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(new BigInteger(DB_VERSION)).build();
builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.TlvsBuilder().setLspErrorCode(tlv1).setSymbolicPathName(tlv2).addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1Builder().setLspDbVersion(lspDbVersion).build()).build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
}
use of org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator in project bgpcep by opendaylight.
the class PCEPValidatorTest method testOpenMsg.
@Test
public void testOpenMsg() throws IOException, PCEPDeserializerException {
try (StatefulActivator a = new StatefulActivator()) {
a.start(this.ctx);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenMessage1.bin"));
final PCEPOpenMessageParser parser = new PCEPOpenMessageParser(this.ctx.getObjectHandlerRegistry());
final OpenMessageBuilder builder = new OpenMessageBuilder();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder b = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder();
b.setProcessingRule(false);
b.setIgnore(false);
b.setVersion(new ProtocolVersion((short) 1));
b.setKeepalive((short) 30);
b.setDeadTimer((short) 120);
b.setSessionId((short) 1);
final Stateful tlv1 = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).build();
b.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().addAugmentation(Tlvs1.class, new Tlvs1Builder().setStateful(tlv1).build()).build());
builder.setOpen(b.build());
assertEquals(new OpenBuilder().setOpenMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new OpenBuilder().setOpenMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
}
use of org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator in project bgpcep by opendaylight.
the class PCEPValidatorTest method testErrorMsg.
@Test
public void testErrorMsg() throws IOException, PCEPDeserializerException {
try (StatefulActivator a = new StatefulActivator()) {
a.start(this.ctx);
final Stateful07ErrorMessageParser parser = new Stateful07ErrorMessageParser(this.ctx.getObjectHandlerRegistry());
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCErr.1.bin"));
ErrorObject error1 = new ErrorObjectBuilder().setIgnore(false).setProcessingRule(false).setType((short) 19).setValue((short) 1).build();
List<Errors> innerErr = new ArrayList<>();
innerErr.add(new ErrorsBuilder().setErrorObject(error1).build());
PcerrMessageBuilder builder = new PcerrMessageBuilder();
builder.setErrors(innerErr);
final List<Srps> srps = new ArrayList<>();
srps.add(new SrpsBuilder().setSrp(new SrpBuilder().setOperationId(new SrpIdNumber(3L)).setIgnore(false).setProcessingRule(false).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.srp.TlvsBuilder().build()).build()).build());
builder.setErrorType(new StatefulCaseBuilder().setStateful(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcerr.pcerr.message.error.type.stateful._case.StatefulBuilder().setSrps(srps).build()).build());
assertEquals(new PcerrBuilder().setPcerrMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcerrBuilder().setPcerrMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCErr.5.bin"));
error1 = new ErrorObjectBuilder().setIgnore(false).setProcessingRule(false).setType((short) 3).setValue((short) 1).build();
innerErr = new ArrayList<>();
builder = new PcerrMessageBuilder();
final RpBuilder rpBuilder = new RpBuilder();
rpBuilder.setProcessingRule(true);
rpBuilder.setIgnore(false);
rpBuilder.setReoptimization(false);
rpBuilder.setBiDirectional(false);
rpBuilder.setLoose(true);
rpBuilder.setMakeBeforeBreak(false);
rpBuilder.setOrder(false);
rpBuilder.setPathKey(false);
rpBuilder.setSupplyOf(false);
rpBuilder.setFragmentation(false);
rpBuilder.setP2mp(false);
rpBuilder.setEroCompression(false);
rpBuilder.setPriority((short) 1);
rpBuilder.setRequestId(new RequestId(10L));
rpBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder().build());
rpBuilder.setProcessingRule(false);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.request._case.request.Rps> rps = Lists.newArrayList();
rps.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.request._case.request.RpsBuilder().setRp(rpBuilder.build()).build());
innerErr.add(new ErrorsBuilder().setErrorObject(error1).build());
builder.setErrors(innerErr);
builder.setErrorType(new RequestCaseBuilder().setRequest(new RequestBuilder().setRps(rps).build()).build());
assertEquals(new PcerrBuilder().setPcerrMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcerrBuilder().setPcerrMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCErr.3.bin"));
builder = new PcerrMessageBuilder();
error1 = new ErrorObjectBuilder().setIgnore(false).setProcessingRule(false).setType((short) 3).setValue((short) 1).build();
innerErr = new ArrayList<>();
innerErr.add(new ErrorsBuilder().setErrorObject(error1).build());
builder.setErrors(innerErr);
builder.setErrorType(new SessionCaseBuilder().setSession(new SessionBuilder().setOpen(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder().setDeadTimer((short) 1).setKeepalive((short) 1).setVersion(new ProtocolVersion((short) 1)).setSessionId((short) 0).setIgnore(false).setProcessingRule(false).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().build()).build()).build()).build());
assertEquals(new PcerrBuilder().setPcerrMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcerrBuilder().setPcerrMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
}
Aggregations