use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.evpn.destination.EvpnDestinationBuilder 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.rev200120.evpn.destination.EvpnDestinationBuilder 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.rev200120.evpn.destination.EvpnDestinationBuilder in project bgpcep by opendaylight.
the class EvpnNlriParserTest method testExtractRouteKey.
@Test
public void testExtractRouteKey() {
final DataContainerNodeBuilder<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.rev200120.evpn.destination.EvpnDestinationBuilder in project bgpcep by opendaylight.
the class EvpnNlriParserTest method testExtractEvpnDestination.
@Test
public void testExtractEvpnDestination() {
final DataContainerNodeBuilder<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.rev200120.evpn.destination.EvpnDestinationBuilder in project bgpcep by opendaylight.
the class EvpnNlriParser method extractDestination.
private static EvpnDestination extractDestination(final DataContainerNode route, final ExtractionInterface extract) {
final EvpnRegistry reg = SimpleEvpnNlriRegistry.getInstance();
final ChoiceNode cont = (ChoiceNode) route.findChildByArg(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(route)).setPathId(PathIdUtil.buildPathId(route, PATH_ID_NID)).setEvpnChoice(evpnValue).build();
}
Aggregations