gcc:
[official-gcc.git] / libgo / go / net / sockoptip_windows.go
blob7b11f207aaf3b83df0dbb29cebd53ca6263442e9
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.
5 package net
7 import (
8 "os"
9 "syscall"
10 "unsafe"
13 func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error {
14 ip, err := interfaceToIPv4Addr(ifi)
15 if err != nil {
16 return os.NewSyscallError("setsockopt", err)
18 var a [4]byte
19 copy(a[:], ip.To4())
20 if err := fd.incref(); err != nil {
21 return err
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))
27 func setIPv4MulticastLoopback(fd *netFD, v bool) error {
28 if err := fd.incref(); err != nil {
29 return err
31 defer fd.decref()
32 return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP, boolint(v)))