From patchwork Sat Feb 5 12:31:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 34136 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp4245771iov; Sat, 5 Feb 2022 04:32:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyDPZgYzTjOyilXdaM1459WwDK9kgssoMZ7SAZOMQ5DWsbb4YXW3EpX0CwzAD7T2dNCLHU X-Received: by 2002:a50:baa8:: with SMTP id x37mr4211122ede.450.1644064334464; Sat, 05 Feb 2022 04:32:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644064334; cv=none; d=google.com; s=arc-20160816; b=gueS7aDQcQfS1Q01ZF6rekD3e87bI3sLWW4sU8DTdAIcEiz/Ixo0934PG96d+9ggFH nTkEK4ENasS6RgGKhB56EAizOcT5ar3CUgtIVFzIMU9kNOY/kfuOFmqkZOeq1W65Qmpr /Bwk0g357FFG3tjZuF79Em8wt2Qzbn0mtOXApjzwihsop7k1AQcb4iUOKzC/qYh9L8rr vd1qZ8QS3ailVLx5OWYc3XsnaBYHYLgmp6luwlN6mGtPIX7966Cxuf8uwbM/OiMv6Mod J1wPKqZn8noi4m1vILpAoCIUPWcVRBfrvWpIKW9ETlgljdpr0bWVjhxsatvK3NNPPYiy 7N6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=0JCSOO1bMly8ezMrpj7Iiph3gleVyeETGx6KIyiyMmg=; b=MZi1keVH3nJZLgPO7nzW0cWME/0FCT6mDRnD57EeMGBh8AvkihUgfjnDTPuRfvO6/e 635zpsZgS7hPtF8UiWEpydr/OYr+iY4a7/bNSd9DNVIXBjoRLDDKvacRc2mOOUiqdKPL nYb3lg4oOWvQAPdi3XlNgsOnZs7PBp0Hh6wIYok29Y15VIn1TLGZ2hut8yrpJfCQU0lc yvII4PXW6W+fVH+WTVuCYdqMLnbl47YaUFDSaaS64/oNt3uWL/MVSBGAm6e/7ICNiJ/k Br/XYDfE9xkiwpQcWh4RQo3HnZR5OHb55rmGmYnebFPJKMlZsOnbl5E/3u1if/s6aiQb hl0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=d4p4PwrN; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x12si3674010edd.246.2022.02.05.04.32.14; Sat, 05 Feb 2022 04:32:14 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=d4p4PwrN; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C033668B379; Sat, 5 Feb 2022 14:32:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B550468B225 for ; Sat, 5 Feb 2022 14:31:55 +0200 (EET) Received: by mail-pj1-f43.google.com with SMTP id v13-20020a17090ac90d00b001b87bc106bdso1647892pjt.4 for ; Sat, 05 Feb 2022 04:31:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L/3t8sgMzjOVSRsBT3/7gE8+AqQitUuTevkeMiEai7w=; b=d4p4PwrNlAvz78qmmlhJotXwGN2RNEicJwqzTCuxuIG1y4gH7TJiXn3YluC3PuibZZ /E8an6znqUvo385N9luNo5ov+wgyRxWNo8PvPa5qm/8wcBButCN9fFQzZCqy9s/IUfsX qvk7SfoJhg1T1J2483I4grfvmufd5OAMU4eRSOx6iBScC/OsnQ7hJO1Q2yGihrMzm2zH fIKUKzl9B4q/Av092k7PjyuC0eQwdZuCxkDPuaNpJ9MulCLqjXKoaBp7N8RSDXOJVpkm d7QkQzyreeA+w3JMX7FzrpMwlCwf3xwffdvEtD1wQvostoGLBcLBeiT88k4XZEgivoTZ +nMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=L/3t8sgMzjOVSRsBT3/7gE8+AqQitUuTevkeMiEai7w=; b=glJqG8WbG6p82Gab6ZTodxg1tPHidgE2bc5JPo2hj3SirheGzguQ/u3Y8dOGpO0gTy /BR8wQksQgxFws1KMtdKscxGarfO8nC+ogTASM1iRawoiWZRnRJxvjp2IN+I4XNIGW3i iOAtKndTYuUYNRRrwnRRxyBEK4Reo8KbeI2XoQrRz8vm2r775lyfcxviCmXyh3Xyyd/8 GdNVsIIh7BNAcbWAQ5E2LP7I3KhjBW85DIhx8Jd+iGWAyTDzPXo/cvFw5ISkdFb8zmOp 7Sjwh53eDIwV1rEitigGC4ZPS6ahnHoso0wMk1fEKLwHmO5IjRm7v1eI6nZuNBAJyYH+ IlZw== X-Gm-Message-State: AOAM532Pq4bBZswugvcqK+ksNDRRdEJcnhzrJoD1gTrpG8K50d1GM65H 0ik6LhtwYpyn2pGHshFw9HPX6/8coLc= X-Received: by 2002:a17:902:7603:: with SMTP id k3mr8333444pll.160.1644064314042; Sat, 05 Feb 2022 04:31:54 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id y27sm3986736pga.22.2022.02.05.04.31.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Feb 2022 04:31:53 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Feb 2022 20:31:47 +0800 Message-Id: <1644064308-21729-2-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1644064308-21729-1-git-send-email-lance.lmwang@gmail.com> References: <1643260580-25792-1-git-send-email-lance.lmwang@gmail.com> <1644064308-21729-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v3 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 Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: J8xYOgh60xUG 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 8178d0e..1871acf 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 and fall back to byte to be safe */ switch (addr->sa_family) { #ifdef IP_MULTICAST_TTL case AF_INET: @@ -182,8 +186,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(IPV4/IPV6 MULTICAST TTL)"); - return ff_neterrno(); + /* BSD compatibility */ + unsigned char ttl; + + ff_log_net_error(logctx, AV_LOG_DEBUG, "setsockopt(IPV4/IPV6 MULTICAST TTL)"); + 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(IPV4/IPV6 MULTICAST TTL)"); + return ff_neterrno(); + } } return 0;