From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id EBFC240C07 for ; Sat, 5 Feb 2022 09:58:20 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BEFDE68B35E; Sat, 5 Feb 2022 11:58:17 +0200 (EET) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7668A68B1B6 for ; Sat, 5 Feb 2022 11:58:11 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 1E128E64E2 for ; Sat, 5 Feb 2022 10:58:11 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Pn24Q21zJCZN for ; Sat, 5 Feb 2022 10:58:08 +0100 (CET) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id 929CCE628A for ; Sat, 5 Feb 2022 10:58:08 +0100 (CET) Date: Sat, 5 Feb 2022 10:58:08 +0100 (CET) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <1644038899-15433-1-git-send-email-lance.lmwang@gmail.com> Message-ID: <2283a4d0-13ce-e7f6-7dce-9bef53a76280@passwd.hu> References: <1643260580-25792-1-git-send-email-lance.lmwang@gmail.com> <1644038899-15433-1-git-send-email-lance.lmwang@gmail.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v2 1/3] avformat/udp: use one setsockopt for ipv4/ipv6 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sat, 5 Feb 2022, lance.lmwang@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavformat/udp.c | 31 ++++++++++++++++++++----------- > 1 file changed, 20 insertions(+), 11 deletions(-) > > diff --git a/libavformat/udp.c b/libavformat/udp.c > index 83c042d..3dc79eb 100644 > --- a/libavformat/udp.c > +++ b/libavformat/udp.c > @@ -162,22 +162,31 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL, > struct sockaddr *addr, > void *logctx) > { > + int protocol, cmd; > + > + switch (addr->sa_family) { > #ifdef IP_MULTICAST_TTL > - if (addr->sa_family == AF_INET) { > - if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, sizeof(mcastTTL)) < 0) { > - ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL)"); > - return ff_neterrno(); > - } > - } > + case AF_INET: > + protocol = IPPROTO_IP; > + cmd = IP_MULTICAST_TTL; > + break; > #endif > #if defined(IPPROTO_IPV6) && defined(IPV6_MULTICAST_HOPS) > - if (addr->sa_family == AF_INET6) { > - if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &mcastTTL, sizeof(mcastTTL)) < 0) { > - ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV6_MULTICAST_HOPS)"); > + case AF_INET6: > + protocol = IPPROTO_IPV6; > + cmd = IPV6_MULTICAST_HOPS; > + break; > +#endif > + default: > + errno = EAFNOSUPPORT; This is not portable, ff_neterrno is different for winsock. Maybe you should simply remove the default case, to make it work like the old code, and not mix behaviour changes with factorization. > return ff_neterrno(); > - } > } > -#endif > + > + if (setsockopt(sockfd, protocol, cmd, &mcastTTL, sizeof(mcastTTL)) < 0) { > + ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt"); "setsockopt(IPV4/IPV6 MULTICAST TTL)", so we know that the issue was with TTL setting? Thanks, Marton _______________________________________________ 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".