use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.AddressFamilies in project bgpcep by opendaylight.
the class AddPathCapabilityHandlerTest method testUnhandledSendReceive.
@Test(expected = IllegalArgumentException.class)
public void testUnhandledSendReceive() {
final List<AddressFamilies> family = new ArrayList<>();
family.add(new AddressFamiliesBuilder().setAfi(AddPathCapabilityHandlerTest.AFI).setSafi(AddPathCapabilityHandlerTest.SAFI).setSendReceive(SendReceive.forValue(4)).build());
final CParameters capabilityToSerialize = new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(family).build()).build()).build();
final ByteBuf bytes = Unpooled.buffer();
final AddPathCapabilityHandler handler = new AddPathCapabilityHandler(this.afiRegistry, this.safiRegistry);
handler.serializeCapability(capabilityToSerialize, bytes);
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.AddressFamilies in project bgpcep by opendaylight.
the class BGPPeer method onSessionUp.
@Override
public synchronized void onSessionUp(final BGPSession session) {
this.session = session;
if (this.session instanceof BGPSessionStateProvider) {
((BGPSessionStateProvider) this.session).registerMessagesCounter(this);
}
final List<AddressFamilies> addPathTablesType = session.getAdvertisedAddPathTableTypes();
final Set<BgpTableType> advertizedTableTypes = session.getAdvertisedTableTypes();
final List<BgpTableType> advertizedGracefulRestartTableTypes = session.getAdvertisedGracefulRestartTableTypes();
LOG.info("Session with peer {} went up with tables {} and Add Path tables {}", this.name, advertizedTableTypes, addPathTablesType);
this.rawIdentifier = InetAddresses.forString(session.getBgpId().getValue()).getAddress();
final Set<TablesKey> setTables = advertizedTableTypes.stream().map(t -> new TablesKey(t.getAfi(), t.getSafi())).collect(Collectors.toSet());
this.tables = ImmutableSet.copyOf(setTables);
setAdvertizedGracefulRestartTableTypes(advertizedGracefulRestartTableTypes.stream().map(t -> new TablesKey(t.getAfi(), t.getSafi())).collect(Collectors.toList()));
this.addPathTableMaps = ImmutableMap.copyOf(mapTableTypesFamilies(addPathTablesType));
this.trackerRegistration = this.rib.getPeerTracker().registerPeer(this);
for (final TablesKey key : this.tables) {
createAdjRibOutListener(key, true);
}
addBgp4Support();
this.effRibInWriter = EffectiveRibInWriter.create(this, this.rib, this.rib.createPeerChain(this), this.peerIId, this.tables);
registerPrefixesCounters(this.effRibInWriter, this.effRibInWriter);
this.ribWriter = this.ribWriter.transform(this.peerId, this.rib.getRibSupportContext(), this.tables, this.addPathTableMaps);
if (this.rpcRegistry != null) {
this.rpcRegistration = this.rpcRegistry.addRoutedRpcImplementation(BgpPeerRpcService.class, new BgpPeerRpc(this, session, this.tables));
final KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.Peer, PeerKey> path = this.rib.getInstanceIdentifier().child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.Peer.class, new PeerKey(this.peerId));
this.rpcRegistration.registerPath(PeerContext.class, path);
}
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.AddressFamilies 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 = Sets.newHashSet();
final List<AddressFamilies> addPathCapabilitiesList = Lists.newArrayList();
for (final BgpParameters param : ((Open) message).getBgpParameters()) {
for (final OptionalCapabilities capa : param.getOptionalCapabilities()) {
final CParameters cParam = capa.getCParameters();
if (cParam.getAugmentation(CParameters1.class) == null) {
continue;
}
if (cParam.getAugmentation(CParameters1.class).getMultiprotocolCapability() != null) {
final MultiprotocolCapability p = cParam.getAugmentation(CParameters1.class).getMultiprotocolCapability();
LOG.debug("Adding open parameter {}", p);
final BgpTableType type = new BgpTableTypeImpl(p.getAfi(), p.getSafi());
tts.add(type);
} else if (cParam.getAugmentation(CParameters1.class).getAddPathCapability() != null) {
final AddPathCapability addPathCap = cParam.getAugmentation(CParameters1.class).getAddPathCapability();
addPathCapabilitiesList.addAll(addPathCap.getAddressFamilies());
}
}
}
listener.onSessionUp(new MockBGPSession(tts));
} 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.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.AddressFamilies in project bgpcep by opendaylight.
the class OpenConfigMappingUtilTest method toAddPathCapability.
@Test
public void toAddPathCapability() {
final List<AfiSafi> families = new ArrayList<>();
families.add(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).addAugmentation(NeighborAddPathsConfig.class, new NeighborAddPathsConfigBuilder().setReceive(true).setSendMax(Shorts.checkedCast(ALL_PATHS)).build()).build());
families.add(new AfiSafiBuilder().setAfiSafiName(IPV6UNICAST.class).addAugmentation(NeighborAddPathsConfig.class, new NeighborAddPathsConfigBuilder().setReceive(false).setSendMax(Shorts.checkedCast(N_PATHS)).build()).build());
families.add(new AfiSafiBuilder().setAfiSafiName(IPV6LABELLEDUNICAST.class).addAugmentation(NeighborAddPathsConfig.class, new NeighborAddPathsConfigBuilder().setReceive(false).build()).build());
final List<AddressFamilies> result = OpenConfigMappingUtil.toAddPathCapability(families, this.tableTypeRegistry);
assertEquals(FAMILIES, result);
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.AddressFamilies 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