if_media.c revision 1.1 1 1.1 thorpej /* $NetBSD: if_media.c,v 1.1 1997/03/17 02:55:15 thorpej Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*
4 1.1 thorpej * Copyright (c) 1997
5 1.1 thorpej * Jonathan Stone and Jason R. Thorpe. All rights reserved.
6 1.1 thorpej *
7 1.1 thorpej * This software is derived from information provided by Matt Thomas.
8 1.1 thorpej *
9 1.1 thorpej * Redistribution and use in source and binary forms, with or without
10 1.1 thorpej * modification, are permitted provided that the following conditions
11 1.1 thorpej * are met:
12 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
13 1.1 thorpej * notice, this list of conditions and the following disclaimer.
14 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
16 1.1 thorpej * documentation and/or other materials provided with the distribution.
17 1.1 thorpej * 3. All advertising materials mentioning features or use of this software
18 1.1 thorpej * must display the following acknowledgement:
19 1.1 thorpej * This product includes software developed by Jonathan Stone
20 1.1 thorpej * and Jason R. Thorpe for the NetBSD Project.
21 1.1 thorpej * 4. The names of the authors may not be used to endorse or promote products
22 1.1 thorpej * derived from this software without specific prior written permission.
23 1.1 thorpej *
24 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
25 1.1 thorpej * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 1.1 thorpej * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 1.1 thorpej * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 1.1 thorpej * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 1.1 thorpej * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 1.1 thorpej * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31 1.1 thorpej * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 1.1 thorpej * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 1.1 thorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 1.1 thorpej * SUCH DAMAGE.
35 1.1 thorpej */
36 1.1 thorpej
37 1.1 thorpej /*
38 1.1 thorpej * BSD/OS-compatible network interface media selection.
39 1.1 thorpej *
40 1.1 thorpej * Where it is safe to do so, this code strays slightly from the BSD/OS
41 1.1 thorpej * design. Software which uses the API (device drivers, basically)
42 1.1 thorpej * shouldn't notice any difference.
43 1.1 thorpej *
44 1.1 thorpej * Many thanks to Matt Thomas for providing the information necessary
45 1.1 thorpej * to implement this interface.
46 1.1 thorpej */
47 1.1 thorpej
48 1.1 thorpej #include <sys/param.h>
49 1.1 thorpej #include <sys/systm.h>
50 1.1 thorpej #include <sys/errno.h>
51 1.1 thorpej #include <sys/ioctl.h>
52 1.1 thorpej #include <sys/socket.h>
53 1.1 thorpej #include <sys/malloc.h>
54 1.1 thorpej
55 1.1 thorpej #include <net/if.h>
56 1.1 thorpej #include <net/if_media.h>
57 1.1 thorpej #include <net/netisr.h>
58 1.1 thorpej
59 1.1 thorpej /*
60 1.1 thorpej * Compile-time options:
61 1.1 thorpej * IFMEDIA_DEBUG:
62 1.1 thorpej * turn on implementation-level debug printfs.
63 1.1 thorpej * Useful for debugging newly-ported drivers.
64 1.1 thorpej */
65 1.1 thorpej
66 1.1 thorpej struct ifmedia_entry *ifmedia_match __P((struct ifmedia *ifm,
67 1.1 thorpej int flags, int mask));
68 1.1 thorpej
69 1.1 thorpej #ifdef IFMEDIA_DEBUG
70 1.1 thorpej int ifmedia_debug = 0;
71 1.1 thorpej static void ifmedia_printword __P((int));
72 1.1 thorpej #endif
73 1.1 thorpej
74 1.1 thorpej /*
75 1.1 thorpej * Initialize if_media struct for a specific interface instance.
76 1.1 thorpej */
77 1.1 thorpej void
78 1.1 thorpej ifmedia_init(ifm, dontcare_mask, change_callback, status_callback)
79 1.1 thorpej struct ifmedia *ifm;
80 1.1 thorpej int dontcare_mask;
81 1.1 thorpej ifm_change_cb_t change_callback;
82 1.1 thorpej ifm_stat_cb_t status_callback;
83 1.1 thorpej {
84 1.1 thorpej
85 1.1 thorpej LIST_INIT(&ifm->ifm_list);
86 1.1 thorpej ifm->ifm_cur = NULL;
87 1.1 thorpej ifm->ifm_media = 0;
88 1.1 thorpej ifm->ifm_mask = dontcare_mask; /* IF don't-care bits */
89 1.1 thorpej ifm->ifm_change = change_callback;
90 1.1 thorpej ifm->ifm_status = status_callback;
91 1.1 thorpej }
92 1.1 thorpej
93 1.1 thorpej /*
94 1.1 thorpej * Add a media configuration to the list of supported media
95 1.1 thorpej * for a specific interface instance.
96 1.1 thorpej */
97 1.1 thorpej void
98 1.1 thorpej ifmedia_add(ifm, mword, data, aux)
99 1.1 thorpej struct ifmedia *ifm;
100 1.1 thorpej int mword;
101 1.1 thorpej int data;
102 1.1 thorpej void *aux;
103 1.1 thorpej {
104 1.1 thorpej register struct ifmedia_entry *entry;
105 1.1 thorpej
106 1.1 thorpej #ifdef IFMEDIA_DEBUG
107 1.1 thorpej if (ifmedia_debug) {
108 1.1 thorpej if (ifm == NULL) {
109 1.1 thorpej printf("ifmedia_add: null ifm\n");
110 1.1 thorpej return;
111 1.1 thorpej }
112 1.1 thorpej printf("Adding entry for ");
113 1.1 thorpej ifmedia_printword(mword);
114 1.1 thorpej }
115 1.1 thorpej #endif
116 1.1 thorpej
117 1.1 thorpej entry = malloc(sizeof(*entry), M_IFADDR, M_NOWAIT);
118 1.1 thorpej if (entry == NULL)
119 1.1 thorpej panic("ifmedia_add: can't malloc entry");
120 1.1 thorpej
121 1.1 thorpej entry->ifm_media = mword;
122 1.1 thorpej entry->ifm_data = data;
123 1.1 thorpej entry->ifm_aux = aux;
124 1.1 thorpej
125 1.1 thorpej LIST_INSERT_HEAD(&ifm->ifm_list, entry, ifm_list);
126 1.1 thorpej }
127 1.1 thorpej
128 1.1 thorpej /*
129 1.1 thorpej * Add an array of media configurations to the list of
130 1.1 thorpej * supported media for a specific interface instance.
131 1.1 thorpej */
132 1.1 thorpej void
133 1.1 thorpej ifmedia_list_add(ifm, lp, count)
134 1.1 thorpej struct ifmedia *ifm;
135 1.1 thorpej struct ifmedia_entry *lp;
136 1.1 thorpej int count;
137 1.1 thorpej {
138 1.1 thorpej int i;
139 1.1 thorpej
140 1.1 thorpej for (i = 0; i < count; i++)
141 1.1 thorpej ifmedia_add(ifm, lp[i].ifm_media, lp[i].ifm_data,
142 1.1 thorpej lp[i].ifm_aux);
143 1.1 thorpej }
144 1.1 thorpej
145 1.1 thorpej /*
146 1.1 thorpej * Set the default active media.
147 1.1 thorpej *
148 1.1 thorpej * Called by device-specific code which is assumed to have already
149 1.1 thorpej * selected the default media in hardware. We do _not_ call the
150 1.1 thorpej * media-change callback.
151 1.1 thorpej */
152 1.1 thorpej void
153 1.1 thorpej ifmedia_set(ifm, target)
154 1.1 thorpej struct ifmedia *ifm;
155 1.1 thorpej int target;
156 1.1 thorpej
157 1.1 thorpej {
158 1.1 thorpej struct ifmedia_entry *match;
159 1.1 thorpej
160 1.1 thorpej match = ifmedia_match(ifm, target, ifm->ifm_mask);
161 1.1 thorpej
162 1.1 thorpej if (match == NULL) {
163 1.1 thorpej printf("ifmedia_set: no match for 0x%x/0x%x\n",
164 1.1 thorpej target, ~ifm->ifm_mask);
165 1.1 thorpej panic("ifmedia_set");
166 1.1 thorpej }
167 1.1 thorpej ifm->ifm_cur = match;
168 1.1 thorpej
169 1.1 thorpej #ifdef IFMEDIA_DEBUG
170 1.1 thorpej if (ifmedia_debug) {
171 1.1 thorpej printf("ifmedia_set: target ");
172 1.1 thorpej ifmedia_printword(target);
173 1.1 thorpej printf("ifmedia_set: setting to ");
174 1.1 thorpej ifmedia_printword(ifm->ifm_cur->ifm_media);
175 1.1 thorpej }
176 1.1 thorpej #endif
177 1.1 thorpej }
178 1.1 thorpej
179 1.1 thorpej /*
180 1.1 thorpej * Device-independent media ioctl support function.
181 1.1 thorpej */
182 1.1 thorpej int
183 1.1 thorpej ifmedia_ioctl(ifp, ifr, ifm, cmd)
184 1.1 thorpej struct ifnet *ifp;
185 1.1 thorpej struct ifreq *ifr;
186 1.1 thorpej struct ifmedia *ifm;
187 1.1 thorpej u_long cmd;
188 1.1 thorpej {
189 1.1 thorpej struct ifmedia_entry *match;
190 1.1 thorpej struct ifmediareq *ifmr = (struct ifmediareq *) ifr;
191 1.1 thorpej int error = 0, sticky;
192 1.1 thorpej
193 1.1 thorpej if (ifp == NULL || ifr == NULL || ifm == NULL)
194 1.1 thorpej return(EINVAL);
195 1.1 thorpej
196 1.1 thorpej switch (cmd) {
197 1.1 thorpej
198 1.1 thorpej /*
199 1.1 thorpej * Set the current media.
200 1.1 thorpej */
201 1.1 thorpej case SIOCSIFMEDIA:
202 1.1 thorpej {
203 1.1 thorpej struct ifmedia_entry *oldentry;
204 1.1 thorpej int oldmedia;
205 1.1 thorpej int newmedia = ifr->ifr_media;
206 1.1 thorpej
207 1.1 thorpej match = ifmedia_match(ifm, newmedia, ifm->ifm_mask);
208 1.1 thorpej if (match == NULL) {
209 1.1 thorpej #ifdef IFMEDIA_DEBUG
210 1.1 thorpej if (ifmedia_debug) {
211 1.1 thorpej printf(
212 1.1 thorpej "ifmedia_ioctl: no media found for 0x%x\n",
213 1.1 thorpej newmedia);
214 1.1 thorpej }
215 1.1 thorpej #endif
216 1.1 thorpej return (ENXIO);
217 1.1 thorpej }
218 1.1 thorpej
219 1.1 thorpej /*
220 1.1 thorpej * If no change, we're done.
221 1.1 thorpej * XXX Automedia may invole software intervention.
222 1.1 thorpej * Keep going in case the the connected media changed.
223 1.1 thorpej * Similarly, if best match changed (kernel debugger?).
224 1.1 thorpej */
225 1.1 thorpej if ((IFM_SUBTYPE(newmedia) != IFM_AUTO) &&
226 1.1 thorpej (newmedia == ifm->ifm_media) &&
227 1.1 thorpej (match == ifm->ifm_cur))
228 1.1 thorpej return 0;
229 1.1 thorpej
230 1.1 thorpej /*
231 1.1 thorpej * We found a match, now make the driver switch to it.
232 1.1 thorpej * Make sure to preserve our old media type in case the
233 1.1 thorpej * driver can't switch.
234 1.1 thorpej */
235 1.1 thorpej #ifdef IFMEDIA_DEBUG
236 1.1 thorpej if (ifmedia_debug) {
237 1.1 thorpej printf("ifmedia_ioctl: switching %s to ",
238 1.1 thorpej ifp->if_xname);
239 1.1 thorpej ifmedia_printword(match->ifm_media);
240 1.1 thorpej }
241 1.1 thorpej #endif
242 1.1 thorpej oldentry = ifm->ifm_cur;
243 1.1 thorpej oldmedia = ifm->ifm_media;
244 1.1 thorpej ifm->ifm_cur = match;
245 1.1 thorpej ifm->ifm_media = newmedia;
246 1.1 thorpej error = (*ifm->ifm_change)(ifp);
247 1.1 thorpej if (error) {
248 1.1 thorpej ifm->ifm_cur = oldentry;
249 1.1 thorpej ifm->ifm_media = oldmedia;
250 1.1 thorpej }
251 1.1 thorpej break;
252 1.1 thorpej }
253 1.1 thorpej
254 1.1 thorpej /*
255 1.1 thorpej * Get list of available media and current media on interface.
256 1.1 thorpej */
257 1.1 thorpej case SIOCGIFMEDIA:
258 1.1 thorpej {
259 1.1 thorpej struct ifmedia_entry *ep;
260 1.1 thorpej int *kptr, count;
261 1.1 thorpej
262 1.1 thorpej kptr = NULL; /* XXX gcc */
263 1.1 thorpej
264 1.1 thorpej ifmr->ifm_active = ifmr->ifm_current = ifm->ifm_cur ?
265 1.1 thorpej ifm->ifm_cur->ifm_media : IFM_NONE;
266 1.1 thorpej ifmr->ifm_mask = ifm->ifm_mask;
267 1.1 thorpej ifmr->ifm_status = 0;
268 1.1 thorpej (*ifm->ifm_status)(ifp, ifmr);
269 1.1 thorpej
270 1.1 thorpej count = 0;
271 1.1 thorpej ep = ifm->ifm_list.lh_first;
272 1.1 thorpej
273 1.1 thorpej if (ifmr->ifm_count != 0) {
274 1.1 thorpej kptr = (int *)malloc(ifmr->ifm_count * sizeof(int),
275 1.1 thorpej M_TEMP, M_WAITOK);
276 1.1 thorpej
277 1.1 thorpej /*
278 1.1 thorpej * Get the media words from the interface's list.
279 1.1 thorpej */
280 1.1 thorpej for (; ep != NULL && count < ifmr->ifm_count;
281 1.1 thorpej ep = ep->ifm_list.le_next, count++)
282 1.1 thorpej kptr[count] = ep->ifm_media;
283 1.1 thorpej
284 1.1 thorpej if (ep != NULL)
285 1.1 thorpej error = E2BIG; /* oops! */
286 1.1 thorpej }
287 1.1 thorpej
288 1.1 thorpej /*
289 1.1 thorpej * If there are more interfaces on the list, count
290 1.1 thorpej * them. This allows the caller to set ifmr->ifm_count
291 1.1 thorpej * to 0 on the first call to know how much space to
292 1.1 thorpej * callocate.
293 1.1 thorpej */
294 1.1 thorpej for (; ep != NULL; ep = ep->ifm_list.le_next)
295 1.1 thorpej count++;
296 1.1 thorpej
297 1.1 thorpej /*
298 1.1 thorpej * We do the copyout on E2BIG, because that's
299 1.1 thorpej * just our way of telling userland that there
300 1.1 thorpej * are more. This is the behavior I've observed
301 1.1 thorpej * under BSD/OS 3.0
302 1.1 thorpej */
303 1.1 thorpej sticky = error;
304 1.1 thorpej if ((error == 0 || error == E2BIG) && ifmr->ifm_count != 0) {
305 1.1 thorpej error = copyout((caddr_t)kptr,
306 1.1 thorpej (caddr_t)ifmr->ifm_ulist,
307 1.1 thorpej ifmr->ifm_count * sizeof(int));
308 1.1 thorpej }
309 1.1 thorpej
310 1.1 thorpej if (error == 0)
311 1.1 thorpej error = sticky;
312 1.1 thorpej
313 1.1 thorpej if (ifmr->ifm_count != 0)
314 1.1 thorpej free(kptr, M_TEMP);
315 1.1 thorpej
316 1.1 thorpej ifmr->ifm_count = count;
317 1.1 thorpej break;
318 1.1 thorpej }
319 1.1 thorpej
320 1.1 thorpej default:
321 1.1 thorpej return (EINVAL);
322 1.1 thorpej }
323 1.1 thorpej
324 1.1 thorpej return (error);
325 1.1 thorpej }
326 1.1 thorpej
327 1.1 thorpej /*
328 1.1 thorpej * Find media entry matching a given ifm word.
329 1.1 thorpej *
330 1.1 thorpej */
331 1.1 thorpej struct ifmedia_entry *
332 1.1 thorpej ifmedia_match(ifm, target, mask)
333 1.1 thorpej struct ifmedia *ifm;
334 1.1 thorpej int target;
335 1.1 thorpej int mask;
336 1.1 thorpej {
337 1.1 thorpej struct ifmedia_entry *match, *next;
338 1.1 thorpej
339 1.1 thorpej match = NULL;
340 1.1 thorpej mask = ~mask;
341 1.1 thorpej
342 1.1 thorpej for (next = ifm->ifm_list.lh_first; next != NULL;
343 1.1 thorpej next = next->ifm_list.le_next) {
344 1.1 thorpej if ((next->ifm_media & mask) == (target & mask)) {
345 1.1 thorpej #if defined(IFMEDIA_DEBUG) || defined(DIAGNOSTIC)
346 1.1 thorpej if (match) {
347 1.1 thorpej printf("ifmedia_match: multiple match for "
348 1.1 thorpej "0x%x/0x%x\n", target, mask);
349 1.1 thorpej }
350 1.1 thorpej #endif
351 1.1 thorpej match = next;
352 1.1 thorpej }
353 1.1 thorpej }
354 1.1 thorpej
355 1.1 thorpej return match;
356 1.1 thorpej }
357 1.1 thorpej
358 1.1 thorpej #ifdef IFMEDIA_DEBUG
359 1.1 thorpej struct ifmedia_description ifm_type_descriptions[] =
360 1.1 thorpej IFM_TYPE_DESCRIPTIONS;
361 1.1 thorpej
362 1.1 thorpej struct ifmedia_description ifm_subtype_ethernet_descriptions[] =
363 1.1 thorpej IFM_SUBTYPE_ETHERNET_DESCRIPTIONS;
364 1.1 thorpej
365 1.1 thorpej struct ifmedia_description ifm_subtype_ethernet_option_descriptions[] =
366 1.1 thorpej IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS;
367 1.1 thorpej
368 1.1 thorpej struct ifmedia_description ifm_subtype_tokenring_descriptions[] =
369 1.1 thorpej IFM_SUBTYPE_TOKENRING_DESCRIPTIONS;
370 1.1 thorpej
371 1.1 thorpej struct ifmedia_description ifm_subtype_tokenring_option_descriptions[] =
372 1.1 thorpej IFM_SUBTYPE_TOKENRING_OPTION_DESCRIPTIONS;
373 1.1 thorpej
374 1.1 thorpej struct ifmedia_description ifm_subtype_fddi_descriptions[] =
375 1.1 thorpej IFM_SUBTYPE_FDDI_DESCRIPTIONS;
376 1.1 thorpej
377 1.1 thorpej struct ifmedia_description ifm_subtype_fddi_option_descriptions[] =
378 1.1 thorpej IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS;
379 1.1 thorpej
380 1.1 thorpej struct ifmedia_description ifm_subtype_shared_descriptions[] =
381 1.1 thorpej IFM_SUBTYPE_SHARED_DESCRIPTIONS;
382 1.1 thorpej
383 1.1 thorpej struct ifmedia_description ifm_shared_option_descriptions[] =
384 1.1 thorpej IFM_SHARED_OPTION_DESCRIPTIONS;
385 1.1 thorpej
386 1.1 thorpej struct ifmedia_type_to_subtype {
387 1.1 thorpej struct ifmedia_description *subtypes;
388 1.1 thorpej struct ifmedia_description *options;
389 1.1 thorpej };
390 1.1 thorpej
391 1.1 thorpej /* must be in the same order as IFM_TYPE_DESCRIPTIONS */
392 1.1 thorpej struct ifmedia_type_to_subtype ifmedia_types_to_subtypes[] = {
393 1.1 thorpej {
394 1.1 thorpej &ifm_subtype_ethernet_descriptions[0],
395 1.1 thorpej &ifm_subtype_ethernet_option_descriptions[0]
396 1.1 thorpej },
397 1.1 thorpej {
398 1.1 thorpej &ifm_subtype_tokenring_descriptions[0],
399 1.1 thorpej &ifm_subtype_tokenring_option_descriptions[0]
400 1.1 thorpej },
401 1.1 thorpej {
402 1.1 thorpej &ifm_subtype_fddi_descriptions[0],
403 1.1 thorpej &ifm_subtype_fddi_option_descriptions[0]
404 1.1 thorpej },
405 1.1 thorpej };
406 1.1 thorpej
407 1.1 thorpej /*
408 1.1 thorpej * print a media word.
409 1.1 thorpej */
410 1.1 thorpej static void
411 1.1 thorpej ifmedia_printword(ifmw)
412 1.1 thorpej int ifmw;
413 1.1 thorpej {
414 1.1 thorpej struct ifmedia_description *desc;
415 1.1 thorpej struct ifmedia_type_to_subtype *ttos;
416 1.1 thorpej int seen_option = 0;
417 1.1 thorpej
418 1.1 thorpej /* Find the top-level interface type. */
419 1.1 thorpej for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes;
420 1.1 thorpej desc->ifmt_string != NULL; desc++, ttos++)
421 1.1 thorpej if (IFM_TYPE(ifmw) == desc->ifmt_word)
422 1.1 thorpej break;
423 1.1 thorpej if (desc->ifmt_string == NULL) {
424 1.1 thorpej printf("<unknown type>\n");
425 1.1 thorpej return;
426 1.1 thorpej }
427 1.1 thorpej printf(desc->ifmt_string);
428 1.1 thorpej
429 1.1 thorpej /*
430 1.1 thorpej * Check for the shared subtype descriptions first, then the
431 1.1 thorpej * type-specific ones.
432 1.1 thorpej */
433 1.1 thorpej for (desc = ifm_subtype_shared_descriptions;
434 1.1 thorpej desc->ifmt_string != NULL; desc++)
435 1.1 thorpej if (IFM_SUBTYPE(ifmw) == desc->ifmt_word)
436 1.1 thorpej goto got_subtype;
437 1.1 thorpej
438 1.1 thorpej for (desc = ttos->subtypes; desc->ifmt_string != NULL; desc++)
439 1.1 thorpej if (IFM_SUBTYPE(ifmw) == desc->ifmt_word)
440 1.1 thorpej break;
441 1.1 thorpej if (desc->ifmt_string == NULL) {
442 1.1 thorpej printf(" <unknown subtype>\n");
443 1.1 thorpej return;
444 1.1 thorpej }
445 1.1 thorpej
446 1.1 thorpej got_subtype:
447 1.1 thorpej printf(" %s", desc->ifmt_string);
448 1.1 thorpej
449 1.1 thorpej /*
450 1.1 thorpej * Look for shared options.
451 1.1 thorpej */
452 1.1 thorpej for (desc = ifm_shared_option_descriptions;
453 1.1 thorpej desc->ifmt_string != NULL; desc++) {
454 1.1 thorpej if (ifmw & desc->ifmt_word) {
455 1.1 thorpej if (seen_option == 0)
456 1.1 thorpej printf(" <");
457 1.1 thorpej printf("%s%s", seen_option++ ? "," : "",
458 1.1 thorpej desc->ifmt_string);
459 1.1 thorpej }
460 1.1 thorpej }
461 1.1 thorpej
462 1.1 thorpej /*
463 1.1 thorpej * Look for subtype-specific options.
464 1.1 thorpej */
465 1.1 thorpej for (desc = ttos->options; desc->ifmt_string != NULL; desc++) {
466 1.1 thorpej if (ifmw & desc->ifmt_word) {
467 1.1 thorpej if (seen_option == 0)
468 1.1 thorpej printf(" <");
469 1.1 thorpej printf("%s%s", seen_option++ ? "," : "",
470 1.1 thorpej desc->ifmt_string);
471 1.1 thorpej }
472 1.1 thorpej }
473 1.1 thorpej printf("%s\n", seen_option ? ">" : "");
474 1.1 thorpej }
475 1.1 thorpej #endif /* IFMEDIA_DEBUG */
476