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 "wpa_common.h"
00021 
00022 #ifndef BIT
00023 #define BIT(n) (1 << (n))
00024 #endif
00025 
00026 #define WPA_CAPABILITY_PREAUTH BIT(0)
00027 #define WPA_CAPABILITY_MGMT_FRAME_PROTECTION BIT(6)
00028 #define WPA_CAPABILITY_PEERKEY_ENABLED BIT(9)
00029 
00030 #define GENERIC_INFO_ELEM 0xdd
00031 #define RSN_INFO_ELEM 0x30
00032 
00033 enum {
00034         REASON_UNSPECIFIED = 1,
00035         REASON_DEAUTH_LEAVING = 3,
00036         REASON_INVALID_IE = 13,
00037         REASON_MICHAEL_MIC_FAILURE = 14,
00038         REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
00039         REASON_GROUP_KEY_UPDATE_TIMEOUT = 16,
00040         REASON_IE_IN_4WAY_DIFFERS = 17,
00041         REASON_GROUP_CIPHER_NOT_VALID = 18,
00042         REASON_PAIRWISE_CIPHER_NOT_VALID = 19,
00043         REASON_AKMP_NOT_VALID = 20,
00044         REASON_UNSUPPORTED_RSN_IE_VERSION = 21,
00045         REASON_INVALID_RSN_IE_CAPAB = 22,
00046         REASON_IEEE_802_1X_AUTH_FAILED = 23,
00047         REASON_CIPHER_SUITE_REJECTED = 24
00048 };
00049 
00050 #define PMKID_LEN 16
00051 
00052 
00053 struct wpa_sm;
00054 struct wpa_ssid;
00055 struct eapol_sm;
00056 struct wpa_config_blob;
00057 
00058 struct wpa_sm_ctx {
00059         void *ctx; /* pointer to arbitrary upper level context */
00060 
00061         void (*set_state)(void *ctx, wpa_states state);
00062         wpa_states (*get_state)(void *ctx);
00063         void (*req_scan)(void *ctx, int sec, int usec);
00064         void (*deauthenticate)(void * ctx, int reason_code); 
00065         void (*disassociate)(void *ctx, int reason_code);
00066         int (*set_key)(void *ctx, wpa_alg alg,
00067                        const u8 *addr, int key_idx, int set_tx,
00068                        const u8 *seq, size_t seq_len,
00069                        const u8 *key, size_t key_len);
00070         void (*scan)(void *eloop_ctx, void *timeout_ctx);
00071         struct wpa_ssid * (*get_ssid)(void *ctx);
00072         int (*get_bssid)(void *ctx, u8 *bssid);
00073         int (*ether_send)(void *ctx, const u8 *dest, u16 proto, const u8 *buf,
00074                           size_t len);
00075         int (*get_beacon_ie)(void *ctx);
00076         void (*cancel_auth_timeout)(void *ctx);
00077         u8 * (*alloc_eapol)(void *ctx, u8 type, const void *data, u16 data_len,
00078                             size_t *msg_len, void **data_pos);
00079         int (*add_pmkid)(void *ctx, const u8 *bssid, const u8 *pmkid);
00080         int (*remove_pmkid)(void *ctx, const u8 *bssid, const u8 *pmkid);
00081         void (*set_config_blob)(void *ctx, struct wpa_config_blob *blob);
00082         const struct wpa_config_blob * (*get_config_blob)(void *ctx,
00083                                                           const char *name);
00084         int (*mlme_setprotection)(void *ctx, const u8 *addr,
00085                                   int protection_type, int key_type);
00086 };
00087 
00088 
00089 enum wpa_sm_conf_params {
00090         RSNA_PMK_LIFETIME /* dot11RSNAConfigPMKLifetime */,
00091         RSNA_PMK_REAUTH_THRESHOLD /* dot11RSNAConfigPMKReauthThreshold */,
00092         RSNA_SA_TIMEOUT /* dot11RSNAConfigSATimeout */,
00093         WPA_PARAM_PROTO,
00094         WPA_PARAM_PAIRWISE,
00095         WPA_PARAM_GROUP,
00096         WPA_PARAM_KEY_MGMT,
00097         WPA_PARAM_MGMT_GROUP
00098 };
00099 
00100 struct wpa_ie_data {
00101         int proto;
00102         int pairwise_cipher;
00103         int group_cipher;
00104         int key_mgmt;
00105         int capabilities;
00106         int num_pmkid;
00107         const u8 *pmkid;
00108         int mgmt_group_cipher;
00109 };
00110 
00111 #ifndef CONFIG_NO_WPA
00112 
00113 struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx);
00114 void wpa_sm_deinit(struct wpa_sm *sm);
00115 void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid);
00116 void wpa_sm_notify_disassoc(struct wpa_sm *sm);
00117 void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk, size_t pmk_len);
00118 void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm);
00119 void wpa_sm_set_fast_reauth(struct wpa_sm *sm, int fast_reauth);
00120 void wpa_sm_set_scard_ctx(struct wpa_sm *sm, void *scard_ctx);
00121 void wpa_sm_set_config(struct wpa_sm *sm, struct wpa_ssid *config);
00122 void wpa_sm_set_own_addr(struct wpa_sm *sm, const u8 *addr);
00123 void wpa_sm_set_ifname(struct wpa_sm *sm, const char *ifname,
00124                        const char *bridge_ifname);
00125 void wpa_sm_set_eapol(struct wpa_sm *sm, struct eapol_sm *eapol);
00126 int wpa_sm_set_assoc_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len);
00127 int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm *sm, u8 *wpa_ie,
00128                                     size_t *wpa_ie_len);
00129 int wpa_sm_set_ap_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len);
00130 int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie, size_t len);
00131 int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen);
00132 
00133 int wpa_sm_set_param(struct wpa_sm *sm, enum wpa_sm_conf_params param,
00134                      unsigned int value);
00135 unsigned int wpa_sm_get_param(struct wpa_sm *sm,
00136                               enum wpa_sm_conf_params param);
00137 
00138 int wpa_sm_get_status(struct wpa_sm *sm, char *buf, size_t buflen,
00139                       int verbose);
00140 
00141 void wpa_sm_key_request(struct wpa_sm *sm, int error, int pairwise);
00142 
00143 int wpa_sm_stkstart(struct wpa_sm *sm, const u8 *peer);
00144 
00145 int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len,
00146                      struct wpa_ie_data *data);
00147 
00148 void wpa_sm_aborted_cached(struct wpa_sm *sm);
00149 int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr,
00150                     const u8 *buf, size_t len);
00151 int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm, struct wpa_ie_data *data);
00152 
00153 #else /* CONFIG_NO_WPA */
00154 
00155 static inline struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx)
00156 {
00157         return (struct wpa_sm *) 1;
00158 }
00159 
00160 static inline void wpa_sm_deinit(struct wpa_sm *sm)
00161 {
00162 }
00163 
00164 static inline void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
00165 {
00166 }
00167 
00168 static inline void wpa_sm_notify_disassoc(struct wpa_sm *sm)
00169 {
00170 }
00171 
00172 static inline void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk,
00173                                   size_t pmk_len)
00174 {
00175 }
00176 
00177 static inline void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm)
00178 {
00179 }
00180 
00181 static inline void wpa_sm_set_fast_reauth(struct wpa_sm *sm, int fast_reauth)
00182 {
00183 }
00184 
00185 static inline void wpa_sm_set_scard_ctx(struct wpa_sm *sm, void *scard_ctx)
00186 {
00187 }
00188 
00189 static inline void wpa_sm_set_config(struct wpa_sm *sm,
00190                                      struct wpa_ssid *config)
00191 {
00192 }
00193 
00194 static inline void wpa_sm_set_own_addr(struct wpa_sm *sm, const u8 *addr)
00195 {
00196 }
00197 
00198 static inline void wpa_sm_set_ifname(struct wpa_sm *sm, const char *ifname,
00199                                      const char *bridge_ifname)
00200 {
00201 }
00202 
00203 static inline void wpa_sm_set_eapol(struct wpa_sm *sm, struct eapol_sm *eapol)
00204 {
00205 }
00206 
00207 static inline int wpa_sm_set_assoc_wpa_ie(struct wpa_sm *sm, const u8 *ie,
00208                                           size_t len)
00209 {
00210         return -1;
00211 }
00212 
00213 static inline int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm *sm,
00214                                                   u8 *wpa_ie,
00215                                                   size_t *wpa_ie_len)
00216 {
00217         return -1;
00218 }
00219 
00220 static inline int wpa_sm_set_ap_wpa_ie(struct wpa_sm *sm, const u8 *ie,
00221                                        size_t len)
00222 {
00223         return -1;
00224 }
00225 
00226 static inline int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie,
00227                                        size_t len)
00228 {
00229         return -1;
00230 }
00231 
00232 static inline int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen)
00233 {
00234         return 0;
00235 }
00236 
00237 static inline int wpa_sm_set_param(struct wpa_sm *sm,
00238                                    enum wpa_sm_conf_params param,
00239                                    unsigned int value)
00240 {
00241         return -1;
00242 }
00243 
00244 static inline unsigned int wpa_sm_get_param(struct wpa_sm *sm,
00245                                             enum wpa_sm_conf_params param)
00246 {
00247         return 0;
00248 }
00249 
00250 static inline int wpa_sm_get_status(struct wpa_sm *sm, char *buf,
00251                                     size_t buflen, int verbose)
00252 {
00253         return 0;
00254 }
00255 
00256 static inline void wpa_sm_key_request(struct wpa_sm *sm, int error,
00257                                       int pairwise)
00258 {
00259 }
00260 
00261 static inline int wpa_sm_stkstart(struct wpa_sm *sm, const u8 *peer)
00262 {
00263         return -1;
00264 }
00265 
00266 static inline int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len,
00267                                    struct wpa_ie_data *data)
00268 {
00269         return -1;
00270 }
00271 
00272 static inline void wpa_sm_aborted_cached(struct wpa_sm *sm)
00273 {
00274 }
00275 
00276 static inline int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr,
00277                                   const u8 *buf, size_t len)
00278 {
00279         return -1;
00280 }
00281 
00282 static inline int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm,
00283                                           struct wpa_ie_data *data)
00284 {
00285         return -1;
00286 }
00287 
00288 #endif /* CONFIG_NO_WPA */
00289 
00290 #endif /* WPA_H */
00291 

Generated on Sun Dec 31 13:48:57 2006 for wpa_supplicant by  doxygen 1.4.2