1 /* $NetBSD: ifconfig.c,v 1.34 1997/04/21 01:17:58 lukem Exp $ */
5 * Copyright (c) 1997 Jason R. Thorpe.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed for the NetBSD Project
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * Copyright (c) 1983, 1993
38 * The Regents of the University of California. All rights reserved.
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
43 * 1. Redistributions of source code must retain the above copyright
44 * notice, this list of conditions and the following disclaimer.
45 * 2. Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following disclaimer in the
47 * documentation and/or other materials provided with the distribution.
48 * 4. Neither the name of the University nor the names of its contributors
49 * may be used to endorse or promote products derived from this software
50 * without specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65 #include <sys/param.h>
66 #include <sys/ioctl.h>
67 #include <sys/socket.h>
68 #include <sys/sysctl.h>
72 #include <net/if_dl.h>
73 #include <net/if_types.h>
74 #include <net/if_media.h>
75 #include <net/route.h>
88 static void domediaopt(const char *, int, int);
89 static int get_media_subtype(int, const char *);
90 static int get_media_mode(int, const char *);
91 static int get_media_options(int, const char *);
92 static int lookup_media_word(struct ifmedia_description *, const char *);
93 static void print_media_word(int, int);
94 static void print_media_word_ifconfig(int);
96 static struct ifmedia_description *get_toptype_desc(int);
97 static struct ifmedia_type_to_subtype *get_toptype_ttos(int);
98 static struct ifmedia_description *get_subtype_desc(int,
99 struct ifmedia_type_to_subtype *ttos);
101 #define IFM_OPMODE(x) \
102 ((x) & (IFM_IEEE80211_ADHOC | IFM_IEEE80211_HOSTAP | \
103 IFM_IEEE80211_IBSS | IFM_IEEE80211_WDS | IFM_IEEE80211_MONITOR | \
105 #define IFM_IEEE80211_STA 0
110 struct ifmediareq ifmr;
114 (void) memset(&ifmr, 0, sizeof(ifmr));
115 (void) strlcpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name));
118 * Check if interface supports extended media types.
120 if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)&ifmr) < 0)
122 if (xmedia == 0 && ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
124 * Interface doesn't support SIOC{G,S}IFMEDIA.
129 if (ifmr.ifm_count == 0) {
130 warnx("%s: no media types?", name);
134 media_list = (int *)malloc(ifmr.ifm_count * sizeof(int));
135 if (media_list == NULL)
137 ifmr.ifm_ulist = media_list;
140 if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)&ifmr) < 0)
141 err(1, "SIOCGIFXMEDIA");
143 if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0)
144 err(1, "SIOCGIFMEDIA");
148 print_media_word(ifmr.ifm_current, 1);
149 if (ifmr.ifm_active != ifmr.ifm_current) {
152 print_media_word(ifmr.ifm_active, 0);
158 if (ifmr.ifm_status & IFM_AVALID) {
159 printf("\tstatus: ");
160 switch (IFM_TYPE(ifmr.ifm_active)) {
163 if (ifmr.ifm_status & IFM_ACTIVE)
166 printf("no carrier");
171 if (ifmr.ifm_status & IFM_ACTIVE)
178 if (ifmr.ifm_status & IFM_ACTIVE) {
179 /* NB: only sta mode associates */
180 if (IFM_OPMODE(ifmr.ifm_active) == IFM_IEEE80211_STA)
181 printf("associated");
185 printf("no carrier");
191 if (ifmr.ifm_count > 0 && supmedia) {
192 printf("\tsupported media:\n");
193 for (i = 0; i < ifmr.ifm_count; i++) {
195 print_media_word_ifconfig(media_list[i]);
204 ifmedia_getstate(int s)
206 static struct ifmediareq *ifmr = NULL;
211 ifmr = (struct ifmediareq *)malloc(sizeof(struct ifmediareq));
215 (void) memset(ifmr, 0, sizeof(struct ifmediareq));
216 (void) strlcpy(ifmr->ifm_name, name,
217 sizeof(ifmr->ifm_name));
220 ifmr->ifm_ulist = NULL;
223 * We must go through the motions of reading all
224 * supported media because we need to know both
225 * the current media type and the top-level type.
228 if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)ifmr) < 0) {
231 if (xmedia == 0 && ioctl(s, SIOCGIFMEDIA, (caddr_t)ifmr) < 0) {
232 err(1, "SIOCGIFMEDIA");
235 if (ifmr->ifm_count == 0)
236 errx(1, "%s: no media types?", name);
238 mwords = (int *)malloc(ifmr->ifm_count * sizeof(int));
242 ifmr->ifm_ulist = mwords;
244 if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)ifmr) < 0)
245 err(1, "SIOCGIFXMEDIA");
247 if (ioctl(s, SIOCGIFMEDIA, (caddr_t)ifmr) < 0)
248 err(1, "SIOCGIFMEDIA");
256 setifmediacallback(int s, void *arg)
258 struct ifmediareq *ifmr = (struct ifmediareq *)arg;
259 static int did_it = 0;
262 ifr.ifr_media = ifmr->ifm_current;
263 if (ioctl(s, SIOCSIFMEDIA, (caddr_t)&ifr) < 0)
264 err(1, "SIOCSIFMEDIA (media)");
265 free(ifmr->ifm_ulist);
272 setmedia(const char *val, int d, int s, const struct afswtch *afp)
274 struct ifmediareq *ifmr;
277 ifmr = ifmedia_getstate(s);
280 * We are primarily concerned with the top-level type.
281 * However, "current" may be only IFM_NONE, so we just look
282 * for the top-level type in the first "supported type"
285 * (I'm assuming that all supported media types for a given
286 * interface will be the same top-level type..)
288 subtype = get_media_subtype(IFM_TYPE(ifmr->ifm_ulist[0]), val);
290 strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
291 ifr.ifr_media = (ifmr->ifm_current & IFM_IMASK) |
292 IFM_TYPE(ifmr->ifm_ulist[0]) | subtype;
294 ifmr->ifm_current = ifr.ifr_media;
295 callback_register(setifmediacallback, (void *)ifmr);
299 setmediaopt(const char *val, int d, int s, const struct afswtch *afp)
302 domediaopt(val, 0, s);
306 unsetmediaopt(const char *val, int d, int s, const struct afswtch *afp)
309 domediaopt(val, 1, s);
313 domediaopt(const char *val, int clear, int s)
315 struct ifmediareq *ifmr;
318 ifmr = ifmedia_getstate(s);
320 options = get_media_options(IFM_TYPE(ifmr->ifm_ulist[0]), val);
322 strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
323 ifr.ifr_media = ifmr->ifm_current;
325 ifr.ifr_media &= ~options;
327 if (options & IFM_HDX) {
328 ifr.ifr_media &= ~IFM_FDX;
331 ifr.ifr_media |= options;
333 ifmr->ifm_current = ifr.ifr_media;
334 callback_register(setifmediacallback, (void *)ifmr);
338 setmediainst(const char *val, int d, int s, const struct afswtch *afp)
340 struct ifmediareq *ifmr;
343 ifmr = ifmedia_getstate(s);
346 if (inst < 0 || inst > (int)IFM_INST_MAX)
347 errx(1, "invalid media instance: %s", val);
349 strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
350 ifr.ifr_media = (ifmr->ifm_current & ~IFM_IMASK) | inst << IFM_ISHIFT;
352 ifmr->ifm_current = ifr.ifr_media;
353 callback_register(setifmediacallback, (void *)ifmr);
357 setmediamode(const char *val, int d, int s, const struct afswtch *afp)
359 struct ifmediareq *ifmr;
362 ifmr = ifmedia_getstate(s);
364 mode = get_media_mode(IFM_TYPE(ifmr->ifm_ulist[0]), val);
366 strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
367 ifr.ifr_media = (ifmr->ifm_current & ~IFM_MMASK) | mode;
369 ifmr->ifm_current = ifr.ifr_media;
370 callback_register(setifmediacallback, (void *)ifmr);
373 /**********************************************************************
374 * A good chunk of this is duplicated from sys/net/ifmedia.c
375 **********************************************************************/
377 static struct ifmedia_description ifm_type_descriptions[] =
378 IFM_TYPE_DESCRIPTIONS;
380 static struct ifmedia_description ifm_subtype_ethernet_descriptions[] =
381 IFM_SUBTYPE_ETHERNET_DESCRIPTIONS;
383 static struct ifmedia_description ifm_subtype_ethernet_aliases[] =
384 IFM_SUBTYPE_ETHERNET_ALIASES;
386 static struct ifmedia_description ifm_subtype_ethernet_option_descriptions[] =
387 IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS;
389 static struct ifmedia_description ifm_subtype_tokenring_descriptions[] =
390 IFM_SUBTYPE_TOKENRING_DESCRIPTIONS;
392 static struct ifmedia_description ifm_subtype_tokenring_aliases[] =
393 IFM_SUBTYPE_TOKENRING_ALIASES;
395 static struct ifmedia_description ifm_subtype_tokenring_option_descriptions[] =
396 IFM_SUBTYPE_TOKENRING_OPTION_DESCRIPTIONS;
398 static struct ifmedia_description ifm_subtype_fddi_descriptions[] =
399 IFM_SUBTYPE_FDDI_DESCRIPTIONS;
401 static struct ifmedia_description ifm_subtype_fddi_aliases[] =
402 IFM_SUBTYPE_FDDI_ALIASES;
404 static struct ifmedia_description ifm_subtype_fddi_option_descriptions[] =
405 IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS;
407 static struct ifmedia_description ifm_subtype_ieee80211_descriptions[] =
408 IFM_SUBTYPE_IEEE80211_DESCRIPTIONS;
410 static struct ifmedia_description ifm_subtype_ieee80211_aliases[] =
411 IFM_SUBTYPE_IEEE80211_ALIASES;
413 static struct ifmedia_description ifm_subtype_ieee80211_option_descriptions[] =
414 IFM_SUBTYPE_IEEE80211_OPTION_DESCRIPTIONS;
416 struct ifmedia_description ifm_subtype_ieee80211_mode_descriptions[] =
417 IFM_SUBTYPE_IEEE80211_MODE_DESCRIPTIONS;
419 struct ifmedia_description ifm_subtype_ieee80211_mode_aliases[] =
420 IFM_SUBTYPE_IEEE80211_MODE_ALIASES;
422 static struct ifmedia_description ifm_subtype_atm_descriptions[] =
423 IFM_SUBTYPE_ATM_DESCRIPTIONS;
425 static struct ifmedia_description ifm_subtype_atm_aliases[] =
426 IFM_SUBTYPE_ATM_ALIASES;
428 static struct ifmedia_description ifm_subtype_atm_option_descriptions[] =
429 IFM_SUBTYPE_ATM_OPTION_DESCRIPTIONS;
431 static struct ifmedia_description ifm_subtype_shared_descriptions[] =
432 IFM_SUBTYPE_SHARED_DESCRIPTIONS;
434 static struct ifmedia_description ifm_subtype_shared_aliases[] =
435 IFM_SUBTYPE_SHARED_ALIASES;
437 static struct ifmedia_description ifm_shared_option_descriptions[] =
438 IFM_SHARED_OPTION_DESCRIPTIONS;
440 static struct ifmedia_description ifm_shared_option_aliases[] =
441 IFM_SHARED_OPTION_ALIASES;
443 struct ifmedia_type_to_subtype {
445 struct ifmedia_description *desc;
449 struct ifmedia_description *desc;
453 struct ifmedia_description *desc;
458 /* must be in the same order as IFM_TYPE_DESCRIPTIONS */
459 static struct ifmedia_type_to_subtype ifmedia_types_to_subtypes[] = {
462 { &ifm_subtype_shared_descriptions[0], 0 },
463 { &ifm_subtype_shared_aliases[0], 1 },
464 { &ifm_subtype_ethernet_descriptions[0], 0 },
465 { &ifm_subtype_ethernet_aliases[0], 1 },
469 { &ifm_shared_option_descriptions[0], 0 },
470 { &ifm_shared_option_aliases[0], 1 },
471 { &ifm_subtype_ethernet_option_descriptions[0], 0 },
480 { &ifm_subtype_shared_descriptions[0], 0 },
481 { &ifm_subtype_shared_aliases[0], 1 },
482 { &ifm_subtype_tokenring_descriptions[0], 0 },
483 { &ifm_subtype_tokenring_aliases[0], 1 },
487 { &ifm_shared_option_descriptions[0], 0 },
488 { &ifm_shared_option_aliases[0], 1 },
489 { &ifm_subtype_tokenring_option_descriptions[0], 0 },
498 { &ifm_subtype_shared_descriptions[0], 0 },
499 { &ifm_subtype_shared_aliases[0], 1 },
500 { &ifm_subtype_fddi_descriptions[0], 0 },
501 { &ifm_subtype_fddi_aliases[0], 1 },
505 { &ifm_shared_option_descriptions[0], 0 },
506 { &ifm_shared_option_aliases[0], 1 },
507 { &ifm_subtype_fddi_option_descriptions[0], 0 },
516 { &ifm_subtype_shared_descriptions[0], 0 },
517 { &ifm_subtype_shared_aliases[0], 1 },
518 { &ifm_subtype_ieee80211_descriptions[0], 0 },
519 { &ifm_subtype_ieee80211_aliases[0], 1 },
523 { &ifm_shared_option_descriptions[0], 0 },
524 { &ifm_shared_option_aliases[0], 1 },
525 { &ifm_subtype_ieee80211_option_descriptions[0], 0 },
529 { &ifm_subtype_ieee80211_mode_descriptions[0], 0 },
530 { &ifm_subtype_ieee80211_mode_aliases[0], 0 },
536 { &ifm_subtype_shared_descriptions[0], 0 },
537 { &ifm_subtype_shared_aliases[0], 1 },
538 { &ifm_subtype_atm_descriptions[0], 0 },
539 { &ifm_subtype_atm_aliases[0], 1 },
543 { &ifm_shared_option_descriptions[0], 0 },
544 { &ifm_shared_option_aliases[0], 1 },
545 { &ifm_subtype_atm_option_descriptions[0], 0 },
555 get_media_subtype(int type, const char *val)
557 struct ifmedia_description *desc;
558 struct ifmedia_type_to_subtype *ttos;
561 /* Find the top-level interface type. */
562 for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes;
563 desc->ifmt_string != NULL; desc++, ttos++)
564 if (type == desc->ifmt_word)
566 if (desc->ifmt_string == NULL)
567 errx(1, "unknown media type 0x%x", type);
569 for (i = 0; ttos->subtypes[i].desc != NULL; i++) {
570 rval = lookup_media_word(ttos->subtypes[i].desc, val);
574 errx(1, "unknown media subtype: %s", val);
579 get_media_mode(int type, const char *val)
581 struct ifmedia_description *desc;
582 struct ifmedia_type_to_subtype *ttos;
585 /* Find the top-level interface type. */
586 for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes;
587 desc->ifmt_string != NULL; desc++, ttos++)
588 if (type == desc->ifmt_word)
590 if (desc->ifmt_string == NULL)
591 errx(1, "unknown media mode 0x%x", type);
593 for (i = 0; ttos->modes[i].desc != NULL; i++) {
594 rval = lookup_media_word(ttos->modes[i].desc, val);
602 get_media_options(int type, const char *val)
604 struct ifmedia_description *desc;
605 struct ifmedia_type_to_subtype *ttos;
606 char *optlist, *optptr;
607 int option = 0, i, rval = 0;
609 /* We muck with the string, so copy it. */
610 optlist = strdup(val);
614 /* Find the top-level interface type. */
615 for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes;
616 desc->ifmt_string != NULL; desc++, ttos++)
617 if (type == desc->ifmt_word)
619 if (desc->ifmt_string == NULL)
620 errx(1, "unknown media type 0x%x", type);
623 * Look up the options in the user-provided comma-separated
627 for (; (optptr = strtok(optptr, ",")) != NULL; optptr = NULL) {
628 for (i = 0; ttos->options[i].desc != NULL; i++) {
629 option = lookup_media_word(ttos->options[i].desc, optptr);
634 errx(1, "unknown option: %s", optptr);
643 lookup_media_word(struct ifmedia_description *desc, const char *val)
646 for (; desc->ifmt_string != NULL; desc++)
647 if (strcasecmp(desc->ifmt_string, val) == 0)
648 return (desc->ifmt_word);
653 static struct ifmedia_description *get_toptype_desc(int ifmw)
655 struct ifmedia_description *desc;
657 for (desc = ifm_type_descriptions; desc->ifmt_string != NULL; desc++)
658 if (IFM_TYPE(ifmw) == desc->ifmt_word)
664 static struct ifmedia_type_to_subtype *get_toptype_ttos(int ifmw)
666 struct ifmedia_description *desc;
667 struct ifmedia_type_to_subtype *ttos;
669 for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes;
670 desc->ifmt_string != NULL; desc++, ttos++)
671 if (IFM_TYPE(ifmw) == desc->ifmt_word)
677 static struct ifmedia_description *get_subtype_desc(int ifmw,
678 struct ifmedia_type_to_subtype *ttos)
681 struct ifmedia_description *desc;
683 for (i = 0; ttos->subtypes[i].desc != NULL; i++) {
684 if (ttos->subtypes[i].alias)
686 for (desc = ttos->subtypes[i].desc;
687 desc->ifmt_string != NULL; desc++) {
688 if (IFM_SUBTYPE(ifmw) == desc->ifmt_word)
696 static struct ifmedia_description *get_mode_desc(int ifmw,
697 struct ifmedia_type_to_subtype *ttos)
700 struct ifmedia_description *desc;
702 for (i = 0; ttos->modes[i].desc != NULL; i++) {
703 if (ttos->modes[i].alias)
705 for (desc = ttos->modes[i].desc;
706 desc->ifmt_string != NULL; desc++) {
707 if (IFM_MODE(ifmw) == desc->ifmt_word)
716 print_media_word(int ifmw, int print_toptype)
718 struct ifmedia_description *desc;
719 struct ifmedia_type_to_subtype *ttos;
720 int seen_option = 0, i;
722 /* Find the top-level interface type. */
723 desc = get_toptype_desc(ifmw);
724 ttos = get_toptype_ttos(ifmw);
725 if (desc->ifmt_string == NULL) {
726 printf("<unknown type>");
728 } else if (print_toptype) {
729 printf("%s", desc->ifmt_string);
733 * Don't print the top-level type; it's not like we can
734 * change it, or anything.
738 desc = get_subtype_desc(ifmw, ttos);
740 printf("<unknown subtype>");
747 printf("%s", desc->ifmt_string);
750 desc = get_mode_desc(ifmw, ttos);
751 if (desc != NULL && strcasecmp("autoselect", desc->ifmt_string))
752 printf(" mode %s", desc->ifmt_string);
756 for (i = 0; ttos->options[i].desc != NULL; i++) {
757 if (ttos->options[i].alias)
759 for (desc = ttos->options[i].desc;
760 desc->ifmt_string != NULL; desc++) {
761 if (ifmw & desc->ifmt_word) {
762 if (seen_option == 0)
764 printf("%s%s", seen_option++ ? "," : "",
769 printf("%s", seen_option ? ">" : "");
771 if (print_toptype && IFM_INST(ifmw) != 0)
772 printf(" instance %d", IFM_INST(ifmw));
776 print_media_word_ifconfig(int ifmw)
778 struct ifmedia_description *desc;
779 struct ifmedia_type_to_subtype *ttos;
780 int seen_option = 0, i;
782 /* Find the top-level interface type. */
783 desc = get_toptype_desc(ifmw);
784 ttos = get_toptype_ttos(ifmw);
785 if (desc->ifmt_string == NULL) {
786 printf("<unknown type>");
791 * Don't print the top-level type; it's not like we can
792 * change it, or anything.
796 desc = get_subtype_desc(ifmw, ttos);
798 printf("<unknown subtype>");
802 printf("media %s", desc->ifmt_string);
804 desc = get_mode_desc(ifmw, ttos);
806 printf(" mode %s", desc->ifmt_string);
809 for (i = 0; ttos->options[i].desc != NULL; i++) {
810 if (ttos->options[i].alias)
812 for (desc = ttos->options[i].desc;
813 desc->ifmt_string != NULL; desc++) {
814 if (ifmw & desc->ifmt_word) {
815 if (seen_option == 0)
816 printf(" mediaopt ");
817 printf("%s%s", seen_option++ ? "," : "",
823 if (IFM_INST(ifmw) != 0)
824 printf(" instance %d", IFM_INST(ifmw));
827 /**********************************************************************
829 **********************************************************************/
831 static struct cmd media_cmds[] = {
832 DEF_CMD_ARG("media", setmedia),
833 DEF_CMD_ARG("mode", setmediamode),
834 DEF_CMD_ARG("mediaopt", setmediaopt),
835 DEF_CMD_ARG("-mediaopt",unsetmediaopt),
836 DEF_CMD_ARG("inst", setmediainst),
837 DEF_CMD_ARG("instance", setmediainst),
839 static struct afswtch af_media = {
840 .af_name = "af_media",
842 .af_other_status = media_status,
845 static __constructor void
850 for (i = 0; i < nitems(media_cmds); i++)
851 cmd_register(&media_cmds[i]);
852 af_register(&af_media);