Search in sources :

Example 1 with Ipv6SrPrefixBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.Ipv6SrPrefixBuilder in project bgpcep by opendaylight.

the class SrAttributeParserTest method testIpv6SrPrefix.

// https://tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-02#section-2.3.2
@Test
public void testIpv6SrPrefix() {
    final byte[] bytes = { 0, 0, 0 };
    final Ipv6SrPrefix prefix = new Ipv6SrPrefixBuilder().setAlgorithm(Algorithm.ShortestPathFirst).build();
    assertEquals(prefix, Ipv6SrPrefixAttributesParser.parseSrIpv6Prefix(Unpooled.wrappedBuffer(bytes)));
    final ByteBuf serializedPrefix = Unpooled.buffer();
    Ipv6SrPrefixAttributesParser.serializeIpv6SrPrefix(prefix, serializedPrefix);
    assertArrayEquals(bytes, ByteArray.readAllBytes(serializedPrefix));
}
Also used : Ipv6SrPrefixBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.Ipv6SrPrefixBuilder) Ipv6SrPrefix(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.Ipv6SrPrefix) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 2 with Ipv6SrPrefixBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.Ipv6SrPrefixBuilder in project bgpcep by opendaylight.

the class Ipv6SrPrefixAttributesParser method parseSrIpv6Prefix.

public static Ipv6SrPrefix parseSrIpv6Prefix(final ByteBuf buffer) {
    final Ipv6SrPrefixBuilder builder = new Ipv6SrPrefixBuilder();
    buffer.skipBytes(FLAGS_SIZE);
    builder.setAlgorithm(Algorithm.forValue(buffer.readUnsignedByte()));
    return builder.build();
}
Also used : Ipv6SrPrefixBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.Ipv6SrPrefixBuilder)

Aggregations

Ipv6SrPrefixBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.Ipv6SrPrefixBuilder)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 Ipv6SrPrefix (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.Ipv6SrPrefix)1