syscall_linux_386.go 830 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2014 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 ipv4
  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. }