eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

knownnetworks.h (6056B)


      1 /*
      2  *
      3  *  Wireless daemon for Linux
      4  *
      5  *  Copyright (C) 2016-2019  Intel Corporation. All rights reserved.
      6  *
      7  *  This library is free software; you can redistribute it and/or
      8  *  modify it under the terms of the GNU Lesser General Public
      9  *  License as published by the Free Software Foundation; either
     10  *  version 2.1 of the License, or (at your option) any later version.
     11  *
     12  *  This library is distributed in the hope that it will be useful,
     13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  *  Lesser General Public License for more details.
     16  *
     17  *  You should have received a copy of the GNU Lesser General Public
     18  *  License along with this library; if not, write to the Free Software
     19  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     20  *
     21  */
     22 
     23 #include "src/defs.h"
     24 
     25 #define SETTINGS "Settings"
     26 #define NET_HIDDEN SETTINGS, "Hidden"
     27 #define NET_AUTOCONNECT SETTINGS, "AutoConnect"
     28 #define NET_ALWAYS_RANDOMIZE_ADDRESS SETTINGS, "AlwaysRandomizeAddress"
     29 #define NET_ADDRESS_OVERRIDE SETTINGS, "AddressOverride"
     30 #define NET_TRANSITION_DISABLE SETTINGS, "TransitionDisable"
     31 #define NET_TRANSITION_DISABLE_MODES SETTINGS, "DisabledTransitionModes"
     32 #define NET_USE_DEFAULT_ECC_GROUP SETTINGS, "UseDefaultEccGroup"
     33 
     34 enum security;
     35 struct scan_freq_set;
     36 struct network_info;
     37 
     38 enum known_networks_event {
     39 	KNOWN_NETWORKS_EVENT_ADDED,
     40 	KNOWN_NETWORKS_EVENT_REMOVED,
     41 	KNOWN_NETWORKS_EVENT_UPDATED,
     42 };
     43 
     44 enum known_network_ecc_group {
     45 	KNOWN_NETWORK_ECC_GROUP_AUTO = 0,
     46 	KNOWN_NETWORK_ECC_GROUP_DEFAULT,
     47 	KNOWN_NETWORK_ECC_GROUP_MOST_SECURE,
     48 };
     49 
     50 struct network_info_ops {
     51 	struct l_settings *(*open)(struct network_info *info);
     52 	int (*touch)(struct network_info *info);
     53 	void (*sync)(struct network_info *info, struct l_settings *settings);
     54 	void (*remove)(struct network_info *info);
     55 	void (*free)(struct network_info *info);
     56 	const char *(*get_path)(const struct network_info *info);
     57 	const char *(*get_name)(const struct network_info *info);
     58 	const char *(*get_type)(const struct network_info *info);
     59 	const struct iovec *(*get_extra_ies)(const struct network_info *info,
     60 						struct scan_bss *bss,
     61 						size_t *num_elems);
     62 	char *(*get_file_path)(const struct network_info *info);
     63 
     64 	bool (*match_hessid)(const struct network_info *info,
     65 						const uint8_t *hessid);
     66 	const uint8_t *(*match_roaming_consortium)(
     67 						const struct network_info *info,
     68 						const uint8_t *rc_ie,
     69 						size_t rc_len,
     70 						size_t *rc_len_out);
     71 	bool (*match_nai_realms)(const struct network_info *info,
     72 						const char **nai_realms);
     73 };
     74 
     75 struct network_config {
     76 	uint64_t connected_time;	/* Time last connected */
     77 	bool is_hidden:1;
     78 	bool is_autoconnectable:1;
     79 	bool override_addr:1;
     80 	bool always_random_addr:1;
     81 	uint8_t sta_addr[6];
     82 	bool have_transition_disable : 1;
     83 	uint8_t transition_disable;
     84 	enum known_network_ecc_group ecc_group;
     85 };
     86 
     87 struct network_info {
     88 	const struct network_info_ops *ops;
     89 	char ssid[SSID_MAX_SIZE + 1];
     90 	enum security type;
     91 	struct l_queue *known_frequencies;
     92 	int seen_count;			/* Ref count for network.info */
     93 	uint8_t uuid[16];
     94 	bool is_hotspot:1;
     95 	bool has_uuid:1;
     96 	struct network_config config;
     97 };
     98 
     99 typedef bool (*known_networks_foreach_func_t)(const struct network_info *info,
    100 						void *user_data);
    101 
    102 typedef void (*known_networks_watch_func_t)(enum known_networks_event event,
    103 						const struct network_info *info,
    104 						void *user_data);
    105 typedef void (*known_networks_destroy_func_t)(void *user_data);
    106 
    107 struct known_frequency {
    108 	uint32_t frequency;
    109 };
    110 
    111 void __network_config_parse(const struct l_settings *settings,
    112 					const char *path,
    113 					struct network_config *config);
    114 void __network_info_init(struct network_info *info,
    115 				const char *ssid, enum security security,
    116 				struct network_config *config);
    117 
    118 int known_network_offset(const struct network_info *target);
    119 bool known_networks_foreach(known_networks_foreach_func_t function,
    120 				void *user_data);
    121 bool known_networks_has_hidden(void);
    122 struct network_info *known_networks_find(const char *ssid,
    123 						enum security security);
    124 
    125 struct scan_freq_set *known_networks_get_recent_frequencies(
    126 						uint8_t num_networks_tosearch,
    127 						uint8_t freqs_per_network);
    128 int known_network_add_frequency(struct network_info *info,
    129 				uint32_t frequency);
    130 void known_network_frequency_sync(struct network_info *info);
    131 
    132 uint32_t known_networks_watch_add(known_networks_watch_func_t func,
    133 					void *user_data,
    134 					known_networks_destroy_func_t destroy);
    135 void known_networks_watch_remove(uint32_t id);
    136 
    137 struct l_settings *network_info_open_settings(struct network_info *info);
    138 int network_info_touch(struct network_info *info);
    139 const char *network_info_get_path(const struct network_info *info);
    140 const char *network_info_get_name(const struct network_info *info);
    141 const char *network_info_get_type(const struct network_info *info);
    142 const struct iovec *network_info_get_extra_ies(const struct network_info *info,
    143 						struct scan_bss *bss,
    144 						size_t *num_elems);
    145 /* Gets the UUID, or generates one if not yet created */
    146 const uint8_t *network_info_get_uuid(struct network_info *info);
    147 void network_info_set_uuid(struct network_info *info, const uint8_t *uuid);
    148 struct scan_freq_set *network_info_get_roam_frequencies(
    149 					const struct network_info *info,
    150 					uint32_t current_freq,
    151 					uint8_t max);
    152 
    153 bool network_info_match_hessid(const struct network_info *info,
    154 				const uint8_t *hessid);
    155 const uint8_t *network_info_match_roaming_consortium(
    156 						const struct network_info *info,
    157 						const uint8_t *rc,
    158 						size_t rc_len,
    159 						size_t *rc_len_out);
    160 bool network_info_match_nai_realm(const struct network_info *info,
    161 						const char **nai_realms);
    162 
    163 void known_networks_add(struct network_info *info);
    164 void known_network_update(struct network_info *info,
    165 					struct network_config *new_config);
    166 void known_network_set_connected_time(struct network_info *network,
    167 					uint64_t connected_time);
    168 void known_networks_remove(struct network_info *info);