Search in sources :

Example 1 with SrCapabilitiesBuilder

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));
}
Also used : SrCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.state.SrCapabilities) PrefixSidCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.binding.sub.tlvs.binding.sub.tlv.PrefixSidCaseBuilder) SidCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.sid.label.index.SidCaseBuilder) ByteBuf(io.netty.buffer.ByteBuf) SrCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.state.SrCapabilitiesBuilder) Test(org.junit.Test)

Example 2 with SrCapabilitiesBuilder

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();
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray) SrCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.state.SrCapabilitiesBuilder)

Aggregations

SrCapabilitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.state.SrCapabilitiesBuilder)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 BitArray (org.opendaylight.protocol.util.BitArray)1 SrCapabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.state.SrCapabilities)1 PrefixSidCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.binding.sub.tlvs.binding.sub.tlv.PrefixSidCaseBuilder)1 SidCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.sid.label.index.SidCaseBuilder)1