Skip to content

Commit

Permalink
internal/socket: make ipv4, ipv6 and icmp work again on android
Browse files Browse the repository at this point in the history
On android, runtime.GOOS returns "android" instead of "linux".

Fixes golang/go#22115.

Change-Id: Idd24d5602f8fa9be1fca0b64bd8966849ea2b5e7
Reviewed-on: https://go-review.googlesource.com/67770
Reviewed-by: Ian Lance Taylor <iant@golang.org>
  • Loading branch information
cixtor committed Oct 4, 2017
1 parent 4f8c76a commit a04bdac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions internal/socket/socket_go1_9_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestUDP(t *testing.T) {
}
})
switch runtime.GOOS {
case "linux":
case "android", "linux":
t.Run("Messages", func(t *testing.T) {
data := []byte("HELLO-R-U-THERE")
wmbs := bytes.SplitAfter(data, []byte("-"))
Expand Down Expand Up @@ -233,7 +233,7 @@ func BenchmarkUDP(b *testing.B) {
}
})
switch runtime.GOOS {
case "linux":
case "android", "linux":
wms := make([]socket.Message, M)
for i := range wms {
wms[i].Buffers = [][]byte{data}
Expand Down
6 changes: 3 additions & 3 deletions internal/socket/sys_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func marshalSockaddr(ip net.IP, port int, zone string) []byte {
if ip4 := ip.To4(); ip4 != nil {
b := make([]byte, sizeofSockaddrInet)
switch runtime.GOOS {
case "linux", "solaris", "windows":
case "android", "linux", "solaris", "windows":
NativeEndian.PutUint16(b[:2], uint16(sysAF_INET))
default:
b[0] = sizeofSockaddrInet
Expand All @@ -47,7 +47,7 @@ func marshalSockaddr(ip net.IP, port int, zone string) []byte {
if ip6 := ip.To16(); ip6 != nil && ip.To4() == nil {
b := make([]byte, sizeofSockaddrInet6)
switch runtime.GOOS {
case "linux", "solaris", "windows":
case "android", "linux", "solaris", "windows":
NativeEndian.PutUint16(b[:2], uint16(sysAF_INET6))
default:
b[0] = sizeofSockaddrInet6
Expand All @@ -69,7 +69,7 @@ func parseInetAddr(b []byte, network string) (net.Addr, error) {
}
var af int
switch runtime.GOOS {
case "linux", "solaris", "windows":
case "android", "linux", "solaris", "windows":
af = int(NativeEndian.Uint16(b[:2]))
default:
af = int(b[1])
Expand Down

0 comments on commit a04bdac

Please sign in to comment.