use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.state.SrCapabilitiesBuilder in project bgpcep by opendaylight.
the class SrAttributeParserTest method testSrCapabilities.
// tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-00#section-2.1.1
@Test
public void testSrCapabilities() {
final byte[] bytesIsis = { (byte) 0xC0, 0, 0, 0, 10, 4, (byte) 0x89, 0, 4, 1, 2, 3, 4 };
final byte[] bytesOspf = { 0, 0, 0, 0, 10, 4, (byte) 0x89, 0, 4, 1, 2, 3, 4 };
final SrCapabilities capsIsis = new SrCapabilitiesBuilder().setMplsIpv4(Boolean.TRUE).setMplsIpv6(Boolean.TRUE).setSrIpv6(Boolean.FALSE).setSidLabelIndex(new SidCaseBuilder().setSid(16909060L).build()).setRangeSize((long) 10).build();
final SrCapabilities capsOspf = new SrCapabilitiesBuilder().setMplsIpv4(Boolean.FALSE).setMplsIpv6(Boolean.FALSE).setSrIpv6(Boolean.FALSE).setSidLabelIndex(new SidCaseBuilder().setSid(16909060L).build()).setRangeSize((long) 10).build();
assertEquals(capsIsis, SrNodeAttributesParser.parseSrCapabilities(Unpooled.wrappedBuffer(bytesIsis), ProtocolId.IsisLevel1));
assertEquals(capsOspf, SrNodeAttributesParser.parseSrCapabilities(Unpooled.wrappedBuffer(bytesIsis), ProtocolId.Ospf));
final ByteBuf encodedIsis = Unpooled.buffer();
final ByteBuf encodedOspf = Unpooled.buffer();
SrNodeAttributesParser.serializeSrCapabilities(capsIsis, encodedIsis);
SrNodeAttributesParser.serializeSrCapabilities(capsOspf, encodedOspf);
assertArrayEquals(bytesIsis, ByteArray.readAllBytes(encodedIsis));
assertArrayEquals(bytesOspf, ByteArray.readAllBytes(encodedOspf));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.state.SrCapabilitiesBuilder in project bgpcep by opendaylight.
the class SrNodeAttributesParser method parseSrCapabilities.
public static SrCapabilities parseSrCapabilities(final ByteBuf buffer, final ProtocolId protocol) {
final SrCapabilitiesBuilder builder = new SrCapabilitiesBuilder();
final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
setFlags(flags, protocol, builder);
buffer.skipBytes(RESERVERED);
builder.setRangeSize((long) buffer.readUnsignedMedium());
builder.setSidLabelIndex(SidLabelIndexParser.parseSidSubTlv(buffer));
return builder.build();
}
Aggregations