Search in sources :

Example 1 with SrCapabilitiesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.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(Uint32.valueOf(16909060L)).build()).setRangeSize(new Uint24(Uint32.TEN)).build();
    final SrCapabilities capsOspf = new SrCapabilitiesBuilder().setMplsIpv4(Boolean.FALSE).setMplsIpv6(Boolean.FALSE).setSrIpv6(Boolean.FALSE).setSidLabelIndex(new SidCaseBuilder().setSid(Uint32.valueOf(16909060L)).build()).setRangeSize(new Uint24(Uint32.TEN)).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.rev200120.node.state.SrCapabilities) SidCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.SidCaseBuilder) PrefixSidCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.binding.sub.tlvs.binding.sub.tlv.PrefixSidCaseBuilder) Uint24(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.Uint24) ByteBuf(io.netty.buffer.ByteBuf) SrCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.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.rev200120.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(RFC8294ByteBufUtils.readUint24(buffer));
    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.rev200120.node.state.SrCapabilitiesBuilder)

Aggregations

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