use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestination in project bgpcep by opendaylight.
the class RouteTargetConstrainNlriHandler method parseNlriDestinations.
private static List<RouteTargetConstrainDestination> parseNlriDestinations(final ByteBuf nlri, final boolean addPathSupported) {
final List<RouteTargetConstrainDestination> dests = new ArrayList<>();
while (nlri.isReadable()) {
final RouteTargetConstrainDestinationBuilder builder = new RouteTargetConstrainDestinationBuilder();
if (addPathSupported) {
builder.setPathId(PathIdUtil.readPathId(nlri));
}
final int length = nlri.readUnsignedByte() / 8;
final ByteBuf nlriBuf = nlri.readSlice(length);
Integer type = null;
if (length != 0) {
builder.setOriginAs(new AsNumber(ByteBufUtils.readUint32(nlriBuf)));
type = (int) nlriBuf.readUnsignedByte();
// Skip Subtype
nlriBuf.skipBytes(1);
}
builder.setRouteTargetConstrainChoice(ImmutableRouteTargetConstrainNlriRegistry.getInstance().parseRouteTargetConstrain(type, nlriBuf));
dests.add(builder.build());
}
return dests;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestination in project bgpcep by opendaylight.
the class RouteTargetConstrainNlriHandler method serializeNlriDestinations.
public static ByteBuf serializeNlriDestinations(final List<RouteTargetConstrainDestination> destinationList) {
final ByteBuf nlri = Unpooled.buffer();
for (final RouteTargetConstrainDestination dest : destinationList) {
final RouteTargetConstrainChoice rtcChoice = dest.getRouteTargetConstrainChoice();
if (rtcChoice instanceof RouteTargetConstrainDefaultCase) {
nlri.writeByte(0);
} else {
nlri.writeByte(RT_BITS_LENGTH);
final AsNumber originAs = dest.getOriginAs();
if (originAs != null) {
ByteBufUtils.write(nlri, originAs.getValue());
}
nlri.writeBytes(ImmutableRouteTargetConstrainNlriRegistry.getInstance().serializeRouteTargetConstrain(rtcChoice));
}
}
return nlri;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestination in project bgpcep by opendaylight.
the class RouteTargetConstrainRIBSupport method extractDestination.
private RouteTargetConstrainDestination extractDestination(final DataContainerNode rtDest) {
final RouteTargetConstrainDestinationBuilder builder = new RouteTargetConstrainDestinationBuilder().setPathId(PathIdUtil.buildPathId(rtDest, routePathIdNid())).setRouteTargetConstrainChoice(extractRouteTargetChoice(rtDest));
final Optional<Object> originAs = NormalizedNodes.findNode(rtDest, this.originAsNid).map(NormalizedNode::body);
originAs.ifPresent(o -> builder.setOriginAs(new AsNumber((Uint32) o)));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.destination.RouteTargetConstrainDestination in project bgpcep by opendaylight.
the class RouteTargetConstrainRIBSupport method createRouteKey.
private NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode routeTarget) {
final ByteBuf buffer = Unpooled.buffer();
final RouteTargetConstrainDestination dest = extractDestination(routeTarget);
buffer.writeBytes(ImmutableRouteTargetConstrainNlriRegistry.getInstance().serializeRouteTargetConstrain(dest.getRouteTargetConstrainChoice()));
return PathIdUtil.createNidKey(routeQName(), routeKeyTemplate(), ByteArray.encodeBase64(buffer), routeTarget.findChildByArg(routePathIdNid()));
}
Aggregations