2014-02-20 23:14:30 +01:00
|
|
|
/*
|
|
|
|
* wpa_supplicant module tests
|
|
|
|
* Copyright (c) 2014, Jouni Malinen <j@w1.fi>
|
|
|
|
*
|
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "utils/includes.h"
|
|
|
|
|
|
|
|
#include "utils/common.h"
|
2016-06-23 17:19:00 +02:00
|
|
|
#include "utils/module_tests.h"
|
2014-02-25 19:04:16 +01:00
|
|
|
#include "wpa_supplicant_i.h"
|
2021-02-07 16:06:19 +01:00
|
|
|
#include "bssid_ignore.h"
|
2014-02-25 19:04:16 +01:00
|
|
|
|
|
|
|
|
2021-02-07 16:02:37 +01:00
|
|
|
static int wpas_bssid_ignore_module_tests(void)
|
2014-02-25 19:04:16 +01:00
|
|
|
{
|
|
|
|
struct wpa_supplicant wpa_s;
|
2023-11-24 19:59:37 +01:00
|
|
|
struct wpa_global global;
|
2014-02-25 19:04:16 +01:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
os_memset(&wpa_s, 0, sizeof(wpa_s));
|
2023-11-24 19:59:37 +01:00
|
|
|
os_memset(&global, 0, sizeof(global));
|
|
|
|
wpa_s.global = &global;
|
2014-02-25 19:04:16 +01:00
|
|
|
|
2021-02-07 16:02:37 +01:00
|
|
|
wpa_bssid_ignore_clear(&wpa_s);
|
2014-02-25 19:04:16 +01:00
|
|
|
|
2021-02-07 16:02:37 +01:00
|
|
|
if (wpa_bssid_ignore_get(NULL, NULL) != NULL ||
|
|
|
|
wpa_bssid_ignore_get(NULL, (u8 *) "123456") != NULL ||
|
|
|
|
wpa_bssid_ignore_get(&wpa_s, NULL) != NULL ||
|
|
|
|
wpa_bssid_ignore_get(&wpa_s, (u8 *) "123456") != NULL)
|
2014-02-25 19:04:16 +01:00
|
|
|
goto fail;
|
|
|
|
|
2021-02-07 16:02:37 +01:00
|
|
|
if (wpa_bssid_ignore_add(NULL, NULL) == 0 ||
|
|
|
|
wpa_bssid_ignore_add(NULL, (u8 *) "123456") == 0 ||
|
|
|
|
wpa_bssid_ignore_add(&wpa_s, NULL) == 0)
|
2014-02-25 19:04:16 +01:00
|
|
|
goto fail;
|
|
|
|
|
2021-02-07 16:02:37 +01:00
|
|
|
if (wpa_bssid_ignore_del(NULL, NULL) == 0 ||
|
|
|
|
wpa_bssid_ignore_del(NULL, (u8 *) "123456") == 0 ||
|
|
|
|
wpa_bssid_ignore_del(&wpa_s, NULL) == 0 ||
|
|
|
|
wpa_bssid_ignore_del(&wpa_s, (u8 *) "123456") == 0)
|
2014-02-25 19:04:16 +01:00
|
|
|
goto fail;
|
|
|
|
|
2021-02-07 16:02:37 +01:00
|
|
|
if (wpa_bssid_ignore_add(&wpa_s, (u8 *) "111111") < 0 ||
|
|
|
|
wpa_bssid_ignore_add(&wpa_s, (u8 *) "111111") < 0 ||
|
|
|
|
wpa_bssid_ignore_add(&wpa_s, (u8 *) "222222") < 0 ||
|
|
|
|
wpa_bssid_ignore_add(&wpa_s, (u8 *) "333333") < 0 ||
|
|
|
|
wpa_bssid_ignore_add(&wpa_s, (u8 *) "444444") < 0 ||
|
|
|
|
wpa_bssid_ignore_del(&wpa_s, (u8 *) "333333") < 0 ||
|
|
|
|
wpa_bssid_ignore_del(&wpa_s, (u8 *) "xxxxxx") == 0 ||
|
|
|
|
wpa_bssid_ignore_get(&wpa_s, (u8 *) "xxxxxx") != NULL ||
|
|
|
|
wpa_bssid_ignore_get(&wpa_s, (u8 *) "111111") == NULL ||
|
|
|
|
wpa_bssid_ignore_get(&wpa_s, (u8 *) "222222") == NULL ||
|
|
|
|
wpa_bssid_ignore_get(&wpa_s, (u8 *) "444444") == NULL ||
|
|
|
|
wpa_bssid_ignore_del(&wpa_s, (u8 *) "111111") < 0 ||
|
|
|
|
wpa_bssid_ignore_del(&wpa_s, (u8 *) "222222") < 0 ||
|
|
|
|
wpa_bssid_ignore_del(&wpa_s, (u8 *) "444444") < 0 ||
|
|
|
|
wpa_bssid_ignore_add(&wpa_s, (u8 *) "111111") < 0 ||
|
|
|
|
wpa_bssid_ignore_add(&wpa_s, (u8 *) "222222") < 0 ||
|
|
|
|
wpa_bssid_ignore_add(&wpa_s, (u8 *) "333333") < 0)
|
2014-02-25 19:04:16 +01:00
|
|
|
goto fail;
|
|
|
|
|
2021-02-07 16:02:37 +01:00
|
|
|
wpa_bssid_ignore_clear(&wpa_s);
|
2020-06-11 23:11:18 +02:00
|
|
|
|
2021-02-07 16:02:37 +01:00
|
|
|
if (wpa_bssid_ignore_add(&wpa_s, (u8 *) "111111") < 0 ||
|
|
|
|
wpa_bssid_ignore_add(&wpa_s, (u8 *) "222222") < 0 ||
|
|
|
|
wpa_bssid_ignore_add(&wpa_s, (u8 *) "333333") < 0 ||
|
|
|
|
wpa_bssid_ignore_add(&wpa_s, (u8 *) "444444") < 0 ||
|
|
|
|
!wpa_bssid_ignore_is_listed(&wpa_s, (u8 *) "111111") ||
|
|
|
|
wpa_bssid_ignore_del(&wpa_s, (u8 *) "111111") < 0 ||
|
|
|
|
wpa_bssid_ignore_is_listed(&wpa_s, (u8 *) "111111") ||
|
|
|
|
wpa_bssid_ignore_add(&wpa_s, (u8 *) "111111") < 0)
|
2020-06-11 23:11:18 +02:00
|
|
|
goto fail;
|
|
|
|
|
2021-02-07 16:02:37 +01:00
|
|
|
wpa_bssid_ignore_update(&wpa_s);
|
2020-06-11 23:11:18 +02:00
|
|
|
|
2021-02-07 16:02:37 +01:00
|
|
|
if (!wpa_bssid_ignore_is_listed(&wpa_s, (u8 *) "111111"))
|
2020-06-11 23:11:18 +02:00
|
|
|
goto fail;
|
|
|
|
|
2014-02-25 19:04:16 +01:00
|
|
|
ret = 0;
|
|
|
|
fail:
|
2021-02-07 16:02:37 +01:00
|
|
|
wpa_bssid_ignore_clear(&wpa_s);
|
2014-02-25 19:04:16 +01:00
|
|
|
|
|
|
|
if (ret)
|
2021-02-07 16:02:37 +01:00
|
|
|
wpa_printf(MSG_ERROR, "bssid_ignore module test failure");
|
2014-02-25 19:04:16 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-02-20 23:14:30 +01:00
|
|
|
|
|
|
|
int wpas_module_tests(void)
|
|
|
|
{
|
2014-02-21 00:15:16 +01:00
|
|
|
int ret = 0;
|
|
|
|
|
2014-02-20 23:14:30 +01:00
|
|
|
wpa_printf(MSG_INFO, "wpa_supplicant module tests");
|
2014-02-21 00:15:16 +01:00
|
|
|
|
2021-02-07 16:02:37 +01:00
|
|
|
if (wpas_bssid_ignore_module_tests() < 0)
|
2014-02-25 19:04:16 +01:00
|
|
|
ret = -1;
|
|
|
|
|
2014-02-21 00:15:16 +01:00
|
|
|
#ifdef CONFIG_WPS
|
2016-06-23 17:19:00 +02:00
|
|
|
if (wps_module_tests() < 0)
|
|
|
|
ret = -1;
|
2014-02-21 00:15:16 +01:00
|
|
|
#endif /* CONFIG_WPS */
|
|
|
|
|
2016-06-23 17:19:00 +02:00
|
|
|
if (utils_module_tests() < 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
if (common_module_tests() < 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
if (crypto_module_tests() < 0)
|
|
|
|
ret = -1;
|
2015-01-05 14:48:17 +01:00
|
|
|
|
2014-02-21 00:15:16 +01:00
|
|
|
return ret;
|
2014-02-20 23:14:30 +01:00
|
|
|
}
|