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


Java BgpAttrNodeMultiTopologyId类代码示例

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


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

示例1: parseLinkDescriptors

import org.onosproject.bgpio.types.attr.BgpAttrNodeMultiTopologyId; //导入依赖的package包/类
/**
 * Parses link descriptors.
 *
 * @param cb ChannelBuffer
 * @return list of link descriptors
 * @throws BgpParseException while parsing link descriptors
 */
public static LinkedList<BgpValueType> parseLinkDescriptors(ChannelBuffer cb) throws BgpParseException {
    LinkedList<BgpValueType> linkDescriptor = new LinkedList<>();
    BgpValueType tlv = null;
    int count = 0;

    while (cb.readableBytes() > 0) {
        ChannelBuffer tempBuf = cb.copy();
        short type = cb.readShort();
        short length = cb.readShort();
        if (cb.readableBytes() < length) {
            throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
                    tempBuf.readBytes(cb.readableBytes() + Constants.TYPE_AND_LEN_AS_SHORT));
        }
        ChannelBuffer tempCb = cb.readBytes(length);
        switch (type) {
        case LinkLocalRemoteIdentifiersTlv.TYPE:
            tlv = LinkLocalRemoteIdentifiersTlv.read(tempCb);
            break;
        case IPV4_INTERFACE_ADDRESS_TYPE:
            tlv = IPv4AddressTlv.read(tempCb, IPV4_INTERFACE_ADDRESS_TYPE);
            break;
        case IPV4_NEIGHBOR_ADDRESS_TYPE:
            tlv = IPv4AddressTlv.read(tempCb, IPV4_NEIGHBOR_ADDRESS_TYPE);
            break;
        case IPV6_INTERFACE_ADDRESS_TYPE:
            tlv = IPv6AddressTlv.read(tempCb, IPV6_INTERFACE_ADDRESS_TYPE);
            break;
        case IPV6_NEIGHBOR_ADDRESS_TYPE:
            tlv = IPv6AddressTlv.read(tempCb, IPV6_NEIGHBOR_ADDRESS_TYPE);
            break;
        case BgpAttrNodeMultiTopologyId.ATTRNODE_MULTITOPOLOGY:
            tlv = BgpAttrNodeMultiTopologyId.read(tempCb);
            count = count++;
            //MultiTopologyId TLV cannot repeat more than once
            if (count > 1) {
                //length + 4 implies data contains type, length and value
                throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
                        BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length
                                + Constants.TYPE_AND_LEN_AS_SHORT));
            }
            break;
        default:
            UnSupportedAttribute.skipBytes(tempCb, length);
        }
        linkDescriptor.add(tlv);
    }
    return linkDescriptor;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:56,代码来源:BgpLinkLSIdentifier.java

示例2: parsePrefixDescriptors

import org.onosproject.bgpio.types.attr.BgpAttrNodeMultiTopologyId; //导入依赖的package包/类
/**
 * Parse list of prefix descriptors.
 *
 * @param cb ChannelBuffer
 * @return list of prefix descriptors
 * @throws BgpParseException while parsing list of prefix descriptors
 */
public static List<BgpValueType> parsePrefixDescriptors(ChannelBuffer cb) throws BgpParseException {
    LinkedList<BgpValueType> prefixDescriptor = new LinkedList<>();
    BgpValueType tlv = null;
    boolean isIpReachInfo = false;
    ChannelBuffer tempCb;
    int count = 0;

    while (cb.readableBytes() > 0) {
        ChannelBuffer tempBuf = cb.copy();
        short type = cb.readShort();
        short length = cb.readShort();
        if (cb.readableBytes() < length) {
            //length + 4 implies data contains type, length and value
            throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
                    tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN));
        }
        tempCb = cb.readBytes(length);
        switch (type) {
        case OspfRouteTypeTlv.TYPE:
            tlv = OspfRouteTypeTlv.read(tempCb);
            break;
        case IPReachabilityInformationTlv.TYPE:
            tlv = IPReachabilityInformationTlv.read(tempCb, length);
            isIpReachInfo = true;
            break;
        case BgpAttrNodeMultiTopologyId.ATTRNODE_MULTITOPOLOGY:
            tlv = BgpAttrNodeMultiTopologyId.read(tempCb);
            count = count + 1;
            if (count > 1) {
                //length + 4 implies data contains type, length and value
                throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
                       BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length + TYPE_AND_LEN));
            }
            break;
        default:
            UnSupportedAttribute.skipBytes(tempCb, length);
        }
        prefixDescriptor.add(tlv);
    }

    if (!isIpReachInfo) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
                null);
    }
    return prefixDescriptor;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:54,代码来源:BgpPrefixLSIdentifier.java

示例3: parseLinkDescriptors

import org.onosproject.bgpio.types.attr.BgpAttrNodeMultiTopologyId; //导入依赖的package包/类
/**
 * Parses link descriptors.
 *
 * @param cb ChannelBuffer
 * @return list of link descriptors
 * @throws BgpParseException while parsing link descriptors
 */
public static LinkedList<BgpValueType> parseLinkDescriptors(ChannelBuffer cb) throws BgpParseException {
    LinkedList<BgpValueType> linkDescriptor = new LinkedList<>();
    BgpValueType tlv = null;
    int count = 0;

    while (cb.readableBytes() > 0) {
        ChannelBuffer tempBuf = cb.copy();
        short type = cb.readShort();
        short length = cb.readShort();
        if (cb.readableBytes() < length) {
            throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
                    tempBuf.readBytes(cb.readableBytes() + Constants.TYPE_AND_LEN_AS_SHORT));
        }
        ChannelBuffer tempCb = cb.readBytes(length);
        switch (type) {
        case LinkLocalRemoteIdentifiersTlv.TYPE:
            tlv = LinkLocalRemoteIdentifiersTlv.read(tempCb);
            break;
        case IPV4_INTERFACE_ADDRESS_TYPE:
            tlv = IPv4AddressTlv.read(tempCb, IPV4_INTERFACE_ADDRESS_TYPE);
            break;
        case IPV4_NEIGHBOR_ADDRESS_TYPE:
            tlv = IPv4AddressTlv.read(tempCb, IPV4_NEIGHBOR_ADDRESS_TYPE);
            break;
        case IPV6_INTERFACE_ADDRESS_TYPE:
            tlv = IPv6AddressTlv.read(tempCb, IPV6_INTERFACE_ADDRESS_TYPE);
            break;
        case IPV6_NEIGHBOR_ADDRESS_TYPE:
            tlv = IPv6AddressTlv.read(tempCb, IPV6_NEIGHBOR_ADDRESS_TYPE);
            break;
        case BgpAttrNodeMultiTopologyId.ATTRNODE_MULTITOPOLOGY:
            tlv = BgpAttrNodeMultiTopologyId.read(tempCb);
            count++;
            log.debug("MultiTopologyId TLV cannot repeat more than once");
            if (count > 1) {
                //length + 4 implies data contains type, length and value
                throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
                        BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length
                                + Constants.TYPE_AND_LEN_AS_SHORT));
            }
            break;
        default:
            UnSupportedAttribute.skipBytes(tempCb, length);
        }
        linkDescriptor.add(tlv);
    }
    return linkDescriptor;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:56,代码来源:BgpLinkLSIdentifier.java


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