Impliment -ad and -au flags in addition to -a and document the change

in the man page. ifconfig -au affects all interfaces marked as up,
and ifconfig -ad affects only the interfaces marked down. ifconfig -a
still handles everything. This change is purely for compatibility with
SunOS, for those who might be accustomed to the SunOS ifconfig's
behavior.
This commit is contained in:
Bill Paul 1995-03-12 19:05:03 +00:00
parent f2a5c98e24
commit f7fa522e95
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=7039
2 changed files with 42 additions and 8 deletions

View File

@ -50,6 +50,10 @@
.Op Ar protocol_family
.Nm ifconfig
.Ar -a
.Nm ifconfig
.Ar -au
.Nm ifconfig
.Ar -ad
.Sh DESCRIPTION
.Nm Ifconfig
is used to assign an address
@ -264,7 +268,18 @@ the hardware will be re-initialized.
.Nm Ifconfig
.Ar -a
displays information on all interfaces. When followed by a configuration
parameter, will also set the configuration on all interfaces.
parameter, it will also set the configuration on all interfaces.
.Pp
.Nm Ifconfig
.Ar -au
is similar to
.Nm ifconfig
.Ar -a ,
except it only affects interfaces that are currently marked as up.
Conversely,
.Nm ifconfig
.Ar -ad
affects only interfaces that are marked down.
.Pp
.Nm Ifconfig
displays the current configuration for a network interface

View File

@ -207,13 +207,17 @@ main(argc, argv)
perror("ifconfig: socket");
exit(1);
}
if (!strcmp(name, "-a")) {
if (strstr(name, "-a")) {
struct ifconf ifc;
#define MAX_INTERFACES 50 /* Yeah right. */
char buffer[MAX_INTERFACES * sizeof(struct ifreq)];
struct ifreq *ifptr, *end;
int ifflags;
int ifflags, selectflag = -1;
if (strstr(name, "-au"))
selectflag = 1;
if (strstr(name, "-ad"))
selectflag = 0;
ifc.ifc_len = sizeof(buffer);
ifc.ifc_buf = buffer;
if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0) {
@ -227,13 +231,12 @@ main(argc, argv)
sprintf(ifr.ifr_name,"%s",ifptr->ifr_name);
sprintf(name,"%s",ifptr->ifr_name);
close(s);
s = socket(af, SOCK_DGRAM, 0);
if (s < 0) {
if ((s = socket(af, SOCK_DGRAM, 0)) < 0) {
perror("ifconfig: socket");
exit(1);
}
if (ifptr->ifr_flags == ifflags)
ifconfig(argc,argv,af,rafp);
ifconfig(argc,argv,af,rafp,selectflag);
if(ifptr->ifr_addr.sa_len) /* Dohw! */
ifptr = (struct ifreq *) ((caddr_t) ifptr +
ifptr->ifr_addr.sa_len -
@ -241,23 +244,39 @@ main(argc, argv)
ifptr++;
}
} else
ifconfig(argc,argv,af,rafp);
ifconfig(argc,argv,af,rafp, -1);
exit (0);
}
ifconfig(argc,argv,af,rafp)
ifconfig(argc,argv,af,rafp,flag)
int argc;
char *argv[];
int af;
struct afswtch *rafp;
int flag;
{
if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) {
Perror("ioctl (SIOCGIFFLAGS)");
exit(1);
}
switch(flag) {
case 0:
if (ifr.ifr_flags & IFF_UP)
return(0);
break;
case 1:
if (!(ifr.ifr_flags & IFF_UP))
return(0);
break;
case -1:
default:
break;
}
strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
flags = ifr.ifr_flags;
if (ioctl(s, SIOCGIFMETRIC, (caddr_t)&ifr) < 0)