go.net/ipv6: make it work with Go 1.1
This CL makes use of built-in syscall stuff to allow go.net/ipv6
to work together with Go 1.1. Also it's able to improve the package
without churning the Go standard library.
Fixes golang/go#6548.
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/15040044
diff --git a/ipv6/sockopt_rfc3493_linux.go b/ipv6/sockopt_rfc3493_linux.go
index b2557e8..f13a28f 100644
--- a/ipv6/sockopt_rfc3493_linux.go
+++ b/ipv6/sockopt_rfc3493_linux.go
@@ -6,12 +6,13 @@
import (
"os"
- "syscall"
+ "unsafe"
)
func setIPv6Checksum(fd int, on bool, offset int) error {
if !on {
offset = -1
}
- return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd, ianaProtocolReserved, syscall.IPV6_CHECKSUM, offset))
+ v := int32(offset)
+ return os.NewSyscallError("setsockopt", setsockopt(fd, ianaProtocolReserved, sysSockoptChecksum, uintptr(unsafe.Pointer(&v)), 4))
}