Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/ifconfig Make display of media status information (e.g....
details: https://anonhg.NetBSD.org/src/rev/508b97dbe6a2
branches: trunk
changeset: 481219:508b97dbe6a2
user: thorpej <thorpej%NetBSD.org@localhost>
date: Tue Jan 25 00:59:39 2000 +0000
description:
Make display of media status information (e.g. carrier, etc.) table-driven
and easily extensible (by merely adding to the tables in ifmedia.h).
diffstat:
sbin/ifconfig/ifconfig.c | 53 +++++++++++++++++++++++++++++------------------
1 files changed, 33 insertions(+), 20 deletions(-)
diffs (83 lines):
diff -r a663d340619b -r 508b97dbe6a2 sbin/ifconfig/ifconfig.c
--- a/sbin/ifconfig/ifconfig.c Tue Jan 25 00:58:59 2000 +0000
+++ b/sbin/ifconfig/ifconfig.c Tue Jan 25 00:59:39 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ifconfig.c,v 1.62 2000/01/24 23:24:16 chopps Exp $ */
+/* $NetBSD: ifconfig.c,v 1.63 2000/01/25 00:59:39 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -80,7 +80,7 @@
#if 0
static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
#else
-__RCSID("$NetBSD: ifconfig.c,v 1.62 2000/01/24 23:24:16 chopps Exp $");
+__RCSID("$NetBSD: ifconfig.c,v 1.63 2000/01/25 00:59:39 thorpej Exp $");
#endif
#endif /* not lint */
@@ -1261,6 +1261,11 @@
"\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6NOTRAILERS\7RUNNING\10NOARP\
\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2\20MULTICAST"
+const int ifm_status_valid_list[] = IFM_STATUS_VALID_LIST;
+
+const struct ifmedia_status_description ifm_status_descriptions[] =
+ IFM_STATUS_DESCRIPTIONS;
+
/*
* Print the status of the interface. If an address family was
* specified, show it and it only; otherwise, show them all.
@@ -1321,26 +1326,34 @@
}
putchar('\n');
- if (ifmr.ifm_status & IFM_AVALID) {
- printf("\tstatus: ");
- switch (IFM_TYPE(ifmr.ifm_active)) {
- case IFM_ETHER:
- if (ifmr.ifm_status & IFM_ACTIVE)
- printf("active");
- else
- printf("no carrier");
- break;
+ if (ifmr.ifm_status & IFM_STATUS_VALID) {
+ const struct ifmedia_status_description *ifms;
+ int bitno, found = 0;
- case IFM_FDDI:
- case IFM_TOKEN:
- if (ifmr.ifm_status & IFM_ACTIVE)
- printf("inserted");
- else
- printf("no ring");
- break;
- default:
+ printf("\tstatus: ");
+ for (bitno = 0; ifm_status_valid_list[bitno] != 0; bitno++) {
+ for (ifms = ifm_status_descriptions;
+ ifms->ifms_valid != 0; ifms++) {
+ if (ifms->ifms_type !=
+ IFM_TYPE(ifmr.ifm_active) &&
+ ifms->ifms_valid !=
+ ifm_status_valid_list[bitno])
+ continue;
+ printf("%s%s", found ? ", " : "",
+ IFM_STATUS_DESC(ifms, ifmr.ifm_status));
+ found = 1;
+
+ /*
+ * For each valid indicator bit, there's
+ * only one entry for each media type, so
+ * terminate the inner loop now.
+ */
+ break;
+ }
+ }
+
+ if (found == 0)
printf("unknown");
- }
putchar('\n');
}
Home |
Main Index |
Thread Index |
Old Index