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


Java MpReachNlri类代码示例

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


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

示例1: processBgpPacket

import org.onosproject.bgpio.types.MpReachNlri; //导入依赖的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: write

import org.onosproject.bgpio.types.MpReachNlri; //导入依赖的package包/类
@Override
public void write(ChannelBuffer cb, BgpUpdateMsgVer4 message) throws BgpParseException {

    int startIndex = cb.writerIndex();
    short afi = 0;
    byte safi = 0;

    // write common header and get msg length index
    int msgLenIndex = message.bgpHeader.write(cb);

    if (msgLenIndex <= 0) {
        throw new BgpParseException("Unable to write message header.");
    }
    List<BgpValueType> pathAttr = message.bgpPathAttributes.pathAttributes();
    if (pathAttr != null) {
        Iterator<BgpValueType> listIterator = pathAttr.iterator();

        while (listIterator.hasNext()) {
            BgpValueType attr = listIterator.next();
            if (attr instanceof MpReachNlri) {
                MpReachNlri mpReach = (MpReachNlri) attr;
                afi = mpReach.afi();
                safi = mpReach.safi();
            } else if (attr instanceof MpUnReachNlri) {
                MpUnReachNlri mpUnReach = (MpUnReachNlri) attr;
                afi = mpUnReach.afi();
                safi = mpUnReach.safi();
            }
        }

        if ((afi == Constants.AFI_FLOWSPEC_VALUE) || (afi == Constants.AFI_VALUE)) {
            //unfeasible route length
            cb.writeShort(0);
        }

    }

    if (message.bgpPathAttributes != null) {
        message.bgpPathAttributes.write(cb);
    }

    // write UPDATE Object Length
    int length = cb.writerIndex() - startIndex;
    cb.setShort(msgLenIndex, (short) length);
    message.bgpHeader.setLength((short) length);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:47,代码来源:BgpUpdateMsgVer4.java

示例3: read

import org.onosproject.bgpio.types.MpReachNlri; //导入依赖的package包/类
/**
 * Reads from channelBuffer and parses BGP path attributes.
 *
 * @param cb channelBuffer
 * @return object of BgpPathAttributes
 * @throws BgpParseException while parsing BGP path attributes
 */
public static BgpPathAttributes read(ChannelBuffer cb)
        throws BgpParseException {

    BgpValueType pathAttribute = null;
    List<BgpValueType> pathAttributeList = new LinkedList<>();
    boolean isOrigin = false;
    boolean isAsPath = false;
    boolean isNextHop = false;
    boolean isMpReach = false;
    boolean isMpUnReach = false;
    while (cb.readableBytes() > 0) {
        cb.markReaderIndex();
        byte flags = cb.readByte();
        byte typeCode = cb.readByte();
        cb.resetReaderIndex();
        switch (typeCode) {
        case Origin.ORIGIN_TYPE:
            pathAttribute = Origin.read(cb);
            isOrigin = ((Origin) pathAttribute).isOriginSet();
            break;
        case AsPath.ASPATH_TYPE:
            pathAttribute = AsPath.read(cb);
            isAsPath = ((AsPath) pathAttribute).isaspathSet();
            break;
        case As4Path.AS4PATH_TYPE:
            pathAttribute = As4Path.read(cb);
            break;
        case NextHop.NEXTHOP_TYPE:
            pathAttribute = NextHop.read(cb);
            isNextHop = ((NextHop) pathAttribute).isNextHopSet();
            break;
        case Med.MED_TYPE:
            pathAttribute = Med.read(cb);
            break;
        case LocalPref.LOCAL_PREF_TYPE:
            pathAttribute = LocalPref.read(cb);
            break;
        case MpReachNlri.MPREACHNLRI_TYPE:
            pathAttribute = MpReachNlri.read(cb);
            isMpReach = ((MpReachNlri) pathAttribute).isMpReachNlriSet();
            break;
        case MpUnReachNlri.MPUNREACHNLRI_TYPE:
            pathAttribute = MpUnReachNlri.read(cb);
            isMpUnReach = ((MpUnReachNlri) pathAttribute)
                    .isMpUnReachNlriSet();
            break;
        case LINK_STATE_ATTRIBUTE_TYPE:
            pathAttribute = LinkStateAttributes.read(cb);
            break;
        case EXTENDED_COMMUNITY_TYPE:
            pathAttribute = BgpExtendedCommunity.read(cb);
            break;
        case WideCommunity.TYPE:
            pathAttribute = WideCommunity.read(cb);
            break;
        default:
            //skip bytes for unsupported attribute types
            UnSupportedAttribute.read(cb);
        }
        pathAttributeList.add(pathAttribute);
    }

    checkMandatoryAttr(isOrigin, isAsPath, isNextHop, isMpReach, isMpUnReach);
    //TODO:if mp_reach or mp_unreach not present ignore the packet
    return new BgpPathAttributes(pathAttributeList);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:74,代码来源:BgpPathAttributes.java

示例4: write

import org.onosproject.bgpio.types.MpReachNlri; //导入依赖的package包/类
/**
 * Write path attributes to channelBuffer.
 *
 * @param cb channelBuffer
 * @return object of BgpPathAttributes
 * @throws BgpParseException while parsing BGP path attributes
 */
public int write(ChannelBuffer cb)
        throws BgpParseException {

    if (pathAttribute == null) {
        return 0;
    }
    int iLenStartIndex = cb.writerIndex();

    ListIterator<BgpValueType> iterator = pathAttribute.listIterator();

    int pathAttributeIndx = cb.writerIndex();
    cb.writeShort(0);

    while (iterator.hasNext()) {

        BgpValueType attr = iterator.next();

        switch (attr.getType()) {
        case Origin.ORIGIN_TYPE:
            Origin origin = (Origin) attr;
            origin.write(cb);
            break;
        case AsPath.ASPATH_TYPE:
            AsPath asPath = (AsPath) attr;
            asPath.write(cb);
            break;
        case As4Path.AS4PATH_TYPE:
            As4Path as4Path = (As4Path) attr;
            as4Path.write(cb);
            break;
        case NextHop.NEXTHOP_TYPE:
            NextHop nextHop = (NextHop) attr;
            nextHop.write(cb);
            break;
        case Med.MED_TYPE:
            Med med = (Med) attr;
            med.write(cb);
            break;
        case LocalPref.LOCAL_PREF_TYPE:
            LocalPref localPref = (LocalPref) attr;
            localPref.write(cb);
            break;
        case Constants.BGP_EXTENDED_COMMUNITY:
            BgpExtendedCommunity extendedCommunity = (BgpExtendedCommunity) attr;
            extendedCommunity.write(cb);
            break;
        case WideCommunity.TYPE:
            WideCommunity wideCommunity = (WideCommunity) attr;
            wideCommunity.write(cb);
            break;
        case MpReachNlri.MPREACHNLRI_TYPE:
            MpReachNlri mpReach = (MpReachNlri) attr;
            mpReach.write(cb);
            break;
        case MpUnReachNlri.MPUNREACHNLRI_TYPE:
            MpUnReachNlri mpUnReach = (MpUnReachNlri) attr;
            mpUnReach.write(cb);
            break;
        case LINK_STATE_ATTRIBUTE_TYPE:
            LinkStateAttributes linkState = (LinkStateAttributes) attr;
            linkState.write(cb);
            break;
        default:
            return cb.writerIndex() - iLenStartIndex;
        }
    }

    int pathAttrLen = cb.writerIndex() - pathAttributeIndx;
    cb.setShort(pathAttributeIndx, (short) (pathAttrLen - 2));
    return cb.writerIndex() - iLenStartIndex;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:79,代码来源:BgpPathAttributes.java

示例5: processBgpPacket

import org.onosproject.bgpio.types.MpReachNlri; //导入依赖的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: write

import org.onosproject.bgpio.types.MpReachNlri; //导入依赖的package包/类
@Override
public void write(ChannelBuffer cb, BgpUpdateMsgVer4 message) throws BgpParseException {

    int startIndex = cb.writerIndex();
    short afi = 0;
    byte safi = 0;

    // write common header and get msg length index
    int msgLenIndex = message.bgpHeader.write(cb);

    if (msgLenIndex <= 0) {
        throw new BgpParseException("Unable to write message header.");
    }
    List<BgpValueType> pathAttr = message.bgpPathAttributes.pathAttributes();
    if (pathAttr != null) {
        Iterator<BgpValueType> listIterator = pathAttr.iterator();

        while (listIterator.hasNext()) {
            BgpValueType attr = listIterator.next();
            if (attr instanceof MpReachNlri) {
                MpReachNlri mpReach = (MpReachNlri) attr;
                afi = mpReach.afi();
                safi = mpReach.safi();
            } else if (attr instanceof MpUnReachNlri) {
                MpUnReachNlri mpUnReach = (MpUnReachNlri) attr;
                afi = mpUnReach.afi();
                safi = mpUnReach.safi();
            }
        }

        if ((afi == Constants.AFI_FLOWSPEC_VALUE)
                || (afi == Constants.AFI_VALUE)) {
            //unfeasible route length
            cb.writeShort(0);
        }

        if ((afi == Constants.AFI_EVPN_VALUE)
                && (safi == Constants.SAFI_EVPN_VALUE)) {
            cb.writeShort(0);
        }

    }

    if (message.bgpPathAttributes != null) {
        message.bgpPathAttributes.write(cb);
    }

    // write UPDATE Object Length
    int length = cb.writerIndex() - startIndex;
    cb.setShort(msgLenIndex, (short) length);
    message.bgpHeader.setLength((short) length);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:53,代码来源:BgpUpdateMsgVer4.java

示例7: read

import org.onosproject.bgpio.types.MpReachNlri; //导入依赖的package包/类
/**
 * Reads from channelBuffer and parses BGP path attributes.
 *
 * @param cb channelBuffer
 * @return object of BgpPathAttributes
 * @throws BgpParseException while parsing BGP path attributes
 */
public static BgpPathAttributes read(ChannelBuffer cb)
        throws BgpParseException {

    BgpValueType pathAttribute = null;
    List<BgpValueType> pathAttributeList = new LinkedList<>();
    boolean isOrigin = false;
    boolean isAsPath = false;
    boolean isNextHop = false;
    boolean isMpReach = false;
    boolean isMpUnReach = false;
    while (cb.readableBytes() > 0) {
        cb.markReaderIndex();
        byte flags = cb.readByte();
        byte typeCode = cb.readByte();
        cb.resetReaderIndex();
        switch (typeCode) {
        case Origin.ORIGIN_TYPE:
            pathAttribute = Origin.read(cb);
            isOrigin = ((Origin) pathAttribute).isOriginSet();
            break;
        case AsPath.ASPATH_TYPE:
            pathAttribute = AsPath.read(cb);
            isAsPath = ((AsPath) pathAttribute).isaspathSet();
            break;
        case As4Path.AS4PATH_TYPE:
            pathAttribute = As4Path.read(cb);
            break;
        case NextHop.NEXTHOP_TYPE:
            pathAttribute = NextHop.read(cb);
            isNextHop = ((NextHop) pathAttribute).isNextHopSet();
            break;
        case Med.MED_TYPE:
            pathAttribute = Med.read(cb);
            break;
        case LocalPref.LOCAL_PREF_TYPE:
            pathAttribute = LocalPref.read(cb);
            break;
        case MpReachNlri.MPREACHNLRI_TYPE:
            pathAttribute = MpReachNlri.read(cb);
            isMpReach = ((MpReachNlri) pathAttribute).isMpReachNlriSet();
            break;
        case MpUnReachNlri.MPUNREACHNLRI_TYPE:
            pathAttribute = MpUnReachNlri.read(cb);
            isMpUnReach = ((MpUnReachNlri) pathAttribute)
                    .isMpUnReachNlriSet();
            break;
        case LINK_STATE_ATTRIBUTE_TYPE:
            pathAttribute = LinkStateAttributes.read(cb);
            break;
        case EXTENDED_COMMUNITY_TYPE:
            pathAttribute = BgpExtendedCommunity.read(cb);
            break;
        case WideCommunity.TYPE:
            pathAttribute = WideCommunity.read(cb);
            break;
        default:
            log.debug("Skip bytes for unsupported attribute types");
            UnSupportedAttribute.read(cb);
        }
        pathAttributeList.add(pathAttribute);
    }

    checkMandatoryAttr(isOrigin, isAsPath, isNextHop, isMpReach, isMpUnReach);
    //TODO:if mp_reach or mp_unreach not present ignore the packet
    return new BgpPathAttributes(pathAttributeList);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:74,代码来源:BgpPathAttributes.java

示例8: displayNode

import org.onosproject.bgpio.types.MpReachNlri; //导入依赖的package包/类
private void displayNode() {


        pathAttrNlriDetails = pathAttrNlriDetailsLocalRib.localRibNlridetails();
        List<BgpValueType> bgpValueTypeList = pathAttrNlriDetails.pathAttributes();
        protocolType = pathAttrNlriDetails.protocolID();
        Iterator<BgpValueType> itrBgpValueType = bgpValueTypeList.iterator();
        while (itrBgpValueType.hasNext()) {
            BgpValueType bgpValueType = itrBgpValueType.next();
            if (bgpValueType instanceof Origin) {
                origin = (Origin) bgpValueType;
            } else if (bgpValueType instanceof LocalPref) {
                localPref = (LocalPref) bgpValueType;
            } else if (bgpValueType instanceof LinkStateAttributes) {
                LinkStateAttributes linkStateAttributes = (LinkStateAttributes) bgpValueType;
                List linkStateAttribiuteList = linkStateAttributes.linkStateAttributes();
                Iterator<BgpValueType> linkStateAttribiteIterator = linkStateAttribiuteList.iterator();
                while (linkStateAttribiteIterator.hasNext()) {
                    BgpValueType bgpValueType1 = linkStateAttribiteIterator.next();
                    if (bgpValueType1 instanceof BgpAttrRouterIdV4) {
                        bgpAttrRouterIdV4 = (BgpAttrRouterIdV4) bgpValueType1;
                    }
                }
            } else if (bgpValueType instanceof MpReachNlri) {
                mpReachNlri = (MpReachNlri) bgpValueType;
                List<BgpLSNlri> bgpLSNlris = mpReachNlri.mpReachNlri();
                Iterator<BgpLSNlri> bgpLsnlrisIterator = bgpLSNlris.iterator();
                while (bgpLsnlrisIterator.hasNext()) {
                    BgpLSNlri bgpLSNlri = bgpLsnlrisIterator.next();
                    if (bgpLSNlri instanceof BgpNodeLSNlriVer4) {
                        BgpNodeLSNlriVer4 bgpNodeLSNlriVer4 = (BgpNodeLSNlriVer4) bgpLSNlri;
                        BgpNodeLSIdentifier bgpNodeLSIdentifier = bgpNodeLSNlriVer4.getLocalNodeDescriptors();
                        NodeDescriptors nodeDescriptors = bgpNodeLSIdentifier.getNodedescriptors();
                        List<BgpValueType> bgpvalueTypesList = nodeDescriptors.getSubTlvs();
                        Iterator<BgpValueType> bgpValueTypeIterator = bgpvalueTypesList.iterator();
                        while (bgpValueTypeIterator.hasNext()) {
                            BgpValueType valueType = bgpValueTypeIterator.next();
                            if (valueType instanceof IsIsNonPseudonode) {
                                isIsNonPseudonode = (IsIsNonPseudonode) valueType;

                            }
                        }
                    }
                }
            }
        }
        print("RibAsNumber = %s,PeerIdentifier = %s,RibIpAddress = %s,ProtocolType = %s,Origin = %s,LocalPref = %s," +
                        "RouterID = %s,IsoNodeID = %s,NextHop = %s", pathAttrNlriDetailsLocalRib.localRibAsNum(),
                pathAttrNlriDetailsLocalRib.localRibIdentifier(), pathAttrNlriDetailsLocalRib.localRibIpAddress(),
                protocolType.toString(), origin.origin(), localPref.localPref(), bgpAttrRouterIdV4.attrRouterId(),
                Arrays.toString(isIsNonPseudonode.getIsoNodeId()), mpReachNlri.nexthop4());
    }
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:53,代码来源:BgpLocalRibDisplay.java


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