Search in sources :

Example 1 with StatefulBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.StatefulBuilder in project bgpcep by opendaylight.

the class CInitiated00StatefulCapabilityTlvParser method parseFlags.

@Override
protected void parseFlags(final StatefulBuilder sb, final ByteBuf buffer) {
    final BitArray flags = BitArray.valueOf(buffer, FLAGS_F_LENGTH);
    sb.setLspUpdateCapability(flags.get(U_FLAG_OFFSET));
    if (flags.get(I_FLAG_OFFSET)) {
        sb.addAugmentation(Stateful1.class, new Stateful1Builder().setInitiation(Boolean.TRUE).build());
    }
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray) Stateful1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Stateful1Builder)

Example 2 with StatefulBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.StatefulBuilder in project bgpcep by opendaylight.

the class Stateful07StatefulCapabilityTlvParser method parseTlv.

@Override
public Stateful parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
    if (buffer == null) {
        return null;
    }
    if (buffer.readableBytes() < FLAGS_F_LENGTH / Byte.SIZE) {
        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >= " + FLAGS_F_LENGTH / Byte.SIZE + ".");
    }
    final StatefulBuilder sb = new StatefulBuilder();
    parseFlags(sb, buffer);
    return sb.build();
}
Also used : StatefulBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.StatefulBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)

Example 3 with StatefulBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.StatefulBuilder in project bgpcep by opendaylight.

the class PCEPTlvParserTest method testStatefulTlv.

@Test
public void testStatefulTlv() throws PCEPDeserializerException {
    final StatefulStatefulCapabilityTlvParser parser = new StatefulStatefulCapabilityTlvParser();
    final Stateful tlv = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(STATEFUL_BYTES, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(STATEFUL_BYTES, ByteArray.getAllBytes(buff));
}
Also used : Stateful(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.Stateful) StatefulBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.StatefulBuilder) StatefulStatefulCapabilityTlvParser(org.opendaylight.protocol.pcep.ietf.stateful.StatefulStatefulCapabilityTlvParser) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 4 with StatefulBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.StatefulBuilder in project bgpcep by opendaylight.

the class PCEPValidatorTest method testOpenMsg.

@Test
public void testOpenMsg() throws IOException, PCEPDeserializerException {
    new StatefulActivator().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().setOpen(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder().setProcessingRule(false).setIgnore(false).setVersion(new ProtocolVersion(Uint8.ONE)).setKeepalive(Uint8.valueOf(30)).setDeadTimer(Uint8.valueOf(120)).setSessionId(Uint8.ONE).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder().addAugmentation(new Tlvs1Builder().setStateful(new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).build()).build()).build()).build());
    assertEquals(new OpenBuilder().setOpenMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of()));
    final ByteBuf buf = Unpooled.buffer(result.readableBytes());
    parser.serializeMessage(new OpenBuilder().setOpenMessage(builder.build()).build(), buf);
    assertArrayEquals(result.array(), buf.array());
}
Also used : StatefulActivator(org.opendaylight.protocol.pcep.ietf.stateful.StatefulActivator) OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.OpenBuilder) Collections(java.util.Collections) StatefulBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.StatefulBuilder) ByteBuf(io.netty.buffer.ByteBuf) ProtocolVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ProtocolVersion) Tlvs1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Tlvs1Builder) PCEPOpenMessageParser(org.opendaylight.protocol.pcep.parser.message.PCEPOpenMessageParser) OpenMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.message.OpenMessageBuilder) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.Subobject) Test(org.junit.Test)

Example 5 with StatefulBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.StatefulBuilder in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testOpenObjectWithTLV.

@Test
public void testOpenObjectWithTLV() throws PCEPDeserializerException, IOException {
    new SyncOptimizationsActivator().start(ctx);
    final SyncOptimizationsOpenObjectParser parser = new SyncOptimizationsOpenObjectParser(this.ctx.getTlvHandlerRegistry(), this.ctx.getVendorInformationTlvRegistry());
    final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
    final var builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder().setProcessingRule(false).setIgnore(false).setVersion(new ProtocolVersion(Uint8.ONE)).setKeepalive(Uint8.valueOf(30)).setDeadTimer(Uint8.valueOf(120)).setSessionId(Uint8.ONE);
    final Stateful tlv1 = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).addAugmentation(new Stateful1Builder().build()).build();
    final Tlvs1Builder statBuilder = new Tlvs1Builder();
    statBuilder.setStateful(tlv1);
    final Tlvs3Builder syncOptBuilder = new Tlvs3Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(DB_VERSION).build()).setSpeakerEntityId(new SpeakerEntityIdBuilder().setSpeakerEntityIdValue(SPEAKER_ID).build());
    builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder().addAugmentation(statBuilder.build()).addAugmentation(syncOptBuilder.build()).build());
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
    final ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
Also used : Stateful(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.Stateful) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) SyncOptimizationsActivator(org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsActivator) StatefulBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.StatefulBuilder) LspDbVersionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.lsp.db.version.tlv.LspDbVersionBuilder) Tlvs3Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.Tlvs3Builder) ByteBuf(io.netty.buffer.ByteBuf) ProtocolVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ProtocolVersion) Stateful1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.Stateful1Builder) Tlvs1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Tlvs1Builder) SyncOptimizationsOpenObjectParser(org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsOpenObjectParser) SpeakerEntityIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.speaker.entity.id.tlv.SpeakerEntityIdBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.srp.object.srp.TlvsBuilder) Test(org.junit.Test)

Aggregations

StatefulBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.StatefulBuilder)6 ByteBuf (io.netty.buffer.ByteBuf)4 Test (org.junit.Test)4 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)4 Tlvs1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Tlvs1Builder)4 Stateful (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.Stateful)4 BitArray (org.opendaylight.protocol.util.BitArray)3 ArrayList (java.util.ArrayList)2 PCEPErrors (org.opendaylight.protocol.pcep.spi.PCEPErrors)2 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)2 Stateful1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.Stateful1Builder)2 Stateful1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Stateful1Builder)2 ProtocolVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ProtocolVersion)2 Collections (java.util.Collections)1 Before (org.junit.Before)1 DataTreeChangeListener (org.opendaylight.mdsal.binding.api.DataTreeChangeListener)1 StatefulActivator (org.opendaylight.protocol.pcep.ietf.stateful.StatefulActivator)1 StatefulStatefulCapabilityTlvParser (org.opendaylight.protocol.pcep.ietf.stateful.StatefulStatefulCapabilityTlvParser)1 PCEPOpenMessageParser (org.opendaylight.protocol.pcep.parser.message.PCEPOpenMessageParser)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1