HS 2.0: Remove temporary network block on cred block removal

If the credential that was used to create a temporary HS 2.0 network
block is removed, remove the network block, too.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2012-11-22 17:53:27 +02:00 committed by Jouni Malinen
parent f403dcd648
commit 736d4f2d77
3 changed files with 44 additions and 11 deletions

View file

@ -542,6 +542,15 @@ struct wpa_ssid {
* disabled_until - Network block disabled until this time if non-zero * disabled_until - Network block disabled until this time if non-zero
*/ */
struct os_time disabled_until; struct os_time disabled_until;
/**
* parent_cred - Pointer to parent wpa_cred entry
*
* This pointer can be used to delete temporary networks when a wpa_cred
* that was used to create them is removed. This pointer should not be
* dereferences since it may not be updated in all cases.
*/
void *parent_cred;
}; };
#endif /* CONFIG_SSID_H */ #endif /* CONFIG_SSID_H */

View file

@ -2306,20 +2306,48 @@ static int wpa_supplicant_ctrl_iface_add_cred(struct wpa_supplicant *wpa_s,
} }
static int wpas_ctrl_remove_cred(struct wpa_supplicant *wpa_s,
struct wpa_cred *cred)
{
struct wpa_ssid *ssid;
char str[20];
if (cred == NULL || wpa_config_remove_cred(wpa_s->conf, cred->id) < 0) {
wpa_printf(MSG_DEBUG, "CTRL_IFACE: Could not find cred");
return -1;
}
/* Remove any network entry created based on the removed credential */
ssid = wpa_s->conf->ssid;
while (ssid) {
if (ssid->parent_cred == cred) {
wpa_printf(MSG_DEBUG, "Remove network id %d since it "
"used the removed credential", ssid->id);
os_snprintf(str, sizeof(str), "%d", ssid->id);
ssid = ssid->next;
wpa_supplicant_ctrl_iface_remove_network(wpa_s, str);
} else
ssid = ssid->next;
}
return 0;
}
static int wpa_supplicant_ctrl_iface_remove_cred(struct wpa_supplicant *wpa_s, static int wpa_supplicant_ctrl_iface_remove_cred(struct wpa_supplicant *wpa_s,
char *cmd) char *cmd)
{ {
int id; int id;
struct wpa_cred *cred; struct wpa_cred *cred, *prev;
/* cmd: "<cred id>" or "all" */ /* cmd: "<cred id>" or "all" */
if (os_strcmp(cmd, "all") == 0) { if (os_strcmp(cmd, "all") == 0) {
wpa_printf(MSG_DEBUG, "CTRL_IFACE: REMOVE_CRED all"); wpa_printf(MSG_DEBUG, "CTRL_IFACE: REMOVE_CRED all");
cred = wpa_s->conf->cred; cred = wpa_s->conf->cred;
while (cred) { while (cred) {
id = cred->id; prev = cred;
cred = cred->next; cred = cred->next;
wpa_config_remove_cred(wpa_s->conf, id); wpas_ctrl_remove_cred(wpa_s, prev);
} }
return 0; return 0;
} }
@ -2328,14 +2356,7 @@ static int wpa_supplicant_ctrl_iface_remove_cred(struct wpa_supplicant *wpa_s,
wpa_printf(MSG_DEBUG, "CTRL_IFACE: REMOVE_CRED id=%d", id); wpa_printf(MSG_DEBUG, "CTRL_IFACE: REMOVE_CRED id=%d", id);
cred = wpa_config_get_cred(wpa_s->conf, id); cred = wpa_config_get_cred(wpa_s->conf, id);
if (cred == NULL || return wpas_ctrl_remove_cred(wpa_s, cred);
wpa_config_remove_cred(wpa_s->conf, id) < 0) {
wpa_printf(MSG_DEBUG, "CTRL_IFACE: Could not find cred id=%d",
id);
return -1;
}
return 0;
} }

View file

@ -786,6 +786,7 @@ static int interworking_connect_3gpp(struct wpa_supplicant *wpa_s,
ssid = wpa_config_add_network(wpa_s->conf); ssid = wpa_config_add_network(wpa_s->conf);
if (ssid == NULL) if (ssid == NULL)
return -1; return -1;
ssid->parent_cred = cred;
wpas_notify_network_added(wpa_s, ssid); wpas_notify_network_added(wpa_s, ssid);
wpa_config_set_network_defaults(ssid); wpa_config_set_network_defaults(ssid);
@ -1095,6 +1096,7 @@ static int interworking_connect_roaming_consortium(
ssid = wpa_config_add_network(wpa_s->conf); ssid = wpa_config_add_network(wpa_s->conf);
if (ssid == NULL) if (ssid == NULL)
return -1; return -1;
ssid->parent_cred = cred;
wpas_notify_network_added(wpa_s, ssid); wpas_notify_network_added(wpa_s, ssid);
wpa_config_set_network_defaults(ssid); wpa_config_set_network_defaults(ssid);
ssid->priority = cred->priority; ssid->priority = cred->priority;
@ -1209,6 +1211,7 @@ int interworking_connect(struct wpa_supplicant *wpa_s, struct wpa_bss *bss)
nai_realm_free(realm, count); nai_realm_free(realm, count);
return -1; return -1;
} }
ssid->parent_cred = cred;
wpas_notify_network_added(wpa_s, ssid); wpas_notify_network_added(wpa_s, ssid);
wpa_config_set_network_defaults(ssid); wpa_config_set_network_defaults(ssid);
ssid->priority = cred->priority; ssid->priority = cred->priority;