git: ac91312f28a9 - stable/14 - Move print_bits to ifconfig.c and make available to other src files.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 27 Sep 2025 15:14:15 UTC
The branch stable/14 has been updated by zlei:
URL: https://cgit.FreeBSD.org/src/commit/?id=ac91312f28a93e9d1d2a21ddbde76d6920ce8ddc
commit ac91312f28a93e9d1d2a21ddbde76d6920ce8ddc
Author: Gordon Tetlow <gordon@FreeBSD.org>
AuthorDate: 2024-05-31 17:48:10 +0000
Commit: Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2025-09-27 15:11:40 +0000
Move print_bits to ifconfig.c and make available to other src files.
Reviewed by: emaste
Event: Kitchener-Waterloo Hackathon 202406
Differential Revision: https://reviews.freebsd.org/D45441
(cherry picked from commit c3e9423743d91ae5b5865602a905900a1855055e)
---
sbin/ifconfig/ifconfig.c | 23 +++++++++++++++++++++++
sbin/ifconfig/ifconfig.h | 2 ++
sbin/ifconfig/ifconfig_netlink.c | 23 -----------------------
3 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 2449d6ca484e..3f3569efbe66 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1887,6 +1887,29 @@ Perror(const char *cmd)
Perrorc(cmd, errno);
}
+void
+print_bits(const char *btype, uint32_t *v, const int v_count,
+ const char **names, const int n_count)
+{
+ int num = 0;
+
+ for (int i = 0; i < v_count * 32; i++) {
+ bool is_set = v[i / 32] & (1U << (i % 32));
+ if (is_set) {
+ if (num++ == 0)
+ printf("<");
+ if (num != 1)
+ printf(",");
+ if (i < n_count)
+ printf("%s", names[i]);
+ else
+ printf("%s_%d", btype, i);
+ }
+ }
+ if (num > 0)
+ printf(">");
+}
+
/*
* Print a value a la the %b format of the kernel's printf
*/
diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h
index 264e7b82a40e..1ea6c29e4ddb 100644
--- a/sbin/ifconfig/ifconfig.h
+++ b/sbin/ifconfig/ifconfig.h
@@ -268,6 +268,8 @@ void setifcap(if_ctx *ctx, const char *, int value);
void setifcapnv(if_ctx *ctx, const char *vname, const char *arg);
void Perror(const char *cmd);
+void print_bits(const char *btype, uint32_t *v, const int v_count,
+ const char **names, const int n_count);
void printb(const char *s, unsigned value, const char *bits);
void ifmaybeload(struct ifconfig_args *args, const char *name);
diff --git a/sbin/ifconfig/ifconfig_netlink.c b/sbin/ifconfig/ifconfig_netlink.c
index 11b3595dafe6..0ec63e3a0b99 100644
--- a/sbin/ifconfig/ifconfig_netlink.c
+++ b/sbin/ifconfig/ifconfig_netlink.c
@@ -81,29 +81,6 @@ static const char *IFFBITS[] = {
"LOWER_UP", /* 24:0x1000000 IFF_NETLINK_1*/
};
-static void
-print_bits(const char *btype, uint32_t *v, const int v_count,
- const char **names, const int n_count)
-{
- int num = 0;
-
- for (int i = 0; i < v_count * 32; i++) {
- bool is_set = v[i / 32] & (1U << (i % 32));
- if (is_set) {
- if (num++ == 0)
- printf("<");
- if (num != 1)
- printf(",");
- if (i < n_count)
- printf("%s", names[i]);
- else
- printf("%s_%d", btype, i);
- }
- }
- if (num > 0)
- printf(">");
-}
-
static void
nl_init_socket(struct snl_state *ss)
{