Package org.onlab.packet
Class Ip4Prefix
- java.lang.Object
-
- org.onlab.packet.IpPrefix
-
- org.onlab.packet.Ip4Prefix
-
public final class Ip4Prefix extends IpPrefix
The class representing an IPv4 network address. This class is immutable.
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_MASK_LENGTH
static IpAddress.Version
VERSION
-
Fields inherited from class org.onlab.packet.IpPrefix
IPV4_LINK_LOCAL_PREFIX, IPV4_MULTICAST_PREFIX, IPV6_LINK_LOCAL_PREFIX, IPV6_MULTICAST_PREFIX, MAX_INET_MASK_LENGTH, MAX_INET6_MASK_LENGTH
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Ip4Address
address()
Returns the IPv4 address value of the prefix.static Ip4Prefix
valueOf(byte[] address, int prefixLength)
Converts a byte array and a prefix length into an IPv4 prefix.static Ip4Prefix
valueOf(int address, int prefixLength)
Converts an integer and a prefix length into an IPv4 prefix.static Ip4Prefix
valueOf(java.lang.String address)
Converts a CIDR (slash) notation string (e.g., "10.1.0.0/16") into an IPv4 prefix.static Ip4Prefix
valueOf(Ip4Address address, int prefixLength)
Converts an IPv4 address and a prefix length into an IPv4 prefix.-
Methods inherited from class org.onlab.packet.IpPrefix
contains, contains, equals, getIp4Prefix, getIp6Prefix, hashCode, isIp4, isIp6, isMulticast, prefixLength, toString, valueOf, valueOf, version
-
-
-
-
Field Detail
-
VERSION
public static final IpAddress.Version VERSION
-
MAX_MASK_LENGTH
public static final int MAX_MASK_LENGTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
address
public Ip4Address address()
Returns the IPv4 address value of the prefix.
-
valueOf
public static Ip4Prefix valueOf(int address, int prefixLength)
Converts an integer and a prefix length into an IPv4 prefix.- Parameters:
address
- an integer representing the IPv4 addressprefixLength
- the prefix length- Returns:
- an IPv4 prefix
- Throws:
java.lang.IllegalArgumentException
- if the prefix length value is invalid
-
valueOf
public static Ip4Prefix valueOf(byte[] address, int prefixLength)
Converts a byte array and a prefix length into an IPv4 prefix.- Parameters:
address
- the IPv4 address value stored in network byte orderprefixLength
- the prefix length- Returns:
- an IPv4 prefix
- Throws:
java.lang.IllegalArgumentException
- if the prefix length value is invalid
-
valueOf
public static Ip4Prefix valueOf(Ip4Address address, int prefixLength)
Converts an IPv4 address and a prefix length into an IPv4 prefix.- Parameters:
address
- the IPv4 addressprefixLength
- the prefix length- Returns:
- an IPv4 prefix
- Throws:
java.lang.IllegalArgumentException
- if the prefix length value is invalid
-
valueOf
public static Ip4Prefix valueOf(java.lang.String address)
Converts a CIDR (slash) notation string (e.g., "10.1.0.0/16") into an IPv4 prefix.- Parameters:
address
- an IP prefix in string form (e.g., "10.1.0.0/16")- Returns:
- an IPv4 prefix
- Throws:
java.lang.IllegalArgumentException
- if the arguments are invalid
-
-