use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1 in project bgpcep by opendaylight.
the class GracefulRestartUtilTest method getLlGracefulCapabilityTest.
@Test
public void getLlGracefulCapabilityTest() {
final Set<BgpPeerUtil.LlGracefulRestartDTO> llGracefulRestartDTOs = new HashSet<>();
llGracefulRestartDTOs.add(new BgpPeerUtil.LlGracefulRestartDTO(IPV4_KEY, STALE_TIME, true));
llGracefulRestartDTOs.add(new BgpPeerUtil.LlGracefulRestartDTO(IPV6_KEY, STALE_TIME, false));
CParameters capability = GracefulRestartUtil.getLlGracefulCapability(llGracefulRestartDTOs);
final CParameters1 params = capability.augmentation(CParameters1.class);
assertNotNull(params);
final LlGracefulRestartCapability llGracefulCapability = params.getLlGracefulRestartCapability();
assertNotNull(llGracefulCapability);
final var tables = llGracefulCapability.getTables();
assertNotNull(tables);
assertEquals(2, tables.size());
assertEquals(STALE_TIME, tables.values().iterator().next().getLongLivedStaleTime().getValue().intValue());
tables.values().forEach(table -> {
assertTrue(isSameKey(IPV4_KEY, table.key()) && table.getAfiFlags().getForwardingState() || isSameKey(IPV6_KEY, table.key()) && !table.getAfiFlags().getForwardingState());
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1 in project bgpcep by opendaylight.
the class GracefulRestartUtilTest method getGracefulCapabilityTest.
@Test
public void getGracefulCapabilityTest() {
final Map<TablesKey, Boolean> gracefulMap = new HashMap<>();
gracefulMap.put(IPV4_KEY, true);
gracefulMap.put(IPV6_KEY, false);
CParameters capability = GracefulRestartUtil.getGracefulCapability(gracefulMap, RESTART_TIME, RESTARTING);
final CParameters1 params = capability.augmentation(CParameters1.class);
assertNotNull(params);
final GracefulRestartCapability gracefulCapability = params.getGracefulRestartCapability();
assertNotNull(gracefulCapability);
assertTrue(gracefulCapability.getRestartFlags().getRestartState());
assertEquals(RESTART_TIME, gracefulCapability.getRestartTime().intValue());
final var tables = gracefulCapability.getTables();
assertNotNull(tables);
assertEquals(2, tables.size());
tables.values().forEach(table -> {
assertTrue(isSameKey(IPV4_KEY, table.key()) && table.getAfiFlags().getForwardingState() || isSameKey(IPV6_KEY, table.key()) && !table.getAfiFlags().getForwardingState());
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1 in project bgpcep by opendaylight.
the class EventBusRegistration method sendMessage.
private static void sendMessage(final BGPSessionListener listener, final Notification message) {
if (BGPMock.CONNECTION_LOST_MAGIC_MSG.equals(message)) {
listener.onSessionTerminated(null, new BGPTerminationReason(BGPError.CEASE));
} else if (message instanceof Open) {
final Set<BgpTableType> tts = new HashSet<>();
final List<AddressFamilies> addPathCapabilitiesList = new ArrayList<>();
for (final BgpParameters param : ((Open) message).getBgpParameters()) {
for (final OptionalCapabilities capa : param.getOptionalCapabilities()) {
final CParameters cParam = capa.getCParameters();
final CParameters1 aug = cParam.augmentation(CParameters1.class);
if (aug == null) {
continue;
}
if (aug.getMultiprotocolCapability() != null) {
final MultiprotocolCapability p = aug.getMultiprotocolCapability();
LOG.debug("Adding open parameter {}", p);
final BgpTableType type = new BgpTableTypeImpl(p.getAfi(), p.getSafi());
tts.add(type);
} else if (aug.getAddPathCapability() != null) {
final AddPathCapability addPathCap = aug.getAddPathCapability();
addPathCapabilitiesList.addAll(addPathCap.getAddressFamilies());
}
}
}
listener.onSessionUp(new MockBGPSession(tts, addPathCapabilitiesList));
} else if (!(message instanceof Keepalive)) {
try {
listener.onMessage(new MockBGPSession(), message);
} catch (BGPDocumentedException e) {
LOG.warn("Exception encountered while handling message", e);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1 in project bgpcep by opendaylight.
the class AbstractAddPathTest method createParameter.
protected static BgpParameters createParameter(final boolean addPath) {
final OptionalCapabilities mp = new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build()).build()).build()).build();
final List<OptionalCapabilities> capabilities = Lists.newArrayList(mp);
if (addPath) {
final OptionalCapabilities addPathCapa = new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(Lists.newArrayList(new AddressFamiliesBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setSendReceive(SendReceive.Both).build())).build()).build()).build()).build();
capabilities.add(addPathCapa);
}
return new BgpParametersBuilder().setOptionalCapabilities(capabilities).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1 in project bgpcep by opendaylight.
the class BgpPeer method getBgpParameters.
private static List<BgpParameters> getBgpParameters(final AfiSafis afiSafis, final RIB rib, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
final List<BgpParameters> tlvs = new ArrayList<>();
final List<OptionalCapabilities> caps = new ArrayList<>();
caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(rib.getLocalAs()).build()).build()).build());
caps.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
caps.add(new OptionalCapabilitiesBuilder().setCParameters(MultiprotocolCapabilitiesUtil.RR_CAPABILITY).build());
final List<AfiSafi> afiSafi = OpenConfigMappingUtil.getAfiSafiWithDefault(afiSafis, false);
final List<AddressFamilies> addPathCapability = OpenConfigMappingUtil.toAddPathCapability(afiSafi, tableTypeRegistry);
if (!addPathCapability.isEmpty()) {
caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(addPathCapability).build()).build()).build()).build());
}
final List<BgpTableType> tableTypes = OpenConfigMappingUtil.toTableTypes(afiSafi, tableTypeRegistry);
for (final BgpTableType tableType : tableTypes) {
if (!rib.getLocalTables().contains(tableType)) {
LOG.info("RIB instance does not list {} " + "in its local tables. Incoming data will be dropped.", tableType);
}
caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder(tableType).build()).build()).build()).build());
}
tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(caps).build());
return tlvs;
}
Aggregations