Search in sources :

Example 1 with SrPceCapability

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapability in project bgpcep by opendaylight.

the class SrTlvParserTest method testSrPceCapabilityParser.

@Test
public void testSrPceCapabilityParser() throws PCEPDeserializerException {
    final SrPceCapabilityTlvParser parser = new SrPceCapabilityTlvParser();
    final SrPceCapability spcTlv = new SrPceCapabilityBuilder().setNFlag(Boolean.TRUE).setXFlag(Boolean.TRUE).setMsd(Uint8.ONE).build();
    assertEquals(spcTlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(SPC_TLV_BYTES, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(spcTlv, buff);
    assertArrayEquals(SPC_TLV_BYTES, ByteArray.getAllBytes(buff));
}
Also used : SrPceCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapability) ByteBuf(io.netty.buffer.ByteBuf) SrPceCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapabilityBuilder) Test(org.junit.Test)

Example 2 with SrPceCapability

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapability in project bgpcep by opendaylight.

the class PcepOpenObjectWithSpcTlvParser method addTlv.

@Override
public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
    super.addTlv(tbuilder, tlv);
    final Tlvs1Builder tlvBuilder = new Tlvs1Builder();
    if (tbuilder.augmentation(Tlvs1.class) != null) {
        final Tlvs1 tlvs = tbuilder.augmentation(Tlvs1.class);
        if (tlvs.getSrPceCapability() != null) {
            tlvBuilder.setSrPceCapability(tlvs.getSrPceCapability());
        }
    }
    if (tlv instanceof SrPceCapability) {
        tlvBuilder.setSrPceCapability((SrPceCapability) tlv);
    }
    tbuilder.addAugmentation(tlvBuilder.build());
}
Also used : SrPceCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapability) Tlvs1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.Tlvs1Builder) Tlvs1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.Tlvs1)

Example 3 with SrPceCapability

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapability in project bgpcep by opendaylight.

the class SrPceCapabilityTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    checkArgument(tlv instanceof SrPceCapability, "SrPceCapability is mandatory.");
    final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
    /* Reserved 2 bytes */
    body.writerIndex(OFFSET);
    /* Flags */
    final SrPceCapability srPceCapability = (SrPceCapability) tlv;
    final BitArray bits = new BitArray(BITSET_LENGTH);
    bits.set(N_FLAG_POSITION, srPceCapability.getNFlag());
    bits.set(X_FLAG_POSITION, srPceCapability.getXFlag());
    bits.toByteBuf(body);
    /* MSD */
    ByteBufUtils.writeOrZero(body, srPceCapability.getMsd());
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : SrPceCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapability) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

SrPceCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapability)3 ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)1 BitArray (org.opendaylight.protocol.util.BitArray)1 Tlvs1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.Tlvs1)1 Tlvs1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.Tlvs1Builder)1 SrPceCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapabilityBuilder)1