| 538 | } |
| 539 | |
| 540 | static int |
| 541 | get_media_mode(int type, const char *val) |
| 542 | { |
| 543 | struct ifmedia_description *desc; |
| 544 | struct ifmedia_type_to_subtype *ttos; |
| 545 | int rval, i; |
| 546 | |
| 547 | /* Find the top-level interface type. */ |
| 548 | for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes; |
| 549 | desc->ifmt_string != NULL; desc++, ttos++) |
| 550 | if (type == desc->ifmt_word) |
| 551 | break; |
| 552 | if (desc->ifmt_string == NULL) |
| 553 | errx(1, "unknown media mode 0x%x", type); |
| 554 | |
| 555 | for (i = 0; ttos->modes[i].desc != NULL; i++) { |
| 556 | rval = lookup_media_word(ttos->modes[i].desc, val); |
| 557 | if (rval != -1) |
| 558 | return (rval); |
| 559 | } |
| 560 | return -1; |
| 561 | } |
| 562 | |
| 563 | static int |
| 564 | get_media_options(int type, const char *val) |
no test coverage detected