Date: Sun, 27 May 2001 23:12:56 -0700 (PDT) From: brooks@one-eyed-alien.net To: FreeBSD-gnats-submit@freebsd.org Subject: bin/27701: [PATCH] ifconfig: supported media looks bad : wastes space Message-ID: <20010528061256.8678524D23@minya.sea.one-eyed-alien.net>
next in thread | raw e-mail | index | archive | help
>Number: 27701 >Category: bin >Synopsis: [PATCH] ifconfig: supported media looks bad & wastes space >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun May 27 23:20:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Brooks Davis >Release: FreeBSD 5.0-CURRENT i386 >Organization: >Environment: System: FreeBSD minya.sea.one-eyed-alien.net 5.0-CURRENT FreeBSD 5.0-CURRENT #4: Thu May 24 23:05:23 PDT 2001 root@minya.sea.one-eyed-alien.net:/usr/src/sys/compile/MINYA i386 >Description: When using interfaces that support if_media, the supported media list is printed on a single, very long, and generally unreadable line. This isn't very useful. It's also really ugly and most of the time you don't care what media is supported anyway. >How-To-Repeat: Type the following on any system with an interface that uses if_media: $ ifconfig >Fix: This patch makes the printing of supported media dependent on the -m flag and prints the options one per line. The concept was obtained from NetBSD (actually, I first saw it on an OpenBSD box, but if_media is a NetBSD thing and I used their manpages as a refrence.) Index: ifconfig.8 =================================================================== RCS file: /home/ncvs/src/sbin/ifconfig/ifconfig.8,v retrieving revision 1.38 diff -u -r1.38 ifconfig.8 --- ifconfig.8 2001/05/26 09:26:01 1.38 +++ ifconfig.8 2001/05/28 06:00:18 @@ -41,6 +41,7 @@ .Sh SYNOPSIS .Nm .Op Fl L +.Op Fl m .Ar interface .Op Ar address_family .Oo @@ -52,6 +53,7 @@ .Fl a .Op Fl L .Op Fl d +.Op Fl m .Op Fl u .Op Ar address_family .Nm @@ -62,6 +64,7 @@ .Nm .Op Fl L .Op Fl d +.Op Fl m .Op Fl u .Sh DESCRIPTION .Nm Ifconfig @@ -530,6 +533,10 @@ If the driver does supports the media selection system, the supported media list will be included in the output. .Pp +If the +.Fl m +flag is passed before an interface name, ifconfig will display all +of the supported media for the specified interface. If .Fl L flag is supplied, address lifetime is displayed for IPv6 addresses, Index: ifconfig.c =================================================================== RCS file: /home/ncvs/src/sbin/ifconfig/ifconfig.c,v retrieving revision 1.61 diff -u -r1.61 ifconfig.c --- ifconfig.c 2001/05/26 09:26:01 1.61 +++ ifconfig.c 2001/05/28 05:45:19 @@ -134,6 +134,8 @@ struct afswtch; +int supmedia = 0; + #ifdef INET6 char addr_buf[MAXHOSTNAMELEN *2 + 1]; /*for getnameinfo()*/ #endif @@ -351,16 +353,16 @@ fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n", "usage: ifconfig interface address_family [address [dest_address]]", " [parameters]", - " ifconfig -a [-d] [-u] [address_family]", + " ifconfig -a [-d] [-m] [-u] [address_family]", " ifconfig -l [-d] [-u] [address_family]", - " ifconfig [-d] [-u]"); + " ifconfig [-d] [-m] [-u]"); #else fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n", "usage: ifconfig [-L] interface address_family [address [dest_address]]", " [parameters]", - " ifconfig -a [-L] [-d] [-u] [address_family]", + " ifconfig -a [-L] [-d] [-m] [-u] [address_family]", " ifconfig -l [-d] [-u] [address_family]", - " ifconfig [-L] [-d] [-u]"); + " ifconfig [-L] [-d] [-m] [-u]"); #endif exit(1); } @@ -410,7 +412,7 @@ uponly++; break; case 'm': /* show media choices in status */ - /* ignored for compatibility */ + supmedia = 1; break; default: usage(); @@ -421,7 +423,7 @@ argv += optind; /* -l cannot be used with -a or -m */ - if (namesonly && all) + if (namesonly && (all || supmedia)) usage(); /* nonsense.. */ Index: ifconfig.h =================================================================== RCS file: /home/ncvs/src/sbin/ifconfig/ifconfig.h,v retrieving revision 1.6 diff -u -r1.6 ifconfig.h --- ifconfig.h 2001/05/26 09:26:01 1.6 +++ ifconfig.h 2001/05/28 05:39:35 @@ -38,6 +38,7 @@ extern char name[32]; /* name of interface */ extern int allmedia; +extern int supmedia; struct afswtch; extern void setmedia(const char *, int, int, const struct afswtch *rafp); Index: ifmedia.c =================================================================== RCS file: /home/ncvs/src/sbin/ifconfig/ifmedia.c,v retrieving revision 1.7 diff -u -r1.7 ifmedia.c --- ifmedia.c 2001/05/26 09:26:01 1.7 +++ ifmedia.c 2001/05/28 05:42:09 @@ -164,13 +164,13 @@ putchar('\n'); - if (ifmr.ifm_count > 0) { - printf("\tsupported media:"); + if (ifmr.ifm_count > 0 && supmedia) { + printf("\tsupported media:\n"); for (i = 0; i < ifmr.ifm_count; i++) { - putchar(' '); + printf("\t\t"); print_media_word(media_list[i]); + putchar('\n'); } - putchar('\n'); } free(media_list); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010528061256.8678524D23>