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 // +build aix darwin dragonfly freebsd linux netbsd openbsd windows
14 func joinIPv4Group(fd
*netFD
, ifi
*Interface
, ip IP
) error
{
15 mreq
:= &syscall
.IPMreq
{Multiaddr
: [4]byte{ip
[0], ip
[1], ip
[2], ip
[3]}}
16 if err
:= setIPv4MreqToInterface(mreq
, ifi
); err
!= nil {
19 err
:= fd
.pfd
.SetsockoptIPMreq(syscall
.IPPROTO_IP
, syscall
.IP_ADD_MEMBERSHIP
, mreq
)
21 return wrapSyscallError("setsockopt", err
)
24 func setIPv6MulticastInterface(fd
*netFD
, ifi
*Interface
) error
{
29 err
:= fd
.pfd
.SetsockoptInt(syscall
.IPPROTO_IPV6
, syscall
.IPV6_MULTICAST_IF
, v
)
31 return wrapSyscallError("setsockopt", err
)
34 func setIPv6MulticastLoopback(fd
*netFD
, v
bool) error
{
35 err
:= fd
.pfd
.SetsockoptInt(syscall
.IPPROTO_IPV6
, syscall
.IPV6_MULTICAST_LOOP
, boolint(v
))
37 return wrapSyscallError("setsockopt", err
)
40 func joinIPv6Group(fd
*netFD
, ifi
*Interface
, ip IP
) error
{
41 mreq
:= &syscall
.IPv6Mreq
{}
42 copy(mreq
.Multiaddr
[:], ip
)
44 mreq
.Interface
= uint32(ifi
.Index
)
46 err
:= fd
.pfd
.SetsockoptIPv6Mreq(syscall
.IPPROTO_IPV6
, syscall
.IPV6_JOIN_GROUP
, mreq
)
48 return wrapSyscallError("setsockopt", err
)