Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Driver interaction with Linux nl80211/cfg80211 - definitions |
| 3 | * Copyright (c) 2002-2014, Jouni Malinen <j@w1.fi> |
| 4 | * Copyright (c) 2003-2004, Instant802 Networks, Inc. |
| 5 | * Copyright (c) 2005-2006, Devicescape Software, Inc. |
| 6 | * Copyright (c) 2007, Johannes Berg <johannes@sipsolutions.net> |
| 7 | * Copyright (c) 2009-2010, Atheros Communications |
| 8 | * |
| 9 | * This software may be distributed under the terms of the BSD license. |
| 10 | * See README for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef DRIVER_NL80211_H |
| 14 | #define DRIVER_NL80211_H |
| 15 | |
| 16 | #include "nl80211_copy.h" |
| 17 | #include "utils/list.h" |
| 18 | #include "driver.h" |
| 19 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 20 | #ifndef NL_CAPABILITY_VERSION_3_5_0 |
| 21 | #define nla_nest_start(msg, attrtype) \ |
| 22 | nla_nest_start(msg, NLA_F_NESTED | (attrtype)) |
| 23 | #endif |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 24 | |
| 25 | struct nl80211_global { |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 26 | void *ctx; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 27 | struct dl_list interfaces; |
| 28 | int if_add_ifindex; |
| 29 | u64 if_add_wdevid; |
| 30 | int if_add_wdevid_set; |
| 31 | struct netlink_data *netlink; |
| 32 | struct nl_cb *nl_cb; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 33 | struct nl_sock *nl; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 34 | int nl80211_id; |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 35 | unsigned int nl80211_maxattr; |
Hai Shalom | c1a2144 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 36 | int nlctrl_id; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 37 | int ioctl_sock; /* socket for ioctl() use */ |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 38 | struct nl_sock *nl_event; |
Mir Ali | 8a8f100 | 2020-10-06 22:41:40 +0530 | [diff] [blame] | 39 | u8 p2p_perm_addr[ETH_ALEN]; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | struct nl80211_wiphy_data { |
| 43 | struct dl_list list; |
| 44 | struct dl_list bsss; |
| 45 | struct dl_list drvs; |
| 46 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 47 | struct nl_sock *nl_beacons; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 48 | struct nl_cb *nl_cb; |
| 49 | |
| 50 | int wiphy_idx; |
| 51 | }; |
| 52 | |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 53 | #define NL80211_DRV_LINK_ID_NA (-1) |
| 54 | |
| 55 | struct i802_link { |
| 56 | unsigned int beacon_set:1; |
| 57 | |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 58 | int freq; |
| 59 | int bandwidth; |
| 60 | u8 addr[ETH_ALEN]; |
| 61 | void *ctx; |
| 62 | }; |
| 63 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 64 | struct i802_bss { |
| 65 | struct wpa_driver_nl80211_data *drv; |
| 66 | struct i802_bss *next; |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 67 | |
Sunil Ravi | 99c035e | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 68 | u16 valid_links; |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 69 | struct i802_link links[MAX_NUM_MLD_LINKS]; |
Sunil Ravi | c0f5d41 | 2024-09-11 22:12:49 +0000 | [diff] [blame] | 70 | struct i802_link *flink, *scan_link; |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 71 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 72 | int ifindex; |
| 73 | int br_ifindex; |
| 74 | u64 wdev_id; |
| 75 | char ifname[IFNAMSIZ + 1]; |
| 76 | char brname[IFNAMSIZ]; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 77 | unsigned int added_if_into_bridge:1; |
Hai Shalom | c9e41a1 | 2018-07-31 14:41:42 -0700 | [diff] [blame] | 78 | unsigned int already_in_bridge:1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 79 | unsigned int added_bridge:1; |
| 80 | unsigned int in_deinit:1; |
| 81 | unsigned int wdev_id_set:1; |
| 82 | unsigned int added_if:1; |
| 83 | unsigned int static_ap:1; |
| 84 | |
| 85 | u8 addr[ETH_ALEN]; |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 86 | u8 prev_addr[ETH_ALEN]; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 87 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 88 | int if_dynamic; |
| 89 | |
| 90 | void *ctx; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 91 | struct nl_sock *nl_preq, *nl_mgmt, *nl_connect; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 92 | struct nl_cb *nl_cb; |
| 93 | |
| 94 | struct nl80211_wiphy_data *wiphy_data; |
| 95 | struct dl_list wiphy_list; |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 96 | u8 rand_addr[ETH_ALEN]; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 97 | }; |
| 98 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 99 | struct drv_nl80211_if_info { |
| 100 | int ifindex; |
| 101 | /* the AP/AP_VLAN iface that is in this bridge */ |
| 102 | int reason; |
| 103 | }; |
| 104 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 105 | struct wpa_driver_nl80211_data { |
| 106 | struct nl80211_global *global; |
| 107 | struct dl_list list; |
| 108 | struct dl_list wiphy_list; |
| 109 | char phyname[32]; |
Dmitry Shmidt | 7d56b75 | 2015-12-22 10:59:44 -0800 | [diff] [blame] | 110 | unsigned int wiphy_idx; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 111 | u8 perm_addr[ETH_ALEN]; |
| 112 | void *ctx; |
| 113 | int ifindex; |
| 114 | int if_removed; |
| 115 | int if_disabled; |
| 116 | int ignore_if_down_event; |
| 117 | struct rfkill_data *rfkill; |
| 118 | struct wpa_driver_capa capa; |
| 119 | u8 *extended_capa, *extended_capa_mask; |
| 120 | unsigned int extended_capa_len; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 121 | struct drv_nl80211_iface_capa { |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 122 | enum nl80211_iftype iftype; |
| 123 | u8 *ext_capa, *ext_capa_mask; |
| 124 | unsigned int ext_capa_len; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 125 | u16 eml_capa; |
| 126 | u16 mld_capa_and_ops; |
| 127 | } iface_capa[NL80211_IFTYPE_MAX]; |
| 128 | unsigned int num_iface_capa; |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 129 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 130 | int has_capability; |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 131 | int has_driver_key_mgmt; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 132 | |
| 133 | int operstate; |
| 134 | |
| 135 | int scan_complete_events; |
| 136 | enum scan_states { |
| 137 | NO_SCAN, SCAN_REQUESTED, SCAN_STARTED, SCAN_COMPLETED, |
| 138 | SCAN_ABORTED, SCHED_SCAN_STARTED, SCHED_SCAN_STOPPED, |
| 139 | SCHED_SCAN_RESULTS |
| 140 | } scan_state; |
| 141 | |
| 142 | u8 auth_bssid[ETH_ALEN]; |
| 143 | u8 auth_attempt_bssid[ETH_ALEN]; |
| 144 | u8 bssid[ETH_ALEN]; |
| 145 | u8 prev_bssid[ETH_ALEN]; |
| 146 | int associated; |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame] | 147 | struct driver_sta_mlo_info sta_mlo_info; |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 148 | u8 ssid[SSID_MAX_LEN]; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 149 | size_t ssid_len; |
| 150 | enum nl80211_iftype nlmode; |
| 151 | enum nl80211_iftype ap_scan_as_station; |
| 152 | unsigned int assoc_freq; |
| 153 | |
| 154 | int monitor_sock; |
| 155 | int monitor_ifidx; |
| 156 | int monitor_refcount; |
| 157 | |
| 158 | unsigned int disabled_11b_rates:1; |
| 159 | unsigned int pending_remain_on_chan:1; |
| 160 | unsigned int in_interface_list:1; |
| 161 | unsigned int device_ap_sme:1; |
| 162 | unsigned int poll_command_supported:1; |
| 163 | unsigned int data_tx_status:1; |
| 164 | unsigned int scan_for_auth:1; |
| 165 | unsigned int retry_auth:1; |
| 166 | unsigned int use_monitor:1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 167 | unsigned int hostapd:1; |
Hai Shalom | c1a2144 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 168 | unsigned int start_mode_sta:1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 169 | unsigned int start_iface_up:1; |
| 170 | unsigned int test_use_roc_tx:1; |
| 171 | unsigned int ignore_deauth_event:1; |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 172 | unsigned int vendor_cmd_test_avail:1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 173 | unsigned int roaming_vendor_cmd_avail:1; |
| 174 | unsigned int dfs_vendor_cmd_avail:1; |
| 175 | unsigned int have_low_prio_scan:1; |
| 176 | unsigned int force_connect_cmd:1; |
| 177 | unsigned int addr_changed:1; |
| 178 | unsigned int get_features_vendor_cmd_avail:1; |
Dmitry Shmidt | ff787d5 | 2015-01-12 13:01:47 -0800 | [diff] [blame] | 179 | unsigned int set_rekey_offload:1; |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 180 | unsigned int p2p_go_ctwindow_supported:1; |
Ravi Joshi | e6ccb16 | 2015-07-16 17:45:41 -0700 | [diff] [blame] | 181 | unsigned int setband_vendor_cmd_avail:1; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 182 | unsigned int get_pref_freq_list:1; |
| 183 | unsigned int set_prob_oper_freq:1; |
| 184 | unsigned int scan_vendor_cmd_avail:1; |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 185 | unsigned int connect_reassoc:1; |
Dmitry Shmidt | 7f2c753 | 2016-08-15 09:48:12 -0700 | [diff] [blame] | 186 | unsigned int set_wifi_conf_vendor_cmd_avail:1; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 187 | unsigned int fetch_bss_trans_status:1; |
| 188 | unsigned int roam_vendor_cmd_avail:1; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 189 | unsigned int add_sta_node_vendor_cmd_avail:1; |
Hai Shalom | b755a2a | 2020-04-23 21:49:02 -0700 | [diff] [blame] | 190 | unsigned int control_port_ap:1; |
Hai Shalom | e21d4e8 | 2020-04-29 16:34:06 -0700 | [diff] [blame] | 191 | unsigned int multicast_registrations:1; |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 192 | unsigned int no_rrm:1; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 193 | unsigned int get_sta_info_vendor_cmd_avail:1; |
| 194 | unsigned int fils_discovery:1; |
| 195 | unsigned int unsol_bcast_probe_resp:1; |
Hai Shalom | c1a2144 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 196 | unsigned int qca_do_acs:1; |
| 197 | unsigned int brcm_do_acs:1; |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame] | 198 | unsigned int uses_6ghz:1; |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 199 | unsigned int uses_s1g:1; |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame] | 200 | unsigned int secure_ranging_ctx_vendor_cmd_avail:1; |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 201 | unsigned int puncturing:1; |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame] | 202 | unsigned int qca_ap_allowed_freqs:1; |
Sunil Ravi | c0f5d41 | 2024-09-11 22:12:49 +0000 | [diff] [blame] | 203 | unsigned int connect_ext_vendor_cmd_avail:1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 204 | |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 205 | u32 ignore_next_local_disconnect; |
| 206 | u32 ignore_next_local_deauth; |
| 207 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 208 | u64 vendor_scan_cookie; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 209 | u64 remain_on_chan_cookie; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 210 | u64 send_frame_cookie; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 211 | int send_frame_link_id; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 212 | #define MAX_SEND_FRAME_COOKIES 20 |
| 213 | u64 send_frame_cookies[MAX_SEND_FRAME_COOKIES]; |
| 214 | unsigned int num_send_frame_cookies; |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 215 | u64 eapol_tx_cookie; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 216 | int eapol_tx_link_id; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 217 | |
| 218 | unsigned int last_mgmt_freq; |
| 219 | |
| 220 | struct wpa_driver_scan_filter *filter_ssids; |
| 221 | size_t num_filter_ssids; |
| 222 | |
| 223 | struct i802_bss *first_bss; |
| 224 | |
| 225 | int eapol_tx_sock; |
| 226 | |
| 227 | int eapol_sock; /* socket for EAPOL frames */ |
| 228 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 229 | struct nl_sock *rtnl_sk; /* nl_sock for NETLINK_ROUTE */ |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 230 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 231 | struct drv_nl80211_if_info default_if_indices[16]; |
| 232 | struct drv_nl80211_if_info *if_indices; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 233 | int num_if_indices; |
| 234 | |
| 235 | /* From failed authentication command */ |
| 236 | int auth_freq; |
| 237 | u8 auth_bssid_[ETH_ALEN]; |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 238 | u8 auth_ssid[SSID_MAX_LEN]; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 239 | size_t auth_ssid_len; |
| 240 | int auth_alg; |
| 241 | u8 *auth_ie; |
| 242 | size_t auth_ie_len; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 243 | u8 *auth_data; |
| 244 | size_t auth_data_len; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 245 | u8 auth_wep_key[4][16]; |
| 246 | size_t auth_wep_key_len[4]; |
| 247 | int auth_wep_tx_keyidx; |
| 248 | int auth_local_state_change; |
| 249 | int auth_p2p; |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 250 | bool auth_mld; |
| 251 | u8 auth_mld_link_id; |
| 252 | u8 auth_ap_mld_addr[ETH_ALEN]; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 253 | |
| 254 | /* |
| 255 | * Tells whether the last scan issued from wpa_supplicant was a normal |
| 256 | * scan (NL80211_CMD_TRIGGER_SCAN) or a vendor scan |
| 257 | * (NL80211_CMD_VENDOR). 0 if no pending scan request. |
| 258 | */ |
| 259 | int last_scan_cmd; |
Andy Kuo | aba17c1 | 2022-04-14 16:05:31 +0800 | [diff] [blame] | 260 | #if defined(CONFIG_DRIVER_NL80211_BRCM) || defined(CONFIG_DRIVER_NL80211_SYNA) |
Mir Ali | 677e748 | 2020-11-12 19:49:02 +0530 | [diff] [blame] | 261 | unsigned int vendor_set_pmk:1; /* for legacy set_pmk method before NL80211_CMD_SET_PMK */ |
Andy Kuo | aba17c1 | 2022-04-14 16:05:31 +0800 | [diff] [blame] | 262 | #endif /* CONFIG_DRIVER_NL80211_BRCM || CONFIG_DRIVER_NL80211_SYNA */ |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 263 | #ifdef CONFIG_DRIVER_NL80211_QCA |
| 264 | bool roam_indication_done; |
| 265 | u8 *pending_roam_data; |
| 266 | size_t pending_roam_data_len; |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame] | 267 | u8 *pending_t2lm_data; |
| 268 | size_t pending_t2lm_data_len; |
| 269 | u8 *pending_link_reconfig_data; |
| 270 | size_t pending_link_reconfig_data_len; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 271 | #endif /* CONFIG_DRIVER_NL80211_QCA */ |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 272 | }; |
| 273 | |
| 274 | struct nl_msg; |
| 275 | |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 276 | struct nl80211_err_info { |
| 277 | int link_id; |
| 278 | }; |
| 279 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 280 | void * nl80211_cmd(struct wpa_driver_nl80211_data *drv, |
| 281 | struct nl_msg *msg, int flags, uint8_t cmd); |
| 282 | struct nl_msg * nl80211_cmd_msg(struct i802_bss *bss, int flags, uint8_t cmd); |
| 283 | struct nl_msg * nl80211_drv_msg(struct wpa_driver_nl80211_data *drv, int flags, |
| 284 | uint8_t cmd); |
| 285 | struct nl_msg * nl80211_bss_msg(struct i802_bss *bss, int flags, uint8_t cmd); |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 286 | |
| 287 | int send_and_recv(struct nl80211_global *global, |
| 288 | struct nl_sock *nl_handle, struct nl_msg *msg, |
| 289 | int (*valid_handler)(struct nl_msg *, void *), |
| 290 | void *valid_data, |
| 291 | int (*ack_handler_custom)(struct nl_msg *, void *), |
| 292 | void *ack_data, |
| 293 | struct nl80211_err_info *err_info); |
| 294 | |
Sunil Ravi | 99c035e | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 295 | // This function is not used in supplicant anymore. But keeping this wrapper |
| 296 | // functions for libraries outside wpa_supplicant to build (For eg: lib_driver_cmd_XX) |
| 297 | static inline int |
| 298 | send_and_recv_msgs(struct wpa_driver_nl80211_data *drv, |
| 299 | struct nl_msg *msg, |
| 300 | int (*valid_handler)(struct nl_msg *, void *), |
| 301 | void *valid_data, |
| 302 | int (*ack_handler_custom)(struct nl_msg *, void *), |
| 303 | void *ack_data) |
| 304 | { |
| 305 | return send_and_recv(drv->global, drv->global->nl, msg, |
| 306 | valid_handler, valid_data, |
| 307 | ack_handler_custom, ack_data, NULL); |
| 308 | } |
| 309 | |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 310 | static inline int |
| 311 | send_and_recv_cmd(struct wpa_driver_nl80211_data *drv, |
| 312 | struct nl_msg *msg) |
| 313 | { |
| 314 | return send_and_recv(drv->global, drv->global->nl, msg, |
| 315 | NULL, NULL, NULL, NULL, NULL); |
| 316 | } |
| 317 | |
| 318 | static inline int |
| 319 | send_and_recv_resp(struct wpa_driver_nl80211_data *drv, |
| 320 | struct nl_msg *msg, |
| 321 | int (*valid_handler)(struct nl_msg *, void *), |
| 322 | void *valid_data) |
| 323 | { |
| 324 | return send_and_recv(drv->global, drv->global->nl, msg, |
| 325 | valid_handler, valid_data, NULL, NULL, NULL); |
| 326 | } |
| 327 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 328 | int nl80211_create_iface(struct wpa_driver_nl80211_data *drv, |
| 329 | const char *ifname, enum nl80211_iftype iftype, |
| 330 | const u8 *addr, int wds, |
| 331 | int (*handler)(struct nl_msg *, void *), |
| 332 | void *arg, int use_existing); |
| 333 | void nl80211_remove_iface(struct wpa_driver_nl80211_data *drv, int ifidx); |
| 334 | unsigned int nl80211_get_assoc_freq(struct wpa_driver_nl80211_data *drv); |
Dmitry Shmidt | abb90a3 | 2016-12-05 15:34:39 -0800 | [diff] [blame] | 335 | int nl80211_get_assoc_ssid(struct wpa_driver_nl80211_data *drv, u8 *ssid); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 336 | enum chan_width convert2width(int width); |
| 337 | void nl80211_mark_disconnected(struct wpa_driver_nl80211_data *drv); |
| 338 | struct i802_bss * get_bss_ifindex(struct wpa_driver_nl80211_data *drv, |
| 339 | int ifindex); |
| 340 | int is_ap_interface(enum nl80211_iftype nlmode); |
| 341 | int is_sta_interface(enum nl80211_iftype nlmode); |
| 342 | int wpa_driver_nl80211_authenticate_retry(struct wpa_driver_nl80211_data *drv); |
| 343 | int nl80211_get_link_signal(struct wpa_driver_nl80211_data *drv, |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 344 | const u8 *bssid, |
| 345 | struct hostap_sta_driver_data *data); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 346 | int nl80211_get_link_noise(struct wpa_driver_nl80211_data *drv, |
| 347 | struct wpa_signal_info *sig_change); |
| 348 | int nl80211_get_wiphy_index(struct i802_bss *bss); |
| 349 | int wpa_driver_nl80211_set_mode(struct i802_bss *bss, |
| 350 | enum nl80211_iftype nlmode); |
| 351 | int wpa_driver_nl80211_mlme(struct wpa_driver_nl80211_data *drv, |
| 352 | const u8 *addr, int cmd, u16 reason_code, |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 353 | int local_state_change, |
Hai Shalom | c1a2144 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 354 | struct i802_bss *bss); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 355 | |
| 356 | int nl80211_create_monitor_interface(struct wpa_driver_nl80211_data *drv); |
| 357 | void nl80211_remove_monitor_interface(struct wpa_driver_nl80211_data *drv); |
| 358 | int nl80211_send_monitor(struct wpa_driver_nl80211_data *drv, |
| 359 | const void *data, size_t len, |
| 360 | int encrypt, int noack); |
| 361 | |
| 362 | int wpa_driver_nl80211_capa(struct wpa_driver_nl80211_data *drv); |
| 363 | struct hostapd_hw_modes * |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 364 | nl80211_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags, |
| 365 | u8 *dfs_domain); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 366 | |
| 367 | int process_global_event(struct nl_msg *msg, void *arg); |
| 368 | int process_bss_event(struct nl_msg *msg, void *arg); |
| 369 | |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 370 | const char * nl80211_iftype_str(enum nl80211_iftype mode); |
| 371 | |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 372 | void nl80211_restore_ap_mode(struct i802_bss *bss); |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 373 | struct i802_link * nl80211_get_link(struct i802_bss *bss, s8 link_id); |
Sunil Ravi | c0f5d41 | 2024-09-11 22:12:49 +0000 | [diff] [blame] | 374 | u8 nl80211_get_link_id_from_link(struct i802_bss *bss, struct i802_link *link); |
| 375 | int nl80211_remove_link(struct i802_bss *bss, int link_id); |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 376 | |
Sunil Ravi | 99c035e | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 377 | static inline bool nl80211_link_valid(u16 links, s8 link_id) |
| 378 | { |
| 379 | if (link_id < 0 || link_id >= MAX_NUM_MLD_LINKS) |
| 380 | return false; |
| 381 | |
| 382 | if (links & BIT(link_id)) |
| 383 | return true; |
| 384 | |
| 385 | return false; |
| 386 | } |
| 387 | |
| 388 | |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 389 | static inline bool |
| 390 | nl80211_attr_supported(struct wpa_driver_nl80211_data *drv, unsigned int attr) |
| 391 | { |
| 392 | return attr <= drv->global->nl80211_maxattr; |
| 393 | } |
| 394 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 395 | #ifdef ANDROID |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 396 | int android_nl_socket_set_nonblocking(struct nl_sock *handle); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 397 | int android_pno_start(struct i802_bss *bss, |
| 398 | struct wpa_driver_scan_params *params); |
| 399 | int android_pno_stop(struct i802_bss *bss); |
| 400 | extern int wpa_driver_nl80211_driver_cmd(void *priv, char *cmd, char *buf, |
| 401 | size_t buf_len); |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 402 | extern int wpa_driver_nl80211_driver_event(struct wpa_driver_nl80211_data *drv, |
| 403 | u32 vendor_id, u32 subcmd, |
| 404 | u8 *data, size_t len); |
| 405 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 406 | |
| 407 | #ifdef ANDROID_P2P |
| 408 | int wpa_driver_set_p2p_noa(void *priv, u8 count, int start, int duration); |
| 409 | int wpa_driver_get_p2p_noa(void *priv, u8 *buf, size_t len); |
| 410 | int wpa_driver_set_p2p_ps(void *priv, int legacy_ps, int opp_ps, int ctwindow); |
| 411 | int wpa_driver_set_ap_wps_p2p_ie(void *priv, const struct wpabuf *beacon, |
| 412 | const struct wpabuf *proberesp, |
| 413 | const struct wpabuf *assocresp); |
| 414 | #endif /* ANDROID_P2P */ |
| 415 | #endif /* ANDROID */ |
| 416 | |
| 417 | |
| 418 | /* driver_nl80211_scan.c */ |
| 419 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 420 | void wpa_driver_nl80211_scan_timeout(void *eloop_ctx, void *timeout_ctx); |
| 421 | int wpa_driver_nl80211_scan(struct i802_bss *bss, |
| 422 | struct wpa_driver_scan_params *params); |
| 423 | int wpa_driver_nl80211_sched_scan(void *priv, |
Dmitry Shmidt | d7ff03d | 2015-12-04 14:49:35 -0800 | [diff] [blame] | 424 | struct wpa_driver_scan_params *params); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 425 | int wpa_driver_nl80211_stop_sched_scan(void *priv); |
Sunil Ravi | 99c035e | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 426 | struct wpa_scan_results * wpa_driver_nl80211_get_scan_results(void *priv, |
| 427 | const u8 *bssid); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 428 | void nl80211_dump_scan(struct wpa_driver_nl80211_data *drv); |
Dmitry Shmidt | abb90a3 | 2016-12-05 15:34:39 -0800 | [diff] [blame] | 429 | int wpa_driver_nl80211_abort_scan(void *priv, u64 scan_cookie); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 430 | int wpa_driver_nl80211_vendor_scan(struct i802_bss *bss, |
| 431 | struct wpa_driver_scan_params *params); |
Dmitry Shmidt | 7f2c753 | 2016-08-15 09:48:12 -0700 | [diff] [blame] | 432 | int nl80211_set_default_scan_ies(void *priv, const u8 *ies, size_t ies_len); |
Sunil Ravi | c0f5d41 | 2024-09-11 22:12:49 +0000 | [diff] [blame] | 433 | struct hostapd_multi_hw_info * |
| 434 | nl80211_get_multi_hw_info(struct i802_bss *bss, unsigned int *num_multi_hws); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 435 | |
| 436 | #endif /* DRIVER_NL80211_H */ |