gtsocial-umbx

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

sys_ssmreq.go (1297B)


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