diff options
Diffstat (limited to 'sbin/ifconfig/ifconfig.c')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 55 |
1 files changed, 21 insertions, 34 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 4d47f06..bdf8e60 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -38,11 +38,11 @@ static const char copyright[] = #endif /* not lint */ #ifndef lint -/* +#if 0 static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94"; -*/ +#endif static const char rcsid[] = - "$Id: ifconfig.c,v 1.34 1997/12/26 23:28:04 imp Exp $"; + "$Id$"; #endif /* not lint */ #include <sys/param.h> @@ -278,20 +278,11 @@ rt_xaddrs(cp, cplim, rtinfo) void usage() { - fputs("usage: ifconfig -a [ -d ] [ -u ] [ af ]\n", stderr); - fputs(" ifconfig -l [ -d ] [ -u ]\n", stderr); - fputs(" [ af [ address [ dest_addr ] ] [ netmask mask ] [ broadcast addr ]\n", stderr); - fputs(" [ alias ] [ delete ] ]\n", stderr); - fputs(" [ up ] [ down ]\n", stderr); - fputs(" [ metric n ]\n", stderr); - fputs(" [ mtu n ]\n", stderr); - fputs(" [ arp | -arp ]\n", stderr); - fputs(" [ link0 | -link0 ] [ link1 | -link1 ] [ link2 | -link2 ]\n", stderr); -#ifdef USE_IF_MEDIA - fputs(" [ media mtype ]\n", stderr); - fputs(" [ mediaopt mopts ]\n", stderr); - fputs(" [ -mediaopt mopts ]\n", stderr); -#endif + fprintf(stderr, "%s\n%s\n%s\n%s\n", + "usage: ifconfig interface address_family [address [dest_address]]", + " [parameters]", + " ifconfig -a [-d] [-u] [address_family]", + " ifconfig -l [-d] [-u] [address_family]"); exit(1); } @@ -331,7 +322,7 @@ main(argc, argv) uponly++; break; case 'm': /* show media choices in status */ - /* ignored for compatability */ + /* ignored for compatibility */ break; default: usage(); @@ -365,7 +356,7 @@ main(argc, argv) /* leave with afp non-zero */ } } else { - /* not listsing, need an argument */ + /* not listing, need an argument */ if (argc < 1) usage(); @@ -501,10 +492,8 @@ ifconfig(argc, argv, afp) ifr.ifr_addr.sa_family = afp->af_af; strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name); - if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0) { - perror("ifconfig: socket"); - exit(1); - } + if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0) + err(1, "socket"); while (argc > 0) { register const struct cmd *p; @@ -708,7 +697,7 @@ setifmetric(val, dummy, s, afp) strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); ifr.ifr_metric = atoi(val); if (ioctl(s, SIOCSIFMETRIC, (caddr_t)&ifr) < 0) - perror("ioctl (set metric)"); + warn("ioctl (set metric)"); } void @@ -721,7 +710,7 @@ setifmtu(val, dummy, s, afp) strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); ifr.ifr_mtu = atoi(val); if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) < 0) - perror("ioctl (set mtu)"); + warn("ioctl (set mtu)"); } #ifdef ISO @@ -764,10 +753,8 @@ status(afp, addrcount, sdl, ifm, ifam) ifr.ifr_addr.sa_family = afp->af_af; strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name); - if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0) { - perror("ifconfig: socket"); - exit(1); - } + if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0) + err(1, "socket"); /* * XXX is it we are doing a SIOCGIFMETRIC etc for one family. @@ -776,12 +763,12 @@ status(afp, addrcount, sdl, ifm, ifam) * metric and mtu is printed on the global the flags line. */ if (ioctl(s, SIOCGIFMETRIC, (caddr_t)&ifr) < 0) - perror("ioctl (SIOCGIFMETRIC)"); + warn("ioctl (SIOCGIFMETRIC)"); else metric = ifr.ifr_metric; if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) < 0) - perror("ioctl (SIOCGIFMTU)"); + warn("ioctl (SIOCGIFMTU)"); else mtu = ifr.ifr_mtu; @@ -1111,7 +1098,7 @@ at_getaddr(addr, which) sat->sat_family = AF_APPLETALK; sat->sat_len = sizeof(*sat); if (which == MASK) - errx(1, "AppleTalk does not use netmasks\n"); + errx(1, "AppleTalk does not use netmasks"); if (sscanf(addr, "%u.%u", &net, &node) != 2 || net > 0xffff || node > 0xfe) errx(1, "%s: illegal address", addr); @@ -1221,9 +1208,9 @@ setnsellength(val) { nsellength = atoi(val); if (nsellength < 0) - errx(1, "Negative NSEL length is absurd"); + errx(1, "negative NSEL length is absurd"); if (afp == 0 || afp->af_af != AF_ISO) - errx(1, "Setting NSEL length valid only for iso"); + errx(1, "setting NSEL length valid only for iso"); } void |