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;
}
}
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;
}
}
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();
}
}
Aggregations