Skip to content

Commit d5efd0d

Browse files
mdlayhergopherbot
authored andcommitted
net/netip: add IPv6LinkLocalAllRouters and IPv6Loopback
Fixes #51766 Fixes #51777 Change-Id: I0510175c20c06442d78b2581cfe218e66be1c35b Reviewed-on: https://go-review.googlesource.com/c/go/+/412475 Auto-Submit: Brad Fitzpatrick <[email protected]> Reviewed-by: David Chase <[email protected]> Reviewed-by: Damien Neil <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> Reviewed-by: Tobias Klauser <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Matt Layher <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> Auto-Submit: Damien Neil <[email protected]>
1 parent e43eebd commit d5efd0d

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

api/next/51766.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pkg net/netip, func IPv6LinkLocalAllRouters() Addr #51766

api/next/51777.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pkg net/netip, func IPv6Loopback() Addr #51777

src/net/netip/netip.go

+7
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ var (
7575
// address ff02::1.
7676
func IPv6LinkLocalAllNodes() Addr { return AddrFrom16([16]byte{0: 0xff, 1: 0x02, 15: 0x01}) }
7777

78+
// IPv6LinkLocalAllRouters returns the IPv6 link-local all routers multicast
79+
// address ff02::2.
80+
func IPv6LinkLocalAllRouters() Addr { return AddrFrom16([16]byte{0: 0xff, 1: 0x02, 15: 0x02}) }
81+
82+
// IPv6Loopback returns the IPv6 loopback address ::1.
83+
func IPv6Loopback() Addr { return AddrFrom16([16]byte{15: 0x01}) }
84+
7885
// IPv6Unspecified returns the IPv6 unspecified address "::".
7986
func IPv6Unspecified() Addr { return Addr{z: z6noz} }
8087

src/net/netip/netip_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,16 @@ func TestAddrWellKnown(t *testing.T) {
784784
ip: IPv6LinkLocalAllNodes(),
785785
std: net.IPv6linklocalallnodes,
786786
},
787+
{
788+
name: "IPv6 link-local all routers",
789+
ip: IPv6LinkLocalAllRouters(),
790+
std: net.IPv6linklocalallrouters,
791+
},
792+
{
793+
name: "IPv6 loopback",
794+
ip: IPv6Loopback(),
795+
std: net.IPv6loopback,
796+
},
787797
{
788798
name: "IPv6 unspecified",
789799
ip: IPv6Unspecified(),
@@ -1867,6 +1877,8 @@ func TestNoAllocs(t *testing.T) {
18671877
test("ParseAddr/6", func() { sinkIP = panicIP(ParseAddr("::1")) })
18681878
test("MustParseAddr", func() { sinkIP = MustParseAddr("1.2.3.4") })
18691879
test("IPv6LinkLocalAllNodes", func() { sinkIP = IPv6LinkLocalAllNodes() })
1880+
test("IPv6LinkLocalAllRouters", func() { sinkIP = IPv6LinkLocalAllRouters() })
1881+
test("IPv6Loopback", func() { sinkIP = IPv6Loopback() })
18701882
test("IPv6Unspecified", func() { sinkIP = IPv6Unspecified() })
18711883

18721884
// IP methods

0 commit comments

Comments
 (0)