Search in sources :

Example 16 with Session

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session in project bgpcep by opendaylight.

the class NeighborUtil method buildCapabilityState.

/**
 * Builds  Neighbor State containing Capabilities State, session State.
 *
 * @return Neighbor State
 */
public static NeighborStateAugmentation buildCapabilityState(@NonNull final BGPSessionState neighbor) {
    final List<Class<? extends BgpCapability>> supportedCapabilities = buildSupportedCapabilities(neighbor);
    SessionState sessionState = null;
    switch(neighbor.getSessionState()) {
        case IDLE:
            sessionState = SessionState.IDLE;
            break;
        case UP:
            sessionState = SessionState.ESTABLISHED;
            break;
        case OPEN_CONFIRM:
            sessionState = SessionState.OPENCONFIRM;
            break;
        default:
    }
    return new NeighborStateAugmentationBuilder().setSupportedCapabilities(supportedCapabilities).setSessionState(sessionState).build();
}
Also used : BGPSessionState(org.opendaylight.protocol.bgp.rib.spi.state.BGPSessionState) SessionState(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.BgpNeighborState.SessionState) NeighborStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborStateAugmentationBuilder) BgpNeighborStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.BgpNeighborStateAugmentationBuilder) BgpCapability(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.BgpCapability)

Example 17 with Session

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session in project bgpcep by opendaylight.

the class GracefulRestartTest method insertRoutes.

private static void insertRoutes(final List<Ipv4Prefix> ipv4prefixes, final Ipv4AddressNoZone ipv4NeighborAddress, final List<Ipv6Prefix> ipv6prefixes, final Ipv6AddressNoZone ipv6NeighborAddress, final BGPSessionImpl session, final BgpOrigin peerRole) {
    if (ipv4prefixes == null && ipv6prefixes == null) {
        waitFutureSuccess(session.writeAndFlush(BgpPeerUtil.createEndOfRib(TABLES_KEY)));
        waitFutureSuccess(session.writeAndFlush(BgpPeerUtil.createEndOfRib(IPV6_TABLES_KEY)));
        return;
    }
    if (ipv4prefixes != null && !ipv4prefixes.isEmpty()) {
        final MpReachNlri reachIpv4 = PeerUtil.createMpReachNlri(new IpAddressNoZone(ipv4NeighborAddress), ipv4prefixes.stream().map(IpPrefix::new).collect(Collectors.toList()));
        final Update update1 = PeerUtil.createUpdate(peerRole, Collections.emptyList(), 100, reachIpv4, null);
        waitFutureSuccess(session.writeAndFlush(update1));
    }
    if (ipv6prefixes != null && !ipv4prefixes.isEmpty()) {
        final MpReachNlri reachIpv6 = PeerUtil.createMpReachNlri(new IpAddressNoZone(ipv6NeighborAddress), ipv6prefixes.stream().map(IpPrefix::new).collect(Collectors.toList()));
        final Update update2 = PeerUtil.createUpdate(peerRole, Collections.emptyList(), 100, reachIpv6, null);
        waitFutureSuccess(session.writeAndFlush(update2));
    }
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone) Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri)

Example 18 with Session

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session in project bgpcep by opendaylight.

the class GracefulRestartTest method nonIpv4PeerGracefulRestart.

/**
 * Test graceful restart of a non-IPv4 peer.
 * {@link BGPPeer#releaseConnection(boolean)} should not throw NPE and binding chain should be closed
 * successfully.
 *
 * @throws InterruptedException on create peer session.
 */
@Test
public void nonIpv4PeerGracefulRestart() throws InterruptedException {
    BgpParameters parametersv6 = PeerUtil.createBgpParameters(Collections.singletonList(IPV6_TABLES_KEY), Collections.emptyList(), Collections.singletonMap(IPV6_TABLES_KEY, true), GRACEFUL_RESTART_TIME);
    gracefulAfiSafiAdvertised.add(IPV6_TABLES_KEY);
    this.nonIpv4 = configurePeer(this.tableRegistry, PEER2, this.ribImpl, parametersv6, PeerRole.Ibgp, this.serverRegistry, afiSafiAdvertised, gracefulAfiSafiAdvertised);
    this.sessionv6 = createPeerSession(PEER2, parametersv6, this.listener);
    final Open open = createClassicOpen(true);
    this.sessionv6.writeAndFlush(open);
    checkIdleState(this.nonIpv4);
    synchronized (this.nonIpv4) {
        assertNull(this.nonIpv4.ribOutChain);
    }
}
Also used : BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Open) Test(org.junit.Test)

Example 19 with Session

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session in project bgpcep by opendaylight.

the class AbstractAddPathTest method sendNotification.

void sendNotification(final BGPSessionImpl session) {
    final Notification notMsg = new NotifyBuilder().setErrorCode(BGPError.OPT_PARAM_NOT_SUPPORTED.getCode()).setErrorSubcode(BGPError.OPT_PARAM_NOT_SUPPORTED.getSubcode()).setData(new byte[] { 4, 9 }).build();
    waitFutureSuccess(session.writeAndFlush(notMsg));
}
Also used : NotifyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.NotifyBuilder) Notification(org.opendaylight.yangtools.yang.binding.Notification)

Example 20 with Session

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session in project bgpcep by opendaylight.

the class PCEPSessionImpl method handleMessage.

/**
 * Handles incoming message. If the session is up, it notifies the user. The user is notified about every message
 * except KeepAlive.
 *
 * @param msg incoming message
 */
public synchronized void handleMessage(final Message msg) {
    if (this.closed.get()) {
        LOG.debug("PCEP Session {} is already closed, skip handling incoming message {}", this, msg);
        return;
    }
    // Update last reception time
    this.lastMessageReceivedAt = TICKER.read();
    this.sessionState.updateLastReceivedMsg();
    if (!(msg instanceof KeepaliveMessage)) {
        LOG.debug("PCEP message {} received.", msg);
    }
    // Internal message handling. The user does not see these messages
    if (msg instanceof KeepaliveMessage) {
    // Do nothing, the timer has been already reset
    } else if (msg instanceof OpenMessage) {
        this.sendErrorMessage(PCEPErrors.ATTEMPT_2ND_SESSION);
    } else if (msg instanceof CloseMessage) {
        /*
             * Session is up, we are reporting all messages to user. One notable
             * exception is CLOSE message, which needs to be converted into a
             * session DOWN event.
             */
        close();
        this.listener.onSessionTerminated(this, new PCEPCloseTermination(TerminationReason.forValue(((CloseMessage) msg).getCCloseMessage().getCClose().getReason())));
    } else {
        // This message needs to be handled by the user
        if (msg instanceof PcerrMessage) {
            this.sessionState.setLastReceivedError(msg);
        }
        this.listener.onMessage(this, msg);
    }
}
Also used : PCEPCloseTermination(org.opendaylight.protocol.pcep.PCEPCloseTermination) OpenMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.OpenMessage) PcerrMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.PcerrMessage) CloseMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.CloseMessage) KeepaliveMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.KeepaliveMessage)

Aggregations

Test (org.junit.Test)48 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcrpt)19 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)18 Session (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session)17 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)16 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId)16 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder)15 Tlvs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.Tlvs)13 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)13 PCEPSession (org.opendaylight.protocol.pcep.PCEPSession)10 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)8 ArrayList (java.util.ArrayList)6 AddLspOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.AddLspOutput)6 InetAddress (java.net.InetAddress)5 List (java.util.List)5 Pcinitiate (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Pcinitiate)5 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests)5 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)5 BigInteger (java.math.BigInteger)4 Collections (java.util.Collections)4