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.
 
 
 

32 lines
830 B

  1. // Copyright 2009 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 ipv6
  5. import (
  6. "syscall"
  7. "unsafe"
  8. )
  9. const (
  10. sysGETSOCKOPT = 0xf
  11. sysSETSOCKOPT = 0xe
  12. )
  13. func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno)
  14. func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error {
  15. if _, errno := socketcall(sysGETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 {
  16. return error(errno)
  17. }
  18. return nil
  19. }
  20. func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error {
  21. if _, errno := socketcall(sysSETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 {
  22. return error(errno)
  23. }
  24. return nil
  25. }