use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.MultiprotocolCapability in project bgpcep by opendaylight.
the class BmpRouterPeerImpl method setPeerTables.
private static Set<TablesKey> setPeerTables(final ReceivedOpen open) {
final Set<TablesKey> tables = Sets.newHashSet(DEFAULT_TABLE);
for (final BgpParameters param : open.getBgpParameters()) {
for (final OptionalCapabilities optCapa : param.getOptionalCapabilities()) {
final CParameters cParam = optCapa.getCParameters();
if (cParam.getAugmentation(CParameters1.class) == null || cParam.getAugmentation(CParameters1.class).getMultiprotocolCapability() == null) {
continue;
}
final MultiprotocolCapability multi = cParam.getAugmentation(CParameters1.class).getMultiprotocolCapability();
final TablesKey tt = new TablesKey(multi.getAfi(), multi.getSafi());
tables.add(tt);
}
}
return tables;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.MultiprotocolCapability in project bgpcep by opendaylight.
the class MultiProtocolCapabilityHandler method serializeCapability.
@Override
public void serializeCapability(final CParameters capability, final ByteBuf byteAggregator) {
final CParameters1 aug = capability.augmentation(CParameters1.class);
if (aug == null) {
return;
}
final MultiprotocolCapability mp = aug.getMultiprotocolCapability();
if (mp == null) {
return;
}
final ByteBuf capBuffer = Unpooled.buffer();
MultiprotocolCapabilitiesUtil.serializeMPAfiSafi(this.afiReg, this.safiReg, mp.getAfi(), mp.getSafi(), capBuffer);
CapabilityUtil.formatCapability(CODE, capBuffer, byteAggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.MultiprotocolCapability in project bgpcep by opendaylight.
the class BGPSessionStateImpl method advertizeCapabilities.
@Override
public synchronized void advertizeCapabilities(final int newHoldTimerValue, final SocketAddress newRemoteAddress, final SocketAddress localAddress, final Set<BgpTableType> tableTypes, final List<BgpParameters> bgpParameters) {
if (bgpParameters != null) {
for (final BgpParameters parameters : bgpParameters) {
for (final OptionalCapabilities optionalCapabilities : parameters.nonnullOptionalCapabilities()) {
final CParameters cParam = optionalCapabilities.getCParameters();
final CParameters1 capabilities = cParam.augmentation(CParameters1.class);
if (capabilities != null) {
final MultiprotocolCapability mc = capabilities.getMultiprotocolCapability();
if (mc != null) {
this.multiProtocolCapability = true;
}
if (capabilities.getGracefulRestartCapability() != null) {
this.gracefulRestartCapability = true;
}
if (capabilities.getAddPathCapability() != null) {
this.addPathCapability = true;
}
if (capabilities.getRouteRefreshCapability() != null) {
this.routerRefreshCapability = true;
}
}
if (cParam.getAs4BytesCapability() != null) {
this.asn32Capability = true;
}
}
}
}
this.holdTimerValue = newHoldTimerValue;
this.remoteAddress = StrictBGPPeerRegistry.getIpAddress(newRemoteAddress);
this.remotePort = new PortNumber(Uint16.valueOf(((InetSocketAddress) newRemoteAddress).getPort()));
this.localPort = new PortNumber(Uint16.valueOf(((InetSocketAddress) localAddress).getPort()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.MultiprotocolCapability 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.mp.capabilities.MultiprotocolCapability in project bgpcep by opendaylight.
the class ComplementaryTest method testBGPParameter.
@Test
public void testBGPParameter() {
final MultiprotocolCapability cap = new MultiprotocolCapabilityBuilder().setAfi(Ipv6AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build();
final CParameters tlv1 = new CParametersBuilder().addAugmentation(new CParameters1Builder().setMultiprotocolCapability(cap).build()).build();
final MultiprotocolCapability cap1 = new MultiprotocolCapabilityBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build();
final CParameters tlv2 = new CParametersBuilder().addAugmentation(new CParameters1Builder().setMultiprotocolCapability(cap1).build()).build();
final Map<TablesKey, Tables> tt = BindingMap.of(new TablesBuilder().setAfi(Ipv6AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build(), new TablesBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build());
final GracefulRestartCapability tlv3 = new GracefulRestartCapabilityBuilder().setRestartFlags(new RestartFlags(Boolean.FALSE)).setRestartTime(Uint16.ZERO).setTables(tt).build();
final CParameters tlv4 = new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(Uint32.valueOf(40))).build()).build();
assertFalse(tlv3.getRestartFlags().getRestartState());
assertEquals(0, tlv3.getRestartTime().intValue());
assertNotEquals(tlv1, tlv2);
assertNotSame(tlv1.hashCode(), tlv3.hashCode());
assertNotSame(tlv2.toString(), tlv3.toString());
assertEquals(tt, tlv3.getTables());
assertEquals(cap.getSafi(), cap1.getSafi());
assertNotSame(cap.getAfi(), cap1.getAfi());
assertEquals(40, tlv4.getAs4BytesCapability().getAsNumber().getValue().longValue());
assertEquals(new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(Uint32.valueOf(40))).build()).build(), tlv4);
}
Aggregations