github.com/roboticscm/goman@v0.0.0-20210203095141-87c07b4a0a55/src/net/sockoptip_linux.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 ) 11 12 func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error { 13 var v int32 14 if ifi != nil { 15 v = int32(ifi.Index) 16 } 17 mreq := &syscall.IPMreqn{Ifindex: v} 18 if err := fd.incref(); err != nil { 19 return err 20 } 21 defer fd.decref() 22 return os.NewSyscallError("setsockopt", syscall.SetsockoptIPMreqn(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, mreq)) 23 } 24 25 func setIPv4MulticastLoopback(fd *netFD, v bool) error { 26 if err := fd.incref(); err != nil { 27 return err 28 } 29 defer fd.decref() 30 return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP, boolint(v))) 31 }