Move cipher to enum wpa_cipher conversion into wpa_common.c

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2013-01-13 18:02:20 +02:00
parent cf830c1c54
commit 62769a88db
6 changed files with 28 additions and 26 deletions

View file

@ -1132,6 +1132,26 @@ int wpa_cipher_to_alg(int cipher)
} }
enum wpa_cipher wpa_cipher_to_suite_driver(int cipher)
{
switch (cipher) {
case WPA_CIPHER_NONE:
return CIPHER_NONE;
case WPA_CIPHER_WEP40:
return CIPHER_WEP40;
case WPA_CIPHER_WEP104:
return CIPHER_WEP104;
case WPA_CIPHER_CCMP:
return CIPHER_CCMP;
case WPA_CIPHER_GCMP:
return CIPHER_GCMP;
case WPA_CIPHER_TKIP:
default:
return CIPHER_TKIP;
}
}
int wpa_cipher_valid_pairwise(int cipher) int wpa_cipher_valid_pairwise(int cipher)
{ {
return cipher == WPA_CIPHER_CCMP || return cipher == WPA_CIPHER_CCMP ||

View file

@ -392,6 +392,7 @@ int wpa_ft_parse_ies(const u8 *ies, size_t ies_len, struct wpa_ft_ies *parse);
int wpa_cipher_key_len(int cipher); int wpa_cipher_key_len(int cipher);
int wpa_cipher_rsc_len(int cipher); int wpa_cipher_rsc_len(int cipher);
int wpa_cipher_to_alg(int cipher); int wpa_cipher_to_alg(int cipher);
enum wpa_cipher wpa_cipher_to_suite_driver(int cipher);
int wpa_cipher_valid_pairwise(int cipher); int wpa_cipher_valid_pairwise(int cipher);
u32 wpa_cipher_to_suite(int proto, int cipher); u32 wpa_cipher_to_suite(int proto, int cipher);
int rsn_cipher_put_suites(u8 *pos, int ciphers); int rsn_cipher_put_suites(u8 *pos, int ciphers);

View file

@ -460,7 +460,8 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
"cipher."); "cipher.");
return -1; return -1;
} }
params.pairwise_suite = cipher_suite2driver(wpa_s->pairwise_cipher); params.pairwise_suite =
wpa_cipher_to_suite_driver(wpa_s->pairwise_cipher);
params.group_suite = params.pairwise_suite; params.group_suite = params.pairwise_suite;
#ifdef CONFIG_P2P #ifdef CONFIG_P2P

View file

@ -643,8 +643,9 @@ void sme_associate(struct wpa_supplicant *wpa_s, enum wpas_mode mode,
params.wpa_ie = wpa_s->sme.assoc_req_ie_len ? params.wpa_ie = wpa_s->sme.assoc_req_ie_len ?
wpa_s->sme.assoc_req_ie : NULL; wpa_s->sme.assoc_req_ie : NULL;
params.wpa_ie_len = wpa_s->sme.assoc_req_ie_len; params.wpa_ie_len = wpa_s->sme.assoc_req_ie_len;
params.pairwise_suite = cipher_suite2driver(wpa_s->pairwise_cipher); params.pairwise_suite =
params.group_suite = cipher_suite2driver(wpa_s->group_cipher); wpa_cipher_to_suite_driver(wpa_s->pairwise_cipher);
params.group_suite = wpa_cipher_to_suite_driver(wpa_s->group_cipher);
#ifdef CONFIG_HT_OVERRIDES #ifdef CONFIG_HT_OVERRIDES
os_memset(&htcaps, 0, sizeof(htcaps)); os_memset(&htcaps, 0, sizeof(htcaps));
os_memset(&htcaps_mask, 0, sizeof(htcaps_mask)); os_memset(&htcaps_mask, 0, sizeof(htcaps_mask));

View file

@ -845,26 +845,6 @@ static void wpa_supplicant_reconfig(int sig, void *signal_ctx)
} }
enum wpa_cipher cipher_suite2driver(int cipher)
{
switch (cipher) {
case WPA_CIPHER_NONE:
return CIPHER_NONE;
case WPA_CIPHER_WEP40:
return CIPHER_WEP40;
case WPA_CIPHER_WEP104:
return CIPHER_WEP104;
case WPA_CIPHER_CCMP:
return CIPHER_CCMP;
case WPA_CIPHER_GCMP:
return CIPHER_GCMP;
case WPA_CIPHER_TKIP:
default:
return CIPHER_TKIP;
}
}
enum wpa_key_mgmt key_mgmt2driver(int key_mgmt) enum wpa_key_mgmt key_mgmt2driver(int key_mgmt)
{ {
switch (key_mgmt) { switch (key_mgmt) {
@ -1480,8 +1460,8 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
wpa_clear_keys(wpa_s, bss ? bss->bssid : NULL); wpa_clear_keys(wpa_s, bss ? bss->bssid : NULL);
use_crypt = 1; use_crypt = 1;
cipher_pairwise = cipher_suite2driver(wpa_s->pairwise_cipher); cipher_pairwise = wpa_cipher_to_suite_driver(wpa_s->pairwise_cipher);
cipher_group = cipher_suite2driver(wpa_s->group_cipher); cipher_group = wpa_cipher_to_suite_driver(wpa_s->group_cipher);
if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE || if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) { wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE) if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE)

View file

@ -748,7 +748,6 @@ void wpa_supplicant_terminate_proc(struct wpa_global *global);
void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr, void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
const u8 *buf, size_t len); const u8 *buf, size_t len);
enum wpa_key_mgmt key_mgmt2driver(int key_mgmt); enum wpa_key_mgmt key_mgmt2driver(int key_mgmt);
enum wpa_cipher cipher_suite2driver(int cipher);
void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s); void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s);
void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s); void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s);
void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid); void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid);