IS_IPV4_MAPPED

IS_IPV4_MAPPED

Description

Syntax

VARCHAR IS_IPV4_MAPPED(INET6_ATON(VARCHAR ipv4_addr))

This function takes an IPv6 address represented in numeric form as a binary string, as returned by INET6_ATON(). It returns 1 if the argument is a valid IPv4-mapped IPv6 address, 0 otherwise, unless expr is NULL, in which case the function returns NULL. IPv4-mapped addresses have the form ::ffff:ipv4_address.

Notice

When the source input doesn't have a prefix of '::ffff:', but if it's still a valid ipv4 address, this result will also be 1 for the reason that the INET6_ATON() automatically adds the prefix for it.

Example

  1. mysql> SELECT IS_IPV4_MAPPED(INET6_ATON('::ffff:10.0.5.9')) AS is_result;
  2. +-----------+
  3. | is_result |
  4. +-----------+
  5. | 1 |
  6. +-----------+
  7. 1 row in set (0.02 sec)
  8. mysql> SELECT IS_IPV4_MAPPED(INET6_ATON('::10.0.5.9')) AS is_result;
  9. +-----------+
  10. | is_result |
  11. +-----------+
  12. | 0 |
  13. +-----------+
  14. 1 row in set (0.03 sec)

Keywords

IS_IPV4_MAPPED, IP