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


Java Validation.toInetAddress方法代码示例

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


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

示例1: read

import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
 * Reads from ChannelBuffer and parses NextHop.
 *
 * @param cb ChannelBuffer
 * @return object of NextHop
 * @throws BgpParseException while parsing nexthop attribute
 */
public static NextHop read(ChannelBuffer cb) throws BgpParseException {
    Ip4Address nextHop;
    ChannelBuffer tempCb = cb.copy();
    Validation parseFlags = Validation.parseAttributeHeader(cb);

    if (cb.readableBytes() < parseFlags.getLength()) {
        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
                parseFlags.getLength());
    }
    int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : parseFlags
            .getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
    ChannelBuffer data = tempCb.readBytes(len);
    if (parseFlags.getFirstBit() && !parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
    }

     InetAddress ipAddress = Validation.toInetAddress(parseFlags.getLength(), cb);
    if (ipAddress.isMulticastAddress()) {
        throw new BgpParseException("Multicast address is not supported");
    }

    nextHop = Ip4Address.valueOf(ipAddress);
    return new NextHop(nextHop);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:32,代码来源:NextHop.java

示例2: read

import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
 * Reads the Evpn type 2 attributes.
 *
 * @param cb channel buffer
 * @return type2 route
 * @throws BgpParseException parse exception
 */
public static BgpEvpnRouteType2Nlri read(ChannelBuffer cb) throws BgpParseException {
    if (cb.readableBytes() == 0) {
        return null;
    }
    RouteDistinguisher rd = RouteDistinguisher.read(cb);
    BgpEvpnEsi esi = BgpEvpnEsi.read(cb);
    int ethernetTagID = cb.readInt();
    byte macAddressLength = cb.readByte();
    MacAddress macAddress = Validation.toMacAddress(macAddressLength / 8, cb);
    byte ipAddressLength = cb.readByte();
    InetAddress ipAddress = null;
    if (ipAddressLength > 0) {
        ipAddress = Validation.toInetAddress(ipAddressLength / 8, cb);
    }
    BgpEvpnLabel mplsLabel1 = BgpEvpnLabel.read(cb);
    BgpEvpnLabel mplsLabel2 = null;
    if (cb.readableBytes() > 0) {
        mplsLabel2 = BgpEvpnLabel.read(cb);
    }

    return new BgpEvpnRouteType2Nlri(rd, esi, ethernetTagID, macAddress,
                                     ipAddress, mplsLabel1,
                                     mplsLabel2);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:32,代码来源:BgpEvpnRouteType2Nlri.java

示例3: read

import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
 * Reads the channel buffer and returns object of IPv6AddressTlv.
 *
 * @param cb channelBuffer
 * @param type address type
 * @return object of IPv6AddressTlv
 * @throws BgpParseException while parsing IPv6AddressTlv
 */
public static IPv6AddressTlv read(ChannelBuffer cb, short type) throws BgpParseException {
    InetAddress ipAddress = Validation.toInetAddress(LENGTH, cb);
    if (ipAddress.isMulticastAddress()) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
    }
    Ip6Address address = Ip6Address.valueOf(ipAddress);
    return IPv6AddressTlv.of(address, type);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:IPv6AddressTlv.java

示例4: read

import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
 * Reads the channel buffer and returns object of IPv4AddressTlv.
 *
 * @param cb channelBuffer
 * @param type address type
 * @return object of IPv4AddressTlv
 * @throws BgpParseException while parsing IPv4AddressTlv
 */
public static IPv4AddressTlv read(ChannelBuffer cb, short type) throws BgpParseException {
    InetAddress ipAddress = Validation.toInetAddress(LENGTH, cb);
    if (ipAddress.isMulticastAddress()) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
    }
    Ip4Address address = Ip4Address.valueOf(ipAddress);
    return IPv4AddressTlv.of(address, type);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:IPv4AddressTlv.java


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