本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}