github.com/gidoBOSSftw5731/go/src@v0.0.0-20210226122457-d24b0edbf019/net/sockoptip_bsdvar.go (about) 1 // Copyright 2011 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 || netbsd || openbsd || solaris 6 // +build aix darwin dragonfly freebsd netbsd openbsd solaris 7 8 package net 9 10 import ( 11 "runtime" 12 "syscall" 13 ) 14 15 func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error { 16 ip, err := interfaceToIPv4Addr(ifi) 17 if err != nil { 18 return wrapSyscallError("setsockopt", err) 19 } 20 var a [4]byte 21 copy(a[:], ip.To4()) 22 err = fd.pfd.SetsockoptInet4Addr(syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, a) 23 runtime.KeepAlive(fd) 24 return wrapSyscallError("setsockopt", err) 25 } 26 27 func setIPv4MulticastLoopback(fd *netFD, v bool) error { 28 err := fd.pfd.SetsockoptByte(syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP, byte(boolint(v))) 29 runtime.KeepAlive(fd) 30 return wrapSyscallError("setsockopt", err) 31 }