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.
This commit is contained in:
@@ -11,14 +11,19 @@
|
|||||||
|
|
||||||
#include "MediaTypes.h"
|
#include "MediaTypes.h"
|
||||||
|
|
||||||
#include <net/if_media.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
# include <freebsd_network/compat/net/if_media.h>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct media_type {
|
struct media_type {
|
||||||
int type;
|
int type;
|
||||||
const char* name;
|
const char* name;
|
||||||
const char* pretty;
|
const char* pretty;
|
||||||
|
int subtype_mask;
|
||||||
struct {
|
struct {
|
||||||
int subtype;
|
int subtype;
|
||||||
const char* name;
|
const char* name;
|
||||||
@@ -38,13 +43,14 @@ const media_type kMediaTypes[] = {
|
|||||||
0, // for generic options
|
0, // for generic options
|
||||||
"all",
|
"all",
|
||||||
"All",
|
"All",
|
||||||
|
IFM_TMASK,
|
||||||
{
|
{
|
||||||
{ IFM_AUTO, "auto", "Auto-select" },
|
{ IFM_AUTO, "auto", "Auto-select" },
|
||||||
{ -1, NULL, NULL }
|
{ -1, NULL, NULL }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{ IFM_FULL_DUPLEX, true, "fullduplex", "Full Duplex" },
|
{ IFM_FDX, true, "fullduplex", "Full Duplex" },
|
||||||
{ IFM_HALF_DUPLEX, true, "halfduplex", "Half Duplex" },
|
{ IFM_HDX, true, "halfduplex", "Half Duplex" },
|
||||||
{ IFM_LOOP, true, "loop", "Loop" },
|
{ IFM_LOOP, true, "loop", "Loop" },
|
||||||
//{ IFM_ACTIVE, false, "active", "Active" },
|
//{ IFM_ACTIVE, false, "active", "Active" },
|
||||||
{ -1, false, NULL, NULL }
|
{ -1, false, NULL, NULL }
|
||||||
@@ -54,6 +60,7 @@ const media_type kMediaTypes[] = {
|
|||||||
IFM_ETHER,
|
IFM_ETHER,
|
||||||
"ether",
|
"ether",
|
||||||
"Ethernet",
|
"Ethernet",
|
||||||
|
IFM_TMASK,
|
||||||
{
|
{
|
||||||
//{ IFM_AUTO, "auto", "Auto-select" },
|
//{ IFM_AUTO, "auto", "Auto-select" },
|
||||||
//{ IFM_AUI, "AUI", "10 MBit, AUI" },
|
//{ IFM_AUI, "AUI", "10 MBit, AUI" },
|
||||||
@@ -73,7 +80,26 @@ const media_type kMediaTypes[] = {
|
|||||||
{ -1, false, NULL, NULL }
|
{ -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))
|
&& kMediaTypes[i].type != IFM_TYPE(media))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
const int subtype = (media & kMediaTypes[i].subtype_mask);
|
||||||
for (size_t j = 0; kMediaTypes[i].subtypes[j].subtype >= 0; j++) {
|
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
|
// found a match
|
||||||
return kMediaTypes[i].subtypes[j].pretty;
|
return kMediaTypes[i].subtypes[j].pretty;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user