From: lance.lmwang@gmail.com
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH] Fix setsockopt IP_MULTICAST_TTL on OpenBSD
Date: Thu, 27 Jan 2022 09:59:56 +0800
Message-ID: <20220127015956.GA14112@gmail.com> (raw)
In-Reply-To: <5b8ea94d-b731-7f48-d4b-a849bc2aac6d@passwd.hu>
On Wed, Jan 26, 2022 at 09:50:47PM +0100, Marton Balint wrote:
>
>
> On Wed, 26 Jan 2022, Brad Smith wrote:
>
> > On Wed, Jan 12, 2022 at 12:13:14AM -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.
> >
> > Based on feedback so far. Here is a much simpler approach to this issue..
>
> Win32 needs DWORD unfortunately. I missed it earlier, sorry.
>
> https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options
From my testing on Mac system, it support one byte only, but at least, it'll
report "Invalid argument" only if the ttl > 255. Maybe we can try with one byte
again if the errno is invalid like below. I tested it with ttl > 255 on Mac system
and without "Invalid argument" anymore.
#ifdef IP_MULTICAST_TTL
+ int ret = 0;
if (addr->sa_family == AF_INET) {
- if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, sizeof(mcastTTL)) < 0) {
+ ret = setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, sizeof(mcastTTL));
+ /* try with byte also for IP_MULTICAST_TTL for some system like OpenBSD */
+ if (ret < 0 && errno == EINVAL) {
+ unsigned char ttl = mcastTTL;
+ ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL): ");
+ ret = setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl));
+ }
+ if (ret < 0) {
ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL)");
return ff_neterrno();
>
> Regards,
> Marton
>
> >
> >
> > diff --git a/libavformat/udp.c b/libavformat/udp.c
> > index 83c042d079..da1b98890b 100644
> > --- a/libavformat/udp.c
> > +++ b/libavformat/udp.c
> > @@ -164,7 +164,9 @@ 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) {
> > + unsigned char ttl = mcastTTL; /* ignore the outdated Linux documentation */
> > +
> > + if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0) {
> > ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL)");
> > return ff_neterrno();
> > }
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> >
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
--
Thanks,
Limin Wang
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-01-27 2:00 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-12 5:13 Brad Smith
2022-01-23 5:25 ` Brad Smith
2022-01-23 11:57 ` Michael Niedermayer
2022-01-23 14:12 ` Marton Balint
2022-01-23 19:55 ` Brad Smith
2022-01-24 12:40 ` Michael Niedermayer
2022-01-25 5:28 ` Brad Smith
2022-01-25 7:25 ` lance.lmwang
2022-01-26 0:28 ` Chad Fraleigh
2022-01-26 1:10 ` Brad Smith
2022-01-26 1:23 ` lance.lmwang
2022-01-26 15:36 ` Brad Smith
2022-01-26 20:50 ` Marton Balint
2022-01-27 1:24 ` Chad Fraleigh
2022-01-27 1:59 ` lance.lmwang [this message]
2022-01-27 2:27 ` "zhilizhao(赵志立)"
2022-01-27 2:30 ` "zhilizhao(赵志立)"
2022-01-27 3:26 ` lance.lmwang
2022-01-27 5:16 ` [FFmpeg-devel] [PATCH] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility lance.lmwang
2022-02-05 5:28 ` [FFmpeg-devel] [PATCH v2 1/3] avformat/udp: use one setsockopt for ipv4/ipv6 lance.lmwang
2022-02-05 5:28 ` [FFmpeg-devel] [PATCH v2 2/3] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility lance.lmwang
2022-02-05 9:59 ` Marton Balint
2022-02-05 12:06 ` lance.lmwang
2022-02-05 21:26 ` Chad Fraleigh
2022-02-06 2:09 ` lance.lmwang
2022-02-06 22:15 ` Marton Balint
2022-02-06 22:27 ` Chad Fraleigh
2022-02-07 0:01 ` lance.lmwang
2022-02-05 5:28 ` [FFmpeg-devel] [PATCH v2 3/3] avformat/udp: remove IPPROTO_IPV6 macro lance.lmwang
2022-02-05 9:58 ` [FFmpeg-devel] [PATCH v2 1/3] avformat/udp: use one setsockopt for ipv4/ipv6 Marton Balint
2022-02-05 12:10 ` lance.lmwang
2022-02-05 12:31 ` [FFmpeg-devel] [PATCH v3 " lance.lmwang
2022-02-05 12:31 ` [FFmpeg-devel] [PATCH v3 2/3] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility lance.lmwang
2022-02-11 21:05 ` Marton Balint
2022-02-12 0:39 ` lance.lmwang
2022-02-05 12:31 ` [FFmpeg-devel] [PATCH v3 3/3] avformat/udp: remove IPPROTO_IPV6 macro lance.lmwang
2022-02-10 23:56 ` [FFmpeg-devel] [PATCH v3 1/3] avformat/udp: use one setsockopt for ipv4/ipv6 lance.lmwang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220127015956.GA14112@gmail.com \
--to=lance.lmwang@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git