本文整理汇总了Java中org.onlab.packet.IpAddress.INET_BYTE_LENGTH属性的典型用法代码示例。如果您正苦于以下问题:Java IpAddress.INET_BYTE_LENGTH属性的具体用法?Java IpAddress.INET_BYTE_LENGTH怎么用?Java IpAddress.INET_BYTE_LENGTH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.onlab.packet.IpAddress
的用法示例。
在下文中一共展示了IpAddress.INET_BYTE_LENGTH属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
@Override
public IpPrefix read(Kryo kryo, Input input,
Class<IpPrefix> type) {
int octLen = input.readInt();
checkArgument(octLen <= IpAddress.INET6_BYTE_LENGTH);
byte[] octs = new byte[octLen];
input.readBytes(octs);
int prefLen = input.readInt();
// Use the address size to decide whether it is IPv4 or IPv6 address
if (octLen == IpAddress.INET_BYTE_LENGTH) {
return IpPrefix.valueOf(IpAddress.Version.INET, octs, prefLen);
}
if (octLen == IpAddress.INET6_BYTE_LENGTH) {
return IpPrefix.valueOf(IpAddress.Version.INET6, octs, prefLen);
}
return null; // Shouldn't be reached
}
示例2: read
@Override
public IpAddress read(Kryo kryo, Input input, Class<IpAddress> type) {
final int octLen = input.readInt();
checkArgument(octLen <= IpAddress.INET6_BYTE_LENGTH);
byte[] octs = new byte[octLen];
input.readBytes(octs);
// Use the address size to decide whether it is IPv4 or IPv6 address
if (octLen == IpAddress.INET_BYTE_LENGTH) {
return IpAddress.valueOf(IpAddress.Version.INET, octs);
}
if (octLen == IpAddress.INET6_BYTE_LENGTH) {
return IpAddress.valueOf(IpAddress.Version.INET6, octs);
}
return null; // Shouldn't be reached
}