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
This commit is contained in:
@@ -1877,6 +1877,29 @@ Perror(const char *cmd)
|
|||||||
Perrorc(cmd, errno);
|
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
|
* Print a value a la the %b format of the kernel's printf
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -260,6 +260,8 @@ void setifcap(if_ctx *ctx, const char *, int value);
|
|||||||
void setifcapnv(if_ctx *ctx, const char *vname, const char *arg);
|
void setifcapnv(if_ctx *ctx, const char *vname, const char *arg);
|
||||||
|
|
||||||
void Perror(const char *cmd);
|
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 printb(const char *s, unsigned value, const char *bits);
|
||||||
|
|
||||||
void ifmaybeload(struct ifconfig_args *args, const char *name);
|
void ifmaybeload(struct ifconfig_args *args, const char *name);
|
||||||
|
|||||||
@@ -81,29 +81,6 @@ static const char *IFFBITS[] = {
|
|||||||
"LOWER_UP", /* 24:0x1000000 IFF_NETLINK_1*/
|
"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
|
static void
|
||||||
nl_init_socket(struct snl_state *ss)
|
nl_init_socket(struct snl_state *ss)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user