aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasashi Honma <masashi.honma@gmail.com>2013-11-17 10:17:09 (GMT)
committerJouni Malinen <j@w1.fi>2013-11-17 14:47:38 (GMT)
commit22cf7d7324ee5e75d3baf905123a5554edf36e8b (patch)
tree5da91166977683ccb191ce48129027061a0bd6a5
parentcea97a04f9527f026c3c3570f2c071c459513393 (diff)
downloadhostap-22cf7d7324ee5e75d3baf905123a5554edf36e8b.zip
hostap-22cf7d7324ee5e75d3baf905123a5554edf36e8b.tar.gz
hostap-22cf7d7324ee5e75d3baf905123a5554edf36e8b.tar.bz2
SCARD: Clean up SIM/USIM selection
Commit eb324600295a570199a5e25eb64e60781a04fb74 left an unneeded sim_type argument to scard_init(). Remove that unnecessary argument to clean up the implementation. Signed-hostap: Masashi Honma <masashi.honma@gmail.com>
-rw-r--r--src/utils/pcsc_funcs.c32
-rw-r--r--src/utils/pcsc_funcs.h11
-rw-r--r--wpa_supplicant/eapol_test.c4
-rw-r--r--wpa_supplicant/events.c3
-rw-r--r--wpa_supplicant/wpa_supplicant.c2
5 files changed, 18 insertions, 34 deletions
diff --git a/src/utils/pcsc_funcs.c b/src/utils/pcsc_funcs.c
index 08510d0..ee90d25 100644
--- a/src/utils/pcsc_funcs.c
+++ b/src/utils/pcsc_funcs.c
@@ -485,17 +485,15 @@ static int scard_get_aid(struct scard_data *scard, unsigned char *aid,
/**
* scard_init - Initialize SIM/USIM connection using PC/SC
- * @sim_type: Allowed SIM types (SIM, USIM, or both)
* @reader: Reader name prefix to search for
* Returns: Pointer to private data structure, or %NULL on failure
*
* This function is used to initialize SIM/USIM connection. PC/SC is used to
- * open connection to the SIM/USIM card and the card is verified to support the
- * selected sim_type. In addition, local flag is set if a PIN is needed to
- * access some of the card functions. Once the connection is not needed
- * anymore, scard_deinit() can be used to close it.
+ * open connection to the SIM/USIM card. In addition, local flag is set if a
+ * PIN is needed to access some of the card functions. Once the connection is
+ * not needed anymore, scard_deinit() can be used to close it.
*/
-struct scard_data * scard_init(scard_sim_type sim_type, const char *reader)
+struct scard_data * scard_init(const char *reader)
{
long ret;
unsigned long len, pos;
@@ -612,20 +610,14 @@ struct scard_data * scard_init(scard_sim_type sim_type, const char *reader)
blen = sizeof(buf);
- scard->sim_type = SCARD_GSM_SIM;
- if (sim_type == SCARD_USIM_ONLY || sim_type == SCARD_TRY_BOTH) {
- wpa_printf(MSG_DEBUG, "SCARD: verifying USIM support");
- if (_scard_select_file(scard, SCARD_FILE_MF, buf, &blen,
- SCARD_USIM, NULL, 0)) {
- wpa_printf(MSG_DEBUG, "SCARD: USIM is not supported");
- if (sim_type == SCARD_USIM_ONLY)
- goto failed;
- wpa_printf(MSG_DEBUG, "SCARD: Trying to use GSM SIM");
- scard->sim_type = SCARD_GSM_SIM;
- } else {
- wpa_printf(MSG_DEBUG, "SCARD: USIM is supported");
- scard->sim_type = SCARD_USIM;
- }
+ wpa_printf(MSG_DEBUG, "SCARD: verifying USIM support");
+ if (_scard_select_file(scard, SCARD_FILE_MF, buf, &blen,
+ SCARD_USIM, NULL, 0)) {
+ wpa_printf(MSG_DEBUG, "SCARD: USIM is not supported. Trying to use GSM SIM");
+ scard->sim_type = SCARD_GSM_SIM;
+ } else {
+ wpa_printf(MSG_DEBUG, "SCARD: USIM is supported");
+ scard->sim_type = SCARD_USIM;
}
if (scard->sim_type == SCARD_GSM_SIM) {
diff --git a/src/utils/pcsc_funcs.h b/src/utils/pcsc_funcs.h
index b4ebc99..eacd2a2 100644
--- a/src/utils/pcsc_funcs.h
+++ b/src/utils/pcsc_funcs.h
@@ -9,15 +9,8 @@
#ifndef PCSC_FUNCS_H
#define PCSC_FUNCS_H
-typedef enum {
- SCARD_GSM_SIM_ONLY,
- SCARD_USIM_ONLY,
- SCARD_TRY_BOTH
-} scard_sim_type;
-
-
#ifdef PCSC_FUNCS
-struct scard_data * scard_init(scard_sim_type sim_type, const char *reader);
+struct scard_data * scard_init(const char *reader);
void scard_deinit(struct scard_data *scard);
int scard_set_pin(struct scard_data *scard, const char *pin);
@@ -34,7 +27,7 @@ int scard_supports_umts(struct scard_data *scard);
#else /* PCSC_FUNCS */
-#define scard_init(s, r) NULL
+#define scard_init(r) NULL
#define scard_deinit(s) do { } while (0)
#define scard_set_pin(s, p) -1
#define scard_get_imsi(s, i, l) -1
diff --git a/wpa_supplicant/eapol_test.c b/wpa_supplicant/eapol_test.c
index 9024f23..2b25b69 100644
--- a/wpa_supplicant/eapol_test.c
+++ b/wpa_supplicant/eapol_test.c
@@ -943,7 +943,7 @@ static int scard_test(void)
unsigned char aka_ik[IK_LEN];
unsigned char aka_ck[CK_LEN];
- scard = scard_init(SCARD_TRY_BOTH, NULL);
+ scard = scard_init(NULL);
if (scard == NULL)
return -1;
if (scard_set_pin(scard, "1234")) {
@@ -1043,7 +1043,7 @@ static int scard_get_triplets(int argc, char *argv[])
wpa_debug_level = 99;
}
- scard = scard_init(SCARD_GSM_SIM_ONLY, NULL);
+ scard = scard_init(NULL);
if (scard == NULL) {
printf("Failed to open smartcard connection\n");
return -1;
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 904b533..44e6be3 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -314,8 +314,7 @@ int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is configured to use SIM "
"(sim=%d aka=%d) - initialize PCSC", sim, aka);
- wpa_s->scard = scard_init((!sim && aka) ? SCARD_USIM_ONLY :
- SCARD_TRY_BOTH, NULL);
+ wpa_s->scard = scard_init(NULL);
if (wpa_s->scard == NULL) {
wpa_msg(wpa_s, MSG_WARNING, "Failed to initialize SIM "
"(pcsc-lite)");
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 4388ad6..55cc3d3 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -2753,7 +2753,7 @@ static int pcsc_reader_init(struct wpa_supplicant *wpa_s)
if (!wpa_s->conf->pcsc_reader)
return 0;
- wpa_s->scard = scard_init(SCARD_TRY_BOTH, wpa_s->conf->pcsc_reader);
+ wpa_s->scard = scard_init(wpa_s->conf->pcsc_reader);
if (!wpa_s->scard)
return 1;