Search in sources :

Example 1 with BgpParameters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters in project bgpcep by opendaylight.

the class AbstractAddPathTest method configurePeer.

protected static BGPPeer configurePeer(final Ipv4Address peerAddress, final RIBImpl ribImpl, final BgpParameters bgpParameters, final PeerRole peerRole, final BGPPeerRegistry bgpPeerRegistry) {
    final IpAddress ipAddress = new IpAddress(peerAddress);
    final BGPPeer bgpPeer = new BGPPeer(new IpAddress(peerAddress), ribImpl, peerRole, null, AFI_SAFIS_ADVERTIZED, Collections.emptySet());
    final List<BgpParameters> tlvs = Lists.newArrayList(bgpParameters);
    bgpPeerRegistry.addPeer(ipAddress, bgpPeer, new BGPSessionPreferences(AS_NUMBER, HOLDTIMER, new BgpId(RIB_ID), AS_NUMBER, tlvs));
    bgpPeer.instantiateServiceInstance();
    return bgpPeer;
}
Also used : BGPSessionPreferences(org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences) BgpId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters)

Example 2 with BgpParameters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters in project bgpcep by opendaylight.

the class AddPathAllPathsTest method testUseCase1.

/*
     * All-Paths
     *                                            ___________________
     *                                           | ODL BGP 127.0.0.1 |
     * [peer://127.0.0.2; p1, lp100] --(iBGP)--> |                   | --(RR-client, non add-path) --> [Peer://127.0.0.5; (p1, lp100), (p1, lp1200)]
     * [peer://127.0.0.3; p1, lp200] --(iBGP)--> |                   |
     * [peer://127.0.0.4; p1, lp50] --(iBGP)-->  |                   | --(RR-client, add-path) --> [Peer://127.0.0.6; (p1, path-id1, lp100), (p1, path-id2, pl50), (p1, path-id3, pl200), (p1, path-id4, pl20)]
     * [peer://127.0.0.2; p1, lp20] --(iBGP)-->  |___________________|
     * p1 = 1.1.1.1/32
     */
@Test
public void testUseCase1() throws Exception {
    final BgpParameters nonAddPathParams = createParameter(false);
    final BgpParameters addPathParams = createParameter(true);
    final BGPPeer peer1 = configurePeer(PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
    final BGPSessionImpl session1 = createPeerSession(PEER1, nonAddPathParams, new SimpleSessionListener());
    configurePeer(PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
    final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener());
    configurePeer(PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
    final BGPSessionImpl session3 = createPeerSession(PEER3, nonAddPathParams, new SimpleSessionListener());
    final SimpleSessionListener listener4 = new SimpleSessionListener();
    final BGPPeer peer4 = configurePeer(PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
    BGPPeerState peer4State = peer4.getPeerState();
    assertNull(peer4State.getGroupId());
    assertEquals(new IpAddress(PEER4), peer4State.getNeighborAddress());
    assertEquals(0L, peer4State.getTotalPathsCount());
    assertEquals(0L, peer4State.getTotalPrefixes());
    assertNull(peer4State.getBGPTimersState());
    assertNull(peer4State.getBGPTransportState());
    assertNull(peer4State.getBGPSessionState());
    assertEquals(0L, peer4State.getBGPErrorHandlingState().getErroneousUpdateReceivedCount());
    BGPGracelfulRestartState gracefulRestart = peer4State.getBGPGracelfulRestart();
    assertFalse(gracefulRestart.isGracefulRestartAdvertized(TABLES_KEY));
    assertFalse(gracefulRestart.isGracefulRestartReceived(TABLES_KEY));
    assertFalse(gracefulRestart.isLocalRestarting());
    assertFalse(gracefulRestart.isPeerRestarting());
    assertEquals(0L, gracefulRestart.getPeerRestartTime());
    BGPAfiSafiState afiSafiState = peer4State.getBGPAfiSafiState();
    assertEquals(AFI_SAFIS_ADVERTIZED, afiSafiState.getAfiSafisAdvertized());
    assertEquals(Collections.emptySet(), afiSafiState.getAfiSafisReceived());
    assertEquals(0L, afiSafiState.getPrefixesSentCount(TABLES_KEY));
    assertEquals(0L, afiSafiState.getPrefixesReceivedCount(TABLES_KEY));
    assertEquals(0L, afiSafiState.getPrefixesInstalledCount(TABLES_KEY));
    assertFalse(afiSafiState.isGracefulRestartAdvertized(TABLES_KEY));
    assertFalse(afiSafiState.isGracefulRestartAdvertized(TABLES_KEY));
    assertFalse(afiSafiState.isLocalRestarting());
    assertFalse(afiSafiState.isPeerRestarting());
    assertFalse(afiSafiState.isAfiSafiSupported(TABLES_KEY));
    final BGPSessionImpl session4 = createPeerSession(PEER4, nonAddPathParams, listener4);
    final SimpleSessionListener listener5 = new SimpleSessionListener();
    configurePeer(PEER5, this.ribImpl, addPathParams, PeerRole.RrClient, this.serverRegistry);
    final BGPSessionImpl session5 = createPeerSession(PEER5, addPathParams, listener5);
    checkPeersPresentOnDataStore(5);
    // the best route
    sendRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 1);
    checkReceivedMessages(listener4, 1);
    checkReceivedMessages(listener5, 1);
    assertEquals(UPD_100, listener5.getListMsg().get(0));
    final BGPPeerState peer1State = peer1.getPeerState();
    assertNull(peer1State.getGroupId());
    assertEquals(new IpAddress(PEER1), peer1State.getNeighborAddress());
    assertEquals(1L, peer1State.getTotalPathsCount());
    assertEquals(1L, peer1State.getTotalPrefixes());
    final BGPTimersState timerStatePeer1 = peer1State.getBGPTimersState();
    assertEquals(HOLDTIMER, timerStatePeer1.getNegotiatedHoldTime());
    assertTrue(timerStatePeer1.getUpTime() > 0L);
    final BGPTransportState transportStatePeer1 = peer1State.getBGPTransportState();
    assertEquals(new PortNumber(PORT), transportStatePeer1.getLocalPort());
    assertEquals(new IpAddress(PEER1), transportStatePeer1.getRemoteAddress());
    assertEquals(State.UP, peer1State.getBGPSessionState().getSessionState());
    checkEquals(() -> assertEquals(1L, peer1State.getBGPPeerMessagesState().getUpdateMessagesReceivedCount()));
    checkEquals(() -> assertEquals(0L, peer1State.getBGPPeerMessagesState().getUpdateMessagesSentCount()));
    final BGPSessionState sessionStatePeer1 = peer1State.getBGPSessionState();
    assertFalse(sessionStatePeer1.isAddPathCapabilitySupported());
    assertFalse(sessionStatePeer1.isAsn32CapabilitySupported());
    assertFalse(sessionStatePeer1.isGracefulRestartCapabilitySupported());
    assertTrue(sessionStatePeer1.isMultiProtocolCapabilitySupported());
    assertFalse(sessionStatePeer1.isRouterRefreshCapabilitySupported());
    final BGPAfiSafiState afiSafiStatePeer1 = peer1State.getBGPAfiSafiState();
    assertEquals(AFI_SAFIS_ADVERTIZED, afiSafiStatePeer1.getAfiSafisAdvertized());
    assertEquals(AFI_SAFIS_ADVERTIZED, afiSafiStatePeer1.getAfiSafisReceived());
    assertEquals(0L, afiSafiStatePeer1.getPrefixesSentCount(TABLES_KEY));
    assertEquals(1L, afiSafiStatePeer1.getPrefixesReceivedCount(TABLES_KEY));
    assertEquals(1L, afiSafiStatePeer1.getPrefixesInstalledCount(TABLES_KEY));
    assertFalse(afiSafiStatePeer1.isGracefulRestartAdvertized(TABLES_KEY));
    assertFalse(afiSafiStatePeer1.isGracefulRestartAdvertized(TABLES_KEY));
    assertFalse(afiSafiStatePeer1.isLocalRestarting());
    assertFalse(afiSafiStatePeer1.isPeerRestarting());
    assertTrue(afiSafiStatePeer1.isAfiSafiSupported(TABLES_KEY));
    final BGPRibState ribState = this.ribImpl.getRIBState();
    assertEquals(1, ribState.getPathsCount().size());
    assertEquals(1L, ribState.getTablesPrefixesCount().size());
    assertEquals(BGP_ID, ribState.getRouteId());
    assertEquals(AS_NUMBER, ribState.getAs());
    assertEquals(1L, ribState.getPathCount(TABLES_KEY));
    assertEquals(1L, ribState.getPrefixesCount(TABLES_KEY));
    assertEquals(1L, ribState.getTotalPathsCount());
    assertEquals(1L, ribState.getTotalPrefixesCount());
    final SimpleSessionListener listener6 = new SimpleSessionListener();
    final BGPPeer peer6 = configurePeer(PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
    final BGPSessionImpl session6 = createPeerSession(PEER6, nonAddPathParams, listener6);
    checkPeersPresentOnDataStore(6);
    checkReceivedMessages(listener6, 1);
    assertEquals(UPD_NA_100, listener6.getListMsg().get(0));
    causeBGPError(session6);
    checkEquals(() -> assertEquals(1L, peer6.getPeerState().getBGPPeerMessagesState().getNotificationMessagesSentCount()));
    checkPeersPresentOnDataStore(5);
    // the second best route
    sendRouteAndCheckIsOnLocRib(session2, PREFIX1, 50, 2);
    checkReceivedMessages(listener4, 1);
    checkReceivedMessages(listener5, 2);
    assertEquals(UPD_50, listener5.getListMsg().get(1));
    // new best route
    sendRouteAndCheckIsOnLocRib(session3, PREFIX1, 200, 3);
    checkReceivedMessages(listener4, 2);
    checkReceivedMessages(listener5, 3);
    assertEquals(UPD_200, listener5.getListMsg().get(2));
    peer4State = peer4.getPeerState();
    assertNull(peer4State.getGroupId());
    assertEquals(new IpAddress(PEER4), peer4State.getNeighborAddress());
    assertEquals(0L, peer4State.getTotalPathsCount());
    assertEquals(0L, peer4State.getTotalPrefixes());
    final BGPTimersState timerState = peer4State.getBGPTimersState();
    assertEquals(HOLDTIMER, timerState.getNegotiatedHoldTime());
    assertTrue(timerState.getUpTime() > 0L);
    final BGPTransportState transportState = peer4State.getBGPTransportState();
    assertEquals(new PortNumber(PORT), transportState.getLocalPort());
    assertEquals(new IpAddress(PEER4), transportState.getRemoteAddress());
    final BGPPeerMessagesState peerMessagesState = peer4State.getBGPPeerMessagesState();
    assertEquals(0L, peerMessagesState.getNotificationMessagesReceivedCount());
    assertEquals(0L, peerMessagesState.getNotificationMessagesSentCount());
    assertEquals(0L, peerMessagesState.getUpdateMessagesReceivedCount());
    assertEquals(2L, peerMessagesState.getUpdateMessagesSentCount());
    final BGPSessionState bgpSessionState = peer4State.getBGPSessionState();
    assertEquals(State.UP, bgpSessionState.getSessionState());
    assertFalse(bgpSessionState.isAddPathCapabilitySupported());
    assertFalse(bgpSessionState.isAsn32CapabilitySupported());
    assertFalse(bgpSessionState.isGracefulRestartCapabilitySupported());
    assertTrue(bgpSessionState.isMultiProtocolCapabilitySupported());
    assertFalse(bgpSessionState.isRouterRefreshCapabilitySupported());
    final BGPErrorHandlingState errorHandling = peer4State.getBGPErrorHandlingState();
    assertEquals(0L, errorHandling.getErroneousUpdateReceivedCount());
    gracefulRestart = peer4State.getBGPGracelfulRestart();
    assertFalse(gracefulRestart.isGracefulRestartAdvertized(TABLES_KEY));
    assertFalse(gracefulRestart.isGracefulRestartReceived(TABLES_KEY));
    assertFalse(gracefulRestart.isLocalRestarting());
    assertFalse(gracefulRestart.isPeerRestarting());
    assertEquals(0L, gracefulRestart.getPeerRestartTime());
    afiSafiState = peer4State.getBGPAfiSafiState();
    assertEquals(AFI_SAFIS_ADVERTIZED, afiSafiState.getAfiSafisAdvertized());
    assertEquals(AFI_SAFIS_ADVERTIZED, afiSafiState.getAfiSafisReceived());
    assertEquals(2L, afiSafiState.getPrefixesSentCount(TABLES_KEY));
    assertEquals(0L, afiSafiState.getPrefixesReceivedCount(TABLES_KEY));
    assertEquals(0L, afiSafiState.getPrefixesInstalledCount(TABLES_KEY));
    assertFalse(afiSafiState.isGracefulRestartAdvertized(TABLES_KEY));
    assertFalse(afiSafiState.isGracefulRestartAdvertized(TABLES_KEY));
    assertFalse(afiSafiState.isLocalRestarting());
    assertFalse(afiSafiState.isPeerRestarting());
    assertTrue(afiSafiState.isAfiSafiSupported(TABLES_KEY));
    // the worst route
    sendRouteAndCheckIsOnLocRib(session1, PREFIX1, 20, 3);
    checkReceivedMessages(listener4, 2);
    checkReceivedMessages(listener5, 4);
    assertEquals(UPD_200.getAttributes().getLocalPref(), ((Update) listener4.getListMsg().get(1)).getAttributes().getLocalPref());
    assertEquals(UPD_20, listener5.getListMsg().get(3));
    // withdraw second best route, 1 advertisement(1 withdrawal) for add-path supported, none for non add path
    sendWithdrawalRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 2);
    checkReceivedMessages(listener4, 2);
    checkReceivedMessages(listener5, 5);
    // we advertise again to try new test
    sendRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 3);
    checkReceivedMessages(listener4, 2);
    checkReceivedMessages(listener5, 6);
    assertEquals(UPD_200, listener5.getListMsg().get(2));
    // withdraw second best route, 1 advertisement(1 withdrawal) for add-path supported, 1 for non add path (withdrawal)
    sendWithdrawalRouteAndCheckIsOnLocRib(session3, PREFIX1, 200, 2);
    checkReceivedMessages(listener4, 3);
    checkReceivedMessages(listener5, 7);
    sendNotification(session1);
    checkEquals(() -> assertEquals(1L, peer1.getPeerState().getBGPPeerMessagesState().getNotificationMessagesReceivedCount()));
    session1.close();
    session2.close();
    session3.close();
    session4.close();
    session5.close();
}
Also used : BGPTimersState(org.opendaylight.protocol.bgp.rib.spi.state.BGPTimersState) BGPTransportState(org.opendaylight.protocol.bgp.rib.spi.state.BGPTransportState) BGPSessionState(org.opendaylight.protocol.bgp.rib.spi.state.BGPSessionState) BGPPeerState(org.opendaylight.protocol.bgp.rib.spi.state.BGPPeerState) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update) BGPAfiSafiState(org.opendaylight.protocol.bgp.rib.spi.state.BGPAfiSafiState) BGPRibState(org.opendaylight.protocol.bgp.rib.spi.state.BGPRibState) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) BGPPeerMessagesState(org.opendaylight.protocol.bgp.rib.spi.state.BGPPeerMessagesState) BGPGracelfulRestartState(org.opendaylight.protocol.bgp.rib.spi.state.BGPGracelfulRestartState) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) BGPErrorHandlingState(org.opendaylight.protocol.bgp.rib.spi.state.BGPErrorHandlingState) Test(org.junit.Test)

Example 3 with BgpParameters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters in project bgpcep by opendaylight.

the class AddPathNPathsTest method testUseCase1.

/*
     * N-Paths
     *                                            ___________________
     *                                           | ODL BGP 127.0.0.1 |
     * [peer://127.0.0.2; p1, lp100] --(iBGP)--> |                   | --(RR-client, non add-path) --> [Peer://127.0.0.5; (p1, lp100), (p1, lp1200)]
     * [peer://127.0.0.3; p1, lp200] --(iBGP)--> |                   |
     * [peer://127.0.0.4; p1, lp50] --(iBGP)-->  |                   | --(RR-client, add-path) --> [Peer://127.0.0.6; (p1, path-id1, lp100), (p1, path-id2, pl50), (p1, path-id3, pl200)]
     * [peer://127.0.0.2; p1, lp20] --(iBGP)-->  |___________________|
     * p1 = 1.1.1.1/32
     */
@Test
public void testUseCase1() throws Exception {
    final BgpParameters nonAddPathParams = createParameter(false);
    final BgpParameters addPathParams = createParameter(true);
    configurePeer(PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
    final BGPSessionImpl session1 = createPeerSession(PEER1, nonAddPathParams, new SimpleSessionListener());
    configurePeer(PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
    final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener());
    configurePeer(PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
    final BGPSessionImpl session3 = createPeerSession(PEER3, nonAddPathParams, new SimpleSessionListener());
    final SimpleSessionListener listener4 = new SimpleSessionListener();
    configurePeer(PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
    final BGPSessionImpl session4 = createPeerSession(PEER4, nonAddPathParams, listener4);
    final SimpleSessionListener listener5 = new SimpleSessionListener();
    configurePeer(PEER5, this.ribImpl, addPathParams, PeerRole.RrClient, this.serverRegistry);
    final BGPSessionImpl session5 = createPeerSession(PEER5, addPathParams, listener5);
    checkPeersPresentOnDataStore(5);
    // new best route so far
    sendRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 1);
    checkReceivedMessages(listener4, 1);
    checkReceivedMessages(listener5, 1);
    assertEquals(UPD_100, listener5.getListMsg().get(0));
    final SimpleSessionListener listener6 = new SimpleSessionListener();
    configurePeer(PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
    final BGPSessionImpl session6 = createPeerSession(PEER6, nonAddPathParams, listener6);
    checkPeersPresentOnDataStore(6);
    checkReceivedMessages(listener6, 1);
    assertEquals(UPD_NA_100, listener6.getListMsg().get(0));
    session6.close();
    checkPeersPresentOnDataStore(5);
    // the second best route
    sendRouteAndCheckIsOnLocRib(session2, PREFIX1, 50, 2);
    checkReceivedMessages(listener4, 1);
    checkReceivedMessages(listener5, 2);
    assertEquals(UPD_50, listener5.getListMsg().get(1));
    // new best route
    sendRouteAndCheckIsOnLocRib(session3, PREFIX1, 200, 2);
    checkReceivedMessages(listener4, 2);
    checkReceivedMessages(listener5, 3);
    assertEquals(UPD_200, listener5.getListMsg().get(2));
    // the worst prefix, no changes
    sendRouteAndCheckIsOnLocRib(session2, PREFIX1, 20, 2);
    checkReceivedMessages(listener4, 2);
    checkReceivedMessages(listener5, 3);
    // withdraw second best route, 2 advertisement (1 withdrawal) for add-path supported, none for non add path
    sendWithdrawalRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 2);
    checkReceivedMessages(listener4, 2);
    checkReceivedMessages(listener5, 5);
    // we advertise again to try new test
    sendRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 2);
    checkReceivedMessages(listener4, 2);
    checkReceivedMessages(listener5, 6);
    // withdraw second best route, 2 advertisement (1 withdrawal) for add-path supported, 1 withdrawal for non add path
    sendWithdrawalRouteAndCheckIsOnLocRib(session3, PREFIX1, 200, 2);
    checkReceivedMessages(listener4, 3);
    checkReceivedMessages(listener5, 8);
    session1.close();
    session2.close();
    session3.close();
    session4.close();
    session5.close();
}
Also used : BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) Test(org.junit.Test)

Example 4 with BgpParameters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters in project bgpcep by opendaylight.

the class PeerTest method mockSession.

private void mockSession() {
    final EventLoop eventLoop = mock(EventLoop.class);
    final Channel channel = mock(Channel.class);
    final ChannelPipeline pipeline = mock(ChannelPipeline.class);
    doReturn(null).when(eventLoop).schedule(any(Runnable.class), any(long.class), any(TimeUnit.class));
    doReturn(eventLoop).when(channel).eventLoop();
    doReturn(Boolean.TRUE).when(channel).isWritable();
    doReturn(null).when(channel).close();
    doReturn(pipeline).when(channel).pipeline();
    doCallRealMethod().when(channel).toString();
    doReturn(pipeline).when(pipeline).addLast(any(ChannelHandler.class));
    doReturn(new DefaultChannelPromise(channel)).when(channel).writeAndFlush(any(Notification.class));
    doReturn(new InetSocketAddress("localhost", 12345)).when(channel).remoteAddress();
    doReturn(new InetSocketAddress("localhost", 12345)).when(channel).localAddress();
    final List<BgpParameters> params = Lists.newArrayList(new BgpParametersBuilder().setOptionalCapabilities(Lists.newArrayList(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build()).build()).build()).build())).build());
    final Open openObj = new OpenBuilder().setBgpIdentifier(new Ipv4Address("1.1.1.1")).setHoldTimer(50).setMyAsNumber(72).setBgpParameters(params).build();
    this.session = new BGPSessionImpl(this.classic, channel, openObj, 30, null);
    this.session.setChannelExtMsgCoder(openObj);
}
Also used : OptionalCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.OptionalCapabilitiesBuilder) MultiprotocolCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.MultiprotocolCapabilityBuilder) OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OpenBuilder) InetSocketAddress(java.net.InetSocketAddress) Channel(io.netty.channel.Channel) ChannelHandler(io.netty.channel.ChannelHandler) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) BgpParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParametersBuilder) CParameters1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1) ChannelPipeline(io.netty.channel.ChannelPipeline) Notification(org.opendaylight.yangtools.yang.binding.Notification) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Open) CParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParametersBuilder) CParameters1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1Builder) EventLoop(io.netty.channel.EventLoop) DefaultChannelPromise(io.netty.channel.DefaultChannelPromise) TimeUnit(java.util.concurrent.TimeUnit) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 5 with BgpParameters

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters 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);
        }
    }
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) Set(java.util.Set) Keepalive(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Keepalive) CParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParameters) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) CParameters1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Open) OptionalCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.OptionalCapabilities) BGPTerminationReason(org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason) MultiprotocolCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.MultiprotocolCapability) BGPDocumentedException(org.opendaylight.protocol.bgp.parser.BGPDocumentedException) AddPathCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.AddPathCapability) List(java.util.List) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)

Aggregations

BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters)26 OptionalCapabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.OptionalCapabilities)19 BgpParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParametersBuilder)15 OptionalCapabilitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.OptionalCapabilitiesBuilder)13 CParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParametersBuilder)13 CParameters1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1Builder)13 MultiprotocolCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.MultiprotocolCapabilityBuilder)12 Test (org.junit.Test)11 OpenBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OpenBuilder)11 CParameters1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1)11 Open (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Open)10 ByteBuf (io.netty.buffer.ByteBuf)7 InetSocketAddress (java.net.InetSocketAddress)7 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)7 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)7 As4BytesCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapabilityBuilder)7 ProtocolVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.ProtocolVersion)6 Notification (org.opendaylight.yangtools.yang.binding.Notification)6 BGPSessionPreferences (org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences)5 BgpId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId)5