func joinIPv6Group(fd int, ifi *net.Interface, grp net.IP) error { mreq := syscall.IPv6Mreq{} copy(mreq.Multiaddr[:], grp) if ifi != nil { mreq.Interface = uint32(ifi.Index) } return os.NewSyscallError("setsockopt", syscall.SetsockoptIPv6Mreq(fd, ianaProtocolIPv6, syscall.IPV6_JOIN_GROUP, &mreq)) }
func leaveIPv6Group(fd *netFD, ifi *Interface, ip IP) error { mreq := &syscall.IPv6Mreq{} copy(mreq.Multiaddr[:], ip) if ifi != nil { mreq.Interface = uint32(ifi.Index) } fd.incref() defer fd.decref() return os.NewSyscallError("setsockopt", syscall.SetsockoptIPv6Mreq(fd.sysfd, syscall.IPPROTO_IPV6, syscall.IPV6_LEAVE_GROUP, mreq)) }
func leaveIPv6GroupUDP(c *UDPConn, ifi *Interface, ip IP) error { mreq := &syscall.IPv6Mreq{} copy(mreq.Multiaddr[:], ip) if ifi != nil { mreq.Interface = uint32(ifi.Index) } if err := os.NewSyscallError("setsockopt", syscall.SetsockoptIPv6Mreq(c.fd.sysfd, syscall.IPPROTO_IPV6, syscall.IPV6_LEAVE_GROUP, mreq)); err != nil { return &OpError{"leaveipv6group", "udp", &IPAddr{ip}, err} } return nil }
func joinIPv6Group(fd *netFD, ifi *Interface, ip IP) error { mreq := &syscall.IPv6Mreq{} copy(mreq.Multiaddr[:], ip) if ifi != nil { mreq.Interface = uint32(ifi.Index) } if err := fd.incref(false); err != nil { return err } defer fd.decref() return os.NewSyscallError("setsockopt", syscall.SetsockoptIPv6Mreq(fd.sysfd, syscall.IPPROTO_IPV6, syscall.IPV6_JOIN_GROUP, mreq)) }
// JoinMulticastIPv6 joins the multicast group address given by gaddr. laddr specifies which // network interface to use when joining the group. func JoinMulticastIPv6(c *net.IPConn, gaddr, laddr net.IP) error { f, err := c.File() if err != nil { return err } defer f.Close() mreq := &syscall.IPv6Mreq{} copy(mreq.Multiaddr[:], gaddr.To16()) iface, err := findInterface(laddr) if err != nil { return err } mreq.Interface = uint32(iface.Index) err = syscall.SetsockoptIPv6Mreq(int(f.Fd()), syscall.IPPROTO_IPV6, syscall.IPV6_JOIN_GROUP, mreq) if err != nil { return err } return nil }