wpa.h

Go to the documentation of this file.
00001 
00016 #ifndef WPA_H
00017 #define WPA_H
00018 
00019 #include "defs.h"
00020 #include "eapol_common.h"
00021 #include "wpa_common.h"
00022 
00023 #ifndef ETH_P_EAPOL
00024 #define ETH_P_EAPOL 0x888e
00025 #endif
00026 
00027 #ifndef ETH_P_RSN_PREAUTH
00028 #define ETH_P_RSN_PREAUTH 0x88c7
00029 #endif
00030 
00031 struct wpa_sm;
00032 struct eapol_sm;
00033 struct wpa_config_blob;
00034 
00035 struct wpa_sm_ctx {
00036         void *ctx; /* pointer to arbitrary upper level context */
00037         void *msg_ctx; /* upper level context for wpa_msg() calls */
00038 
00039         void (*set_state)(void *ctx, wpa_states state);
00040         wpa_states (*get_state)(void *ctx);
00041         void (*deauthenticate)(void * ctx, int reason_code); 
00042         void (*disassociate)(void *ctx, int reason_code);
00043         int (*set_key)(void *ctx, wpa_alg alg,
00044                        const u8 *addr, int key_idx, int set_tx,
00045                        const u8 *seq, size_t seq_len,
00046                        const u8 *key, size_t key_len);
00047         void * (*get_network_ctx)(void *ctx);
00048         int (*get_bssid)(void *ctx, u8 *bssid);
00049         int (*ether_send)(void *ctx, const u8 *dest, u16 proto, const u8 *buf,
00050                           size_t len);
00051         int (*get_beacon_ie)(void *ctx);
00052         void (*cancel_auth_timeout)(void *ctx);
00053         u8 * (*alloc_eapol)(void *ctx, u8 type, const void *data, u16 data_len,
00054                             size_t *msg_len, void **data_pos);
00055         int (*add_pmkid)(void *ctx, const u8 *bssid, const u8 *pmkid);
00056         int (*remove_pmkid)(void *ctx, const u8 *bssid, const u8 *pmkid);
00057         void (*set_config_blob)(void *ctx, struct wpa_config_blob *blob);
00058         const struct wpa_config_blob * (*get_config_blob)(void *ctx,
00059                                                           const char *name);
00060         int (*mlme_setprotection)(void *ctx, const u8 *addr,
00061                                   int protection_type, int key_type);
00062         int (*update_ft_ies)(void *ctx, const u8 *md, const u8 *ies,
00063                              size_t ies_len);
00064         int (*send_ft_action)(void *ctx, u8 action, const u8 *target_ap,
00065                               const u8 *ies, size_t ies_len);
00066 };
00067 
00068 
00069 enum wpa_sm_conf_params {
00070         RSNA_PMK_LIFETIME /* dot11RSNAConfigPMKLifetime */,
00071         RSNA_PMK_REAUTH_THRESHOLD /* dot11RSNAConfigPMKReauthThreshold */,
00072         RSNA_SA_TIMEOUT /* dot11RSNAConfigSATimeout */,
00073         WPA_PARAM_PROTO,
00074         WPA_PARAM_PAIRWISE,
00075         WPA_PARAM_GROUP,
00076         WPA_PARAM_KEY_MGMT,
00077         WPA_PARAM_MGMT_GROUP,
00078         WPA_PARAM_RSN_ENABLED
00079 };
00080 
00081 struct rsn_supp_config {
00082         void *network_ctx;
00083         int peerkey_enabled;
00084         int allowed_pairwise_cipher; /* bitfield of WPA_CIPHER_* */
00085         int proactive_key_caching;
00086         int eap_workaround;
00087         void *eap_conf_ctx;
00088         const u8 *ssid;
00089         size_t ssid_len;
00090         int wpa_ptk_rekey;
00091 };
00092 
00093 #ifndef CONFIG_NO_WPA
00094 
00095 struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx);
00096 void wpa_sm_deinit(struct wpa_sm *sm);
00097 void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid);
00098 void wpa_sm_notify_disassoc(struct wpa_sm *sm);
00099 void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk, size_t pmk_len);
00100 void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm);
00101 void wpa_sm_set_fast_reauth(struct wpa_sm *sm, int fast_reauth);
00102 void wpa_sm_set_scard_ctx(struct wpa_sm *sm, void *scard_ctx);
00103 void wpa_sm_set_config(struct wpa_sm *sm, struct rsn_supp_config *config);
00104 void wpa_sm_set_own_addr(struct wpa_sm *sm, const u8 *addr);
00105 void wpa_sm_set_ifname(struct wpa_sm *sm, const char *ifname,
00106                        const char *bridge_ifname);
00107 void wpa_sm_set_eapol(struct wpa_sm *sm, struct eapol_sm *eapol);
00108 int wpa_sm_set_assoc_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len);
00109 int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm *sm, u8 *wpa_ie,
00110                                     size_t *wpa_ie_len);
00111 int wpa_sm_set_ap_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len);
00112 int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie, size_t len);
00113 int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen);
00114 
00115 int wpa_sm_set_param(struct wpa_sm *sm, enum wpa_sm_conf_params param,
00116                      unsigned int value);
00117 unsigned int wpa_sm_get_param(struct wpa_sm *sm,
00118                               enum wpa_sm_conf_params param);
00119 
00120 int wpa_sm_get_status(struct wpa_sm *sm, char *buf, size_t buflen,
00121                       int verbose);
00122 
00123 void wpa_sm_key_request(struct wpa_sm *sm, int error, int pairwise);
00124 
00125 int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len,
00126                      struct wpa_ie_data *data);
00127 
00128 void wpa_sm_aborted_cached(struct wpa_sm *sm);
00129 int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr,
00130                     const u8 *buf, size_t len);
00131 int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm, struct wpa_ie_data *data);
00132 int wpa_sm_pmksa_cache_list(struct wpa_sm *sm, char *buf, size_t len);
00133 
00134 #else /* CONFIG_NO_WPA */
00135 
00136 static inline struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx)
00137 {
00138         return (struct wpa_sm *) 1;
00139 }
00140 
00141 static inline void wpa_sm_deinit(struct wpa_sm *sm)
00142 {
00143 }
00144 
00145 static inline void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
00146 {
00147 }
00148 
00149 static inline void wpa_sm_notify_disassoc(struct wpa_sm *sm)
00150 {
00151 }
00152 
00153 static inline void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk,
00154                                   size_t pmk_len)
00155 {
00156 }
00157 
00158 static inline void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm)
00159 {
00160 }
00161 
00162 static inline void wpa_sm_set_fast_reauth(struct wpa_sm *sm, int fast_reauth)
00163 {
00164 }
00165 
00166 static inline void wpa_sm_set_scard_ctx(struct wpa_sm *sm, void *scard_ctx)
00167 {
00168 }
00169 
00170 static inline void wpa_sm_set_config(struct wpa_sm *sm,
00171                                      struct rsn_supp_config *config)
00172 {
00173 }
00174 
00175 static inline void wpa_sm_set_own_addr(struct wpa_sm *sm, const u8 *addr)
00176 {
00177 }
00178 
00179 static inline void wpa_sm_set_ifname(struct wpa_sm *sm, const char *ifname,
00180                                      const char *bridge_ifname)
00181 {
00182 }
00183 
00184 static inline void wpa_sm_set_eapol(struct wpa_sm *sm, struct eapol_sm *eapol)
00185 {
00186 }
00187 
00188 static inline int wpa_sm_set_assoc_wpa_ie(struct wpa_sm *sm, const u8 *ie,
00189                                           size_t len)
00190 {
00191         return -1;
00192 }
00193 
00194 static inline int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm *sm,
00195                                                   u8 *wpa_ie,
00196                                                   size_t *wpa_ie_len)
00197 {
00198         return -1;
00199 }
00200 
00201 static inline int wpa_sm_set_ap_wpa_ie(struct wpa_sm *sm, const u8 *ie,
00202                                        size_t len)
00203 {
00204         return -1;
00205 }
00206 
00207 static inline int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie,
00208                                        size_t len)
00209 {
00210         return -1;
00211 }
00212 
00213 static inline int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen)
00214 {
00215         return 0;
00216 }
00217 
00218 static inline int wpa_sm_set_param(struct wpa_sm *sm,
00219                                    enum wpa_sm_conf_params param,
00220                                    unsigned int value)
00221 {
00222         return -1;
00223 }
00224 
00225 static inline unsigned int wpa_sm_get_param(struct wpa_sm *sm,
00226                                             enum wpa_sm_conf_params param)
00227 {
00228         return 0;
00229 }
00230 
00231 static inline int wpa_sm_get_status(struct wpa_sm *sm, char *buf,
00232                                     size_t buflen, int verbose)
00233 {
00234         return 0;
00235 }
00236 
00237 static inline void wpa_sm_key_request(struct wpa_sm *sm, int error,
00238                                       int pairwise)
00239 {
00240 }
00241 
00242 static inline int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len,
00243                                    struct wpa_ie_data *data)
00244 {
00245         return -1;
00246 }
00247 
00248 static inline void wpa_sm_aborted_cached(struct wpa_sm *sm)
00249 {
00250 }
00251 
00252 static inline int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr,
00253                                   const u8 *buf, size_t len)
00254 {
00255         return -1;
00256 }
00257 
00258 static inline int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm,
00259                                           struct wpa_ie_data *data)
00260 {
00261         return -1;
00262 }
00263 
00264 static inline int wpa_sm_pmksa_cache_list(struct wpa_sm *sm, char *buf,
00265                                           size_t len)
00266 {
00267         return -1;
00268 }
00269 
00270 #endif /* CONFIG_NO_WPA */
00271 
00272 #ifdef CONFIG_PEERKEY
00273 int wpa_sm_stkstart(struct wpa_sm *sm, const u8 *peer);
00274 #else /* CONFIG_PEERKEY */
00275 static inline int wpa_sm_stkstart(struct wpa_sm *sm, const u8 *peer)
00276 {
00277         return -1;
00278 }
00279 #endif /* CONFIG_PEERKEY */
00280 
00281 #ifdef CONFIG_IEEE80211R
00282 
00283 int wpa_sm_set_ft_params(struct wpa_sm *sm, const u8 *mobility_domain,
00284                          const u8 *r0kh_id, size_t r0kh_id_len,
00285                          const u8 *r1kh_id);
00286 int wpa_ft_prepare_auth_request(struct wpa_sm *sm);
00287 int wpa_ft_process_response(struct wpa_sm *sm, const u8 *ies, size_t ies_len,
00288                             int ft_action, const u8 *target_ap,
00289                             const u8 *ric_ies, size_t ric_ies_len);
00290 int wpa_ft_is_completed(struct wpa_sm *sm);
00291 int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
00292                                  size_t ies_len, const u8 *src_addr);
00293 int wpa_ft_start_over_ds(struct wpa_sm *sm, const u8 *target_ap);
00294 
00295 #else /* CONFIG_IEEE80211R */
00296 
00297 static inline int
00298 wpa_sm_set_ft_params(struct wpa_sm *sm, const u8 *mobility_domain,
00299                      const u8 *r0kh_id, const u8 *r1kh_id)
00300 {
00301         return 0;
00302 }
00303 
00304 static inline int wpa_ft_prepare_auth_request(struct wpa_sm *sm)
00305 {
00306         return 0;
00307 }
00308 
00309 static inline int
00310 wpa_ft_process_response(struct wpa_sm *sm, const u8 *ies, size_t ies_len,
00311                         int ft_action, const u8 *target_ap)
00312 {
00313         return 0;
00314 }
00315 
00316 static inline int wpa_ft_is_completed(struct wpa_sm *sm)
00317 {
00318         return 0;
00319 }
00320 
00321 static inline int
00322 wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies, size_t ies_len,
00323                              const u8 *src_addr)
00324 {
00325         return -1;
00326 }
00327 
00328 #endif /* CONFIG_IEEE80211R */
00329 
00330 #endif /* WPA_H */
00331 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on Sat Nov 21 23:16:49 2009 for hostapd by  doxygen 1.6.1