当前位置: 首页>>代码示例>>Java>>正文


Java BgpUpdateMsg类代码示例

本文整理汇总了Java中org.onosproject.bgpio.protocol.BgpUpdateMsg的典型用法代码示例。如果您正苦于以下问题:Java BgpUpdateMsg类的具体用法?Java BgpUpdateMsg怎么用?Java BgpUpdateMsg使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BgpUpdateMsg类属于org.onosproject.bgpio.protocol包,在下文中一共展示了BgpUpdateMsg类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processBgpPacket

import org.onosproject.bgpio.protocol.BgpUpdateMsg; //导入依赖的package包/类
@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;

        while (listIterator.hasNext()) {
            BgpValueType attr = listIterator.next();
            if (attr instanceof MpReachNlri) {
                MpReachNlri mpReach = (MpReachNlri) attr;
                if (mpReach.bgpFlowSpecNlri() == null) {
                    isLinkstate = true;
                }
            } else if (attr instanceof MpUnReachNlri) {
                MpUnReachNlri mpUnReach = (MpUnReachNlri) attr;
                if (mpUnReach.bgpFlowSpecNlri() == null) {
                    isLinkstate = true;
                }
            }
        }
        if (isLinkstate) {
            peer.buildAdjRibIn(pathAttr);
        }
        break;
    default:
        // TODO: Process other message
        break;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:49,代码来源:BgpControllerImpl.java

示例2: readFrom

import org.onosproject.bgpio.protocol.BgpUpdateMsg; //导入依赖的package包/类
@Override
public BgpUpdateMsg readFrom(ChannelBuffer cb, BgpHeader bgpHeader)
        throws BgpParseException {

    if (cb.readableBytes() != (bgpHeader.getLength() - MINIMUM_COMMON_HEADER_LENGTH)) {
        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
                BgpErrorType.BAD_MESSAGE_LENGTH, bgpHeader.getLength());
    }

    LinkedList<IpPrefix> withDrwRoutes = new LinkedList<>();
    LinkedList<IpPrefix> nlri = new LinkedList<>();
    BgpPathAttributes bgpPathAttributes = new BgpPathAttributes();
    // Reading Withdrawn Routes Length
    Short withDrwLen = cb.readShort();

    if (cb.readableBytes() < withDrwLen) {
        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
                BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
                cb.readableBytes());
    }
    ChannelBuffer tempCb = cb.readBytes(withDrwLen);
    if (withDrwLen != 0) {
        // Parsing WithdrawnRoutes
        withDrwRoutes = parseWithdrawnRoutes(tempCb);
    }
    if (cb.readableBytes() < MIN_LEN_AFTER_WITHDRW_ROUTES) {
        log.debug("Bgp Path Attribute len field not present");
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
                BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
    }

    // Reading Total Path Attribute Length
    short totPathAttrLen = cb.readShort();
    int len = withDrwLen + totPathAttrLen + PACKET_MINIMUM_LENGTH;
    if (len > bgpHeader.getLength()) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
                BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
    }
    if (totPathAttrLen != 0) {
        // Parsing BGPPathAttributes
        if (cb.readableBytes() < totPathAttrLen) {
            Validation
                    .validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
                                 BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
                                 cb.readableBytes());
        }
        tempCb = cb.readBytes(totPathAttrLen);
        bgpPathAttributes = BgpPathAttributes.read(tempCb);
    }
    if (cb.readableBytes() > 0) {
        // Parsing NLRI
        nlri = parseNlri(cb);
    }
    return new BgpUpdateMsgVer4(bgpHeader, withDrwRoutes,
            bgpPathAttributes, nlri);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:57,代码来源:BgpUpdateMsgVer4.java

示例3: build

import org.onosproject.bgpio.protocol.BgpUpdateMsg; //导入依赖的package包/类
@Override
public BgpUpdateMsg build() {
    BgpHeader bgpMsgHeader = DEFAULT_UPDATE_HEADER;

    return new BgpUpdateMsgVer4(bgpMsgHeader, withdrawnRoutes, bgpPathAttributes, nlri);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:7,代码来源:BgpUpdateMsgVer4.java

示例4: updateMessageBuilder

import org.onosproject.bgpio.protocol.BgpUpdateMsg; //导入依赖的package包/类
@Override
public BgpUpdateMsg.Builder updateMessageBuilder() {
    return new BgpUpdateMsgVer4.Builder();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:BgpFactoryVer4.java

示例5: processBgpPacket

import org.onosproject.bgpio.protocol.BgpUpdateMsg; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:63,代码来源:BgpControllerImpl.java

示例6: readFrom

import org.onosproject.bgpio.protocol.BgpUpdateMsg; //导入依赖的package包/类
@Override
public BgpUpdateMsg readFrom(ChannelBuffer cb, BgpHeader bgpHeader)
        throws BgpParseException {

    if (cb.readableBytes() != (bgpHeader.getLength() - MINIMUM_COMMON_HEADER_LENGTH)) {
        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
                BgpErrorType.BAD_MESSAGE_LENGTH, bgpHeader.getLength());
    }

    LinkedList<IpPrefix> withDrwRoutes = new LinkedList<>();
    LinkedList<IpPrefix> nlri = new LinkedList<>();
    BgpPathAttributes bgpPathAttributes = new BgpPathAttributes();

    Short withDrwLen = cb.readShort();

    if (cb.readableBytes() < withDrwLen) {
        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
                BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
                cb.readableBytes());
    }
    log.debug("Reading withdrawn routes length");
    ChannelBuffer tempCb = cb.readBytes(withDrwLen);
    if (withDrwLen != 0) {
        // Parsing WithdrawnRoutes
        withDrwRoutes = parseWithdrawnRoutes(tempCb);
        log.debug("Withdrawn routes parsed");
    }
    if (cb.readableBytes() < MIN_LEN_AFTER_WITHDRW_ROUTES) {
        log.debug("Bgp path attribute len field not present");
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
                BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
    }

    // Reading Total Path Attribute Length
    short totPathAttrLen = cb.readShort();
    int len = withDrwLen + totPathAttrLen + PACKET_MINIMUM_LENGTH;
    if (len > bgpHeader.getLength()) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
                BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
    }
    log.debug("Total path attribute length read");
    if (totPathAttrLen != 0) {
        // Parsing BGPPathAttributes
        if (cb.readableBytes() < totPathAttrLen) {
            Validation
                    .validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
                                 BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
                                 cb.readableBytes());
        }
        tempCb = cb.readBytes(totPathAttrLen);
        bgpPathAttributes = BgpPathAttributes.read(tempCb);
    }
    if (cb.readableBytes() > 0) {
        // Parsing NLRI
        nlri = parseNlri(cb);
    }
    return new BgpUpdateMsgVer4(bgpHeader, withDrwRoutes,
            bgpPathAttributes, nlri);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:60,代码来源:BgpUpdateMsgVer4.java

示例7: processRoute

import org.onosproject.bgpio.protocol.BgpUpdateMsg; //导入依赖的package包/类
/**
 * Notify that got an update message and operate route.
 *
 * @param bgpId bgp identifier
 * @param msg BGP update message
 */
void processRoute(BgpId bgpId, BgpUpdateMsg msg);
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:8,代码来源:BgpRouteListener.java


注:本文中的org.onosproject.bgpio.protocol.BgpUpdateMsg类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。