从 MySQL 5.6 开始,它添加了一些与 IPv6 相关的功能。
我想知道为什么新函数IS_IPV4_COMPAT(expr)
使用已弃用的 RFC-4291 来检查给定binary
地址是否是有效的与 IPv4 兼容的 IPv6 地址。
此函数采用以数字形式表示的 IPv6 地址作为二进制字符串,由 INET6_ATON() 返回。如果参数是有效的与 IPv4 兼容的 IPv6 地址,则返回 1,否则返回 0。IPv4 兼容地址的格式为 ::ipv4_address。
mysql> SELECT IS_IPV4_COMPAT(INET6_ATON('::10.0.5.9'));
-> 1
mysql> SELECT IS_IPV4_COMPAT(INET6_ATON('::ffff:10.0.5.9'));
-> 0
But the [RFC-4291](https://www.rfc-editor.org/rfc/rfc4291#section-2.5.5) says:
+--------------------------------------+--------------------------+
| 80 bits | 16 | 32 bits |
+--------------------------------------+--------------------------+
|0000..............................0000|0000| IPv4 address |
+--------------------------------------+----+---------------------+
> The "IPv4-Compatible IPv6 address" is now deprecated because the current IPv6 transition mechanisms no longer use these addresses. New or updated implementations are not required to support this address type.
+--------------------------------------+----+---------------------+
| 80 bits | 16 | 32 bits |
+--------------------------------------+--------------------------+
|0000..............................0000|FFFF| IPv4 address |
+--------------------------------------+----+---------------------+
> See [RFC4038](https://www.rfc-editor.org/rfc/rfc4038) for background on the usage of the "IPv4-mapped IPv6 address".
**Which format should I use to store IPv4 addresses within a IPv6 context?**