use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.Ipv6SrPrefix in project bgpcep by opendaylight.
the class PrefixAttributesParser method parseAttribute.
private static void parseAttribute(final int key, final ByteBuf value, final ProtocolId protocolId, final PrefixAttributesBuilder builder, final List<RouteTag> routeTags, final List<ExtendedRouteTag> exRouteTags) {
switch(key) {
case IGP_FLAGS:
parseIgpFags(builder, value);
break;
case ROUTE_TAG:
parseRouteTags(routeTags, value);
break;
case EXTENDED_ROUTE_TAG:
parseExtendedRouteTags(exRouteTags, value);
break;
case PREFIX_METRIC:
final IgpMetric metric = new IgpMetric(value.readUnsignedInt());
builder.setPrefixMetric(metric);
LOG.debug("Parsed Metric: {}", metric);
break;
case FORWARDING_ADDRESS:
final IpAddress fwdAddress = parseForwardingAddress(value);
builder.setOspfForwardingAddress(fwdAddress);
LOG.debug("Parsed FWD Address: {}", fwdAddress);
break;
case PREFIX_OPAQUE:
if (LOG.isDebugEnabled()) {
LOG.debug("Parsed Opaque value: {}, not preserving it", ByteBufUtil.hexDump(value));
}
break;
case PREFIX_SID:
final SrPrefix prefix = SrPrefixAttributesParser.parseSrPrefix(value, protocolId);
builder.setSrPrefix(prefix);
LOG.debug("Parsed SR Prefix: {}", prefix);
break;
case IPV6_PREFIX_SID:
final Ipv6SrPrefix ipv6Prefix = Ipv6SrPrefixAttributesParser.parseSrIpv6Prefix(value);
builder.setIpv6SrPrefix(ipv6Prefix);
LOG.debug("Parsed Ipv6 SR Prefix: {}", ipv6Prefix);
break;
case RANGE:
final SrRange range = RangeTlvParser.parseSrRange(value, protocolId);
builder.setSrRange(range);
LOG.debug("Parsed SR Range: {}", range);
break;
case BINDING_SID:
parseBindingSid(builder, value, protocolId);
break;
default:
LOG.warn("TLV {} is not a valid prefix attribute, ignoring it", key);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.Ipv6SrPrefix 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));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.Ipv6SrPrefix 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();
}
Aggregations