Browse Source

go.net/ipv6: fix build on dragonfly, plan9, solaris

R=golang-codereviews, aram, r, 0intro
CC=golang-codereviews
https://golang.org/cl/54350043
Mikio Hara 12 years ago
parent
commit
0cda728e61

+ 0 - 1
ipv6/control.go

@@ -12,7 +12,6 @@ import (
 )
 
 var (
-	errNotSupported    = errors.New("not supported")
 	errMissingAddress  = errors.New("missing address")
 	errInvalidConnType = errors.New("invalid conn type")
 	errNoSuchInterface = errors.New("no such interface")

+ 4 - 4
ipv6/control_rfc3542_plan9.go → ipv6/control_rfc3542_stub.go

@@ -2,13 +2,13 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package ipv6
+// +build dragonfly plan9 solaris
 
-import "syscall"
+package ipv6
 
 func setControlMessage(fd int, opt *rawOpt, cf ControlFlags, on bool) error {
 	// TODO(mikio): Implement this
-	return syscall.EPLAN9
+	return errOpNoSupport
 }
 
 func newControlMessage(opt *rawOpt) (oob []byte) {
@@ -18,7 +18,7 @@ func newControlMessage(opt *rawOpt) (oob []byte) {
 
 func parseControlMessage(b []byte) (*ControlMessage, error) {
 	// TODO(mikio): Implement this
-	return nil, syscall.EPLAN9
+	return nil, errOpNoSupport
 }
 
 func marshalControlMessage(cm *ControlMessage) (oob []byte) {

+ 15 - 16
ipv6/dgramopt_plan9.go → ipv6/dgramopt_stub.go

@@ -2,53 +2,52 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build dragonfly plan9 solaris
+
 package ipv6
 
-import (
-	"net"
-	"syscall"
-)
+import "net"
 
 // MulticastHopLimit returns the hop limit field value for outgoing
 // multicast packets.
 func (c *dgramOpt) MulticastHopLimit() (int, error) {
 	// TODO(mikio): Implement this
-	return 0, syscall.EPLAN9
+	return 0, errOpNoSupport
 }
 
 // SetMulticastHopLimit sets the hop limit field value for future
 // outgoing multicast packets.
 func (c *dgramOpt) SetMulticastHopLimit(hoplim int) error {
 	// TODO(mikio): Implement this
-	return syscall.EPLAN9
+	return errOpNoSupport
 }
 
 // MulticastInterface returns the default interface for multicast
 // packet transmissions.
 func (c *dgramOpt) MulticastInterface() (*net.Interface, error) {
 	// TODO(mikio): Implement this
-	return nil, syscall.EPLAN9
+	return nil, errOpNoSupport
 }
 
 // SetMulticastInterface sets the default interface for future
 // multicast packet transmissions.
 func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error {
 	// TODO(mikio): Implement this
-	return syscall.EPLAN9
+	return errOpNoSupport
 }
 
 // MulticastLoopback reports whether transmitted multicast packets
 // should be copied and send back to the originator.
 func (c *dgramOpt) MulticastLoopback() (bool, error) {
 	// TODO(mikio): Implement this
-	return false, syscall.EPLAN9
+	return false, errOpNoSupport
 }
 
 // SetMulticastLoopback sets whether transmitted multicast packets
 // should be copied and send back to the originator.
 func (c *dgramOpt) SetMulticastLoopback(on bool) error {
 	// TODO(mikio): Implement this
-	return syscall.EPLAN9
+	return errOpNoSupport
 }
 
 // JoinGroup joins the group address group on the interface ifi.
@@ -57,13 +56,13 @@ func (c *dgramOpt) SetMulticastLoopback(on bool) error {
 // platforms and sometimes it might require routing configuration.
 func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error {
 	// TODO(mikio): Implement this
-	return syscall.EPLAN9
+	return errOpNoSupport
 }
 
 // LeaveGroup leaves the group address group on the interface ifi.
 func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error {
 	// TODO(mikio): Implement this
-	return syscall.EPLAN9
+	return errOpNoSupport
 }
 
 // Checksum reports whether the kernel will compute, store or verify a
@@ -72,7 +71,7 @@ func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error {
 // field is located.
 func (c *dgramOpt) Checksum() (on bool, offset int, err error) {
 	// TODO(mikio): Implement this
-	return false, 0, syscall.EPLAN9
+	return false, 0, errOpNoSupport
 }
 
 // SetChecksum enables the kernel checksum processing.  If on is ture,
@@ -80,17 +79,17 @@ func (c *dgramOpt) Checksum() (on bool, offset int, err error) {
 // checksum field is located.
 func (c *dgramOpt) SetChecksum(on bool, offset int) error {
 	// TODO(mikio): Implement this
-	return syscall.EPLAN9
+	return errOpNoSupport
 }
 
 // ICMPFilter returns an ICMP filter.
 func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) {
 	// TODO(mikio): Implement this
-	return nil, syscall.EPLAN9
+	return nil, errOpNoSupport
 }
 
 // SetICMPFilter deploys the ICMP filter.
 func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error {
 	// TODO(mikio): Implement this
-	return syscall.EPLAN9
+	return errOpNoSupport
 }

+ 6 - 6
ipv6/genericopt_plan9.go → ipv6/genericopt_stub.go

@@ -2,33 +2,33 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package ipv6
+// +build dragonfly plan9 solaris
 
-import "syscall"
+package ipv6
 
 // TrafficClass returns the traffic class field value for outgoing
 // packets.
 func (c *genericOpt) TrafficClass() (int, error) {
 	// TODO(mikio): Implement this
-	return 0, syscall.EPLAN9
+	return 0, errOpNoSupport
 }
 
 // SetTrafficClass sets the traffic class field value for future
 // outgoing packets.
 func (c *genericOpt) SetTrafficClass(tclass int) error {
 	// TODO(mikio): Implement this
-	return syscall.EPLAN9
+	return errOpNoSupport
 }
 
 // HopLimit returns the hop limit field value for outgoing packets.
 func (c *genericOpt) HopLimit() (int, error) {
 	// TODO(mikio): Implement this
-	return 0, syscall.EPLAN9
+	return 0, errOpNoSupport
 }
 
 // SetHopLimit sets the hop limit field value for future outgoing
 // packets.
 func (c *genericOpt) SetHopLimit(hoplim int) error {
 	// TODO(mikio): Implement this
-	return syscall.EPLAN9
+	return errOpNoSupport
 }

+ 6 - 1
ipv6/helper.go

@@ -4,7 +4,12 @@
 
 package ipv6
 
-import "net"
+import (
+	"errors"
+	"net"
+)
+
+var errOpNoSupport = errors.New("operation not supported")
 
 func boolint(b bool) int {
 	if b {

+ 5 - 5
ipv6/helper_plan9.go → ipv6/helper_stub.go

@@ -2,21 +2,21 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package ipv6
+// +build dragonfly plan9 solaris
 
-import "syscall"
+package ipv6
 
 func (c *genericOpt) sysfd() (int, error) {
 	// TODO(mikio): Implement this
-	return 0, syscall.EPLAN9
+	return 0, errOpNoSupport
 }
 
 func (c *dgramOpt) sysfd() (int, error) {
 	// TODO(mikio): Implement this
-	return 0, syscall.EPLAN9
+	return 0, errOpNoSupport
 }
 
 func (c *payloadHandler) sysfd() (int, error) {
 	// TODO(mikio): Implement this
-	return 0, syscall.EPLAN9
+	return 0, errOpNoSupport
 }

+ 2 - 0
ipv6/icmp_plan9.go → ipv6/icmp_stub.go

@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build dragonfly plan9 solaris
+
 package ipv6
 
 type sysICMPFilter struct {

+ 2 - 2
ipv6/icmp_test.go

@@ -34,7 +34,7 @@ func TestICMPString(t *testing.T) {
 
 func TestICMPFilter(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 
@@ -67,7 +67,7 @@ func TestICMPFilter(t *testing.T) {
 
 func TestSetICMPFilter(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {

+ 2 - 2
ipv6/multicast_test.go

@@ -19,7 +19,7 @@ func TestPacketConnReadWriteMulticastUDP(t *testing.T) {
 	case "freebsd": // due to a bug on loopback marking
 		// See http://www.freebsd.org/cgi/query-pr.cgi?pr=180065.
 		t.Skipf("not supported on %q", runtime.GOOS)
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {
@@ -97,7 +97,7 @@ func TestPacketConnReadWriteMulticastUDP(t *testing.T) {
 
 func TestPacketConnReadWriteMulticastICMP(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {

+ 5 - 5
ipv6/multicastlistener_test.go

@@ -21,7 +21,7 @@ var udpMultipleGroupListenerTests = []net.Addr{
 
 func TestUDPSinglePacketConnWithMultipleGroupListeners(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {
@@ -61,7 +61,7 @@ func TestUDPSinglePacketConnWithMultipleGroupListeners(t *testing.T) {
 
 func TestUDPMultiplePacketConnWithMultipleGroupListeners(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {
@@ -113,7 +113,7 @@ func TestUDPMultiplePacketConnWithMultipleGroupListeners(t *testing.T) {
 
 func TestUDPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {
@@ -156,7 +156,7 @@ func TestUDPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) {
 
 func TestIPSinglePacketConnWithSingleGroupListener(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {
@@ -198,7 +198,7 @@ func TestIPSinglePacketConnWithSingleGroupListener(t *testing.T) {
 
 func TestIPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) {
 	switch runtime.GOOS {
-	case "darwin", "plan9", "windows":
+	case "darwin", "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {

+ 1 - 1
ipv6/multicastsockopt_test.go

@@ -22,7 +22,7 @@ var packetConnMulticastSocketOptionTests = []struct {
 
 func TestPacketConnMulticastSocketOptions(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {

+ 1 - 1
ipv6/readwrite_test.go

@@ -90,7 +90,7 @@ func benchmarkReadWriteIPv6UDP(b *testing.B, p *ipv6.PacketConn, wb, rb []byte,
 
 func TestPacketConnConcurrentReadWriteUnicastUDP(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {

+ 5 - 5
ipv6/sockopt_rfc2292_unix.go

@@ -12,11 +12,11 @@ import (
 )
 
 func ipv6ReceiveTrafficClass(fd int) (bool, error) {
-	return false, errNotSupported
+	return false, errOpNoSupport
 }
 
 func setIPv6ReceiveTrafficClass(fd int, v bool) error {
-	return errNotSupported
+	return errOpNoSupport
 }
 
 func ipv6ReceiveHopLimit(fd int) (bool, error) {
@@ -48,15 +48,15 @@ func setIPv6ReceivePacketInfo(fd int, v bool) error {
 }
 
 func ipv6PathMTU(fd int) (int, error) {
-	return 0, errNotSupported
+	return 0, errOpNoSupport
 }
 
 func ipv6ReceivePathMTU(fd int) (bool, error) {
-	return false, errNotSupported
+	return false, errOpNoSupport
 }
 
 func setIPv6ReceivePathMTU(fd int, v bool) error {
-	return errNotSupported
+	return errOpNoSupport
 }
 
 func ipv6ICMPFilter(fd int) (*ICMPFilter, error) {

+ 3 - 3
ipv6/sockopt_rfc3542_plan9.go → ipv6/sockopt_rfc3542_stub.go

@@ -2,11 +2,11 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package ipv6
+// +build dragonfly plan9 solaris
 
-import "syscall"
+package ipv6
 
 func ipv6PathMTU(fd int) (int, error) {
 	// TODO(mikio): Implement this
-	return 0, syscall.EPLAN9
+	return 0, errOpNoSupport
 }

+ 4 - 4
ipv6/sockopt_test.go

@@ -24,7 +24,7 @@ func init() {
 var condFatalf = func() func(*testing.T, string, ...interface{}) {
 	// A few APIs are not implemented yet on some platforms.
 	switch runtime.GOOS {
-	case "darwin", "plan9", "windows":
+	case "darwin", "dragonfly", "plan9", "solaris", "windows":
 		return (*testing.T).Logf
 	}
 	return (*testing.T).Fatalf
@@ -32,7 +32,7 @@ var condFatalf = func() func(*testing.T, string, ...interface{}) {
 
 func TestConnInitiatorPathMTU(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {
@@ -65,7 +65,7 @@ func TestConnInitiatorPathMTU(t *testing.T) {
 
 func TestConnResponderPathMTU(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {
@@ -98,7 +98,7 @@ func TestConnResponderPathMTU(t *testing.T) {
 
 func TestPacketConnChecksum(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {

+ 2 - 2
ipv6/unicast_test.go

@@ -16,7 +16,7 @@ import (
 
 func TestPacketConnReadWriteUnicastUDP(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {
@@ -77,7 +77,7 @@ func TestPacketConnReadWriteUnicastUDP(t *testing.T) {
 
 func TestPacketConnReadWriteUnicastICMP(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {

+ 2 - 2
ipv6/unicastsockopt_test.go

@@ -14,7 +14,7 @@ import (
 
 func TestConnUnicastSocketOptions(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {
@@ -50,7 +50,7 @@ var packetConnUnicastSocketOptionTests = []struct {
 
 func TestPacketConnUnicastSocketOptions(t *testing.T) {
 	switch runtime.GOOS {
-	case "plan9", "windows":
+	case "dragonfly", "plan9", "solaris", "windows":
 		t.Skipf("not supported on %q", runtime.GOOS)
 	}
 	if !supportsIPv6 {