From 54e7cced8eabf3600660d9bc8b905860fb7f2184 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Sun, 15 May 2016 21:04:02 -0500 Subject: [PATCH] network: Move PSK sync to network.c --- src/network.c | 15 +++++++++++++++ src/network.h | 1 + src/wiphy.c | 11 +---------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/network.c b/src/network.c index 171053d3..36bcec04 100644 --- a/src/network.c +++ b/src/network.c @@ -230,6 +230,21 @@ bool network_settings_load(struct network *network) return true; } +void network_sync_psk(struct network *network) +{ + char *hex; + + if (!network->update_psk) + return; + + network->update_psk = false; + hex = l_util_hexstring(network->psk, 32); + l_settings_set_value(network->settings, "Security", + "PreSharedKey", hex); + l_free(hex); + storage_network_sync("psk", network->ssid, network->settings); +} + void network_settings_close(struct network *network) { if (!network->settings) diff --git a/src/network.h b/src/network.h index 4a66e97e..f4701378 100644 --- a/src/network.h +++ b/src/network.h @@ -51,6 +51,7 @@ enum security network_get_security(struct network *network); bool network_settings_load(struct network *network); void network_settings_close(struct network *network); +void network_sync_psk(struct network *network); void network_emit_added(struct network *network); void network_emit_removed(struct network *network); diff --git a/src/wiphy.c b/src/wiphy.c index ddb74999..a30f5078 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -1132,16 +1132,7 @@ static void wiphy_set_tk(uint32_t ifindex, const uint8_t *aa, } /* If we got here, then our PSK works. Save if required */ - if (network->update_psk) { - char *hex; - - network->update_psk = false; - hex = l_util_hexstring(network->psk, 32); - l_settings_set_value(network->settings, "Security", - "PreSharedKey", hex); - l_free(hex); - storage_network_sync("psk", network->ssid, network->settings); - } + network_sync_psk(network); netdev->pairwise_new_key_cmd_id = mlme_new_pairwise_key(netdev, cipher, aa,