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));
}
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());
}
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);
}
Aggregations