mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-22 21:01:00 +02:00
Added support for IPv6 to IpAddressSerializer and IpPrefixSerializer.
This commit is contained in:
parent
af5ff79583
commit
b139f4d947
@ -46,8 +46,13 @@ public class IpAddressSerializer extends Serializer<IpAddress> {
|
||||
final int octLen = input.readInt();
|
||||
byte[] octs = new byte[octLen];
|
||||
input.readBytes(octs);
|
||||
// TODO: Add support for reading/writing the IP version
|
||||
return IpAddress.valueOf(IpAddress.Version.INET, 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
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,7 +52,13 @@ public final class IpPrefixSerializer extends Serializer<IpPrefix> {
|
||||
byte[] octs = new byte[octLen];
|
||||
input.readBytes(octs);
|
||||
int prefLen = input.readInt();
|
||||
// TODO: Add support for reading/writing the IP version
|
||||
return IpPrefix.valueOf(IpAddress.Version.INET, octs, prefLen);
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user