3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-10-04 02:18:49 +02:00

netconfig: Change public API

As a first step to enable the usage of netconfig in ead and
prospective transition to be a part of ell, the public API for
creation and destruction of the netconfig objects has been
renamed and changed. Instead of hiding the netconfig objects inside
of netconfig module, the object is now passed back to the caller.
The internal queue of netconfig objects remains untouched, due
to limitations in ell’s implementation of rtnl. After the proper
changes are done to ell, netconfig_list is expected to be removed
from netconfig module.
This commit is contained in:
Tim Kourt 2019-09-27 12:52:17 -07:00 committed by Denis Kenzior
parent c8dfb6061d
commit d954eee0cc
3 changed files with 17 additions and 30 deletions

View File

@ -94,17 +94,6 @@ static void netconfig_free(void *data)
l_free(netconfig); l_free(netconfig);
} }
static bool netconfig_match(const void *a, const void *b)
{
const struct netconfig *netconfig = a;
uint32_t ifindex = L_PTR_TO_UINT(b);
if (netconfig->ifindex == ifindex)
return true;
return false;
}
static struct netconfig *netconfig_find(uint32_t ifindex) static struct netconfig *netconfig_find(uint32_t ifindex)
{ {
const struct l_queue_entry *entry; const struct l_queue_entry *entry;
@ -696,23 +685,23 @@ static void netconfig_station_state_changed(enum station_state state,
netconfig->station_state = state; netconfig->station_state = state;
} }
bool netconfig_ifindex_add(uint32_t ifindex) struct netconfig *netconfig_new(uint32_t ifindex)
{ {
struct netconfig *netconfig; struct netconfig *netconfig;
struct station *station; struct station *station;
if (!netconfig_list) if (!netconfig_list)
return false; return NULL;
l_debug("Starting netconfig for interface: %d", ifindex); l_debug("Starting netconfig for interface: %d", ifindex);
netconfig = netconfig_find(ifindex); netconfig = netconfig_find(ifindex);
if (netconfig) if (netconfig)
return true; return netconfig;
station = station_find(ifindex); station = station_find(ifindex);
if (!station) if (!station)
return false; return NULL;
netconfig = l_new(struct netconfig, 1); netconfig = l_new(struct netconfig, 1);
netconfig->ifindex = ifindex; netconfig->ifindex = ifindex;
@ -725,22 +714,17 @@ bool netconfig_ifindex_add(uint32_t ifindex)
l_queue_push_tail(netconfig_list, netconfig); l_queue_push_tail(netconfig_list, netconfig);
return true; return netconfig;
} }
bool netconfig_ifindex_remove(uint32_t ifindex) void netconfig_destroy(struct netconfig *netconfig)
{ {
struct netconfig *netconfig;
if (!netconfig_list) if (!netconfig_list)
return false; return;
l_debug(); l_debug();
netconfig = l_queue_remove_if(netconfig_list, netconfig_match, l_queue_remove(netconfig_list, netconfig);
L_UINT_TO_PTR(ifindex));
if (!netconfig)
return false;
if (netconfig->station_state != STATION_STATE_DISCONNECTED) { if (netconfig->station_state != STATION_STATE_DISCONNECTED) {
netconfig_ipv4_select_and_uninstall(netconfig); netconfig_ipv4_select_and_uninstall(netconfig);
@ -751,8 +735,6 @@ bool netconfig_ifindex_remove(uint32_t ifindex)
} }
netconfig_free(netconfig); netconfig_free(netconfig);
return true;
} }
static int netconfig_init(void) static int netconfig_init(void)

View File

@ -20,5 +20,7 @@
* *
*/ */
bool netconfig_ifindex_add(uint32_t ifindex); struct netconfig;
bool netconfig_ifindex_remove(uint32_t ifindex);
struct netconfig *netconfig_new(uint32_t ifindex);
void netconfig_destroy(struct netconfig *netconfig);

View File

@ -88,6 +88,8 @@ struct station {
struct l_queue *anqp_pending; struct l_queue *anqp_pending;
struct netconfig *netconfig;
bool preparing_roam : 1; bool preparing_roam : 1;
bool signal_low : 1; bool signal_low : 1;
bool roam_no_orig_ap : 1; bool roam_no_orig_ap : 1;
@ -3021,7 +3023,7 @@ static struct station *station_create(struct netdev *netdev)
l_dbus_object_add_interface(dbus, netdev_get_path(netdev), l_dbus_object_add_interface(dbus, netdev_get_path(netdev),
IWD_STATION_INTERFACE, station); IWD_STATION_INTERFACE, station);
netconfig_ifindex_add(netdev_get_ifindex(netdev)); station->netconfig = netconfig_new(netdev_get_ifindex(netdev));
station->anqp_pending = l_queue_new(); station->anqp_pending = l_queue_new();
@ -3038,7 +3040,8 @@ static void station_free(struct station *station)
if (station->connected_bss) if (station->connected_bss)
netdev_disconnect(station->netdev, NULL, NULL); netdev_disconnect(station->netdev, NULL, NULL);
netconfig_ifindex_remove(netdev_get_ifindex(station->netdev)); netconfig_destroy(station->netconfig);
station->netconfig = NULL;
periodic_scan_stop(station); periodic_scan_stop(station);