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


Java BgpValueType.getType方法代码示例

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


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

示例1: add

import org.onosproject.bgpio.types.BgpValueType; //导入方法依赖的package包/类
/**
 * Obtains instance of this class by appending stringBuilder with node descriptor value.
 *
 * @param value node descriptor
 * @return instance of this class
 */
public BgpDpid add(final NodeDescriptors value) {
    log.info("BgpDpid :: add function");
    if (value != null) {
        List<BgpValueType> subTlvs = value.getSubTlvs();
        ListIterator<BgpValueType> listIterator = subTlvs.listIterator();
        while (listIterator.hasNext()) {
            BgpValueType tlv = listIterator.next();
            if (tlv.getType() == AutonomousSystemTlv.TYPE) {
                this.stringBuilder.append(":ASN=").append(((AutonomousSystemTlv) tlv).getAsNum());
            } else if (tlv.getType() == BgpLSIdentifierTlv.TYPE) {
                this.stringBuilder.append(":DOMAINID=").append(((BgpLSIdentifierTlv) tlv).getBgpLsIdentifier());
            } else if (tlv.getType() == NodeDescriptors.IGP_ROUTERID_TYPE) {
                if (tlv instanceof IsIsNonPseudonode) {
                    this.stringBuilder.append(":ISOID=").append(
                            isoNodeIdString(((IsIsNonPseudonode) tlv).getIsoNodeId()));
                } else if (tlv instanceof IsIsPseudonode) {
                    IsIsPseudonode isisPseudonode = ((IsIsPseudonode) tlv);
                    this.stringBuilder.append(":ISOID=").append(
                            isoNodeIdString(((IsIsPseudonode) tlv).getIsoNodeId()));
                    this.stringBuilder.append(":PSN=").append(isisPseudonode.getPsnIdentifier());
                } else if (tlv instanceof OspfNonPseudonode) {
                    this.stringBuilder.append(":RID=").append(((OspfNonPseudonode) tlv).getrouterID());
                } else if (tlv instanceof OspfPseudonode) {
                    this.stringBuilder.append(":RID=").append(((OspfPseudonode) tlv).getrouterID());
                }
            }
        }
    }
    return this;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:37,代码来源:BgpDpid.java

示例2: write

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

    int optParaLen = 0;
    int as4num = 0;

    int startIndex = cb.writerIndex();

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

    if (msgLenIndex <= 0) {
        throw new BgpParseException("Unable to write message header.");
    }

    // write version in 1-octet
    cb.writeByte(message.version);

    // get as4num if LS Capability is set
    if (message.isLargeAsCapabilitySet) {
        LinkedList<BgpValueType> capabilityTlv = message
                .getCapabilityTlv();
        ListIterator<BgpValueType> listIterator = capabilityTlv
                .listIterator();

        while (listIterator.hasNext()) {
            BgpValueType tlv = listIterator.next();
            if (tlv.getType() == FOUR_OCTET_AS_NUM_CAPA_TYPE) {
                as4num = ((FourOctetAsNumCapabilityTlv) tlv).getInt();
                break;
            }
        }
    }

    if ((message.isLargeAsCapabilitySet) && (as4num > 65535)) {
        // write As number as AS_TRANS
        cb.writeShort(AS_TRANS);
    } else {
        // write AS number in next 2-octet
        cb.writeShort((short) message.asNumber);
    }

    // write HoldTime in next 2-octet
    cb.writeShort(message.holdTime);

    // write BGP Identifier in next 4-octet
    cb.writeInt(message.bgpId);

    // store the index of Optional parameter length
    int optParaLenIndex = cb.writerIndex();

    // set optional parameter length as 0
    cb.writeByte(0);

    // Pack capability TLV
    optParaLen = message.packCapabilityTlv(cb, message);

    if (optParaLen != 0) {
        // Update optional parameter length
        cb.setByte(optParaLenIndex, (byte) (optParaLen + 2)); //+2 for optional parameter type.
    }

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

示例3: registerBandwidth

import org.onosproject.bgpio.types.BgpValueType; //导入方法依赖的package包/类
private void registerBandwidth(LinkDescription linkDes, PathAttrNlriDetails details) {
    if (details ==  null) {
        log.error("Couldnot able to register bandwidth ");
        return;
    }

    List<BgpValueType> attribute = details.pathAttributes().stream()
            .filter(attr -> attr instanceof LinkStateAttributes).collect(toList());
    if (attribute.isEmpty()) {
        return;
    }

    List<BgpValueType> tlvs = ((LinkStateAttributes) attribute.iterator().next()).linkStateAttributes();
    float maxReservableBw = 0;

    for (BgpValueType tlv : tlvs) {
        switch (tlv.getType()) {
        case LinkStateAttributes.ATTR_LINK_MAX_RES_BANDWIDTH:
            maxReservableBw = ((BgpLinkAttrMaxLinkBandwidth) tlv).linkAttrMaxLinkBandwidth();
            //will get in bits/second , convert to MBPS to store in network config service
            maxReservableBw = maxReservableBw / 1000000;
            break;
        default: // do nothing
        }
    }

    if (maxReservableBw == 0.0) {
        return;
    }

    //Configure bandwidth for src and dst port
    BandwidthCapacity config = networkConfigService.addConfig(linkDes.src(), BandwidthCapacity.class);
    config.capacity(Bandwidth.bps(maxReservableBw)).apply();

    config = networkConfigService.addConfig(linkDes.dst(), BandwidthCapacity.class);
    config.capacity(Bandwidth.bps(maxReservableBw)).apply();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:38,代码来源:BgpTopologyProvider.java

示例4: add

import org.onosproject.bgpio.types.BgpValueType; //导入方法依赖的package包/类
/**
 * Obtains instance of this class by appending stringBuilder with node descriptor value.
 *
 * @param value node descriptor
 * @return instance of this class
 */
public BgpDpid add(final NodeDescriptors value) {
    log.debug("BgpDpid :: add function");
    if (value != null) {
        List<BgpValueType> subTlvs = value.getSubTlvs();
        ListIterator<BgpValueType> listIterator = subTlvs.listIterator();
        while (listIterator.hasNext()) {
            BgpValueType tlv = listIterator.next();
            if (tlv.getType() == AutonomousSystemTlv.TYPE) {
                this.stringBuilder.append(":ASN=").append(((AutonomousSystemTlv) tlv).getAsNum());
            } else if (tlv.getType() == BgpLSIdentifierTlv.TYPE) {
                this.stringBuilder.append(":DOMAINID=").append(((BgpLSIdentifierTlv) tlv).getBgpLsIdentifier());
            } else if (tlv.getType() == NodeDescriptors.IGP_ROUTERID_TYPE) {
                if (tlv instanceof IsIsNonPseudonode) {
                    this.stringBuilder.append(":ISOID=").append(
                            isoNodeIdString(((IsIsNonPseudonode) tlv).getIsoNodeId()));
                } else if (tlv instanceof IsIsPseudonode) {
                    IsIsPseudonode isisPseudonode = ((IsIsPseudonode) tlv);
                    this.stringBuilder.append(":ISOID=").append(
                            isoNodeIdString(((IsIsPseudonode) tlv).getIsoNodeId()));
                    this.stringBuilder.append(":PSN=").append(isisPseudonode.getPsnIdentifier());
                } else if (tlv instanceof OspfNonPseudonode) {
                    this.stringBuilder.append(":RID=").append(((OspfNonPseudonode) tlv).getrouterID());
                } else if (tlv instanceof OspfPseudonode) {
                    this.stringBuilder.append(":RID=").append(((OspfPseudonode) tlv).getrouterID());
                }
            }
        }
    }
    return this;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:37,代码来源:BgpDpid.java

示例5: storeAttr

import org.onosproject.bgpio.types.BgpValueType; //导入方法依赖的package包/类
/**
 * Stores BGP basic attributes of two objects.
 *
 * @param listIteratorObj1 list iterator of object1
 * @param listIteratorObj2 list iterator of object2
 */
void storeAttr(ListIterator<BgpValueType> listIteratorObj1, ListIterator<BgpValueType> listIteratorObj2) {
     while (listIteratorObj1.hasNext()) {
         BgpValueType pathAttributeObj1 = listIteratorObj1.next();
         switch (pathAttributeObj1.getType()) {
         case LocalPref.LOCAL_PREF_TYPE:
             obj1LocPref = (LocalPref) pathAttributeObj1;
             break;
         case AsPath.ASPATH_TYPE:
             obj1Aspath = (AsPath) pathAttributeObj1;
             break;
         case Origin.ORIGIN_TYPE:
             obj1Origin = (Origin) pathAttributeObj1;
             break;
         case Med.MED_TYPE:
             obj1Med = (Med) pathAttributeObj1;
             break;
         default:
             log.debug("Got other type, Not required: " + pathAttributeObj1.getType());
         }
     }
     while (listIteratorObj2.hasNext()) {
         BgpValueType pathAttributeObj2 = listIteratorObj2.next();
         switch (pathAttributeObj2.getType()) {
         case LocalPref.LOCAL_PREF_TYPE:
             obj2LocPref = (LocalPref) pathAttributeObj2;
             break;
         case AsPath.ASPATH_TYPE:
             obj2Aspath = (AsPath) pathAttributeObj2;
             break;
         case Origin.ORIGIN_TYPE:
             obj2Origin = (Origin) pathAttributeObj2;
             break;
         case Med.MED_TYPE:
             obj2Med = (Med) pathAttributeObj2;
             break;
         default:
             log.debug("Got other type, Not required: " + pathAttributeObj2.getType());
         }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:47,代码来源:BgpSelectionAlgo.java

示例6: asNumberValidation

import org.onosproject.bgpio.types.BgpValueType; //导入方法依赖的package包/类
/**
 * AS Number Validation.
 *
 * @param h channel Handler
 * @param openMsg open message
 * @return true or false
 */
private boolean asNumberValidation(BgpChannelHandler h, BgpOpenMsg openMsg) {
    log.debug("AS Num validation");

    int capAsNum = 0;
    boolean isFourOctetCapabilityExits = false;

    BgpPeerCfg peerCfg = h.bgpconfig.displayPeers(peerAddr);
    List<BgpValueType> capabilityTlv = openMsg.getCapabilityTlv();
    ListIterator<BgpValueType> listIterator = capabilityTlv.listIterator();

    while (listIterator.hasNext()) {
        BgpValueType tlv = listIterator.next();
        if (tlv.getType() == FOUR_OCTET_AS_NUM_CAPA_TYPE) {
            isFourOctetCapabilityExits = true;
            capAsNum = ((FourOctetAsNumCapabilityTlv) tlv).getInt();
        }
    }

    if (peerCfg.getAsNumber() > MAX_AS2_NUM) {
        if (openMsg.getAsNumber() != AS_TRANS) {
            return false;
        }

        if (!isFourOctetCapabilityExits) {
            return false;
        }

        if (peerCfg.getAsNumber() != capAsNum) {
            return false;
        }

        isIbgpSession = peerCfg.getIsIBgp();
        if (isIbgpSession) {
            // IBGP - AS number should be same for Peer and local if it is IBGP
            if (h.bgpconfig.getAsNumber() != capAsNum) {
                return false;
            }
        }
    } else {

        if (openMsg.getAsNumber() != peerCfg.getAsNumber()) {
            return false;
        }

        if (isFourOctetCapabilityExits) {
            if (capAsNum != peerCfg.getAsNumber()) {
                return false;
            }
        }

        isIbgpSession = peerCfg.getIsIBgp();
        if (isIbgpSession) {
            // IBGP - AS number should be same for Peer and local if it is IBGP
            if (openMsg.getAsNumber() != h.bgpconfig.getAsNumber()) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:68,代码来源:BgpChannelHandler.java

示例7: writeFlowType

import org.onosproject.bgpio.types.BgpValueType; //导入方法依赖的package包/类
/**
 * Write flow type to channel buffer.
 *
 * @param tlv flow type
 * @param cb channel buffer
 */
public static void writeFlowType(BgpValueType tlv, ChannelBuffer cb) {

    switch (tlv.getType()) {
        case Constants.BGP_FLOWSPEC_DST_PREFIX:
            BgpFsDestinationPrefix fsDstPrefix = (BgpFsDestinationPrefix) tlv;
            fsDstPrefix.write(cb);
            break;
        case Constants.BGP_FLOWSPEC_SRC_PREFIX:
            BgpFsSourcePrefix fsSrcPrefix = (BgpFsSourcePrefix) tlv;
            fsSrcPrefix.write(cb);
            break;
        case Constants.BGP_FLOWSPEC_IP_PROTO:
            BgpFsIpProtocol fsIpProtocol = (BgpFsIpProtocol) tlv;
            fsIpProtocol.write(cb);
            break;
        case Constants.BGP_FLOWSPEC_PORT:
            BgpFsPortNum fsPortNum = (BgpFsPortNum) tlv;
            fsPortNum.write(cb);
            break;
        case Constants.BGP_FLOWSPEC_DST_PORT:
            BgpFsDestinationPortNum fsDstPortNum = (BgpFsDestinationPortNum) tlv;
            fsDstPortNum.write(cb);
            break;
        case Constants.BGP_FLOWSPEC_SRC_PORT:
            BgpFsSourcePortNum fsSrcPortNum = (BgpFsSourcePortNum) tlv;
            fsSrcPortNum.write(cb);
            break;
        case Constants.BGP_FLOWSPEC_ICMP_TP:
            BgpFsIcmpType fsIcmpType = (BgpFsIcmpType) tlv;
            fsIcmpType.write(cb);
            break;
        case Constants.BGP_FLOWSPEC_ICMP_CD:
            BgpFsIcmpCode fsIcmpCode = (BgpFsIcmpCode) tlv;
            fsIcmpCode.write(cb);
            break;
        case Constants.BGP_FLOWSPEC_TCP_FLAGS:
            BgpFsTcpFlags fsTcpFlags = (BgpFsTcpFlags) tlv;
            fsTcpFlags.write(cb);
            break;
        case Constants.BGP_FLOWSPEC_PCK_LEN:
            BgpFsPacketLength fsPacketLen = (BgpFsPacketLength) tlv;
            fsPacketLen.write(cb);
            break;
        case Constants.BGP_FLOWSPEC_DSCP:
            BgpFsDscpValue fsDscpVal = (BgpFsDscpValue) tlv;
            fsDscpVal.write(cb);
            break;
        case Constants.BGP_FLOWSPEC_FRAGMENT:
            BgpFsFragment fsFragment = (BgpFsFragment) tlv;
            fsFragment.write(cb);
            break;
        default:
            break;
    }
    return;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:63,代码来源:BgpFlowSpecNlri.java

示例8: write

import org.onosproject.bgpio.types.BgpValueType; //导入方法依赖的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

示例9: compareTo

import org.onosproject.bgpio.types.BgpValueType; //导入方法依赖的package包/类
/**
 * Compares this and o object.
 *
 * @param o object to be compared with this object
 * @return which object is greater
 */
public int compareTo(Object o) {
    if (this.equals(o)) {
        return 0;
    }
    ListIterator<BgpValueType> listIterator = subTlvs.listIterator();
    int countOtherSubTlv = ((NodeDescriptors) o).subTlvs.size();
    int countObjSubTlv = subTlvs.size();
    boolean tlvFound = false;
    if (countOtherSubTlv != countObjSubTlv) {
        if (countOtherSubTlv > countObjSubTlv) {
            return 1;
        } else {
            return -1;
        }
    } else {
        while (listIterator.hasNext()) {
            BgpValueType tlv1 = listIterator.next();
            log.debug("NodeDescriptor compare subtlv's");
            for (BgpValueType tlv : ((NodeDescriptors) o).subTlvs) {
                if (tlv.getType() == tlv1.getType()) {
                    if (tlv.getType() == IGP_ROUTERID_TYPE) {
                        if ((tlv1 instanceof IsIsNonPseudonode && tlv instanceof IsIsPseudonode)
                            || (tlv1 instanceof IsIsPseudonode && tlv instanceof IsIsNonPseudonode)
                            || (tlv1 instanceof OspfNonPseudonode && tlv instanceof OspfPseudonode)
                            || (tlv1 instanceof OspfPseudonode && tlv instanceof OspfNonPseudonode)) {
                            continue;
                        }
                    }
                    int result = subTlvs.get(subTlvs.indexOf(tlv1)).compareTo(
                            ((NodeDescriptors) o).subTlvs.get(((NodeDescriptors) o).subTlvs.indexOf(tlv)));
                    if (result != 0) {
                        return result;
                    }
                    tlvFound = true;
                    break;
                }
            }
            if (!tlvFound) {
                return 1;
            }
        }
    }
    return 0;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:51,代码来源:NodeDescriptors.java

示例10: compareTo

import org.onosproject.bgpio.types.BgpValueType; //导入方法依赖的package包/类
@Override
public int compareTo(Object o) {
    if (this.equals(o)) {
        return 0;
    }
    boolean tlvFound = false;
    int result = this.localNodeDescriptors.compareTo(((BgpLinkLSIdentifier) o).localNodeDescriptors);
    if (result != 0) {
        return result;
    } else if (this.remoteNodeDescriptors.compareTo(((BgpLinkLSIdentifier) o).remoteNodeDescriptors) != 0) {
        return this.remoteNodeDescriptors.compareTo(((BgpLinkLSIdentifier) o).remoteNodeDescriptors);
    } else {
        int countOtherSubTlv = ((BgpLinkLSIdentifier) o).linkDescriptor.size();
        int countObjSubTlv = linkDescriptor.size();
        if (countOtherSubTlv != countObjSubTlv) {
            if (countOtherSubTlv > countObjSubTlv) {
                return 1;
            } else {
                return -1;
            }
        }
        ListIterator<BgpValueType> listIterator = linkDescriptor.listIterator();
        while (listIterator.hasNext()) {
            BgpValueType tlv1 = listIterator.next();
            for (BgpValueType tlv : ((BgpLinkLSIdentifier) o).linkDescriptor) {
                if (tlv.getType() == tlv1.getType()) {
                    result = linkDescriptor.get(linkDescriptor.indexOf(tlv1)).compareTo(
                            ((BgpLinkLSIdentifier) o).linkDescriptor.get(((BgpLinkLSIdentifier) o).linkDescriptor
                                    .indexOf(tlv)));
                    if (result != 0) {
                        return result;
                    }
                    tlvFound = true;
                    break;
                }
            }
            if (!tlvFound) {
                return 1;
            }
        }
    }
    return 0;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:44,代码来源:BgpLinkLSIdentifier.java

示例11: compareTo

import org.onosproject.bgpio.types.BgpValueType; //导入方法依赖的package包/类
@Override
public int compareTo(Object o) {
    if (this.equals(o)) {
        return 0;
    }
    int result = this.localNodeDescriptors.compareTo(((BgpPrefixLSIdentifier) o).localNodeDescriptors);
    boolean tlvFound = false;
    if (result != 0) {
        return result;
    } else {
        int countOtherSubTlv = ((BgpPrefixLSIdentifier) o).prefixDescriptor.size();
        int countObjSubTlv = prefixDescriptor.size();
        if (countOtherSubTlv != countObjSubTlv) {
            if (countOtherSubTlv > countObjSubTlv) {
                return 1;
            } else {
                return -1;
            }
        }

        ListIterator<BgpValueType> listIterator = prefixDescriptor.listIterator();
        while (listIterator.hasNext()) {
            BgpValueType tlv1 = listIterator.next();
            for (BgpValueType tlv : ((BgpPrefixLSIdentifier) o).prefixDescriptor) {
                if (tlv.getType() == tlv1.getType()) {
                    result = prefixDescriptor.get(prefixDescriptor.indexOf(tlv1)).compareTo(
                            ((BgpPrefixLSIdentifier) o).prefixDescriptor
                                    .get(((BgpPrefixLSIdentifier) o).prefixDescriptor.indexOf(tlv)));
                    if (result != 0) {
                        return result;
                    }
                    tlvFound = true;
                    break;
                }
            }
            if (!tlvFound) {
                return 1;
            }
        }
    }
    return 0;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:43,代码来源:BgpPrefixLSIdentifier.java

示例12: addNode

import org.onosproject.bgpio.types.BgpValueType; //导入方法依赖的package包/类
@Override
public void addNode(BgpNodeLSNlriVer4 nodeNlri, PathAttrNlriDetails details) {
    log.debug("Add node {}", nodeNlri.toString());

    if (deviceProviderService == null || deviceService == null) {
        return;
    }
    Device.Type deviceType = ROUTER;
    BgpDpid nodeUri = new BgpDpid(nodeNlri);
    DeviceId deviceId = deviceId(uri(nodeUri.toString()));
    ChassisId cId = new ChassisId();

    /*
     * Check if device is already there (available) , if yes not updating to core.
     */
    if (deviceService.isAvailable(deviceId)) {
        return;
    }

    DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();

    newBuilder.set(AnnotationKeys.DRIVER, "l3Device");
    newBuilder.set(AnnotationKeys.TYPE, "L3");
    newBuilder.set(ROUTING_UNIVERSE, Long.toString(nodeNlri.getIdentifier()));

    List<BgpValueType> tlvs = nodeNlri.getLocalNodeDescriptors().getNodedescriptors().getSubTlvs();
    for (BgpValueType tlv : tlvs) {
        if (tlv instanceof AutonomousSystemTlv) {
            newBuilder.set(AS_NUMBER, Integer.toString(((AutonomousSystemTlv) tlv).getAsNum()));
        } else if (tlv instanceof BgpLSIdentifierTlv) {
            newBuilder.set(DOMAIN_IDENTIFIER,
                    Integer.toString(((BgpLSIdentifierTlv) tlv).getBgpLsIdentifier()));
        }
        if (tlv.getType() == NodeDescriptors.IGP_ROUTERID_TYPE) {
            if (tlv instanceof IsIsPseudonode) {
                deviceType = VIRTUAL;
                newBuilder.set(AnnotationKeys.ROUTER_ID, nodeUri.isoNodeIdString(((IsIsPseudonode) tlv)
                        .getIsoNodeId()));
            } else if (tlv instanceof OspfPseudonode) {
                deviceType = VIRTUAL;
                newBuilder
                        .set(AnnotationKeys.ROUTER_ID, Integer.toString(((OspfPseudonode) tlv).getrouterID()));
            } else if (tlv instanceof IsIsNonPseudonode) {
                newBuilder.set(AnnotationKeys.ROUTER_ID, nodeUri.isoNodeIdString(((IsIsNonPseudonode) tlv)
                        .getIsoNodeId()));
            } else if (tlv instanceof OspfNonPseudonode) {
                newBuilder.set(AnnotationKeys.ROUTER_ID,
                        Integer.toString(((OspfNonPseudonode) tlv).getrouterID()));
            }
        }
    }
    DefaultAnnotations.Builder anntotations = DefaultAnnotations.builder();
    anntotations = getAnnotations(newBuilder, true, details);

    DeviceDescription description = new DefaultDeviceDescription(uri(nodeUri.toString()), deviceType, UNKNOWN,
            UNKNOWN, UNKNOWN, UNKNOWN, cId, anntotations.build());

    deviceProviderService.deviceConnected(deviceId, description);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:60,代码来源:BgpTopologyProvider.java

示例13: buildLinkDes

import org.onosproject.bgpio.types.BgpValueType; //导入方法依赖的package包/类
private LinkDescription buildLinkDes(BgpLinkLsNlriVer4 linkNlri, PathAttrNlriDetails details, boolean isAddLink)
        throws BgpParseException {
    long srcAddress = 0;
    long dstAddress = 0;
    boolean localPseduo = false;
    boolean remotePseduo = false;

    List<BgpValueType> localTlvs = linkNlri.getLinkIdentifier().localNodeDescriptors().getSubTlvs();
    for (BgpValueType localTlv : localTlvs) {
        if (localTlv instanceof IsIsPseudonode || localTlv instanceof OspfPseudonode) {
            localPseduo = true;
        }
    }
    List<BgpValueType> remoteTlvs = linkNlri.getLinkIdentifier().remoteNodeDescriptors().getSubTlvs();
    for (BgpValueType remoteTlv : remoteTlvs) {
        if (remoteTlv instanceof IsIsPseudonode || remoteTlv instanceof OspfPseudonode) {
            remotePseduo = true;
        }
    }

    List<BgpValueType> tlvs = linkNlri.getLinkIdentifier().linkDescriptors();
    for (BgpValueType tlv : tlvs) {
        if (tlv instanceof LinkLocalRemoteIdentifiersTlv) {
            srcAddress = ((LinkLocalRemoteIdentifiersTlv) tlv).getLinkLocalIdentifier();
            //Set 32nd bit.
            srcAddress = srcAddress | IDENTIFIER_SET;
            dstAddress = ((LinkLocalRemoteIdentifiersTlv) tlv).getLinkRemoteIdentifier();
            dstAddress = dstAddress | IDENTIFIER_SET;
        } else if (tlv instanceof IPv4AddressTlv) {
            if (tlv.getType() == BgpLinkLSIdentifier.IPV4_INTERFACE_ADDRESS_TYPE) {
                srcAddress = ((IPv4AddressTlv) tlv).address().toInt();
            } else {
                dstAddress = ((IPv4AddressTlv) tlv).address().toInt();
            }
        }
    }

    DeviceId srcId = deviceId(uri(new BgpDpid(linkNlri, BgpDpid.NODE_DESCRIPTOR_LOCAL).toString()));
    DeviceId dstId = deviceId(uri(new BgpDpid(linkNlri, BgpDpid.NODE_DESCRIPTOR_REMOTE).toString()));

    if (localPseduo && srcAddress == 0) {
        srcAddress = PSEUDO_PORT;
    } else if (remotePseduo && dstAddress == 0) {
        dstAddress = PSEUDO_PORT;
    }

    ConnectPoint src = new ConnectPoint(srcId, PortNumber.portNumber(srcAddress));
    ConnectPoint dst = new ConnectPoint(dstId, PortNumber.portNumber(dstAddress));
    BgpNodeLSNlriVer4 srcNodeNlri = new BgpNodeLSNlriVer4(linkNlri.getIdentifier(), linkNlri.getProtocolId()
            .getType(), new BgpNodeLSIdentifier(linkNlri.getLinkIdentifier().localNodeDescriptors()), false,
            linkNlri.getRouteDistinguisher());

    BgpNodeLSNlriVer4 dstNodeNlri = new BgpNodeLSNlriVer4(linkNlri.getIdentifier(), linkNlri.getProtocolId()
            .getType(), new BgpNodeLSIdentifier(linkNlri.getLinkIdentifier().remoteNodeDescriptors()), false,
            linkNlri.getRouteDistinguisher());

    addOrDeletePseudoNode(isAddLink, localPseduo, remotePseduo, srcNodeNlri,
             dstNodeNlri, srcId, dstId, details);
    DefaultAnnotations.Builder annotationBuilder = DefaultAnnotations.builder();
    if (details != null) {
        annotationBuilder = getAnnotations(annotationBuilder, false, details);
    }

    return new DefaultLinkDescription(src, dst, Link.Type.DIRECT, false, annotationBuilder.build());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:66,代码来源:BgpTopologyProvider.java

示例14: getAnnotations

import org.onosproject.bgpio.types.BgpValueType; //导入方法依赖的package包/类
private DefaultAnnotations.Builder getAnnotations(DefaultAnnotations.Builder annotationBuilder, boolean isNode,
        PathAttrNlriDetails details) {

    List<BgpValueType> attribute = details.pathAttributes().stream()
            .filter(attr -> attr instanceof LinkStateAttributes).collect(toList());
    if (attribute.isEmpty()) {
        return annotationBuilder;
    }
    List<BgpValueType> tlvs = ((LinkStateAttributes) attribute.iterator().next()).linkStateAttributes();
    boolean abrBit = false;
    boolean externalBit = false;
    boolean pseudo = false;
    int igpMetric = 0;
    int teMetric = 0;
    byte[] areaId = null;
    Ip4Address routerId = null;
    for (BgpValueType tlv : tlvs) {
        switch (tlv.getType()) {
        case LinkStateAttributes.ATTR_NODE_FLAG_BITS:
            abrBit = ((BgpAttrNodeFlagBitTlv) tlv).abrBit();
            externalBit = ((BgpAttrNodeFlagBitTlv) tlv).externalBit();
            break;
        case NodeDescriptors.IGP_ROUTERID_TYPE:
            if (tlv instanceof IsIsPseudonode || tlv instanceof OspfPseudonode) {
                pseudo = true;
            }
            break;
        case LinkStateAttributes.ATTR_NODE_ISIS_AREA_ID:
            areaId = ((BgpAttrNodeIsIsAreaId) tlv).attrNodeIsIsAreaId();
            break;
        case LinkStateAttributes.ATTR_NODE_IPV4_LOCAL_ROUTER_ID:
            routerId = ((BgpAttrRouterIdV4) tlv).attrRouterId();
            break;
        case LinkStateAttributes.ATTR_LINK_IGP_METRIC:
            igpMetric = ((BgpLinkAttrIgpMetric) tlv).attrLinkIgpMetric();
            break;
        case LinkStateAttributes.ATTR_LINK_TE_DEFAULT_METRIC:
            teMetric = ((BgpLinkAttrTeDefaultMetric) tlv).attrLinkDefTeMetric();
            break;
        default: // do nothing
        }
    }

    // Annotations for device
    if (isNode) {
        boolean internalBit = false;
        if (!abrBit && !externalBit) {
            internalBit = true;
        }

        annotationBuilder.set(EXTERNAL_BIT, String.valueOf(externalBit));
        annotationBuilder.set(ABR_BIT, String.valueOf(abrBit));
        annotationBuilder.set(INTERNAL_BIT, String.valueOf(internalBit));
        annotationBuilder.set(PSEUDO, String.valueOf(pseudo));

        if (areaId != null) {
            annotationBuilder.set(AREAID, new String(areaId));
        }
        if (routerId != null) {
            // LsrID
            annotationBuilder.set(LSRID, String.valueOf(routerId));
        }
    } else {
        // Annotations for link
        if (igpMetric != 0) {
            annotationBuilder.set(COST, String.valueOf(igpMetric));
        }

        if (teMetric != 0) {
            annotationBuilder.set(TE_COST, String.valueOf(teMetric));
        }
    }
    return annotationBuilder;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:75,代码来源:BgpTopologyProvider.java

示例15: storeAttr

import org.onosproject.bgpio.types.BgpValueType; //导入方法依赖的package包/类
/**
 * Stores BGP basic attributes of two objects.
 *
 * @param listIteratorObj1 list iterator of object1
 * @param listIteratorObj2 list iterator of object2
 */
private void storeAttr(ListIterator<BgpValueType> listIteratorObj1, ListIterator<BgpValueType> listIteratorObj2) {
     while (listIteratorObj1.hasNext()) {
         BgpValueType pathAttributeObj1 = listIteratorObj1.next();
         switch (pathAttributeObj1.getType()) {
         case LocalPref.LOCAL_PREF_TYPE:
             obj1LocPref = (LocalPref) pathAttributeObj1;
             break;
         case AsPath.ASPATH_TYPE:
             obj1Aspath = (AsPath) pathAttributeObj1;
             break;
         case Origin.ORIGIN_TYPE:
             obj1Origin = (Origin) pathAttributeObj1;
             break;
         case Med.MED_TYPE:
             obj1Med = (Med) pathAttributeObj1;
             break;
         default:
             log.debug("Got other type, Not required: " + pathAttributeObj1.getType());
         }
     }
     while (listIteratorObj2.hasNext()) {
         BgpValueType pathAttributeObj2 = listIteratorObj2.next();
         switch (pathAttributeObj2.getType()) {
         case LocalPref.LOCAL_PREF_TYPE:
             obj2LocPref = (LocalPref) pathAttributeObj2;
             break;
         case AsPath.ASPATH_TYPE:
             obj2Aspath = (AsPath) pathAttributeObj2;
             break;
         case Origin.ORIGIN_TYPE:
             obj2Origin = (Origin) pathAttributeObj2;
             break;
         case Med.MED_TYPE:
             obj2Med = (Med) pathAttributeObj2;
             break;
         default:
             log.debug("Got other type, Not required: " + pathAttributeObj2.getType());
         }
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:47,代码来源:BgpSelectionAlgo.java


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