iwd/src/station.h

108 lines
3.8 KiB
C
Raw Normal View History

2018-08-31 20:24:26 +02:00
/*
*
* Wireless daemon for Linux
*
* Copyright (C) 2018-2019 Intel Corporation. All rights reserved.
2018-08-31 20:24:26 +02:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <stdbool.h>
struct wiphy;
struct netdev;
struct station;
enum security;
struct scan_bss;
struct scan_freq_set;
struct network;
2018-08-31 20:24:26 +02:00
enum station_state {
/* Disconnected, no auto-connect */
STATION_STATE_DISCONNECTED,
/* Disconnected, try auto-connect with quick scan */
STATION_STATE_AUTOCONNECT_QUICK,
/* Disconnected, try auto-connect with full scan */
STATION_STATE_AUTOCONNECT_FULL,
/* Connecting */
STATION_STATE_CONNECTING,
STATION_STATE_CONNECTING_AUTO,
STATION_STATE_CONNECTED,
STATION_STATE_DISCONNECTING,
STATION_STATE_ROAMING, /* Reassociation */
STATION_STATE_FT_ROAMING, /* Fast transition */
STATION_STATE_FW_ROAMING, /* Firmware roamed by itself */
};
enum station_event {
STATION_EVENT_ANQP_STARTED,
STATION_EVENT_ANQP_FINISHED,
STATION_EVENT_OWE_HIDDEN_STARTED,
STATION_EVENT_OWE_HIDDEN_FINISHED,
};
typedef void (*station_foreach_func_t)(struct station *, void *data);
typedef void (*station_state_watch_func_t)(enum station_state, void *userdata);
typedef void (*station_event_watch_func_t)(enum station_event,
struct network *network,
void *user_data);
typedef void (*station_destroy_func_t)(void *userdata);
typedef void (*station_network_foreach_func_t)(struct network *, void *data);
2018-09-04 22:33:46 +02:00
struct wiphy *station_get_wiphy(struct station *station);
2018-09-04 22:34:17 +02:00
struct netdev *station_get_netdev(struct station *station);
struct network *station_get_connected_network(struct station *station);
2018-09-04 23:26:13 +02:00
bool station_is_busy(struct station *station);
2018-09-04 22:33:46 +02:00
struct network *station_network_find(struct station *station, const char *ssid,
enum security security);
void station_set_scan_results(struct station *station, struct l_queue *bss_list,
const struct scan_freq_set *freqs,
bool add_to_autoconnect);
enum station_state station_get_state(struct station *station);
uint32_t station_add_state_watch(struct station *station,
station_state_watch_func_t func,
void *user_data,
station_destroy_func_t destroy);
bool station_remove_state_watch(struct station *station, uint32_t id);
uint32_t station_add_event_watch(station_event_watch_func_t func,
void *user_data,
station_destroy_func_t destroy);
void station_remove_event_watch(uint32_t id);
bool station_set_autoconnect(struct station *station, bool autoconnect);
int __station_connect_network(struct station *station, struct network *network,
station: provide new state in __station_connect_network This is being done to allow the DPP module to work correctly. DPP currently uses __station_connect_network incorrectly since it does not (and cannot) change the state after calling. The only way to connect with a state change is via station_connect_network which requires a DBus method that triggered the connection; DPP does not have this due to its potentially long run time. To support DPP there are a few options: 1. Pass a state into __station_connect_network (this patch) 2. Support a NULL DBus message in station_connect_network. This would require several NULL checks and adding all that to only support DPP just didn't feel right. 3. A 3rd connect API in station which wraps __station_connect_network and changes the state. And again, an entirely new API for only DPP felt wrong (I guess we did this for network_autoconnect though...) Its about 50/50 between call sites that changed state after calling and those that do not. Changing the state inside __station_connect_network felt useful enough to cover the cases that could benefit and the remaining cases could handle it easily enough: - network_autoconnect(), and the state is changed by station after calling so it more or less follows the same pattern just routes through network. This will now pass the CONNECTING_AUTO state from within network vs station. - The disconnect/reconnect path. Here the state is changed to ROAMING prior in order to avoid multiple state changes. Knowing this the same ROAMING state can be passed which won't trigger a state change. - Retrying after a failed BSS. The state changes on the first call then remains the same for each connection attempt. To support this the current station->state is passed to avoid a state change.
2023-10-31 19:47:46 +01:00
struct scan_bss *bss, enum station_state state);
void station_connect_network(struct station *station, struct network *network,
struct scan_bss *bss,
struct l_dbus_message *message);
int station_disconnect(struct station *station);
struct station *station_find(uint32_t ifindex);
void station_foreach(station_foreach_func_t func, void *user_data);
void station_network_foreach(struct station *station,
station_network_foreach_func_t func,
void *user_data);
struct l_queue *station_get_bss_list(struct station *station);
struct scan_bss *station_get_connected_bss(struct station *station);
int station_hide_network(struct station *station, struct network *network);