From 7313d3bad7b3ee95d65c2e2879e7500efda7f3da Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Mon, 19 Aug 2019 11:12:00 -0700 Subject: [PATCH] network: remove hotspot specific settings loading The hotspot module now uses network_info ops 'open' --- src/hotspot.c | 92 --------------------------------------------------- src/hotspot.h | 2 -- src/network.c | 16 +-------- 3 files changed, 1 insertion(+), 109 deletions(-) diff --git a/src/hotspot.c b/src/hotspot.c index 68218c25..33b0124b 100644 --- a/src/hotspot.c +++ b/src/hotspot.c @@ -387,98 +387,6 @@ static void hs20_dir_watch_destroy(void *user_data) hs20_dir_watch = NULL; } -static bool match_hessid(const void *a, const void *b) -{ - const struct hs20_config *config = a; - const uint8_t *hessid = b; - - if (!memcmp(config->hessid, hessid, 6)) - return true; - - return false; -} - -static bool match_nai_realm(const void *a, const void *b) -{ - const struct hs20_config *config = a; - char **realms = (char **)b; - - while (*realms) { - if (l_strv_contains(config->nai_realms, *realms)) - return true; - - realms++; - } - - return false; -} - -static bool match_rc(const void *a, const void *b) -{ - const struct hs20_config *config = a; - const uint8_t *rc_ie = b; - const uint8_t *rc1, *rc2, *rc3; - size_t rc1_len, rc2_len, rc3_len; - - if (ie_parse_roaming_consortium_from_data(rc_ie, rc_ie[1] + 2, NULL, - &rc1, &rc1_len, &rc2, &rc2_len, - &rc3, &rc3_len) < 0) - return false; - - /* rc1 is guarenteed to be set if the above returns success */ - if (rc1_len == config->rc_len && !memcmp(rc1, config->rc, rc1_len)) - return true; - - if (rc2 && rc2_len == config->rc_len && - !memcmp(rc2, config->rc, rc2_len)) - return true; - - if (rc3 && rc1_len == config->rc_len && - !memcmp(rc3, config->rc, rc3_len)) - return true; - - return false; -} - -const char *hs20_find_settings_file(struct network *network) -{ - struct hs20_config *config; - const uint8_t *hessid = network_get_hessid(network); - char **nai_realms = network_get_nai_realms(network); - const uint8_t *rc_ie = network_get_roaming_consortium(network); - - if (!hessid || util_mem_is_zero(hessid, 6)) { - l_debug("Network has no HESSID, trying NAI realms"); - goto try_nai_realms; - } - - config = l_queue_find(hs20_settings, match_hessid, hessid); - if (config) - return config->filename; - -try_nai_realms: - if (!nai_realms) { - l_debug("Network has no NAI Realms, trying roaming consortium"); - goto try_roaming_consortium; - } - - config = l_queue_find(hs20_settings, match_nai_realm, nai_realms); - if (config) - return config->filename; - -try_roaming_consortium: - if (!rc_ie) { - l_debug("Network has no roaming consortium IE"); - return NULL; - } - - config = l_queue_find(hs20_settings, match_rc, rc_ie); - if (config) - return config->filename; - - return NULL; -} - const uint8_t *hs20_get_roaming_consortium(struct network *network, size_t *len) { diff --git a/src/hotspot.h b/src/hotspot.h index 7ce95156..070d0bff 100644 --- a/src/hotspot.h +++ b/src/hotspot.h @@ -22,7 +22,5 @@ struct network; -const char *hs20_find_settings_file(struct network *network); - const uint8_t *hs20_get_roaming_consortium(struct network *network, size_t *len); diff --git a/src/network.c b/src/network.c index 7a955022..4b08c06b 100644 --- a/src/network.c +++ b/src/network.c @@ -80,21 +80,7 @@ static bool network_settings_load(struct network *network) if (network->settings) return true; - /* - * If this network contains NAI realm info OR we have a Hotspot - * provisioning file containing the HESSID we know this is a Hotspot - * network. - */ - if (network->is_hs20 && (network->nai_realms || network->rc_ie || - !util_mem_is_zero(network->hessid, 6))) { - network->settings = l_settings_new(); - - if (!l_settings_load_from_file(network->settings, - hs20_find_settings_file(network))) { - l_settings_free(network->settings); - network->settings = NULL; - } - } else if (network->info) + if (network->info) network->settings = network_info_open_settings(network->info); return network->settings != NULL;