Hi Samuel,

> We need to save most of the wifi network settings in order to autconnect to
> secure and hidden networks.
> ---
>  src/service.c |   35 +++++++++++++++++++++++++++++++++++
>  1 files changed, 35 insertions(+), 0 deletions(-)
> 
> diff --git a/src/service.c b/src/service.c
> index 9fefac8..24ee710 100644
> --- a/src/service.c
> +++ b/src/service.c
> @@ -1526,6 +1526,7 @@ static int service_save(struct connman_service *service)
>       gchar *pathname, *data = NULL;
>       gsize length;
>       gchar *str;
> +     const char *security;
>  
>       DBG("service %p", service);
>  
> @@ -1559,6 +1560,31 @@ update:
>       case CONNMAN_SERVICE_TYPE_ETHERNET:
>               break;
>       case CONNMAN_SERVICE_TYPE_WIFI:
> +             if (service->network) {
> +                     char *identifier = service->identifier;
> +                     const void *ssid;
> +                     const char *bssid;
> +                     unsigned int ssid_len = 0;
> +
> +                     ssid = connman_network_get_blob(service->network,
> +                                                     "WiFi.SSID",
> +                                                     &ssid_len);
> +
> +                     bssid = connman_network_get_string(service->network,
> +                                                        "Address");
> +
> +                     if (ssid) {
> +                             g_key_file_set_value(keyfile, identifier,
> +                                                  "SSID", ssid);
> +                             g_key_file_set_integer(keyfile, identifier,
> +                                                    "SSID_len", ssid_len);
> +                     }

I don't like this. Especially since we don't know what encoding our
filesystems uses. Can we convert the SSID into a hex string like we do
for the service object path and just store that one. Also please prefix
this with WiFi.SSID so we have a clean namespace here.

> +                     if (bssid)
> +                             g_key_file_set_string(keyfile, identifier,
> +                                                   "BSSID", bssid);
> +             }
> +
>       case CONNMAN_SERVICE_TYPE_WIMAX:
>       case CONNMAN_SERVICE_TYPE_BLUETOOTH:
>       case CONNMAN_SERVICE_TYPE_CELLULAR:
> @@ -1585,6 +1611,15 @@ update:
>               g_free(str);
>       }
>  
> +     security = security2string(service->security);
> +     if (security)
> +             g_key_file_set_string(keyfile, service->identifier,
> +                                   "Security",
> +                                   security2string(service->security));
> +     else
> +             g_key_file_set_string(keyfile, service->identifier,
> +                                   "Security", "none");
> +
>       if (service->passphrase != NULL)
>               g_key_file_set_string(keyfile, service->identifier,
>                                       "Passphrase", service->passphrase);

Do we really need to store BSSID and security details. My plan is that
we only re-connect to a hidden network if we find it during a scan. And
once scanned we have the BSSID and security details. They will actually
match perfectly with group name. Since for hidden networks we use the
address in the group name.

Regards

Marcel


_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to