net/netip: fix uses of "IPv4-mapped IPv6" in doc comments

The correct (or at least mostly commonly used) name for addresses of the
form ::ffff:192.0.2.128 is "IPv4-mapped IPv6". Some of the comments in
the netip package used that name, but others used "IPv6-mapped IPv4" or
"v6-mapped". This change makes the usage of the term consistent.

Change-Id: Ic01309ddf9252705a2387322d940b777e88800a5
GitHub-Last-Rev: 56044dcb97
GitHub-Pull-Request: golang/go#51950
Reviewed-on: https://go-review.googlesource.com/c/go/+/395914
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Adam Pritchard 2022-03-25 19:08:19 +00:00 committed by Ian Lance Taylor
parent 2bbf383774
commit 3dac914b77
2 changed files with 6 additions and 6 deletions

View file

@ -90,7 +90,7 @@ func AddrFrom4(addr [4]byte) Addr {
} }
// AddrFrom16 returns the IPv6 address given by the bytes in addr. // AddrFrom16 returns the IPv6 address given by the bytes in addr.
// An IPv6-mapped IPv4 address is left as an IPv6 address. // An IPv4-mapped IPv6 address is left as an IPv6 address.
// (Use Unmap to convert them if needed.) // (Use Unmap to convert them if needed.)
func AddrFrom16(addr [16]byte) Addr { func AddrFrom16(addr [16]byte) Addr {
return Addr{ return Addr{
@ -675,7 +675,7 @@ const (
) )
// As16 returns the IP address in its 16-byte representation. // As16 returns the IP address in its 16-byte representation.
// IPv4 addresses are returned in their v6-mapped form. // IPv4 addresses are returned in their IPv4-mapped IPv6 form.
// IPv6 addresses with zones are returned without their zone (use the // IPv6 addresses with zones are returned without their zone (use the
// Zone method to get it). // Zone method to get it).
// The ip zero value returns all zeroes. // The ip zero value returns all zeroes.
@ -1340,7 +1340,7 @@ func (p Prefix) Masked() Prefix {
// Contains reports whether the network p includes ip. // Contains reports whether the network p includes ip.
// //
// An IPv4 address will not match an IPv6 prefix. // An IPv4 address will not match an IPv6 prefix.
// A v6-mapped IPv6 address will not match an IPv4 prefix. // An IPv4-mapped IPv6 address will not match an IPv4 prefix.
// A zero-value IP will not match any prefix. // A zero-value IP will not match any prefix.
// If ip has an IPv6 zone, Contains returns false, // If ip has an IPv6 zone, Contains returns false,
// because Prefixes strip zones. // because Prefixes strip zones.
@ -1372,8 +1372,8 @@ func (p Prefix) Contains(ip Addr) bool {
// Overlaps reports whether p and o contain any IP addresses in common. // Overlaps reports whether p and o contain any IP addresses in common.
// //
// If p and o are of different address families or either have a zero // If p and o are of different address families or either have a zero
// IP, it reports false. Like the Contains method, a prefix with a // IP, it reports false. Like the Contains method, a prefix with an
// v6-mapped IPv4 IP is still treated as an IPv6 mask. // IPv4-mapped IPv6 IP is still treated as an IPv6 mask.
func (p Prefix) Overlaps(o Prefix) bool { func (p Prefix) Overlaps(o Prefix) bool {
if !p.IsValid() || !o.IsValid() { if !p.IsValid() || !o.IsValid() {
return false return false

View file

@ -1776,7 +1776,7 @@ func TestPrefixOverlaps(t *testing.T) {
{pfx("1::1/128"), pfx("2::2/128"), false}, {pfx("1::1/128"), pfx("2::2/128"), false},
{pfx("0100::0/8"), pfx("::1/128"), false}, {pfx("0100::0/8"), pfx("::1/128"), false},
// v6-mapped v4 should not overlap with IPv4. // IPv4-mapped IPv6 should not overlap with IPv4.
{PrefixFrom(AddrFrom16(mustIP("1.2.0.0").As16()), 16), pfx("1.2.3.0/24"), false}, {PrefixFrom(AddrFrom16(mustIP("1.2.0.0").As16()), 16), pfx("1.2.3.0/24"), false},
// Invalid prefixes // Invalid prefixes