Implemented two modifier flags for -a and -l: -d (only show "down" interfaces)
and -u (only show "up" interfaces)
This commit is contained in:
parent
fc43576e8d
commit
13d5dd4446
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: ifconfig.8,v 1.16 1997/04/10 19:10:16 is Exp $
|
||||
.\" $NetBSD: ifconfig.8,v 1.17 1997/04/21 01:17:57 lukem Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1983, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -33,7 +33,7 @@
|
|||
.\"
|
||||
.\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94
|
||||
.\"
|
||||
.Dd June 1, 1994
|
||||
.Dd April 16, 1997
|
||||
.Dt IFCONFIG 8
|
||||
.Os BSD 4.2
|
||||
.Sh NAME
|
||||
|
@ -54,22 +54,26 @@
|
|||
.Nm ifconfig
|
||||
.Fl a
|
||||
.Op Fl m
|
||||
.Op Fl d
|
||||
.Op Fl u
|
||||
.Op Ar protocol_family
|
||||
.Nm ifconfig
|
||||
.Fl l
|
||||
.Op Fl d
|
||||
.Op Fl u
|
||||
.Sh DESCRIPTION
|
||||
.Nm Ifconfig
|
||||
.Nm
|
||||
is used to assign an address
|
||||
to a network interface and/or configure
|
||||
network interface parameters.
|
||||
.Nm Ifconfig
|
||||
.Nm
|
||||
must be used at boot time to define the network address
|
||||
of each interface present on a machine; it may also be used at
|
||||
a later time to redefine an interface's address
|
||||
or other operating parameters.
|
||||
.Pp
|
||||
Available operands for
|
||||
.Nm ifconfig:
|
||||
.Nm ifconfig :
|
||||
.Bl -tag -width Ds
|
||||
.It Ar Address
|
||||
For the
|
||||
|
@ -290,8 +294,7 @@ If the interface was reset when previously marked down,
|
|||
the hardware will be re-initialized.
|
||||
.El
|
||||
.Pp
|
||||
.Pp
|
||||
.Nm Ifconfig
|
||||
.Nm
|
||||
displays the current configuration for a network interface
|
||||
when no optional parameters are supplied.
|
||||
If a protocol family is specified,
|
||||
|
@ -300,19 +303,29 @@ Ifconfig will report only the details specific to that protocol family.
|
|||
If the
|
||||
.Fl m
|
||||
flag is passed before an interface name,
|
||||
.Nm ifconfig
|
||||
.Nm
|
||||
will display all of the supported media for the specified interface.
|
||||
.Pp
|
||||
Optionally, the
|
||||
.Fl a
|
||||
flag may be used instead of an interface name. This flag instructs
|
||||
.Nm ifconfig
|
||||
.Nm
|
||||
to display information about all interfaces in the system.
|
||||
.Fl d
|
||||
limits this to interfaces that are down, and
|
||||
.Fl u
|
||||
limits this to interfaces that are up.
|
||||
.Pp
|
||||
The
|
||||
.Fl l
|
||||
flag may be used to list all available interfaces on the system, with
|
||||
no other additional information. Use of this flag is mutually exclusive
|
||||
with all other flags and commands.
|
||||
with all other flags and commands, except for
|
||||
.Fl d
|
||||
(only list interfaces that are down)
|
||||
and
|
||||
.Fl u
|
||||
(only list interfaces that are up).
|
||||
.Pp
|
||||
Only the super-user may modify the configuration of a network interface.
|
||||
.Sh DIAGNOSTICS
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ifconfig.c,v 1.33 1997/04/10 19:10:17 is Exp $ */
|
||||
/* $NetBSD: ifconfig.c,v 1.34 1997/04/21 01:17:58 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Jason R. Thorpe.
|
||||
|
@ -75,7 +75,7 @@ static char copyright[] =
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
|
||||
#else
|
||||
static char rcsid[] = "$NetBSD: ifconfig.c,v 1.33 1997/04/10 19:10:17 is Exp $";
|
||||
static char rcsid[] = "$NetBSD: ifconfig.c,v 1.34 1997/04/21 01:17:58 lukem Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -121,7 +121,7 @@ int clearaddr, s;
|
|||
int newaddr = 1;
|
||||
int nsellength = 1;
|
||||
int af;
|
||||
int mflag, lflag;
|
||||
int dflag, mflag, lflag, uflag;
|
||||
|
||||
void notealias __P((char *, int));
|
||||
void notrailers __P((char *, int));
|
||||
|
@ -257,12 +257,16 @@ main(argc, argv)
|
|||
|
||||
/* Parse command-line options */
|
||||
aflag = mflag = 0;
|
||||
while ((ch = getopt(argc, argv, "alm")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "adlmu")) != -1) {
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
aflag = 1;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
dflag = 1;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
lflag = 1;
|
||||
break;
|
||||
|
@ -271,6 +275,10 @@ main(argc, argv)
|
|||
mflag = 1;
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
uflag = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
/* NOTREACHED */
|
||||
|
@ -467,7 +475,7 @@ printall()
|
|||
err(1, "SIOCGIFCONF");
|
||||
ifr = ifc.ifc_req;
|
||||
ifreq.ifr_name[0] = '\0';
|
||||
for (i = 0, idx = 0; i < ifc.ifc_len; idx++) {
|
||||
for (i = 0, idx = 0; i < ifc.ifc_len; ) {
|
||||
ifr = (struct ifreq *)((caddr_t)ifc.ifc_req + i);
|
||||
i += sizeof(ifr->ifr_name) +
|
||||
(ifr->ifr_addr.sa_len > sizeof(struct sockaddr)
|
||||
|
@ -481,18 +489,24 @@ printall()
|
|||
(void) strncpy(name, ifr->ifr_name, sizeof(ifr->ifr_name));
|
||||
ifreq = *ifr;
|
||||
|
||||
if (getinfo(&ifreq) < 0)
|
||||
continue;
|
||||
if (dflag && (flags & IFF_UP) != 0)
|
||||
continue;
|
||||
if (uflag && (flags & IFF_UP) == 0)
|
||||
continue;
|
||||
|
||||
idx++;
|
||||
/*
|
||||
* Are we just listing the interfaces?
|
||||
*/
|
||||
if (lflag) {
|
||||
if (idx)
|
||||
if (idx > 1)
|
||||
putchar(' ');
|
||||
printf(name);
|
||||
fputs(name, stdout);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (getinfo(&ifreq) < 0)
|
||||
continue;
|
||||
if (sdl == NULL) {
|
||||
status(NULL, 0);
|
||||
} else {
|
||||
|
@ -577,7 +591,7 @@ notrailers(vname, value)
|
|||
char *vname;
|
||||
int value;
|
||||
{
|
||||
printf("Note: trailers are no longer sent, but always received\n");
|
||||
puts("Note: trailers are no longer sent, but always received");
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
|
@ -1444,7 +1458,7 @@ xns_getaddr(addr, which)
|
|||
sns->sns_len = sizeof(*sns);
|
||||
sns->sns_addr = ns_addr(addr);
|
||||
if (which == MASK)
|
||||
printf("Attempt to set XNS netmask will be ineffectual\n");
|
||||
puts("Attempt to set XNS netmask will be ineffectual");
|
||||
}
|
||||
|
||||
#define SISO(x) ((struct sockaddr_iso *) &(x))
|
||||
|
@ -1522,7 +1536,7 @@ usage()
|
|||
"\t[ mediaopt mopts ]\n",
|
||||
"\t[ -mediaopt mopts ]\n",
|
||||
"\t[ link0 | -link0 ] [ link1 | -link1 ] [ link2 | -link2 ]\n",
|
||||
" ifconfig -a [ -m ] [ af ]\n",
|
||||
" ifconfig -l\n");
|
||||
" ifconfig -a [ -m ] [ -d ] [ -u ] [ af ]\n",
|
||||
" ifconfig -l [ -d ] [ -u ]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue