author | Mikio Hara
<mikioh.mikioh@gmail.com> 2016-08-24 22:20:41 UTC |
committer | Mikio Hara
<mikioh.mikioh@gmail.com> 2016-08-26 23:57:38 UTC |
parent | b398290406bbc75d396dcdbeaf07c7117d9804d8 |
ipv6/icmp_windows.go | +0 | -4 |
ipv6/{sockopt_asmreq_unix.go => sockopt_asmreq_posix.go} | +1 | -1 |
ipv6/sockopt_asmreq_windows.go | +0 | -21 |
ipv6/{sockopt_unix.go => sockopt_posix.go} | +1 | -1 |
ipv6/sockopt_windows.go | +0 | -86 |
ipv6/sys_windows.go | +12 | -1 |
ipv6/syscall_windows.go | +18 | -0 |
diff --git a/ipv6/icmp_windows.go b/ipv6/icmp_windows.go index 9dcfb81..f477a8c 100644 --- a/ipv6/icmp_windows.go +++ b/ipv6/icmp_windows.go @@ -4,10 +4,6 @@ package ipv6 -type sysICMPv6Filter struct { - // TODO(mikio): implement this -} - func (f *sysICMPv6Filter) accept(typ ICMPType) { // TODO(mikio): implement this } diff --git a/ipv6/sockopt_asmreq_unix.go b/ipv6/sockopt_asmreq_posix.go similarity index 89% rename from ipv6/sockopt_asmreq_unix.go rename to ipv6/sockopt_asmreq_posix.go index 4fcd7c5..092e398 100644 --- a/ipv6/sockopt_asmreq_unix.go +++ b/ipv6/sockopt_asmreq_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 +// +build darwin dragonfly freebsd linux netbsd openbsd windows package ipv6 diff --git a/ipv6/sockopt_asmreq_windows.go b/ipv6/sockopt_asmreq_windows.go deleted file mode 100644 index 88408ea..0000000 --- a/ipv6/sockopt_asmreq_windows.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "os" - "syscall" - "unsafe" -) - -func setsockoptIPMreq(s uintptr, opt *sockOpt, ifi *net.Interface, grp net.IP) error { - var mreq sysIPv6Mreq - copy(mreq.Multiaddr[:], grp) - if ifi != nil { - mreq.setIfindex(ifi.Index) - } - return os.NewSyscallError("setsockopt", syscall.Setsockopt(syscall.Handle(s), int32(opt.level), int32(opt.name), (*byte)(unsafe.Pointer(&mreq)), sysSizeofIPv6Mreq)) -} diff --git a/ipv6/sockopt_unix.go b/ipv6/sockopt_posix.go similarity index 98% rename from ipv6/sockopt_unix.go rename to ipv6/sockopt_posix.go index 8563203..651aa93 100644 --- a/ipv6/sockopt_unix.go +++ b/ipv6/sockopt_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 +// +build darwin dragonfly freebsd linux netbsd openbsd windows package ipv6 diff --git a/ipv6/sockopt_windows.go b/ipv6/sockopt_windows.go deleted file mode 100644 index 3e3331f..0000000 --- a/ipv6/sockopt_windows.go +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "os" - "syscall" - "unsafe" -) - -func getInt(s uintptr, opt *sockOpt) (int, error) { - if opt.name < 1 || opt.typ != ssoTypeInt { - return 0, errOpNoSupport - } - var i int32 - l := int32(4) - if err := syscall.Getsockopt(syscall.Handle(s), int32(opt.level), int32(opt.name), (*byte)(unsafe.Pointer(&i)), &l); err != nil { - return 0, os.NewSyscallError("getsockopt", err) - } - return int(i), nil -} - -func setInt(s uintptr, opt *sockOpt, v int) error { - if opt.name < 1 || opt.typ != ssoTypeInt { - return errOpNoSupport - } - i := int32(v) - return os.NewSyscallError("setsockopt", syscall.Setsockopt(syscall.Handle(s), int32(opt.level), int32(opt.name), (*byte)(unsafe.Pointer(&i)), 4)) -} - -func getInterface(s uintptr, opt *sockOpt) (*net.Interface, error) { - if opt.name < 1 || opt.typ != ssoTypeInterface { - return nil, errOpNoSupport - } - var i int32 - l := int32(4) - if err := syscall.Getsockopt(syscall.Handle(s), int32(opt.level), int32(opt.name), (*byte)(unsafe.Pointer(&i)), &l); err != nil { - return nil, os.NewSyscallError("getsockopt", err) - } - if i == 0 { - return nil, nil - } - ifi, err := net.InterfaceByIndex(int(i)) - if err != nil { - return nil, err - } - return ifi, nil -} - -func setInterface(s uintptr, opt *sockOpt, ifi *net.Interface) error { - if opt.name < 1 || opt.typ != ssoTypeInterface { - return errOpNoSupport - } - var i int32 - if ifi != nil { - i = int32(ifi.Index) - } - return os.NewSyscallError("setsockopt", syscall.Setsockopt(syscall.Handle(s), int32(opt.level), int32(opt.name), (*byte)(unsafe.Pointer(&i)), 4)) -} - -func getICMPFilter(s uintptr, opt *sockOpt) (*ICMPFilter, error) { - return nil, errOpNoSupport -} - -func setICMPFilter(s uintptr, opt *sockOpt, f *ICMPFilter) error { - return errOpNoSupport -} - -func getMTUInfo(s uintptr, opt *sockOpt) (*net.Interface, int, error) { - return nil, 0, errOpNoSupport -} - -func setGroup(s uintptr, opt *sockOpt, ifi *net.Interface, grp net.IP) error { - if opt.name < 1 || opt.typ != ssoTypeIPMreq { - return errOpNoSupport - } - return setsockoptIPMreq(s, opt, ifi, grp) -} - -func setSourceGroup(s uintptr, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error { - // TODO(mikio): implement this - return errOpNoSupport -} diff --git a/ipv6/sys_windows.go b/ipv6/sys_windows.go index fda8757..4051906 100644 --- a/ipv6/sys_windows.go +++ b/ipv6/sys_windows.go @@ -23,7 +23,9 @@ const ( sysSizeofSockaddrInet6 = 0x1c - sysSizeofIPv6Mreq = 0x14 + sysSizeofIPv6Mreq = 0x14 + sysSizeofIPv6Mtuinfo = 0x20 + sysSizeofICMPv6Filter = 0 ) type sysSockaddrInet6 struct { @@ -39,6 +41,15 @@ type sysIPv6Mreq struct { Interface uint32 } +type sysIPv6Mtuinfo struct { + Addr sysSockaddrInet6 + Mtu uint32 +} + +type sysICMPv6Filter struct { + // TODO(mikio): implement this +} + var ( ctlOpts = [ctlMax]ctlOpt{} diff --git a/ipv6/syscall_windows.go b/ipv6/syscall_windows.go new file mode 100644 index 0000000..c1f649d --- /dev/null +++ b/ipv6/syscall_windows.go @@ -0,0 +1,18 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ipv6 + +import ( + "syscall" + "unsafe" +) + +func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error { + return syscall.Getsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(v), (*int32)(unsafe.Pointer(l))) +} + +func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error { + return syscall.Setsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(v), int32(l)) +}