sys_windows.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright 2017 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package socket
  5. import (
  6. "syscall"
  7. "unsafe"
  8. "golang.org/x/sys/windows"
  9. )
  10. func probeProtocolStack() int {
  11. var p uintptr
  12. return int(unsafe.Sizeof(p))
  13. }
  14. const (
  15. sysAF_UNSPEC = windows.AF_UNSPEC
  16. sysAF_INET = windows.AF_INET
  17. sysAF_INET6 = windows.AF_INET6
  18. sysSOCK_RAW = windows.SOCK_RAW
  19. )
  20. type sockaddrInet struct {
  21. Family uint16
  22. Port uint16
  23. Addr [4]byte /* in_addr */
  24. Zero [8]uint8
  25. }
  26. type sockaddrInet6 struct {
  27. Family uint16
  28. Port uint16
  29. Flowinfo uint32
  30. Addr [16]byte /* in6_addr */
  31. Scope_id uint32
  32. }
  33. const (
  34. sizeofSockaddrInet = 0x10
  35. sizeofSockaddrInet6 = 0x1c
  36. )
  37. func getsockopt(s uintptr, level, name int, b []byte) (int, error) {
  38. l := uint32(len(b))
  39. err := syscall.Getsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(unsafe.Pointer(&b[0])), (*int32)(unsafe.Pointer(&l)))
  40. return int(l), err
  41. }
  42. func setsockopt(s uintptr, level, name int, b []byte) error {
  43. return syscall.Setsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(unsafe.Pointer(&b[0])), int32(len(b)))
  44. }
  45. func recvmsg(s uintptr, h *msghdr, flags int) (int, error) {
  46. return 0, errNotImplemented
  47. }
  48. func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
  49. return 0, errNotImplemented
  50. }
  51. func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
  52. return 0, errNotImplemented
  53. }
  54. func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
  55. return 0, errNotImplemented
  56. }