From f7c14501218e469b128871a5ac19f1cc90cfb874 Mon Sep 17 00:00:00 2001 From: Daniil Lunev Date: Tue, 31 Jul 2012 21:33:14 +0000 Subject: [PATCH] 3013 ifconfig with no args should list all interfaces Reviewed by: Garrett D'Amore Reviewed by: Gary Mills Approved by: Albert Lee --- usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c | 23 ++++++++++++++--------- usr/src/man/man1m/ifconfig.1m | 19 +++++++++++++++++-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c b/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c index 63661b0301..4fb78375f7 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c @@ -1,4 +1,7 @@ /* + * Copyright 2012, Daniil Lunev. All rights reserved. + */ +/* * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* @@ -380,15 +383,16 @@ main(int argc, char *argv[]) lifc_flags = LIFC_DEFAULT; if (argc < 2) { - usage(); - exit(1); - } - argc--, argv++; - if (strlen(*argv) > sizeof (name) - 1) { - (void) fprintf(stderr, "%s: interface name too long\n", *argv); - exit(1); + (void) strncpy(name, "-a", sizeof (name)); + } else { + argc--, argv++; + if (strlen(*argv) > sizeof (name) - 1) { + (void) fprintf(stderr, "%s: interface name too long\n", + *argv); + exit(1); + } + (void) strncpy(name, *argv, sizeof (name)); } - (void) strncpy(name, *argv, sizeof (name)); name[sizeof (name) - 1] = '\0'; (void) strncpy(origname, name, sizeof (origname)); /* For addif */ default_ip_str = NULL; @@ -452,7 +456,7 @@ main(int argc, char *argv[]) int c; char *av[2] = { "ifconfig", name }; - while ((c = getopt(2, av, "audDXZ46v")) != -1) { + while ((c = getopt(2, av, "audhDXZ46v")) != -1) { switch ((char)c) { case 'a': all = 1; @@ -491,6 +495,7 @@ main(int argc, char *argv[]) case 'v': verbose = 1; break; + case 'h': case '?': usage(); exit(1); diff --git a/usr/src/man/man1m/ifconfig.1m b/usr/src/man/man1m/ifconfig.1m index abe9e75e62..0de64da068 100644 --- a/usr/src/man/man1m/ifconfig.1m +++ b/usr/src/man/man1m/ifconfig.1m @@ -1,8 +1,9 @@ '\" te +.\" Copyright (C) 2012, Darren Reed. All rights reserved .\" Copyright (C) 2009, Sun Microsystems, Inc. All Rights Reserved .\" Copyright 1989 AT&T .\" Copyright (c) 1983 Regents of the University of California. All rights reserved. The Berkeley software License Agreement specifies the terms and conditions for redistribution. -.TH IFCONFIG 1M "Aug 13, 2009" +.TH IFCONFIG 1M "July 23, 2012" .SH NAME ifconfig \- configure network interface parameters .SH SYNOPSIS @@ -48,7 +49,17 @@ an address family is specified, \fBifconfig\fR reports only the details specific to that address family. Only privileged users may modify the configuration of a network interface. Options appearing within braces (\fB{\|}\fR) indicate that one of the options must be specified. -.SS "DHCP Configuration" +.SS Network Interface Observability +.sp +.LP +Network interface observability with \fBifconfig\fR is limited to those +network interfaces that have been prepared for use with the IP +protocol suite. The preferred method for configuring a network +interface for use with TCP/IP is with \fBipadm\fR and alternatively +with the use of the \fBplumb\fR option as documented below. Network +interfaces that have not been configured for use with the IP +protocol suite can only be observed by using the \fBdladm\fR command. +.SS DHCP Configuration .sp .LP The forms of \fBifconfig\fR that use the \fBauto-dhcp\fR or \fBdhcp\fR @@ -63,6 +74,10 @@ control. .SH OPTIONS .sp .LP +When the \fBifconfig\fR command is executed without any options +its behavior is the same as when the \fB\-a\fR option is supplied +with no other options or arguments. +.LP The following options are supported: .sp .ne 2 -- 2.11.4.GIT