From nobody Tue May 24 20:59:50 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 53CA91B4F66B; Tue, 24 May 2022 20:59:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L765g4ZGCz4jdj; Tue, 24 May 2022 20:59:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653425991; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=04SPmTnsBMie9GevudjUKkKlLvmUMmDZQmAk8aFDGG8=; b=uhbGVFn9t3abLYXMZWQUzP1bzKCxFrtBcYUKt7HfBbDPX/wGWxLJJdqZoK5bcR52dKhLqO PCbqx7kMiTU04vgIbHSmf9clGdNFS/zZDx2SlxzXUq6My9XbVj7M7PCN9hkbtkYBcUszjW piaarhC9FveCLRE1eMFZ2f02VW7ywurh68m4ViPGk9EyRi0l46DDbLIrZWdZLMWa+rD0Sy ICU7Ri8YMd8CubK78uOkKKgOSZinfIo3e3zetYyu3rPt5Y1psZBeYiy0iAOmGKw+Ceqf2s 3zZtl7WxnatuZFWj/hPS/D8/PRRuKTM9HMEfznBnpiDHY0YIMqC8ZReRcfSRrw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 154543B3B; Tue, 24 May 2022 20:59:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24OKxoTa036705; Tue, 24 May 2022 20:59:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24OKxooJ036704; Tue, 24 May 2022 20:59:50 GMT (envelope-from git) Date: Tue, 24 May 2022 20:59:50 GMT Message-Id: <202205242059.24OKxooJ036704@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 42d5cb0927f8 - main - ifconfig: add glue for specifying functions taking static string parameter List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 42d5cb0927f8a2ef0be2dc0630d5520555131c95 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653425991; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=04SPmTnsBMie9GevudjUKkKlLvmUMmDZQmAk8aFDGG8=; b=LF5coCPtn9XiofviwdjSxInVYXpdYogmVPJH2xOSEueHYuI/QGYeM5EBFLNTfCRWvW+No6 zCGEnYNKqHxGC++kK7KQtB+eIa/GT2mFbPnjIkxkin7q8CAp61jaBjBacaPyDQMcCI9trj 4Rr+X57FcUViYo0Azyyz0+TMlGehGBJETmh/zvSg6oC5dGAUKIcPIH+EvKoap0iKl5KZ/2 PzCYZt4SOIYMpfbPcjy4+1j6yD6JHxAQD1CzhkldwC6pfQ5Tk+DT5nmzPbATPViV4UDaBf UZANRItOGWFoTgrQ8flo4Vq9F0tViYJZHaJ2aJZsp1+++W8F/zCG0yYATnwnKw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653425991; a=rsa-sha256; cv=none; b=pmPA5mW5q0gvyFUO06KSghOeOPd//SuBYNAqpBbCmnlXjhMNTMYYeWqXUc1Fa6dGRLC/a4 U8QQCorq510hW5fpJccutcOnnoAjVXFyl87jZSQdq43JpMbuDFWUsi9p9x1IxevY6DjBWg Wjys/4d/3n2lOENFOSO15QpBuAjGYUqIQelITOCFHbxoDcOU/GlE8N+CaCnzWeOClM7p/j aDd3d2JK7ukxxULKvzTNjDPgBtZkv9Oaf7hJ33QYpCPbCUIie9QcNHNuzY56jQE3y4DwL6 xlBuJFTqyRjuqNsyIH3LVdensPnC1Zpfcv1V43bDFq4JLbFPudQH8H/+Z0XBBQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=42d5cb0927f8a2ef0be2dc0630d5520555131c95 commit 42d5cb0927f8a2ef0be2dc0630d5520555131c95 Author: Konstantin Belousov AuthorDate: 2021-12-15 03:04:35 +0000 Commit: Konstantin Belousov CommitDate: 2022-05-24 20:59:33 +0000 ifconfig: add glue for specifying functions taking static string parameter Reviewed by: hselasky, jhb, kp Sponsored by: NVIDIA Networking MFC after: 3 weeks Differential revision: https://reviews.freebsd.org/D32551 --- sbin/ifconfig/ifconfig.c | 2 ++ sbin/ifconfig/ifconfig.h | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 9e7d38d4c2a4..37ce0fb18943 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -991,6 +991,8 @@ top: p->c_name); p->c_u.c_func2(argv[1], argv[2], s, afp); argc -= 2, argv += 2; + } else if (p->c_parameter == SPARAM && p->c_u.c_func3) { + p->c_u.c_func3(*argv, p->c_sparameter, s, afp); } else if (p->c_u.c_func) p->c_u.c_func(*argv, p->c_parameter, s, afp); argc--, argv++; diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h index 76f6ef926a5c..4a9fb380fbab 100644 --- a/sbin/ifconfig/ifconfig.h +++ b/sbin/ifconfig/ifconfig.h @@ -48,6 +48,8 @@ struct cmd; typedef void c_func(const char *cmd, int arg, int s, const struct afswtch *afp); typedef void c_func2(const char *arg1, const char *arg2, int s, const struct afswtch *afp); +typedef void c_func3(const char *cmd, const char *arg, int s, + const struct afswtch *afp); struct cmd { const char *c_name; @@ -55,9 +57,12 @@ struct cmd { #define NEXTARG 0xffffff /* has following arg */ #define NEXTARG2 0xfffffe /* has 2 following args */ #define OPTARG 0xfffffd /* has optional following arg */ +#define SPARAM 0xfffffc /* parameter is string c_sparameter */ + const char *c_sparameter; union { c_func *c_func; c_func2 *c_func2; + c_func3 *c_func3; } c_u; int c_iscloneop; struct cmd *c_next; @@ -81,7 +86,7 @@ void callback_register(callback_func *, void *); .c_parameter = (param), \ .c_u = { .c_func = (func) }, \ .c_iscloneop = 0, \ - .c_next = NULL, + .c_next = NULL, \ } #define DEF_CMD_ARG(name, func) { \ .c_name = (name), \ @@ -104,6 +109,14 @@ void callback_register(callback_func *, void *); .c_iscloneop = 0, \ .c_next = NULL, \ } +#define DEF_CMD_SARG(name, sparam, func) { \ + .c_name = (name), \ + .c_parameter = SPARAM, \ + .c_sparameter = (sparam), \ + .c_u = { .c_func3 = (func) }, \ + .c_iscloneop = 0, \ + .c_next = NULL, \ +} #define DEF_CLONE_CMD(name, param, func) { \ .c_name = (name), \ .c_parameter = (param), \