sys_windows.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. "errors"
  7. "syscall"
  8. "unsafe"
  9. )
  10. func probeProtocolStack() int {
  11. var p uintptr
  12. return int(unsafe.Sizeof(p))
  13. }
  14. const (
  15. sysAF_UNSPEC = 0x0
  16. sysAF_INET = 0x2
  17. sysAF_INET6 = 0x17
  18. sysSOCK_RAW = 0x3
  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, errors.New("not implemented")
  47. }
  48. func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
  49. return 0, errors.New("not implemented")
  50. }
  51. func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
  52. return 0, errors.New("not implemented")
  53. }
  54. func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
  55. return 0, errors.New("not implemented")
  56. }