wpa.h

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

Generated on Sat May 6 21:13:40 2006 for wpa_supplicant by  doxygen 1.4.2