sys_bsd.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 dragonfly freebsd netbsd openbsd
  5. package ipv6
  6. import (
  7. "net"
  8. "syscall"
  9. )
  10. // RFC 3542 options
  11. const (
  12. // See /usr/include/netinet6/in6.h.
  13. sysSockoptReceiveTrafficClass = syscall.IPV6_RECVTCLASS
  14. sysSockoptTrafficClass = syscall.IPV6_TCLASS
  15. sysSockoptReceiveHopLimit = syscall.IPV6_RECVHOPLIMIT
  16. sysSockoptHopLimit = syscall.IPV6_HOPLIMIT
  17. sysSockoptReceivePacketInfo = syscall.IPV6_RECVPKTINFO
  18. sysSockoptPacketInfo = syscall.IPV6_PKTINFO
  19. sysSockoptReceivePathMTU = syscall.IPV6_RECVPATHMTU
  20. sysSockoptPathMTU = syscall.IPV6_PATHMTU
  21. sysSockoptNextHop = syscall.IPV6_NEXTHOP
  22. sysSockoptChecksum = syscall.IPV6_CHECKSUM
  23. // See /usr/include/netinet6/in6.h.
  24. sysSockoptICMPFilter = 0x12 // syscall.ICMP6_FILTER
  25. )
  26. func setSockaddr(sa *syscall.RawSockaddrInet6, ip net.IP, ifindex int) {
  27. sa.Len = syscall.SizeofSockaddrInet6
  28. sa.Family = syscall.AF_INET6
  29. copy(sa.Addr[:], ip)
  30. sa.Scope_id = uint32(ifindex)
  31. }