sys_darwin.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. package ipv6
  5. import (
  6. "net"
  7. "syscall"
  8. )
  9. // RFC 2292 options
  10. const (
  11. // See /usr/include/netinet6/in6.h.
  12. sysSockopt2292HopLimit = syscall.IPV6_2292HOPLIMIT
  13. sysSockopt2292PacketInfo = syscall.IPV6_2292PKTINFO
  14. sysSockopt2292NextHop = syscall.IPV6_2292NEXTHOP
  15. )
  16. // RFC 3542 options
  17. const (
  18. // See /usr/include/netinet6/in6.h.
  19. sysSockoptReceiveTrafficClass = 0x23 // IPV6_RECVTCLASS
  20. sysSockoptTrafficClass = 0x24 // IPV6_TCLASS
  21. sysSockoptReceiveHopLimit = 0x25 // IPV6_RECVHOPLIMIT
  22. sysSockoptHopLimit = 0x2f // IPV6_HOPLIMIT
  23. sysSockoptReceivePacketInfo = 0x3d // IPV6_RECVPKTINFO
  24. sysSockoptPacketInfo = 0x2e // IPV6_PKTINFO
  25. sysSockoptReceivePathMTU = 0x2b // IPV6_RECVPATHMTU
  26. sysSockoptPathMTU = 0x2c // IPV6_PATHMTU
  27. sysSockoptNextHop = 0x30 // IPV6_NEXTHOP
  28. sysSockoptChecksum = 0x1a // IPV6_CHECKSUM
  29. // See /usr/include/netinet6/in6.h.
  30. sysSockoptICMPFilter = 0x12 // ICMP6_FILTER
  31. )
  32. func setSockaddr(sa *syscall.RawSockaddrInet6, ip net.IP, ifindex int) {
  33. sa.Len = syscall.SizeofSockaddrInet6
  34. sa.Family = syscall.AF_INET6
  35. copy(sa.Addr[:], ip)
  36. sa.Scope_id = uint32(ifindex)
  37. }