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 C054B40C6E for ; Sun, 6 Feb 2022 02:09:48 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8D1C068B09B; Sun, 6 Feb 2022 04:09:45 +0200 (EET) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 12B9F68AFE9 for ; Sun, 6 Feb 2022 04:09:39 +0200 (EET) Received: by mail-pj1-f45.google.com with SMTP id oa14-20020a17090b1bce00b001b61aed4a03so9868714pjb.5 for ; Sat, 05 Feb 2022 18:09:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=SxEVXUDDPSlmg01JvaYMDQl17KBTylIpNFfQG2p9bgU=; b=NKFESUkXqpE0XW3aiFhEemkXRGIvqV1J7EXPrAb+Bgbxhidmo+R/ETVc++Y8HnOWDl YUmdf94WnpqRgGjtOJ7ZWCNuDKcjCelNvwUaegt24EIyN74+PTolfzOETf+AZBPQzx1y O4x3RUVLybQacaR2K/rLycjOFKk+rxBXyPMh6h/ZNUvQHLPoibPGnJBrrF1HbAdbhKli Ul3bd73GwLLi5VZkhfipZjACCAJ9/8zux7ojREl1fuxV7FWC+cVGOW9aIM5YUQf8wJUV CQR1HqQZngt4V1LxlZJ58EJo+5f1alRgALHCJEBR5Hz232E/NrnAz5ZxGlbhWVHXSeTD PP5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to; bh=SxEVXUDDPSlmg01JvaYMDQl17KBTylIpNFfQG2p9bgU=; b=0AEo/cBLPI4B52uztyykXmjwMsWiCCasTp1rzc1/0ON9Afd+2FaI67JsRaDGmLHYcC 0rOkAxwYNfAC+s5RBMILvl647w0owMHdimhHkQRDd7tx3d5kOY79HtJC1ieF3rpSdExz GN3kGnqJkeVO3CrloedLD92XfnDNRQVqpI3mrIHCZla3Du0ErcW8AC0k7dSPn9RIS94b mE8HzvLbkEX5yGnTOIGzD7AvlBp3gwUXLE0aCjs9QauflWAGZt8Z443a4UCirH25/1Z3 ElgR6txypkI3N1vW1Id3tJskmNgnY/Bvqq5J0EZBiWVlmQAb/EfXMvitpRq3mWZlSGYE UPrw== X-Gm-Message-State: AOAM532E57kxniCUSkxdHEOREHLTuWTHESxebi9WgqT/tJKndtSlMXbH Q/ZZ/WkUFg5mL+veCF+vHePsJomct/I= X-Google-Smtp-Source: ABdhPJy6h3OXXzU/tbPWu8UbEXIW71KemLxOpY2foBQAeMOGUWLSM0n2UNkq0YpkMjwCd7UahakDTg== X-Received: by 2002:a17:90b:1806:: with SMTP id lw6mr11234732pjb.82.1644113376813; Sat, 05 Feb 2022 18:09:36 -0800 (PST) Received: from gmail.com ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id s15sm7184060pfg.145.2022.02.05.18.09.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Feb 2022 18:09:36 -0800 (PST) Date: Sun, 6 Feb 2022 10:09:33 +0800 From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Message-ID: <20220206020933.GA29837@gmail.com> Mail-Followup-To: ffmpeg-devel@ffmpeg.org References: <1643260580-25792-1-git-send-email-lance.lmwang@gmail.com> <1644038899-15433-1-git-send-email-lance.lmwang@gmail.com> <1644038899-15433-2-git-send-email-lance.lmwang@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH v2 2/3] avformat/udp: Fix IP_MULTICAST_TTL for BSD compatibility 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sat, Feb 05, 2022 at 01:26:18PM -0800, Chad Fraleigh wrote: > Since any [valid] value over 255 is impossible in the IPv4 protocol (the TTL field is only 8-bits), it should always be capped at 255 (for consistency) or return an invalid value error (the one I would suggest). > zhilizhao have submit a patch to limit the range of ttl from option. Do you want to return an invalid error here still? > Despite VLC's reversed comment, using an int seems to be the exception to the rule (i.e. only linux and windows seem to use it [as-documented]), perhaps doing the unsigned char first and using the int as the fallback would be better? It's not really just a BSD thing, unless you also count LWIP and Solaris as BSD. Unless VLC's code history shows them doing it this way at one time and swapping it (but forgetting the comment) to fix a known bug? > I have blamed vlc code and sure the code doing it this way at one time(104938796a3). For the mismatch of code and comments, I prefer to code always as code were build and used by all kinds of system which vlc is supported already. As for use BSD, I prefer to count LWIP and Solaris into BSD category which using rule of byte. If you still prefer to add them into comments, I'm OK also. > > On 2/4/2022 9:28 PM, lance.lmwang@gmail.com wrote: > > From: Limin Wang > > > > Suggested by zhilizhao, vlc project has solved the compatibility by > > the same way, so I borrowed the comments from vlc project. > > > > Fix #ticket9449 > > > > Signed-off-by: Limin Wang > > --- > > libavformat/udp.c | 15 +++++++++++++-- > > 1 file changed, 13 insertions(+), 2 deletions(-) > > > > diff --git a/libavformat/udp.c b/libavformat/udp.c > > index 3dc79eb..34488d6 100644 > > --- a/libavformat/udp.c > > +++ b/libavformat/udp.c > > @@ -164,6 +164,10 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL, > > { > > int protocol, cmd; > > > > + /* There is some confusion in the world whether IP_MULTICAST_TTL > > + * takes a byte or an int as an argument. > > + * BSD seems to indicate byte so we are going with that and use > > + * int as a fallback to be safe */ > > switch (addr->sa_family) { > > #ifdef IP_MULTICAST_TTL > > case AF_INET: > > @@ -183,8 +187,15 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL, > > } > > > > if (setsockopt(sockfd, protocol, cmd, &mcastTTL, sizeof(mcastTTL)) < 0) { > > - ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt"); > > - return ff_neterrno(); > > + /* BSD compatibility */ > > + unsigned char ttl; > > + > > + ff_log_net_error(logctx, AV_LOG_DEBUG, "setsockopt"); > > + ttl = (unsigned char)(( mcastTTL > 255 ) ? 255 : mcastTTL); > > + if (setsockopt(sockfd, protocol, cmd, &ttl, sizeof(ttl)) < 0) { > > + ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt"); > > + return ff_neterrno(); > > + } > > } > > > > return 0; > _______________________________________________ > 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".