2016-06-17 00:54:15 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Wireless daemon for Linux
|
|
|
|
*
|
2019-04-11 21:14:25 +02:00
|
|
|
* Copyright (C) 2016-2019 Intel Corporation. All rights reserved.
|
2016-06-17 00:54:15 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-07-16 18:11:36 +02:00
|
|
|
#define SETTINGS "Settings"
|
|
|
|
#define NET_HIDDEN SETTINGS, "Hidden"
|
|
|
|
#define NET_AUTOCONNECT SETTINGS, "AutoConnect"
|
|
|
|
#define NET_ALWAYS_RANDOMIZE_ADDRESS SETTINGS, "AlwaysRandomizeAddress"
|
|
|
|
#define NET_ADDRESS_OVERRIDE SETTINGS, "AddressOverride"
|
2021-07-16 00:06:34 +02:00
|
|
|
#define NET_TRANSITION_DISABLE SETTINGS, "TransitionDisable"
|
|
|
|
#define NET_TRANSITION_DISABLE_MODES SETTINGS, "DisabledTransitionModes"
|
2021-07-16 18:11:36 +02:00
|
|
|
|
2018-07-22 14:15:18 +02:00
|
|
|
enum security;
|
2019-04-16 23:51:41 +02:00
|
|
|
struct scan_freq_set;
|
2019-08-15 22:15:13 +02:00
|
|
|
struct network_info;
|
2018-07-22 14:15:18 +02:00
|
|
|
|
2019-08-09 18:28:42 +02:00
|
|
|
enum known_networks_event {
|
|
|
|
KNOWN_NETWORKS_EVENT_ADDED,
|
|
|
|
KNOWN_NETWORKS_EVENT_REMOVED,
|
|
|
|
};
|
|
|
|
|
2019-08-15 22:15:13 +02:00
|
|
|
struct network_info_ops {
|
|
|
|
struct l_settings *(*open)(struct network_info *info);
|
|
|
|
int (*touch)(struct network_info *info);
|
|
|
|
void (*sync)(struct network_info *info, struct l_settings *settings);
|
|
|
|
void (*remove)(struct network_info *info);
|
|
|
|
void (*free)(struct network_info *info);
|
|
|
|
const char *(*get_path)(const struct network_info *info);
|
2019-08-21 21:06:13 +02:00
|
|
|
const char *(*get_name)(const struct network_info *info);
|
|
|
|
const char *(*get_type)(const struct network_info *info);
|
2019-09-09 18:49:08 +02:00
|
|
|
const struct iovec *(*get_extra_ies)(const struct network_info *info,
|
|
|
|
struct scan_bss *bss,
|
|
|
|
size_t *num_elems);
|
2019-09-12 18:53:32 +02:00
|
|
|
char *(*get_file_path)(const struct network_info *info);
|
2019-08-19 20:11:56 +02:00
|
|
|
|
|
|
|
bool (*match_hessid)(const struct network_info *info,
|
|
|
|
const uint8_t *hessid);
|
2019-09-06 20:11:01 +02:00
|
|
|
const uint8_t *(*match_roaming_consortium)(
|
|
|
|
const struct network_info *info,
|
2019-08-19 20:11:56 +02:00
|
|
|
const uint8_t *rc_ie,
|
2019-09-06 20:11:01 +02:00
|
|
|
size_t rc_len,
|
|
|
|
size_t *rc_len_out);
|
2019-08-19 20:11:56 +02:00
|
|
|
bool (*match_nai_realms)(const struct network_info *info,
|
|
|
|
const char **nai_realms);
|
2019-08-15 22:15:13 +02:00
|
|
|
};
|
|
|
|
|
2021-07-16 18:11:36 +02:00
|
|
|
struct network_config {
|
|
|
|
uint64_t connected_time; /* Time last connected */
|
|
|
|
bool is_hidden:1;
|
|
|
|
bool is_autoconnectable:1;
|
2021-07-17 01:22:28 +02:00
|
|
|
bool override_addr:1;
|
|
|
|
bool always_random_addr:1;
|
|
|
|
uint8_t sta_addr[6];
|
2021-07-16 00:06:34 +02:00
|
|
|
bool have_transition_disable : 1;
|
|
|
|
uint8_t transition_disable;
|
2021-07-16 18:11:36 +02:00
|
|
|
};
|
|
|
|
|
2019-08-15 22:15:12 +02:00
|
|
|
struct network_info {
|
2019-08-15 22:15:13 +02:00
|
|
|
const struct network_info_ops *ops;
|
2019-08-15 22:15:12 +02:00
|
|
|
char ssid[33];
|
|
|
|
enum security type;
|
|
|
|
struct l_queue *known_frequencies;
|
|
|
|
int seen_count; /* Ref count for network.info */
|
2019-09-13 19:27:26 +02:00
|
|
|
uint8_t uuid[16];
|
2019-08-15 22:15:15 +02:00
|
|
|
bool is_hotspot:1;
|
2019-09-13 19:27:26 +02:00
|
|
|
bool has_uuid:1;
|
2021-07-16 18:11:36 +02:00
|
|
|
struct network_config config;
|
2019-08-15 22:15:12 +02:00
|
|
|
};
|
|
|
|
|
2018-07-22 14:15:18 +02:00
|
|
|
typedef bool (*known_networks_foreach_func_t)(const struct network_info *info,
|
|
|
|
void *user_data);
|
|
|
|
|
2019-08-09 18:28:42 +02:00
|
|
|
typedef void (*known_networks_watch_func_t)(enum known_networks_event event,
|
|
|
|
const struct network_info *info,
|
|
|
|
void *user_data);
|
|
|
|
typedef void (*known_networks_destroy_func_t)(void *user_data);
|
|
|
|
|
2019-04-11 21:14:25 +02:00
|
|
|
struct known_frequency {
|
|
|
|
uint32_t frequency;
|
|
|
|
};
|
|
|
|
|
2021-07-16 18:11:36 +02:00
|
|
|
void __network_config_parse(const struct l_settings *settings,
|
|
|
|
const char *path,
|
|
|
|
struct network_config *config);
|
|
|
|
void __network_info_init(struct network_info *info,
|
|
|
|
const char *ssid, enum security security,
|
|
|
|
struct network_config *config);
|
|
|
|
|
2019-08-09 08:06:10 +02:00
|
|
|
int known_network_offset(const struct network_info *target);
|
2018-07-22 14:15:18 +02:00
|
|
|
bool known_networks_foreach(known_networks_foreach_func_t function,
|
|
|
|
void *user_data);
|
|
|
|
bool known_networks_has_hidden(void);
|
|
|
|
struct network_info *known_networks_find(const char *ssid,
|
|
|
|
enum security security);
|
|
|
|
|
2019-04-16 23:51:41 +02:00
|
|
|
struct scan_freq_set *known_networks_get_recent_frequencies(
|
|
|
|
uint8_t num_networks_tosearch);
|
2019-08-09 18:40:07 +02:00
|
|
|
int known_network_add_frequency(struct network_info *info, uint32_t frequency);
|
2019-09-13 19:27:26 +02:00
|
|
|
void known_network_frequency_sync(struct network_info *info);
|
2019-08-09 18:28:42 +02:00
|
|
|
|
|
|
|
uint32_t known_networks_watch_add(known_networks_watch_func_t func,
|
|
|
|
void *user_data,
|
|
|
|
known_networks_destroy_func_t destroy);
|
|
|
|
void known_networks_watch_remove(uint32_t id);
|
2019-08-15 22:15:13 +02:00
|
|
|
|
|
|
|
struct l_settings *network_info_open_settings(struct network_info *info);
|
|
|
|
int network_info_touch(struct network_info *info);
|
|
|
|
const char *network_info_get_path(const struct network_info *info);
|
2019-08-21 21:06:13 +02:00
|
|
|
const char *network_info_get_name(const struct network_info *info);
|
|
|
|
const char *network_info_get_type(const struct network_info *info);
|
2019-09-09 18:49:08 +02:00
|
|
|
const struct iovec *network_info_get_extra_ies(const struct network_info *info,
|
|
|
|
struct scan_bss *bss,
|
|
|
|
size_t *num_elems);
|
2019-09-13 19:27:26 +02:00
|
|
|
/* Gets the UUID, or generates one if not yet created */
|
|
|
|
const uint8_t *network_info_get_uuid(struct network_info *info);
|
|
|
|
void network_info_set_uuid(struct network_info *info, const uint8_t *uuid);
|
2019-09-16 22:14:13 +02:00
|
|
|
struct scan_freq_set *network_info_get_roam_frequencies(
|
|
|
|
const struct network_info *info,
|
|
|
|
uint32_t current_freq,
|
|
|
|
uint8_t max);
|
2019-08-15 22:15:16 +02:00
|
|
|
|
2019-08-19 20:11:56 +02:00
|
|
|
bool network_info_match_hessid(const struct network_info *info,
|
|
|
|
const uint8_t *hessid);
|
2019-09-06 20:11:01 +02:00
|
|
|
const uint8_t *network_info_match_roaming_consortium(
|
|
|
|
const struct network_info *info,
|
2019-08-19 20:11:56 +02:00
|
|
|
const uint8_t *rc,
|
2019-09-06 20:11:01 +02:00
|
|
|
size_t rc_len,
|
|
|
|
size_t *rc_len_out);
|
2019-08-19 20:11:56 +02:00
|
|
|
bool network_info_match_nai_realm(const struct network_info *info,
|
|
|
|
const char **nai_realms);
|
|
|
|
|
2019-08-15 22:15:16 +02:00
|
|
|
void known_networks_add(struct network_info *info);
|
2019-08-28 18:34:10 +02:00
|
|
|
void known_network_update(struct network_info *info,
|
2021-07-16 18:11:36 +02:00
|
|
|
struct network_config *new_config);
|
2020-01-27 21:28:08 +01:00
|
|
|
void known_network_set_connected_time(struct network_info *network,
|
2019-08-28 18:34:10 +02:00
|
|
|
uint64_t connected_time);
|
2019-08-15 22:15:16 +02:00
|
|
|
void known_networks_remove(struct network_info *info);
|