Search in sources :

Example 1 with BgpRouteListener

use of org.onosproject.bgp.controller.BgpRouteListener 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)

Aggregations

BgpPeer (org.onosproject.bgp.controller.BgpPeer)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