Package org.opendaylight.protocol.util
Class Ipv4Util
java.lang.Object
org.opendaylight.protocol.util.Ipv4Util
Util class for creating generated Ipv4Address.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone
addressForByteBuf
(io.netty.buffer.ByteBuf buffer) Reads from ByteBuf buffer and converts bytes to Ipv4Address.static io.netty.buffer.ByteBuf
byteBufForAddress
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone ipAddress) From string ipAddress creates an InetAddress and puts it into ByteBuf.static byte[]
bytesForAddress
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone address) Converts Ipv4Address to byte array.static byte[]
bytesForPrefix
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix prefix) Converts Ipv4Prefix to byte array.static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone
getIpAddress
(InetAddress inetAddress) Converts InetAddress to IpAddress.protected static int
getPrefixLength
(String prefixValue) Obtains prefix length from given string prefix.static int
getPrefixLengthBytes
(String prefix) Returns number of minimum bytes needed to cover all bits of prefix.static String
incrementIpv4Address
(String ipv4Address) Increment Address.static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone
incrementIpv4Address
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone ipv4Address) Increment Address.static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix
incrementIpv4Prefix
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix ipv4Prefix) static int
prefixBitsToBytes
(int bits) static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix
prefixForByteBuf
(io.netty.buffer.ByteBuf buf) Creates an Ipv4Prefix object from given ByteBuf.static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix
prefixForByteBuf
(io.netty.buffer.ByteBuf buf, int prefixLength) Creates an Ipv4Prefix object from given ByteBuf with specified NLRI length.static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix
prefixForBytes
(byte[] bytes, int length) Creates an Ipv4Prefix object from given byte array.static List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix>
prefixListForBytes
(byte[] bytes) Creates a list of Ipv4 Prefixes from given byte array.static InetSocketAddress
toInetSocketAddress
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone ipAddress, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber port) Converts IpAddress and PortNumber to InetSocketAddress.static String
toStringIP
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone ipAddress) Get string representation of IpAddress.static void
writeIpv4Address
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone ipv4Address, io.netty.buffer.ByteBuf output) Writes IPv4 address if not null, otherwise writes zeros to theoutput
ByteBuf.static void
writeIpv4Prefix
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix ipv4Prefix, io.netty.buffer.ByteBuf output) Writes IPv4 prefix if not null, otherwise writes zeros to theoutput
ByteBuf.static void
writeMinimalPrefix
(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix ipv4Prefix, io.netty.buffer.ByteBuf output)
-
Field Details
-
IP4_LENGTH
public static final int IP4_LENGTH- See Also:
-
IP4_BITS_LENGTH
public static final int IP4_BITS_LENGTH- See Also:
-
-
Method Details
-
addressForByteBuf
public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone addressForByteBuf(io.netty.buffer.ByteBuf buffer) Reads from ByteBuf buffer and converts bytes to Ipv4Address.- Parameters:
buffer
- containing Ipv4 address, starting at reader index- Returns:
- Ipv4AddressNoZone
-
byteBufForAddress
public static io.netty.buffer.ByteBuf byteBufForAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone ipAddress) From string ipAddress creates an InetAddress and puts it into ByteBuf.- Parameters:
ipAddress
- Ipv4 address- Returns:
- ByteBuf with filled in bytes from ipAddress
-
bytesForAddress
public static byte[] bytesForAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone address) Converts Ipv4Address to byte array.- Parameters:
address
- Ipv4Address to be converted- Returns:
- byte array
-
prefixBitsToBytes
public static int prefixBitsToBytes(int bits) -
getPrefixLengthBytes
Returns number of minimum bytes needed to cover all bits of prefix. -
bytesForPrefix
public static byte[] bytesForPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix prefix) Converts Ipv4Prefix to byte array. Prefix length at the end.- Parameters:
prefix
- Ipv4Prefix to be converted- Returns:
- byte array with prefix length at the end
-
prefixForBytes
public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix prefixForBytes(byte[] bytes, int length) Creates an Ipv4Prefix object from given byte array.- Parameters:
bytes
- IPv4 addresslength
- prefix length- Returns:
- Ipv4Prefix object
-
prefixForByteBuf
public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix prefixForByteBuf(io.netty.buffer.ByteBuf buf) Creates an Ipv4Prefix object from given ByteBuf. Prefix length is assumed to be in the left most byte of the buffer.- Parameters:
buf
- Buffer containing serialized prefix- Returns:
- Ipv4Prefix object
-
prefixForByteBuf
public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix prefixForByteBuf(io.netty.buffer.ByteBuf buf, int prefixLength) Creates an Ipv4Prefix object from given ByteBuf with specified NLRI length.- Parameters:
buf
- Buffer containing serialized prefixprefixLength
- Prefix length- Returns:
- Ipv4Prefix object
-
prefixListForBytes
public static List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix> prefixListForBytes(byte[] bytes) Creates a list of Ipv4 Prefixes from given byte array.- Parameters:
bytes
- to be converted to List of Ipv4Prefixes.- Returns:
- A list of Ipv4Prefixes
-
getPrefixLength
Obtains prefix length from given string prefix.- Parameters:
prefixValue
- value of prefix- Returns:
- prefix length
-
getIpAddress
public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone getIpAddress(InetAddress inetAddress) Converts InetAddress to IpAddress.- Parameters:
inetAddress
- address- Returns:
- IpAddressNoZone
-
toInetSocketAddress
public static InetSocketAddress toInetSocketAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone ipAddress, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber port) Converts IpAddress and PortNumber to InetSocketAddress.- Parameters:
ipAddress
- addressport
- number- Returns:
- InetSocketAddress
-
incrementIpv4Address
Increment Address.- Parameters:
ipv4Address
- String containing Ipv4Address- Returns:
- String containing Ipv4Address incremented by 1
-
incrementIpv4Address
public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone incrementIpv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone ipv4Address) Increment Address.- Parameters:
ipv4Address
- ipv4 address to be incremented- Returns:
- new ipv4 address
-
incrementIpv4Prefix
public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix incrementIpv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix ipv4Prefix) -
toStringIP
public static String toStringIP(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone ipAddress) Get string representation of IpAddress.- Parameters:
ipAddress
- address- Returns:
- String value of Ipv4Address or Ipv6Address
-
writeIpv4Address
public static void writeIpv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone ipv4Address, io.netty.buffer.ByteBuf output) Writes IPv4 address if not null, otherwise writes zeros to theoutput
ByteBuf. ByteBuf's writerIndex is increased by 4.- Parameters:
ipv4Address
- IPv4 address to be written to the output.output
- ByteBuf, where ipv4Address or zeros are written.
-
writeIpv4Prefix
public static void writeIpv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix ipv4Prefix, io.netty.buffer.ByteBuf output) Writes IPv4 prefix if not null, otherwise writes zeros to theoutput
ByteBuf. ByteBuf's writerIndex is increased by 5.- Parameters:
ipv4Prefix
- IPv4 prefix value to be written to the output. Prefix is written in the last byte.output
- ByteBuf, where ipv4Prefix or zeros are written.
-
writeMinimalPrefix
public static void writeMinimalPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix ipv4Prefix, io.netty.buffer.ByteBuf output)
-