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