IPV4_CIDR_TO_RANGE

SinceVersion dev

IPV4_CIDR_TO_RANGE

description

Syntax

STRUCT<IPV4, IPV4> IPV4_CIDR_TO_RANGE(IPV4 ip_v4, INT16 cidr)

Receive an IPv4 and an Int16 value containing CIDR. Returns a struct that contains two IPv4 fields representing the lower range (min) and higher range (max) of the subnet, respectively.

notice

If the input parameter is NULL, return NULL, indicating invalid input

example

  1. mysql> SELECT ipv4_cidr_to_range(ipv4_string_to_num('192.168.5.2'), 16);
  2. +-----------------------------------------------------------+
  3. | ipv4_cidr_to_range(ipv4_string_to_num('192.168.5.2'), 16) |
  4. +-----------------------------------------------------------+
  5. | {"min": "192.168.0.0", "max": "192.168.255.255"} |
  6. +-----------------------------------------------------------+
  7. mysql> SELECT ipv4_cidr_to_range(to_ipv4('192.168.5.2'), 16);
  8. +--------------------------------------------------+
  9. | ipv4_cidr_to_range(to_ipv4('192.168.5.2'), 16) |
  10. +--------------------------------------------------+
  11. | {"min": "192.168.0.0", "max": "192.168.255.255"} |
  12. +--------------------------------------------------+
  13. mysql> SELECT ipv4_cidr_to_range(NULL, NULL);
  14. +--------------------------------+
  15. | ipv4_cidr_to_range(NULL, NULL) |
  16. +--------------------------------+
  17. | NULL |
  18. +--------------------------------+

keywords

IPV4_CIDR_TO_RANGE, IP