Merge "icmp: make Marshal of MessageBody, ParseMessage work correctly on parameter problem message"
diff --git a/icmp/endpoint.go b/icmp/endpoint.go
index 5bf2cfe..3de49e6 100644
--- a/icmp/endpoint.go
+++ b/icmp/endpoint.go
@@ -6,6 +6,7 @@
import (
"net"
+ "runtime"
"syscall"
"time"
@@ -51,6 +52,15 @@
if !c.ok() {
return 0, nil, syscall.EINVAL
}
+ // Please be informed that ipv4.NewPacketConn enables
+ // IP_STRIPHDR option by default on Darwin.
+ // See golang.org/issue/9395 for futher information.
+ if runtime.GOOS == "darwin" {
+ if p, _ := c.ipc.(*ipv4.PacketConn); p != nil {
+ n, _, peer, err := p.ReadFrom(b)
+ return n, peer, err
+ }
+ }
return c.c.ReadFrom(b)
}
diff --git a/icmp/helper_unix.go b/icmp/helper_posix.go
similarity index 95%
rename from icmp/helper_unix.go
rename to icmp/helper_posix.go
index ced835c..398fd38 100644
--- a/icmp/helper_unix.go
+++ b/icmp/helper_posix.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build darwin dragonfly freebsd linux netbsd openbsd solaris
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
package icmp
diff --git a/icmp/listen_unix.go b/icmp/listen_posix.go
similarity index 97%
rename from icmp/listen_unix.go
rename to icmp/listen_posix.go
index e99e67d..38b20f9 100644
--- a/icmp/listen_unix.go
+++ b/icmp/listen_posix.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build darwin dragonfly freebsd linux netbsd openbsd solaris
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
package icmp
diff --git a/icmp/listen_stub.go b/icmp/listen_stub.go
index 396a556..668728d 100644
--- a/icmp/listen_stub.go
+++ b/icmp/listen_stub.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build nacl plan9 windows
+// +build nacl plan9
package icmp