]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
ERP: Add ERP_FLUSH for hostapd
authorJouni Malinen <j@w1.fi>
Sun, 14 Dec 2014 11:31:12 +0000 (13:31 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 14 Dec 2014 13:47:04 +0000 (15:47 +0200)
This can be used to drop any pending ERP key from both the internal AP
authentication server and RADIUS server use of hostapd.

Signed-off-by: Jouni Malinen <j@w1.fi>
hostapd/ctrl_iface.c
hostapd/hostapd_cli.c
src/ap/ieee802_1x.c
src/ap/ieee802_1x.h
src/radius/radius_server.c
src/radius/radius_server.h

index 4ed3decf783317ba07d6ba7ae7e0787e70289097..52e7a43b78ac64fd4e8f13cdf0364046bc47eaf1 100644 (file)
@@ -2019,7 +2019,11 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
        } else if (os_strncmp(buf, "VENDOR ", 7) == 0) {
                reply_len = hostapd_ctrl_iface_vendor(hapd, buf + 7, reply,
                                                      reply_size);
-
+       } else if (os_strcmp(buf, "ERP_FLUSH") == 0) {
+               ieee802_1x_erp_flush(hapd);
+#ifdef RADIUS_SERVER
+               radius_server_erp_flush(hapd->radius_srv);
+#endif /* RADIUS_SERVER */
        } else {
                os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
                reply_len = 16;
index 7faa3240ba2538edab7d8d31da897aea448e7177..700918421a6c75223e120df1ffa6699356f4e6c9 100644 (file)
@@ -1002,6 +1002,13 @@ static int hostapd_cli_cmd_vendor(struct wpa_ctrl *ctrl, int argc, char *argv[])
 }
 
 
+static int hostapd_cli_cmd_erp_flush(struct wpa_ctrl *ctrl, int argc,
+                                    char *argv[])
+{
+       return wpa_ctrl_command(ctrl, "ERP_FLUSH");
+}
+
+
 struct hostapd_cli_cmd {
        const char *cmd;
        int (*handler)(struct wpa_ctrl *ctrl, int argc, char *argv[]);
@@ -1055,6 +1062,7 @@ static struct hostapd_cli_cmd hostapd_cli_commands[] = {
        { "enable", hostapd_cli_cmd_enable },
        { "reload", hostapd_cli_cmd_reload },
        { "disable", hostapd_cli_cmd_disable },
+       { "erp_flush", hostapd_cli_cmd_erp_flush },
        { NULL, NULL }
 };
 
index 181092547af6743ace4f5e461864ba4e08f324eb..2287b281dc26ccc7b38c146a729c10b9c139503b 100644 (file)
@@ -2151,10 +2151,20 @@ int ieee802_1x_init(struct hostapd_data *hapd)
 }
 
 
-void ieee802_1x_deinit(struct hostapd_data *hapd)
+void ieee802_1x_erp_flush(struct hostapd_data *hapd)
 {
        struct eap_server_erp_key *erp;
 
+       while ((erp = dl_list_first(&hapd->erp_keys, struct eap_server_erp_key,
+                                   list)) != NULL) {
+               dl_list_del(&erp->list);
+               bin_clear_free(erp, sizeof(*erp));
+       }
+}
+
+
+void ieee802_1x_deinit(struct hostapd_data *hapd)
+{
        eloop_cancel_timeout(ieee802_1x_rekey, hapd, NULL);
 
        if (hapd->driver != NULL &&
@@ -2164,11 +2174,7 @@ void ieee802_1x_deinit(struct hostapd_data *hapd)
        eapol_auth_deinit(hapd->eapol_auth);
        hapd->eapol_auth = NULL;
 
-       while ((erp = dl_list_first(&hapd->erp_keys, struct eap_server_erp_key,
-                                   list)) != NULL) {
-               dl_list_del(&erp->list);
-               bin_clear_free(erp, sizeof(*erp));
-       }
+       ieee802_1x_erp_flush(hapd);
 }
 
 
index e1df94057de702fe794c362db2200dadd77f1a10..de6e0e75fac3b00606f48bcc6682ca574220f112 100644 (file)
@@ -29,6 +29,7 @@ void ieee802_1x_set_sta_authorized(struct hostapd_data *hapd,
                                   struct sta_info *sta, int authorized);
 void ieee802_1x_dump_state(FILE *f, const char *prefix, struct sta_info *sta);
 int ieee802_1x_init(struct hostapd_data *hapd);
+void ieee802_1x_erp_flush(struct hostapd_data *hapd);
 void ieee802_1x_deinit(struct hostapd_data *hapd);
 int ieee802_1x_tx_status(struct hostapd_data *hapd, struct sta_info *sta,
                         const u8 *buf, size_t len, int ack);
index b315277b087c48cd4d115feb31c5c82f885ba686..85a485e91d93223fe567a39c84ebb7c0fecaf986 100644 (file)
@@ -1820,13 +1820,29 @@ radius_server_init(struct radius_server_conf *conf)
 
 
 /**
- * radius_server_deinit - Deinitialize RADIUS server
+ * radius_server_erp_flush - Flush all ERP keys
  * @data: RADIUS server context from radius_server_init()
  */
-void radius_server_deinit(struct radius_server_data *data)
+void radius_server_erp_flush(struct radius_server_data *data)
 {
        struct eap_server_erp_key *erp;
 
+       if (data == NULL)
+               return;
+       while ((erp = dl_list_first(&data->erp_keys, struct eap_server_erp_key,
+                                   list)) != NULL) {
+               dl_list_del(&erp->list);
+               bin_clear_free(erp, sizeof(*erp));
+       }
+}
+
+
+/**
+ * radius_server_deinit - Deinitialize RADIUS server
+ * @data: RADIUS server context from radius_server_init()
+ */
+void radius_server_deinit(struct radius_server_data *data)
+{
        if (data == NULL)
                return;
 
@@ -1856,11 +1872,7 @@ void radius_server_deinit(struct radius_server_data *data)
                sqlite3_close(data->db);
 #endif /* CONFIG_SQLITE */
 
-       while ((erp = dl_list_first(&data->erp_keys, struct eap_server_erp_key,
-                                   list)) != NULL) {
-               dl_list_del(&erp->list);
-               bin_clear_free(erp, sizeof(*erp));
-       }
+       radius_server_erp_flush(data);
 
        os_free(data);
 }
index 1b8967c26bcfb6f366684de6eb055e9a50f7b3e1..ca4e38c12e99502622caacbb597fd2b0feaaa079 100644 (file)
@@ -235,6 +235,7 @@ struct radius_server_conf {
 struct radius_server_data *
 radius_server_init(struct radius_server_conf *conf);
 
+void radius_server_erp_flush(struct radius_server_data *data);
 void radius_server_deinit(struct radius_server_data *data);
 
 int radius_server_get_mib(struct radius_server_data *data, char *buf,