Page MenuHomeFreeBSD

D45441.id139354.diff
No OneTemporary

D45441.id139354.diff

diff --git a/sbin/ifconfig/af_nd6.c b/sbin/ifconfig/af_nd6.c
--- a/sbin/ifconfig/af_nd6.c
+++ b/sbin/ifconfig/af_nd6.c
@@ -52,17 +52,22 @@
#include "ifconfig.h"
#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
-#define ND6BITS "\020\001PERFORMNUD\002ACCEPT_RTADV\003PREFER_SOURCE" \
- "\004IFDISABLED\005DONT_SET_IFROUTE\006AUTO_LINKLOCAL" \
- "\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"
+ [9] = "IPV6_ONLY",
+ [10] = "IPV6_ONLY_MANUAL",
#endif
+ [15] = "DEFAULTIF",
+};
static int isnd6defif(if_ctx *ctx, int s);
void setnd6flags(if_ctx *, const char *, int);
@@ -141,6 +146,7 @@
int s6;
int error;
int isdefif;
+ uint32_t bits;
strlcpy(nd.ifname, ctx->ifname, sizeof(nd.ifname));
if ((s6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
@@ -159,7 +165,8 @@
close(s6);
if (nd.ndi.flags == 0 && !isdefif)
return;
- printb("\tnd6 options",
- (unsigned int)(nd.ndi.flags | (isdefif << 15)), ND6BITS);
+ bits = (nd.ndi.flags | (isdefif << 15));
+ printf("\tnd6 options=%x", bits);
+ print_bits("options", &bits, 1, ND6BITS, nitems(ND6BITS));
putchar('\n');
}
diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h
--- a/sbin/ifconfig/ifconfig.h
+++ b/sbin/ifconfig/ifconfig.h
@@ -260,6 +260,8 @@
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.c b/sbin/ifconfig/ifconfig.c
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1617,17 +1617,60 @@
#ifdef WITHOUT_NETLINK
-#define IFFBITS \
-"\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\7RUNNING" \
-"\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \
-"\20MULTICAST\22PPROMISC\23MONITOR\24STATICARP\25STICKYARP"
-
-#define IFCAPBITS \
-"\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING" \
-"\10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC" \
-"\17TOE4\20TOE6\21VLAN_HWFILTER\23VLAN_HWTSO\24LINKSTATE\25NETMAP" \
-"\26RXCSUM_IPV6\27TXCSUM_IPV6\31TXRTLMT\32HWRXTSTMP\33NOMAP\34TXTLS4\35TXTLS6" \
-"\36VXLAN_HWCSUM\37VXLAN_HWTSO\40TXTLS_RTLMT"
+static const char *IFFBITS[] = {
+ [0] = "UP",
+ [1] = "BROADCAST",
+ [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",
+};
+
+static const char *IFCAPBITS[] = {
+ [0] = "RXCSUM",
+ [1] = "TXCSUM",
+ [2] = "NETCONS",
+ [3] = "VLAN_MTU",
+ [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
print_ifcap_nv(if_ctx *ctx)
@@ -1699,10 +1742,12 @@
if ((ifr.ifr_curcap & IFCAP_NV) != 0)
print_ifcap_nv(ctx);
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');
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');
}
}
@@ -1790,8 +1835,8 @@
old_s = ctx->io_s;
ctx->io_s = s;
- printf("%s: ", ctx->ifname);
- printb("flags", ifa->ifa_flags, IFFBITS);
+ printf("%s: flags=%x", ctx->ifname, ifa->ifa_flags);
+ print_bits("flags", &ifa->ifa_flags, 1, IFFBITS, nitems(IFFBITS));
print_metric(ctx);
print_mtu(ctx);
putchar('\n');
@@ -1877,6 +1922,29 @@
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_netlink.c b/sbin/ifconfig/ifconfig_netlink.c
--- a/sbin/ifconfig/ifconfig_netlink.c
+++ b/sbin/ifconfig/ifconfig_netlink.c
@@ -81,29 +81,6 @@
"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)
{
diff --git a/sbin/ifconfig/ifgif.c b/sbin/ifconfig/ifgif.c
--- a/sbin/ifconfig/ifgif.c
+++ b/sbin/ifconfig/ifgif.c
@@ -48,7 +48,9 @@
#include "ifconfig.h"
-#define GIFBITS "\020\2IGNORE_SOURCE"
+static const char *GIFBITS[] = {
+ [1] = "IGNORE_SOURCE",
+};
static void
gif_status(if_ctx *ctx)
@@ -60,7 +62,8 @@
return;
if (opts == 0)
return;
- printb("\toptions", opts, GIFBITS);
+ printf("\toptions=%x", opts);
+ print_bits("options", &opts, 1, GIFBITS, nitems(GIFBITS));
putchar('\n');
}
diff --git a/sbin/ifconfig/ifgre.c b/sbin/ifconfig/ifgre.c
--- a/sbin/ifconfig/ifgre.c
+++ b/sbin/ifconfig/ifgre.c
@@ -41,7 +41,11 @@
#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
gre_status(if_ctx *ctx)
@@ -60,7 +64,8 @@
ifr.ifr_data = (caddr_t)&port;
if (ioctl_ctx_ifr(ctx, GREGPORT, &ifr) == 0 && port != 0)
printf("\tudpport: %u\n", port);
- printb("\toptions", opts, GREBITS);
+ printf("\toptions=%x", opts);
+ print_bits("options", &opts, 1, GREBITS, nitems(GREBITS));
putchar('\n');
}

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 22, 3:21 AM (6 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31950122
Default Alt Text
D45441.id139354.diff (7 KB)

Event Timeline