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 5D95C40C52 for ; Sat, 5 Feb 2022 21:26:30 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 180D868B025; Sat, 5 Feb 2022 23:26:28 +0200 (EET) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CFE816800EA for ; Sat, 5 Feb 2022 23:26:20 +0200 (EET) Received: by mail-pj1-f54.google.com with SMTP id s2-20020a17090ad48200b001b501977b23so16458687pju.2 for ; Sat, 05 Feb 2022 13:26:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=triularity-org.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=QJEZlhpDBS3AOQfvzEa2CBOn50DYVsVcXIqrSLQn84A=; b=qfiOhg85Wi2hXa0zm0mPuV6B4XoMBXaW5ME7Dw/0Qn6vDG39+hxoOKptcEasltbg+e fOdRrPpe9RQ3x09zNcQ6NG9Ti/mx+ECNmvafxEUgy3goqZLo5SyKBx7CuQ5xVfuRKeo3 xYgw07+9DO9rVuQPauAwf0YR1fe+fZ2sbf1dq6eZL2dBqjpiCNqiLPXw/7OqEOZX9jv9 f5/ixoX5ZamZh1D6zGg7nwBOnoEFf3aA58wZRzMnpQT4ut7xLt1Hg6R7LM1oqFkUdxMJ 5fVY3uMLw9ggiEfLCDPOfy0jlGaVUqooOX0FMIak1T/tO1dcLtZg44pqC9yeoKyz2SVW mCnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=QJEZlhpDBS3AOQfvzEa2CBOn50DYVsVcXIqrSLQn84A=; b=43ytER9ef5SN7lTdKfR9vP128zplkMisKTL/Av3XzgkPfYkVb3SDCKcbJ8qdkf3eZ6 mzogLfdzRI4hWr4McWeRAbPq1W2O/SHg6eXfGEjMAADZn5HBeFZfQSmbU+UZeslUcjLO oMFnBUhaW0UYSqxNeUbFErtCDWMrxyC2jSGWT+aJ+WpfsIxZ2h4U9yBep1CT32mmtJ2X aFpgqXRD46gmKd1YU2RZSpidKW+kRYpvrNDskX2uqK3ybXn1xogcs2IdzZQb4G5Gcrw8 Famh4mWs3t74eygiyTYmlJ3OHwktQkUbcuZP4XRZicCJGt/Gv4HqTasFFJSKIa5Lb9ql V7ng== X-Gm-Message-State: AOAM531mEjT/pU49pI02rFSpeY3JjV01VReo6EcigOF7YfDUjXWPO7jm J7LmywoV/j3Tel97uUCdP7MjR6yhxHlaPINrpWE= X-Google-Smtp-Source: ABdhPJyOZDlwrWpX6eCTWpF1GOH55BFc7Su5LjvO7L0oO7rpjs3xgpyRPuhEoE7pe5frGwo+qzqYbQ== X-Received: by 2002:a17:90a:d144:: with SMTP id t4mr10288042pjw.18.1644096378588; Sat, 05 Feb 2022 13:26:18 -0800 (PST) Received: from ?IPV6:2601:603:5000:f89:c045:dfaa:62:b16a? ([2601:603:5000:f89:c045:dfaa:62:b16a]) by smtp.gmail.com with ESMTPSA id d15sm6691520pfu.127.2022.02.05.13.26.17 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 05 Feb 2022 13:26:18 -0800 (PST) Message-ID: Date: Sat, 5 Feb 2022 13:26:18 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Content-Language: en-US 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> From: Chad Fraleigh In-Reply-To: <1644038899-15433-2-git-send-email-lance.lmwang@gmail.com> 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: 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). 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? 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".