sys_bsd.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2013 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 freebsd netbsd openbsd
  5. package ipv6
  6. import (
  7. "net"
  8. "syscall"
  9. )
  10. // RFC 3493 options
  11. const (
  12. // See /usr/include/netinet6/in6.h.
  13. sysSockoptUnicastHopLimit = 0x4
  14. sysSockoptMulticastHopLimit = 0xa
  15. sysSockoptMulticastInterface = 0x9
  16. sysSockoptMulticastLoopback = 0xb
  17. sysSockoptJoinGroup = 0xc
  18. sysSockoptLeaveGroup = 0xd
  19. )
  20. // RFC 3542 options
  21. const (
  22. // See /usr/include/netinet6/in6.h.
  23. sysSockoptReceiveTrafficClass = 0x39
  24. sysSockoptTrafficClass = 0x3d
  25. sysSockoptReceiveHopLimit = 0x25
  26. sysSockoptHopLimit = 0x2f
  27. sysSockoptReceivePacketInfo = 0x24
  28. sysSockoptPacketInfo = 0x2e
  29. sysSockoptReceivePathMTU = 0x2b
  30. sysSockoptPathMTU = 0x2c
  31. sysSockoptNextHop = 0x30
  32. sysSockoptChecksum = 0x1a
  33. // See /usr/include/netinet6/in6.h.
  34. sysSockoptICMPFilter = 0x12
  35. )
  36. func setSockaddr(sa *syscall.RawSockaddrInet6, ip net.IP, ifindex int) {
  37. sa.Len = syscall.SizeofSockaddrInet6
  38. sa.Family = syscall.AF_INET6
  39. copy(sa.Addr[:], ip)
  40. sa.Scope_id = uint32(ifindex)
  41. }