[FFmpeg-devel] [PATCH] Fix setsockopt IP_MULTICAST_TTL on OpenBSD
Brad Smith
brad at comstyle.com
Sun Jan 23 21:55:38 EET 2022
On 1/23/2022 6:57 AM, Michael Niedermayer wrote:
> On Wed, Jan 12, 2022 at 12:13:13AM -0500, 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
> this "ifdef __linux__" feels like the wrong thing to check, dont you agree ?
Not sure what you mean.
But as I said in one of my other posts..
"FreeBSD, NetBSD, OpenBSD, DragonFlyBSD, macOS, Solaris, AIX, IRIX,
HP-UX, QNX, Minix3 and a few
others define the ttl parameter to IP_MULTICAST_TTL as an unsigned char.
Linux has it as an integer."
I looked for various examples of IP_MULTICAST_TTL usage in whatever
projects I could find and most
of the examples I found used only unsigned char, with BIRD (routing
daemon) being one of few that
use an int for Linux and unsigned char for *BSD's. It does not have
support for any other OS's.
More information about the ffmpeg-devel
mailing list