Get rid of unnecessary typedefs for enums.
[mech_eap.git] / wpa_supplicant / wpa_supplicant.c
index df7d1d5..a02fd77 100644 (file)
@@ -143,7 +143,7 @@ static int wpa_supplicant_set_wpa_none_key(struct wpa_supplicant *wpa_s,
 {
        u8 key[32];
        size_t keylen;
-       wpa_alg alg;
+       enum wpa_alg alg;
        u8 seq[6] = { 0 };
 
        /* IBSS/WPA-None uses only one key (Group) for both receiving and
@@ -478,7 +478,7 @@ void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr)
  * @state: State (wpa_state; WPA_*)
  * Returns: The state name as a printable text string
  */
-const char * wpa_supplicant_state_txt(int state)
+const char * wpa_supplicant_state_txt(enum wpa_states state)
 {
        switch (state) {
        case WPA_DISCONNECTED:
@@ -513,7 +513,8 @@ const char * wpa_supplicant_state_txt(int state)
  * This function is called whenever the connection state changes, e.g.,
  * association is completed for WPA/WPA2 4-Way Handshake is started.
  */
-void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state)
+void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
+                             enum wpa_states state)
 {
        wpa_printf(MSG_DEBUG, "State: %s -> %s",
                   wpa_supplicant_state_txt(wpa_s->wpa_state),
@@ -546,6 +547,23 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state)
 }
 
 
+void wpa_supplicant_terminate_proc(struct wpa_global *global)
+{
+       int pending = 0;
+#ifdef CONFIG_WPS
+       struct wpa_supplicant *wpa_s = global->ifaces;
+       while (wpa_s) {
+               if (wpas_wps_terminate_pending(wpa_s) == 1)
+                       pending = 1;
+               wpa_s = wpa_s->next;
+       }
+#endif /* CONFIG_WPS */
+       if (pending)
+               return;
+       eloop_terminate();
+}
+
+
 static void wpa_supplicant_terminate(int sig, void *signal_ctx)
 {
        struct wpa_global *global = signal_ctx;
@@ -554,13 +572,13 @@ static void wpa_supplicant_terminate(int sig, void *signal_ctx)
                wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TERMINATING "- signal %d "
                        "received", sig);
        }
-       eloop_terminate();
+       wpa_supplicant_terminate_proc(global);
 }
 
 
 static void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s)
 {
-       wpa_states old_state = wpa_s->wpa_state;
+       enum wpa_states old_state = wpa_s->wpa_state;
        wpa_s->pairwise_cipher = 0;
        wpa_s->group_cipher = 0;
        wpa_s->mgmt_group_cipher = 0;
@@ -653,13 +671,13 @@ static void wpa_supplicant_reconfig(int sig, void *signal_ctx)
        wpa_printf(MSG_DEBUG, "Signal %d received - reconfiguring", sig);
        for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
                if (wpa_supplicant_reload_configuration(wpa_s) < 0) {
-                       eloop_terminate();
+                       wpa_supplicant_terminate_proc(global);
                }
        }
 }
 
 
-static wpa_cipher cipher_suite2driver(int cipher)
+static enum wpa_cipher cipher_suite2driver(int cipher)
 {
        switch (cipher) {
        case WPA_CIPHER_NONE:
@@ -677,7 +695,7 @@ static wpa_cipher cipher_suite2driver(int cipher)
 }
 
 
-static wpa_key_mgmt key_mgmt2driver(int key_mgmt)
+static enum wpa_key_mgmt key_mgmt2driver(int key_mgmt)
 {
        switch (key_mgmt) {
        case WPA_KEY_MGMT_NONE:
@@ -963,7 +981,7 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
        size_t wpa_ie_len;
        int use_crypt, ret, i, bssid_changed;
        int algs = AUTH_ALG_OPEN_SYSTEM;
-       wpa_cipher cipher_pairwise, cipher_group;
+       enum wpa_cipher cipher_pairwise, cipher_group;
        struct wpa_driver_associate_params params;
        int wep_keys_set = 0;
        struct wpa_driver_capa capa;
@@ -2015,7 +2033,7 @@ next_driver:
        wpa_s->drv_priv = wpa_drv_init(wpa_s, wpa_s->ifname);
        if (wpa_s->drv_priv == NULL) {
                const char *pos;
-               pos = os_strchr(driver, ',');
+               pos = driver ? os_strchr(driver, ',') : NULL;
                if (pos) {
                        wpa_printf(MSG_DEBUG, "Failed to initialize driver "
                                   "interface - try next driver wrapper");