当前位置: 首页>>代码示例>>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;未经允许,请勿转载。