diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 54f5ee8a6..bfd9cdaef 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -137,6 +137,12 @@ static const char * p2p_state_txt(int state) } +const char * p2p_get_state_txt(struct p2p_data *p2p) +{ + return p2p_state_txt(p2p->state); +} + + u16 p2p_get_provisioning_info(struct p2p_data *p2p, const u8 *addr) { struct p2p_device *dev = NULL; diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index e911474e6..1f1fa6712 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -1820,4 +1820,15 @@ struct wpabuf * wifi_display_encaps(struct wpabuf *subelems); int p2p_set_disc_int(struct p2p_data *p2p, int min_disc_int, int max_disc_int, int max_disc_tu); +/** + * p2p_get_state_txt - Get current P2P state for debug purposes + * @p2p: P2P module context from p2p_init() + * Returns: Name of the current P2P module state + * + * It should be noted that the P2P module state names are internal information + * and subject to change at any point, i.e., this information should be used + * mainly for debugging purposes. + */ +const char * p2p_get_state_txt(struct p2p_data *p2p); + #endif /* P2P_H */ diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 1064f1dd1..03ffde055 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -6047,9 +6047,17 @@ static int wpas_global_ctrl_iface_status(struct wpa_global *global, end = buf + buflen; #ifdef CONFIG_P2P - if (global->p2p) { + if (global->p2p && !global->p2p_disabled) { ret = os_snprintf(pos, end - pos, "p2p_device_address=" MACSTR - "\n", MAC2STR(global->p2p_dev_addr)); + "\n" + "p2p_state=%s\n", + MAC2STR(global->p2p_dev_addr), + p2p_get_state_txt(global->p2p)); + if (ret < 0 || ret >= end - pos) + return pos - buf; + pos += ret; + } else if (global->p2p) { + ret = os_snprintf(pos, end - pos, "p2p_state=DISABLED\n"); if (ret < 0 || ret >= end - pos) return pos - buf; pos += ret;