Allow ctrl_iface SET command to change global config parameters
authorJouni Malinen <jouni.malinen@atheros.com>
Sun, 18 Jul 2010 21:30:24 +0000 (14:30 -0700)
committerJouni Malinen <j@w1.fi>
Thu, 9 Sep 2010 14:17:16 +0000 (07:17 -0700)
wpa_supplicant/ctrl_iface.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h
wpa_supplicant/wps_supplicant.c
wpa_supplicant/wps_supplicant.h

index f025548..70c762b 100644 (file)
@@ -82,8 +82,12 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s,
                        ret = -1;
        } else if (os_strcasecmp(cmd, "wps_fragment_size") == 0) {
                wpa_s->wps_fragment_size = atoi(value);
-       } else
-               ret = -1;
+       } else {
+               value[-1] = '=';
+               ret = wpa_config_process_global(wpa_s->conf, cmd, -1);
+               if (ret == 0)
+                       wpa_supplicant_update_config(wpa_s);
+       }
 
        return ret;
 }
index 69c926a..b53609b 100644 (file)
@@ -628,6 +628,7 @@ int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s)
                        "file '%s' - exiting", wpa_s->confname);
                return -1;
        }
+       conf->changed_parameters = (unsigned int) -1;
 
        reconf_ctrl = !!conf->ctrl_interface != !!wpa_s->conf->ctrl_interface
                || (conf->ctrl_interface && wpa_s->conf->ctrl_interface &&
@@ -670,6 +671,8 @@ int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s)
        if (reconf_ctrl)
                wpa_s->ctrl_iface = wpa_supplicant_ctrl_iface_init(wpa_s);
 
+       wpa_supplicant_update_config(wpa_s);
+
        wpa_supplicant_clear_status(wpa_s);
        wpa_s->reassociate = 1;
        wpa_supplicant_req_scan(wpa_s, 0, 0);
@@ -2415,3 +2418,13 @@ void wpa_supplicant_deinit(struct wpa_global *global)
        wpa_debug_close_syslog();
        wpa_debug_close_file();
 }
+
+
+void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s)
+{
+#ifdef CONFIG_WPS
+       wpas_wps_update_config(wpa_s);
+#endif /* CONFIG_WPS */
+
+       wpa_s->conf->changed_parameters = 0;
+}
index b170638..2ee22be 100644 (file)
@@ -500,6 +500,7 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
                             const u8 *buf, size_t len);
 enum wpa_key_mgmt key_mgmt2driver(int key_mgmt);
 enum wpa_cipher cipher_suite2driver(int cipher);
+void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s);
 
 /* events.c */
 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
index 99fcabc..5e724c6 100644 (file)
@@ -1322,3 +1322,44 @@ int wpas_wps_in_progress(struct wpa_supplicant *wpa_s)
 
        return 0;
 }
+
+
+void wpas_wps_update_config(struct wpa_supplicant *wpa_s)
+{
+       struct wps_context *wps = wpa_s->wps;
+
+       if (wps == NULL)
+               return;
+
+       if (wpa_s->conf->changed_parameters & CFG_CHANGED_CONFIG_METHODS) {
+               wps->config_methods = wps_config_methods_str2bin(
+                       wpa_s->conf->config_methods);
+               if ((wps->config_methods &
+                    (WPS_CONFIG_DISPLAY | WPS_CONFIG_LABEL)) ==
+                   (WPS_CONFIG_DISPLAY | WPS_CONFIG_LABEL)) {
+                       wpa_printf(MSG_ERROR, "WPS: Both Label and Display "
+                                  "config methods are not allowed at the "
+                                  "same time");
+                       wps->config_methods &= ~WPS_CONFIG_LABEL;
+               }
+       }
+
+       if (wpa_s->conf->changed_parameters & CFG_CHANGED_DEVICE_TYPE) {
+               if (wpa_s->conf->device_type &&
+                   wps_dev_type_str2bin(wpa_s->conf->device_type,
+                                        wps->dev.pri_dev_type) < 0)
+                       wpa_printf(MSG_ERROR, "WPS: Invalid device_type");
+       }
+
+       if (wpa_s->conf->changed_parameters & CFG_CHANGED_OS_VERSION)
+               wps->dev.os_version = WPA_GET_BE32(wpa_s->conf->os_version);
+
+       if (wpa_s->conf->changed_parameters & CFG_CHANGED_UUID) {
+               if (is_nil_uuid(wpa_s->conf->uuid)) {
+                       uuid_gen_mac_addr(wpa_s->own_addr, wps->uuid);
+                       wpa_hexdump(MSG_DEBUG, "WPS: UUID based on MAC "
+                                   "address", wps->uuid, WPS_UUID_LEN);
+               } else
+                       os_memcpy(wps->uuid, wpa_s->conf->uuid, WPS_UUID_LEN);
+       }
+}
index 2bd6fa7..4c243ea 100644 (file)
@@ -63,6 +63,7 @@ int wpas_wps_er_config(struct wpa_supplicant *wpa_s, const char *uuid,
                       const char *pin, struct wps_new_ap_settings *settings);
 int wpas_wps_terminate_pending(struct wpa_supplicant *wpa_s);
 int wpas_wps_in_progress(struct wpa_supplicant *wpa_s);
+void wpas_wps_update_config(struct wpa_supplicant *wpa_s);
 
 #else /* CONFIG_WPS */