network: store HESSID and NAI Realms in network object

Hotspot networks are supposed to include an HESSID in the scan
results. This is more or less an identifier for the overall
network. In addition, the NAI Realms can be obtained via ANQP
and should be the same for each BSS. Since both HESSID and NAI
realms should be the same for a given network in range we can
store these values in the network object itself. This also allows
us to easily find hotspot configuration files by looking at
the HESSID/NAI Realms directly in the network object as opposed
to individual scan_bss's.
This commit is contained in:
James Prestwood 2019-06-26 10:42:50 -07:00 committed by Denis Kenzior
parent d63c8290a9
commit 701a5cc41e
2 changed files with 37 additions and 0 deletions

View File

@ -48,6 +48,7 @@
#include "src/knownnetworks.h"
#include "src/network.h"
#include "src/blacklist.h"
#include "src/util.h"
struct network {
char *object_path;
@ -60,6 +61,8 @@ struct network {
struct l_settings *settings;
struct l_queue *secrets;
struct l_queue *blacklist; /* temporary blacklist for BSS's */
uint8_t hessid[6];
char **nai_realms;
bool update_psk:1; /* Whether PSK should be written to storage */
bool ask_passphrase:1; /* Whether we should force-ask agent */
int rank;
@ -520,6 +523,29 @@ void network_sync_psk(struct network *network)
network->settings);
}
void network_set_hessid(struct network *network, uint8_t *hessid)
{
memcpy(network->hessid, hessid, 6);
}
void network_set_nai_realms(struct network *network, char **realms)
{
if (network->nai_realms)
l_strv_free(network->nai_realms);
network->nai_realms = realms;
}
uint8_t *network_get_hessid(struct network *network)
{
return network->hessid;
}
char **network_get_nai_realms(struct network *network)
{
return network->nai_realms;
}
static inline bool __bss_is_sae(const struct scan_bss *bss,
const struct ie_rsn_info *rsn)
{
@ -659,6 +685,9 @@ bool network_bss_add(struct network *network, struct scan_bss *bss)
l_queue_push_head(network->info->known_frequencies, known_freq);
if (!util_mem_is_zero(bss->hessid, 6))
memcpy(network->hessid, bss->hessid, 6);
return true;
}
@ -1315,6 +1344,9 @@ void network_remove(struct network *network, int reason)
l_queue_destroy(network->blacklist, NULL);
if (network->nai_realms)
l_strv_free(network->nai_realms);
l_free(network);
}

View File

@ -48,6 +48,11 @@ struct l_settings *network_get_settings(const struct network *network);
bool network_set_psk(struct network *network, const uint8_t *psk);
void network_sync_psk(struct network *network);
void network_set_hessid(struct network *network, uint8_t *hessid);
void network_set_nai_realms(struct network *network, char **realms);
uint8_t *network_get_hessid(struct network *network);
char **network_get_nai_realms(struct network *network);
int network_autoconnect(struct network *network, struct scan_bss *bss);
void network_connect_failed(struct network *network);
bool network_bss_add(struct network *network, struct scan_bss *bss);