+#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#define SO_MAX_PACING_RATE 47
#endif
-UDPStream::UDPStream(const sockaddr_in6 &dst, uint32_t pacing_rate, int ttl)
+UDPStream::UDPStream(const sockaddr_in6 &dst, uint32_t pacing_rate, int ttl, int multicast_iface_index)
: dst(dst)
{
sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
log_perror("setsockopt(IPV6_MULTICAST_HOPS)");
}
}
+
+ if (multicast_iface_index != -1) {
+ ip_mreqn mr;
+ memset(&mr, 0, sizeof(mr));
+ mr.imr_ifindex = multicast_iface_index;
+ if (setsockopt(sock, IPPROTO_IP, IP_MULTICAST_IF, &mr, sizeof(mr)) == -1) {
+ log_perror("setsockopt(IP_MULTICAST_IF)");
+ }
+ if (setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_IF, &multicast_iface_index, sizeof(multicast_iface_index)) == -1) {
+ log_perror("setsockopt(IPV6_MULTICAST_IF)");
+ }
+ }
}
UDPStream::~UDPStream()