sys_linux.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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 3542 options
  10. const (
  11. // See /usr/include/linux/ipv6.h,in6.h.
  12. sysSockoptReceiveTrafficClass = syscall.IPV6_RECVTCLASS
  13. sysSockoptTrafficClass = syscall.IPV6_TCLASS
  14. sysSockoptReceiveHopLimit = syscall.IPV6_RECVHOPLIMIT
  15. sysSockoptHopLimit = syscall.IPV6_HOPLIMIT
  16. sysSockoptReceivePacketInfo = syscall.IPV6_RECVPKTINFO
  17. sysSockoptPacketInfo = syscall.IPV6_PKTINFO
  18. sysSockoptReceivePathMTU = 0x3c // IPV6_RECVPATHMTU
  19. sysSockoptPathMTU = 0x3d // IPV6_PATHMTU
  20. sysSockoptNextHop = syscall.IPV6_NEXTHOP
  21. sysSockoptChecksum = syscall.IPV6_CHECKSUM
  22. // See /usr/include/linux/icmpv6.h.
  23. sysSockoptICMPFilter = 0x1 // syscall.ICMPV6_FILTER
  24. )
  25. func setSockaddr(sa *syscall.RawSockaddrInet6, ip net.IP, ifindex int) {
  26. sa.Family = syscall.AF_INET6
  27. copy(sa.Addr[:], ip)
  28. sa.Scope_id = uint32(ifindex)
  29. }