mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-16 17:09:24 +01:00
network: Move parsing of additional options
Move parsing of AddressOverride and AlwaysRandomizeAddress settings to knownnetwork.c to be in the same place as other global network settings.
This commit is contained in:
parent
bedf2b0596
commit
8cfe038d67
@ -57,6 +57,8 @@ void __network_config_parse(const struct l_settings *settings,
|
|||||||
struct network_config *config)
|
struct network_config *config)
|
||||||
{
|
{
|
||||||
bool b;
|
bool b;
|
||||||
|
const char *value;
|
||||||
|
uint8_t new_addr[6];
|
||||||
|
|
||||||
memset(config, 0, sizeof(struct network_config));
|
memset(config, 0, sizeof(struct network_config));
|
||||||
|
|
||||||
@ -72,6 +74,29 @@ void __network_config_parse(const struct l_settings *settings,
|
|||||||
b = false;
|
b = false;
|
||||||
|
|
||||||
config->is_hidden = b;
|
config->is_hidden = b;
|
||||||
|
|
||||||
|
if (!l_settings_get_bool(settings, NET_ALWAYS_RANDOMIZE_ADDRESS, &b))
|
||||||
|
b = false;
|
||||||
|
|
||||||
|
config->always_random_addr = b;
|
||||||
|
|
||||||
|
value = l_settings_get_value(settings, NET_ADDRESS_OVERRIDE);
|
||||||
|
if (value) {
|
||||||
|
if (util_string_to_address(value, new_addr) &&
|
||||||
|
util_is_valid_sta_address(new_addr)) {
|
||||||
|
config->override_addr = true;
|
||||||
|
memcpy(config->sta_addr, new_addr, sizeof(new_addr));
|
||||||
|
} else
|
||||||
|
l_warn("[%s].%s is not a valid MAC address",
|
||||||
|
NET_ADDRESS_OVERRIDE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config->override_addr && config->always_random_addr) {
|
||||||
|
l_warn("Cannot use both [%s].%s and [%s].%s, using latter",
|
||||||
|
NET_ALWAYS_RANDOMIZE_ADDRESS,
|
||||||
|
NET_ADDRESS_OVERRIDE);
|
||||||
|
config->always_random_addr = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void __network_info_init(struct network_info *info,
|
void __network_info_init(struct network_info *info,
|
||||||
|
@ -64,6 +64,9 @@ struct network_config {
|
|||||||
uint64_t connected_time; /* Time last connected */
|
uint64_t connected_time; /* Time last connected */
|
||||||
bool is_hidden:1;
|
bool is_hidden:1;
|
||||||
bool is_autoconnectable:1;
|
bool is_autoconnectable:1;
|
||||||
|
bool override_addr:1;
|
||||||
|
bool always_random_addr:1;
|
||||||
|
uint8_t sta_addr[6];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct network_info {
|
struct network_info {
|
||||||
|
@ -446,10 +446,8 @@ int network_handshake_setup(struct network *network,
|
|||||||
struct station *station = network->station;
|
struct station *station = network->station;
|
||||||
struct wiphy *wiphy = station_get_wiphy(station);
|
struct wiphy *wiphy = station_get_wiphy(station);
|
||||||
struct l_settings *settings = network->settings;
|
struct l_settings *settings = network->settings;
|
||||||
|
struct network_info *info = network->info;
|
||||||
uint32_t eapol_proto_version;
|
uint32_t eapol_proto_version;
|
||||||
const char *value;
|
|
||||||
bool full_random;
|
|
||||||
bool override = false;
|
|
||||||
uint8_t new_addr[ETH_ALEN];
|
uint8_t new_addr[ETH_ALEN];
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -493,31 +491,10 @@ int network_handshake_setup(struct network *network,
|
|||||||
* 2. per-network full MAC randomization
|
* 2. per-network full MAC randomization
|
||||||
* 3. per-network MAC override
|
* 3. per-network MAC override
|
||||||
*/
|
*/
|
||||||
|
if (info && info->config.override_addr)
|
||||||
if (!l_settings_get_bool(settings, NET_ALWAYS_RANDOMIZE_ADDRESS,
|
handshake_state_set_supplicant_address(hs,
|
||||||
&full_random))
|
info->config.sta_addr);
|
||||||
full_random = false;
|
else if (info && info->config.always_random_addr) {
|
||||||
|
|
||||||
value = l_settings_get_value(settings, NET_ADDRESS_OVERRIDE);
|
|
||||||
if (value) {
|
|
||||||
if (util_string_to_address(value, new_addr) &&
|
|
||||||
util_is_valid_sta_address(new_addr))
|
|
||||||
override = true;
|
|
||||||
else
|
|
||||||
l_warn("[%s].%s is not a valid MAC address",
|
|
||||||
NET_ADDRESS_OVERRIDE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (override && full_random) {
|
|
||||||
l_warn("Cannot use both [%s].%s and [%s].%s, using latter",
|
|
||||||
NET_ALWAYS_RANDOMIZE_ADDRESS,
|
|
||||||
NET_ADDRESS_OVERRIDE);
|
|
||||||
full_random = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (override)
|
|
||||||
handshake_state_set_supplicant_address(hs, new_addr);
|
|
||||||
else if (full_random) {
|
|
||||||
wiphy_generate_random_address(wiphy, new_addr);
|
wiphy_generate_random_address(wiphy, new_addr);
|
||||||
handshake_state_set_supplicant_address(hs, new_addr);
|
handshake_state_set_supplicant_address(hs, new_addr);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user