aboutsummaryrefslogtreecommitdiff
path: root/src/net/interface_test.go
diff options
context:
space:
mode:
authorMikio Hara <mikioh.mikioh@gmail.com>2015-12-18 12:39:57 +0900
committerMikio Hara <mikioh.mikioh@gmail.com>2015-12-19 10:00:04 +0000
commit97f854cd7bb6c06046d386469a2b56c9b0e16406 (patch)
tree895deb7452790e82913b5cf31eeb289679d78313 /src/net/interface_test.go
parent2cf5f04ffd4b00821fd0aed40ae8836f6ce8f161 (diff)
downloadgo-97f854cd7bb6c06046d386469a2b56c9b0e16406.tar.xz
net: make use of IPv4 for parsing routing information on windows
In general the package net deals IPv4 addresses as IPv6 IPv4-mapped addresses internally for the dual stack era, when we need to support various techniques on IPv4/IPv6 translation. This change makes windows implementation follow the same pattern which BSD variants and Linux do. Updates #13544. Also fixes an unintentionally formatted line by accident by gofmt. Change-Id: I4953796e751fd8050c73094468a0d7b0d33f5516 Reviewed-on: https://go-review.googlesource.com/17992 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Diffstat (limited to 'src/net/interface_test.go')
-rw-r--r--src/net/interface_test.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/net/interface_test.go b/src/net/interface_test.go
index c5e7c432cd..7bdd924150 100644
--- a/src/net/interface_test.go
+++ b/src/net/interface_test.go
@@ -185,6 +185,10 @@ func testAddrs(t *testing.T, ifat []Addr) (naf4, naf6 int) {
t.Errorf("unexpected value: %#v", ifa)
continue
}
+ if len(ifa.IP) != IPv6len {
+ t.Errorf("should be internal representation either IPv6 or IPv6 IPv4-mapped address: %#v", ifa)
+ continue
+ }
prefixLen, maxPrefixLen := ifa.Mask.Size()
if ifa.IP.To4() != nil {
if 0 >= prefixLen || prefixLen > 8*IPv4len || maxPrefixLen != 8*IPv4len {
@@ -211,7 +215,11 @@ func testAddrs(t *testing.T, ifat []Addr) (naf4, naf6 int) {
t.Logf("interface address %q", ifa.String())
case *IPAddr:
if ifa == nil || ifa.IP == nil || ifa.IP.IsUnspecified() || ifa.IP.IsMulticast() {
- t.Errorf("unexpected value: %+v", ifa)
+ t.Errorf("unexpected value: %#v", ifa)
+ continue
+ }
+ if len(ifa.IP) != IPv6len {
+ t.Errorf("should be internal representation either IPv6 or IPv6 IPv4-mapped address: %#v", ifa)
continue
}
if ifa.IP.To4() != nil {
@@ -233,7 +241,11 @@ func testMulticastAddrs(t *testing.T, ifmat []Addr) (nmaf4, nmaf6 int) {
switch ifma := ifma.(type) {
case *IPAddr:
if ifma == nil || ifma.IP == nil || ifma.IP.IsUnspecified() || !ifma.IP.IsMulticast() {
- t.Errorf("unexpected value: %#v", ifma)
+ t.Errorf("unexpected value: %+v", ifma)
+ continue
+ }
+ if len(ifma.IP) != IPv6len {
+ t.Errorf("should be internal representation either IPv6 or IPv6 IPv4-mapped address: %#v", ifma)
continue
}
if ifma.IP.To4() != nil {