Class Ipv4Util


  • public final class Ipv4Util
    extends Object
    Util class for creating generated Ipv4Address.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      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 the output 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 the output 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)  
    • Method Detail

      • 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

        public static int getPrefixLengthBytes​(String prefix)
        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 address
        length - 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 prefix
        prefixLength - 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

        protected static int getPrefixLength​(String prefixValue)
        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 - address
        port - number
        Returns:
        InetSocketAddress
      • incrementIpv4Address

        public static String incrementIpv4Address​(String ipv4Address)
        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 the output 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 the output 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)