diff options
author | wpaul <wpaul@FreeBSD.org> | 1995-03-12 19:05:03 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 1995-03-12 19:05:03 +0000 |
commit | f35bd2b8e80fbedba802ad510574a163bedb55db (patch) | |
tree | e7fff3672d34b8e54ff858425f24b031a110e1fa | |
parent | 0fcaf7139aa9cdd217d54d9f949c29b425ba67b5 (diff) | |
download | FreeBSD-src-f35bd2b8e80fbedba802ad510574a163bedb55db.zip FreeBSD-src-f35bd2b8e80fbedba802ad510574a163bedb55db.tar.gz |
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.
-rw-r--r-- | sbin/ifconfig/ifconfig.8 | 17 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 33 |
2 files changed, 42 insertions, 8 deletions
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 6cdb459..cb97093 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -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 diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 66de006..f62761c 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -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) |