eap_proxy: Callback to notify any updates from eap_proxy
authorSunil Dutt <usdutt@qti.qualcomm.com>
Thu, 26 Feb 2015 10:24:37 +0000 (15:54 +0530)
committerJouni Malinen <j@w1.fi>
Mon, 2 Mar 2015 10:47:20 +0000 (12:47 +0200)
This commit introduces a callback to notify any configuration updates
from the eap_proxy layer. This is used to trigger re-reading of IMSI and
MNC length.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/eap_peer/eap.h
src/eapol_supp/eapol_supp_sm.c
src/eapol_supp/eapol_supp_sm.h
wpa_supplicant/wpas_glue.c

index 8c4a42f..702463b 100644 (file)
@@ -246,6 +246,14 @@ struct eapol_callbacks {
        void (*notify_status)(void *ctx, const char *status,
                              const char *parameter);
 
+#ifdef CONFIG_EAP_PROXY
+       /**
+        * eap_proxy_cb - Callback signifying any updates from eap_proxy
+        * @ctx: eapol_ctx from eap_peer_sm_init() call
+        */
+       void (*eap_proxy_cb)(void *ctx);
+#endif /* CONFIG_EAP_PROXY */
+
        /**
         * set_anon_id - Set or add anonymous identity
         * @ctx: eapol_ctx from eap_peer_sm_init() call
index f615051..9cc234a 100644 (file)
@@ -1977,6 +1977,17 @@ static void eapol_sm_notify_status(void *ctx, const char *status,
 }
 
 
+#ifdef CONFIG_EAP_PROXY
+static void eapol_sm_eap_proxy_cb(void *ctx)
+{
+       struct eapol_sm *sm = ctx;
+
+       if (sm->ctx->eap_proxy_cb)
+               sm->ctx->eap_proxy_cb(sm->ctx->ctx);
+}
+#endif /* CONFIG_EAP_PROXY */
+
+
 static void eapol_sm_set_anon_id(void *ctx, const u8 *id, size_t len)
 {
        struct eapol_sm *sm = ctx;
@@ -2000,6 +2011,9 @@ static struct eapol_callbacks eapol_cb =
        eapol_sm_eap_param_needed,
        eapol_sm_notify_cert,
        eapol_sm_notify_status,
+#ifdef CONFIG_EAP_PROXY
+       eapol_sm_eap_proxy_cb,
+#endif /* CONFIG_EAP_PROXY */
        eapol_sm_set_anon_id
 };
 
index 03341a3..1309ff7 100644 (file)
@@ -271,6 +271,14 @@ struct eapol_ctx {
        void (*status_cb)(void *ctx, const char *status,
                          const char *parameter);
 
+#ifdef CONFIG_EAP_PROXY
+       /**
+        * eap_proxy_cb - Callback signifying any updates from eap_proxy
+        * @ctx: eapol_ctx from eap_peer_sm_init() call
+        */
+       void (*eap_proxy_cb)(void *ctx);
+#endif /* CONFIG_EAP_PROXY */
+
        /**
         * set_anon_id - Set or add anonymous identity
         * @ctx: eapol_ctx from eap_peer_sm_init() call
index 99e7351..1bb82ba 100644 (file)
@@ -842,6 +842,25 @@ static void wpa_supplicant_eap_param_needed(void *ctx,
 #endif /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
 
 
+#ifdef CONFIG_EAP_PROXY
+static void wpa_supplicant_eap_proxy_cb(void *ctx)
+{
+       struct wpa_supplicant *wpa_s = ctx;
+       size_t len;
+
+       wpa_s->mnc_len = eapol_sm_get_eap_proxy_imsi(wpa_s->eapol,
+                                                    wpa_s->imsi, &len);
+       if (wpa_s->mnc_len > 0) {
+               wpa_s->imsi[len] = '\0';
+               wpa_printf(MSG_DEBUG, "eap_proxy: IMSI %s (MNC length %d)",
+                          wpa_s->imsi, wpa_s->mnc_len);
+       } else {
+               wpa_printf(MSG_DEBUG, "eap_proxy: IMSI not available");
+       }
+}
+#endif /* CONFIG_EAP_PROXY */
+
+
 static void wpa_supplicant_port_cb(void *ctx, int authorized)
 {
        struct wpa_supplicant *wpa_s = ctx;
@@ -947,6 +966,9 @@ int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s)
        ctx->openssl_ciphers = wpa_s->conf->openssl_ciphers;
        ctx->wps = wpa_s->wps;
        ctx->eap_param_needed = wpa_supplicant_eap_param_needed;
+#ifdef CONFIG_EAP_PROXY
+       ctx->eap_proxy_cb = wpa_supplicant_eap_proxy_cb;
+#endif /* CONFIG_EAP_PROXY */
        ctx->port_cb = wpa_supplicant_port_cb;
        ctx->cb = wpa_supplicant_eapol_cb;
        ctx->cert_cb = wpa_supplicant_cert_cb;