sys_windows.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. "golang.org/x/net/internal/iana"
  9. )
  10. const (
  11. // See ws2tcpip.h.
  12. sysIPV6_UNICAST_HOPS = 0x4
  13. sysIPV6_MULTICAST_IF = 0x9
  14. sysIPV6_MULTICAST_HOPS = 0xa
  15. sysIPV6_MULTICAST_LOOP = 0xb
  16. sysIPV6_JOIN_GROUP = 0xc
  17. sysIPV6_LEAVE_GROUP = 0xd
  18. sysIPV6_PKTINFO = 0x13
  19. sysSizeofSockaddrInet6 = 0x1c
  20. sysSizeofIPv6Mreq = 0x14
  21. )
  22. type sysSockaddrInet6 struct {
  23. Family uint16
  24. Port uint16
  25. Flowinfo uint32
  26. Addr [16]byte /* in6_addr */
  27. Scope_id uint32
  28. }
  29. type sysIPv6Mreq struct {
  30. Multiaddr [16]byte /* in6_addr */
  31. Interface uint32
  32. }
  33. var (
  34. ctlOpts = [ctlMax]ctlOpt{}
  35. sockOpts = [ssoMax]sockOpt{
  36. ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt},
  37. ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface},
  38. ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt},
  39. ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt},
  40. ssoJoinGroup: {iana.ProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq},
  41. ssoLeaveGroup: {iana.ProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq},
  42. }
  43. )
  44. func (sa *sysSockaddrInet6) setSockaddr(ip net.IP, i int) {
  45. sa.Family = syscall.AF_INET6
  46. copy(sa.Addr[:], ip)
  47. sa.Scope_id = uint32(i)
  48. }
  49. func (mreq *sysIPv6Mreq) setIfindex(i int) {
  50. mreq.Interface = uint32(i)
  51. }