sys_darwin.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 = 0x14
  13. sysSockopt2292PacketInfo = 0x13
  14. sysSockopt2292NextHop = 0x15
  15. )
  16. // RFC 3493 options
  17. const (
  18. // See /usr/include/netinet6/in6.h.
  19. sysSockoptUnicastHopLimit = 0x4
  20. sysSockoptMulticastHopLimit = 0xa
  21. sysSockoptMulticastInterface = 0x9
  22. sysSockoptMulticastLoopback = 0xb
  23. sysSockoptJoinGroup = 0xc
  24. sysSockoptLeaveGroup = 0xd
  25. )
  26. // RFC 3542 options
  27. const (
  28. // See /usr/include/netinet6/in6.h.
  29. sysSockoptReceiveTrafficClass = 0x23
  30. sysSockoptTrafficClass = 0x24
  31. sysSockoptReceiveHopLimit = 0x25
  32. sysSockoptHopLimit = 0x2f
  33. sysSockoptReceivePacketInfo = 0x3d
  34. sysSockoptPacketInfo = 0x2e
  35. sysSockoptReceivePathMTU = 0x2b
  36. sysSockoptPathMTU = 0x2c
  37. sysSockoptNextHop = 0x30
  38. sysSockoptChecksum = 0x1a
  39. // See /usr/include/netinet6/in6.h.
  40. sysSockoptICMPFilter = 0x12
  41. )
  42. func setSockaddr(sa *syscall.RawSockaddrInet6, ip net.IP, ifindex int) {
  43. sa.Len = syscall.SizeofSockaddrInet6
  44. sa.Family = syscall.AF_INET6
  45. copy(sa.Addr[:], ip)
  46. sa.Scope_id = uint32(ifindex)
  47. }