Shows the current set driver flags in wpa_cli and hostapd_cli. Signed-off-by: Erik Ljungberg <erik.ljungberg@xxxxxxxxxxxxxx> --- hostapd/ctrl_iface.c | 32 +++++++++++++++++++++++++++- hostapd/hostapd_cli.c | 5 +++++ src/drivers/driver.h | 2 ++ src/drivers/driver_common.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ wpa_supplicant/ctrl_iface.c | 30 ++++++++++++++++++++++++++ wpa_supplicant/wpa_cli.c | 9 ++++++++ 6 files changed, 128 insertions(+), 1 deletion(-) diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index 62bef18..b0df862 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -2254,6 +2254,34 @@ static int hostapd_ctrl_iface_remove_neighbor(struct hostapd_data *hapd, } +static int hostapd_ctrl_driver_flags(struct hostapd_iface *iface, char *buf, + size_t buflen) { + int ret, i; + char *pos, *end; + + ret = os_snprintf(buf, buflen, "%016llX:\n", + (long long unsigned)iface->drv_flags); + if (os_snprintf_error(buflen, ret)) + return -1; + + pos = buf + ret; + end = buf + buflen; + + for (i = 0; i < 64; i++) { + if (iface->drv_flags & 1LLU << i) { + ret = os_snprintf(pos, end - pos, "%s\n", + driver_flag_to_string( + 1LLU << i)); + if (os_snprintf_error(end - pos, ret)) + return -1; + pos += ret; + } + } + + return pos - buf; +} + + static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, char *buf, char *reply, int reply_size, @@ -2510,6 +2538,9 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, } else if (os_strncmp(buf, "REQ_RANGE ", 10) == 0) { if (hostapd_ctrl_iface_req_range(hapd, buf + 10)) reply_len = -1; + } else if (os_strncmp(buf, "DRIVER_FLAGS", 12) == 0) { + reply_len = hostapd_ctrl_driver_flags(hapd->iface, reply, + reply_size); } else { os_memcpy(reply, "UNKNOWN COMMAND\n", 16); reply_len = 16; @@ -2523,7 +2554,6 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, return reply_len; } - static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx, void *sock_ctx) { diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c index ff133f6..bcd6b2a 100644 --- a/hostapd/hostapd_cli.c +++ b/hostapd/hostapd_cli.c @@ -1217,6 +1217,10 @@ static int hostapd_cli_cmd_req_range(struct wpa_ctrl *ctrl, int argc, return hostapd_cli_cmd(ctrl, "REQ_RANGE", 4, argc, argv); } +static int hostapd_cli_cmd_driver_flags(struct wpa_ctrl *ctrl, int argc, char *argv[]) +{ + return wpa_ctrl_command(ctrl, "DRIVER_FLAGS"); +} struct hostapd_cli_cmd { const char *cmd; @@ -1283,6 +1287,7 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = { { "remove_neighbor", hostapd_cli_cmd_remove_neighbor }, { "req_lci", hostapd_cli_cmd_req_lci }, { "req_range", hostapd_cli_cmd_req_range }, + { "driver_flags", hostapd_cli_cmd_driver_flags }, { NULL, NULL } }; diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 671a4b8..11c63ee 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -4915,6 +4915,8 @@ int vht_supported(const struct hostapd_hw_modes *mode); struct wowlan_triggers * wpa_get_wowlan_triggers(const char *wowlan_triggers, const struct wpa_driver_capa *capa); +/* Convert driver flag to string */ +const char* driver_flag_to_string(u64 flag); /* NULL terminated array of linked in driver wrappers */ extern const struct wpa_driver_ops *const wpa_drivers[]; diff --git a/src/drivers/driver_common.c b/src/drivers/driver_common.c index a1141ab..40ea7fa 100644 --- a/src/drivers/driver_common.c +++ b/src/drivers/driver_common.c @@ -219,3 +219,54 @@ out: os_free(buf); return triggers; } + + +const char* driver_flag_to_string(u64 flag) { +#define DF2S(x) case x: return #x; + switch (flag) { + DF2S(WPA_DRIVER_FLAGS_DRIVER_IE) + DF2S(WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC) + DF2S(WPA_DRIVER_FLAGS_DFS_OFFLOAD) + DF2S(WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) + DF2S(WPA_DRIVER_FLAGS_WIRED) + DF2S(WPA_DRIVER_FLAGS_SME) + DF2S(WPA_DRIVER_FLAGS_AP) + DF2S(WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE) + DF2S(WPA_DRIVER_FLAGS_HT_2040_COEX) + DF2S(WPA_DRIVER_FLAGS_P2P_CONCURRENT) + DF2S(WPA_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE) + DF2S(WPA_DRIVER_FLAGS_P2P_CAPABLE) + DF2S(WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT) + DF2S(WPA_DRIVER_FLAGS_P2P_MGMT_AND_NON_P2P) + DF2S(WPA_DRIVER_FLAGS_SANE_ERROR_CODES) + DF2S(WPA_DRIVER_FLAGS_OFFCHANNEL_TX) + DF2S(WPA_DRIVER_FLAGS_EAPOL_TX_STATUS) + DF2S(WPA_DRIVER_FLAGS_DEAUTH_TX_STATUS) + DF2S(WPA_DRIVER_FLAGS_BSS_SELECTION) + DF2S(WPA_DRIVER_FLAGS_TDLS_SUPPORT) + DF2S(WPA_DRIVER_FLAGS_TDLS_EXTERNAL_SETUP) + DF2S(WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD) + DF2S(WPA_DRIVER_FLAGS_AP_UAPSD) + DF2S(WPA_DRIVER_FLAGS_INACTIVITY_TIMER) + DF2S(WPA_DRIVER_FLAGS_AP_MLME) + DF2S(WPA_DRIVER_FLAGS_SAE) + DF2S(WPA_DRIVER_FLAGS_OBSS_SCAN) + DF2S(WPA_DRIVER_FLAGS_IBSS) + DF2S(WPA_DRIVER_FLAGS_RADAR) + DF2S(WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE) + DF2S(WPA_DRIVER_FLAGS_QOS_MAPPING) + DF2S(WPA_DRIVER_FLAGS_AP_CSA) + DF2S(WPA_DRIVER_FLAGS_MESH) + DF2S(WPA_DRIVER_FLAGS_ACS_OFFLOAD) + DF2S(WPA_DRIVER_FLAGS_KEY_MGMT_OFFLOAD) + DF2S(WPA_DRIVER_FLAGS_TDLS_CHANNEL_SWITCH) + DF2S(WPA_DRIVER_FLAGS_HT_IBSS) + DF2S(WPA_DRIVER_FLAGS_VHT_IBSS) + DF2S(WPA_DRIVER_FLAGS_SUPPORT_HW_MODE_ANY) + DF2S(WPA_DRIVER_FLAGS_OFFCHANNEL_SIMULTANEOUS) + DF2S(WPA_DRIVER_FLAGS_FULL_AP_CLIENT_STATE) + DF2S(WPA_DRIVER_FLAGS_P2P_LISTEN_OFFLOAD) + } + return "WPA_DRIVER_FLAGS_UNKNOWN"; +#undef DF2S +} diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 2d53174..650f422 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -6997,6 +6997,33 @@ static int wpas_ctrl_iface_get_pref_freq_list( return pos - buf; } +static int wpas_ctrl_iface_driver_flags(struct wpa_supplicant *wpa_s, + char *buf, size_t buflen) +{ + int ret, i; + char *pos, *end; + + ret = os_snprintf(buf, buflen, "%016llX:\n", + (long long unsigned)wpa_s->drv_flags); + if (os_snprintf_error(buflen, ret)) + return -1; + + pos = buf + ret; + end = buf + buflen; + + for (i = 0; i < 64; i++) { + if (wpa_s->drv_flags & 1LLU << i) { + ret = os_snprintf(pos, end - pos, "%s\n", + driver_flag_to_string( + 1LLU << i)); + if (os_snprintf_error(end - pos, ret)) + return -1; + pos += ret; + } + } + + return pos - buf; +} static int wpa_supplicant_pktcnt_poll(struct wpa_supplicant *wpa_s, char *buf, size_t buflen) @@ -9264,6 +9291,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, if (wpa_supplicant_ctrl_iface_autoscan(wpa_s, buf + 9)) reply_len = -1; #endif /* CONFIG_AUTOSCAN */ + } else if (os_strncmp(buf, "DRIVER_FLAGS", 12) == 0) { + reply_len = wpas_ctrl_iface_driver_flags(wpa_s, reply, + reply_size); #ifdef ANDROID } else if (os_strncmp(buf, "DRIVER ", 7) == 0) { reply_len = wpa_supplicant_driver_cmd(wpa_s, buf + 7, reply, diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index ede66b7..66e360c 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -711,6 +711,12 @@ static int wpa_cli_cmd_dump(struct wpa_ctrl *ctrl, int argc, char *argv[]) } +static int wpa_cli_cmd_driver_flags(struct wpa_ctrl *ctrl, int argc, char *argv[]) +{ + return wpa_ctrl_command(ctrl, "DRIVER_FLAGS"); +} + + static int wpa_cli_cmd_get(struct wpa_ctrl *ctrl, int argc, char *argv[]) { return wpa_cli_cmd(ctrl, "GET", 1, argc, argv); @@ -2963,6 +2969,9 @@ static const struct wpa_cli_cmd wpa_cli_commands[] = { { "get", wpa_cli_cmd_get, wpa_cli_complete_get, cli_cmd_flag_none, "<name> = get information" }, + { "driver_flags", wpa_cli_cmd_driver_flags, NULL, + cli_cmd_flag_none, + "= list driver flags" }, { "logon", wpa_cli_cmd_logon, NULL, cli_cmd_flag_none, "= IEEE 802.1X EAPOL state machine logon" }, -- 2.9.0.137.gcf4c2cf _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap