You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

34 lines
1.1 KiB

  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. // +build dragonfly freebsd linux,!s390x,!386 netbsd openbsd
  5. package socket
  6. import (
  7. "syscall"
  8. "unsafe"
  9. )
  10. func getsockopt(s uintptr, level, name int, b []byte) (int, error) {
  11. l := uint32(len(b))
  12. _, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(unsafe.Pointer(&l)), 0)
  13. return int(l), errnoErr(errno)
  14. }
  15. func setsockopt(s uintptr, level, name int, b []byte) error {
  16. _, _, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), 0)
  17. return errnoErr(errno)
  18. }
  19. func recvmsg(s uintptr, h *msghdr, flags int) (int, error) {
  20. n, _, errno := syscall.Syscall(syscall.SYS_RECVMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags))
  21. return int(n), errnoErr(errno)
  22. }
  23. func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
  24. n, _, errno := syscall.Syscall(syscall.SYS_SENDMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags))
  25. return int(n), errnoErr(errno)
  26. }