[FFmpeg-devel] [PATCH] Fix setsockopt IP_MULTICAST_TTL on OpenBSD

Brad Smith brad at comstyle.com
Sun Jan 23 07:25:12 EET 2022


ping.

On 1/12/2022 12:13 AM, Brad Smith wrote:
> Fix setsockopt() usage on OpenBSD with IP_MULTICAST_TTL. The field
> type should be an unsigned char on anything but Linux.
>
>
> diff --git a/libavformat/udp.c b/libavformat/udp.c
> index 180d96a988..29aa865fff 100644
> --- a/libavformat/udp.c
> +++ b/libavformat/udp.c
> @@ -163,7 +163,13 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
>   {
>   #ifdef IP_MULTICAST_TTL
>       if (addr->sa_family == AF_INET) {
> -        if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, sizeof(mcastTTL)) < 0) {
> +#ifdef __linux__
> +        int ttl = mcastTTL;
> +#else
> +        unsigned char ttl = mcastTTL;
> +#endif
> +
> +        if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0) {
>               ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL)");
>               return ff_neterrno();
>           }


More information about the ffmpeg-devel mailing list