From c40a8918ec005c565279dc76de057b17de4404bd Mon Sep 17 00:00:00 2001 From: Max Stepanov Date: Mon, 16 Mar 2015 01:16:57 -0400 Subject: [PATCH] P2PS: Delete ASP advertisements on wpas_p2p_service_flush Delete all ASP serice advertisement on wpas_p2p_service_flush similarly to Bonjour and UPnP services. Signed-off-by: Max Stepanov --- src/p2p/p2p.c | 29 ++++++++++++++++++++--------- src/p2p/p2p.h | 1 + wpa_supplicant/p2p_supplicant.h | 1 + wpa_supplicant/p2p_supplicant_sd.c | 7 +++++++ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 6adb3dc20..f584fae2c 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -2730,6 +2730,25 @@ inserted: } +void p2p_service_flush_asp(struct p2p_data *p2p) +{ + struct p2ps_advertisement *adv, *prev; + + if (!p2p) + return; + + adv = p2p->p2ps_adv_list; + while (adv) { + prev = adv; + adv = adv->next; + os_free(prev); + } + + p2p->p2ps_adv_list = NULL; + p2p_dbg(p2p, "All ASP advertisements flushed"); +} + + int p2p_parse_dev_addr_in_p2p_ie(struct wpabuf *p2p_ie, u8 *dev_addr) { struct p2p_message msg; @@ -2878,8 +2897,6 @@ struct p2p_data * p2p_init(const struct p2p_config *cfg) void p2p_deinit(struct p2p_data *p2p) { - struct p2ps_advertisement *adv, *prev; - #ifdef CONFIG_WIFI_DISPLAY wpabuf_free(p2p->wfd_ie_beacon); wpabuf_free(p2p->wfd_ie_probe_req); @@ -2913,13 +2930,7 @@ void p2p_deinit(struct p2p_data *p2p) os_free(p2p->after_scan_tx); p2p_remove_wps_vendor_extensions(p2p); os_free(p2p->no_go_freq.range); - - adv = p2p->p2ps_adv_list; - while (adv) { - prev = adv; - adv = adv->next; - os_free(prev); - } + p2p_service_flush_asp(p2p); os_free(p2p); } diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 2402db6a7..2e5c3dc75 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -2242,6 +2242,7 @@ int p2p_service_add_asp(struct p2p_data *p2p, int auto_accept, u32 adv_id, const char *adv_str, u8 svc_state, u16 config_methods, const char *svc_info); int p2p_service_del_asp(struct p2p_data *p2p, u32 adv_id); +void p2p_service_flush_asp(struct p2p_data *p2p); struct p2ps_advertisement * p2p_get_p2ps_adv_list(struct p2p_data *p2p); #endif /* P2P_H */ diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h index 1d3c67b7e..0b9ebc0b6 100644 --- a/wpa_supplicant/p2p_supplicant.h +++ b/wpa_supplicant/p2p_supplicant.h @@ -93,6 +93,7 @@ int wpas_p2p_service_add_asp(struct wpa_supplicant *wpa_s, int auto_accept, u32 adv_id, const char *adv_str, u8 svc_state, u16 config_methods, const char *svc_info); int wpas_p2p_service_del_asp(struct wpa_supplicant *wpa_s, u32 adv_id); +void wpas_p2p_service_flush_asp(struct wpa_supplicant *wpa_s); int wpas_p2p_service_p2ps_id_exists(struct wpa_supplicant *wpa_s, u32 adv_id); void wpas_sd_request(void *ctx, int freq, const u8 *sa, u8 dialog_token, u16 update_indic, const u8 *tlvs, size_t tlvs_len); diff --git a/wpa_supplicant/p2p_supplicant_sd.c b/wpa_supplicant/p2p_supplicant_sd.c index 54af4b6b2..fcf0f644e 100644 --- a/wpa_supplicant/p2p_supplicant_sd.c +++ b/wpa_supplicant/p2p_supplicant_sd.c @@ -1136,6 +1136,7 @@ void wpas_p2p_service_flush(struct wpa_supplicant *wpa_s) struct p2p_srv_upnp, list) wpas_p2p_srv_upnp_free(usrv); + wpas_p2p_service_flush_asp(wpa_s); wpas_p2p_sd_service_update(wpa_s); } @@ -1179,6 +1180,12 @@ int wpas_p2p_service_add_asp(struct wpa_supplicant *wpa_s, } +void wpas_p2p_service_flush_asp(struct wpa_supplicant *wpa_s) +{ + p2p_service_flush_asp(wpa_s->global->p2p); +} + + int wpas_p2p_service_add_bonjour(struct wpa_supplicant *wpa_s, struct wpabuf *query, struct wpabuf *resp) {