wlantest: Add flush command for dropping all BSS data

This commit is contained in:
Jouni Malinen 2010-11-18 17:36:08 +02:00 committed by Jouni Malinen
parent 6f2346c144
commit d356bd630b
6 changed files with 29 additions and 3 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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, "<BSSID> = get STA list" },
{ "flush", cmd_flush, "= drop all collected BSS data" },
{ NULL, NULL, NULL }
};

View File

@ -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 {