Hi Jukka, > --- > plugins/wifi.c | 78 > ++++++++++++++++++++++++++++++++++++++++++++++---------- > 1 file changed, 65 insertions(+), 13 deletions(-) > > diff --git a/plugins/wifi.c b/plugins/wifi.c > index c0f7ddc..c807ab9 100644 > --- a/plugins/wifi.c > +++ b/plugins/wifi.c > @@ -51,6 +51,7 @@ > #include <connman/option.h> > #include <connman/storage.h> > #include <include/setting.h> > +#include <connman/provision.h> > > #include <gsupplicant/gsupplicant.h> > > @@ -263,25 +264,32 @@ static void wifi_remove(struct connman_device *device) > g_free(wifi); > } > > -static int add_scan_param(gchar *hex_ssid, int freq, > - GSupplicantScanParams *scan_data, > +static int add_scan_param(gchar *hex_ssid, char *raw_ssid, int ssid_len, > + int freq, GSupplicantScanParams *scan_data, > int driver_max_scan_ssids) > { > unsigned int i; > struct scan_ssid *scan_ssid; > > - if (driver_max_scan_ssids > scan_data->num_ssids && hex_ssid != NULL) { > + if (driver_max_scan_ssids > scan_data->num_ssids && > + (hex_ssid != NULL || raw_ssid != NULL)) { > gchar *ssid; > unsigned int j = 0, hex; > - size_t hex_ssid_len = strlen(hex_ssid); > > - ssid = g_try_malloc0(hex_ssid_len / 2); > - if (ssid == NULL) > - return -ENOMEM; > + if (hex_ssid != NULL) { > + size_t hex_ssid_len = strlen(hex_ssid); > + > + ssid = g_try_malloc0(hex_ssid_len / 2); > + if (ssid == NULL) > + return -ENOMEM; > > - for (i = 0; i < hex_ssid_len; i += 2) { > - sscanf(hex_ssid + i, "%02x", &hex); > - ssid[j++] = hex; > + for (i = 0; i < hex_ssid_len; i += 2) { > + sscanf(hex_ssid + i, "%02x", &hex); > + ssid[j++] = hex; > + } > + } else { > + ssid = raw_ssid; > + j = ssid_len; > } > > scan_ssid = g_try_new(struct scan_ssid, 1); > @@ -297,7 +305,8 @@ static int add_scan_param(gchar *hex_ssid, int freq, > > scan_data->num_ssids++; > > - g_free(ssid); > + if (hex_ssid != NULL) > + g_free(ssid); > } else > return -EINVAL; > > @@ -335,6 +344,7 @@ static int add_scan_param(gchar *hex_ssid, int freq, > static int get_hidden_connections(int max_ssids, > GSupplicantScanParams *scan_data) > { > + struct connman_config_item **configs; > GKeyFile *keyfile; > gchar **services; > char *ssid; > @@ -377,7 +387,8 @@ static int get_hidden_connections(int max_ssids, > freq = g_key_file_get_integer(keyfile, services[i], > "Frequency", NULL); > > - if (add_scan_param(ssid, freq, scan_data, max_ssids) < 0) { > + if (add_scan_param(ssid, NULL, 0, freq, scan_data, > + max_ssids) < 0) { > str = g_key_file_get_string(keyfile, > services[i], "Name", NULL); > DBG("Cannot scan %s (%s)", ssid, str); > @@ -390,6 +401,46 @@ static int get_hidden_connections(int max_ssids, > g_key_file_free(keyfile); > } > > + /* > + * Check if there are any hidden AP that needs to be provisioned. > + */ > + configs = connman_config_get_configs(); > + for (i = 0; configs && configs[i]; i++) { > + int len; > + > + if (configs[i]->hidden == FALSE) > + goto free; > + > + if (configs[i]->ssid == NULL) { > + ssid = configs[i]->name; > + len = strlen(ssid); > + } else { > + ssid = configs[i]->ssid; > + len = configs[i]->ssid_len; > + } > + > + if (ssid == NULL) > + goto free; > + > + DBG("[%d]->ssid = %s", i, ssid); > + > + if (add_scan_param(NULL, ssid, len, 0, scan_data, > + max_ssids) < 0) { > + DBG("Cannot scan %s (%s)", ssid, configs[i]->ident); > + add_param_failed++; > + } > + > + num_ssids++; > + > + free: > + g_free(configs[i]->ident); > + g_free(configs[i]->name); > + g_free(configs[i]->ssid); > + g_free(configs[i]); > + }
there is no way we are doing this. This is complicated. Labels inside a for loop are not a good idea. Please restructure this code to make it more readable. Regards Marcel _______________________________________________ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman