Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/ifconfig When ifconfig is invoked without any arguments...



details:   https://anonhg.NetBSD.org/src/rev/b12cb65e6eab
branches:  trunk
changeset: 773132:b12cb65e6eab
user:      mbalmer <mbalmer%NetBSD.org@localhost>
date:      Sat Jan 28 15:01:44 2012 +0000

description:
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.)

diffstat:

 sbin/ifconfig/ifconfig.8 |  10 ++++++++--
 sbin/ifconfig/ifconfig.c |  26 +++++++++++++++-----------
 2 files changed, 23 insertions(+), 13 deletions(-)

diffs (134 lines):

diff -r b9d0ef887189 -r b12cb65e6eab sbin/ifconfig/ifconfig.8
--- a/sbin/ifconfig/ifconfig.8  Sat Jan 28 14:37:35 2012 +0000
+++ b/sbin/ifconfig/ifconfig.8  Sat Jan 28 15:01:44 2012 +0000
@@ -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 @@
 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
diff -r b9d0ef887189 -r b12cb65e6eab sbin/ifconfig/ifconfig.c
--- a/sbin/ifconfig/ifconfig.c  Sat Jan 28 14:37:35 2012 +0000
+++ b/sbin/ifconfig/ifconfig.c  Sat Jan 28 15:01:44 2012 +0000
@@ -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 @@
 #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 @@
        SIMPLEQ_INSERT_TAIL(&aflist, af, af_next);
        return 0;
 }
- 
+
 int
 register_flag(int flag)
 {
@@ -434,7 +434,7 @@
 
        return 0;
 }
- 
+
 static int
 flag_index(int flag)
 {
@@ -467,7 +467,7 @@
 
        if ((idx = flag_index(flag)) == -1)
                return false;
-               
+
        return gflagset[idx];
 }
 
@@ -482,7 +482,7 @@
                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 @@
        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 @@
                case 'b':
                        bflag = true;
                        break;
-                       
+
                case 'C':
                        Cflag = true;
                        break;
@@ -988,7 +992,7 @@
        if (direct_ioctl(env, SIOCSIFFLAGS, &ifr) == -1)
                return -1;
 
-       return 0; 
+       return 0;
 }
 
 static int
@@ -1078,7 +1082,7 @@
 
        if (!prop_dictionary_get_int16(env, "preference",
            &ifap.ifap_preference))
-               return; 
+               return;
 
        d = (prop_data_t)prop_dictionary_get(env, "address");
        assert(d != NULL);



Home | Main Index | Thread Index | Old Index