Search in sources :

Example 1 with BgpPeer

use of org.onosproject.bgp.controller.BgpPeer in project onos by opennetworkinglab.

the class BgpConfig method disconnectPeer.

@Override
public boolean disconnectPeer(String routerid) {
    BgpPeerCfg lspeer = this.bgpPeerTree.get(routerid);
    if (lspeer != null) {
        BgpPeer disconnPeer = peerManager.getPeer(BgpId.bgpId(IpAddress.valueOf(routerid)));
        if (disconnPeer != null) {
            // TODO: send notification peer deconfigured
            disconnPeer.disconnectPeer();
        } else if (lspeer.connectPeer() != null) {
            lspeer.connectPeer().disconnectPeer();
        }
        lspeer.setState(BgpPeerCfg.State.IDLE);
        lspeer.setSelfInnitConnection(false);
        log.debug("Disconnected : " + routerid + " successfully");
        return true;
    } else {
        log.debug("Did not find : " + routerid);
        return false;
    }
}
Also used : BgpPeer(org.onosproject.bgp.controller.BgpPeer) BgpPeerCfg(org.onosproject.bgp.controller.BgpPeerCfg)

Example 2 with BgpPeer

use of org.onosproject.bgp.controller.BgpPeer in project onos by opennetworkinglab.

the class BgpControllerImpl method processBgpPacket.

@Override
public void processBgpPacket(BgpId bgpId, BgpMessage msg) throws BgpParseException {
    BgpPeer peer = getPeer(bgpId);
    switch(msg.getType()) {
        case OPEN:
            // TODO: Process Open message
            break;
        case KEEP_ALIVE:
            // TODO: Process keepalive message
            break;
        case NOTIFICATION:
            // TODO: Process notificatoin message
            break;
        case UPDATE:
            BgpUpdateMsg updateMsg = (BgpUpdateMsg) msg;
            List<BgpValueType> pathAttr = updateMsg.bgpPathAttributes().pathAttributes();
            if (pathAttr == null) {
                log.debug("llPathAttr is null, cannot process update message");
                break;
            }
            Iterator<BgpValueType> listIterator = pathAttr.iterator();
            boolean isLinkstate = false;
            boolean isEvpn = false;
            while (listIterator.hasNext()) {
                BgpValueType attr = listIterator.next();
                if (attr instanceof MpReachNlri) {
                    MpReachNlri mpReach = (MpReachNlri) attr;
                    if (mpReach.bgpFlowSpecNlri() == null && mpReach.bgpEvpnNlri() == null) {
                        isLinkstate = true;
                    }
                    if (mpReach.bgpEvpnNlri() != null) {
                        isEvpn = true;
                    }
                } else if (attr instanceof MpUnReachNlri) {
                    MpUnReachNlri mpUnReach = (MpUnReachNlri) attr;
                    if (mpUnReach.bgpFlowSpecNlri() == null && mpUnReach.bgpEvpnNlri() == null) {
                        isLinkstate = true;
                    }
                    if (mpUnReach.bgpEvpnNlri() != null) {
                        isEvpn = true;
                    }
                }
            }
            if (isLinkstate) {
                peer.buildAdjRibIn(pathAttr);
            }
            if (isEvpn) {
                for (BgpRouteListener listener : bgpRouteListener) {
                    listener.processRoute(bgpId, updateMsg);
                }
            }
            break;
        default:
            // TODO: Process other message
            break;
    }
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) MpUnReachNlri(org.onosproject.bgpio.types.MpUnReachNlri) BgpPeer(org.onosproject.bgp.controller.BgpPeer) BgpUpdateMsg(org.onosproject.bgpio.protocol.BgpUpdateMsg) MpReachNlri(org.onosproject.bgpio.types.MpReachNlri) BgpRouteListener(org.onosproject.bgp.controller.BgpRouteListener)

Example 3 with BgpPeer

use of org.onosproject.bgp.controller.BgpPeer in project onos by opennetworkinglab.

the class BgpControllerImpl method closeConnectedPeers.

@Override
public void closeConnectedPeers() {
    BgpPeer bgpPeer;
    for (BgpId id : this.connectedPeers.keySet()) {
        bgpPeer = getPeer(id);
        bgpPeer.disconnectPeer();
    }
}
Also used : BgpPeer(org.onosproject.bgp.controller.BgpPeer) BgpId(org.onosproject.bgp.controller.BgpId)

Aggregations

BgpPeer (org.onosproject.bgp.controller.BgpPeer)3 BgpId (org.onosproject.bgp.controller.BgpId)1 BgpPeerCfg (org.onosproject.bgp.controller.BgpPeerCfg)1 BgpRouteListener (org.onosproject.bgp.controller.BgpRouteListener)1 BgpUpdateMsg (org.onosproject.bgpio.protocol.BgpUpdateMsg)1 BgpValueType (org.onosproject.bgpio.types.BgpValueType)1 MpReachNlri (org.onosproject.bgpio.types.MpReachNlri)1 MpUnReachNlri (org.onosproject.bgpio.types.MpUnReachNlri)1