IS_IPV4_MAPPED
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β
mysql> SELECT IS_IPV4_MAPPED(INET6_ATON('::ffff:10.0.5.9')) AS is_result;
+-----------+
| is_result |
+-----------+
| 1 |
+-----------+
1 row in set (0.02 sec)
mysql> SELECT IS_IPV4_MAPPED(INET6_ATON('::10.0.5.9')) AS is_result;
+-----------+
| is_result |
+-----------+
| 0 |
+-----------+
1 row in set (0.03 sec)
Keywordsβ
IS_IPV4_MAPPED, IP