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.

28 lines
729 B

  1. // Copyright 2016 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 darwin dragonfly freebsd netbsd openbsd
  5. package route
  6. import (
  7. "syscall"
  8. "unsafe"
  9. )
  10. var zero uintptr
  11. func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error {
  12. var p unsafe.Pointer
  13. if len(mib) > 0 {
  14. p = unsafe.Pointer(&mib[0])
  15. } else {
  16. p = unsafe.Pointer(&zero)
  17. }
  18. _, _, errno := syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(p), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
  19. if errno != 0 {
  20. return error(errno)
  21. }
  22. return nil
  23. }