mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 21:22:37 +01:00
networks: Simplify parameters
for network_seen and network_connected Only accept a struct network pointer instead of separately the ssid and security type. This is needed so we can do some more simplification in the next patch by having access to the network struct.
This commit is contained in:
parent
9fbdba0957
commit
1ba2630216
@ -99,24 +99,24 @@ static bool network_info_match(const void *a, const void *b)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool network_seen(uint32_t type, const char *ssid)
|
||||
bool network_seen(struct network *network)
|
||||
{
|
||||
struct timespec mtim;
|
||||
int err;
|
||||
struct network_info *info;
|
||||
struct network_info search;
|
||||
|
||||
search.type = type;
|
||||
strncpy(search.ssid, ssid, 32);
|
||||
search.type = network->security;
|
||||
strncpy(search.ssid, network->ssid, 32);
|
||||
search.ssid[32] = 0;
|
||||
|
||||
info = l_queue_find(networks, network_info_match, &search);
|
||||
if (info)
|
||||
return true;
|
||||
|
||||
switch(type) {
|
||||
switch (network->security) {
|
||||
case SECURITY_PSK:
|
||||
err = storage_network_get_mtime("psk", ssid, &mtim);
|
||||
err = storage_network_get_mtime("psk", network->ssid, &mtim);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
@ -126,8 +126,8 @@ bool network_seen(uint32_t type, const char *ssid)
|
||||
return false;
|
||||
|
||||
info = l_new(struct network_info, 1);
|
||||
info->type = type;
|
||||
strncpy(info->ssid, ssid, 32);
|
||||
info->type = network->security;
|
||||
strncpy(info->ssid, network->ssid, 32);
|
||||
info->ssid[32] = 0;
|
||||
memcpy(&info->connected_time, &mtim, sizeof(struct timespec));
|
||||
|
||||
@ -136,30 +136,31 @@ bool network_seen(uint32_t type, const char *ssid)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool network_connected(uint32_t type, const char *ssid)
|
||||
bool network_connected(struct network *network)
|
||||
{
|
||||
int err;
|
||||
struct network_info *info;
|
||||
struct network_info search;
|
||||
const char *strtype;
|
||||
|
||||
search.type = type;
|
||||
strncpy(search.ssid, ssid, 32);
|
||||
search.type = network->security;
|
||||
strncpy(search.ssid, network->ssid, 32);
|
||||
search.ssid[32] = 0;
|
||||
|
||||
info = l_queue_remove_if(networks, network_info_match, &search);
|
||||
if (!info)
|
||||
return false;
|
||||
|
||||
strtype = security_to_str(type);
|
||||
strtype = security_to_str(network->security);
|
||||
if (!strtype)
|
||||
goto fail;
|
||||
|
||||
err = storage_network_touch(strtype, ssid);
|
||||
err = storage_network_touch(strtype, network->ssid);
|
||||
if (err < 0)
|
||||
goto fail;
|
||||
|
||||
err = storage_network_get_mtime(strtype, ssid, &info->connected_time);
|
||||
err = storage_network_get_mtime(strtype, network->ssid,
|
||||
&info->connected_time);
|
||||
if (err < 0)
|
||||
goto fail;
|
||||
|
||||
|
@ -23,9 +23,10 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
struct netdev;
|
||||
struct network;
|
||||
|
||||
bool network_seen(uint32_t type, const char *ssid);
|
||||
bool network_connected(uint32_t type, const char *ssid);
|
||||
bool network_seen(struct network *network);
|
||||
bool network_connected(struct network *network);
|
||||
double network_rankmod(uint32_t type, const char *ssid);
|
||||
|
||||
struct network *network_create(struct netdev *device,
|
||||
|
@ -810,8 +810,7 @@ static void operstate_cb(bool result, void *user_data)
|
||||
dbus_pending_reply(&netdev->connect_pending, reply);
|
||||
}
|
||||
|
||||
network_connected(network_get_security(netdev->connected_network),
|
||||
network_get_ssid(netdev->connected_network));
|
||||
network_connected(netdev->connected_network);
|
||||
netdev_enter_state(netdev, DEVICE_STATE_CONNECTED);
|
||||
}
|
||||
|
||||
@ -1299,7 +1298,7 @@ static void process_bss(struct netdev *netdev, struct scan_bss *bss)
|
||||
l_debug("Added new Network \"%s\" security %s",
|
||||
network_get_ssid(network), security_to_str(security));
|
||||
|
||||
network_seen(security, network_get_ssid(network));
|
||||
network_seen(network);
|
||||
}
|
||||
|
||||
network_bss_add(network, bss);
|
||||
|
Loading…
Reference in New Issue
Block a user