wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
hostapd.h
Go to the documentation of this file.
1 
5 #ifndef HOSTAPD_H
6 #define HOSTAPD_H
7 
8 #include "common/defs.h"
9 #include "utils/list.h"
10 #include "ap_config.h"
11 #include "drivers/driver.h"
12 
13 struct wpa_ctrl_dst;
14 struct radius_server_data;
15 struct upnp_wps_device_sm;
16 struct hostapd_data;
17 struct sta_info;
19 struct full_dynamic_vlan;
20 enum wps_event;
21 union wps_event_data;
22 #ifdef CONFIG_MESH
23 struct mesh_conf;
24 #endif /* CONFIG_MESH */
25 
26 struct hostapd_iface;
27 
29  int (*reload_config)(struct hostapd_iface *iface);
30  struct hostapd_config * (*config_read_cb)(const char *config_fname);
31  int (*ctrl_iface_init)(struct hostapd_data *hapd);
32  void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
33  int (*for_each_interface)(struct hapd_interfaces *interfaces,
34  int (*cb)(struct hostapd_iface *iface,
35  void *ctx), void *ctx);
36  int (*driver_init)(struct hostapd_iface *iface);
37 
38  size_t count;
39  int global_ctrl_sock;
40  struct wpa_ctrl_dst *global_ctrl_dst;
41  char *global_iface_path;
42  char *global_iface_name;
43 #ifndef CONFIG_NATIVE_WINDOWS
44  gid_t ctrl_iface_group;
45 #endif /* CONFIG_NATIVE_WINDOWS */
46  struct hostapd_iface **iface;
47 
48  size_t terminate_on_error;
49 #ifndef CONFIG_NO_VLAN
50  struct dynamic_iface *vlan_priv;
51 #endif /* CONFIG_NO_VLAN */
52 };
53 
54 enum hostapd_chan_status {
55  HOSTAPD_CHAN_VALID = 0, /* channel is ready */
56  HOSTAPD_CHAN_INVALID = 1, /* no usable channel found */
57  HOSTAPD_CHAN_ACS = 2, /* ACS work being performed */
58 };
59 
61  int (*cb)(void *ctx, const u8 *sa, const u8 *da, const u8 *bssid,
62  const u8 *ie, size_t ie_len, int ssi_signal);
63  void *ctx;
64 };
65 
66 #define HOSTAPD_RATE_BASIC 0x00000001
67 
69  int rate; /* rate in 100 kbps */
70  int flags; /* HOSTAPD_RATE_ flags */
71 };
72 
74  u32 channel;
75  u32 datarate;
76  int ssi_signal; /* dBm */
77 };
78 
79 enum wps_status {
80  WPS_STATUS_SUCCESS = 1,
81  WPS_STATUS_FAILURE
82 };
83 
84 enum pbc_status {
85  WPS_PBC_STATUS_DISABLE,
86  WPS_PBC_STATUS_ACTIVE,
87  WPS_PBC_STATUS_TIMEOUT,
88  WPS_PBC_STATUS_OVERLAP
89 };
90 
91 struct wps_stat {
92  enum wps_status status;
93  enum wps_error_indication failure_reason;
94  enum pbc_status pbc_status;
95  u8 peer_addr[ETH_ALEN];
96 };
97 
98 
103 struct hostapd_data {
104  struct hostapd_iface *iface;
105  struct hostapd_config *iconf;
106  struct hostapd_bss_config *conf;
107  int interface_added; /* virtual interface added for this BSS */
108  unsigned int started:1;
109  unsigned int disabled:1;
110  unsigned int reenable_beacon:1;
111 
112  u8 own_addr[ETH_ALEN];
113 
114  int num_sta; /* number of entries in sta_list */
115  struct sta_info *sta_list; /* STA info list head */
116 #define STA_HASH_SIZE 256
117 #define STA_HASH(sta) (sta[5])
118  struct sta_info *sta_hash[STA_HASH_SIZE];
119 
120  /*
121  * Bitfield for indicating which AIDs are allocated. Only AID values
122  * 1-2007 are used and as such, the bit at index 0 corresponds to AID
123  * 1.
124  */
125 #define AID_WORDS ((2008 + 31) / 32)
126  u32 sta_aid[AID_WORDS];
127 
128  const struct wpa_driver_ops *driver;
129  void *drv_priv;
130 
131  void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
132  struct sta_info *sta, int reassoc);
133 
134  void *msg_ctx; /* ctx for wpa_msg() calls */
135  void *msg_ctx_parent; /* parent interface ctx for wpa_msg() calls */
136 
137  struct radius_client_data *radius;
138  u32 acct_session_id_hi, acct_session_id_lo;
139  struct radius_das_data *radius_das;
140 
141  struct iapp_data *iapp;
142 
143  struct hostapd_cached_radius_acl *acl_cache;
144  struct hostapd_acl_query_data *acl_queries;
145 
146  struct wpa_authenticator *wpa_auth;
147  struct eapol_authenticator *eapol_auth;
148 
149  struct rsn_preauth_interface *preauth_iface;
150  struct os_reltime michael_mic_failure;
151  int michael_mic_failures;
152  int tkip_countermeasures;
153 
154  int ctrl_sock;
155  struct wpa_ctrl_dst *ctrl_dst;
156 
157  void *ssl_ctx;
158  void *eap_sim_db_priv;
159  struct radius_server_data *radius_srv;
160  struct dl_list erp_keys; /* struct eap_server_erp_key */
161 
162  int parameter_set_count;
163 
164  /* Time Advertisement */
165  u8 time_update_counter;
166  struct wpabuf *time_adv;
167 
168 #ifdef CONFIG_FULL_DYNAMIC_VLAN
169  struct full_dynamic_vlan *full_dynamic_vlan;
170 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
171 
172  struct l2_packet_data *l2;
173  struct wps_context *wps;
174 
175  int beacon_set_done;
176  struct wpabuf *wps_beacon_ie;
177  struct wpabuf *wps_probe_resp_ie;
178 #ifdef CONFIG_WPS
179  unsigned int ap_pin_failures;
180  unsigned int ap_pin_failures_consecutive;
181  struct upnp_wps_device_sm *wps_upnp;
182  unsigned int ap_pin_lockout_time;
183 
184  struct wps_stat wps_stats;
185 #endif /* CONFIG_WPS */
186 
187  struct hostapd_probereq_cb *probereq_cb;
188  size_t num_probereq_cb;
189 
190  void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
191  int freq);
192  void *public_action_cb_ctx;
193  void (*public_action_cb2)(void *ctx, const u8 *buf, size_t len,
194  int freq);
195  void *public_action_cb2_ctx;
196 
197  int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len,
198  int freq);
199  void *vendor_action_cb_ctx;
200 
201  void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
202  const u8 *uuid_e);
203  void *wps_reg_success_cb_ctx;
204 
205  void (*wps_event_cb)(void *ctx, enum wps_event event,
206  union wps_event_data *data);
207  void *wps_event_cb_ctx;
208 
209  void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr,
210  int authorized, const u8 *p2p_dev_addr);
211  void *sta_authorized_cb_ctx;
212 
213  void (*setup_complete_cb)(void *ctx);
214  void *setup_complete_cb_ctx;
215 
216  void (*new_psk_cb)(void *ctx, const u8 *mac_addr,
217  const u8 *p2p_dev_addr, const u8 *psk,
218  size_t psk_len);
219  void *new_psk_cb_ctx;
220 
221  /* channel switch parameters */
222  struct hostapd_freq_params cs_freq_params;
223  u8 cs_count;
224  int cs_block_tx;
225  unsigned int cs_c_off_beacon;
226  unsigned int cs_c_off_proberesp;
227  int csa_in_progress;
228 
229  /* BSS Load */
230  unsigned int bss_load_update_timeout;
231 
232 #ifdef CONFIG_P2P
233  struct p2p_data *p2p;
234  struct p2p_group *p2p_group;
235  struct wpabuf *p2p_beacon_ie;
236  struct wpabuf *p2p_probe_resp_ie;
237 
238  /* Number of non-P2P association stations */
239  int num_sta_no_p2p;
240 
241  /* Periodic NoA (used only when no non-P2P clients in the group) */
242  int noa_enabled;
243  int noa_start;
244  int noa_duration;
245 #endif /* CONFIG_P2P */
246 #ifdef CONFIG_INTERWORKING
247  size_t gas_frag_limit;
248 #endif /* CONFIG_INTERWORKING */
249 #ifdef CONFIG_PROXYARP
250  struct l2_packet_data *sock_dhcp;
251  struct l2_packet_data *sock_ndisc;
252 #endif /* CONFIG_PROXYARP */
253 #ifdef CONFIG_MESH
254  int num_plinks;
255  int max_plinks;
256  void (*mesh_sta_free_cb)(struct sta_info *sta);
257  struct wpabuf *mesh_pending_auth;
258  struct os_reltime mesh_pending_auth_time;
259 #endif /* CONFIG_MESH */
260 
261 #ifdef CONFIG_SQLITE
262  struct hostapd_eap_user tmp_eap_user;
263 #endif /* CONFIG_SQLITE */
264 
265 #ifdef CONFIG_SAE
266 
267  u8 sae_token_key[8];
268  struct os_reltime last_sae_token_key_update;
269  int dot11RSNASAERetransPeriod; /* msec */
270 #endif /* CONFIG_SAE */
271 
272 #ifdef CONFIG_TESTING_OPTIONS
273  unsigned int ext_mgmt_frame_handling:1;
274  unsigned int ext_eapol_frame_io:1;
275 
276  struct l2_packet_data *l2_test;
277 #endif /* CONFIG_TESTING_OPTIONS */
278 };
279 
280 
282  struct dl_list list;
283  u8 addr[ETH_ALEN];
284  struct os_reltime last_seen;
285 };
286 
292  struct hapd_interfaces *interfaces;
293  void *owner;
294  char *config_fname;
295  struct hostapd_config *conf;
296  char phy[16]; /* Name of the PHY (radio) */
297 
298  enum hostapd_iface_state {
299  HAPD_IFACE_UNINITIALIZED,
300  HAPD_IFACE_DISABLED,
301  HAPD_IFACE_COUNTRY_UPDATE,
302  HAPD_IFACE_ACS,
303  HAPD_IFACE_HT_SCAN,
304  HAPD_IFACE_DFS,
305  HAPD_IFACE_ENABLED
306  } state;
307 
308 #ifdef CONFIG_MESH
309  struct mesh_conf *mconf;
310 #endif /* CONFIG_MESH */
311 
312  size_t num_bss;
313  struct hostapd_data **bss;
314 
315  unsigned int wait_channel_update:1;
316  unsigned int cac_started:1;
317 #ifdef CONFIG_FST
318  struct fst_iface *fst;
319  const struct wpabuf *fst_ies;
320 #endif /* CONFIG_FST */
321 
322  /*
323  * When set, indicates that the driver will handle the AP
324  * teardown: delete global keys, station keys, and stations.
325  */
326  unsigned int driver_ap_teardown:1;
327 
328  int num_ap; /* number of entries in ap_list */
329  struct ap_info *ap_list; /* AP info list head */
330  struct ap_info *ap_hash[STA_HASH_SIZE];
331 
332  u64 drv_flags;
333 
334  /* SMPS modes supported by the driver (WPA_DRIVER_SMPS_MODE_*) */
335  unsigned int smps_modes;
336 
337  /*
338  * A bitmap of supported protocols for probe response offload. See
339  * struct wpa_driver_capa in driver.h
340  */
341  unsigned int probe_resp_offloads;
342 
343  /* extended capabilities supported by the driver */
344  const u8 *extended_capa, *extended_capa_mask;
345  unsigned int extended_capa_len;
346 
347  unsigned int drv_max_acl_mac_addrs;
348 
349  struct hostapd_hw_modes *hw_features;
350  int num_hw_features;
351  struct hostapd_hw_modes *current_mode;
352  /* Rates that are currently used (i.e., filtered copy of
353  * current_mode->channels */
354  int num_rates;
355  struct hostapd_rate_data *current_rates;
356  int *basic_rates;
357  int freq;
358 
359  u16 hw_flags;
360 
361  /* Number of associated Non-ERP stations (i.e., stations using 802.11b
362  * in 802.11g BSS) */
363  int num_sta_non_erp;
364 
365  /* Number of associated stations that do not support Short Slot Time */
366  int num_sta_no_short_slot_time;
367 
368  /* Number of associated stations that do not support Short Preamble */
369  int num_sta_no_short_preamble;
370 
371  int olbc; /* Overlapping Legacy BSS Condition */
372 
373  /* Number of HT associated stations that do not support greenfield */
374  int num_sta_ht_no_gf;
375 
376  /* Number of associated non-HT stations */
377  int num_sta_no_ht;
378 
379  /* Number of HT associated stations 20 MHz */
380  int num_sta_ht_20mhz;
381 
382  /* Number of HT40 intolerant stations */
383  int num_sta_ht40_intolerant;
384 
385  /* Overlapping BSS information */
386  int olbc_ht;
387 
388  u16 ht_op_mode;
389 
390  /* surveying helpers */
391 
392  /* number of channels surveyed */
393  unsigned int chans_surveyed;
394 
395  /* lowest observed noise floor in dBm */
396  s8 lowest_nf;
397 
398  /* channel utilization calculation */
399  u64 last_channel_time;
400  u64 last_channel_time_busy;
401  u8 channel_utilization;
402 
403  unsigned int dfs_cac_ms;
404  struct os_reltime dfs_cac_start;
405 
406  /* Latched with the actual secondary channel information and will be
407  * used while juggling between HT20 and HT40 modes. */
408  int secondary_ch;
409 
410 #ifdef CONFIG_ACS
411  unsigned int acs_num_completed_scans;
412 #endif /* CONFIG_ACS */
413 
414  void (*scan_cb)(struct hostapd_iface *iface);
415  int num_ht40_scan_tries;
416 
417  struct dl_list sta_seen; /* struct hostapd_sta_info */
418  unsigned int num_sta_seen;
419 };
420 
421 /* hostapd.c */
422 int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
423  int (*cb)(struct hostapd_iface *iface,
424  void *ctx), void *ctx);
425 int hostapd_reload_config(struct hostapd_iface *iface);
426 struct hostapd_data *
427 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
428  struct hostapd_config *conf,
429  struct hostapd_bss_config *bss);
430 int hostapd_setup_interface(struct hostapd_iface *iface);
431 int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
432 void hostapd_interface_deinit(struct hostapd_iface *iface);
433 void hostapd_interface_free(struct hostapd_iface *iface);
434 struct hostapd_iface * hostapd_init(struct hapd_interfaces *interfaces,
435  const char *config_file);
436 struct hostapd_iface *
437 hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy,
438  const char *config_fname, int debug);
439 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
440  int reassoc);
441 void hostapd_interface_deinit_free(struct hostapd_iface *iface);
442 int hostapd_enable_iface(struct hostapd_iface *hapd_iface);
443 int hostapd_reload_iface(struct hostapd_iface *hapd_iface);
444 int hostapd_disable_iface(struct hostapd_iface *hapd_iface);
445 int hostapd_add_iface(struct hapd_interfaces *ifaces, char *buf);
446 int hostapd_remove_iface(struct hapd_interfaces *ifaces, char *buf);
447 void hostapd_channel_list_updated(struct hostapd_iface *iface, int initiator);
448 void hostapd_set_state(struct hostapd_iface *iface, enum hostapd_iface_state s);
449 const char * hostapd_state_text(enum hostapd_iface_state s);
450 int hostapd_switch_channel(struct hostapd_data *hapd,
451  struct csa_settings *settings);
452 void
453 hostapd_switch_channel_fallback(struct hostapd_iface *iface,
454  const struct hostapd_freq_params *freq_params);
455 void hostapd_cleanup_cs_params(struct hostapd_data *hapd);
456 void hostapd_periodic_iface(struct hostapd_iface *iface);
457 
458 /* utils.c */
459 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
460  int (*cb)(void *ctx, const u8 *sa,
461  const u8 *da, const u8 *bssid,
462  const u8 *ie, size_t ie_len,
463  int ssi_signal),
464  void *ctx);
465 void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
466 
467 /* drv_callbacks.c (TODO: move to somewhere else?) */
468 int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
469  const u8 *ie, size_t ielen, int reassoc);
470 void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
471 void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr);
472 void hostapd_event_connect_failed_reason(struct hostapd_data *hapd,
473  const u8 *addr, int reason_code);
474 int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da,
475  const u8 *bssid, const u8 *ie, size_t ie_len,
476  int ssi_signal);
477 void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht,
478  int offset, int width, int cf1, int cf2);
479 
480 const struct hostapd_eap_user *
481 hostapd_get_eap_user(struct hostapd_data *hapd, const u8 *identity,
482  size_t identity_len, int phase2);
483 
484 struct hostapd_data * hostapd_get_iface(struct hapd_interfaces *interfaces,
485  const char *ifname);
486 
487 #ifdef CONFIG_FST
488 void fst_hostapd_fill_iface_obj(struct hostapd_data *hapd,
489  struct fst_wpa_obj *iface_obj);
490 #endif /* CONFIG_FST */
491 
492 #endif /* HOSTAPD_H */
wps_event
WPS event types.
Definition: wps.h:416
Settings for channel switch command.
Definition: driver.h:1661
Definition: sta_info.h:44
int num_rates
Number of entries in the rates array.
Definition: driver.h:155
Definition: ieee802_11_auth.c:41
Definition: hostapd.h:91
hostapd per-interface data structure
Definition: hostapd.h:291
Definition: radius_das.c:15
Driver interface definition.
WPA Supplicant - Common definitions.
Definition: wpabuf.h:16
Definition: wps_upnp_i.h:123
Definition: ieee802_11_defs.h:634
struct hostapd_iface * hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy, const char *config_fname, int debug)
Read configuration file and init BSS data.
Definition: hostapd.c:1930
hostapd / Configuration definitions and helpers functions
Definition: ap_list.h:10
int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err)
Complete interface setup.
Definition: hostapd.c:1517
Definition: hostapd.h:73
Definition: l2_packet_freebsd.c:32
union wps_event_data - WPS event data
Definition: wps.h:511
Definition: os.h:22
Doubly-linked list.
P2P module data (internal to P2P module)
Definition: p2p_i.h:177
Definition: ieee802_11_auth.c:27
Supported hardware mode information.
Definition: driver.h:132
Doubly-linked list.
Definition: list.h:12
Definition: hostapd.h:60
Definition: iapp.c:165
Internal RADIUS server data.
Definition: radius_server.c:117
Driver interface API definition.
Definition: driver.h:1746
struct hostapd_iface * hostapd_init(struct hapd_interfaces *interfaces, const char *config_file)
Allocate and initialize per-interface data.
Definition: hostapd.c:1846
Definition: hostapd.h:281
Definition: hostapd.h:68
Definition: wpa_auth_i.h:176
Per-BSS configuration.
Definition: ap_config.h:209
void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr)
Remove extraneous associations.
Definition: utils.c:83
Channel parameters.
Definition: driver.h:510
local MBSS state and settings
Definition: ap_config.h:20
Internal RADIUS client data.
Definition: radius_client.c:171
Definition: ap_config.h:137
Internal data structure of control interface clients.
Definition: ctrl_iface.c:50
Internal P2P module per-group data.
Definition: p2p_group.c:31
struct hostapd_data * hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface, struct hostapd_config *conf, struct hostapd_bss_config *bss)
Allocate and initialize per-BSS data.
Definition: hostapd.c:1762
Definition: hostapd.h:28
int hostapd_setup_interface(struct hostapd_iface *iface)
Setup of an interface.
Definition: hostapd.c:1735
Definition: dbus_new_introspect.c:16
void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta, int reassoc)
Notify that a new station associated with the AP.
Definition: hostapd.c:2548
hostapd per-BSS data structure
Definition: hostapd.h:103
Global EAPOL authenticator data.
Definition: eapol_auth_sm_i.h:24
Long term WPS context data.
Definition: wps.h:623
Per-radio interface configuration.
Definition: ap_config.h:565