HAMMER 60I/Many: Mirroring
[dragonfly.git] / contrib / hostapd-0.5.8 / hostapd.h
blob70f802d2a8f096fd271d941c9b21b3adefc4e4fa
1 /*
2 * hostapd / Initialization and configuration
3 * Host AP kernel driver
4 * Copyright (c) 2002-2006, Jouni Malinen <j@w1.fi>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * Alternatively, this software may be distributed under the terms of BSD
11 * license.
13 * See README and COPYING for more details.
16 #ifndef HOSTAPD_H
17 #define HOSTAPD_H
19 #include "common.h"
20 #include "ap.h"
22 #ifndef ETH_ALEN
23 #define ETH_ALEN 6
24 #endif
25 #ifndef IFNAMSIZ
26 #define IFNAMSIZ 16
27 #endif
28 #ifndef ETH_P_ALL
29 #define ETH_P_ALL 0x0003
30 #endif
31 #ifndef ETH_P_PAE
32 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
33 #endif /* ETH_P_PAE */
35 #ifndef BIT
36 #define BIT(x) (1 << (x))
37 #endif
39 #ifndef MAC2STR
40 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
41 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
42 #endif
44 #include "config.h"
46 #ifdef _MSC_VER
47 #pragma pack(push, 1)
48 #endif /* _MSC_VER */
50 #define MAX_VLAN_ID 4094
52 struct ieee8023_hdr {
53 u8 dest[6];
54 u8 src[6];
55 u16 ethertype;
56 } STRUCT_PACKED;
59 struct ieee80211_hdr {
60 u16 frame_control;
61 u16 duration_id;
62 u8 addr1[6];
63 u8 addr2[6];
64 u8 addr3[6];
65 u16 seq_ctrl;
66 /* followed by 'u8 addr4[6];' if ToDS and FromDS is set in data frame
68 } STRUCT_PACKED;
70 #ifdef _MSC_VER
71 #pragma pack(pop)
72 #endif /* _MSC_VER */
74 #define IEEE80211_DA_FROMDS addr1
75 #define IEEE80211_BSSID_FROMDS addr2
76 #define IEEE80211_SA_FROMDS addr3
78 #define IEEE80211_HDRLEN (sizeof(struct ieee80211_hdr))
80 #define IEEE80211_FC(type, stype) host_to_le16((type << 2) | (stype << 4))
82 /* MTU to be set for the wlan#ap device; this is mainly needed for IEEE 802.1X
83 * frames that might be longer than normal default MTU and they are not
84 * fragmented */
85 #define HOSTAPD_MTU 2290
87 extern unsigned char rfc1042_header[6];
89 struct hostap_sta_driver_data {
90 unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
91 unsigned long current_tx_rate;
92 unsigned long inactive_msec;
93 unsigned long flags;
94 unsigned long num_ps_buf_frames;
95 unsigned long tx_retry_failed;
96 unsigned long tx_retry_count;
97 int last_rssi;
98 int last_ack_rssi;
101 struct driver_ops;
102 struct wpa_ctrl_dst;
103 struct radius_server_data;
105 #ifdef CONFIG_FULL_DYNAMIC_VLAN
106 struct full_dynamic_vlan;
107 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
110 * struct hostapd_data - hostapd per-BSS data structure
112 struct hostapd_data {
113 struct hostapd_iface *iface;
114 struct hostapd_config *iconf;
115 struct hostapd_bss_config *conf;
116 int interface_added; /* virtual interface added for this BSS */
118 u8 own_addr[ETH_ALEN];
120 int num_sta; /* number of entries in sta_list */
121 struct sta_info *sta_list; /* STA info list head */
122 struct sta_info *sta_hash[STA_HASH_SIZE];
124 /* pointers to STA info; based on allocated AID or NULL if AID free
125 * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
126 * and so on
128 struct sta_info *sta_aid[MAX_AID_TABLE_SIZE];
130 struct driver_ops *driver;
132 u8 *default_wep_key;
133 u8 default_wep_key_idx;
135 struct radius_client_data *radius;
136 int radius_client_reconfigured;
137 u32 acct_session_id_hi, acct_session_id_lo;
139 struct iapp_data *iapp;
141 enum { DO_NOT_ASSOC = 0, WAIT_BEACON, AUTHENTICATE, ASSOCIATE,
142 ASSOCIATED } assoc_ap_state;
143 char assoc_ap_ssid[33];
144 int assoc_ap_ssid_len;
145 u16 assoc_ap_aid;
147 struct hostapd_cached_radius_acl *acl_cache;
148 struct hostapd_acl_query_data *acl_queries;
150 struct wpa_authenticator *wpa_auth;
152 struct rsn_preauth_interface *preauth_iface;
153 time_t michael_mic_failure;
154 int michael_mic_failures;
155 int tkip_countermeasures;
157 int ctrl_sock;
158 struct wpa_ctrl_dst *ctrl_dst;
160 void *ssl_ctx;
161 void *eap_sim_db_priv;
162 struct radius_server_data *radius_srv;
164 int parameter_set_count;
166 #ifdef CONFIG_FULL_DYNAMIC_VLAN
167 struct full_dynamic_vlan *full_dynamic_vlan;
168 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
173 * hostapd_iface_cb - Generic callback type for per-iface asynchronous requests
174 * @iface: the interface the event occured on.
175 * @status: 0 if the request succeeded; -1 if the request failed.
177 typedef void (*hostapd_iface_cb)(struct hostapd_iface *iface, int status);
180 struct hostapd_config_change;
183 * struct hostapd_iface - hostapd per-interface data structure
185 struct hostapd_iface {
186 char *config_fname;
187 struct hostapd_config *conf;
189 hostapd_iface_cb setup_cb;
191 size_t num_bss;
192 struct hostapd_data **bss;
194 int num_ap; /* number of entries in ap_list */
195 struct ap_info *ap_list; /* AP info list head */
196 struct ap_info *ap_hash[STA_HASH_SIZE];
197 struct ap_info *ap_iter_list;
199 struct hostapd_hw_modes *hw_features;
200 int num_hw_features;
201 struct hostapd_hw_modes *current_mode;
202 /* Rates that are currently used (i.e., filtered copy of
203 * current_mode->channels */
204 int num_rates;
205 struct hostapd_rate_data *current_rates;
206 hostapd_iface_cb hw_mode_sel_cb;
208 u16 hw_flags;
210 /* Number of associated Non-ERP stations (i.e., stations using 802.11b
211 * in 802.11g BSS) */
212 int num_sta_non_erp;
214 /* Number of associated stations that do not support Short Slot Time */
215 int num_sta_no_short_slot_time;
217 /* Number of associated stations that do not support Short Preamble */
218 int num_sta_no_short_preamble;
220 int olbc; /* Overlapping Legacy BSS Condition */
222 int dfs_enable;
223 u8 pwr_const;
224 unsigned int tx_power;
225 unsigned int sta_max_power;
227 unsigned int channel_switch;
229 struct hostapd_config_change *change;
230 hostapd_iface_cb reload_iface_cb;
231 hostapd_iface_cb config_reload_cb;
234 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
235 int reassoc);
236 void hostapd_logger(struct hostapd_data *hapd, const u8 *addr,
237 unsigned int module, int level, const char *fmt,
238 ...) PRINTF_FORMAT(5, 6);
241 #ifndef _MSC_VER
242 #define HOSTAPD_DEBUG(level, args...) \
243 do { \
244 if (hapd->conf == NULL || hapd->conf->debug >= (level)) \
245 printf(args); \
246 } while (0)
247 #endif /* _MSC_VER */
249 #define HOSTAPD_DEBUG_COND(level) (hapd->conf->debug >= (level))
251 const char * hostapd_ip_txt(const struct hostapd_ip_addr *addr, char *buf,
252 size_t buflen);
253 int hostapd_ip_diff(struct hostapd_ip_addr *a, struct hostapd_ip_addr *b);
255 #endif /* HOSTAPD_H */