use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.destination.EvpnDestination in project bgpcep by opendaylight.
the class EvpnNlriParserTest method testExtractRouteKey.
@Test
public void testExtractRouteKey() throws BGPParsingException {
final DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> evpnBI = ImmutableUnkeyedListEntryNodeBuilder.create();
evpnBI.withNodeIdentifier(EVPN_CHOICE_NID);
evpnBI.withChild(createValueBuilder(RD_MODEL, RD_NID).build());
evpnBI.withChild(createMACIpAdvChoice());
final EvpnDestination destResult = EvpnNlriParser.extractRouteKeyDestination(evpnBI.build());
final EvpnDestination expected = new EvpnDestinationBuilder().setRouteDistinguisher(RD).setEvpnChoice(MACIpAdvRParserTest.createdExpectedRouteKey()).build();
assertEquals(expected, destResult);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.destination.EvpnDestination in project bgpcep by opendaylight.
the class EvpnNlriParserTest method testExtractEvpnDestination.
@Test
public void testExtractEvpnDestination() throws BGPParsingException {
final DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> evpnBI = ImmutableUnkeyedListEntryNodeBuilder.create();
evpnBI.withNodeIdentifier(EVPN_NID);
evpnBI.withChild(createMACIpAdvChoice());
evpnBI.withChild(createValueBuilder(RD_MODEL, RD_NID).build());
final EvpnDestination destResult = EvpnNlriParser.extractEvpnDestination(evpnBI.build());
final EvpnDestination expected = new EvpnDestinationBuilder().setRouteDistinguisher(RD).setEvpnChoice(MACIpAdvRParserTest.createdExpectedResult()).build();
assertEquals(expected, destResult);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.destination.EvpnDestination in project bgpcep by opendaylight.
the class EvpnNlriParser method extractDestination.
private static EvpnDestination extractDestination(final DataContainerNode<? extends PathArgument> evpnChoice, final ExtractionInterface extract) {
final EvpnRegistry reg = SimpleEvpnNlriRegistry.getInstance();
final ChoiceNode cont = (ChoiceNode) evpnChoice.getChild(EVPN_CHOICE_NID).get();
final EvpnChoice evpnValue = extract.check(reg, cont);
if (evpnValue == null) {
LOG.warn("Unrecognized Nlri {}", cont);
return null;
}
return new EvpnDestinationBuilder().setRouteDistinguisher(extractRouteDistinguisher(evpnChoice)).setEvpnChoice(evpnValue).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.destination.EvpnDestination in project bgpcep by opendaylight.
the class EvpnNlriParser method parseNlri.
@Nullable
private static List<EvpnDestination> parseNlri(final ByteBuf nlri) {
if (!nlri.isReadable()) {
return null;
}
final List<EvpnDestination> dests = new ArrayList<>();
while (nlri.isReadable()) {
final EvpnDestinationBuilder builder = new EvpnDestinationBuilder();
final NlriType type = NlriType.forValue(nlri.readUnsignedByte());
final int length = nlri.readUnsignedByte();
final ByteBuf nlriBuf = nlri.readSlice(length);
builder.setRouteDistinguisher(parseRouteDistinguisher(nlriBuf));
builder.setEvpnChoice(SimpleEvpnNlriRegistry.getInstance().parseEvpn(type, nlriBuf));
dests.add(builder.build());
}
return dests;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.destination.EvpnDestination in project bgpcep by opendaylight.
the class EvpnRibSupport method createRouteKey.
private NodeIdentifierWithPredicates createRouteKey(final UnkeyedListEntryNode evpn) {
final ByteBuf buffer = Unpooled.buffer();
final EvpnDestination dest = EvpnNlriParser.extractRouteKeyDestination(evpn);
EvpnNlriParser.serializeNlri(Collections.singletonList(dest), buffer);
return new NodeIdentifierWithPredicates(routeQName(), ROUTE_KEY_QNAME, ByteArray.encodeBase64(buffer));
}
Aggregations