Search in sources :

Example 6 with Stateful

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful 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 7 with Stateful

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

the class SyncOptimizationsCapabilityTlvParser method serializeFlags.

@Override
protected BitArray serializeFlags(final Stateful sct) {
    final BitArray flags = new BitArray(FLAGS_F_LENGTH);
    final Stateful1 sfi = sct.getAugmentation(Stateful1.class);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1 sf2 = sct.getAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1.class);
    if (sf2 != null) {
        flags.set(F_FLAG_OFFSET, sf2.isTriggeredInitialSync());
        flags.set(D_FLAG_OFFSET, sf2.isDeltaLspSyncCapability());
        flags.set(T_FLAG_OFFSET, sf2.isTriggeredResync());
        flags.set(S_FLAG_OFFSET, sf2.isIncludeDbVersion());
    }
    if (sfi != null) {
        flags.set(I_FLAG_OFFSET, sfi.isInitiation());
    }
    flags.set(U_FLAG_OFFSET, sct.isLspUpdateCapability());
    return flags;
}
Also used : Stateful1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Stateful1) BitArray(org.opendaylight.protocol.util.BitArray)

Example 8 with Stateful

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

the class PCEPTlvParserTest method testStatefulTlvSyncOptimizationExtension.

@Test
public void testStatefulTlvSyncOptimizationExtension() throws PCEPDeserializerException {
    final SyncOptimizationsCapabilityTlvParser parser = new SyncOptimizationsCapabilityTlvParser();
    final Stateful tlv = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1Builder().setTriggeredInitialSync(Boolean.TRUE).setDeltaLspSyncCapability(Boolean.TRUE).setIncludeDbVersion(Boolean.TRUE).build()).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(STATEFUL_SYNC_OPT_BYTES, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(STATEFUL_SYNC_OPT_BYTES, ByteArray.getAllBytes(buff));
}
Also used : Stateful(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful) StatefulBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.StatefulBuilder) ByteBuf(io.netty.buffer.ByteBuf) SyncOptimizationsCapabilityTlvParser(org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsCapabilityTlvParser) Test(org.junit.Test)

Example 9 with Stateful

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

the class Stateful07OpenObjectParser method addTlv.

@Override
public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
    super.addTlv(tbuilder, tlv);
    final Tlvs1Builder statefulBuilder = new Tlvs1Builder();
    if (tbuilder.getAugmentation(Tlvs1.class) != null) {
        final Tlvs1 t = tbuilder.getAugmentation(Tlvs1.class);
        if (t.getStateful() != null) {
            statefulBuilder.setStateful(t.getStateful());
        }
    }
    if (tlv instanceof Stateful) {
        statefulBuilder.setStateful((Stateful) tlv);
    }
    tbuilder.addAugmentation(Tlvs1.class, statefulBuilder.build());
}
Also used : Stateful(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful) Tlvs1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1Builder) Tlvs1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1)

Example 10 with Stateful

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

the class Stateful07StatefulCapabilityTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof Stateful, "StatefulCapabilityTlv is mandatory.");
    final Stateful sct = (Stateful) tlv;
    TlvUtil.formatTlv(TYPE, Unpooled.wrappedBuffer(serializeFlags(sct).array()), buffer);
}
Also used : Stateful(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful)

Aggregations

Stateful (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful)7 StatefulBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.StatefulBuilder)5 ByteBuf (io.netty.buffer.ByteBuf)4 Test (org.junit.Test)4 Stateful1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Stateful1)4 Tlvs1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1)3 Tlvs1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1Builder)3 BitArray (org.opendaylight.protocol.util.BitArray)2 ProtocolVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion)2 BigInteger (java.math.BigInteger)1 InetAddress (java.net.InetAddress)1 Collections (java.util.Collections)1 Stateful07StatefulCapabilityTlvParser (org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07StatefulCapabilityTlvParser)1 StatefulActivator (org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator)1 PCEPOpenMessageParser (org.opendaylight.protocol.pcep.parser.message.PCEPOpenMessageParser)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)1 SyncOptimizationsActivator (org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsActivator)1 SyncOptimizationsCapabilityTlvParser (org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsCapabilityTlvParser)1 SyncOptimizationsOpenObjectParser (org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsOpenObjectParser)1