请选择 进入手机版 | 继续访问电脑版
  • 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BgpAttrNodeFlagBitTlv类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VcsRevisionDescription类代码示例发布时间:2022-05-16
下一篇:
Java WriteOption类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap