sys_linux.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 3493 options
  10. const (
  11. // See /usr/include/linux/in6.h.
  12. sysSockoptUnicastHopLimit = 0x10
  13. sysSockoptMulticastHopLimit = 0x12
  14. sysSockoptMulticastInterface = 0x11
  15. sysSockoptMulticastLoopback = 0x13
  16. sysSockoptJoinGroup = 0x14
  17. sysSockoptLeaveGroup = 0x15
  18. )
  19. // RFC 3542 options
  20. const (
  21. // See /usr/include/linux/ipv6.h,in6.h.
  22. sysSockoptReceiveTrafficClass = 0x42
  23. sysSockoptTrafficClass = 0x43
  24. sysSockoptReceiveHopLimit = 0x33
  25. sysSockoptHopLimit = 0x34
  26. sysSockoptReceivePacketInfo = 0x31
  27. sysSockoptPacketInfo = 0x32
  28. sysSockoptReceivePathMTU = 0x3c
  29. sysSockoptPathMTU = 0x3d
  30. sysSockoptNextHop = 0x9
  31. sysSockoptChecksum = 0x7
  32. // See /usr/include/linux/icmpv6.h.
  33. sysSockoptICMPFilter = 0x1
  34. )
  35. func setSockaddr(sa *syscall.RawSockaddrInet6, ip net.IP, ifindex int) {
  36. sa.Family = syscall.AF_INET6
  37. copy(sa.Addr[:], ip)
  38. sa.Scope_id = uint32(ifindex)
  39. }