eap_proxy: Support multiple SIMs in get_imsi()

This allows the eap_proxy mechanism to be used with multiple SIMs by
following the configured sim_num to index which SIM to use for when
fetching the IMSI through eap_proxy.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Vidyullatha Kanchanapally 2017-06-02 18:38:20 +05:30 committed by Jouni Malinen
parent 0020876514
commit b5db6e5dc4
9 changed files with 16 additions and 14 deletions

View file

@ -482,8 +482,8 @@ static char * eap_get_realm(struct eap_sm *sm, struct eap_peer_config *config)
int mnc_len, pos; int mnc_len, pos;
wpa_printf(MSG_DEBUG, "EAP: Build realm from IMSI (eap_proxy)"); wpa_printf(MSG_DEBUG, "EAP: Build realm from IMSI (eap_proxy)");
mnc_len = sm->eapol_cb->get_imsi(sm->eapol_ctx, imsi, mnc_len = sm->eapol_cb->get_imsi(sm->eapol_ctx, config->sim_num,
&imsi_len); imsi, &imsi_len);
if (mnc_len < 0) if (mnc_len < 0)
return NULL; return NULL;

View file

@ -264,11 +264,12 @@ struct eapol_callbacks {
/** /**
* get_imsi - Get the IMSI value from eap_proxy * get_imsi - Get the IMSI value from eap_proxy
* @ctx: eapol_ctx from eap_peer_sm_init() call * @ctx: eapol_ctx from eap_peer_sm_init() call
* @sim_num: SIM/USIM number to get the IMSI value for
* @imsi: Buffer for IMSI value * @imsi: Buffer for IMSI value
* @len: Buffer for returning IMSI length in octets * @len: Buffer for returning IMSI length in octets
* Returns: MNC length (2 or 3) or -1 on error * Returns: MNC length (2 or 3) or -1 on error
*/ */
int (*get_imsi)(void *ctx, char *imsi, size_t *len); int (*get_imsi)(void *ctx, int sim_num, char *imsi, size_t *len);
#endif /* CONFIG_EAP_PROXY */ #endif /* CONFIG_EAP_PROXY */
/** /**

View file

@ -40,8 +40,8 @@ eap_proxy_packet_update(struct eap_proxy_sm *eap_proxy, u8 *eapReqData,
int eap_proxy_sm_get_status(struct eap_proxy_sm *sm, char *buf, size_t buflen, int eap_proxy_sm_get_status(struct eap_proxy_sm *sm, char *buf, size_t buflen,
int verbose); int verbose);
int eap_proxy_get_imsi(struct eap_proxy_sm *eap_proxy, char *imsi_buf, int eap_proxy_get_imsi(struct eap_proxy_sm *eap_proxy, int sim_num,
size_t *imsi_len); char *imsi_buf, size_t *imsi_len);
int eap_proxy_notify_config(struct eap_proxy_sm *sm, int eap_proxy_notify_config(struct eap_proxy_sm *sm,
struct eap_peer_config *config); struct eap_peer_config *config);

View file

@ -63,8 +63,8 @@ int eap_proxy_sm_get_status(struct eap_proxy_sm *sm, char *buf, size_t buflen,
} }
int eap_proxy_get_imsi(struct eap_proxy_sm *eap_proxy, char *imsi_buf, int eap_proxy_get_imsi(struct eap_proxy_sm *eap_proxy, int sim_num,
size_t *imsi_len) char *imsi_buf, size_t *imsi_len)
{ {
return -1; return -1;
} }

View file

@ -2174,13 +2174,13 @@ int eapol_sm_failed(struct eapol_sm *sm)
#ifdef CONFIG_EAP_PROXY #ifdef CONFIG_EAP_PROXY
int eapol_sm_get_eap_proxy_imsi(void *ctx, char *imsi, size_t *len) int eapol_sm_get_eap_proxy_imsi(void *ctx, int sim_num, char *imsi, size_t *len)
{ {
struct eapol_sm *sm = ctx; struct eapol_sm *sm = ctx;
if (sm->eap_proxy == NULL) if (sm->eap_proxy == NULL)
return -1; return -1;
return eap_proxy_get_imsi(sm->eap_proxy, imsi, len); return eap_proxy_get_imsi(sm->eap_proxy, sim_num, imsi, len);
} }
#endif /* CONFIG_EAP_PROXY */ #endif /* CONFIG_EAP_PROXY */

View file

@ -339,7 +339,8 @@ void eapol_sm_erp_flush(struct eapol_sm *sm);
struct wpabuf * eapol_sm_build_erp_reauth_start(struct eapol_sm *sm); struct wpabuf * eapol_sm_build_erp_reauth_start(struct eapol_sm *sm);
void eapol_sm_process_erp_finish(struct eapol_sm *sm, const u8 *buf, void eapol_sm_process_erp_finish(struct eapol_sm *sm, const u8 *buf,
size_t len); size_t len);
int eapol_sm_get_eap_proxy_imsi(void *ctx, char *imsi, size_t *len); int eapol_sm_get_eap_proxy_imsi(void *ctx, int sim_num, char *imsi,
size_t *len);
int eapol_sm_update_erp_next_seq_num(struct eapol_sm *sm, u16 next_seq_num); int eapol_sm_update_erp_next_seq_num(struct eapol_sm *sm, u16 next_seq_num);
int eapol_sm_get_erp_info(struct eapol_sm *sm, struct eap_peer_config *config, int eapol_sm_get_erp_info(struct eapol_sm *sm, struct eap_peer_config *config,
const u8 **username, size_t *username_len, const u8 **username, size_t *username_len,

View file

@ -1897,7 +1897,7 @@ static struct wpa_cred * interworking_credentials_available_3gpp(
size_t len; size_t len;
wpa_msg(wpa_s, MSG_DEBUG, wpa_msg(wpa_s, MSG_DEBUG,
"Interworking: IMSI not available - try to read again through eap_proxy"); "Interworking: IMSI not available - try to read again through eap_proxy");
wpa_s->mnc_len = eapol_sm_get_eap_proxy_imsi(wpa_s->eapol, wpa_s->mnc_len = eapol_sm_get_eap_proxy_imsi(wpa_s->eapol, -1,
wpa_s->imsi, wpa_s->imsi,
&len); &len);
if (wpa_s->mnc_len > 0) { if (wpa_s->mnc_len > 0) {

View file

@ -5227,8 +5227,8 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s,
#ifdef CONFIG_EAP_PROXY #ifdef CONFIG_EAP_PROXY
{ {
size_t len; size_t len;
wpa_s->mnc_len = eapol_sm_get_eap_proxy_imsi(wpa_s->eapol, wpa_s->imsi, wpa_s->mnc_len = eapol_sm_get_eap_proxy_imsi(wpa_s->eapol, -1,
&len); wpa_s->imsi, &len);
if (wpa_s->mnc_len > 0) { if (wpa_s->mnc_len > 0) {
wpa_s->imsi[len] = '\0'; wpa_s->imsi[len] = '\0';
wpa_printf(MSG_DEBUG, "eap_proxy: IMSI %s (MNC length %d)", wpa_printf(MSG_DEBUG, "eap_proxy: IMSI %s (MNC length %d)",

View file

@ -930,7 +930,7 @@ static void wpa_supplicant_eap_proxy_cb(void *ctx)
struct wpa_supplicant *wpa_s = ctx; struct wpa_supplicant *wpa_s = ctx;
size_t len; size_t len;
wpa_s->mnc_len = eapol_sm_get_eap_proxy_imsi(wpa_s->eapol, wpa_s->mnc_len = eapol_sm_get_eap_proxy_imsi(wpa_s->eapol, -1,
wpa_s->imsi, &len); wpa_s->imsi, &len);
if (wpa_s->mnc_len > 0) { if (wpa_s->mnc_len > 0) {
wpa_s->imsi[len] = '\0'; wpa_s->imsi[len] = '\0';