Retro68/gcc/libgo/go/net/sockoptip_linux.go

32 lines
831 B
Go
Raw Normal View History

2012-03-27 23:13:14 +00:00
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package net
import (
"os"
"syscall"
)
func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error {
var v int32
if ifi != nil {
v = int32(ifi.Index)
}
mreq := &syscall.IPMreqn{Ifindex: v}
2014-09-21 17:33:12 +00:00
if err := fd.incref(); err != nil {
2012-03-27 23:13:14 +00:00
return err
}
defer fd.decref()
2014-09-21 17:33:12 +00:00
return os.NewSyscallError("setsockopt", syscall.SetsockoptIPMreqn(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, mreq))
2012-03-27 23:13:14 +00:00
}
func setIPv4MulticastLoopback(fd *netFD, v bool) error {
2014-09-21 17:33:12 +00:00
if err := fd.incref(); err != nil {
2012-03-27 23:13:14 +00:00
return err
}
defer fd.decref()
2014-09-21 17:33:12 +00:00
return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP, boolint(v)))
2012-03-27 23:13:14 +00:00
}