| 676 | } |
| 677 | |
| 678 | static void |
| 679 | print_media_word(int ifmw, int print_toptype) |
| 680 | { |
| 681 | struct ifmedia_description *desc; |
| 682 | struct ifmedia_type_to_subtype *ttos; |
| 683 | int seen_option = 0, i; |
| 684 | |
| 685 | /* Find the top-level interface type. */ |
| 686 | desc = get_toptype_desc(ifmw); |
| 687 | ttos = get_toptype_ttos(ifmw); |
| 688 | if (desc->ifmt_string == NULL) { |
| 689 | printf("<unknown type>"); |
| 690 | return; |
| 691 | } else if (print_toptype) { |
| 692 | printf("%s", desc->ifmt_string); |
| 693 | } |
| 694 | |
| 695 | /* |
| 696 | * Don't print the top-level type; it's not like we can |
| 697 | * change it, or anything. |
| 698 | */ |
| 699 | |
| 700 | /* Find subtype. */ |
| 701 | desc = get_subtype_desc(ifmw, ttos); |
| 702 | if (desc == NULL) { |
| 703 | printf("<unknown subtype>"); |
| 704 | return; |
| 705 | } |
| 706 | |
| 707 | if (print_toptype) |
| 708 | putchar(' '); |
| 709 | |
| 710 | printf("%s", desc->ifmt_string); |
| 711 | |
| 712 | if (print_toptype) { |
| 713 | desc = get_mode_desc(ifmw, ttos); |
| 714 | if (desc != NULL && strcasecmp("autoselect", desc->ifmt_string)) |
| 715 | printf(" mode %s", desc->ifmt_string); |
| 716 | } |
| 717 | |
| 718 | /* Find options. */ |
| 719 | for (i = 0; ttos->options[i].desc != NULL; i++) { |
| 720 | if (ttos->options[i].alias) |
| 721 | continue; |
| 722 | for (desc = ttos->options[i].desc; |
| 723 | desc->ifmt_string != NULL; desc++) { |
| 724 | if (ifmw & desc->ifmt_word) { |
| 725 | if (seen_option == 0) |
| 726 | printf(" <"); |
| 727 | printf("%s%s", seen_option++ ? "," : "", |
| 728 | desc->ifmt_string); |
| 729 | } |
| 730 | } |
| 731 | } |
| 732 | printf("%s", seen_option ? ">" : ""); |
| 733 | |
| 734 | if (print_toptype && IFM_INST(ifmw) != 0) |
| 735 | printf(" instance %d", IFM_INST(ifmw)); |
no test coverage detected