mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-22 02:37:15 +00:00
Migrate from printb to print_bits for locally defined bit fields.
Reviewed by: emaste Event: Kitchener-Waterloo Hackathon 202406 Differential Revision: https://reviews.freebsd.org/D45441
This commit is contained in:
parent
c3e9423743
commit
a68e4f7a06
|
@ -52,17 +52,22 @@
|
||||||
#include "ifconfig.h"
|
#include "ifconfig.h"
|
||||||
|
|
||||||
#define MAX_SYSCTL_TRY 5
|
#define MAX_SYSCTL_TRY 5
|
||||||
|
static const char *ND6BITS[] = {
|
||||||
|
[0] = "PERFORMNUD",
|
||||||
|
[1] = "ACCEPT_RTADV",
|
||||||
|
[2] = "PREFER_SOURCE",
|
||||||
|
[3] = "IFDISABLED",
|
||||||
|
[4] = "DONT_SET_IFROUTE",
|
||||||
|
[5] = "AUTO_LINKLOCAL",
|
||||||
|
[6] = "NO_RADR",
|
||||||
|
[7] = "NO_PREFER_IFACE",
|
||||||
|
[8] = "NO_DAD",
|
||||||
#ifdef DRAFT_IETF_6MAN_IPV6ONLY_FLAG
|
#ifdef DRAFT_IETF_6MAN_IPV6ONLY_FLAG
|
||||||
#define ND6BITS "\020\001PERFORMNUD\002ACCEPT_RTADV\003PREFER_SOURCE" \
|
[9] = "IPV6_ONLY",
|
||||||
"\004IFDISABLED\005DONT_SET_IFROUTE\006AUTO_LINKLOCAL" \
|
[10] = "IPV6_ONLY_MANUAL",
|
||||||
"\007NO_RADR\010NO_PREFER_IFACE\011NO_DAD" \
|
|
||||||
"\012IPV6_ONLY\013IPV6_ONLY_MANUAL" \
|
|
||||||
"\020DEFAULTIF"
|
|
||||||
#else
|
|
||||||
#define ND6BITS "\020\001PERFORMNUD\002ACCEPT_RTADV\003PREFER_SOURCE" \
|
|
||||||
"\004IFDISABLED\005DONT_SET_IFROUTE\006AUTO_LINKLOCAL" \
|
|
||||||
"\007NO_RADR\010NO_PREFER_IFACE\011NO_DAD\020DEFAULTIF"
|
|
||||||
#endif
|
#endif
|
||||||
|
[15] = "DEFAULTIF",
|
||||||
|
};
|
||||||
|
|
||||||
static int isnd6defif(if_ctx *ctx, int s);
|
static int isnd6defif(if_ctx *ctx, int s);
|
||||||
void setnd6flags(if_ctx *, const char *, int);
|
void setnd6flags(if_ctx *, const char *, int);
|
||||||
|
@ -141,6 +146,7 @@ nd6_status(if_ctx *ctx)
|
||||||
int s6;
|
int s6;
|
||||||
int error;
|
int error;
|
||||||
int isdefif;
|
int isdefif;
|
||||||
|
uint32_t bits;
|
||||||
|
|
||||||
strlcpy(nd.ifname, ctx->ifname, sizeof(nd.ifname));
|
strlcpy(nd.ifname, ctx->ifname, sizeof(nd.ifname));
|
||||||
if ((s6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
|
if ((s6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
|
||||||
|
@ -159,7 +165,8 @@ nd6_status(if_ctx *ctx)
|
||||||
close(s6);
|
close(s6);
|
||||||
if (nd.ndi.flags == 0 && !isdefif)
|
if (nd.ndi.flags == 0 && !isdefif)
|
||||||
return;
|
return;
|
||||||
printb("\tnd6 options",
|
bits = (nd.ndi.flags | (isdefif << 15));
|
||||||
(unsigned int)(nd.ndi.flags | (isdefif << 15)), ND6BITS);
|
printf("\tnd6 options=%x", bits);
|
||||||
|
print_bits("options", &bits, 1, ND6BITS, nitems(ND6BITS));
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1617,17 +1617,60 @@ unsetifdescr(if_ctx *ctx, const char *val __unused, int value __unused)
|
||||||
|
|
||||||
#ifdef WITHOUT_NETLINK
|
#ifdef WITHOUT_NETLINK
|
||||||
|
|
||||||
#define IFFBITS \
|
static const char *IFFBITS[] = {
|
||||||
"\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\7RUNNING" \
|
[0] = "UP",
|
||||||
"\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \
|
[1] = "BROADCAST",
|
||||||
"\20MULTICAST\22PPROMISC\23MONITOR\24STATICARP\25STICKYARP"
|
[2] = "DEBUG",
|
||||||
|
[3] = "LOOPBACK",
|
||||||
|
[4] = "POINTOPOINT",
|
||||||
|
[6] = "RUNNING",
|
||||||
|
[7] = "NOARP",
|
||||||
|
[8] = "PROMISC",
|
||||||
|
[9] = "ALLMULTI",
|
||||||
|
[10] = "OACTIVE",
|
||||||
|
[11] = "SIMPLEX",
|
||||||
|
[12] = "LINK0",
|
||||||
|
[13] = "LINK1",
|
||||||
|
[14] = "LINK2",
|
||||||
|
[15] = "MULTICAST",
|
||||||
|
[17] = "PPROMISC",
|
||||||
|
[18] = "MONITOR",
|
||||||
|
[19] = "STATICARP",
|
||||||
|
[20] = "STICKYARP",
|
||||||
|
};
|
||||||
|
|
||||||
#define IFCAPBITS \
|
static const char *IFCAPBITS[] = {
|
||||||
"\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING" \
|
[0] = "RXCSUM",
|
||||||
"\10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC" \
|
[1] = "TXCSUM",
|
||||||
"\17TOE4\20TOE6\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE\25NETMAP" \
|
[2] = "NETCONS",
|
||||||
"\26RXCSUM_IPV6\27TXCSUM_IPV6\31TXRTLMT\32HWRXTSTMP\33NOMAP\34TXTLS4\35TXTLS6" \
|
[3] = "VLAN_MTU",
|
||||||
"\36VXLAN_HWCSUM\37VXLAN_HWTSO\40TXTLS_RTLMT"
|
[4] = "VLAN_HWTAGGING",
|
||||||
|
[5] = "JUMBO_MTU",
|
||||||
|
[6] = "POLLING",
|
||||||
|
[7] = "VLAN_HWCSUM",
|
||||||
|
[8] = "TSO4",
|
||||||
|
[9] = "TSO6",
|
||||||
|
[10] = "LRO",
|
||||||
|
[11] = "WOL_UCAST",
|
||||||
|
[12] = "WOL_MCAST",
|
||||||
|
[13] = "WOL_MAGIC",
|
||||||
|
[14] = "TOE4",
|
||||||
|
[15] = "TOE6",
|
||||||
|
[16] = "VLAN_HWFILTER",
|
||||||
|
[18] = "VLAN_HWTSO",
|
||||||
|
[19] = "LINKSTATE",
|
||||||
|
[20] = "NETMAP",
|
||||||
|
[21] = "RXCSUM_IPV6",
|
||||||
|
[22] = "TXCSUM_IPV6",
|
||||||
|
[24] = "TXRTLMT",
|
||||||
|
[25] = "HWRXTSTMP",
|
||||||
|
[26] = "NOMAP",
|
||||||
|
[27] = "TXTLS4",
|
||||||
|
[28] = "TXTLS6",
|
||||||
|
[29] = "VXLAN_HWCSUM",
|
||||||
|
[30] = "VXLAN_HWTSO",
|
||||||
|
[31] = "TXTLS_RTLMT",
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_ifcap_nv(if_ctx *ctx)
|
print_ifcap_nv(if_ctx *ctx)
|
||||||
|
@ -1699,10 +1742,12 @@ print_ifcap(if_ctx *ctx)
|
||||||
if ((ifr.ifr_curcap & IFCAP_NV) != 0)
|
if ((ifr.ifr_curcap & IFCAP_NV) != 0)
|
||||||
print_ifcap_nv(ctx);
|
print_ifcap_nv(ctx);
|
||||||
else {
|
else {
|
||||||
printb("\toptions", ifr.ifr_curcap, IFCAPBITS);
|
printf("\toptions=%x", ifr.ifr_curcap);
|
||||||
|
print_bits("options", &ifr.ifr_curcap, 1, IFCAPBITS, nitems(IFCAPBITS));
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
if (ctx->args->supmedia && ifr.ifr_reqcap != 0) {
|
if (ctx->args->supmedia && ifr.ifr_reqcap != 0) {
|
||||||
printb("\tcapabilities", ifr.ifr_reqcap, IFCAPBITS);
|
printf("\tcapabilities=%x", ifr.ifr_reqcap);
|
||||||
|
print_bits("capabilities", &ifr.ifr_reqcap, 1, IFCAPBITS, nitems(IFCAPBITS));
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1790,8 +1835,8 @@ status(if_ctx *ctx, const struct sockaddr_dl *sdl __unused, struct ifaddrs *ifa)
|
||||||
old_s = ctx->io_s;
|
old_s = ctx->io_s;
|
||||||
ctx->io_s = s;
|
ctx->io_s = s;
|
||||||
|
|
||||||
printf("%s: ", ctx->ifname);
|
printf("%s: flags=%x", ctx->ifname, ifa->ifa_flags);
|
||||||
printb("flags", ifa->ifa_flags, IFFBITS);
|
print_bits("flags", &ifa->ifa_flags, 1, IFFBITS, nitems(IFFBITS));
|
||||||
print_metric(ctx);
|
print_metric(ctx);
|
||||||
print_mtu(ctx);
|
print_mtu(ctx);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
|
|
|
@ -48,7 +48,9 @@
|
||||||
|
|
||||||
#include "ifconfig.h"
|
#include "ifconfig.h"
|
||||||
|
|
||||||
#define GIFBITS "\020\2IGNORE_SOURCE"
|
static const char *GIFBITS[] = {
|
||||||
|
[1] = "IGNORE_SOURCE",
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gif_status(if_ctx *ctx)
|
gif_status(if_ctx *ctx)
|
||||||
|
@ -60,7 +62,8 @@ gif_status(if_ctx *ctx)
|
||||||
return;
|
return;
|
||||||
if (opts == 0)
|
if (opts == 0)
|
||||||
return;
|
return;
|
||||||
printb("\toptions", opts, GIFBITS);
|
printf("\toptions=%x", opts);
|
||||||
|
print_bits("options", &opts, 1, GIFBITS, nitems(GIFBITS));
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,11 @@
|
||||||
|
|
||||||
#include "ifconfig.h"
|
#include "ifconfig.h"
|
||||||
|
|
||||||
#define GREBITS "\020\01ENABLE_CSUM\02ENABLE_SEQ\03UDPENCAP"
|
static const char *GREBITS[] = {
|
||||||
|
[0] = "ENABLE_CSUM",
|
||||||
|
[1] = "ENABLE_SEQ",
|
||||||
|
[2] = "UDPENCAP",
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gre_status(if_ctx *ctx)
|
gre_status(if_ctx *ctx)
|
||||||
|
@ -60,7 +64,8 @@ gre_status(if_ctx *ctx)
|
||||||
ifr.ifr_data = (caddr_t)&port;
|
ifr.ifr_data = (caddr_t)&port;
|
||||||
if (ioctl_ctx_ifr(ctx, GREGPORT, &ifr) == 0 && port != 0)
|
if (ioctl_ctx_ifr(ctx, GREGPORT, &ifr) == 0 && port != 0)
|
||||||
printf("\tudpport: %u\n", port);
|
printf("\tudpport: %u\n", port);
|
||||||
printb("\toptions", opts, GREBITS);
|
printf("\toptions=%x", opts);
|
||||||
|
print_bits("options", &opts, 1, GREBITS, nitems(GREBITS));
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue