Search in sources :

Example 6 with StatefulActivator

use of org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator in project bgpcep by opendaylight.

the class PCEPValidatorTest method testMissingLspObjectErrorInPcRptMsg.

@Test
public void testMissingLspObjectErrorInPcRptMsg() throws PCEPDeserializerException {
    final byte[] statefulMsg = { (byte) 0x20, (byte) 0x0B, (byte) 0x00, (byte) 0x1C, /* srp-object */
    (byte) 0x21, (byte) 0x10, (byte) 0x00, (byte) 0x0C, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x001, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, /* sr-ero-object */
    (byte) 0x07, (byte) 0x10, (byte) 0x00, (byte) 0x0C, /* ipv4 prefix subobject */
    (byte) 0x81, (byte) 0x08, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x16, (byte) 0x00 };
    try (CrabbeInitiatedActivator a = new CrabbeInitiatedActivator();
        StatefulActivator b = new StatefulActivator()) {
        a.start(this.ctx);
        b.start(this.ctx);
        final Stateful07PCReportMessageParser parser = new Stateful07PCReportMessageParser(this.ctx.getObjectHandlerRegistry());
        final PcerrMessageBuilder errMsgBuilder = new PcerrMessageBuilder();
        errMsgBuilder.setErrors(Lists.newArrayList(new ErrorsBuilder().setErrorObject(new ErrorObjectBuilder().setType((short) 6).setValue((short) 8).build()).build()));
        final PcerrBuilder builder = new PcerrBuilder();
        builder.setPcerrMessage(errMsgBuilder.build());
        final ByteBuf buf = Unpooled.wrappedBuffer(statefulMsg);
        final List<Message> errors = Lists.newArrayList();
        parser.parseMessage(buf.slice(4, buf.readableBytes() - 4), errors);
        assertFalse(errors.isEmpty());
        assertEquals(builder.build(), errors.get(0));
    }
}
Also used : StatefulActivator(org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator) Stateful07PCReportMessageParser(org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07PCReportMessageParser) PcerrBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message) ErrorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder) ByteBuf(io.netty.buffer.ByteBuf) CrabbeInitiatedActivator(org.opendaylight.protocol.pcep.ietf.initiated00.CrabbeInitiatedActivator) PcerrMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessageBuilder) ErrorObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObjectBuilder) Test(org.junit.Test)

Example 7 with StatefulActivator

use of org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator in project bgpcep by opendaylight.

the class PCEPValidatorTest method testRptMsg.

@Test
public void testRptMsg() throws IOException, PCEPDeserializerException {
    try (CrabbeInitiatedActivator a = new CrabbeInitiatedActivator();
        StatefulActivator b = new StatefulActivator()) {
        a.start(this.ctx);
        b.start(this.ctx);
        ByteBuf result = Unpooled.wrappedBuffer(PCRT1);
        final Stateful07PCReportMessageParser parser = new Stateful07PCReportMessageParser(this.ctx.getObjectHandlerRegistry());
        final PcrptMessageBuilder builder = new PcrptMessageBuilder();
        final List<Reports> reports = Lists.newArrayList();
        reports.add(new ReportsBuilder().setLsp(this.lsp).build());
        builder.setReports(reports);
        final Message parseResult = parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList());
        assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parseResult);
        ByteBuf buf = Unpooled.buffer(result.readableBytes());
        parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
        assertArrayEquals(result.array(), buf.array());
        result = Unpooled.wrappedBuffer(PCRT2);
        final List<Reports> reports1 = Lists.newArrayList();
        reports1.add(new ReportsBuilder().setLsp(this.lsp).setPath(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder().setEro(this.ero).setLspa(this.lspa).build()).build());
        builder.setReports(reports1);
        final ByteBuf input = result.slice(4, result.readableBytes() - 4);
        assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(input, Collections.emptyList()));
        buf = Unpooled.buffer(result.readableBytes());
        parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
        assertArrayEquals(result.array(), buf.array());
        result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRpt.3.bin"));
        final List<Reports> reports2 = Lists.newArrayList();
        final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder pBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder();
        pBuilder.setEro(this.ero);
        pBuilder.setLspa(this.lspa);
        pBuilder.setMetrics(Lists.newArrayList(this.metrics, this.metrics));
        pBuilder.setRro(this.rro);
        reports2.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build());
        builder.setReports(reports2);
        assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
        buf = Unpooled.buffer(result.readableBytes());
        parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
        assertArrayEquals(result.array(), buf.array());
        result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRpt.5.bin"));
        final List<Reports> reports3 = Lists.newArrayList();
        final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder pBuilder1 = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder();
        pBuilder1.setEro(this.ero);
        pBuilder1.setLspa(this.lspa);
        pBuilder1.setMetrics(Lists.newArrayList(this.metrics, this.metrics));
        pBuilder1.setRro(this.rro);
        reports3.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build());
        reports3.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder1.build()).build());
        builder.setReports(reports3);
        assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
        buf = Unpooled.buffer(result.readableBytes());
        parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
        assertArrayEquals(result.array(), buf.array());
        result = Unpooled.wrappedBuffer(PCRT3);
        final List<Reports> reports4 = Lists.newArrayList();
        reports4.add(new ReportsBuilder().setLsp(this.lsp).setPath(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder().setEro(this.ero).setLspa(this.lspa).setBandwidth(this.bandwidth).setReoptimizationBandwidth(this.reoptimizationBandwidth).build()).build());
        builder.setReports(reports4);
        final ByteBuf input2 = result.slice(4, result.readableBytes() - 4);
        assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(input2, Collections.emptyList()));
        buf = Unpooled.buffer(result.readableBytes());
        parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
        assertArrayEquals(result.array(), buf.array());
    }
}
Also used : ReportsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.ReportsBuilder) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message) Collections(java.util.Collections) PcrptBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PcrptBuilder) ByteBuf(io.netty.buffer.ByteBuf) Stateful07PCReportMessageParser(org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07PCReportMessageParser) PathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.PathBuilder) PcrptMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.PcrptMessageBuilder) CrabbeInitiatedActivator(org.opendaylight.protocol.pcep.ietf.initiated00.CrabbeInitiatedActivator) StatefulActivator(org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator) Reports(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.Reports) Test(org.junit.Test)

Example 8 with StatefulActivator

use of org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator in project bgpcep by opendaylight.

the class PCCsBuilder method startActivators.

private static void startActivators() {
    final PCCActivator pccActivator = new PCCActivator();
    final StatefulActivator stateful = new StatefulActivator();
    final SyncOptimizationsActivator optimizationsActivator = new SyncOptimizationsActivator();
    final CrabbeInitiatedActivator activator = new CrabbeInitiatedActivator();
    final PCEPExtensionProviderContext ctx = ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance();
    pccActivator.start(ctx);
    stateful.start(ctx);
    optimizationsActivator.start(ctx);
    activator.start(ctx);
}
Also used : StatefulActivator(org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator) ServiceLoaderPCEPExtensionProviderContext(org.opendaylight.protocol.pcep.spi.pojo.ServiceLoaderPCEPExtensionProviderContext) PCEPExtensionProviderContext(org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext) SyncOptimizationsActivator(org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsActivator) CrabbeInitiatedActivator(org.opendaylight.protocol.pcep.ietf.initiated00.CrabbeInitiatedActivator)

Example 9 with StatefulActivator

use of org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator in project bgpcep by opendaylight.

the class PCCMockCommon method createServer.

Channel createServer(final TestingSessionListenerFactory factory, final InetSocketAddress serverAddress2, final PCEPPeerProposal peerProposal) {
    final StatefulActivator activator07 = new StatefulActivator();
    final SyncOptimizationsActivator optimizationsActivator = new SyncOptimizationsActivator();
    activator07.start(this.extensionProvider);
    optimizationsActivator.start(this.extensionProvider);
    final ChannelFuture future = this.pceDispatcher.createServer(new DispatcherDependencies(serverAddress2, factory, peerProposal));
    waitFutureSuccess(future);
    return future.channel();
}
Also used : StatefulActivator(org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator) ChannelFuture(io.netty.channel.ChannelFuture) PCEPDispatcherDependencies(org.opendaylight.protocol.pcep.PCEPDispatcherDependencies) SyncOptimizationsActivator(org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsActivator)

Aggregations

StatefulActivator (org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator)9 ByteBuf (io.netty.buffer.ByteBuf)5 Test (org.junit.Test)5 Collections (java.util.Collections)3 CrabbeInitiatedActivator (org.opendaylight.protocol.pcep.ietf.initiated00.CrabbeInitiatedActivator)3 SyncOptimizationsActivator (org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsActivator)3 ArrayList (java.util.ArrayList)2 Stateful07PCReportMessageParser (org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07PCReportMessageParser)2 Message (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message)2 ProtocolVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion)2 Subobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.iro.Subobject)2 ChannelFuture (io.netty.channel.ChannelFuture)1 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 BigInteger (java.math.BigInteger)1 InetSocketAddress (java.net.InetSocketAddress)1 Before (org.junit.Before)1 PCEPCapability (org.opendaylight.protocol.pcep.PCEPCapability)1 PCEPDispatcherDependencies (org.opendaylight.protocol.pcep.PCEPDispatcherDependencies)1 PCEPSessionProposalFactory (org.opendaylight.protocol.pcep.PCEPSessionProposalFactory)1 PCEPStatefulCapability (org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability)1