func leaveIPv4Group(fd int, ifi *net.Interface, grp net.IP) error {
	mreqn := syscall.IPMreqn{Multiaddr: [4]byte{grp[0], grp[1], grp[2], grp[3]}}
	if ifi != nil {
		mreqn.Ifindex = int32(ifi.Index)
	}
	return os.NewSyscallError("setsockopt", syscall.SetsockoptIPMreqn(fd, ianaProtocolIP, sysSockoptLeaveGroup, &mreqn))
}
func setIPv4MulticastInterface(fd int, ifi *net.Interface) error {
	var mreqn syscall.IPMreqn
	if ifi != nil {
		mreqn.Ifindex = int32(ifi.Index)
	}
	return os.NewSyscallError("setsockopt", syscall.SetsockoptIPMreqn(fd, ianaProtocolIP, sysSockoptMulticastInterface, &mreqn))
}
Exemple #3
0
func setIPv4MulticastInterface(fd int, ifi *net.Interface) error {
	mreqn := syscall.IPMreqn{}
	if ifi != nil {
		mreqn.Ifindex = int32(ifi.Index)
	}
	return os.NewSyscallError("setsockopt", syscall.SetsockoptIPMreqn(fd, ianaProtocolIP, syscall.IP_MULTICAST_IF, &mreqn))
}
Exemple #4
0
func joinIPv4Group(fd int, ifi *net.Interface, grp net.IP) error {
	mreqn := &syscall.IPMreqn{Multiaddr: [4]byte{grp[0], grp[1], grp[2], grp[3]}}
	if ifi != nil {
		mreqn.Ifindex = int32(ifi.Index)
	}
	err := syscall.SetsockoptIPMreqn(fd, syscall.IPPROTO_IP, syscall.IP_ADD_MEMBERSHIP, mreqn)
	if err != nil {
		return os.NewSyscallError("setsockopt", err)
	}
	return nil
}
Exemple #5
0
func setIPv4MulticastInterface(fd int, ifi *net.Interface) error {
	mreqn := &syscall.IPMreqn{}
	if ifi != nil {
		mreqn.Ifindex = int32(ifi.Index)
	}
	err := syscall.SetsockoptIPMreqn(fd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, mreqn)
	if err != nil {
		return os.NewSyscallError("setsockopt", err)
	}
	return nil
}
Exemple #6
0
func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error {
	var v int32
	if ifi != nil {
		v = int32(ifi.Index)
	}
	mreq := &syscall.IPMreqn{Ifindex: v}
	if err := fd.incref(); err != nil {
		return err
	}
	defer fd.decref()
	return os.NewSyscallError("setsockopt", syscall.SetsockoptIPMreqn(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, mreq))
}