From 73d88d4ee6b1984ac73e0c63224cb5f59052e471 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 13 Jun 2022 22:46:44 -0400 Subject: [PATCH] ifconfig: Add basic IEEE 802.11 media types to the list. This requires using the FreeBSD if_media.h (for now, anyway) and adding a subtype_mask to the data structures. But this does work. Now 802.11 media will be displayed in ifconfig and Network preferences. --- src/bin/network/ifconfig/MediaTypes.cpp | 37 +++++++++++++++++++++---- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/bin/network/ifconfig/MediaTypes.cpp b/src/bin/network/ifconfig/MediaTypes.cpp index ecead54a79..11c45b04d1 100644 --- a/src/bin/network/ifconfig/MediaTypes.cpp +++ b/src/bin/network/ifconfig/MediaTypes.cpp @@ -11,14 +11,19 @@ #include "MediaTypes.h" -#include +#include #include +extern "C" { +# include +} + struct media_type { int type; const char* name; const char* pretty; + int subtype_mask; struct { int subtype; const char* name; @@ -38,13 +43,14 @@ const media_type kMediaTypes[] = { 0, // for generic options "all", "All", + IFM_TMASK, { { IFM_AUTO, "auto", "Auto-select" }, { -1, NULL, NULL } }, { - { IFM_FULL_DUPLEX, true, "fullduplex", "Full Duplex" }, - { IFM_HALF_DUPLEX, true, "halfduplex", "Half Duplex" }, + { IFM_FDX, true, "fullduplex", "Full Duplex" }, + { IFM_HDX, true, "halfduplex", "Half Duplex" }, { IFM_LOOP, true, "loop", "Loop" }, //{ IFM_ACTIVE, false, "active", "Active" }, { -1, false, NULL, NULL } @@ -54,6 +60,7 @@ const media_type kMediaTypes[] = { IFM_ETHER, "ether", "Ethernet", + IFM_TMASK, { //{ IFM_AUTO, "auto", "Auto-select" }, //{ IFM_AUI, "AUI", "10 MBit, AUI" }, @@ -73,7 +80,26 @@ const media_type kMediaTypes[] = { { -1, false, NULL, NULL } } }, - { -1, NULL, NULL, {{ -1, NULL, NULL }}, {{ -1, false, NULL, NULL }} } + { + IFM_IEEE80211, + "80211", + "Wireless Ethernet", + IFM_MMASK, + { + { IFM_IEEE80211_11A, "802.11a", "802.11a" }, + { IFM_IEEE80211_11B, "802.11b", "802.11b" }, + { IFM_IEEE80211_11G, "802.11g", "802.11g" }, + { IFM_IEEE80211_FH, "802.11 FH", "802.11 FH" }, + { IFM_IEEE80211_11NA, "802.11n(a)", "802.11n(a)" }, + { IFM_IEEE80211_11NG, "802.11n(g)", "802.11n(g)" }, + { IFM_IEEE80211_VHT5G, "802.11ac", "802.11ac" }, + { -1, NULL, NULL } + }, + { + { -1, false, NULL, NULL } + } + }, + { -1, NULL, NULL, -1, {{ -1, NULL, NULL }}, {{ -1, false, NULL, NULL }} } }; @@ -132,8 +158,9 @@ media_type_to_string(int media) && kMediaTypes[i].type != IFM_TYPE(media)) continue; + const int subtype = (media & kMediaTypes[i].subtype_mask); for (size_t j = 0; kMediaTypes[i].subtypes[j].subtype >= 0; j++) { - if (kMediaTypes[i].subtypes[j].subtype == IFM_SUBTYPE(media)) { + if (kMediaTypes[i].subtypes[j].subtype == subtype) { // found a match return kMediaTypes[i].subtypes[j].pretty; }