use of org.onosproject.bgpio.protocol.BgpUpdateMsg 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;
}
}
Aggregations