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 * 3. All advertising materials mentioning features or use of this software
49 * must display the following acknowledgement:
50 * This product includes software developed by the University of
51 * California, Berkeley and its contributors.
52 * 4. Neither the name of the University nor the names of its contributors
53 * may be used to endorse or promote products derived from this software
54 * without specific prior written permission.
56 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
57 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
59 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
60 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
61 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
62 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
64 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
65 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 #include <sys/param.h>
70 #include <sys/ioctl.h>
71 #include <sys/socket.h>
72 #include <sys/sysctl.h>
76 #include <net/if_dl.h>
77 #include <net/if_types.h>
78 #include <net/if_media.h>
79 #include <net/route.h>
92 static void domediaopt(const char *, int, int);
93 static int get_media_subtype(int, const char *);
94 static int get_media_mode(int, const char *);
95 static int get_media_options(int, const char *);
96 static int lookup_media_word(struct ifmedia_description *, const char *);
97 static void print_media_word(int, int);
98 static void print_media_word_ifconfig(int);
100 static struct ifmedia_description *get_toptype_desc(int);
101 static struct ifmedia_type_to_subtype *get_toptype_ttos(int);
102 static struct ifmedia_description *get_subtype_desc(int,
103 struct ifmedia_type_to_subtype *ttos);
105 #define IFM_OPMODE(x) \
106 ((x) & (IFM_IEEE80211_ADHOC | IFM_IEEE80211_HOSTAP | \
107 IFM_IEEE80211_IBSS | IFM_IEEE80211_WDS | IFM_IEEE80211_MONITOR | \
109 #define IFM_IEEE80211_STA 0
114 struct ifmediareq ifmr;
117 (void) memset(&ifmr, 0, sizeof(ifmr));
118 (void) strncpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name));
120 if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
122 * Interface doesn't support SIOC{G,S}IFMEDIA.
127 if (ifmr.ifm_count == 0) {
128 warnx("%s: no media types?", name);
132 media_list = (int *)malloc(ifmr.ifm_count * sizeof(int));
133 if (media_list == NULL)
135 ifmr.ifm_ulist = media_list;
137 if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0)
138 err(1, "SIOCGIFMEDIA");
141 print_media_word(ifmr.ifm_current, 1);
142 if (ifmr.ifm_active != ifmr.ifm_current) {
145 print_media_word(ifmr.ifm_active, 0);
151 if (ifmr.ifm_status & IFM_AVALID) {
152 printf("\tstatus: ");
153 switch (IFM_TYPE(ifmr.ifm_active)) {
156 if (ifmr.ifm_status & IFM_ACTIVE)
159 printf("no carrier");
164 if (ifmr.ifm_status & IFM_ACTIVE)
171 if (ifmr.ifm_status & IFM_ACTIVE) {
172 /* NB: only sta mode associates */
173 if (IFM_OPMODE(ifmr.ifm_active) == IFM_IEEE80211_STA)
174 printf("associated");
178 printf("no carrier");
184 if (ifmr.ifm_count > 0 && supmedia) {
185 printf("\tsupported media:\n");
186 for (i = 0; i < ifmr.ifm_count; i++) {
188 print_media_word_ifconfig(media_list[i]);
197 ifmedia_getstate(int s)
199 static struct ifmediareq *ifmr = NULL;
203 ifmr = (struct ifmediareq *)malloc(sizeof(struct ifmediareq));
207 (void) memset(ifmr, 0, sizeof(struct ifmediareq));
208 (void) strncpy(ifmr->ifm_name, name,
209 sizeof(ifmr->ifm_name));
212 ifmr->ifm_ulist = NULL;
215 * We must go through the motions of reading all
216 * supported media because we need to know both
217 * the current media type and the top-level type.
220 if (ioctl(s, SIOCGIFMEDIA, (caddr_t)ifmr) < 0) {
221 err(1, "SIOCGIFMEDIA");
224 if (ifmr->ifm_count == 0)
225 errx(1, "%s: no media types?", name);
227 mwords = (int *)malloc(ifmr->ifm_count * sizeof(int));
231 ifmr->ifm_ulist = mwords;
232 if (ioctl(s, SIOCGIFMEDIA, (caddr_t)ifmr) < 0)
233 err(1, "SIOCGIFMEDIA");
240 setifmediacallback(int s, void *arg)
242 struct ifmediareq *ifmr = (struct ifmediareq *)arg;
243 static int did_it = 0;
246 ifr.ifr_media = ifmr->ifm_current;
247 if (ioctl(s, SIOCSIFMEDIA, (caddr_t)&ifr) < 0)
248 err(1, "SIOCSIFMEDIA (media)");
249 free(ifmr->ifm_ulist);
256 setmedia(const char *val, int d, int s, const struct afswtch *afp)
258 struct ifmediareq *ifmr;
261 ifmr = ifmedia_getstate(s);
264 * We are primarily concerned with the top-level type.
265 * However, "current" may be only IFM_NONE, so we just look
266 * for the top-level type in the first "supported type"
269 * (I'm assuming that all supported media types for a given
270 * interface will be the same top-level type..)
272 subtype = get_media_subtype(IFM_TYPE(ifmr->ifm_ulist[0]), val);
274 strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
275 ifr.ifr_media = (ifmr->ifm_current & IFM_IMASK) |
276 IFM_TYPE(ifmr->ifm_ulist[0]) | subtype;
278 ifmr->ifm_current = ifr.ifr_media;
279 callback_register(setifmediacallback, (void *)ifmr);
283 setmediaopt(const char *val, int d, int s, const struct afswtch *afp)
286 domediaopt(val, 0, s);
290 unsetmediaopt(const char *val, int d, int s, const struct afswtch *afp)
293 domediaopt(val, 1, s);
297 domediaopt(const char *val, int clear, int s)
299 struct ifmediareq *ifmr;
302 ifmr = ifmedia_getstate(s);
304 options = get_media_options(IFM_TYPE(ifmr->ifm_ulist[0]), val);
306 strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
307 ifr.ifr_media = ifmr->ifm_current;
309 ifr.ifr_media &= ~options;
311 if (options & IFM_HDX) {
312 ifr.ifr_media &= ~IFM_FDX;
315 ifr.ifr_media |= options;
317 ifmr->ifm_current = ifr.ifr_media;
318 callback_register(setifmediacallback, (void *)ifmr);
322 setmediainst(const char *val, int d, int s, const struct afswtch *afp)
324 struct ifmediareq *ifmr;
327 ifmr = ifmedia_getstate(s);
330 if (inst < 0 || inst > (int)IFM_INST_MAX)
331 errx(1, "invalid media instance: %s", val);
333 strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
334 ifr.ifr_media = (ifmr->ifm_current & ~IFM_IMASK) | inst << IFM_ISHIFT;
336 ifmr->ifm_current = ifr.ifr_media;
337 callback_register(setifmediacallback, (void *)ifmr);
341 setmediamode(const char *val, int d, int s, const struct afswtch *afp)
343 struct ifmediareq *ifmr;
346 ifmr = ifmedia_getstate(s);
348 mode = get_media_mode(IFM_TYPE(ifmr->ifm_ulist[0]), val);
350 strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
351 ifr.ifr_media = (ifmr->ifm_current & ~IFM_MMASK) | mode;
353 ifmr->ifm_current = ifr.ifr_media;
354 callback_register(setifmediacallback, (void *)ifmr);
357 /**********************************************************************
358 * A good chunk of this is duplicated from sys/net/ifmedia.c
359 **********************************************************************/
361 static struct ifmedia_description ifm_type_descriptions[] =
362 IFM_TYPE_DESCRIPTIONS;
364 static struct ifmedia_description ifm_subtype_ethernet_descriptions[] =
365 IFM_SUBTYPE_ETHERNET_DESCRIPTIONS;
367 static struct ifmedia_description ifm_subtype_ethernet_aliases[] =
368 IFM_SUBTYPE_ETHERNET_ALIASES;
370 static struct ifmedia_description ifm_subtype_ethernet_option_descriptions[] =
371 IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS;
373 static struct ifmedia_description ifm_subtype_tokenring_descriptions[] =
374 IFM_SUBTYPE_TOKENRING_DESCRIPTIONS;
376 static struct ifmedia_description ifm_subtype_tokenring_aliases[] =
377 IFM_SUBTYPE_TOKENRING_ALIASES;
379 static struct ifmedia_description ifm_subtype_tokenring_option_descriptions[] =
380 IFM_SUBTYPE_TOKENRING_OPTION_DESCRIPTIONS;
382 static struct ifmedia_description ifm_subtype_fddi_descriptions[] =
383 IFM_SUBTYPE_FDDI_DESCRIPTIONS;
385 static struct ifmedia_description ifm_subtype_fddi_aliases[] =
386 IFM_SUBTYPE_FDDI_ALIASES;
388 static struct ifmedia_description ifm_subtype_fddi_option_descriptions[] =
389 IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS;
391 static struct ifmedia_description ifm_subtype_ieee80211_descriptions[] =
392 IFM_SUBTYPE_IEEE80211_DESCRIPTIONS;
394 static struct ifmedia_description ifm_subtype_ieee80211_aliases[] =
395 IFM_SUBTYPE_IEEE80211_ALIASES;
397 static struct ifmedia_description ifm_subtype_ieee80211_option_descriptions[] =
398 IFM_SUBTYPE_IEEE80211_OPTION_DESCRIPTIONS;
400 struct ifmedia_description ifm_subtype_ieee80211_mode_descriptions[] =
401 IFM_SUBTYPE_IEEE80211_MODE_DESCRIPTIONS;
403 struct ifmedia_description ifm_subtype_ieee80211_mode_aliases[] =
404 IFM_SUBTYPE_IEEE80211_MODE_ALIASES;
406 static struct ifmedia_description ifm_subtype_atm_descriptions[] =
407 IFM_SUBTYPE_ATM_DESCRIPTIONS;
409 static struct ifmedia_description ifm_subtype_atm_aliases[] =
410 IFM_SUBTYPE_ATM_ALIASES;
412 static struct ifmedia_description ifm_subtype_atm_option_descriptions[] =
413 IFM_SUBTYPE_ATM_OPTION_DESCRIPTIONS;
415 static struct ifmedia_description ifm_subtype_shared_descriptions[] =
416 IFM_SUBTYPE_SHARED_DESCRIPTIONS;
418 static struct ifmedia_description ifm_subtype_shared_aliases[] =
419 IFM_SUBTYPE_SHARED_ALIASES;
421 static struct ifmedia_description ifm_shared_option_descriptions[] =
422 IFM_SHARED_OPTION_DESCRIPTIONS;
424 static struct ifmedia_description ifm_shared_option_aliases[] =
425 IFM_SHARED_OPTION_ALIASES;
427 struct ifmedia_type_to_subtype {
429 struct ifmedia_description *desc;
433 struct ifmedia_description *desc;
437 struct ifmedia_description *desc;
442 /* must be in the same order as IFM_TYPE_DESCRIPTIONS */
443 static struct ifmedia_type_to_subtype ifmedia_types_to_subtypes[] = {
446 { &ifm_subtype_shared_descriptions[0], 0 },
447 { &ifm_subtype_shared_aliases[0], 1 },
448 { &ifm_subtype_ethernet_descriptions[0], 0 },
449 { &ifm_subtype_ethernet_aliases[0], 1 },
453 { &ifm_shared_option_descriptions[0], 0 },
454 { &ifm_shared_option_aliases[0], 1 },
455 { &ifm_subtype_ethernet_option_descriptions[0], 0 },
464 { &ifm_subtype_shared_descriptions[0], 0 },
465 { &ifm_subtype_shared_aliases[0], 1 },
466 { &ifm_subtype_tokenring_descriptions[0], 0 },
467 { &ifm_subtype_tokenring_aliases[0], 1 },
471 { &ifm_shared_option_descriptions[0], 0 },
472 { &ifm_shared_option_aliases[0], 1 },
473 { &ifm_subtype_tokenring_option_descriptions[0], 0 },
482 { &ifm_subtype_shared_descriptions[0], 0 },
483 { &ifm_subtype_shared_aliases[0], 1 },
484 { &ifm_subtype_fddi_descriptions[0], 0 },
485 { &ifm_subtype_fddi_aliases[0], 1 },
489 { &ifm_shared_option_descriptions[0], 0 },
490 { &ifm_shared_option_aliases[0], 1 },
491 { &ifm_subtype_fddi_option_descriptions[0], 0 },
500 { &ifm_subtype_shared_descriptions[0], 0 },
501 { &ifm_subtype_shared_aliases[0], 1 },
502 { &ifm_subtype_ieee80211_descriptions[0], 0 },
503 { &ifm_subtype_ieee80211_aliases[0], 1 },
507 { &ifm_shared_option_descriptions[0], 0 },
508 { &ifm_shared_option_aliases[0], 1 },
509 { &ifm_subtype_ieee80211_option_descriptions[0], 0 },
513 { &ifm_subtype_ieee80211_mode_descriptions[0], 0 },
514 { &ifm_subtype_ieee80211_mode_aliases[0], 0 },
520 { &ifm_subtype_shared_descriptions[0], 0 },
521 { &ifm_subtype_shared_aliases[0], 1 },
522 { &ifm_subtype_atm_descriptions[0], 0 },
523 { &ifm_subtype_atm_aliases[0], 1 },
527 { &ifm_shared_option_descriptions[0], 0 },
528 { &ifm_shared_option_aliases[0], 1 },
529 { &ifm_subtype_atm_option_descriptions[0], 0 },
539 get_media_subtype(int type, const char *val)
541 struct ifmedia_description *desc;
542 struct ifmedia_type_to_subtype *ttos;
545 /* Find the top-level interface type. */
546 for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes;
547 desc->ifmt_string != NULL; desc++, ttos++)
548 if (type == desc->ifmt_word)
550 if (desc->ifmt_string == NULL)
551 errx(1, "unknown media type 0x%x", type);
553 for (i = 0; ttos->subtypes[i].desc != NULL; i++) {
554 rval = lookup_media_word(ttos->subtypes[i].desc, val);
558 errx(1, "unknown media subtype: %s", val);
563 get_media_mode(int type, const char *val)
565 struct ifmedia_description *desc;
566 struct ifmedia_type_to_subtype *ttos;
569 /* Find the top-level interface type. */
570 for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes;
571 desc->ifmt_string != NULL; desc++, ttos++)
572 if (type == desc->ifmt_word)
574 if (desc->ifmt_string == NULL)
575 errx(1, "unknown media mode 0x%x", type);
577 for (i = 0; ttos->modes[i].desc != NULL; i++) {
578 rval = lookup_media_word(ttos->modes[i].desc, val);
586 get_media_options(int type, const char *val)
588 struct ifmedia_description *desc;
589 struct ifmedia_type_to_subtype *ttos;
590 char *optlist, *optptr;
591 int option = 0, i, rval = 0;
593 /* We muck with the string, so copy it. */
594 optlist = strdup(val);
598 /* Find the top-level interface type. */
599 for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes;
600 desc->ifmt_string != NULL; desc++, ttos++)
601 if (type == desc->ifmt_word)
603 if (desc->ifmt_string == NULL)
604 errx(1, "unknown media type 0x%x", type);
607 * Look up the options in the user-provided comma-separated
611 for (; (optptr = strtok(optptr, ",")) != NULL; optptr = NULL) {
612 for (i = 0; ttos->options[i].desc != NULL; i++) {
613 option = lookup_media_word(ttos->options[i].desc, optptr);
618 errx(1, "unknown option: %s", optptr);
627 lookup_media_word(struct ifmedia_description *desc, const char *val)
630 for (; desc->ifmt_string != NULL; desc++)
631 if (strcasecmp(desc->ifmt_string, val) == 0)
632 return (desc->ifmt_word);
637 static struct ifmedia_description *get_toptype_desc(int ifmw)
639 struct ifmedia_description *desc;
641 for (desc = ifm_type_descriptions; desc->ifmt_string != NULL; desc++)
642 if (IFM_TYPE(ifmw) == desc->ifmt_word)
648 static struct ifmedia_type_to_subtype *get_toptype_ttos(int ifmw)
650 struct ifmedia_description *desc;
651 struct ifmedia_type_to_subtype *ttos;
653 for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes;
654 desc->ifmt_string != NULL; desc++, ttos++)
655 if (IFM_TYPE(ifmw) == desc->ifmt_word)
661 static struct ifmedia_description *get_subtype_desc(int ifmw,
662 struct ifmedia_type_to_subtype *ttos)
665 struct ifmedia_description *desc;
667 for (i = 0; ttos->subtypes[i].desc != NULL; i++) {
668 if (ttos->subtypes[i].alias)
670 for (desc = ttos->subtypes[i].desc;
671 desc->ifmt_string != NULL; desc++) {
672 if (IFM_SUBTYPE(ifmw) == desc->ifmt_word)
680 static struct ifmedia_description *get_mode_desc(int ifmw,
681 struct ifmedia_type_to_subtype *ttos)
684 struct ifmedia_description *desc;
686 for (i = 0; ttos->modes[i].desc != NULL; i++) {
687 if (ttos->modes[i].alias)
689 for (desc = ttos->modes[i].desc;
690 desc->ifmt_string != NULL; desc++) {
691 if (IFM_MODE(ifmw) == desc->ifmt_word)
700 print_media_word(int ifmw, int print_toptype)
702 struct ifmedia_description *desc;
703 struct ifmedia_type_to_subtype *ttos;
704 int seen_option = 0, i;
706 /* Find the top-level interface type. */
707 desc = get_toptype_desc(ifmw);
708 ttos = get_toptype_ttos(ifmw);
709 if (desc->ifmt_string == NULL) {
710 printf("<unknown type>");
712 } else if (print_toptype) {
713 printf("%s", desc->ifmt_string);
717 * Don't print the top-level type; it's not like we can
718 * change it, or anything.
722 desc = get_subtype_desc(ifmw, ttos);
724 printf("<unknown subtype>");
731 printf("%s", desc->ifmt_string);
734 desc = get_mode_desc(ifmw, ttos);
735 if (desc != NULL && strcasecmp("autoselect", desc->ifmt_string))
736 printf(" mode %s", desc->ifmt_string);
740 for (i = 0; ttos->options[i].desc != NULL; i++) {
741 if (ttos->options[i].alias)
743 for (desc = ttos->options[i].desc;
744 desc->ifmt_string != NULL; desc++) {
745 if (ifmw & desc->ifmt_word) {
746 if (seen_option == 0)
748 printf("%s%s", seen_option++ ? "," : "",
753 printf("%s", seen_option ? ">" : "");
755 if (print_toptype && IFM_INST(ifmw) != 0)
756 printf(" instance %d", IFM_INST(ifmw));
760 print_media_word_ifconfig(int ifmw)
762 struct ifmedia_description *desc;
763 struct ifmedia_type_to_subtype *ttos;
764 int seen_option = 0, i;
766 /* Find the top-level interface type. */
767 desc = get_toptype_desc(ifmw);
768 ttos = get_toptype_ttos(ifmw);
769 if (desc->ifmt_string == NULL) {
770 printf("<unknown type>");
775 * Don't print the top-level type; it's not like we can
776 * change it, or anything.
780 desc = get_subtype_desc(ifmw, ttos);
782 printf("<unknown subtype>");
786 printf("media %s", desc->ifmt_string);
788 desc = get_mode_desc(ifmw, ttos);
790 printf(" mode %s", desc->ifmt_string);
793 for (i = 0; ttos->options[i].desc != NULL; i++) {
794 if (ttos->options[i].alias)
796 for (desc = ttos->options[i].desc;
797 desc->ifmt_string != NULL; desc++) {
798 if (ifmw & desc->ifmt_word) {
799 if (seen_option == 0)
800 printf(" mediaopt ");
801 printf("%s%s", seen_option++ ? "," : "",
807 if (IFM_INST(ifmw) != 0)
808 printf(" instance %d", IFM_INST(ifmw));
811 /**********************************************************************
813 **********************************************************************/
815 static struct cmd media_cmds[] = {
816 DEF_CMD_ARG("media", setmedia),
817 DEF_CMD_ARG("mode", setmediamode),
818 DEF_CMD_ARG("mediaopt", setmediaopt),
819 DEF_CMD_ARG("-mediaopt",unsetmediaopt),
820 DEF_CMD_ARG("inst", setmediainst),
821 DEF_CMD_ARG("instance", setmediainst),
823 static struct afswtch af_media = {
824 .af_name = "af_media",
826 .af_other_status = media_status,
829 static __constructor void
832 #define N(a) (sizeof(a) / sizeof(a[0]))
835 for (i = 0; i < N(media_cmds); i++)
836 cmd_register(&media_cmds[i]);
837 af_register(&af_media);