Home | History | Annotate | Download | only in ap
      1 /*
      2  * hostapd / Initialization and configuration
      3  * Copyright (c) 2002-2009, Jouni Malinen <j (at) w1.fi>
      4  *
      5  * This program is free software; you can redistribute it and/or modify
      6  * it under the terms of the GNU General Public License version 2 as
      7  * published by the Free Software Foundation.
      8  *
      9  * Alternatively, this software may be distributed under the terms of BSD
     10  * license.
     11  *
     12  * See README and COPYING for more details.
     13  */
     14 
     15 #ifndef HOSTAPD_H
     16 #define HOSTAPD_H
     17 
     18 #include "common/defs.h"
     19 
     20 struct wpa_driver_ops;
     21 struct wpa_ctrl_dst;
     22 struct radius_server_data;
     23 struct upnp_wps_device_sm;
     24 struct hapd_interfaces;
     25 struct hostapd_data;
     26 struct sta_info;
     27 struct hostap_sta_driver_data;
     28 struct ieee80211_ht_capabilities;
     29 struct full_dynamic_vlan;
     30 enum wps_event;
     31 union wps_event_data;
     32 
     33 struct hostapd_probereq_cb {
     34 	int (*cb)(void *ctx, const u8 *sa, const u8 *ie, size_t ie_len);
     35 	void *ctx;
     36 };
     37 
     38 #define HOSTAPD_RATE_BASIC 0x00000001
     39 
     40 struct hostapd_rate_data {
     41 	int rate; /* rate in 100 kbps */
     42 	int flags; /* HOSTAPD_RATE_ flags */
     43 };
     44 
     45 struct hostapd_frame_info {
     46 	u32 channel;
     47 	u32 datarate;
     48 	u32 ssi_signal;
     49 };
     50 
     51 
     52 /**
     53  * struct hostapd_data - hostapd per-BSS data structure
     54  */
     55 struct hostapd_data {
     56 	struct hostapd_iface *iface;
     57 	struct hostapd_config *iconf;
     58 	struct hostapd_bss_config *conf;
     59 	int interface_added; /* virtual interface added for this BSS */
     60 
     61 	u8 own_addr[ETH_ALEN];
     62 
     63 	int num_sta; /* number of entries in sta_list */
     64 	struct sta_info *sta_list; /* STA info list head */
     65 #define STA_HASH_SIZE 256
     66 #define STA_HASH(sta) (sta[5])
     67 	struct sta_info *sta_hash[STA_HASH_SIZE];
     68 
     69 	/*
     70 	 * Bitfield for indicating which AIDs are allocated. Only AID values
     71 	 * 1-2007 are used and as such, the bit at index 0 corresponds to AID
     72 	 * 1.
     73 	 */
     74 #define AID_WORDS ((2008 + 31) / 32)
     75 	u32 sta_aid[AID_WORDS];
     76 
     77 	const struct wpa_driver_ops *driver;
     78 	void *drv_priv;
     79 
     80 	void (*new_assoc_sta_cb)(struct hostapd_data *hapd,
     81 				 struct sta_info *sta, int reassoc);
     82 
     83 	void *msg_ctx; /* ctx for wpa_msg() calls */
     84 #ifdef ANDROID_BRCM_P2P_PATCH
     85 	/* Sending the event to parent is required as SSL listens on parent ctrl iface */
     86 	void *msg_ctx_parent; /* ctx for wpa_msg() calls */
     87 #endif /*ANDROID_BRCM_P2P_PATCH*/
     88 
     89 	struct radius_client_data *radius;
     90 	u32 acct_session_id_hi, acct_session_id_lo;
     91 
     92 	struct iapp_data *iapp;
     93 
     94 	struct hostapd_cached_radius_acl *acl_cache;
     95 	struct hostapd_acl_query_data *acl_queries;
     96 
     97 	struct wpa_authenticator *wpa_auth;
     98 	struct eapol_authenticator *eapol_auth;
     99 
    100 	struct rsn_preauth_interface *preauth_iface;
    101 	time_t michael_mic_failure;
    102 	int michael_mic_failures;
    103 	int tkip_countermeasures;
    104 
    105 	int ctrl_sock;
    106 	struct wpa_ctrl_dst *ctrl_dst;
    107 
    108 	void *ssl_ctx;
    109 	void *eap_sim_db_priv;
    110 	struct radius_server_data *radius_srv;
    111 
    112 	int parameter_set_count;
    113 
    114 #ifdef CONFIG_FULL_DYNAMIC_VLAN
    115 	struct full_dynamic_vlan *full_dynamic_vlan;
    116 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
    117 
    118 	struct l2_packet_data *l2;
    119 	struct wps_context *wps;
    120 
    121 	struct wpabuf *wps_beacon_ie;
    122 	struct wpabuf *wps_probe_resp_ie;
    123 #ifdef CONFIG_WPS
    124 	unsigned int ap_pin_failures;
    125 	struct upnp_wps_device_sm *wps_upnp;
    126 	unsigned int ap_pin_lockout_time;
    127 #endif /* CONFIG_WPS */
    128 
    129 	struct hostapd_probereq_cb *probereq_cb;
    130 	size_t num_probereq_cb;
    131 
    132 	void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
    133 				 int freq);
    134 	void *public_action_cb_ctx;
    135 
    136 	int (*vendor_action_cb)(void *ctx, const u8 *buf, size_t len,
    137 				int freq);
    138 	void *vendor_action_cb_ctx;
    139 
    140 	void (*wps_reg_success_cb)(void *ctx, const u8 *mac_addr,
    141 				   const u8 *uuid_e);
    142 	void *wps_reg_success_cb_ctx;
    143 
    144 	void (*wps_event_cb)(void *ctx, enum wps_event event,
    145 			     union wps_event_data *data);
    146 	void *wps_event_cb_ctx;
    147 
    148 	void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr,
    149 				  int authorized);
    150 	void *sta_authorized_cb_ctx;
    151 
    152 	void (*setup_complete_cb)(void *ctx);
    153 	void *setup_complete_cb_ctx;
    154 
    155 #ifdef CONFIG_P2P
    156 	struct p2p_data *p2p;
    157 	struct p2p_group *p2p_group;
    158 	struct wpabuf *p2p_beacon_ie;
    159 	struct wpabuf *p2p_probe_resp_ie;
    160 
    161 	/* Number of non-P2P association stations */
    162 	int num_sta_no_p2p;
    163 
    164 	/* Periodic NoA (used only when no non-P2P clients in the group) */
    165 	int noa_enabled;
    166 	int noa_start;
    167 	int noa_duration;
    168 #endif /* CONFIG_P2P */
    169 };
    170 
    171 
    172 /**
    173  * struct hostapd_iface - hostapd per-interface data structure
    174  */
    175 struct hostapd_iface {
    176 	struct hapd_interfaces *interfaces;
    177 	void *owner;
    178 	int (*reload_config)(struct hostapd_iface *iface);
    179 	struct hostapd_config * (*config_read_cb)(const char *config_fname);
    180 	char *config_fname;
    181 	struct hostapd_config *conf;
    182 
    183 	size_t num_bss;
    184 	struct hostapd_data **bss;
    185 
    186 	int num_ap; /* number of entries in ap_list */
    187 	struct ap_info *ap_list; /* AP info list head */
    188 	struct ap_info *ap_hash[STA_HASH_SIZE];
    189 	struct ap_info *ap_iter_list;
    190 
    191 	unsigned int drv_flags;
    192 	struct hostapd_hw_modes *hw_features;
    193 	int num_hw_features;
    194 	struct hostapd_hw_modes *current_mode;
    195 	/* Rates that are currently used (i.e., filtered copy of
    196 	 * current_mode->channels */
    197 	int num_rates;
    198 	struct hostapd_rate_data *current_rates;
    199 	int freq;
    200 
    201 	u16 hw_flags;
    202 
    203 	/* Number of associated Non-ERP stations (i.e., stations using 802.11b
    204 	 * in 802.11g BSS) */
    205 	int num_sta_non_erp;
    206 
    207 	/* Number of associated stations that do not support Short Slot Time */
    208 	int num_sta_no_short_slot_time;
    209 
    210 	/* Number of associated stations that do not support Short Preamble */
    211 	int num_sta_no_short_preamble;
    212 
    213 	int olbc; /* Overlapping Legacy BSS Condition */
    214 
    215 	/* Number of HT associated stations that do not support greenfield */
    216 	int num_sta_ht_no_gf;
    217 
    218 	/* Number of associated non-HT stations */
    219 	int num_sta_no_ht;
    220 
    221 	/* Number of HT associated stations 20 MHz */
    222 	int num_sta_ht_20mhz;
    223 
    224 	/* Overlapping BSS information */
    225 	int olbc_ht;
    226 
    227 	u16 ht_op_mode;
    228 	void (*scan_cb)(struct hostapd_iface *iface);
    229 
    230 	int (*ctrl_iface_init)(struct hostapd_data *hapd);
    231 	void (*ctrl_iface_deinit)(struct hostapd_data *hapd);
    232 
    233 	int (*for_each_interface)(struct hapd_interfaces *interfaces,
    234 				  int (*cb)(struct hostapd_iface *iface,
    235 					    void *ctx), void *ctx);
    236 };
    237 
    238 /* hostapd.c */
    239 int hostapd_reload_config(struct hostapd_iface *iface);
    240 struct hostapd_data *
    241 hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
    242 		       struct hostapd_config *conf,
    243 		       struct hostapd_bss_config *bss);
    244 int hostapd_setup_interface(struct hostapd_iface *iface);
    245 int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err);
    246 void hostapd_interface_deinit(struct hostapd_iface *iface);
    247 void hostapd_interface_free(struct hostapd_iface *iface);
    248 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
    249 			   int reassoc);
    250 
    251 /* utils.c */
    252 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
    253 				 int (*cb)(void *ctx, const u8 *sa,
    254 					   const u8 *ie, size_t ie_len),
    255 				 void *ctx);
    256 void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
    257 
    258 /* drv_callbacks.c (TODO: move to somewhere else?) */
    259 int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
    260 			const u8 *ie, size_t ielen, int reassoc);
    261 void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
    262 void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr);
    263 int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa,
    264 			 const u8 *ie, size_t ie_len);
    265 
    266 #endif /* HOSTAPD_H */
    267