From 13f6a07efc3e737d8fcb8f7014cb961ce77e64ee Mon Sep 17 00:00:00 2001 From: Naresh Jayaram Date: Fri, 28 Mar 2014 17:01:44 +0200 Subject: [PATCH] Add SIM identifier to the network profile and cred block This allows the specific SIM to be identified for authentication purposes in multi-SIM devices. This SIM number represents the index of the SIM slot. This SIM number shall be used for the authentication using the respective SIM for the Wi-Fi connection to the corresponding network. Signed-off-by: Jouni Malinen --- src/eap_peer/eap_config.h | 8 ++++++++ wpa_supplicant/README-HS20 | 2 ++ wpa_supplicant/config.c | 8 ++++++++ wpa_supplicant/config.h | 8 ++++++++ wpa_supplicant/config_file.c | 5 +++++ wpa_supplicant/config_ssid.h | 1 + wpa_supplicant/interworking.c | 1 + wpa_supplicant/wpa_supplicant.conf | 2 ++ 8 files changed, 35 insertions(+) diff --git a/src/eap_peer/eap_config.h b/src/eap_peer/eap_config.h index 98ec1f7..daa1d32 100644 --- a/src/eap_peer/eap_config.h +++ b/src/eap_peer/eap_config.h @@ -678,6 +678,14 @@ struct eap_peer_config { * SIM/USIM processing. */ char *external_sim_resp; + + /** + * sim_num - User selected SIM identifier + * + * This variable is used for identifying which SIM is used if the system + * has more than one. + */ + int sim_num; }; diff --git a/wpa_supplicant/README-HS20 b/wpa_supplicant/README-HS20 index d0b0b50..58c2475 100644 --- a/wpa_supplicant/README-HS20 +++ b/wpa_supplicant/README-HS20 @@ -270,6 +270,8 @@ Credentials can be pre-configured for automatic network selection: # 1 = try to use OCSP stapling, but not require response # 2 = require valid OCSP stapling response # +# sim_num: Identifier for which SIM to use in multi-SIM devices +# # for example: # #cred={ diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index b4ee1f5..698b459 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -1666,6 +1666,7 @@ static const struct parse_data ssid_fields[] = { { INTe(engine) }, { INTe(engine2) }, { INT(eapol_flags) }, + { INTe(sim_num) }, #endif /* IEEE8021X_EAPOL */ { FUNC_KEY(wep_key0) }, { FUNC_KEY(wep_key1) }, @@ -2154,6 +2155,7 @@ void wpa_config_set_network_defaults(struct wpa_ssid *ssid) ssid->eapol_flags = DEFAULT_EAPOL_FLAGS; ssid->eap_workaround = DEFAULT_EAP_WORKAROUND; ssid->eap.fragment_size = DEFAULT_FRAGMENT_SIZE; + ssid->eap.sim_num = DEFAULT_USER_SELECTED_SIM; #endif /* IEEE8021X_EAPOL */ #ifdef CONFIG_HT_OVERRIDES ssid->disable_ht = DEFAULT_DISABLE_HT; @@ -2572,6 +2574,11 @@ int wpa_config_set_cred(struct wpa_cred *cred, const char *var, return 0; } + if (os_strcmp(var, "sim_num") == 0) { + cred->sim_num = atoi(value); + return 0; + } + val = wpa_config_parse_string(value, &len); if (val == NULL) { wpa_printf(MSG_ERROR, "Line %d: invalid field '%s' string " @@ -3100,6 +3107,7 @@ struct wpa_cred * wpa_config_add_cred(struct wpa_config *config) if (cred == NULL) return NULL; cred->id = id; + cred->sim_num = DEFAULT_USER_SELECTED_SIM; if (last) last->next = cred; else diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index a398049..26b1233 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -288,6 +288,14 @@ struct wpa_cred { * 2 = require valid OCSP stapling response */ int ocsp; + + /** + * sim_num - User selected SIM identifier + * + * This variable is used for identifying which SIM is used if the system + * has more than one. + */ + int sim_num; }; diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index 8f0561a..8d59f49 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -219,6 +219,7 @@ static struct wpa_cred * wpa_config_read_cred(FILE *f, int *line, int id) if (cred == NULL) return NULL; cred->id = id; + cred->sim_num = DEFAULT_USER_SELECTED_SIM; while (wpa_config_get_line(buf, sizeof(buf), f, line, &pos)) { if (os_strcmp(pos, "}") == 0) { @@ -712,6 +713,7 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid) STR(pac_file); INT_DEFe(fragment_size, DEFAULT_FRAGMENT_SIZE); INTe(ocsp); + INT_DEFe(sim_num, DEFAULT_USER_SELECTED_SIM); #endif /* IEEE8021X_EAPOL */ INT(mode); INT(frequency); @@ -858,6 +860,9 @@ static void wpa_config_write_cred(FILE *f, struct wpa_cred *cred) cred->required_roaming_consortium[i]); fprintf(f, "\n"); } + + if (cred->sim_num != DEFAULT_USER_SELECTED_SIM) + fprintf(f, "\tsim_num=%d\n", cred->sim_num); } diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h index a458990..18fb65b 100644 --- a/wpa_supplicant/config_ssid.h +++ b/wpa_supplicant/config_ssid.h @@ -34,6 +34,7 @@ #define DEFAULT_DISABLE_MAX_AMSDU -1 /* no change */ #define DEFAULT_AMPDU_FACTOR -1 /* no change */ #define DEFAULT_AMPDU_DENSITY -1 /* no change */ +#define DEFAULT_USER_SELECTED_SIM 1 struct psk_list_entry { struct dl_list list; diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c index 3450ffe..f46c4cf 100644 --- a/wpa_supplicant/interworking.c +++ b/wpa_supplicant/interworking.c @@ -925,6 +925,7 @@ static int interworking_connect_3gpp(struct wpa_supplicant *wpa_s, goto fail; os_memcpy(ssid->ssid, bss->ssid, bss->ssid_len); ssid->ssid_len = bss->ssid_len; + ssid->eap.sim_num = cred->sim_num; if (interworking_set_hs20_params(wpa_s, ssid) < 0) goto fail; diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf index 86a4621..81fbdfb 100644 --- a/wpa_supplicant/wpa_supplicant.conf +++ b/wpa_supplicant/wpa_supplicant.conf @@ -483,6 +483,8 @@ fast_reauth=1 # 1 = try to use OCSP stapling, but not require response # 2 = require valid OCSP stapling response # +# sim_num: Identifier for which SIM to use in multi-SIM devices +# # for example: # #cred={ -- 2.1.4