diff --git a/wlantest/bss.c b/wlantest/bss.c index a60ae3364..20e4f207b 100644 --- a/wlantest/bss.c +++ b/wlantest/bss.c @@ -252,3 +252,11 @@ void bss_update(struct wlantest *wt, struct wlantest_bss *bss, bss->rsn_capab & WPA_CAPABILITY_PEERKEY_ENABLED ? "PEERKEY " : ""); } + + +void bss_flush(struct wlantest *wt) +{ + struct wlantest_bss *bss, *n; + dl_list_for_each_safe(bss, n, &wt->bss, struct wlantest_bss, list) + bss_deinit(bss); +} diff --git a/wlantest/ctrl.c b/wlantest/ctrl.c index 3f880295b..f2526eb2b 100644 --- a/wlantest/ctrl.c +++ b/wlantest/ctrl.c @@ -149,6 +149,14 @@ static void ctrl_list_sta(struct wlantest *wt, int sock, u8 *cmd, size_t clen) } +static void ctrl_flush(struct wlantest *wt, int sock) +{ + wpa_printf(MSG_DEBUG, "Drop all collected BSS data"); + bss_flush(wt); + ctrl_send_simple(wt, sock, WLANTEST_CTRL_SUCCESS); +} + + static void ctrl_read(int sock, void *eloop_ctx, void *sock_ctx) { struct wlantest *wt = eloop_ctx; @@ -193,6 +201,9 @@ static void ctrl_read(int sock, void *eloop_ctx, void *sock_ctx) case WLANTEST_CTRL_LIST_STA: ctrl_list_sta(wt, sock, buf + 4, len - 4); break; + case WLANTEST_CTRL_FLUSH: + ctrl_flush(wt, sock); + break; default: ctrl_send_simple(wt, sock, WLANTEST_CTRL_UNKNOWN_CMD); break; diff --git a/wlantest/wlantest.c b/wlantest/wlantest.c index d43379f3d..a98513a0c 100644 --- a/wlantest/wlantest.c +++ b/wlantest/wlantest.c @@ -78,7 +78,6 @@ void radius_deinit(struct wlantest_radius *r) static void wlantest_deinit(struct wlantest *wt) { - struct wlantest_bss *bss, *n; struct wlantest_passphrase *p, *pn; struct wlantest_radius_secret *s, *sn; struct wlantest_radius *r, *rn; @@ -88,8 +87,7 @@ static void wlantest_deinit(struct wlantest *wt) ctrl_deinit(wt); if (wt->monitor_sock >= 0) monitor_deinit(wt); - dl_list_for_each_safe(bss, n, &wt->bss, struct wlantest_bss, list) - bss_deinit(bss); + bss_flush(wt); dl_list_for_each_safe(p, pn, &wt->passphrase, struct wlantest_passphrase, list) passphrase_deinit(p); diff --git a/wlantest/wlantest.h b/wlantest/wlantest.h index aed4fb879..18c1ddd20 100644 --- a/wlantest/wlantest.h +++ b/wlantest/wlantest.h @@ -148,6 +148,7 @@ struct wlantest_bss * bss_get(struct wlantest *wt, const u8 *bssid); void bss_deinit(struct wlantest_bss *bss); void bss_update(struct wlantest *wt, struct wlantest_bss *bss, struct ieee802_11_elems *elems); +void bss_flush(struct wlantest *wt); void pmk_deinit(struct wlantest_pmk *pmk); struct wlantest_sta * sta_get(struct wlantest_bss *bss, const u8 *addr); diff --git a/wlantest/wlantest_cli.c b/wlantest/wlantest_cli.c index 7ba5ff175..ee8d0cc0a 100644 --- a/wlantest/wlantest_cli.c +++ b/wlantest/wlantest_cli.c @@ -163,6 +163,12 @@ static int cmd_list_sta(int s, int argc, char *argv[]) } +static int cmd_flush(int s, int argc, char *argv[]) +{ + return cmd_simple(s, WLANTEST_CTRL_FLUSH); +} + + struct wlantest_cli_cmd { const char *cmd; int (*handler)(int s, int argc, char *argv[]); @@ -174,6 +180,7 @@ static const struct wlantest_cli_cmd wlantest_cli_commands[] = { { "terminate", cmd_terminate, "= terminate wlantest" }, { "list_bss", cmd_list_bss, "= get BSS list" }, { "list_sta", cmd_list_sta, " = get STA list" }, + { "flush", cmd_flush, "= drop all collected BSS data" }, { NULL, NULL, NULL } }; diff --git a/wlantest/wlantest_ctrl.h b/wlantest/wlantest_ctrl.h index 85db87ee1..3e7d6cae9 100644 --- a/wlantest/wlantest_ctrl.h +++ b/wlantest/wlantest_ctrl.h @@ -28,6 +28,7 @@ enum wlantest_ctrl_cmd { WLANTEST_CTRL_TERMINATE, WLANTEST_CTRL_LIST_BSS, WLANTEST_CTRL_LIST_STA, + WLANTEST_CTRL_FLUSH, }; enum wlantest_ctrl_attr {