Skip to content

Commit 328152d

Browse files
committed
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>
1 parent 62affa3 commit 328152d

18 files changed

+24
-24
lines changed

icmp/diag_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ var (
276276
func supportsNonPrivilegedICMP() (string, bool) {
277277
nonPrivOnce.Do(func() {
278278
switch runtime.GOOS {
279-
case "darwin":
279+
case "darwin", "ios":
280280
nonPrivICMP = true
281281
case "linux":
282282
for _, t := range []struct{ network, address string }{

icmp/endpoint.go

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

icmp/example_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
func ExamplePacketConn_nonPrivilegedPing() {
1818
switch runtime.GOOS {
19-
case "darwin":
19+
case "darwin", "ios":
2020
case "linux":
2121
log.Println("you may need to adjust the net.ipv4.ping_group_range kernel state")
2222
default:

icmp/ipv4.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func ParseIPv4Header(b []byte) (*ipv4.Header, error) {
4848
Dst: net.IPv4(b[16], b[17], b[18], b[19]),
4949
}
5050
switch runtime.GOOS {
51-
case "darwin":
51+
case "darwin", "ios":
5252
h.TotalLen = int(socket.NativeEndian.Uint16(b[2:4]))
5353
case "freebsd":
5454
if freebsdVersion >= 1000000 {

icmp/ipv4_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TestParseIPv4Header(t *testing.T) {
5252
}
5353
var wh []byte
5454
switch runtime.GOOS {
55-
case "darwin":
55+
case "darwin", "ios":
5656
wh = wireHeaderFromTradBSDKernel[:]
5757
case "freebsd":
5858
if freebsdVersion >= 1000000 {

icmp/listen_posix.go

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

ipv4/example_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func ExampleRawConn_advertisingOSPFHello() {
211211

212212
var cm *ipv4.ControlMessage
213213
switch runtime.GOOS {
214-
case "darwin", "linux":
214+
case "darwin", "ios", "linux":
215215
cm = &ipv4.ControlMessage{IfIndex: en0.Index}
216216
default:
217217
if err := r.SetMulticastInterface(en0); err != nil {

ipv4/header.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (h *Header) Marshal() ([]byte, error) {
6767
b[1] = byte(h.TOS)
6868
flagsAndFragOff := (h.FragOff & 0x1fff) | int(h.Flags<<13)
6969
switch runtime.GOOS {
70-
case "darwin", "dragonfly", "netbsd":
70+
case "darwin", "ios", "dragonfly", "netbsd":
7171
socket.NativeEndian.PutUint16(b[2:4], uint16(h.TotalLen))
7272
socket.NativeEndian.PutUint16(b[6:8], uint16(flagsAndFragOff))
7373
case "freebsd":
@@ -126,7 +126,7 @@ func (h *Header) Parse(b []byte) error {
126126
h.Src = net.IPv4(b[12], b[13], b[14], b[15])
127127
h.Dst = net.IPv4(b[16], b[17], b[18], b[19])
128128
switch runtime.GOOS {
129-
case "darwin", "dragonfly", "netbsd":
129+
case "darwin", "ios", "dragonfly", "netbsd":
130130
h.TotalLen = int(socket.NativeEndian.Uint16(b[2:4])) + hdrlen
131131
h.FragOff = int(socket.NativeEndian.Uint16(b[6:8]))
132132
case "freebsd":

ipv4/header_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func TestMarshalHeader(t *testing.T) {
179179
}
180180
var wh []byte
181181
switch runtime.GOOS {
182-
case "darwin", "dragonfly", "netbsd":
182+
case "darwin", "ios", "dragonfly", "netbsd":
183183
wh = tt.wireHeaderToTradBSDKernel
184184
case "freebsd":
185185
switch {
@@ -227,7 +227,7 @@ func TestParseHeader(t *testing.T) {
227227
for _, tt := range headerLittleEndianTests {
228228
var wh []byte
229229
switch runtime.GOOS {
230-
case "darwin", "dragonfly", "netbsd":
230+
case "darwin", "ios", "dragonfly", "netbsd":
231231
wh = tt.wireHeaderFromTradBSDKernel
232232
case "freebsd":
233233
switch {

ipv4/unicast_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func TestPacketConnReadWriteUnicastICMP(t *testing.T) {
132132
}
133133
if n, _, _, err := p.ReadFrom(rb); err != nil {
134134
switch runtime.GOOS {
135-
case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket
135+
case "darwin", "ios": // older darwin kernels have some limitation on receiving icmp packet through raw socket
136136
t.Logf("not supported on %s", runtime.GOOS)
137137
continue
138138
}
@@ -222,7 +222,7 @@ func TestRawConnReadWriteUnicastICMP(t *testing.T) {
222222
}
223223
if _, b, _, err := r.ReadFrom(rb); err != nil {
224224
switch runtime.GOOS {
225-
case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket
225+
case "darwin", "ios": // older darwin kernels have some limitation on receiving icmp packet through raw socket
226226
t.Logf("not supported on %s", runtime.GOOS)
227227
continue
228228
}

ipv6/multicast_test.go

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

ipv6/multicastlistener_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func TestIPSinglePacketConnWithSingleGroupListener(t *testing.T) {
214214

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

ipv6/sockopt_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestConnInitiatorPathMTU(t *testing.T) {
4141

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

8080
if pmtu, err := ipv6.NewConn(c).PathMTU(); err != nil {
8181
switch runtime.GOOS {
82-
case "darwin": // older darwin kernels don't support IPV6_PATHMTU option
82+
case "darwin", "ios": // older darwin kernels don't support IPV6_PATHMTU option
8383
t.Logf("not supported on %s", runtime.GOOS)
8484
default:
8585
t.Fatal(err)

ipv6/unicast_test.go

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

ipv6/unicastsockopt_test.go

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

nettest/nettest.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func TestableNetwork(network string) bool {
9797
switch runtime.GOOS {
9898
case "android", "fuchsia", "hurd", "js", "nacl", "plan9", "windows":
9999
return false
100-
case "darwin":
100+
case "darwin", "ios":
101101
// iOS doesn't support it.
102102
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
103103
return false
@@ -118,15 +118,15 @@ func TestableNetwork(network string) bool {
118118
return false
119119
case "aix":
120120
return unixStrmDgramEnabled()
121-
case "darwin":
121+
case "darwin", "ios":
122122
// iOS does not support unix, unixgram.
123123
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
124124
return false
125125
}
126126
}
127127
case "unixpacket":
128128
switch runtime.GOOS {
129-
case "aix", "android", "fuchsia", "hurd", "darwin", "js", "nacl", "plan9", "windows":
129+
case "aix", "android", "fuchsia", "hurd", "darwin", "ios", "js", "nacl", "plan9", "windows":
130130
return false
131131
case "netbsd":
132132
// It passes on amd64 at least. 386 fails

route/address.go

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

route/route_classic.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func (m *RouteMessage) marshal() ([]byte, error) {
1717
return nil, errUnsupportedMessage
1818
}
1919
l := w.bodyOff + addrsSpace(m.Addrs)
20-
if runtime.GOOS == "darwin" {
20+
if runtime.GOOS == "darwin" || runtime.GOOS == "ios" {
2121
// Fix stray pointer writes on macOS.
2222
// See golang.org/issue/22456.
2323
l += 1024

0 commit comments

Comments
 (0)