commit 936542fa795b82e1aa77d27f0ab91a39f909bd0d
parent 1fe50706669f9651cf33d9d8b0c838025d71c33f
Author: James Prestwood <prestwoj@gmail.com>
Date: Tue, 27 Apr 2021 11:06:24 -0700
network: copy station_has_erp_identity
This API is internal to station, but acts only on the network
object so it is being moved into network.c and exposed.
Diffstat:
2 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/src/network.c b/src/network.c
@@ -52,6 +52,7 @@
#include "src/network.h"
#include "src/blacklist.h"
#include "src/util.h"
+#include "src/erp.h"
static uint32_t known_networks_watch;
static uint32_t anqp_watch;
@@ -720,6 +721,46 @@ static bool match_bss(const void *a, const void *b)
return a == b;
}
+bool network_has_erp_identity(struct network *network)
+{
+ struct erp_cache_entry *cache;
+ struct l_settings *settings;
+ char *check_id;
+ const char *identity;
+ bool ret;
+
+ settings = network_get_settings(network);
+ if (!settings)
+ return false;
+
+ check_id = l_settings_get_string(settings, "Security", "EAP-Identity");
+ if (!check_id)
+ return false;
+
+ cache = erp_cache_get(network_get_ssid(network));
+ if (!cache) {
+ l_free(check_id);
+ return false;
+ }
+
+ identity = erp_cache_entry_get_identity(cache);
+
+ ret = strcmp(check_id, identity) == 0;
+
+ l_free(check_id);
+ erp_cache_put(cache);
+
+ /*
+ * The settings file must have change out from under us. In this
+ * case we want to remove the ERP entry because it is no longer
+ * valid.
+ */
+ if (!ret)
+ erp_cache_remove(identity);
+
+ return ret;
+}
+
struct scan_bss *network_bss_select(struct network *network,
bool fallback_to_blacklist)
{
diff --git a/src/network.h b/src/network.h
@@ -79,3 +79,5 @@ void network_blacklist_add(struct network *network, struct scan_bss *bss);
const struct iovec *network_get_extra_ies(struct network *network,
size_t *num_elems);
+
+bool network_has_erp_identity(struct network *network);