139beb93cSSam Leffler /* 239beb93cSSam Leffler * wpa_supplicant - WPA definitions 339beb93cSSam Leffler * Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi> 439beb93cSSam Leffler * 539beb93cSSam Leffler * This program is free software; you can redistribute it and/or modify 639beb93cSSam Leffler * it under the terms of the GNU General Public License version 2 as 739beb93cSSam Leffler * published by the Free Software Foundation. 839beb93cSSam Leffler * 939beb93cSSam Leffler * Alternatively, this software may be distributed under the terms of BSD 1039beb93cSSam Leffler * license. 1139beb93cSSam Leffler * 1239beb93cSSam Leffler * See README and COPYING for more details. 1339beb93cSSam Leffler */ 1439beb93cSSam Leffler 1539beb93cSSam Leffler #ifndef WPA_H 1639beb93cSSam Leffler #define WPA_H 1739beb93cSSam Leffler 1839beb93cSSam Leffler #include "defs.h" 1939beb93cSSam Leffler #include "eapol_common.h" 2039beb93cSSam Leffler #include "wpa_common.h" 2139beb93cSSam Leffler 2239beb93cSSam Leffler #ifndef ETH_P_EAPOL 2339beb93cSSam Leffler #define ETH_P_EAPOL 0x888e 2439beb93cSSam Leffler #endif 2539beb93cSSam Leffler 2639beb93cSSam Leffler #ifndef ETH_P_RSN_PREAUTH 2739beb93cSSam Leffler #define ETH_P_RSN_PREAUTH 0x88c7 2839beb93cSSam Leffler #endif 2939beb93cSSam Leffler 3039beb93cSSam Leffler struct wpa_sm; 3139beb93cSSam Leffler struct eapol_sm; 3239beb93cSSam Leffler struct wpa_config_blob; 3339beb93cSSam Leffler 3439beb93cSSam Leffler struct wpa_sm_ctx { 3539beb93cSSam Leffler void *ctx; /* pointer to arbitrary upper level context */ 3639beb93cSSam Leffler 3739beb93cSSam Leffler void (*set_state)(void *ctx, wpa_states state); 3839beb93cSSam Leffler wpa_states (*get_state)(void *ctx); 3939beb93cSSam Leffler void (*deauthenticate)(void * ctx, int reason_code); 4039beb93cSSam Leffler void (*disassociate)(void *ctx, int reason_code); 4139beb93cSSam Leffler int (*set_key)(void *ctx, wpa_alg alg, 4239beb93cSSam Leffler const u8 *addr, int key_idx, int set_tx, 4339beb93cSSam Leffler const u8 *seq, size_t seq_len, 4439beb93cSSam Leffler const u8 *key, size_t key_len); 4539beb93cSSam Leffler void * (*get_network_ctx)(void *ctx); 4639beb93cSSam Leffler int (*get_bssid)(void *ctx, u8 *bssid); 4739beb93cSSam Leffler int (*ether_send)(void *ctx, const u8 *dest, u16 proto, const u8 *buf, 4839beb93cSSam Leffler size_t len); 4939beb93cSSam Leffler int (*get_beacon_ie)(void *ctx); 5039beb93cSSam Leffler void (*cancel_auth_timeout)(void *ctx); 5139beb93cSSam Leffler u8 * (*alloc_eapol)(void *ctx, u8 type, const void *data, u16 data_len, 5239beb93cSSam Leffler size_t *msg_len, void **data_pos); 5339beb93cSSam Leffler int (*add_pmkid)(void *ctx, const u8 *bssid, const u8 *pmkid); 5439beb93cSSam Leffler int (*remove_pmkid)(void *ctx, const u8 *bssid, const u8 *pmkid); 5539beb93cSSam Leffler void (*set_config_blob)(void *ctx, struct wpa_config_blob *blob); 5639beb93cSSam Leffler const struct wpa_config_blob * (*get_config_blob)(void *ctx, 5739beb93cSSam Leffler const char *name); 5839beb93cSSam Leffler int (*mlme_setprotection)(void *ctx, const u8 *addr, 5939beb93cSSam Leffler int protection_type, int key_type); 6039beb93cSSam Leffler int (*update_ft_ies)(void *ctx, const u8 *md, const u8 *ies, 6139beb93cSSam Leffler size_t ies_len); 6239beb93cSSam Leffler int (*send_ft_action)(void *ctx, u8 action, const u8 *target_ap, 6339beb93cSSam Leffler const u8 *ies, size_t ies_len); 6439beb93cSSam Leffler }; 6539beb93cSSam Leffler 6639beb93cSSam Leffler 6739beb93cSSam Leffler enum wpa_sm_conf_params { 6839beb93cSSam Leffler RSNA_PMK_LIFETIME /* dot11RSNAConfigPMKLifetime */, 6939beb93cSSam Leffler RSNA_PMK_REAUTH_THRESHOLD /* dot11RSNAConfigPMKReauthThreshold */, 7039beb93cSSam Leffler RSNA_SA_TIMEOUT /* dot11RSNAConfigSATimeout */, 7139beb93cSSam Leffler WPA_PARAM_PROTO, 7239beb93cSSam Leffler WPA_PARAM_PAIRWISE, 7339beb93cSSam Leffler WPA_PARAM_GROUP, 7439beb93cSSam Leffler WPA_PARAM_KEY_MGMT, 7539beb93cSSam Leffler WPA_PARAM_MGMT_GROUP, 7639beb93cSSam Leffler WPA_PARAM_RSN_ENABLED 7739beb93cSSam Leffler }; 7839beb93cSSam Leffler 7939beb93cSSam Leffler struct rsn_supp_config { 8039beb93cSSam Leffler void *network_ctx; 8139beb93cSSam Leffler int peerkey_enabled; 8239beb93cSSam Leffler int allowed_pairwise_cipher; /* bitfield of WPA_CIPHER_* */ 8339beb93cSSam Leffler int proactive_key_caching; 8439beb93cSSam Leffler int eap_workaround; 8539beb93cSSam Leffler void *eap_conf_ctx; 8639beb93cSSam Leffler const u8 *ssid; 8739beb93cSSam Leffler size_t ssid_len; 8839beb93cSSam Leffler int wpa_ptk_rekey; 8939beb93cSSam Leffler }; 9039beb93cSSam Leffler 9139beb93cSSam Leffler #ifndef CONFIG_NO_WPA 9239beb93cSSam Leffler 9339beb93cSSam Leffler struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx); 9439beb93cSSam Leffler void wpa_sm_deinit(struct wpa_sm *sm); 9539beb93cSSam Leffler void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid); 9639beb93cSSam Leffler void wpa_sm_notify_disassoc(struct wpa_sm *sm); 9739beb93cSSam Leffler void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk, size_t pmk_len); 9839beb93cSSam Leffler void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm); 9939beb93cSSam Leffler void wpa_sm_set_fast_reauth(struct wpa_sm *sm, int fast_reauth); 10039beb93cSSam Leffler void wpa_sm_set_scard_ctx(struct wpa_sm *sm, void *scard_ctx); 10139beb93cSSam Leffler void wpa_sm_set_config(struct wpa_sm *sm, struct rsn_supp_config *config); 10239beb93cSSam Leffler void wpa_sm_set_own_addr(struct wpa_sm *sm, const u8 *addr); 10339beb93cSSam Leffler void wpa_sm_set_ifname(struct wpa_sm *sm, const char *ifname, 10439beb93cSSam Leffler const char *bridge_ifname); 10539beb93cSSam Leffler void wpa_sm_set_eapol(struct wpa_sm *sm, struct eapol_sm *eapol); 10639beb93cSSam Leffler int wpa_sm_set_assoc_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len); 10739beb93cSSam Leffler int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm *sm, u8 *wpa_ie, 10839beb93cSSam Leffler size_t *wpa_ie_len); 10939beb93cSSam Leffler int wpa_sm_set_ap_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len); 11039beb93cSSam Leffler int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie, size_t len); 11139beb93cSSam Leffler int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen); 11239beb93cSSam Leffler 11339beb93cSSam Leffler int wpa_sm_set_param(struct wpa_sm *sm, enum wpa_sm_conf_params param, 11439beb93cSSam Leffler unsigned int value); 11539beb93cSSam Leffler unsigned int wpa_sm_get_param(struct wpa_sm *sm, 11639beb93cSSam Leffler enum wpa_sm_conf_params param); 11739beb93cSSam Leffler 11839beb93cSSam Leffler int wpa_sm_get_status(struct wpa_sm *sm, char *buf, size_t buflen, 11939beb93cSSam Leffler int verbose); 12039beb93cSSam Leffler 12139beb93cSSam Leffler void wpa_sm_key_request(struct wpa_sm *sm, int error, int pairwise); 12239beb93cSSam Leffler 12339beb93cSSam Leffler int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len, 12439beb93cSSam Leffler struct wpa_ie_data *data); 12539beb93cSSam Leffler 12639beb93cSSam Leffler void wpa_sm_aborted_cached(struct wpa_sm *sm); 12739beb93cSSam Leffler int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr, 12839beb93cSSam Leffler const u8 *buf, size_t len); 12939beb93cSSam Leffler int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm, struct wpa_ie_data *data); 13039beb93cSSam Leffler 13139beb93cSSam Leffler #else /* CONFIG_NO_WPA */ 13239beb93cSSam Leffler 13339beb93cSSam Leffler static inline struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx) 13439beb93cSSam Leffler { 13539beb93cSSam Leffler return (struct wpa_sm *) 1; 13639beb93cSSam Leffler } 13739beb93cSSam Leffler 13839beb93cSSam Leffler static inline void wpa_sm_deinit(struct wpa_sm *sm) 13939beb93cSSam Leffler { 14039beb93cSSam Leffler } 14139beb93cSSam Leffler 14239beb93cSSam Leffler static inline void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid) 14339beb93cSSam Leffler { 14439beb93cSSam Leffler } 14539beb93cSSam Leffler 14639beb93cSSam Leffler static inline void wpa_sm_notify_disassoc(struct wpa_sm *sm) 14739beb93cSSam Leffler { 14839beb93cSSam Leffler } 14939beb93cSSam Leffler 15039beb93cSSam Leffler static inline void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk, 15139beb93cSSam Leffler size_t pmk_len) 15239beb93cSSam Leffler { 15339beb93cSSam Leffler } 15439beb93cSSam Leffler 15539beb93cSSam Leffler static inline void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm) 15639beb93cSSam Leffler { 15739beb93cSSam Leffler } 15839beb93cSSam Leffler 15939beb93cSSam Leffler static inline void wpa_sm_set_fast_reauth(struct wpa_sm *sm, int fast_reauth) 16039beb93cSSam Leffler { 16139beb93cSSam Leffler } 16239beb93cSSam Leffler 16339beb93cSSam Leffler static inline void wpa_sm_set_scard_ctx(struct wpa_sm *sm, void *scard_ctx) 16439beb93cSSam Leffler { 16539beb93cSSam Leffler } 16639beb93cSSam Leffler 16739beb93cSSam Leffler static inline void wpa_sm_set_config(struct wpa_sm *sm, 16839beb93cSSam Leffler struct rsn_supp_config *config) 16939beb93cSSam Leffler { 17039beb93cSSam Leffler } 17139beb93cSSam Leffler 17239beb93cSSam Leffler static inline void wpa_sm_set_own_addr(struct wpa_sm *sm, const u8 *addr) 17339beb93cSSam Leffler { 17439beb93cSSam Leffler } 17539beb93cSSam Leffler 17639beb93cSSam Leffler static inline void wpa_sm_set_ifname(struct wpa_sm *sm, const char *ifname, 17739beb93cSSam Leffler const char *bridge_ifname) 17839beb93cSSam Leffler { 17939beb93cSSam Leffler } 18039beb93cSSam Leffler 18139beb93cSSam Leffler static inline void wpa_sm_set_eapol(struct wpa_sm *sm, struct eapol_sm *eapol) 18239beb93cSSam Leffler { 18339beb93cSSam Leffler } 18439beb93cSSam Leffler 18539beb93cSSam Leffler static inline int wpa_sm_set_assoc_wpa_ie(struct wpa_sm *sm, const u8 *ie, 18639beb93cSSam Leffler size_t len) 18739beb93cSSam Leffler { 18839beb93cSSam Leffler return -1; 18939beb93cSSam Leffler } 19039beb93cSSam Leffler 19139beb93cSSam Leffler static inline int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm *sm, 19239beb93cSSam Leffler u8 *wpa_ie, 19339beb93cSSam Leffler size_t *wpa_ie_len) 19439beb93cSSam Leffler { 19539beb93cSSam Leffler return -1; 19639beb93cSSam Leffler } 19739beb93cSSam Leffler 19839beb93cSSam Leffler static inline int wpa_sm_set_ap_wpa_ie(struct wpa_sm *sm, const u8 *ie, 19939beb93cSSam Leffler size_t len) 20039beb93cSSam Leffler { 20139beb93cSSam Leffler return -1; 20239beb93cSSam Leffler } 20339beb93cSSam Leffler 20439beb93cSSam Leffler static inline int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie, 20539beb93cSSam Leffler size_t len) 20639beb93cSSam Leffler { 20739beb93cSSam Leffler return -1; 20839beb93cSSam Leffler } 20939beb93cSSam Leffler 21039beb93cSSam Leffler static inline int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen) 21139beb93cSSam Leffler { 21239beb93cSSam Leffler return 0; 21339beb93cSSam Leffler } 21439beb93cSSam Leffler 21539beb93cSSam Leffler static inline int wpa_sm_set_param(struct wpa_sm *sm, 21639beb93cSSam Leffler enum wpa_sm_conf_params param, 21739beb93cSSam Leffler unsigned int value) 21839beb93cSSam Leffler { 21939beb93cSSam Leffler return -1; 22039beb93cSSam Leffler } 22139beb93cSSam Leffler 22239beb93cSSam Leffler static inline unsigned int wpa_sm_get_param(struct wpa_sm *sm, 22339beb93cSSam Leffler enum wpa_sm_conf_params param) 22439beb93cSSam Leffler { 22539beb93cSSam Leffler return 0; 22639beb93cSSam Leffler } 22739beb93cSSam Leffler 22839beb93cSSam Leffler static inline int wpa_sm_get_status(struct wpa_sm *sm, char *buf, 22939beb93cSSam Leffler size_t buflen, int verbose) 23039beb93cSSam Leffler { 23139beb93cSSam Leffler return 0; 23239beb93cSSam Leffler } 23339beb93cSSam Leffler 23439beb93cSSam Leffler static inline void wpa_sm_key_request(struct wpa_sm *sm, int error, 23539beb93cSSam Leffler int pairwise) 23639beb93cSSam Leffler { 23739beb93cSSam Leffler } 23839beb93cSSam Leffler 23939beb93cSSam Leffler static inline int wpa_parse_wpa_ie(const u8 *wpa_ie, size_t wpa_ie_len, 24039beb93cSSam Leffler struct wpa_ie_data *data) 24139beb93cSSam Leffler { 24239beb93cSSam Leffler return -1; 24339beb93cSSam Leffler } 24439beb93cSSam Leffler 24539beb93cSSam Leffler static inline void wpa_sm_aborted_cached(struct wpa_sm *sm) 24639beb93cSSam Leffler { 24739beb93cSSam Leffler } 24839beb93cSSam Leffler 24939beb93cSSam Leffler static inline int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr, 25039beb93cSSam Leffler const u8 *buf, size_t len) 25139beb93cSSam Leffler { 25239beb93cSSam Leffler return -1; 25339beb93cSSam Leffler } 25439beb93cSSam Leffler 25539beb93cSSam Leffler static inline int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm, 25639beb93cSSam Leffler struct wpa_ie_data *data) 25739beb93cSSam Leffler { 25839beb93cSSam Leffler return -1; 25939beb93cSSam Leffler } 26039beb93cSSam Leffler 26139beb93cSSam Leffler #endif /* CONFIG_NO_WPA */ 26239beb93cSSam Leffler 26339beb93cSSam Leffler #ifdef CONFIG_PEERKEY 26439beb93cSSam Leffler int wpa_sm_stkstart(struct wpa_sm *sm, const u8 *peer); 26539beb93cSSam Leffler #else /* CONFIG_PEERKEY */ 26639beb93cSSam Leffler static inline int wpa_sm_stkstart(struct wpa_sm *sm, const u8 *peer) 26739beb93cSSam Leffler { 26839beb93cSSam Leffler return -1; 26939beb93cSSam Leffler } 27039beb93cSSam Leffler #endif /* CONFIG_PEERKEY */ 27139beb93cSSam Leffler 27239beb93cSSam Leffler #ifdef CONFIG_IEEE80211R 27339beb93cSSam Leffler 27439beb93cSSam Leffler int wpa_sm_set_ft_params(struct wpa_sm *sm, const u8 *mobility_domain, 27539beb93cSSam Leffler const u8 *r0kh_id, size_t r0kh_id_len, 27639beb93cSSam Leffler const u8 *r1kh_id); 27739beb93cSSam Leffler int wpa_ft_prepare_auth_request(struct wpa_sm *sm); 27839beb93cSSam Leffler int wpa_ft_process_response(struct wpa_sm *sm, const u8 *ies, size_t ies_len, 27939beb93cSSam Leffler int ft_action, const u8 *target_ap); 28039beb93cSSam Leffler int wpa_ft_is_completed(struct wpa_sm *sm); 28139beb93cSSam Leffler int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies, 28239beb93cSSam Leffler size_t ies_len, const u8 *src_addr); 28339beb93cSSam Leffler int wpa_ft_start_over_ds(struct wpa_sm *sm, const u8 *target_ap); 28439beb93cSSam Leffler 28539beb93cSSam Leffler #else /* CONFIG_IEEE80211R */ 28639beb93cSSam Leffler 28739beb93cSSam Leffler static inline int 28839beb93cSSam Leffler wpa_sm_set_ft_params(struct wpa_sm *sm, const u8 *mobility_domain, 28939beb93cSSam Leffler const u8 *r0kh_id, const u8 *r1kh_id) 29039beb93cSSam Leffler { 29139beb93cSSam Leffler return 0; 29239beb93cSSam Leffler } 29339beb93cSSam Leffler 29439beb93cSSam Leffler static inline int wpa_ft_prepare_auth_request(struct wpa_sm *sm) 29539beb93cSSam Leffler { 29639beb93cSSam Leffler return 0; 29739beb93cSSam Leffler } 29839beb93cSSam Leffler 29939beb93cSSam Leffler static inline int 30039beb93cSSam Leffler wpa_ft_process_response(struct wpa_sm *sm, const u8 *ies, size_t ies_len, 30139beb93cSSam Leffler int ft_action, const u8 *target_ap) 30239beb93cSSam Leffler { 30339beb93cSSam Leffler return 0; 30439beb93cSSam Leffler } 30539beb93cSSam Leffler 30639beb93cSSam Leffler static inline int wpa_ft_is_completed(struct wpa_sm *sm) 30739beb93cSSam Leffler { 30839beb93cSSam Leffler return 0; 30939beb93cSSam Leffler } 31039beb93cSSam Leffler 31139beb93cSSam Leffler static inline int 31239beb93cSSam Leffler wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies, size_t ies_len, 31339beb93cSSam Leffler const u8 *src_addr) 31439beb93cSSam Leffler { 31539beb93cSSam Leffler return -1; 31639beb93cSSam Leffler } 31739beb93cSSam Leffler 31839beb93cSSam Leffler #endif /* CONFIG_IEEE80211R */ 31939beb93cSSam Leffler 32039beb93cSSam Leffler #endif /* WPA_H */ 321