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>
77 * Since "struct ifreq" is composed of various union members, callers
78 * should pay special attention to interprete the value.
79 * (.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, int addrcount,
98 struct sockaddr_dl *sdl, struct if_msghdr *ifm,
99 struct ifa_msghdr *ifam);
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 int need_nl = 0, count = 0;
145 const struct afswtch *afp = NULL;
146 int addrcount, ifindex;
147 struct if_msghdr *ifm, *nextifm;
148 struct ifa_msghdr *ifam;
149 struct sockaddr_dl *sdl;
150 char *buf, *lim, *next;
156 all = downonly = uponly = namesonly = verbose = 0;
158 /* Parse leading line options */
159 strlcpy(options, "adklmuv", sizeof(options));
160 for (p = opts; p != NULL; p = p->next)
161 strlcat(options, p->opt, sizeof(options));
162 while ((c = getopt(argc, argv, options)) != -1) {
164 case 'a': /* scan all interfaces */
167 case 'd': /* restrict scan to "down" interfaces */
173 case 'l': /* scan interface names only */
176 case 'm': /* show media choices in status */
179 case 'u': /* restrict scan to "up" interfaces */
186 for (p = opts; p != NULL; p = p->next)
187 if (p->opt[0] == c) {
199 /* -l cannot be used with -a or -m */
200 if (namesonly && (all || supmedia))
204 if (uponly && downonly)
207 /* no arguments is equivalent to '-a' */
208 if (!namesonly && argc < 1)
211 /* -a and -l allow an address family arg to limit the output */
212 if (all || namesonly) {
218 afp = af_getbyname(*argv);
221 if (afp->af_name != NULL)
223 /* leave with afp non-zero */
226 /* not listing, need an argument */
230 strncpy(name, *argv, sizeof(name));
233 /* check and maybe load support for this interface */
236 ifindex = if_nametoindex(name);
239 * NOTE: We must special-case the `create' command
240 * right here as we would otherwise fail when trying
241 * to find the interface.
243 if (argc > 0 && (strcmp(argv[0], "create") == 0 ||
244 strcmp(argv[0], "plumb") == 0)) {
245 ifconfig(argc, argv, NULL);
248 errx(1, "interface %s does not exist", name);
252 /* Check for address family */
254 afp = af_getbyname(*argv);
263 mib[3] = 0; /* address family */
264 mib[4] = NET_RT_IFLIST;
265 mib[5] = ifindex; /* interface index */
267 /* if particular family specified, only ask about it */
271 if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
272 errx(1, "iflist-sysctl-estimate");
273 if ((buf = malloc(needed)) == NULL)
275 if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) {
276 if (errno == ENOMEM && count++ < 10) {
277 warnx("Routing table grew, retrying");
282 errx(1, "actual retrieval of interface table");
289 ifm = (struct if_msghdr *)next;
291 if (ifm->ifm_type == RTM_IFINFO) {
292 if (ifm->ifm_data.ifi_datalen == 0)
293 ifm->ifm_data.ifi_datalen = sizeof(struct if_data);
294 sdl = (struct sockaddr_dl *)((char *)ifm + sizeof(struct if_msghdr) -
295 sizeof(struct if_data) + ifm->ifm_data.ifi_datalen);
296 flags = ifm->ifm_flags;
298 fprintf(stderr, "out of sync parsing NET_RT_IFLIST\n");
299 fprintf(stderr, "expected %d, got %d\n", RTM_IFINFO,
301 fprintf(stderr, "msglen = %d\n", ifm->ifm_msglen);
302 fprintf(stderr, "buf:%p, next:%p, lim:%p\n", buf, next,
307 next += ifm->ifm_msglen;
312 nextifm = (struct if_msghdr *)next;
314 if (nextifm->ifm_type != RTM_NEWADDR)
318 ifam = (struct ifa_msghdr *)nextifm;
321 next += nextifm->ifm_msglen;
323 memcpy(name, sdl->sdl_data,
324 sizeof(name) < sdl->sdl_nlen ?
325 sizeof(name)-1 : sdl->sdl_nlen);
326 name[sizeof(name) < sdl->sdl_nlen ?
327 sizeof(name)-1 : sdl->sdl_nlen] = '\0';
329 if (all || namesonly) {
331 if ((flags & IFF_UP) == 0)
332 continue; /* not up */
335 continue; /* not down */
337 if (afp == NULL || afp->af_af != AF_LINK ||
338 sdl->sdl_type == IFT_ETHER) {
349 ifconfig(argc, argv, afp);
351 status(afp, addrcount, sdl, ifm, ifam);
355 if (namesonly && need_nl > 0)
361 static struct afswtch *afs = NULL;
364 af_register(struct afswtch *p)
370 static struct afswtch *
371 af_getbyname(const char *name)
375 for (afp = afs; afp != NULL; afp = afp->af_next)
376 if (strcmp(afp->af_name, name) == 0)
381 static struct afswtch *
382 af_getbyfamily(int af)
386 for (afp = afs; afp != NULL; afp = afp->af_next)
387 if (afp->af_af == af)
393 af_other_status(int s)
396 uint8_t afmask[howmany(AF_MAX, NBBY)];
398 memset(afmask, 0, sizeof(afmask));
399 for (afp = afs; afp != NULL; afp = afp->af_next) {
400 if (afp->af_other_status == NULL)
402 if (afp->af_af != AF_UNSPEC && isset(afmask, afp->af_af))
404 afp->af_other_status(s);
405 setbit(afmask, afp->af_af);
410 af_all_tunnel_status(int s)
413 uint8_t afmask[howmany(AF_MAX, NBBY)];
415 memset(afmask, 0, sizeof(afmask));
416 for (afp = afs; afp != NULL; afp = afp->af_next) {
417 if (afp->af_status_tunnel == NULL)
419 if (afp->af_af != AF_UNSPEC && isset(afmask, afp->af_af))
421 afp->af_status_tunnel(s);
422 setbit(afmask, afp->af_af);
426 static struct cmd *cmds = NULL;
429 cmd_register(struct cmd *p)
435 static const struct cmd *
436 cmd_lookup(const char *name)
438 #define N(a) (sizeof(a)/sizeof(a[0]))
441 for (p = cmds; p != NULL; p = p->c_next)
442 if (strcmp(name, p->c_name) == 0)
449 callback_func *cb_func;
451 struct callback *cb_next;
453 static struct callback *callbacks = NULL;
456 callback_register(callback_func *func, void *arg)
460 cb = malloc(sizeof(struct callback));
462 errx(1, "unable to allocate memory for callback");
465 cb->cb_next = callbacks;
469 /* specially-handled commands */
470 static void setifaddr(const char *, int, int, const struct afswtch *);
471 static const struct cmd setifaddr_cmd = DEF_CMD("ifaddr", 0, setifaddr);
473 static void setifdstaddr(const char *, int, int, const struct afswtch *);
474 static const struct cmd setifdstaddr_cmd =
475 DEF_CMD("ifdstaddr", 0, setifdstaddr);
478 ifconfig(int argc, char *const *argv, const struct afswtch *afp)
484 afp = af_getbyname("inet");
485 ifr.ifr_addr.sa_family =
486 afp->af_af == AF_LINK || afp->af_af == AF_UNSPEC ?
487 AF_INET : afp->af_af;
488 strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
490 if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0)
491 err(1, "socket(family %u,SOCK_DGRAM", ifr.ifr_addr.sa_family);
496 p = cmd_lookup(*argv);
499 * Not a recognized command, choose between setting
500 * the interface address and the dst address.
502 p = (setaddr ? &setifdstaddr_cmd : &setifaddr_cmd);
504 if (p->c_u.c_func || p->c_u.c_func2) {
505 if (p->c_parameter == NEXTARG) {
507 errx(1, "'%s' requires argument",
509 p->c_u.c_func(argv[1], 0, s, afp);
511 } else if (p->c_parameter == OPTARG) {
512 p->c_u.c_func(argv[1], 0, s, afp);
515 } else if (p->c_parameter == NEXTARG2) {
517 errx(1, "'%s' requires 2 arguments",
519 p->c_u.c_func2(argv[1], argv[2], s, afp);
520 argc -= 2, argv += 2;
522 p->c_u.c_func(*argv, p->c_parameter, s, afp);
528 * Do any post argument processing required by the address family.
530 if (afp->af_postproc != NULL)
531 afp->af_postproc(s, afp);
533 * Do deferred callbacks registered while processing
534 * command-line arguments.
536 for (cb = callbacks; cb != NULL; cb = cb->cb_next)
537 cb->cb_func(s, cb->cb_arg);
539 * Do deferred operations.
542 if (afp->af_ridreq == NULL || afp->af_difaddr == 0) {
543 warnx("interface %s cannot change %s addresses!",
550 strncpy(afp->af_ridreq, name, sizeof ifr.ifr_name);
551 ret = ioctl(s, afp->af_difaddr, afp->af_ridreq);
553 if (errno == EADDRNOTAVAIL && (doalias >= 0)) {
554 /* means no previous address for interface */
556 Perror("ioctl (SIOCDIFADDR)");
560 if (afp->af_addreq == NULL || afp->af_aifaddr == 0) {
561 warnx("interface %s cannot change %s addresses!",
566 if (newaddr && (setaddr || setmask)) {
567 strncpy(afp->af_addreq, name, sizeof ifr.ifr_name);
568 if (ioctl(s, afp->af_aifaddr, afp->af_addreq) < 0)
569 Perror("ioctl (SIOCAIFADDR)");
578 setifaddr(const char *addr, int param, int s, const struct afswtch *afp)
580 if (afp->af_getaddr == NULL)
583 * Delay the ioctl to set the interface addr until flags are all set.
584 * The address interpretation may depend on the flags,
585 * and the flags may change when the address is set.
588 if (doalias == 0 && afp->af_af != AF_LINK)
590 afp->af_getaddr(addr, (doalias >= 0 ? ADDR : RIDADDR));
594 settunnel(const char *src, const char *dst, int s, const struct afswtch *afp)
596 struct addrinfo *srcres, *dstres;
599 if (afp->af_settunnel == NULL) {
600 warn("address family %s does not support tunnel setup",
605 if ((ecode = getaddrinfo(src, NULL, NULL, &srcres)) != 0)
606 errx(1, "error in parsing address string: %s",
607 gai_strerror(ecode));
609 if ((ecode = getaddrinfo(dst, NULL, NULL, &dstres)) != 0)
610 errx(1, "error in parsing address string: %s",
611 gai_strerror(ecode));
613 if (srcres->ai_addr->sa_family != dstres->ai_addr->sa_family)
615 "source and destination address families do not match");
617 afp->af_settunnel(s, srcres, dstres);
619 freeaddrinfo(srcres);
620 freeaddrinfo(dstres);
625 deletetunnel(const char *vname, int param, int s, const struct afswtch *afp)
628 if (ioctl(s, SIOCDIFPHYADDR, &ifr) < 0)
629 err(1, "SIOCDIFPHYADDR");
633 setifnetmask(const char *addr, int dummy __unused, int s,
634 const struct afswtch *afp)
636 if (afp->af_getaddr != NULL) {
638 afp->af_getaddr(addr, MASK);
643 setifbroadaddr(const char *addr, int dummy __unused, int s,
644 const struct afswtch *afp)
646 if (afp->af_getaddr != NULL)
647 afp->af_getaddr(addr, DSTADDR);
651 setifipdst(const char *addr, int dummy __unused, int s,
652 const struct afswtch *afp)
654 const struct afswtch *inet;
656 inet = af_getbyname("inet");
659 inet->af_getaddr(addr, DSTADDR);
666 notealias(const char *addr, int param, int s, const struct afswtch *afp)
668 #define rqtosa(x) (&(((struct ifreq *)(afp->x))->ifr_addr))
669 if (setaddr && doalias == 0 && param < 0)
670 if (afp->af_addreq != NULL && afp->af_ridreq != NULL)
671 bcopy((caddr_t)rqtosa(af_addreq),
672 (caddr_t)rqtosa(af_ridreq),
673 rqtosa(af_addreq)->sa_len);
685 setifdstaddr(const char *addr, int param __unused, int s,
686 const struct afswtch *afp)
688 if (afp->af_getaddr != NULL)
689 afp->af_getaddr(addr, DSTADDR);
693 * Note: doing an SIOCIGIFFLAGS scribbles on the union portion
694 * of the ifreq structure, which may confuse other parts of ifconfig.
695 * Make a private copy so we can avoid that.
698 setifflags(const char *vname, int value, int s, const struct afswtch *afp)
702 bcopy((char *)&ifr, (char *)&my_ifr, sizeof(struct ifreq));
704 if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&my_ifr) < 0) {
705 Perror("ioctl (SIOCGIFFLAGS)");
708 strncpy(my_ifr.ifr_name, name, sizeof (my_ifr.ifr_name));
709 flags = (my_ifr.ifr_flags & 0xffff) | (my_ifr.ifr_flagshigh << 16);
716 my_ifr.ifr_flags = flags & 0xffff;
717 my_ifr.ifr_flagshigh = flags >> 16;
718 if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&my_ifr) < 0)
723 setifcap(const char *vname, int value, int s, const struct afswtch *afp)
726 if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) < 0) {
727 Perror("ioctl (SIOCGIFCAP)");
730 flags = ifr.ifr_curcap;
736 flags &= ifr.ifr_reqcap;
737 ifr.ifr_reqcap = flags;
738 if (ioctl(s, SIOCSIFCAP, (caddr_t)&ifr) < 0)
743 setifmetric(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_metric = atoi(val);
748 if (ioctl(s, SIOCSIFMETRIC, (caddr_t)&ifr) < 0)
749 warn("ioctl (set metric)");
753 setifmtu(const char *val, int dummy __unused, int s,
754 const struct afswtch *afp)
756 strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
757 ifr.ifr_mtu = atoi(val);
758 if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) < 0)
759 warn("ioctl (set mtu)");
763 setifname(const char *val, int dummy __unused, int s,
764 const struct afswtch *afp)
768 newname = strdup(val);
769 if (newname == NULL) {
770 warn("no memory to set ifname");
773 ifr.ifr_data = newname;
774 if (ioctl(s, SIOCSIFNAME, (caddr_t)&ifr) < 0) {
775 warn("ioctl (set name)");
779 strlcpy(name, newname, sizeof(name));
784 * Expand the compacted form of addresses as returned via the
785 * configuration read via sysctl().
788 rt_xaddrs(caddr_t cp, caddr_t cplim, struct rt_addrinfo *rtinfo)
793 memset(rtinfo->rti_info, 0, sizeof(rtinfo->rti_info));
794 for (i = 0; (i < RTAX_MAX) && (cp < cplim); i++) {
795 if ((rtinfo->rti_addrs & (1 << i)) == 0)
797 rtinfo->rti_info[i] = sa = (struct sockaddr *)cp;
803 "\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6SMART\7RUNNING" \
804 "\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX\15LINK0\16LINK1\17LINK2" \
805 "\20MULTICAST\22PPROMISC\23MONITOR\24STATICARP\25NEEDSGIANT"
808 "\020\1RXCSUM\2TXCSUM\3NETCONS\4VLAN_MTU\5VLAN_HWTAGGING\6JUMBO_MTU\7POLLING" \
809 "\10VLAN_HWCSUM\11TSO4\12TSO6"
812 * Print the status of the interface. If an address family was
813 * specified, show only it; otherwise, show them all.
816 status(const struct afswtch *afp, int addrcount, struct sockaddr_dl *sdl,
817 struct if_msghdr *ifm, struct ifa_msghdr *ifam)
819 struct rt_addrinfo info;
825 afp = af_getbyname("inet");
829 ifr.ifr_addr.sa_family = afp->af_af == AF_LINK ? AF_INET : afp->af_af;
830 strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
832 s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0);
834 err(1, "socket(family %u,SOCK_DGRAM)", ifr.ifr_addr.sa_family);
836 printf("%s: ", name);
837 printb("flags", flags, IFFBITS);
838 if (ifm->ifm_data.ifi_metric)
839 printf(" metric %ld", ifm->ifm_data.ifi_metric);
840 if (ifm->ifm_data.ifi_mtu)
841 printf(" mtu %ld", ifm->ifm_data.ifi_mtu);
844 if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) == 0) {
845 if (ifr.ifr_curcap != 0) {
846 printb("\toptions", ifr.ifr_curcap, IFCAPBITS);
849 if (supmedia && ifr.ifr_reqcap != 0) {
850 printb("\tcapabilities", ifr.ifr_reqcap, IFCAPBITS);
857 while (addrcount > 0) {
858 info.rti_addrs = ifam->ifam_addrs;
859 /* Expand the compacted addresses */
860 rt_xaddrs((char *)(ifam + 1), ifam->ifam_msglen + (char *)ifam,
864 const struct afswtch *p;
865 p = af_getbyfamily(info.rti_info[RTAX_IFA]->sa_family);
866 if (p != NULL && p->af_status != NULL)
867 p->af_status(s, &info);
868 } else if (afp->af_af == info.rti_info[RTAX_IFA]->sa_family)
869 afp->af_status(s, &info);
871 ifam = (struct ifa_msghdr *)((char *)ifam + ifam->ifam_msglen);
873 if (allfamilies || afp->af_af == AF_LINK) {
874 const struct afswtch *lafp;
877 * Hack; the link level address is received separately
878 * from the routing information so any address is not
879 * handled above. Cobble together an entry and invoke
880 * the status method specially.
882 lafp = af_getbyname("lladdr");
884 info.rti_info[RTAX_IFA] = (struct sockaddr *)sdl;
885 lafp->af_status(s, &info);
890 else if (afp->af_other_status != NULL)
891 afp->af_other_status(s);
893 strncpy(ifs.ifs_name, name, sizeof ifs.ifs_name);
894 if (ioctl(s, SIOCGIFSTATUS, &ifs) == 0)
895 printf("%s", ifs.ascii);
904 af_all_tunnel_status(s);
908 Perror(const char *cmd)
913 errx(1, "%s: no such interface", cmd);
917 errx(1, "%s: permission denied", cmd);
926 * Print a value a la the %b format of the kernel's printf
929 printb(const char *s, unsigned v, const char *bits)
934 if (bits && *bits == 8)
935 printf("%s=%o", s, v);
937 printf("%s=%x", s, v);
941 while ((i = *bits++) != '\0') {
942 if (v & (1 << (i-1))) {
946 for (; (c = *bits) > 32; bits++)
949 for (; *bits > 32; bits++)
957 ifmaybeload(char *name)
959 struct module_stat mstat;
961 char ifkind[35], *cp, *dp;
963 /* turn interface and unit into module name */
964 strcpy(ifkind, "if_");
965 for (cp = name, dp = ifkind + 3;
966 (*cp != 0) && !isdigit(*cp); cp++, dp++)
970 /* scan files in kernel */
971 mstat.version = sizeof(struct module_stat);
972 for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) {
973 /* scan modules in file */
974 for (modid = kldfirstmod(fileid); modid > 0;
975 modid = modfnext(modid)) {
976 if (modstat(modid, &mstat) < 0)
978 /* strip bus name if present */
979 if ((cp = strchr(mstat.name, '/')) != NULL) {
984 /* already loaded? */
985 if (strncmp(name, cp, strlen(cp)) == 0 ||
986 strncmp(ifkind, cp, strlen(cp)) == 0)
991 /* not present, we should try to load it */
995 static struct cmd basic_cmds[] = {
996 DEF_CMD("up", IFF_UP, setifflags),
997 DEF_CMD("down", -IFF_UP, setifflags),
998 DEF_CMD("arp", -IFF_NOARP, setifflags),
999 DEF_CMD("-arp", IFF_NOARP, setifflags),
1000 DEF_CMD("debug", IFF_DEBUG, setifflags),
1001 DEF_CMD("-debug", -IFF_DEBUG, setifflags),
1002 DEF_CMD("promisc", IFF_PPROMISC, setifflags),
1003 DEF_CMD("-promisc", -IFF_PPROMISC, setifflags),
1004 DEF_CMD("add", IFF_UP, notealias),
1005 DEF_CMD("alias", IFF_UP, notealias),
1006 DEF_CMD("-alias", -IFF_UP, notealias),
1007 DEF_CMD("delete", -IFF_UP, notealias),
1008 DEF_CMD("remove", -IFF_UP, notealias),
1010 #define EN_SWABIPS 0x1000
1011 DEF_CMD("swabips", EN_SWABIPS, setifflags),
1012 DEF_CMD("-swabips", -EN_SWABIPS, setifflags),
1014 DEF_CMD_ARG("netmask", setifnetmask),
1015 DEF_CMD_ARG("metric", setifmetric),
1016 DEF_CMD_ARG("broadcast", setifbroadaddr),
1017 DEF_CMD_ARG("ipdst", setifipdst),
1018 DEF_CMD_ARG2("tunnel", settunnel),
1019 DEF_CMD("-tunnel", 0, deletetunnel),
1020 DEF_CMD("deletetunnel", 0, deletetunnel),
1021 DEF_CMD("link0", IFF_LINK0, setifflags),
1022 DEF_CMD("-link0", -IFF_LINK0, setifflags),
1023 DEF_CMD("link1", IFF_LINK1, setifflags),
1024 DEF_CMD("-link1", -IFF_LINK1, setifflags),
1025 DEF_CMD("link2", IFF_LINK2, setifflags),
1026 DEF_CMD("-link2", -IFF_LINK2, setifflags),
1027 DEF_CMD("monitor", IFF_MONITOR, setifflags),
1028 DEF_CMD("-monitor", -IFF_MONITOR, setifflags),
1029 DEF_CMD("staticarp", IFF_STATICARP, setifflags),
1030 DEF_CMD("-staticarp", -IFF_STATICARP, setifflags),
1031 DEF_CMD("rxcsum", IFCAP_RXCSUM, setifcap),
1032 DEF_CMD("-rxcsum", -IFCAP_RXCSUM, setifcap),
1033 DEF_CMD("txcsum", IFCAP_TXCSUM, setifcap),
1034 DEF_CMD("-txcsum", -IFCAP_TXCSUM, setifcap),
1035 DEF_CMD("netcons", IFCAP_NETCONS, setifcap),
1036 DEF_CMD("-netcons", -IFCAP_NETCONS, setifcap),
1037 DEF_CMD("polling", IFCAP_POLLING, setifcap),
1038 DEF_CMD("-polling", -IFCAP_POLLING, setifcap),
1039 DEF_CMD("tso", IFCAP_TSO, setifcap),
1040 DEF_CMD("-tso", -IFCAP_TSO, setifcap),
1041 DEF_CMD("normal", -IFF_LINK0, setifflags),
1042 DEF_CMD("compress", IFF_LINK0, setifflags),
1043 DEF_CMD("noicmp", IFF_LINK1, setifflags),
1044 DEF_CMD_ARG("mtu", setifmtu),
1045 DEF_CMD_ARG("name", setifname),
1048 static __constructor void
1051 #define N(a) (sizeof(a) / sizeof(a[0]))
1054 for (i = 0; i < N(basic_cmds); i++)
1055 cmd_register(&basic_cmds[i]);