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

Generated on Sat Nov 28 23:07:46 2009 for wpa_supplicant/hostapd by  doxygen 1.6.1