From 1619e9d51232287a6eaa94af75133551d7533409 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 4 Apr 2014 19:10:47 +0300 Subject: [PATCH] Interworking: Add ctrl_iface events on cred block modifications Following events are now sent to ctrl_iface monitors to indicate if credential blocks have been added, modified, or removed: CRED-ADDED CRED-MODIFIED CRED-REMOVE Signed-off-by: Jouni Malinen --- src/common/wpa_ctrl.h | 7 +++++++ wpa_supplicant/ctrl_iface.c | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h index 6d172283d..7f39ccdc3 100644 --- a/src/common/wpa_ctrl.h +++ b/src/common/wpa_ctrl.h @@ -164,6 +164,13 @@ extern "C" { #define INTERWORKING_ALREADY_CONNECTED "INTERWORKING-ALREADY-CONNECTED " #define INTERWORKING_SELECTED "INTERWORKING-SELECTED " +/* Credential block added; parameters: */ +#define CRED_ADDED "CRED-ADDED " +/* Credential block modified; parameters: */ +#define CRED_MODIFIED "CRED-MODIFIED " +/* Credential block removed; parameters: */ +#define CRED_REMOVED "CRED-REMOVED " + #define GAS_RESPONSE_INFO "GAS-RESPONSE-INFO " /* parameters: */ #define GAS_QUERY_START "GAS-QUERY-START " diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 925ece128..4a63f4a8c 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -2660,6 +2660,8 @@ static int wpa_supplicant_ctrl_iface_add_cred(struct wpa_supplicant *wpa_s, if (cred == NULL) return -1; + wpa_msg(wpa_s, MSG_INFO, CRED_ADDED "%d", cred->id); + ret = os_snprintf(buf, buflen, "%d\n", cred->id); if (ret < 0 || (size_t) ret >= buflen) return -1; @@ -2672,12 +2674,21 @@ static int wpas_ctrl_remove_cred(struct wpa_supplicant *wpa_s, { struct wpa_ssid *ssid; char str[20]; + int id; - if (cred == NULL || wpa_config_remove_cred(wpa_s->conf, cred->id) < 0) { + if (cred == NULL) { wpa_printf(MSG_DEBUG, "CTRL_IFACE: Could not find cred"); return -1; } + id = cred->id; + if (wpa_config_remove_cred(wpa_s->conf, id) < 0) { + wpa_printf(MSG_DEBUG, "CTRL_IFACE: Could not find cred"); + return -1; + } + + wpa_msg(wpa_s, MSG_INFO, CRED_REMOVED "%d", id); + /* Remove any network entry created based on the removed credential */ ssid = wpa_s->conf->ssid; while (ssid) { @@ -2794,6 +2805,8 @@ static int wpa_supplicant_ctrl_iface_set_cred(struct wpa_supplicant *wpa_s, return -1; } + wpa_msg(wpa_s, MSG_INFO, CRED_MODIFIED "%d %s", cred->id, name); + return 0; }