1 /* $NetBSD: ifconfig.c,v 1.34 1997/04/21 01:17:58 lukem Exp $ */
5 * SPDX-License-Identifier: BSD-4-Clause
7 * Copyright (c) 1997 Jason R. Thorpe.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed for the NetBSD Project
22 * 4. The name of the author may not be used to endorse or promote products
23 * derived from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
32 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * Copyright (c) 1983, 1993
40 * The Regents of the University of California. All rights reserved.
42 * Redistribution and use in source and binary forms, with or without
43 * modification, are permitted provided that the following conditions
45 * 1. Redistributions of source code must retain the above copyright
46 * notice, this list of conditions and the following disclaimer.
47 * 2. Redistributions in binary form must reproduce the above copyright
48 * notice, this list of conditions and the following disclaimer in the
49 * documentation and/or other materials provided with the distribution.
50 * 4. Neither the name of the University nor the names of its contributors
51 * may be used to endorse or promote products derived from this software
52 * without specific prior written permission.
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
67 #include <sys/param.h>
68 #include <sys/ioctl.h>
69 #include <sys/socket.h>
70 #include <sys/sysctl.h>
74 #include <net/if_dl.h>
75 #include <net/if_types.h>
76 #include <net/if_media.h>
77 #include <net/route.h>
90 static void domediaopt(const char *, int, int);
91 static int get_media_subtype(int, const char *);
92 static int get_media_mode(int, const char *);
93 static int get_media_options(int, const char *);
94 static int lookup_media_word(struct ifmedia_description *, const char *);
95 static void print_media_word(int, int);
96 static void print_media_word_ifconfig(int);
98 static struct ifmedia_description *get_toptype_desc(int);
99 static struct ifmedia_type_to_subtype *get_toptype_ttos(int);
100 static struct ifmedia_description *get_subtype_desc(int,
101 struct ifmedia_type_to_subtype *ttos);
103 #define IFM_OPMODE(x) \
104 ((x) & (IFM_IEEE80211_ADHOC | IFM_IEEE80211_HOSTAP | \
105 IFM_IEEE80211_IBSS | IFM_IEEE80211_WDS | IFM_IEEE80211_MONITOR | \
107 #define IFM_IEEE80211_STA 0
112 struct ifmediareq ifmr;
116 (void) memset(&ifmr, 0, sizeof(ifmr));
117 (void) strlcpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name));
120 * Check if interface supports extended media types.
122 if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)&ifmr) < 0)
124 if (xmedia == 0 && ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
126 * Interface doesn't support SIOC{G,S}IFMEDIA.
131 if (ifmr.ifm_count == 0) {
132 warnx("%s: no media types?", name);
136 media_list = (int *)malloc(ifmr.ifm_count * sizeof(int));
137 if (media_list == NULL)
139 ifmr.ifm_ulist = media_list;
142 if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)&ifmr) < 0)
143 err(1, "SIOCGIFXMEDIA");
145 if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0)
146 err(1, "SIOCGIFMEDIA");
150 print_media_word(ifmr.ifm_current, 1);
151 if (ifmr.ifm_active != ifmr.ifm_current) {
154 print_media_word(ifmr.ifm_active, 0);
160 if (ifmr.ifm_status & IFM_AVALID) {
161 printf("\tstatus: ");
162 switch (IFM_TYPE(ifmr.ifm_active)) {
165 if (ifmr.ifm_status & IFM_ACTIVE)
168 printf("no carrier");
173 if (ifmr.ifm_status & IFM_ACTIVE)
180 if (ifmr.ifm_status & IFM_ACTIVE) {
181 /* NB: only sta mode associates */
182 if (IFM_OPMODE(ifmr.ifm_active) == IFM_IEEE80211_STA)
183 printf("associated");
187 printf("no carrier");
193 if (ifmr.ifm_count > 0 && supmedia) {
194 printf("\tsupported media:\n");
195 for (i = 0; i < ifmr.ifm_count; i++) {
197 print_media_word_ifconfig(media_list[i]);
206 ifmedia_getstate(int s)
208 static struct ifmediareq *ifmr = NULL;
213 ifmr = (struct ifmediareq *)malloc(sizeof(struct ifmediareq));
217 (void) memset(ifmr, 0, sizeof(struct ifmediareq));
218 (void) strlcpy(ifmr->ifm_name, name,
219 sizeof(ifmr->ifm_name));
222 ifmr->ifm_ulist = NULL;
225 * We must go through the motions of reading all
226 * supported media because we need to know both
227 * the current media type and the top-level type.
230 if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)ifmr) < 0) {
233 if (xmedia == 0 && ioctl(s, SIOCGIFMEDIA, (caddr_t)ifmr) < 0) {
234 err(1, "SIOCGIFMEDIA");
237 if (ifmr->ifm_count == 0)
238 errx(1, "%s: no media types?", name);
240 mwords = (int *)malloc(ifmr->ifm_count * sizeof(int));
244 ifmr->ifm_ulist = mwords;
246 if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)ifmr) < 0)
247 err(1, "SIOCGIFXMEDIA");
249 if (ioctl(s, SIOCGIFMEDIA, (caddr_t)ifmr) < 0)
250 err(1, "SIOCGIFMEDIA");
258 setifmediacallback(int s, void *arg)
260 struct ifmediareq *ifmr = (struct ifmediareq *)arg;
261 static int did_it = 0;
264 ifr.ifr_media = ifmr->ifm_current;
265 if (ioctl(s, SIOCSIFMEDIA, (caddr_t)&ifr) < 0)
266 err(1, "SIOCSIFMEDIA (media)");
267 free(ifmr->ifm_ulist);
274 setmedia(const char *val, int d, int s, const struct afswtch *afp)
276 struct ifmediareq *ifmr;
279 ifmr = ifmedia_getstate(s);
282 * We are primarily concerned with the top-level type.
283 * However, "current" may be only IFM_NONE, so we just look
284 * for the top-level type in the first "supported type"
287 * (I'm assuming that all supported media types for a given
288 * interface will be the same top-level type..)
290 subtype = get_media_subtype(IFM_TYPE(ifmr->ifm_ulist[0]), val);
292 strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
293 ifr.ifr_media = (ifmr->ifm_current & IFM_IMASK) |
294 IFM_TYPE(ifmr->ifm_ulist[0]) | subtype;
296 ifmr->ifm_current = ifr.ifr_media;
297 callback_register(setifmediacallback, (void *)ifmr);
301 setmediaopt(const char *val, int d, int s, const struct afswtch *afp)
304 domediaopt(val, 0, s);
308 unsetmediaopt(const char *val, int d, int s, const struct afswtch *afp)
311 domediaopt(val, 1, s);
315 domediaopt(const char *val, int clear, int s)
317 struct ifmediareq *ifmr;
320 ifmr = ifmedia_getstate(s);
322 options = get_media_options(IFM_TYPE(ifmr->ifm_ulist[0]), val);
324 strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
325 ifr.ifr_media = ifmr->ifm_current;
327 ifr.ifr_media &= ~options;
329 if (options & IFM_HDX) {
330 ifr.ifr_media &= ~IFM_FDX;
333 ifr.ifr_media |= options;
335 ifmr->ifm_current = ifr.ifr_media;
336 callback_register(setifmediacallback, (void *)ifmr);
340 setmediainst(const char *val, int d, int s, const struct afswtch *afp)
342 struct ifmediareq *ifmr;
345 ifmr = ifmedia_getstate(s);
348 if (inst < 0 || inst > (int)IFM_INST_MAX)
349 errx(1, "invalid media instance: %s", val);
351 strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
352 ifr.ifr_media = (ifmr->ifm_current & ~IFM_IMASK) | inst << IFM_ISHIFT;
354 ifmr->ifm_current = ifr.ifr_media;
355 callback_register(setifmediacallback, (void *)ifmr);
359 setmediamode(const char *val, int d, int s, const struct afswtch *afp)
361 struct ifmediareq *ifmr;
364 ifmr = ifmedia_getstate(s);
366 mode = get_media_mode(IFM_TYPE(ifmr->ifm_ulist[0]), val);
368 strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
369 ifr.ifr_media = (ifmr->ifm_current & ~IFM_MMASK) | mode;
371 ifmr->ifm_current = ifr.ifr_media;
372 callback_register(setifmediacallback, (void *)ifmr);
375 /**********************************************************************
376 * A good chunk of this is duplicated from sys/net/if_media.c
377 **********************************************************************/
379 static struct ifmedia_description ifm_type_descriptions[] =
380 IFM_TYPE_DESCRIPTIONS;
382 static struct ifmedia_description ifm_subtype_ethernet_descriptions[] =
383 IFM_SUBTYPE_ETHERNET_DESCRIPTIONS;
385 static struct ifmedia_description ifm_subtype_ethernet_aliases[] =
386 IFM_SUBTYPE_ETHERNET_ALIASES;
388 static struct ifmedia_description ifm_subtype_ethernet_option_descriptions[] =
389 IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS;
391 static struct ifmedia_description ifm_subtype_tokenring_descriptions[] =
392 IFM_SUBTYPE_TOKENRING_DESCRIPTIONS;
394 static struct ifmedia_description ifm_subtype_tokenring_aliases[] =
395 IFM_SUBTYPE_TOKENRING_ALIASES;
397 static struct ifmedia_description ifm_subtype_tokenring_option_descriptions[] =
398 IFM_SUBTYPE_TOKENRING_OPTION_DESCRIPTIONS;
400 static struct ifmedia_description ifm_subtype_fddi_descriptions[] =
401 IFM_SUBTYPE_FDDI_DESCRIPTIONS;
403 static struct ifmedia_description ifm_subtype_fddi_aliases[] =
404 IFM_SUBTYPE_FDDI_ALIASES;
406 static struct ifmedia_description ifm_subtype_fddi_option_descriptions[] =
407 IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS;
409 static struct ifmedia_description ifm_subtype_ieee80211_descriptions[] =
410 IFM_SUBTYPE_IEEE80211_DESCRIPTIONS;
412 static struct ifmedia_description ifm_subtype_ieee80211_aliases[] =
413 IFM_SUBTYPE_IEEE80211_ALIASES;
415 static struct ifmedia_description ifm_subtype_ieee80211_option_descriptions[] =
416 IFM_SUBTYPE_IEEE80211_OPTION_DESCRIPTIONS;
418 struct ifmedia_description ifm_subtype_ieee80211_mode_descriptions[] =
419 IFM_SUBTYPE_IEEE80211_MODE_DESCRIPTIONS;
421 struct ifmedia_description ifm_subtype_ieee80211_mode_aliases[] =
422 IFM_SUBTYPE_IEEE80211_MODE_ALIASES;
424 static struct ifmedia_description ifm_subtype_atm_descriptions[] =
425 IFM_SUBTYPE_ATM_DESCRIPTIONS;
427 static struct ifmedia_description ifm_subtype_atm_aliases[] =
428 IFM_SUBTYPE_ATM_ALIASES;
430 static struct ifmedia_description ifm_subtype_atm_option_descriptions[] =
431 IFM_SUBTYPE_ATM_OPTION_DESCRIPTIONS;
433 static struct ifmedia_description ifm_subtype_shared_descriptions[] =
434 IFM_SUBTYPE_SHARED_DESCRIPTIONS;
436 static struct ifmedia_description ifm_subtype_shared_aliases[] =
437 IFM_SUBTYPE_SHARED_ALIASES;
439 static struct ifmedia_description ifm_shared_option_descriptions[] =
440 IFM_SHARED_OPTION_DESCRIPTIONS;
442 static struct ifmedia_description ifm_shared_option_aliases[] =
443 IFM_SHARED_OPTION_ALIASES;
445 struct ifmedia_type_to_subtype {
447 struct ifmedia_description *desc;
451 struct ifmedia_description *desc;
455 struct ifmedia_description *desc;
460 /* must be in the same order as IFM_TYPE_DESCRIPTIONS */
461 static struct ifmedia_type_to_subtype ifmedia_types_to_subtypes[] = {
464 { &ifm_subtype_shared_descriptions[0], 0 },
465 { &ifm_subtype_shared_aliases[0], 1 },
466 { &ifm_subtype_ethernet_descriptions[0], 0 },
467 { &ifm_subtype_ethernet_aliases[0], 1 },
471 { &ifm_shared_option_descriptions[0], 0 },
472 { &ifm_shared_option_aliases[0], 1 },
473 { &ifm_subtype_ethernet_option_descriptions[0], 0 },
482 { &ifm_subtype_shared_descriptions[0], 0 },
483 { &ifm_subtype_shared_aliases[0], 1 },
484 { &ifm_subtype_tokenring_descriptions[0], 0 },
485 { &ifm_subtype_tokenring_aliases[0], 1 },
489 { &ifm_shared_option_descriptions[0], 0 },
490 { &ifm_shared_option_aliases[0], 1 },
491 { &ifm_subtype_tokenring_option_descriptions[0], 0 },
500 { &ifm_subtype_shared_descriptions[0], 0 },
501 { &ifm_subtype_shared_aliases[0], 1 },
502 { &ifm_subtype_fddi_descriptions[0], 0 },
503 { &ifm_subtype_fddi_aliases[0], 1 },
507 { &ifm_shared_option_descriptions[0], 0 },
508 { &ifm_shared_option_aliases[0], 1 },
509 { &ifm_subtype_fddi_option_descriptions[0], 0 },
518 { &ifm_subtype_shared_descriptions[0], 0 },
519 { &ifm_subtype_shared_aliases[0], 1 },
520 { &ifm_subtype_ieee80211_descriptions[0], 0 },
521 { &ifm_subtype_ieee80211_aliases[0], 1 },
525 { &ifm_shared_option_descriptions[0], 0 },
526 { &ifm_shared_option_aliases[0], 1 },
527 { &ifm_subtype_ieee80211_option_descriptions[0], 0 },
531 { &ifm_subtype_ieee80211_mode_descriptions[0], 0 },
532 { &ifm_subtype_ieee80211_mode_aliases[0], 0 },
538 { &ifm_subtype_shared_descriptions[0], 0 },
539 { &ifm_subtype_shared_aliases[0], 1 },
540 { &ifm_subtype_atm_descriptions[0], 0 },
541 { &ifm_subtype_atm_aliases[0], 1 },
545 { &ifm_shared_option_descriptions[0], 0 },
546 { &ifm_shared_option_aliases[0], 1 },
547 { &ifm_subtype_atm_option_descriptions[0], 0 },
557 get_media_subtype(int type, const char *val)
559 struct ifmedia_description *desc;
560 struct ifmedia_type_to_subtype *ttos;
563 /* Find the top-level interface type. */
564 for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes;
565 desc->ifmt_string != NULL; desc++, ttos++)
566 if (type == desc->ifmt_word)
568 if (desc->ifmt_string == NULL)
569 errx(1, "unknown media type 0x%x", type);
571 for (i = 0; ttos->subtypes[i].desc != NULL; i++) {
572 rval = lookup_media_word(ttos->subtypes[i].desc, val);
576 errx(1, "unknown media subtype: %s", val);
581 get_media_mode(int type, const char *val)
583 struct ifmedia_description *desc;
584 struct ifmedia_type_to_subtype *ttos;
587 /* Find the top-level interface type. */
588 for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes;
589 desc->ifmt_string != NULL; desc++, ttos++)
590 if (type == desc->ifmt_word)
592 if (desc->ifmt_string == NULL)
593 errx(1, "unknown media mode 0x%x", type);
595 for (i = 0; ttos->modes[i].desc != NULL; i++) {
596 rval = lookup_media_word(ttos->modes[i].desc, val);
604 get_media_options(int type, const char *val)
606 struct ifmedia_description *desc;
607 struct ifmedia_type_to_subtype *ttos;
608 char *optlist, *optptr;
609 int option = 0, i, rval = 0;
611 /* We muck with the string, so copy it. */
612 optlist = strdup(val);
616 /* Find the top-level interface type. */
617 for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes;
618 desc->ifmt_string != NULL; desc++, ttos++)
619 if (type == desc->ifmt_word)
621 if (desc->ifmt_string == NULL)
622 errx(1, "unknown media type 0x%x", type);
625 * Look up the options in the user-provided comma-separated
629 for (; (optptr = strtok(optptr, ",")) != NULL; optptr = NULL) {
630 for (i = 0; ttos->options[i].desc != NULL; i++) {
631 option = lookup_media_word(ttos->options[i].desc, optptr);
636 errx(1, "unknown option: %s", optptr);
645 lookup_media_word(struct ifmedia_description *desc, const char *val)
648 for (; desc->ifmt_string != NULL; desc++)
649 if (strcasecmp(desc->ifmt_string, val) == 0)
650 return (desc->ifmt_word);
655 static struct ifmedia_description *get_toptype_desc(int ifmw)
657 struct ifmedia_description *desc;
659 for (desc = ifm_type_descriptions; desc->ifmt_string != NULL; desc++)
660 if (IFM_TYPE(ifmw) == desc->ifmt_word)
666 static struct ifmedia_type_to_subtype *get_toptype_ttos(int ifmw)
668 struct ifmedia_description *desc;
669 struct ifmedia_type_to_subtype *ttos;
671 for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes;
672 desc->ifmt_string != NULL; desc++, ttos++)
673 if (IFM_TYPE(ifmw) == desc->ifmt_word)
679 static struct ifmedia_description *get_subtype_desc(int ifmw,
680 struct ifmedia_type_to_subtype *ttos)
683 struct ifmedia_description *desc;
685 for (i = 0; ttos->subtypes[i].desc != NULL; i++) {
686 if (ttos->subtypes[i].alias)
688 for (desc = ttos->subtypes[i].desc;
689 desc->ifmt_string != NULL; desc++) {
690 if (IFM_SUBTYPE(ifmw) == desc->ifmt_word)
698 static struct ifmedia_description *get_mode_desc(int ifmw,
699 struct ifmedia_type_to_subtype *ttos)
702 struct ifmedia_description *desc;
704 for (i = 0; ttos->modes[i].desc != NULL; i++) {
705 if (ttos->modes[i].alias)
707 for (desc = ttos->modes[i].desc;
708 desc->ifmt_string != NULL; desc++) {
709 if (IFM_MODE(ifmw) == desc->ifmt_word)
718 print_media_word(int ifmw, int print_toptype)
720 struct ifmedia_description *desc;
721 struct ifmedia_type_to_subtype *ttos;
722 int seen_option = 0, i;
724 /* Find the top-level interface type. */
725 desc = get_toptype_desc(ifmw);
726 ttos = get_toptype_ttos(ifmw);
727 if (desc->ifmt_string == NULL) {
728 printf("<unknown type>");
730 } else if (print_toptype) {
731 printf("%s", desc->ifmt_string);
735 * Don't print the top-level type; it's not like we can
736 * change it, or anything.
740 desc = get_subtype_desc(ifmw, ttos);
742 printf("<unknown subtype>");
749 printf("%s", desc->ifmt_string);
752 desc = get_mode_desc(ifmw, ttos);
753 if (desc != NULL && strcasecmp("autoselect", desc->ifmt_string))
754 printf(" mode %s", desc->ifmt_string);
758 for (i = 0; ttos->options[i].desc != NULL; i++) {
759 if (ttos->options[i].alias)
761 for (desc = ttos->options[i].desc;
762 desc->ifmt_string != NULL; desc++) {
763 if (ifmw & desc->ifmt_word) {
764 if (seen_option == 0)
766 printf("%s%s", seen_option++ ? "," : "",
771 printf("%s", seen_option ? ">" : "");
773 if (print_toptype && IFM_INST(ifmw) != 0)
774 printf(" instance %d", IFM_INST(ifmw));
778 print_media_word_ifconfig(int ifmw)
780 struct ifmedia_description *desc;
781 struct ifmedia_type_to_subtype *ttos;
782 int seen_option = 0, i;
784 /* Find the top-level interface type. */
785 desc = get_toptype_desc(ifmw);
786 ttos = get_toptype_ttos(ifmw);
787 if (desc->ifmt_string == NULL) {
788 printf("<unknown type>");
793 * Don't print the top-level type; it's not like we can
794 * change it, or anything.
798 desc = get_subtype_desc(ifmw, ttos);
800 printf("<unknown subtype>");
804 printf("media %s", desc->ifmt_string);
806 desc = get_mode_desc(ifmw, ttos);
808 printf(" mode %s", desc->ifmt_string);
811 for (i = 0; ttos->options[i].desc != NULL; i++) {
812 if (ttos->options[i].alias)
814 for (desc = ttos->options[i].desc;
815 desc->ifmt_string != NULL; desc++) {
816 if (ifmw & desc->ifmt_word) {
817 if (seen_option == 0)
818 printf(" mediaopt ");
819 printf("%s%s", seen_option++ ? "," : "",
825 if (IFM_INST(ifmw) != 0)
826 printf(" instance %d", IFM_INST(ifmw));
829 /**********************************************************************
831 **********************************************************************/
833 static struct cmd media_cmds[] = {
834 DEF_CMD_ARG("media", setmedia),
835 DEF_CMD_ARG("mode", setmediamode),
836 DEF_CMD_ARG("mediaopt", setmediaopt),
837 DEF_CMD_ARG("-mediaopt",unsetmediaopt),
838 DEF_CMD_ARG("inst", setmediainst),
839 DEF_CMD_ARG("instance", setmediainst),
841 static struct afswtch af_media = {
842 .af_name = "af_media",
844 .af_other_status = media_status,
847 static __constructor void
852 for (i = 0; i < nitems(media_cmds); i++)
853 cmd_register(&media_cmds[i]);
854 af_register(&af_media);