gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/net/ipv6/sys_asmreq.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  //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows
     6  // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows
     7  
     8  package ipv6
     9  
    10  import (
    11  	"net"
    12  	"unsafe"
    13  
    14  	"gitee.com/ks-custle/core-gm/net/internal/socket"
    15  )
    16  
    17  func (so *sockOpt) setIPMreq(c *socket.Conn, ifi *net.Interface, grp net.IP) error {
    18  	var mreq ipv6Mreq
    19  	copy(mreq.Multiaddr[:], grp)
    20  	if ifi != nil {
    21  		mreq.setIfindex(ifi.Index)
    22  	}
    23  	b := (*[sizeofIPv6Mreq]byte)(unsafe.Pointer(&mreq))[:sizeofIPv6Mreq]
    24  	return so.Set(c, b)
    25  }