github.com/roboticscm/goman@v0.0.0-20210203095141-87c07b4a0a55/src/net/sockoptip_windows.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 package net 6 7 import ( 8 "os" 9 "syscall" 10 "unsafe" 11 ) 12 13 func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error { 14 ip, err := interfaceToIPv4Addr(ifi) 15 if err != nil { 16 return os.NewSyscallError("setsockopt", err) 17 } 18 var a [4]byte 19 copy(a[:], ip.To4()) 20 if err := fd.incref(); err != nil { 21 return err 22 } 23 defer fd.decref() 24 return os.NewSyscallError("setsockopt", syscall.Setsockopt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, (*byte)(unsafe.Pointer(&a[0])), 4)) 25 } 26 27 func setIPv4MulticastLoopback(fd *netFD, v bool) error { 28 if err := fd.incref(); err != nil { 29 return err 30 } 31 defer fd.decref() 32 return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP, boolint(v))) 33 }