net: wifi: Move function from shell to mgmt
The CONFIG_NET_L2_WIFI_SHELL isn't always enabled. But these functions might still be used, so need to move functions into mgmt. Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
This commit is contained in:
parent
6d23a960db
commit
29bbcb1e38
2 changed files with 218 additions and 218 deletions
|
@ -17,6 +17,224 @@ LOG_MODULE_REGISTER(net_wifi_mgmt, CONFIG_NET_L2_WIFI_MGMT_LOG_LEVEL);
|
||||||
#include <zephyr/net/wifi_nm.h>
|
#include <zephyr/net/wifi_nm.h>
|
||||||
#endif /* CONFIG_WIFI_NM */
|
#endif /* CONFIG_WIFI_NM */
|
||||||
|
|
||||||
|
const char * const wifi_security_txt(enum wifi_security_type security)
|
||||||
|
{
|
||||||
|
switch (security) {
|
||||||
|
case WIFI_SECURITY_TYPE_NONE:
|
||||||
|
return "OPEN";
|
||||||
|
case WIFI_SECURITY_TYPE_WEP:
|
||||||
|
return "WEP";
|
||||||
|
case WIFI_SECURITY_TYPE_WPA_PSK:
|
||||||
|
return "WPA-PSK";
|
||||||
|
case WIFI_SECURITY_TYPE_PSK:
|
||||||
|
return "WPA2-PSK";
|
||||||
|
case WIFI_SECURITY_TYPE_PSK_SHA256:
|
||||||
|
return "WPA2-PSK-SHA256";
|
||||||
|
case WIFI_SECURITY_TYPE_SAE:
|
||||||
|
return "WPA3-SAE";
|
||||||
|
case WIFI_SECURITY_TYPE_WAPI:
|
||||||
|
return "WAPI";
|
||||||
|
case WIFI_SECURITY_TYPE_EAP:
|
||||||
|
return "EAP";
|
||||||
|
case WIFI_SECURITY_TYPE_UNKNOWN:
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * const wifi_mfp_txt(enum wifi_mfp_options mfp)
|
||||||
|
{
|
||||||
|
switch (mfp) {
|
||||||
|
case WIFI_MFP_DISABLE:
|
||||||
|
return "Disable";
|
||||||
|
case WIFI_MFP_OPTIONAL:
|
||||||
|
return "Optional";
|
||||||
|
case WIFI_MFP_REQUIRED:
|
||||||
|
return "Required";
|
||||||
|
case WIFI_MFP_UNKNOWN:
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * const wifi_band_txt(enum wifi_frequency_bands band)
|
||||||
|
{
|
||||||
|
switch (band) {
|
||||||
|
case WIFI_FREQ_BAND_2_4_GHZ:
|
||||||
|
return "2.4GHz";
|
||||||
|
case WIFI_FREQ_BAND_5_GHZ:
|
||||||
|
return "5GHz";
|
||||||
|
case WIFI_FREQ_BAND_6_GHZ:
|
||||||
|
return "6GHz";
|
||||||
|
case WIFI_FREQ_BAND_UNKNOWN:
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * const wifi_state_txt(enum wifi_iface_state state)
|
||||||
|
{
|
||||||
|
switch (state) {
|
||||||
|
case WIFI_STATE_DISCONNECTED:
|
||||||
|
return "DISCONNECTED";
|
||||||
|
case WIFI_STATE_INACTIVE:
|
||||||
|
return "INACTIVE";
|
||||||
|
case WIFI_STATE_INTERFACE_DISABLED:
|
||||||
|
return "INTERFACE_DISABLED";
|
||||||
|
case WIFI_STATE_SCANNING:
|
||||||
|
return "SCANNING";
|
||||||
|
case WIFI_STATE_AUTHENTICATING:
|
||||||
|
return "AUTHENTICATING";
|
||||||
|
case WIFI_STATE_ASSOCIATING:
|
||||||
|
return "ASSOCIATING";
|
||||||
|
case WIFI_STATE_ASSOCIATED:
|
||||||
|
return "ASSOCIATED";
|
||||||
|
case WIFI_STATE_4WAY_HANDSHAKE:
|
||||||
|
return "4WAY_HANDSHAKE";
|
||||||
|
case WIFI_STATE_GROUP_HANDSHAKE:
|
||||||
|
return "GROUP_HANDSHAKE";
|
||||||
|
case WIFI_STATE_COMPLETED:
|
||||||
|
return "COMPLETED";
|
||||||
|
case WIFI_STATE_UNKNOWN:
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * const wifi_mode_txt(enum wifi_iface_mode mode)
|
||||||
|
{
|
||||||
|
switch (mode) {
|
||||||
|
case WIFI_MODE_INFRA:
|
||||||
|
return "STATION";
|
||||||
|
case WIFI_MODE_IBSS:
|
||||||
|
return "ADHOC";
|
||||||
|
case WIFI_MODE_AP:
|
||||||
|
return "ACCESS POINT";
|
||||||
|
case WIFI_MODE_P2P_GO:
|
||||||
|
return "P2P GROUP OWNER";
|
||||||
|
case WIFI_MODE_P2P_GROUP_FORMATION:
|
||||||
|
return "P2P GROUP FORMATION";
|
||||||
|
case WIFI_MODE_MESH:
|
||||||
|
return "MESH";
|
||||||
|
case WIFI_MODE_UNKNOWN:
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * const wifi_link_mode_txt(enum wifi_link_mode link_mode)
|
||||||
|
{
|
||||||
|
switch (link_mode) {
|
||||||
|
case WIFI_0:
|
||||||
|
return "WIFI 0 (802.11)";
|
||||||
|
case WIFI_1:
|
||||||
|
return "WIFI 1 (802.11b)";
|
||||||
|
case WIFI_2:
|
||||||
|
return "WIFI 2 (802.11a)";
|
||||||
|
case WIFI_3:
|
||||||
|
return "WIFI 3 (802.11g)";
|
||||||
|
case WIFI_4:
|
||||||
|
return "WIFI 4 (802.11n/HT)";
|
||||||
|
case WIFI_5:
|
||||||
|
return "WIFI 5 (802.11ac/VHT)";
|
||||||
|
case WIFI_6:
|
||||||
|
return "WIFI 6 (802.11ax/HE)";
|
||||||
|
case WIFI_6E:
|
||||||
|
return "WIFI 6E (802.11ax 6GHz/HE)";
|
||||||
|
case WIFI_7:
|
||||||
|
return "WIFI 7 (802.11be/EHT)";
|
||||||
|
case WIFI_LINK_MODE_UNKNOWN:
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * const wifi_ps_txt(enum wifi_ps ps_name)
|
||||||
|
{
|
||||||
|
switch (ps_name) {
|
||||||
|
case WIFI_PS_DISABLED:
|
||||||
|
return "Power save disabled";
|
||||||
|
case WIFI_PS_ENABLED:
|
||||||
|
return "Power save enabled";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * const wifi_ps_mode_txt(enum wifi_ps_mode ps_mode)
|
||||||
|
{
|
||||||
|
switch (ps_mode) {
|
||||||
|
case WIFI_PS_MODE_LEGACY:
|
||||||
|
return "Legacy power save";
|
||||||
|
case WIFI_PS_MODE_WMM:
|
||||||
|
return "WMM power save";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * const wifi_twt_operation_txt(enum wifi_twt_operation twt_operation)
|
||||||
|
{
|
||||||
|
switch (twt_operation) {
|
||||||
|
case WIFI_TWT_SETUP:
|
||||||
|
return "TWT setup";
|
||||||
|
case WIFI_TWT_TEARDOWN:
|
||||||
|
return "TWT teardown";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * const wifi_twt_negotiation_type_txt(enum wifi_twt_negotiation_type twt_negotiation)
|
||||||
|
{
|
||||||
|
switch (twt_negotiation) {
|
||||||
|
case WIFI_TWT_INDIVIDUAL:
|
||||||
|
return "TWT individual negotiation";
|
||||||
|
case WIFI_TWT_BROADCAST:
|
||||||
|
return "TWT broadcast negotiation";
|
||||||
|
case WIFI_TWT_WAKE_TBTT:
|
||||||
|
return "TWT wake TBTT negotiation";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * const wifi_twt_setup_cmd_txt(enum wifi_twt_setup_cmd twt_setup)
|
||||||
|
{
|
||||||
|
switch (twt_setup) {
|
||||||
|
case WIFI_TWT_SETUP_CMD_REQUEST:
|
||||||
|
return "TWT request";
|
||||||
|
case WIFI_TWT_SETUP_CMD_SUGGEST:
|
||||||
|
return "TWT suggest";
|
||||||
|
case WIFI_TWT_SETUP_CMD_DEMAND:
|
||||||
|
return "TWT demand";
|
||||||
|
case WIFI_TWT_SETUP_CMD_GROUPING:
|
||||||
|
return "TWT grouping";
|
||||||
|
case WIFI_TWT_SETUP_CMD_ACCEPT:
|
||||||
|
return "TWT accept";
|
||||||
|
case WIFI_TWT_SETUP_CMD_ALTERNATE:
|
||||||
|
return "TWT alternate";
|
||||||
|
case WIFI_TWT_SETUP_CMD_DICTATE:
|
||||||
|
return "TWT dictate";
|
||||||
|
case WIFI_TWT_SETUP_CMD_REJECT:
|
||||||
|
return "TWT reject";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * const wifi_ps_wakeup_mode_txt(enum wifi_ps_wakeup_mode ps_wakeup_mode)
|
||||||
|
{
|
||||||
|
switch (ps_wakeup_mode) {
|
||||||
|
case WIFI_PS_WAKEUP_MODE_DTIM:
|
||||||
|
return "PS wakeup mode DTIM";
|
||||||
|
case WIFI_PS_WAKEUP_MODE_LISTEN_INTERVAL:
|
||||||
|
return "PS wakeup mode listen interval";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const struct wifi_mgmt_ops *const get_wifi_api(struct net_if *iface)
|
static const struct wifi_mgmt_ops *const get_wifi_api(struct net_if *iface)
|
||||||
{
|
{
|
||||||
const struct device *dev = net_if_get_device(iface);
|
const struct device *dev = net_if_get_device(iface);
|
||||||
|
|
|
@ -97,224 +97,6 @@ static bool parse_number(const struct shell *sh, long *param, char *str, long mi
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * const wifi_security_txt(enum wifi_security_type security)
|
|
||||||
{
|
|
||||||
switch (security) {
|
|
||||||
case WIFI_SECURITY_TYPE_NONE:
|
|
||||||
return "OPEN";
|
|
||||||
case WIFI_SECURITY_TYPE_WEP:
|
|
||||||
return "WEP";
|
|
||||||
case WIFI_SECURITY_TYPE_WPA_PSK:
|
|
||||||
return "WPA-PSK";
|
|
||||||
case WIFI_SECURITY_TYPE_PSK:
|
|
||||||
return "WPA2-PSK";
|
|
||||||
case WIFI_SECURITY_TYPE_PSK_SHA256:
|
|
||||||
return "WPA2-PSK-SHA256";
|
|
||||||
case WIFI_SECURITY_TYPE_SAE:
|
|
||||||
return "WPA3-SAE";
|
|
||||||
case WIFI_SECURITY_TYPE_WAPI:
|
|
||||||
return "WAPI";
|
|
||||||
case WIFI_SECURITY_TYPE_EAP:
|
|
||||||
return "EAP";
|
|
||||||
case WIFI_SECURITY_TYPE_UNKNOWN:
|
|
||||||
default:
|
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * const wifi_mfp_txt(enum wifi_mfp_options mfp)
|
|
||||||
{
|
|
||||||
switch (mfp) {
|
|
||||||
case WIFI_MFP_DISABLE:
|
|
||||||
return "Disable";
|
|
||||||
case WIFI_MFP_OPTIONAL:
|
|
||||||
return "Optional";
|
|
||||||
case WIFI_MFP_REQUIRED:
|
|
||||||
return "Required";
|
|
||||||
case WIFI_MFP_UNKNOWN:
|
|
||||||
default:
|
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * const wifi_band_txt(enum wifi_frequency_bands band)
|
|
||||||
{
|
|
||||||
switch (band) {
|
|
||||||
case WIFI_FREQ_BAND_2_4_GHZ:
|
|
||||||
return "2.4GHz";
|
|
||||||
case WIFI_FREQ_BAND_5_GHZ:
|
|
||||||
return "5GHz";
|
|
||||||
case WIFI_FREQ_BAND_6_GHZ:
|
|
||||||
return "6GHz";
|
|
||||||
case WIFI_FREQ_BAND_UNKNOWN:
|
|
||||||
default:
|
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * const wifi_state_txt(enum wifi_iface_state state)
|
|
||||||
{
|
|
||||||
switch (state) {
|
|
||||||
case WIFI_STATE_DISCONNECTED:
|
|
||||||
return "DISCONNECTED";
|
|
||||||
case WIFI_STATE_INACTIVE:
|
|
||||||
return "INACTIVE";
|
|
||||||
case WIFI_STATE_INTERFACE_DISABLED:
|
|
||||||
return "INTERFACE_DISABLED";
|
|
||||||
case WIFI_STATE_SCANNING:
|
|
||||||
return "SCANNING";
|
|
||||||
case WIFI_STATE_AUTHENTICATING:
|
|
||||||
return "AUTHENTICATING";
|
|
||||||
case WIFI_STATE_ASSOCIATING:
|
|
||||||
return "ASSOCIATING";
|
|
||||||
case WIFI_STATE_ASSOCIATED:
|
|
||||||
return "ASSOCIATED";
|
|
||||||
case WIFI_STATE_4WAY_HANDSHAKE:
|
|
||||||
return "4WAY_HANDSHAKE";
|
|
||||||
case WIFI_STATE_GROUP_HANDSHAKE:
|
|
||||||
return "GROUP_HANDSHAKE";
|
|
||||||
case WIFI_STATE_COMPLETED:
|
|
||||||
return "COMPLETED";
|
|
||||||
case WIFI_STATE_UNKNOWN:
|
|
||||||
default:
|
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * const wifi_mode_txt(enum wifi_iface_mode mode)
|
|
||||||
{
|
|
||||||
switch (mode) {
|
|
||||||
case WIFI_MODE_INFRA:
|
|
||||||
return "STATION";
|
|
||||||
case WIFI_MODE_IBSS:
|
|
||||||
return "ADHOC";
|
|
||||||
case WIFI_MODE_AP:
|
|
||||||
return "ACCESS POINT";
|
|
||||||
case WIFI_MODE_P2P_GO:
|
|
||||||
return "P2P GROUP OWNER";
|
|
||||||
case WIFI_MODE_P2P_GROUP_FORMATION:
|
|
||||||
return "P2P GROUP FORMATION";
|
|
||||||
case WIFI_MODE_MESH:
|
|
||||||
return "MESH";
|
|
||||||
case WIFI_MODE_UNKNOWN:
|
|
||||||
default:
|
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * const wifi_link_mode_txt(enum wifi_link_mode link_mode)
|
|
||||||
{
|
|
||||||
switch (link_mode) {
|
|
||||||
case WIFI_0:
|
|
||||||
return "WIFI 0 (802.11)";
|
|
||||||
case WIFI_1:
|
|
||||||
return "WIFI 1 (802.11b)";
|
|
||||||
case WIFI_2:
|
|
||||||
return "WIFI 2 (802.11a)";
|
|
||||||
case WIFI_3:
|
|
||||||
return "WIFI 3 (802.11g)";
|
|
||||||
case WIFI_4:
|
|
||||||
return "WIFI 4 (802.11n/HT)";
|
|
||||||
case WIFI_5:
|
|
||||||
return "WIFI 5 (802.11ac/VHT)";
|
|
||||||
case WIFI_6:
|
|
||||||
return "WIFI 6 (802.11ax/HE)";
|
|
||||||
case WIFI_6E:
|
|
||||||
return "WIFI 6E (802.11ax 6GHz/HE)";
|
|
||||||
case WIFI_7:
|
|
||||||
return "WIFI 7 (802.11be/EHT)";
|
|
||||||
case WIFI_LINK_MODE_UNKNOWN:
|
|
||||||
default:
|
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * const wifi_ps_txt(enum wifi_ps ps_name)
|
|
||||||
{
|
|
||||||
switch (ps_name) {
|
|
||||||
case WIFI_PS_DISABLED:
|
|
||||||
return "Power save disabled";
|
|
||||||
case WIFI_PS_ENABLED:
|
|
||||||
return "Power save enabled";
|
|
||||||
default:
|
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * const wifi_ps_mode_txt(enum wifi_ps_mode ps_mode)
|
|
||||||
{
|
|
||||||
switch (ps_mode) {
|
|
||||||
case WIFI_PS_MODE_LEGACY:
|
|
||||||
return "Legacy power save";
|
|
||||||
case WIFI_PS_MODE_WMM:
|
|
||||||
return "WMM power save";
|
|
||||||
default:
|
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * const wifi_twt_operation_txt(enum wifi_twt_operation twt_operation)
|
|
||||||
{
|
|
||||||
switch (twt_operation) {
|
|
||||||
case WIFI_TWT_SETUP:
|
|
||||||
return "TWT setup";
|
|
||||||
case WIFI_TWT_TEARDOWN:
|
|
||||||
return "TWT teardown";
|
|
||||||
default:
|
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * const wifi_twt_negotiation_type_txt(enum wifi_twt_negotiation_type twt_negotiation)
|
|
||||||
{
|
|
||||||
switch (twt_negotiation) {
|
|
||||||
case WIFI_TWT_INDIVIDUAL:
|
|
||||||
return "TWT individual negotiation";
|
|
||||||
case WIFI_TWT_BROADCAST:
|
|
||||||
return "TWT broadcast negotiation";
|
|
||||||
case WIFI_TWT_WAKE_TBTT:
|
|
||||||
return "TWT wake TBTT negotiation";
|
|
||||||
default:
|
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * const wifi_twt_setup_cmd_txt(enum wifi_twt_setup_cmd twt_setup)
|
|
||||||
{
|
|
||||||
switch (twt_setup) {
|
|
||||||
case WIFI_TWT_SETUP_CMD_REQUEST:
|
|
||||||
return "TWT request";
|
|
||||||
case WIFI_TWT_SETUP_CMD_SUGGEST:
|
|
||||||
return "TWT suggest";
|
|
||||||
case WIFI_TWT_SETUP_CMD_DEMAND:
|
|
||||||
return "TWT demand";
|
|
||||||
case WIFI_TWT_SETUP_CMD_GROUPING:
|
|
||||||
return "TWT grouping";
|
|
||||||
case WIFI_TWT_SETUP_CMD_ACCEPT:
|
|
||||||
return "TWT accept";
|
|
||||||
case WIFI_TWT_SETUP_CMD_ALTERNATE:
|
|
||||||
return "TWT alternate";
|
|
||||||
case WIFI_TWT_SETUP_CMD_DICTATE:
|
|
||||||
return "TWT dictate";
|
|
||||||
case WIFI_TWT_SETUP_CMD_REJECT:
|
|
||||||
return "TWT reject";
|
|
||||||
default:
|
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * const wifi_ps_wakeup_mode_txt(enum wifi_ps_wakeup_mode ps_wakeup_mode)
|
|
||||||
{
|
|
||||||
switch (ps_wakeup_mode) {
|
|
||||||
case WIFI_PS_WAKEUP_MODE_DTIM:
|
|
||||||
return "PS wakeup mode DTIM";
|
|
||||||
case WIFI_PS_WAKEUP_MODE_LISTEN_INTERVAL:
|
|
||||||
return "PS wakeup mode listen interval";
|
|
||||||
default:
|
|
||||||
return "UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_wifi_scan_result(struct net_mgmt_event_callback *cb)
|
static void handle_wifi_scan_result(struct net_mgmt_event_callback *cb)
|
||||||
{
|
{
|
||||||
const struct wifi_scan_result *entry =
|
const struct wifi_scan_result *entry =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue