2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 4. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 static const char copyright[] =
32 "@(#) Copyright (c) 1983, 1993\n\
33 The Regents of the University of California. All rights reserved.\n";
38 static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
40 static const char rcsid[] =
44 #include <sys/param.h>
45 #include <sys/ioctl.h>
46 #include <sys/socket.h>
47 #include <sys/sysctl.h>
49 #include <sys/module.h>
50 #include <sys/linker.h>
52 #include <net/ethernet.h>
54 #include <net/if_var.h>
55 #include <net/if_dl.h>
56 #include <net/if_types.h>
57 #include <net/route.h>
60 #include <netinet/in.h>
61 #include <netinet/in_var.h>
62 #include <arpa/inet.h>
78 * Since "struct ifreq" is composed of various union members, callers
79 * should pay special attention to interprete the value.
80 * (.e.g. little/big endian difference in the structure.)
94 int printkeys = 0; /* Print keying material for interfaces. */
96 static int ifconfig(int argc, char *const *argv, int iscreate,
97 const struct afswtch *afp);
98 static void status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
100 static void tunnel_status(int s);
101 static void usage(void);
103 static struct afswtch *af_getbyname(const char *name);
104 static struct afswtch *af_getbyfamily(int af);
105 static void af_other_status(int);
107 static struct option *opts = NULL;
110 opt_register(struct option *p)
122 /* XXX not right but close enough for now */
124 for (p = opts; p != NULL; p = p->next) {
125 strlcat(options, p->opt_usage, sizeof(options));
126 strlcat(options, " ", sizeof(options));
130 "usage: ifconfig %sinterface address_family [address [dest_address]]\n"
132 " ifconfig interface create\n"
133 " ifconfig -a %s[-d] [-m] [-u] [-v] [address_family]\n"
134 " ifconfig -l [-d] [-u] [address_family]\n"
135 " ifconfig %s[-d] [-m] [-u] [-v]\n",
136 options, options, options);
141 main(int argc, char *argv[])
143 int c, all, namesonly, downonly, uponly;
144 const struct afswtch *afp = NULL;
146 struct ifaddrs *ifap, *ifa;
148 const struct sockaddr_dl *sdl;
149 char options[1024], *cp;
154 all = downonly = uponly = namesonly = noload = verbose = 0;
156 /* Parse leading line options */
157 strlcpy(options, "adklmnuv", sizeof(options));
158 for (p = opts; p != NULL; p = p->next)
159 strlcat(options, p->opt, sizeof(options));
160 while ((c = getopt(argc, argv, options)) != -1) {
162 case 'a': /* scan all interfaces */
165 case 'd': /* restrict scan to "down" interfaces */
171 case 'l': /* scan interface names only */
174 case 'm': /* show media choices in status */
177 case 'n': /* suppress module loading */
180 case 'u': /* restrict scan to "up" interfaces */
187 for (p = opts; p != NULL; p = p->next)
188 if (p->opt[0] == c) {
200 /* -l cannot be used with -a or -m */
201 if (namesonly && (all || supmedia))
205 if (uponly && downonly)
208 /* no arguments is equivalent to '-a' */
209 if (!namesonly && argc < 1)
212 /* -a and -l allow an address family arg to limit the output */
213 if (all || namesonly) {
220 afp = af_getbyname(*argv);
223 if (afp->af_name != NULL)
225 /* leave with afp non-zero */
228 /* not listing, need an argument */
235 /* check and maybe load support for this interface */
238 ifindex = if_nametoindex(ifname);
241 * NOTE: We must special-case the `create' command
242 * right here as we would otherwise fail when trying
243 * to find the interface.
245 if (argc > 0 && (strcmp(argv[0], "create") == 0 ||
246 strcmp(argv[0], "plumb") == 0)) {
247 iflen = strlcpy(name, ifname, sizeof(name));
248 if (iflen >= sizeof(name))
249 errx(1, "%s: cloning name too long",
251 ifconfig(argc, argv, 1, NULL);
254 errx(1, "interface %s does not exist", ifname);
258 /* Check for address family */
260 afp = af_getbyname(*argv);
265 if (getifaddrs(&ifap) != 0)
266 err(EXIT_FAILURE, "getifaddrs");
269 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
270 memset(&paifr, 0, sizeof(paifr));
271 strncpy(paifr.ifr_name, ifa->ifa_name, sizeof(paifr.ifr_name));
272 if (sizeof(paifr.ifr_addr) >= ifa->ifa_addr->sa_len) {
273 memcpy(&paifr.ifr_addr, ifa->ifa_addr,
274 ifa->ifa_addr->sa_len);
277 if (ifname != NULL && strcmp(ifname, ifa->ifa_name) != 0)
279 if (ifa->ifa_addr->sa_family == AF_LINK)
280 sdl = (const struct sockaddr_dl *) ifa->ifa_addr;
283 if (cp != NULL && strcmp(cp, ifa->ifa_name) == 0)
285 iflen = strlcpy(name, ifa->ifa_name, sizeof(name));
286 if (iflen >= sizeof(name)) {
287 warnx("%s: interface name too long, skipping",
293 if (downonly && (ifa->ifa_flags & IFF_UP) != 0)
295 if (uponly && (ifa->ifa_flags & IFF_UP) == 0)
299 * Are we just listing the interfaces?
309 ifconfig(argc, argv, 0, afp);
311 status(afp, sdl, ifa);
320 static struct afswtch *afs = NULL;
323 af_register(struct afswtch *p)
329 static struct afswtch *
330 af_getbyname(const char *name)
334 for (afp = afs; afp != NULL; afp = afp->af_next)
335 if (strcmp(afp->af_name, name) == 0)
340 static struct afswtch *
341 af_getbyfamily(int af)
345 for (afp = afs; afp != NULL; afp = afp->af_next)
346 if (afp->af_af == af)
352 af_other_status(int s)
355 uint8_t afmask[howmany(AF_MAX, NBBY)];
357 memset(afmask, 0, sizeof(afmask));
358 for (afp = afs; afp != NULL; afp = afp->af_next) {
359 if (afp->af_other_status == NULL)
361 if (afp->af_af != AF_UNSPEC && isset(afmask, afp->af_af))
363 afp->af_other_status(s);
364 setbit(afmask, afp->af_af);
369 af_all_tunnel_status(int s)
372 uint8_t afmask[howmany(AF_MAX, NBBY)];
374 memset(afmask, 0, sizeof(afmask));
375 for (afp = afs; afp != NULL; afp = afp->af_next) {
376 if (afp->af_status_tunnel == NULL)
378 if (afp->af_af != AF_UNSPEC && isset(afmask, afp->af_af))
380 afp->af_status_tunnel(s);
381 setbit(afmask, afp->af_af);
385 static struct cmd *cmds = NULL;
388 cmd_register(struct cmd *p)
394 static const struct cmd *
395 cmd_lookup(const char *name)
397 #define N(a) (sizeof(a)/sizeof(a[0]))
400 for (p = cmds; p != NULL; p = p->c_next)
401 if (strcmp(name, p->c_name) == 0)
408 callback_func *cb_func;
410 struct callback *cb_next;
412 static struct callback *callbacks = NULL;
415 callback_register(callback_func *func, void *arg)
419 cb = malloc(sizeof(struct callback));
421 errx(1, "unable to allocate memory for callback");
424 cb->cb_next = callbacks;
428 /* specially-handled commands */
429 static void setifaddr(const char *, int, int, const struct afswtch *);
430 static const struct cmd setifaddr_cmd = DEF_CMD("ifaddr", 0, setifaddr);
432 static void setifdstaddr(const char *, int, int, const struct afswtch *);
433 static const struct cmd setifdstaddr_cmd =
434 DEF_CMD("ifdstaddr", 0, setifdstaddr);
437 ifconfig(int argc, char *const *argv, int iscreate, const struct afswtch *uafp)
439 const struct afswtch *afp, *nafp;
443 strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
444 afp = uafp != NULL ? uafp : af_getbyname("inet");
446 ifr.ifr_addr.sa_family =
447 afp->af_af == AF_LINK || afp->af_af == AF_UNSPEC ?
448 AF_LOCAL : afp->af_af;
450 if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0 &&
451 (uafp != NULL || errno != EPROTONOSUPPORT ||
452 (s = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0))
453 err(1, "socket(family %u,SOCK_DGRAM", ifr.ifr_addr.sa_family);
458 p = cmd_lookup(*argv);
461 * Not a recognized command, choose between setting
462 * the interface address and the dst address.
464 p = (setaddr ? &setifdstaddr_cmd : &setifaddr_cmd);
466 if (p->c_u.c_func || p->c_u.c_func2) {
467 if (iscreate && !p->c_iscloneop) {
469 * Push the clone create callback so the new
470 * device is created and can be used for any
471 * remaining arguments.
475 errx(1, "internal error, no callback");
476 callbacks = cb->cb_next;
477 cb->cb_func(s, cb->cb_arg);
480 * Handle any address family spec that
481 * immediately follows and potentially
482 * recreate the socket.
484 nafp = af_getbyname(*argv);
494 if (p->c_parameter == NEXTARG) {
496 errx(1, "'%s' requires argument",
498 p->c_u.c_func(argv[1], 0, s, afp);
500 } else if (p->c_parameter == OPTARG) {
501 p->c_u.c_func(argv[1], 0, s, afp);
504 } else if (p->c_parameter == NEXTARG2) {
506 errx(1, "'%s' requires 2 arguments",
508 p->c_u.c_func2(argv[1], argv[2], s, afp);
509 argc -= 2, argv += 2;
511 p->c_u.c_func(*argv, p->c_parameter, s, afp);
517 * Do any post argument processing required by the address family.
519 if (afp->af_postproc != NULL)
520 afp->af_postproc(s, afp);
522 * Do deferred callbacks registered while processing
523 * command-line arguments.
525 for (cb = callbacks; cb != NULL; cb = cb->cb_next)
526 cb->cb_func(s, cb->cb_arg);
528 * Do deferred operations.
531 if (afp->af_ridreq == NULL || afp->af_difaddr == 0) {
532 warnx("interface %s cannot change %s addresses!",
539 strncpy(afp->af_ridreq, name, sizeof ifr.ifr_name);
540 ret = ioctl(s, afp->af_difaddr, afp->af_ridreq);
542 if (errno == EADDRNOTAVAIL && (doalias >= 0)) {
543 /* means no previous address for interface */
545 Perror("ioctl (SIOCDIFADDR)");
549 if (afp->af_addreq == NULL || afp->af_aifaddr == 0) {
550 warnx("interface %s cannot change %s addresses!",
555 if (newaddr && (setaddr || setmask)) {
556 strncpy(afp->af_addreq, name, sizeof ifr.ifr_name);
557 if (ioctl(s, afp->af_aifaddr, afp->af_addreq) < 0)
558 Perror("ioctl (SIOCAIFADDR)");
567 setifaddr(const char *addr, int param, int s, const struct afswtch *afp)
569 if (afp->af_getaddr == NULL)
572 * Delay the ioctl to set the interface addr until flags are all set.
573 * The address interpretation may depend on the flags,
574 * and the flags may change when the address is set.
577 if (doalias == 0 && afp->af_af != AF_LINK)
579 afp->af_getaddr(addr, (doalias >= 0 ? ADDR : RIDADDR));
583 settunnel(const char *src, const char *dst, int s, const struct afswtch *afp)
585 struct addrinfo *srcres, *dstres;
588 if (afp->af_settunnel == NULL) {
589 warn("address family %s does not support tunnel setup",
594 if ((ecode = getaddrinfo(src, NULL, NULL, &srcres)) != 0)
595 errx(1, "error in parsing address string: %s",
596 gai_strerror(ecode));
598 if ((ecode = getaddrinfo(dst, NULL, NULL, &dstres)) != 0)
599 errx(1, "error in parsing address string: %s",
600 gai_strerror(ecode));
602 if (srcres->ai_addr->sa_family != dstres->ai_addr->sa_family)
604 "source and destination address families do not match");
606 afp->af_settunnel(s, srcres, dstres);
608 freeaddrinfo(srcres);
609 freeaddrinfo(dstres);
614 deletetunnel(const char *vname, int param, int s, const struct afswtch *afp)
617 if (ioctl(s, SIOCDIFPHYADDR, &ifr) < 0)
618 err(1, "SIOCDIFPHYADDR");
622 setifnetmask(const char *addr, int dummy __unused, int s,
623 const struct afswtch *afp)
625 if (afp->af_getaddr != NULL) {
627 afp->af_getaddr(addr, MASK);
632 setifbroadaddr(const char *addr, int dummy __unused, int s,
633 const struct afswtch *afp)
635 if (afp->af_getaddr != NULL)
636 afp->af_getaddr(addr, DSTADDR);
640 setifipdst(const char *addr, int dummy __unused, int s,
641 const struct afswtch *afp)
643 const struct afswtch *inet;
645 inet = af_getbyname("inet");
648 inet->af_getaddr(addr, DSTADDR);
654 notealias(const char *addr, int param, int s, const struct afswtch *afp)
656 #define rqtosa(x) (&(((struct ifreq *)(afp->x))->ifr_addr))
657 if (setaddr && doalias == 0 && param < 0)
658 if (afp->af_addreq != NULL && afp->af_ridreq != NULL)
659 bcopy((caddr_t)rqtosa(af_addreq),
660 (caddr_t)rqtosa(af_ridreq),
661 rqtosa(af_addreq)->sa_len);
673 setifdstaddr(const char *addr, int param __unused, int s,
674 const struct afswtch *afp)
676 if (afp->af_getaddr != NULL)
677 afp->af_getaddr(addr, DSTADDR);
681 * Note: doing an SIOCIGIFFLAGS scribbles on the union portion
682 * of the ifreq structure, which may confuse other parts of ifconfig.
683 * Make a private copy so we can avoid that.
686 setifflags(const char *vname, int value, int s, const struct afswtch *afp)
691 bcopy((char *)&ifr, (char *)&my_ifr, sizeof(struct ifreq));
693 if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&my_ifr) < 0) {
694 Perror("ioctl (SIOCGIFFLAGS)");
697 strncpy(my_ifr.ifr_name, name, sizeof (my_ifr.ifr_name));
698 flags = (my_ifr.ifr_flags & 0xffff) | (my_ifr.ifr_flagshigh << 16);
705 my_ifr.ifr_flags = flags & 0xffff;
706 my_ifr.ifr_flagshigh = flags >> 16;
707 if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&my_ifr) < 0)
712 setifcap(const char *vname, int value, int s, const struct afswtch *afp)
716 if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) < 0) {
717 Perror("ioctl (SIOCGIFCAP)");
720 flags = ifr.ifr_curcap;
726 flags &= ifr.ifr_reqcap;
727 ifr.ifr_reqcap = flags;
728 if (ioctl(s, SIOCSIFCAP, (caddr_t)&ifr) < 0)
733 setifmetric(const char *val, int dummy __unused, int s,
734 const struct afswtch *afp)
736 strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
737 ifr.ifr_metric = atoi(val);
738 if (ioctl(s, SIOCSIFMETRIC, (caddr_t)&ifr) < 0)
739 warn("ioctl (set metric)");
743 setifmtu(const char *val, int dummy __unused, int s,
744 const struct afswtch *afp)
746 strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
747 ifr.ifr_mtu = atoi(val);
748 if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) < 0)
749 warn("ioctl (set mtu)");
753 setifname(const char *val, int dummy __unused, int s,
754 const struct afswtch *afp)
758 newname = strdup(val);
759 if (newname == NULL) {
760 warn("no memory to set ifname");
763 ifr.ifr_data = newname;
764 if (ioctl(s, SIOCSIFNAME, (caddr_t)&ifr) < 0) {
765 warn("ioctl (set name)");
769 strlcpy(name, newname, sizeof(name));
774 "\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6SMART\7RUNNING" \
775 "\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \
776 "\20MULTICAST\22PPROMISC\23MONITOR\24STATICARP\25NEEDSGIANT"
779 "\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING" \
780 "\10VLAN_HWCSUM\11TSO4\12TSO6\13LRO\14WOL_UCAST\15WOL_MCAST\16WOL_MAGIC"
783 * Print the status of the interface. If an address family was
784 * specified, show only it; otherwise, show them all.
787 status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
796 ifr.ifr_addr.sa_family = AF_LOCAL;
799 ifr.ifr_addr.sa_family =
800 afp->af_af == AF_LINK ? AF_LOCAL : afp->af_af;
802 strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
804 s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0);
806 err(1, "socket(family %u,SOCK_DGRAM)", ifr.ifr_addr.sa_family);
808 printf("%s: ", name);
809 printb("flags", ifa->ifa_flags, IFFBITS);
810 if (ioctl(s, SIOCGIFMETRIC, &ifr) != -1)
811 printf(" metric %d", ifr.ifr_metric);
812 if (ioctl(s, SIOCGIFMTU, &ifr) != -1)
813 printf(" mtu %d", ifr.ifr_mtu);
816 if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) == 0) {
817 if (ifr.ifr_curcap != 0) {
818 printb("\toptions", ifr.ifr_curcap, IFCAPBITS);
821 if (supmedia && ifr.ifr_reqcap != 0) {
822 printb("\tcapabilities", ifr.ifr_reqcap, IFCAPBITS);
829 for (ift = ifa; ift != NULL; ift = ift->ifa_next) {
830 if (ift->ifa_addr == NULL)
832 if (strcmp(ifa->ifa_name, ift->ifa_name) != 0)
835 const struct afswtch *p;
836 p = af_getbyfamily(ift->ifa_addr->sa_family);
837 if (p != NULL && p->af_status != NULL)
838 p->af_status(s, ift);
839 } else if (afp->af_af == ift->ifa_addr->sa_family)
840 afp->af_status(s, ift);
843 if (allfamilies || afp->af_af == AF_LINK) {
844 const struct afswtch *lafp;
847 * Hack; the link level address is received separately
848 * from the routing information so any address is not
849 * handled above. Cobble together an entry and invoke
850 * the status method specially.
852 lafp = af_getbyname("lladdr");
854 info.rti_info[RTAX_IFA] = (struct sockaddr *)sdl;
855 lafp->af_status(s, &info);
861 else if (afp->af_other_status != NULL)
862 afp->af_other_status(s);
864 strncpy(ifs.ifs_name, name, sizeof ifs.ifs_name);
865 if (ioctl(s, SIOCGIFSTATUS, &ifs) == 0)
866 printf("%s", ifs.ascii);
875 af_all_tunnel_status(s);
879 Perror(const char *cmd)
884 errx(1, "%s: no such interface", cmd);
888 errx(1, "%s: permission denied", cmd);
897 * Print a value a la the %b format of the kernel's printf
900 printb(const char *s, unsigned v, const char *bits)
905 if (bits && *bits == 8)
906 printf("%s=%o", s, v);
908 printf("%s=%x", s, v);
912 while ((i = *bits++) != '\0') {
913 if (v & (1 << (i-1))) {
917 for (; (c = *bits) > 32; bits++)
920 for (; *bits > 32; bits++)
928 ifmaybeload(const char *name)
930 #define MOD_PREFIX_LEN 3 /* "if_" */
931 struct module_stat mstat;
933 char ifkind[IFNAMSIZ + MOD_PREFIX_LEN], ifname[IFNAMSIZ], *dp;
936 /* loading suppressed by the user */
940 /* trim the interface number off the end */
941 strlcpy(ifname, name, sizeof(ifname));
942 for (dp = ifname; *dp != 0; dp++)
948 /* turn interface and unit into module name */
949 strcpy(ifkind, "if_");
950 strlcpy(ifkind + MOD_PREFIX_LEN, ifname,
951 sizeof(ifkind) - MOD_PREFIX_LEN);
953 /* scan files in kernel */
954 mstat.version = sizeof(struct module_stat);
955 for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) {
956 /* scan modules in file */
957 for (modid = kldfirstmod(fileid); modid > 0;
958 modid = modfnext(modid)) {
959 if (modstat(modid, &mstat) < 0)
961 /* strip bus name if present */
962 if ((cp = strchr(mstat.name, '/')) != NULL) {
967 /* already loaded? */
968 if (strncmp(ifname, cp, strlen(ifname) + 1) == 0 ||
969 strncmp(ifkind, cp, strlen(ifkind) + 1) == 0)
974 /* not present, we should try to load it */
978 static struct cmd basic_cmds[] = {
979 DEF_CMD("up", IFF_UP, setifflags),
980 DEF_CMD("down", -IFF_UP, setifflags),
981 DEF_CMD("arp", -IFF_NOARP, setifflags),
982 DEF_CMD("-arp", IFF_NOARP, setifflags),
983 DEF_CMD("debug", IFF_DEBUG, setifflags),
984 DEF_CMD("-debug", -IFF_DEBUG, setifflags),
985 DEF_CMD("promisc", IFF_PPROMISC, setifflags),
986 DEF_CMD("-promisc", -IFF_PPROMISC, setifflags),
987 DEF_CMD("add", IFF_UP, notealias),
988 DEF_CMD("alias", IFF_UP, notealias),
989 DEF_CMD("-alias", -IFF_UP, notealias),
990 DEF_CMD("delete", -IFF_UP, notealias),
991 DEF_CMD("remove", -IFF_UP, notealias),
993 #define EN_SWABIPS 0x1000
994 DEF_CMD("swabips", EN_SWABIPS, setifflags),
995 DEF_CMD("-swabips", -EN_SWABIPS, setifflags),
997 DEF_CMD_ARG("netmask", setifnetmask),
998 DEF_CMD_ARG("metric", setifmetric),
999 DEF_CMD_ARG("broadcast", setifbroadaddr),
1000 DEF_CMD_ARG("ipdst", setifipdst),
1001 DEF_CMD_ARG2("tunnel", settunnel),
1002 DEF_CMD("-tunnel", 0, deletetunnel),
1003 DEF_CMD("deletetunnel", 0, deletetunnel),
1004 DEF_CMD("link0", IFF_LINK0, setifflags),
1005 DEF_CMD("-link0", -IFF_LINK0, setifflags),
1006 DEF_CMD("link1", IFF_LINK1, setifflags),
1007 DEF_CMD("-link1", -IFF_LINK1, setifflags),
1008 DEF_CMD("link2", IFF_LINK2, setifflags),
1009 DEF_CMD("-link2", -IFF_LINK2, setifflags),
1010 DEF_CMD("monitor", IFF_MONITOR, setifflags),
1011 DEF_CMD("-monitor", -IFF_MONITOR, setifflags),
1012 DEF_CMD("staticarp", IFF_STATICARP, setifflags),
1013 DEF_CMD("-staticarp", -IFF_STATICARP, setifflags),
1014 DEF_CMD("rxcsum", IFCAP_RXCSUM, setifcap),
1015 DEF_CMD("-rxcsum", -IFCAP_RXCSUM, setifcap),
1016 DEF_CMD("txcsum", IFCAP_TXCSUM, setifcap),
1017 DEF_CMD("-txcsum", -IFCAP_TXCSUM, setifcap),
1018 DEF_CMD("netcons", IFCAP_NETCONS, setifcap),
1019 DEF_CMD("-netcons", -IFCAP_NETCONS, setifcap),
1020 DEF_CMD("polling", IFCAP_POLLING, setifcap),
1021 DEF_CMD("-polling", -IFCAP_POLLING, setifcap),
1022 DEF_CMD("tso", IFCAP_TSO, setifcap),
1023 DEF_CMD("-tso", -IFCAP_TSO, setifcap),
1024 DEF_CMD("lro", IFCAP_LRO, setifcap),
1025 DEF_CMD("-lro", -IFCAP_LRO, setifcap),
1026 DEF_CMD("wol", IFCAP_WOL, setifcap),
1027 DEF_CMD("-wol", -IFCAP_WOL, setifcap),
1028 DEF_CMD("wol_ucast", IFCAP_WOL_UCAST, setifcap),
1029 DEF_CMD("-wol_ucast", -IFCAP_WOL_UCAST, setifcap),
1030 DEF_CMD("wol_mcast", IFCAP_WOL_MCAST, setifcap),
1031 DEF_CMD("-wol_mcast", -IFCAP_WOL_MCAST, setifcap),
1032 DEF_CMD("wol_magic", IFCAP_WOL_MAGIC, setifcap),
1033 DEF_CMD("-wol_magic", -IFCAP_WOL_MAGIC, setifcap),
1034 DEF_CMD("normal", -IFF_LINK0, setifflags),
1035 DEF_CMD("compress", IFF_LINK0, setifflags),
1036 DEF_CMD("noicmp", IFF_LINK1, setifflags),
1037 DEF_CMD_ARG("mtu", setifmtu),
1038 DEF_CMD_ARG("name", setifname),
1041 static __constructor void
1044 #define N(a) (sizeof(a) / sizeof(a[0]))
1047 for (i = 0; i < N(basic_cmds); i++)
1048 cmd_register(&basic_cmds[i]);