github.com/Andyfoo/golang/x/net@v0.0.0-20190901054642-57c1bf301704/ipv6/sys_windows.go (about) 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 5 package ipv6 6 7 import ( 8 "net" 9 "syscall" 10 11 "github.com/Andyfoo/golang/x/net/internal/iana" 12 "github.com/Andyfoo/golang/x/net/internal/socket" 13 ) 14 15 const ( 16 // See ws2tcpip.h. 17 sysIPV6_UNICAST_HOPS = 0x4 18 sysIPV6_MULTICAST_IF = 0x9 19 sysIPV6_MULTICAST_HOPS = 0xa 20 sysIPV6_MULTICAST_LOOP = 0xb 21 sysIPV6_JOIN_GROUP = 0xc 22 sysIPV6_LEAVE_GROUP = 0xd 23 sysIPV6_PKTINFO = 0x13 24 25 sizeofSockaddrInet6 = 0x1c 26 27 sizeofIPv6Mreq = 0x14 28 sizeofIPv6Mtuinfo = 0x20 29 sizeofICMPv6Filter = 0 30 ) 31 32 type sockaddrInet6 struct { 33 Family uint16 34 Port uint16 35 Flowinfo uint32 36 Addr [16]byte /* in6_addr */ 37 Scope_id uint32 38 } 39 40 type ipv6Mreq struct { 41 Multiaddr [16]byte /* in6_addr */ 42 Interface uint32 43 } 44 45 type ipv6Mtuinfo struct { 46 Addr sockaddrInet6 47 Mtu uint32 48 } 49 50 type icmpv6Filter struct { 51 // TODO(mikio): implement this 52 } 53 54 var ( 55 ctlOpts = [ctlMax]ctlOpt{} 56 57 sockOpts = map[int]*sockOpt{ 58 ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_UNICAST_HOPS, Len: 4}}, 59 ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_IF, Len: 4}}, 60 ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_HOPS, Len: 4}}, 61 ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_LOOP, Len: 4}}, 62 ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_JOIN_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, 63 ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_LEAVE_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, 64 } 65 ) 66 67 func (sa *sockaddrInet6) setSockaddr(ip net.IP, i int) { 68 sa.Family = syscall.AF_INET6 69 copy(sa.Addr[:], ip) 70 sa.Scope_id = uint32(i) 71 } 72 73 func (mreq *ipv6Mreq) setIfindex(i int) { 74 mreq.Interface = uint32(i) 75 }