From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from orbyte.nwl.cc (orbyte.nwl.cc [151.80.46.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 602D8482CB for ; Wed, 20 Dec 2023 16:06:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nwl.cc Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nwl.cc Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nwl.cc header.i=@nwl.cc header.b="aXpaX0kG" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nwl.cc; s=mail2022; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=FuMlcvhfpwLq3DTD1TvMxPiZLDqGk0kn5qjhuTGPDB4=; b=aXpaX0kGKf5MWUnZMtEIR81Xdf eoyCqU8ve72yFXr+dK8UG0TwYJPLLzmSMVIMhDVFo66+K85YiGiDZGvzGHhOlg6gbjcZ5AM07Uoyh JfUdwUcp7xV7voW/C2oKuOKay5QdV1aPqoHOT7CRupqwWqs+e4wSm+ZiyFyLjrGJzK66LIorAOIgs wghxbkhr62OshVS828bt804dWuiemfU1K0nD6w6UT47zqqjp4zCR39m9oOsZetRkbDgaZY8WeWaOZ IWKuQnWH6h7tZF6sF8wyDDs81rd1udIDx6VxzzWhdbpuGpcaCNM/7Nratn8ReAsr+EoUQX4d2e9r8 GzhCjSTw==; Received: from localhost ([::1] helo=xic) by orbyte.nwl.cc with esmtp (Exim 4.94.2) (envelope-from ) id 1rFz5k-0004KA-BA for netfilter-devel@vger.kernel.org; Wed, 20 Dec 2023 17:06:40 +0100 From: Phil Sutter To: netfilter-devel@vger.kernel.org Subject: [iptables PATCH 13/23] extensions: libebt_mark: Use guided option parser Date: Wed, 20 Dec 2023 17:06:26 +0100 Message-ID: <20231220160636.11778-14-phil@nwl.cc> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231220160636.11778-1-phil@nwl.cc> References: <20231220160636.11778-1-phil@nwl.cc> Precedence: bulk X-Mailing-List: netfilter-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Signed-off-by: Phil Sutter --- extensions/libebt_mark.c | 140 +++++++++++++++------------------------ 1 file changed, 54 insertions(+), 86 deletions(-) diff --git a/extensions/libebt_mark.c b/extensions/libebt_mark.c index 40e49618e0215..0dc598fe1009d 100644 --- a/extensions/libebt_mark.c +++ b/extensions/libebt_mark.c @@ -12,27 +12,39 @@ #include #include #include -#include #include #include #include "iptables/nft.h" #include "iptables/nft-bridge.h" -#define MARK_TARGET '1' -#define MARK_SETMARK '2' -#define MARK_ORMARK '3' -#define MARK_ANDMARK '4' -#define MARK_XORMARK '5' -static const struct option brmark_opts[] = { - { .name = "mark-target",.has_arg = true, .val = MARK_TARGET }, +enum { + O_SET_MARK = 0, + O_AND_MARK, + O_OR_MARK, + O_XOR_MARK, + O_MARK_TARGET, + F_SET_MARK = 1 << O_SET_MARK, + F_AND_MARK = 1 << O_AND_MARK, + F_OR_MARK = 1 << O_OR_MARK, + F_XOR_MARK = 1 << O_XOR_MARK, + F_ANY = F_SET_MARK | F_AND_MARK | F_OR_MARK | F_XOR_MARK, +}; + +static const struct xt_option_entry brmark_opts[] = { + { .name = "mark-target",.id = O_MARK_TARGET, .type = XTTYPE_STRING }, /* an oldtime messup, we should have always used the scheme * -