all: add GOOS=ios

Following CL 254740, this CL does it on x/net.

Updates golang/go#38485.

Change-Id: I80831dd0faa6f216d8d3b8f1af0af811aacce43f
Reviewed-on: https://go-review.googlesource.com/c/net/+/255537
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Cherry Zhang
2020-09-16 18:51:21 -04:00
parent 62affa334b
commit 328152dc79
18 changed files with 24 additions and 24 deletions

View File

@@ -276,7 +276,7 @@ var (
func supportsNonPrivilegedICMP() (string, bool) {
nonPrivOnce.Do(func() {
switch runtime.GOOS {
case "darwin":
case "darwin", "ios":
nonPrivICMP = true
case "linux":
for _, t := range []struct{ network, address string }{

View File

@@ -51,7 +51,7 @@ func (c *PacketConn) ReadFrom(b []byte) (int, net.Addr, error) {
// Please be informed that ipv4.NewPacketConn enables
// IP_STRIPHDR option by default on Darwin.
// See golang.org/issue/9395 for further information.
if runtime.GOOS == "darwin" && c.p4 != nil {
if (runtime.GOOS == "darwin" || runtime.GOOS == "ios") && c.p4 != nil {
n, _, peer, err := c.p4.ReadFrom(b)
return n, peer, err
}

View File

@@ -16,7 +16,7 @@ import (
func ExamplePacketConn_nonPrivilegedPing() {
switch runtime.GOOS {
case "darwin":
case "darwin", "ios":
case "linux":
log.Println("you may need to adjust the net.ipv4.ping_group_range kernel state")
default:

View File

@@ -48,7 +48,7 @@ func ParseIPv4Header(b []byte) (*ipv4.Header, error) {
Dst: net.IPv4(b[16], b[17], b[18], b[19]),
}
switch runtime.GOOS {
case "darwin":
case "darwin", "ios":
h.TotalLen = int(socket.NativeEndian.Uint16(b[2:4]))
case "freebsd":
if freebsdVersion >= 1000000 {

View File

@@ -52,7 +52,7 @@ func TestParseIPv4Header(t *testing.T) {
}
var wh []byte
switch runtime.GOOS {
case "darwin":
case "darwin", "ios":
wh = wireHeaderFromTradBSDKernel[:]
case "freebsd":
if freebsdVersion >= 1000000 {

View File

@@ -68,7 +68,7 @@ func ListenPacket(network, address string) (*PacketConn, error) {
if err != nil {
return nil, os.NewSyscallError("socket", err)
}
if runtime.GOOS == "darwin" && family == syscall.AF_INET {
if (runtime.GOOS == "darwin" || runtime.GOOS == "ios") && family == syscall.AF_INET {
if err := syscall.SetsockoptInt(s, iana.ProtocolIP, sysIP_STRIPHDR, 1); err != nil {
syscall.Close(s)
return nil, os.NewSyscallError("setsockopt", err)

View File

@@ -211,7 +211,7 @@ func ExampleRawConn_advertisingOSPFHello() {
var cm *ipv4.ControlMessage
switch runtime.GOOS {
case "darwin", "linux":
case "darwin", "ios", "linux":
cm = &ipv4.ControlMessage{IfIndex: en0.Index}
default:
if err := r.SetMulticastInterface(en0); err != nil {

View File

@@ -67,7 +67,7 @@ func (h *Header) Marshal() ([]byte, error) {
b[1] = byte(h.TOS)
flagsAndFragOff := (h.FragOff & 0x1fff) | int(h.Flags<<13)
switch runtime.GOOS {
case "darwin", "dragonfly", "netbsd":
case "darwin", "ios", "dragonfly", "netbsd":
socket.NativeEndian.PutUint16(b[2:4], uint16(h.TotalLen))
socket.NativeEndian.PutUint16(b[6:8], uint16(flagsAndFragOff))
case "freebsd":
@@ -126,7 +126,7 @@ func (h *Header) Parse(b []byte) error {
h.Src = net.IPv4(b[12], b[13], b[14], b[15])
h.Dst = net.IPv4(b[16], b[17], b[18], b[19])
switch runtime.GOOS {
case "darwin", "dragonfly", "netbsd":
case "darwin", "ios", "dragonfly", "netbsd":
h.TotalLen = int(socket.NativeEndian.Uint16(b[2:4])) + hdrlen
h.FragOff = int(socket.NativeEndian.Uint16(b[6:8]))
case "freebsd":

View File

@@ -179,7 +179,7 @@ func TestMarshalHeader(t *testing.T) {
}
var wh []byte
switch runtime.GOOS {
case "darwin", "dragonfly", "netbsd":
case "darwin", "ios", "dragonfly", "netbsd":
wh = tt.wireHeaderToTradBSDKernel
case "freebsd":
switch {
@@ -227,7 +227,7 @@ func TestParseHeader(t *testing.T) {
for _, tt := range headerLittleEndianTests {
var wh []byte
switch runtime.GOOS {
case "darwin", "dragonfly", "netbsd":
case "darwin", "ios", "dragonfly", "netbsd":
wh = tt.wireHeaderFromTradBSDKernel
case "freebsd":
switch {

View File

@@ -132,7 +132,7 @@ func TestPacketConnReadWriteUnicastICMP(t *testing.T) {
}
if n, _, _, err := p.ReadFrom(rb); err != nil {
switch runtime.GOOS {
case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket
case "darwin", "ios": // older darwin kernels have some limitation on receiving icmp packet through raw socket
t.Logf("not supported on %s", runtime.GOOS)
continue
}
@@ -222,7 +222,7 @@ func TestRawConnReadWriteUnicastICMP(t *testing.T) {
}
if _, b, _, err := r.ReadFrom(rb); err != nil {
switch runtime.GOOS {
case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket
case "darwin", "ios": // older darwin kernels have some limitation on receiving icmp packet through raw socket
t.Logf("not supported on %s", runtime.GOOS)
continue
}

View File

@@ -247,7 +247,7 @@ func TestPacketConnReadWriteMulticastICMP(t *testing.T) {
rb := make([]byte, 128)
if n, _, _, err := p.ReadFrom(rb); err != nil {
switch runtime.GOOS {
case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket
case "darwin", "ios": // older darwin kernels have some limitation on receiving icmp packet through raw socket
t.Logf("not supported on %s", runtime.GOOS)
continue
}

View File

@@ -214,7 +214,7 @@ func TestIPSinglePacketConnWithSingleGroupListener(t *testing.T) {
func TestIPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) {
switch runtime.GOOS {
case "darwin", "dragonfly", "openbsd": // platforms that return fe80::1%lo0: bind: can't assign requested address
case "darwin", "ios", "dragonfly", "openbsd": // platforms that return fe80::1%lo0: bind: can't assign requested address
t.Skipf("not supported on %s", runtime.GOOS)
case "fuchsia", "hurd", "js", "nacl", "plan9", "windows":
t.Skipf("not supported on %s", runtime.GOOS)

View File

@@ -41,7 +41,7 @@ func TestConnInitiatorPathMTU(t *testing.T) {
if pmtu, err := ipv6.NewConn(c).PathMTU(); err != nil {
switch runtime.GOOS {
case "darwin": // older darwin kernels don't support IPV6_PATHMTU option
case "darwin", "ios": // older darwin kernels don't support IPV6_PATHMTU option
t.Logf("not supported on %s", runtime.GOOS)
default:
t.Fatal(err)
@@ -79,7 +79,7 @@ func TestConnResponderPathMTU(t *testing.T) {
if pmtu, err := ipv6.NewConn(c).PathMTU(); err != nil {
switch runtime.GOOS {
case "darwin": // older darwin kernels don't support IPV6_PATHMTU option
case "darwin", "ios": // older darwin kernels don't support IPV6_PATHMTU option
t.Logf("not supported on %s", runtime.GOOS)
default:
t.Fatal(err)

View File

@@ -170,7 +170,7 @@ func TestPacketConnReadWriteUnicastICMP(t *testing.T) {
}
if n, _, _, err := p.ReadFrom(rb); err != nil {
switch runtime.GOOS {
case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket
case "darwin", "ios": // older darwin kernels have some limitation on receiving icmp packet through raw socket
t.Logf("not supported on %s", runtime.GOOS)
continue
}

View File

@@ -97,7 +97,7 @@ func testUnicastSocketOptions(t *testing.T, c testIPv6UnicastConn) {
tclass := iana.DiffServCS0 | iana.NotECNTransport
if err := c.SetTrafficClass(tclass); err != nil {
switch runtime.GOOS {
case "darwin": // older darwin kernels don't support IPV6_TCLASS option
case "darwin", "ios": // older darwin kernels don't support IPV6_TCLASS option
t.Logf("not supported on %s", runtime.GOOS)
goto next
}

View File

@@ -97,7 +97,7 @@ func TestableNetwork(network string) bool {
switch runtime.GOOS {
case "android", "fuchsia", "hurd", "js", "nacl", "plan9", "windows":
return false
case "darwin":
case "darwin", "ios":
// iOS doesn't support it.
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
return false
@@ -118,7 +118,7 @@ func TestableNetwork(network string) bool {
return false
case "aix":
return unixStrmDgramEnabled()
case "darwin":
case "darwin", "ios":
// iOS does not support unix, unixgram.
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
return false
@@ -126,7 +126,7 @@ func TestableNetwork(network string) bool {
}
case "unixpacket":
switch runtime.GOOS {
case "aix", "android", "fuchsia", "hurd", "darwin", "js", "nacl", "plan9", "windows":
case "aix", "android", "fuchsia", "hurd", "darwin", "ios", "js", "nacl", "plan9", "windows":
return false
case "netbsd":
// It passes on amd64 at least. 386 fails

View File

@@ -221,7 +221,7 @@ func parseKernelInetAddr(af int, b []byte) (int, Addr, error) {
// to make the <length, prefix> tuple to be conformed with
// the routing message boundary
l := int(b[0])
if runtime.GOOS == "darwin" {
if runtime.GOOS == "darwin" || runtime.GOOS == "ios" {
// On Darwin, an address in the kernel form is also
// used as a message filler.
if l == 0 || len(b) > roundup(l) {

View File

@@ -17,7 +17,7 @@ func (m *RouteMessage) marshal() ([]byte, error) {
return nil, errUnsupportedMessage
}
l := w.bodyOff + addrsSpace(m.Addrs)
if runtime.GOOS == "darwin" {
if runtime.GOOS == "darwin" || runtime.GOOS == "ios" {
// Fix stray pointer writes on macOS.
// See golang.org/issue/22456.
l += 1024