gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/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  	"gitee.com/ks-custle/core-gm/net/internal/iana"
     9  	"gitee.com/ks-custle/core-gm/net/internal/socket"
    10  
    11  	"golang.org/x/sys/windows"
    12  )
    13  
    14  const (
    15  	sizeofIPMreq       = 0x8
    16  	sizeofIPMreqSource = 0xc
    17  )
    18  
    19  type ipMreq struct {
    20  	Multiaddr [4]byte
    21  	Interface [4]byte
    22  }
    23  
    24  type ipMreqSource struct {
    25  	Multiaddr  [4]byte
    26  	Sourceaddr [4]byte
    27  	Interface  [4]byte
    28  }
    29  
    30  // See http://msdn.microsoft.com/en-us/library/windows/desktop/ms738586(v=vs.85).aspx
    31  var (
    32  	ctlOpts = [ctlMax]ctlOpt{}
    33  
    34  	sockOpts = map[int]*sockOpt{
    35  		ssoTOS:                {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_TOS, Len: 4}},
    36  		ssoTTL:                {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_TTL, Len: 4}},
    37  		ssoMulticastTTL:       {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_MULTICAST_TTL, Len: 4}},
    38  		ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_MULTICAST_IF, Len: 4}},
    39  		ssoMulticastLoopback:  {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_MULTICAST_LOOP, Len: 4}},
    40  		ssoHeaderPrepend:      {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_HDRINCL, Len: 4}},
    41  		ssoJoinGroup:          {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_ADD_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq},
    42  		ssoLeaveGroup:         {Option: socket.Option{Level: iana.ProtocolIP, Name: windows.IP_DROP_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq},
    43  	}
    44  )