IS_IPV4_MAPPED
SinceVersion dev
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)
9. mysql> SELECT IS_IPV4_MAPPED(INET6_ATON('::10.0.5.9')) AS is_result;
10. +-----------+
11. | is_result |
12. +-----------+
13. | 0 |
14. +-----------+
15. 1 row in set (0.03 sec)
keywords
IS_IPV4_MAPPED, IP
