gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

sys_ssmreq.go (1371B)


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