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, const struct afswtch *afp);
97 static void status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
99 static void tunnel_status(int s);
100 static void usage(void);
102 static struct afswtch *af_getbyname(const char *name);
103 static struct afswtch *af_getbyfamily(int af);
104 static void af_other_status(int);
106 static struct option *opts = NULL;
109 opt_register(struct option *p)
121 /* XXX not right but close enough for now */
123 for (p = opts; p != NULL; p = p->next) {
124 strlcat(options, p->opt_usage, sizeof(options));
125 strlcat(options, " ", sizeof(options));
129 "usage: ifconfig %sinterface address_family [address [dest_address]]\n"
131 " ifconfig interface create\n"
132 " ifconfig -a %s[-d] [-m] [-u] [-v] [address_family]\n"
133 " ifconfig -l [-d] [-u] [address_family]\n"
134 " ifconfig %s[-d] [-m] [-u] [-v]\n",
135 options, options, options);
140 main(int argc, char *argv[])
142 int c, all, namesonly, downonly, uponly;
143 const struct afswtch *afp = NULL;
145 struct ifaddrs *ifap, *ifa;
147 const struct sockaddr_dl *sdl;
148 char options[1024], *cp;
153 all = downonly = uponly = namesonly = verbose = 0;
155 /* Parse leading line options */
156 strlcpy(options, "adklmuv", sizeof(options));
157 for (p = opts; p != NULL; p = p->next)
158 strlcat(options, p->opt, sizeof(options));
159 while ((c = getopt(argc, argv, options)) != -1) {
161 case 'a': /* scan all interfaces */
164 case 'd': /* restrict scan to "down" interfaces */
170 case 'l': /* scan interface names only */
173 case 'm': /* show media choices in status */
176 case 'u': /* restrict scan to "up" interfaces */
183 for (p = opts; p != NULL; p = p->next)
184 if (p->opt[0] == c) {
196 /* -l cannot be used with -a or -m */
197 if (namesonly && (all || supmedia))
201 if (uponly && downonly)
204 /* no arguments is equivalent to '-a' */
205 if (!namesonly && argc < 1)
208 /* -a and -l allow an address family arg to limit the output */
209 if (all || namesonly) {
216 afp = af_getbyname(*argv);
219 if (afp->af_name != NULL)
221 /* leave with afp non-zero */
224 /* not listing, need an argument */
231 ifindex = if_nametoindex(ifname);
234 * NOTE: We must special-case the `create' command
235 * right here as we would otherwise fail when trying
236 * to find the interface.
238 if (argc > 0 && (strcmp(argv[0], "create") == 0 ||
239 strcmp(argv[0], "plumb") == 0)) {
240 iflen = strlcpy(name, ifname, sizeof(name));
241 if (iflen >= sizeof(name))
242 errx(1, "%s: cloning name too long",
245 ifconfig(argc, argv, NULL);
248 errx(1, "interface %s does not exist", ifname);
252 /* Check for address family */
254 afp = af_getbyname(*argv);
259 if (getifaddrs(&ifap) != 0)
260 err(EXIT_FAILURE, "getifaddrs");
263 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
264 memset(&paifr, 0, sizeof(paifr));
265 strncpy(paifr.ifr_name, ifa->ifa_name, sizeof(paifr.ifr_name));
266 if (sizeof(paifr.ifr_addr) >= ifa->ifa_addr->sa_len) {
267 memcpy(&paifr.ifr_addr, ifa->ifa_addr,
268 ifa->ifa_addr->sa_len);
271 if (ifname != NULL && strcmp(ifname, ifa->ifa_name) != 0)
273 if (ifa->ifa_addr->sa_family == AF_LINK)
274 sdl = (const struct sockaddr_dl *) ifa->ifa_addr;
277 if (cp != NULL && strcmp(cp, ifa->ifa_name) == 0)
279 iflen = strlcpy(name, ifa->ifa_name, sizeof(name));
280 if (iflen >= sizeof(name)) {
281 warnx("%s: interface name too long, skipping",
287 if (downonly && (ifa->ifa_flags & IFF_UP) != 0)
289 if (uponly && (ifa->ifa_flags & IFF_UP) == 0)
293 * Are we just listing the interfaces?
303 ifconfig(argc, argv, afp);
305 status(afp, sdl, ifa);
314 static struct afswtch *afs = NULL;
317 af_register(struct afswtch *p)
323 static struct afswtch *
324 af_getbyname(const char *name)
328 for (afp = afs; afp != NULL; afp = afp->af_next)
329 if (strcmp(afp->af_name, name) == 0)
334 static struct afswtch *
335 af_getbyfamily(int af)
339 for (afp = afs; afp != NULL; afp = afp->af_next)
340 if (afp->af_af == af)
346 af_other_status(int s)
349 uint8_t afmask[howmany(AF_MAX, NBBY)];
351 memset(afmask, 0, sizeof(afmask));
352 for (afp = afs; afp != NULL; afp = afp->af_next) {
353 if (afp->af_other_status == NULL)
355 if (afp->af_af != AF_UNSPEC && isset(afmask, afp->af_af))
357 afp->af_other_status(s);
358 setbit(afmask, afp->af_af);
363 af_all_tunnel_status(int s)
366 uint8_t afmask[howmany(AF_MAX, NBBY)];
368 memset(afmask, 0, sizeof(afmask));
369 for (afp = afs; afp != NULL; afp = afp->af_next) {
370 if (afp->af_status_tunnel == NULL)
372 if (afp->af_af != AF_UNSPEC && isset(afmask, afp->af_af))
374 afp->af_status_tunnel(s);
375 setbit(afmask, afp->af_af);
379 static struct cmd *cmds = NULL;
382 cmd_register(struct cmd *p)
388 static const struct cmd *
389 cmd_lookup(const char *name)
391 #define N(a) (sizeof(a)/sizeof(a[0]))
394 for (p = cmds; p != NULL; p = p->c_next)
395 if (strcmp(name, p->c_name) == 0)
402 callback_func *cb_func;
404 struct callback *cb_next;
406 static struct callback *callbacks = NULL;
409 callback_register(callback_func *func, void *arg)
413 cb = malloc(sizeof(struct callback));
415 errx(1, "unable to allocate memory for callback");
418 cb->cb_next = callbacks;
422 /* specially-handled commands */
423 static void setifaddr(const char *, int, int, const struct afswtch *);
424 static const struct cmd setifaddr_cmd = DEF_CMD("ifaddr", 0, setifaddr);
426 static void setifdstaddr(const char *, int, int, const struct afswtch *);
427 static const struct cmd setifdstaddr_cmd =
428 DEF_CMD("ifdstaddr", 0, setifdstaddr);
431 ifconfig(int argc, char *const *argv, const struct afswtch *afp)
437 afp = af_getbyname("inet");
438 ifr.ifr_addr.sa_family =
439 afp->af_af == AF_LINK || afp->af_af == AF_UNSPEC ?
440 AF_INET : afp->af_af;
441 strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
443 if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0)
444 err(1, "socket(family %u,SOCK_DGRAM", ifr.ifr_addr.sa_family);
449 p = cmd_lookup(*argv);
452 * Not a recognized command, choose between setting
453 * the interface address and the dst address.
455 p = (setaddr ? &setifdstaddr_cmd : &setifaddr_cmd);
457 if (p->c_u.c_func || p->c_u.c_func2) {
458 if (p->c_parameter == NEXTARG) {
460 errx(1, "'%s' requires argument",
462 p->c_u.c_func(argv[1], 0, s, afp);
464 } else if (p->c_parameter == OPTARG) {
465 p->c_u.c_func(argv[1], 0, s, afp);
468 } else if (p->c_parameter == NEXTARG2) {
470 errx(1, "'%s' requires 2 arguments",
472 p->c_u.c_func2(argv[1], argv[2], s, afp);
473 argc -= 2, argv += 2;
475 p->c_u.c_func(*argv, p->c_parameter, s, afp);
481 * Do any post argument processing required by the address family.
483 if (afp->af_postproc != NULL)
484 afp->af_postproc(s, afp);
486 * Do deferred callbacks registered while processing
487 * command-line arguments.
489 for (cb = callbacks; cb != NULL; cb = cb->cb_next)
490 cb->cb_func(s, cb->cb_arg);
492 * Do deferred operations.
495 if (afp->af_ridreq == NULL || afp->af_difaddr == 0) {
496 warnx("interface %s cannot change %s addresses!",
503 strncpy(afp->af_ridreq, name, sizeof ifr.ifr_name);
504 ret = ioctl(s, afp->af_difaddr, afp->af_ridreq);
506 if (errno == EADDRNOTAVAIL && (doalias >= 0)) {
507 /* means no previous address for interface */
509 Perror("ioctl (SIOCDIFADDR)");
513 if (afp->af_addreq == NULL || afp->af_aifaddr == 0) {
514 warnx("interface %s cannot change %s addresses!",
519 if (newaddr && (setaddr || setmask)) {
520 strncpy(afp->af_addreq, name, sizeof ifr.ifr_name);
521 if (ioctl(s, afp->af_aifaddr, afp->af_addreq) < 0)
522 Perror("ioctl (SIOCAIFADDR)");
531 setifaddr(const char *addr, int param, int s, const struct afswtch *afp)
533 if (afp->af_getaddr == NULL)
536 * Delay the ioctl to set the interface addr until flags are all set.
537 * The address interpretation may depend on the flags,
538 * and the flags may change when the address is set.
541 if (doalias == 0 && afp->af_af != AF_LINK)
543 afp->af_getaddr(addr, (doalias >= 0 ? ADDR : RIDADDR));
547 settunnel(const char *src, const char *dst, int s, const struct afswtch *afp)
549 struct addrinfo *srcres, *dstres;
552 if (afp->af_settunnel == NULL) {
553 warn("address family %s does not support tunnel setup",
558 if ((ecode = getaddrinfo(src, NULL, NULL, &srcres)) != 0)
559 errx(1, "error in parsing address string: %s",
560 gai_strerror(ecode));
562 if ((ecode = getaddrinfo(dst, NULL, NULL, &dstres)) != 0)
563 errx(1, "error in parsing address string: %s",
564 gai_strerror(ecode));
566 if (srcres->ai_addr->sa_family != dstres->ai_addr->sa_family)
568 "source and destination address families do not match");
570 afp->af_settunnel(s, srcres, dstres);
572 freeaddrinfo(srcres);
573 freeaddrinfo(dstres);
578 deletetunnel(const char *vname, int param, int s, const struct afswtch *afp)
581 if (ioctl(s, SIOCDIFPHYADDR, &ifr) < 0)
582 err(1, "SIOCDIFPHYADDR");
586 setifnetmask(const char *addr, int dummy __unused, int s,
587 const struct afswtch *afp)
589 if (afp->af_getaddr != NULL) {
591 afp->af_getaddr(addr, MASK);
596 setifbroadaddr(const char *addr, int dummy __unused, int s,
597 const struct afswtch *afp)
599 if (afp->af_getaddr != NULL)
600 afp->af_getaddr(addr, DSTADDR);
604 setifipdst(const char *addr, int dummy __unused, int s,
605 const struct afswtch *afp)
607 const struct afswtch *inet;
609 inet = af_getbyname("inet");
612 inet->af_getaddr(addr, DSTADDR);
619 notealias(const char *addr, int param, int s, const struct afswtch *afp)
621 #define rqtosa(x) (&(((struct ifreq *)(afp->x))->ifr_addr))
622 if (setaddr && doalias == 0 && param < 0)
623 if (afp->af_addreq != NULL && afp->af_ridreq != NULL)
624 bcopy((caddr_t)rqtosa(af_addreq),
625 (caddr_t)rqtosa(af_ridreq),
626 rqtosa(af_addreq)->sa_len);
638 setifdstaddr(const char *addr, int param __unused, int s,
639 const struct afswtch *afp)
641 if (afp->af_getaddr != NULL)
642 afp->af_getaddr(addr, DSTADDR);
646 * Note: doing an SIOCIGIFFLAGS scribbles on the union portion
647 * of the ifreq structure, which may confuse other parts of ifconfig.
648 * Make a private copy so we can avoid that.
651 setifflags(const char *vname, int value, int s, const struct afswtch *afp)
656 bcopy((char *)&ifr, (char *)&my_ifr, sizeof(struct ifreq));
658 if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&my_ifr) < 0) {
659 Perror("ioctl (SIOCGIFFLAGS)");
662 strncpy(my_ifr.ifr_name, name, sizeof (my_ifr.ifr_name));
663 flags = (my_ifr.ifr_flags & 0xffff) | (my_ifr.ifr_flagshigh << 16);
670 my_ifr.ifr_flags = flags & 0xffff;
671 my_ifr.ifr_flagshigh = flags >> 16;
672 if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&my_ifr) < 0)
677 setifcap(const char *vname, int value, int s, const struct afswtch *afp)
681 if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) < 0) {
682 Perror("ioctl (SIOCGIFCAP)");
685 flags = ifr.ifr_curcap;
691 flags &= ifr.ifr_reqcap;
692 ifr.ifr_reqcap = flags;
693 if (ioctl(s, SIOCSIFCAP, (caddr_t)&ifr) < 0)
698 setifmetric(const char *val, int dummy __unused, int s,
699 const struct afswtch *afp)
701 strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
702 ifr.ifr_metric = atoi(val);
703 if (ioctl(s, SIOCSIFMETRIC, (caddr_t)&ifr) < 0)
704 warn("ioctl (set metric)");
708 setifmtu(const char *val, int dummy __unused, int s,
709 const struct afswtch *afp)
711 strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
712 ifr.ifr_mtu = atoi(val);
713 if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) < 0)
714 warn("ioctl (set mtu)");
718 setifname(const char *val, int dummy __unused, int s,
719 const struct afswtch *afp)
723 newname = strdup(val);
724 if (newname == NULL) {
725 warn("no memory to set ifname");
728 ifr.ifr_data = newname;
729 if (ioctl(s, SIOCSIFNAME, (caddr_t)&ifr) < 0) {
730 warn("ioctl (set name)");
734 strlcpy(name, newname, sizeof(name));
739 "\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6SMART\7RUNNING" \
740 "\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \
741 "\20MULTICAST\22PPROMISC\23MONITOR\24STATICARP\25NEEDSGIANT"
744 "\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING" \
745 "\10VLAN_HWCSUM\11TSO4\12TSO6"
748 * Print the status of the interface. If an address family was
749 * specified, show only it; otherwise, show them all.
752 status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
761 afp = af_getbyname("inet");
765 ifr.ifr_addr.sa_family = afp->af_af == AF_LINK ? AF_INET : afp->af_af;
766 strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
768 s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0);
770 err(1, "socket(family %u,SOCK_DGRAM)", ifr.ifr_addr.sa_family);
772 printf("%s: ", name);
773 printb("flags", ifa->ifa_flags, IFFBITS);
774 if (ioctl(s, SIOCGIFMETRIC, &ifr) != -1)
775 printf(" metric %d", ifr.ifr_metric);
776 if (ioctl(s, SIOCGIFMTU, &ifr) != -1)
777 printf(" mtu %d", ifr.ifr_mtu);
780 if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) == 0) {
781 if (ifr.ifr_curcap != 0) {
782 printb("\toptions", ifr.ifr_curcap, IFCAPBITS);
785 if (supmedia && ifr.ifr_reqcap != 0) {
786 printb("\tcapabilities", ifr.ifr_reqcap, IFCAPBITS);
793 for (ift = ifa; ift != NULL; ift = ift->ifa_next) {
794 if (ift->ifa_addr == NULL)
796 if (strcmp(ifa->ifa_name, ift->ifa_name) != 0)
799 const struct afswtch *p;
800 p = af_getbyfamily(ift->ifa_addr->sa_family);
801 if (p != NULL && p->af_status != NULL)
802 p->af_status(s, ift);
803 } else if (afp->af_af == ift->ifa_addr->sa_family)
804 afp->af_status(s, ift);
807 if (allfamilies || afp->af_af == AF_LINK) {
808 const struct afswtch *lafp;
811 * Hack; the link level address is received separately
812 * from the routing information so any address is not
813 * handled above. Cobble together an entry and invoke
814 * the status method specially.
816 lafp = af_getbyname("lladdr");
818 info.rti_info[RTAX_IFA] = (struct sockaddr *)sdl;
819 lafp->af_status(s, &info);
825 else if (afp->af_other_status != NULL)
826 afp->af_other_status(s);
828 strncpy(ifs.ifs_name, name, sizeof ifs.ifs_name);
829 if (ioctl(s, SIOCGIFSTATUS, &ifs) == 0)
830 printf("%s", ifs.ascii);
839 af_all_tunnel_status(s);
843 Perror(const char *cmd)
848 errx(1, "%s: no such interface", cmd);
852 errx(1, "%s: permission denied", cmd);
861 * Print a value a la the %b format of the kernel's printf
864 printb(const char *s, unsigned v, const char *bits)
869 if (bits && *bits == 8)
870 printf("%s=%o", s, v);
872 printf("%s=%x", s, v);
876 while ((i = *bits++) != '\0') {
877 if (v & (1 << (i-1))) {
881 for (; (c = *bits) > 32; bits++)
884 for (; *bits > 32; bits++)
892 ifmaybeload(const char *name)
894 struct module_stat mstat;
896 char ifkind[35], *dp;
899 /* turn interface and unit into module name */
900 strcpy(ifkind, "if_");
901 for (cp = name, dp = ifkind + 3;
902 (*cp != 0) && !isdigit(*cp); cp++, dp++)
906 /* scan files in kernel */
907 mstat.version = sizeof(struct module_stat);
908 for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) {
909 /* scan modules in file */
910 for (modid = kldfirstmod(fileid); modid > 0;
911 modid = modfnext(modid)) {
912 if (modstat(modid, &mstat) < 0)
914 /* strip bus name if present */
915 if ((cp = strchr(mstat.name, '/')) != NULL) {
920 /* already loaded? */
921 if (strncmp(name, cp, strlen(cp)) == 0 ||
922 strncmp(ifkind, cp, strlen(cp)) == 0)
927 /* not present, we should try to load it */
931 static struct cmd basic_cmds[] = {
932 DEF_CMD("up", IFF_UP, setifflags),
933 DEF_CMD("down", -IFF_UP, setifflags),
934 DEF_CMD("arp", -IFF_NOARP, setifflags),
935 DEF_CMD("-arp", IFF_NOARP, setifflags),
936 DEF_CMD("debug", IFF_DEBUG, setifflags),
937 DEF_CMD("-debug", -IFF_DEBUG, setifflags),
938 DEF_CMD("promisc", IFF_PPROMISC, setifflags),
939 DEF_CMD("-promisc", -IFF_PPROMISC, setifflags),
940 DEF_CMD("add", IFF_UP, notealias),
941 DEF_CMD("alias", IFF_UP, notealias),
942 DEF_CMD("-alias", -IFF_UP, notealias),
943 DEF_CMD("delete", -IFF_UP, notealias),
944 DEF_CMD("remove", -IFF_UP, notealias),
946 #define EN_SWABIPS 0x1000
947 DEF_CMD("swabips", EN_SWABIPS, setifflags),
948 DEF_CMD("-swabips", -EN_SWABIPS, setifflags),
950 DEF_CMD_ARG("netmask", setifnetmask),
951 DEF_CMD_ARG("metric", setifmetric),
952 DEF_CMD_ARG("broadcast", setifbroadaddr),
953 DEF_CMD_ARG("ipdst", setifipdst),
954 DEF_CMD_ARG2("tunnel", settunnel),
955 DEF_CMD("-tunnel", 0, deletetunnel),
956 DEF_CMD("deletetunnel", 0, deletetunnel),
957 DEF_CMD("link0", IFF_LINK0, setifflags),
958 DEF_CMD("-link0", -IFF_LINK0, setifflags),
959 DEF_CMD("link1", IFF_LINK1, setifflags),
960 DEF_CMD("-link1", -IFF_LINK1, setifflags),
961 DEF_CMD("link2", IFF_LINK2, setifflags),
962 DEF_CMD("-link2", -IFF_LINK2, setifflags),
963 DEF_CMD("monitor", IFF_MONITOR, setifflags),
964 DEF_CMD("-monitor", -IFF_MONITOR, setifflags),
965 DEF_CMD("staticarp", IFF_STATICARP, setifflags),
966 DEF_CMD("-staticarp", -IFF_STATICARP, setifflags),
967 DEF_CMD("rxcsum", IFCAP_RXCSUM, setifcap),
968 DEF_CMD("-rxcsum", -IFCAP_RXCSUM, setifcap),
969 DEF_CMD("txcsum", IFCAP_TXCSUM, setifcap),
970 DEF_CMD("-txcsum", -IFCAP_TXCSUM, setifcap),
971 DEF_CMD("netcons", IFCAP_NETCONS, setifcap),
972 DEF_CMD("-netcons", -IFCAP_NETCONS, setifcap),
973 DEF_CMD("polling", IFCAP_POLLING, setifcap),
974 DEF_CMD("-polling", -IFCAP_POLLING, setifcap),
975 DEF_CMD("tso", IFCAP_TSO, setifcap),
976 DEF_CMD("-tso", -IFCAP_TSO, setifcap),
977 DEF_CMD("normal", -IFF_LINK0, setifflags),
978 DEF_CMD("compress", IFF_LINK0, setifflags),
979 DEF_CMD("noicmp", IFF_LINK1, setifflags),
980 DEF_CMD_ARG("mtu", setifmtu),
981 DEF_CMD_ARG("name", setifname),
984 static __constructor void
987 #define N(a) (sizeof(a) / sizeof(a[0]))
990 for (i = 0; i < N(basic_cmds); i++)
991 cmd_register(&basic_cmds[i]);