+ if(multicast_group) {
+ if((n = getaddrinfo(multicast_group, 0, &prefs, &res)))
+ fatal(0, "getaddrinfo %s: %s", multicast_group, gai_strerror(n));
+ switch(res->ai_family) {
+ case PF_INET:
+ mreq.imr_multiaddr = ((struct sockaddr_in *)res->ai_addr)->sin_addr;
+ mreq.imr_interface.s_addr = 0; /* use primary interface */
+ if(setsockopt(rtpfd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
+ &mreq, sizeof mreq) < 0)
+ fatal(errno, "error calling setsockopt IP_ADD_MEMBERSHIP");
+ break;
+ case PF_INET6:
+ mreq6.ipv6mr_multiaddr = ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
+ memset(&mreq6.ipv6mr_interface, 0, sizeof mreq6.ipv6mr_interface);
+ if(setsockopt(rtpfd, IPPROTO_IPV6, IPV6_JOIN_GROUP,
+ &mreq6, sizeof mreq6) < 0)
+ fatal(errno, "error calling setsockopt IPV6_JOIN_GROUP");
+ break;
+ default:
+ fatal(0, "unsupported address family %d", res->ai_family);
+ }
+ }
+ len = sizeof rcvbuf;
+ if(getsockopt(rtpfd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, &len) < 0)
+ fatal(errno, "error calling getsockopt SO_RCVBUF");
+ if(target_rcvbuf > rcvbuf) {
+ if(setsockopt(rtpfd, SOL_SOCKET, SO_RCVBUF,
+ &target_rcvbuf, sizeof target_rcvbuf) < 0)
+ error(errno, "error calling setsockopt SO_RCVBUF %d",
+ target_rcvbuf);
+ /* We try to carry on anyway */
+ else
+ info("changed socket receive buffer from %d to %d",
+ rcvbuf, target_rcvbuf);
+ } else
+ info("default socket receive buffer %d", rcvbuf);
+ if(logfp)
+ info("WARNING: -L option can impact performance");