Module Name: src Committed By: mbalmer Date: Sat Jan 28 15:01:44 UTC 2012
Modified Files: src/sbin/ifconfig: ifconfig.8 ifconfig.c Log Message: When ifconfig is invoked without any arguments, display the list of all network interfaces (equivalent to ifconfig -a), instead of displaying the usage. (This is consistent with the behaviour on FreeBSD and OpenBSD.) To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/sbin/ifconfig/ifconfig.8 cvs rdiff -u -r1.226 -r1.227 src/sbin/ifconfig/ifconfig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/ifconfig/ifconfig.8 diff -u src/sbin/ifconfig/ifconfig.8:1.103 src/sbin/ifconfig/ifconfig.8:1.104 --- src/sbin/ifconfig/ifconfig.8:1.103 Tue May 31 16:17:30 2011 +++ src/sbin/ifconfig/ifconfig.8 Sat Jan 28 15:01:44 2012 @@ -1,4 +1,4 @@ -.\" $NetBSD: ifconfig.8,v 1.103 2011/05/31 16:17:30 riastradh Exp $ +.\" $NetBSD: ifconfig.8,v 1.104 2012/01/28 15:01:44 mbalmer Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94 .\" -.Dd November 15, 2010 +.Dd January 28, 2012 .Dt IFCONFIG 8 .Os .Sh NAME @@ -805,6 +805,12 @@ flag may be used instead of an interface This flag instructs .Nm to display information about all interfaces in the system. +This is also the default behaviour when no arguments are given to +.Nm +on the command line. +When +.Fl a +is used, the output can be modified by adding more flags: .Fl d limits this to interfaces that are down, .Fl u Index: src/sbin/ifconfig/ifconfig.c diff -u src/sbin/ifconfig/ifconfig.c:1.226 src/sbin/ifconfig/ifconfig.c:1.227 --- src/sbin/ifconfig/ifconfig.c:1.226 Mon Aug 29 14:35:00 2011 +++ src/sbin/ifconfig/ifconfig.c Sat Jan 28 15:01:44 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ifconfig.c,v 1.226 2011/08/29 14:35:00 joerg Exp $ */ +/* $NetBSD: ifconfig.c,v 1.227 2012/01/28 15:01:44 mbalmer Exp $ */ /*- * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1983, 1993\ The Regents of the University of California. All rights reserved."); -__RCSID("$NetBSD: ifconfig.c,v 1.226 2011/08/29 14:35:00 joerg Exp $"); +__RCSID("$NetBSD: ifconfig.c,v 1.227 2012/01/28 15:01:44 mbalmer Exp $"); #endif /* not lint */ #include <sys/param.h> @@ -77,7 +77,7 @@ __RCSID("$NetBSD: ifconfig.c,v 1.226 201 #include <net/if_ether.h> #include <netinet/in.h> /* XXX */ #include <netinet/in_var.h> /* XXX */ - + #include <netdb.h> #include <sys/protosw.h> @@ -418,7 +418,7 @@ register_family(struct afswtch *af) SIMPLEQ_INSERT_TAIL(&aflist, af, af_next); return 0; } - + int register_flag(int flag) { @@ -434,7 +434,7 @@ register_flag(int flag) return 0; } - + static int flag_index(int flag) { @@ -467,7 +467,7 @@ get_flag(int flag) if ((idx = flag_index(flag)) == -1) return false; - + return gflagset[idx]; } @@ -482,7 +482,7 @@ init_parser(void) err(EXIT_FAILURE, "parser_init(iface_only)"); if (parser_init(&iface_start.pif_parser) == -1) err(EXIT_FAILURE, "parser_init(iface_start)"); - + SIMPLEQ_FOREACH(b, &cmdloop_branches, b_next) pbranch_addbranch(&command_root, b->b_parser); @@ -557,7 +557,11 @@ main(int argc, char **argv) start = init_parser(); /* Parse command-line options */ - aflag = Nflag = vflag = zflag = false; + Nflag = vflag = zflag = false; + aflag = argc == 1 ? true : false; + if (aflag) + start = &opt_family_only.pb_parser; + while ((ch = getopt(argc, argv, gflags)) != -1) { switch (ch) { case 'A': @@ -571,7 +575,7 @@ main(int argc, char **argv) case 'b': bflag = true; break; - + case 'C': Cflag = true; break; @@ -988,7 +992,7 @@ setifflags(prop_dictionary_t env, prop_d if (direct_ioctl(env, SIOCSIFFLAGS, &ifr) == -1) return -1; - return 0; + return 0; } static int @@ -1078,7 +1082,7 @@ do_setifpreference(prop_dictionary_t env if (!prop_dictionary_get_int16(env, "preference", &ifap.ifap_preference)) - return; + return; d = (prop_data_t)prop_dictionary_get(env, "address"); assert(d != NULL);