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