use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.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().setMsd((short) 1).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.rev171025.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.getAugmentation(Tlvs1.class) != null) {
final Tlvs1 tlvs = tbuilder.getAugmentation(Tlvs1.class);
if (tlvs.getSrPceCapability() != null) {
tlvBuilder.setSrPceCapability(tlvs.getSrPceCapability());
}
}
if (tlv instanceof SrPceCapability) {
tlvBuilder.setSrPceCapability((SrPceCapability) tlv);
}
tbuilder.addAugmentation(Tlvs1.class, tlvBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.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) {
Preconditions.checkArgument(tlv instanceof SrPceCapability, "SrPceCapability is mandatory.");
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
body.writerIndex(OFFSET);
writeUnsignedByte(((SrPceCapability) tlv).getMsd(), body);
TlvUtil.formatTlv(TYPE, body, buffer);
}
Aggregations