-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Ipv6Addr::is_ipv4_mapped
#86490
Add Ipv6Addr::is_ipv4_mapped
#86490
Conversation
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
| multicast_admin_local | ||
| multicast_global | ||
| multicast_link_local | ||
| multicast_realm_local | ||
| multicast_site_local | ||
| multicast_organization_local; | ||
let ipv4_mapped = 1 << 17; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assigned ipv4_mapped
to 1 << 17
, as I already assigned 1 << 16
to benchmarking
in the related PR #86434. (the actual values don't really matter, only that they are distinct)
check!( | ||
"::ffff:127.0.0.1", | ||
&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0x7f, 0, 0, 1], | ||
global | unicast_global | ipv4_mapped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the IANA IPv6 Special Address Registry IPv4-mapped addresses are not globally reachable. However due to the current simplistic implementation of Ipv6Addr::is_global
compared to Ipv4Addr::is_global
, Rust currently considers these addresses global. I plan to address this in a future PR reworking is_global
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rework of Ipv6Addr::is_global
has been submitted (#86634).
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #86335) made this pull request unmergeable. Please resolve the merge conflicts. |
ping from triage: |
This change consists of cherry-picking the content from the original PR[1], which got closed due to inactivity, and applying the following changes: * Resolving merge conflicts (obviously) * Linked to to_ipv4_mapped instead of to_ipv4 in the documentation (seems more appropriate) * Added the must_use and rustc_const_unstable attributes the original didn't have I think it's a reasonably useful method. [1] rust-lang#86490
Add Ipv6Addr::is_ipv4_mapped This change consists of cherry-picking the content from the original PR[1], which got closed due to inactivity, and applying the following changes: * Resolving merge conflicts (obviously) * Linked to to_ipv4_mapped instead of to_ipv4 in the documentation (seems more appropriate) * Added the must_use and rustc_const_unstable attributes the original didn't have I think it's a reasonably useful method to have. [1] rust-lang#86490
Rollup merge of rust-lang#119081 - jstasiak:is-ipv4-mapped, r=dtolnay Add Ipv6Addr::is_ipv4_mapped This change consists of cherry-picking the content from the original PR[1], which got closed due to inactivity, and applying the following changes: * Resolving merge conflicts (obviously) * Linked to to_ipv4_mapped instead of to_ipv4 in the documentation (seems more appropriate) * Added the must_use and rustc_const_unstable attributes the original didn't have I think it's a reasonably useful method to have. [1] rust-lang#86490
Add Ipv6Addr::is_ipv4_mapped This change consists of cherry-picking the content from the original PR[1], which got closed due to inactivity, and applying the following changes: * Resolving merge conflicts (obviously) * Linked to to_ipv4_mapped instead of to_ipv4 in the documentation (seems more appropriate) * Added the must_use and rustc_const_unstable attributes the original didn't have I think it's a reasonably useful method to have. [1] rust-lang/rust#86490
Add Ipv6Addr::is_ipv4_mapped This change consists of cherry-picking the content from the original PR[1], which got closed due to inactivity, and applying the following changes: * Resolving merge conflicts (obviously) * Linked to to_ipv4_mapped instead of to_ipv4 in the documentation (seems more appropriate) * Added the must_use and rustc_const_unstable attributes the original didn't have I think it's a reasonably useful method to have. [1] rust-lang/rust#86490
This PR adds the unstable method
Ipv6Addr::is_ipv4_mapped
, as I proposed a while ago #76098 (comment). It allows for making decisions based on if an address is IPv4-mapped (see also the IPv4-in-IPv6 Address Support issue #85609). I also intend to use this method in a future rework ofIpv6Addr::is_global
(edit: #86634) to more accurately follow the IANA Special Address Registry (like is done inIpv4Addr::is_global
).