Retro68/gcc/libgo/go/net/sockoptip_windows.go

34 lines
910 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"
2014-09-21 17:33:12 +00:00
"unsafe"
2012-03-27 23:13:14 +00:00
)
func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error {
ip, err := interfaceToIPv4Addr(ifi)
if err != nil {
return os.NewSyscallError("setsockopt", err)
}
2014-09-21 17:33:12 +00:00
var a [4]byte
copy(a[:], ip.To4())
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.Setsockopt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, (*byte)(unsafe.Pointer(&a[0])), 4))
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
}