當前位置: 首頁>>代碼示例>>Java>>正文


Java BgpAttrNodeFlagBitTlv類代碼示例

本文整理匯總了Java中org.onosproject.bgpio.types.attr.BgpAttrNodeFlagBitTlv的典型用法代碼示例。如果您正苦於以下問題:Java BgpAttrNodeFlagBitTlv類的具體用法?Java BgpAttrNodeFlagBitTlv怎麽用?Java BgpAttrNodeFlagBitTlv使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BgpAttrNodeFlagBitTlv類屬於org.onosproject.bgpio.types.attr包,在下文中一共展示了BgpAttrNodeFlagBitTlv類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAnnotations

import org.onosproject.bgpio.types.attr.BgpAttrNodeFlagBitTlv; //導入依賴的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

示例2: bgpTopologyProviderTestAddDevice4

import org.onosproject.bgpio.types.attr.BgpAttrNodeFlagBitTlv; //導入依賴的package包/類
/**
 * Validate node is added to the device with all device annotations.
 */
@Test
public void bgpTopologyProviderTestAddDevice4() {
    LinkedList<BgpValueType> subTlvs = new LinkedList<>();
    BgpValueType tlv = new AutonomousSystemTlv(100);
    short deslength = AutonomousSystemTlv.LENGTH;
    short desType = AutonomousSystemTlv.TYPE;

    subTlvs.add(tlv);
    BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(new NodeDescriptors(subTlvs, deslength,
                                                                                           desType));
    BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
                                                       new RouteDistinguisher());

    PathAttrNlriDetails details = new PathAttrNlriDetails();
    details.setIdentifier(0);
    details.setProtocolID(ProtocolType.DIRECT);
    List<BgpValueType> pathAttributes = new LinkedList<>();
    List<BgpValueType> linkStateAttr = new LinkedList<>();
    tlv = BgpAttrNodeFlagBitTlv.of(true, true, true, false);
    linkStateAttr.add(tlv);
    tlv = BgpAttrNodeIsIsAreaId.of(new byte[] {01, 01, 01, 01});
    linkStateAttr.add(tlv);
    tlv = BgpAttrRouterIdV4.of(Ip4Address.valueOf("1.1.1.1"), LinkStateAttributes.ATTR_NODE_IPV4_LOCAL_ROUTER_ID);
    linkStateAttr.add(tlv);
    pathAttributes.add(new LinkStateAttributes(linkStateAttr));
    details.setPathAttribute(pathAttributes);

    for (BgpNodeListener l : controller.nodeListener) {
        l.addNode(nodeNlri, details);

        assertThat(deviceMap.values().iterator().next().annotations().value(BgpTopologyProvider.ABR_BIT),
                is("false"));
        assertThat(deviceMap.values().iterator().next().annotations().value(BgpTopologyProvider.EXTERNAL_BIT),
                is("true"));
        assertThat(deviceMap.values().iterator().next().annotations().value(BgpTopologyProvider.INTERNAL_BIT),
                is("false"));
        assertThat(deviceMap.values().iterator().next().annotations().value(BgpTopologyProvider.PSEUDO),
                is("false"));
        assertThat(deviceMap.values().iterator().next().annotations().value(BgpTopologyProvider.AREAID).getBytes(),
                is(new byte[] {01, 01, 01, 01}));
        assertThat(deviceMap.values().iterator().next().annotations().value(BgpTopologyProvider.LSRID),
                is("1.1.1.1"));

        assertThat(nodeRegistry.connected.size(), is(1));
        l.deleteNode(nodeNlri);
        assertThat(nodeRegistry.connected.size(), is(0));
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:52,代碼來源:BgpTopologyProviderTest.java

示例3: getAnnotations

import org.onosproject.bgpio.types.attr.BgpAttrNodeFlagBitTlv; //導入依賴的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;
    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;
        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));
        }
    }
    return annotationBuilder;
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:58,代碼來源:BgpTopologyProvider.java


注:本文中的org.onosproject.bgpio.types.attr.BgpAttrNodeFlagBitTlv類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。