github.com/binkynet/BinkyNet@v1.12.1-0.20240421190447-da4e34c20be0/proto_vendor/golang.org/x/net/ipv4/sys_windows.go (about) 1 // Copyright 2014 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 ipv4 6 7 import ( 8 "golang.org/x/net/internal/iana" 9 "golang.org/x/net/internal/socket" 10 ) 11 12 const ( 13 // See ws2tcpip.h. 14 sysIP_OPTIONS = 0x1 15 sysIP_HDRINCL = 0x2 16 sysIP_TOS = 0x3 17 sysIP_TTL = 0x4 18 sysIP_MULTICAST_IF = 0x9 19 sysIP_MULTICAST_TTL = 0xa 20 sysIP_MULTICAST_LOOP = 0xb 21 sysIP_ADD_MEMBERSHIP = 0xc 22 sysIP_DROP_MEMBERSHIP = 0xd 23 sysIP_DONTFRAGMENT = 0xe 24 sysIP_ADD_SOURCE_MEMBERSHIP = 0xf 25 sysIP_DROP_SOURCE_MEMBERSHIP = 0x10 26 sysIP_PKTINFO = 0x13 27 28 sizeofInetPktinfo = 0x8 29 sizeofIPMreq = 0x8 30 sizeofIPMreqSource = 0xc 31 ) 32 33 type inetPktinfo struct { 34 Addr [4]byte 35 Ifindex int32 36 } 37 38 type ipMreq struct { 39 Multiaddr [4]byte 40 Interface [4]byte 41 } 42 43 type ipMreqSource struct { 44 Multiaddr [4]byte 45 Sourceaddr [4]byte 46 Interface [4]byte 47 } 48 49 // See http://msdn.microsoft.com/en-us/library/windows/desktop/ms738586(v=vs.85).aspx 50 var ( 51 ctlOpts = [ctlMax]ctlOpt{} 52 53 sockOpts = map[int]*sockOpt{ 54 ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TOS, Len: 4}}, 55 ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_TTL, Len: 4}}, 56 ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_TTL, Len: 4}}, 57 ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_IF, Len: 4}}, 58 ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_MULTICAST_LOOP, Len: 4}}, 59 ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_HDRINCL, Len: 4}}, 60 ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_ADD_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, 61 ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysIP_DROP_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, 62 } 63 ) 64 65 func (pi *inetPktinfo) setIfindex(i int) { 66 pi.Ifindex = int32(i) 67 }