station: refactor __station_connect_network
This makes __station_connect_network even less intelligent by JUST making it connect to a network, without any state changes. This makes the rekey logic much cleaner. We were also changing dbus properties when setting the state to CONNECTING, so those dbus property change calls were moved into station_enter_state.
This commit is contained in:
parent
cff0600621
commit
da485179a6
|
@ -115,6 +115,9 @@ struct autoconnect_entry {
|
||||||
struct scan_bss *bss;
|
struct scan_bss *bss;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void station_enter_state(struct station *station,
|
||||||
|
enum station_state state);
|
||||||
|
|
||||||
static void station_autoconnect_next(struct station *station)
|
static void station_autoconnect_next(struct station *station)
|
||||||
{
|
{
|
||||||
struct autoconnect_entry *entry;
|
struct autoconnect_entry *entry;
|
||||||
|
@ -132,9 +135,11 @@ static void station_autoconnect_next(struct station *station)
|
||||||
r = network_autoconnect(entry->network, entry->bss);
|
r = network_autoconnect(entry->network, entry->bss);
|
||||||
l_free(entry);
|
l_free(entry);
|
||||||
|
|
||||||
if (!r)
|
if (!r) {
|
||||||
|
station_enter_state(station, STATION_STATE_CONNECTING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int autoconnect_rank_compare(const void *a, const void *b, void *user)
|
static int autoconnect_rank_compare(const void *a, const void *b, void *user)
|
||||||
|
@ -680,9 +685,15 @@ static void station_enter_state(struct station *station,
|
||||||
scan_periodic_start(index, periodic_scan_trigger,
|
scan_periodic_start(index, periodic_scan_trigger,
|
||||||
new_scan_results, station);
|
new_scan_results, station);
|
||||||
break;
|
break;
|
||||||
|
case STATION_STATE_CONNECTING:
|
||||||
|
l_dbus_property_changed(dbus, netdev_get_path(station->netdev),
|
||||||
|
IWD_STATION_INTERFACE, "ConnectedNetwork");
|
||||||
|
l_dbus_property_changed(dbus,
|
||||||
|
network_get_path(station->connected_network),
|
||||||
|
IWD_NETWORK_INTERFACE, "Connected");
|
||||||
|
/* fall through */
|
||||||
case STATION_STATE_DISCONNECTED:
|
case STATION_STATE_DISCONNECTED:
|
||||||
case STATION_STATE_CONNECTED:
|
case STATION_STATE_CONNECTED:
|
||||||
case STATION_STATE_CONNECTING:
|
|
||||||
periodic_scan_stop(station);
|
periodic_scan_stop(station);
|
||||||
break;
|
break;
|
||||||
case STATION_STATE_DISCONNECTING:
|
case STATION_STATE_DISCONNECTING:
|
||||||
|
@ -1633,14 +1644,9 @@ static void station_connect_cb(struct netdev *netdev, enum netdev_result result,
|
||||||
int __station_connect_network(struct station *station, struct network *network,
|
int __station_connect_network(struct station *station, struct network *network,
|
||||||
struct scan_bss *bss)
|
struct scan_bss *bss)
|
||||||
{
|
{
|
||||||
struct l_dbus *dbus = dbus_get_bus();
|
|
||||||
struct netdev *netdev = station->netdev;
|
|
||||||
struct handshake_state *hs;
|
struct handshake_state *hs;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (station_is_busy(station))
|
|
||||||
return -EBUSY;
|
|
||||||
|
|
||||||
hs = station_handshake_setup(station, network, bss);
|
hs = station_handshake_setup(station, network, bss);
|
||||||
if (!hs)
|
if (!hs)
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
@ -1655,13 +1661,6 @@ int __station_connect_network(struct station *station, struct network *network,
|
||||||
station->connected_bss = bss;
|
station->connected_bss = bss;
|
||||||
station->connected_network = network;
|
station->connected_network = network;
|
||||||
|
|
||||||
station_enter_state(station, STATION_STATE_CONNECTING);
|
|
||||||
|
|
||||||
l_dbus_property_changed(dbus, netdev_get_path(netdev),
|
|
||||||
IWD_STATION_INTERFACE, "ConnectedNetwork");
|
|
||||||
l_dbus_property_changed(dbus, network_get_path(network),
|
|
||||||
IWD_NETWORK_INTERFACE, "Connected");
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1669,17 +1668,27 @@ void station_connect_network(struct station *station, struct network *network,
|
||||||
struct scan_bss *bss,
|
struct scan_bss *bss,
|
||||||
struct l_dbus_message *message)
|
struct l_dbus_message *message)
|
||||||
{
|
{
|
||||||
int err = __station_connect_network(station, network, bss);
|
|
||||||
|
|
||||||
if (err < 0) {
|
|
||||||
struct l_dbus *dbus = dbus_get_bus();
|
struct l_dbus *dbus = dbus_get_bus();
|
||||||
|
int err;
|
||||||
|
|
||||||
l_dbus_send(dbus, dbus_error_from_errno(err, message));
|
if (station_is_busy(station)) {
|
||||||
return;
|
err = -EBUSY;
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = __station_connect_network(station, network, bss);
|
||||||
|
if (err < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
station_enter_state(station, STATION_STATE_CONNECTING);
|
||||||
|
|
||||||
station->connect_pending = l_dbus_message_ref(message);
|
station->connect_pending = l_dbus_message_ref(message);
|
||||||
station->autoconnect = true;
|
station->autoconnect = true;
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
error:
|
||||||
|
l_dbus_send(dbus, dbus_error_from_errno(err, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void station_hidden_network_scan_triggered(int err, void *user_data)
|
static void station_hidden_network_scan_triggered(int err, void *user_data)
|
||||||
|
@ -1820,19 +1829,9 @@ static void station_disconnect_reconnect_cb(struct netdev *netdev, bool success,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
struct station *station = user_data;
|
struct station *station = user_data;
|
||||||
struct handshake_state *hs;
|
|
||||||
|
|
||||||
hs = station_handshake_setup(station, station->connected_network,
|
if (__station_connect_network(station, station->connected_network,
|
||||||
station->connected_bss);
|
station->connected_bss) < 0)
|
||||||
if (!hs)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (netdev_connect(station->netdev, station->connected_bss, hs,
|
|
||||||
station_netdev_event, station_connect_cb,
|
|
||||||
station) > 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
error:
|
|
||||||
station_disassociated(station);
|
station_disassociated(station);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue