golang.org/x/net@v0.25.1-0.20240516223405-c87a5b62e243/ipv6/sys_ssmreq.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 //go:build aix || darwin || freebsd || linux || solaris || zos 6 7 package ipv6 8 9 import ( 10 "net" 11 "unsafe" 12 13 "golang.org/x/net/internal/socket" 14 ) 15 16 var compatFreeBSD32 bool // 386 emulation on amd64 17 18 func (so *sockOpt) setGroupReq(c *socket.Conn, ifi *net.Interface, grp net.IP) error { 19 var gr groupReq 20 if ifi != nil { 21 gr.Interface = uint32(ifi.Index) 22 } 23 gr.setGroup(grp) 24 var b []byte 25 if compatFreeBSD32 { 26 var d [sizeofGroupReq + 4]byte 27 s := (*[sizeofGroupReq]byte)(unsafe.Pointer(&gr)) 28 copy(d[:4], s[:4]) 29 copy(d[8:], s[4:]) 30 b = d[:] 31 } else { 32 b = (*[sizeofGroupReq]byte)(unsafe.Pointer(&gr))[:sizeofGroupReq] 33 } 34 return so.Set(c, b) 35 } 36 37 func (so *sockOpt) setGroupSourceReq(c *socket.Conn, ifi *net.Interface, grp, src net.IP) error { 38 var gsr groupSourceReq 39 if ifi != nil { 40 gsr.Interface = uint32(ifi.Index) 41 } 42 gsr.setSourceGroup(grp, src) 43 var b []byte 44 if compatFreeBSD32 { 45 var d [sizeofGroupSourceReq + 4]byte 46 s := (*[sizeofGroupSourceReq]byte)(unsafe.Pointer(&gsr)) 47 copy(d[:4], s[:4]) 48 copy(d[8:], s[4:]) 49 b = d[:] 50 } else { 51 b = (*[sizeofGroupSourceReq]byte)(unsafe.Pointer(&gsr))[:sizeofGroupSourceReq] 52 } 53 return so.Set(c, b) 54 }