Hi Tomasz,

On 07/09/2014 02:36 PM, Tomasz Bursztyka wrote:
> The wifi plugin will use this function to specify the P2P device name,
> and will set it according to the hostname.
> ---
>  gsupplicant/gsupplicant.h |  2 ++
>  gsupplicant/supplicant.c  | 60 
> +++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 62 insertions(+)
> 
> diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
> index 5fb2928..99f9d90 100644
> --- a/gsupplicant/gsupplicant.h
> +++ b/gsupplicant/gsupplicant.h
> @@ -233,6 +233,8 @@ int 
> g_supplicant_interface_set_country(GSupplicantInterface *interface,
>                                                       const char *alpha2,
>                                                       void *user_data);
>  bool g_supplicant_interface_has_p2p(GSupplicantInterface *interface);
> +int g_supplicant_interface_set_p2p_device_config(GSupplicantInterface 
> *interface,
> +                                             const char *device_name);
>  
>  /* Network and Peer API */
>  struct _GSupplicantNetwork;
> diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
> index 7685bd7..42d4cc1 100644
> --- a/gsupplicant/supplicant.c
> +++ b/gsupplicant/supplicant.c
> @@ -2704,6 +2704,66 @@ bool 
> g_supplicant_interface_has_p2p(GSupplicantInterface *interface)
>       return interface->p2p_support;
>  }
>  
> +struct supplicant_p2p_dev_config {
> +     const char *device_name;
> +};
> +
> +static void p2p_device_config_result(const char *error,
> +                                     DBusMessageIter *iter, void *user_data)
> +{
> +     struct supplicant_p2p_dev_config *config = user_data;
> +
> +     if (error)
> +             SUPPLICANT_DBG("Unable to set P2P Device configuration");
> +
> +     g_free(config);

config was allocated by dbus_malloc0, I think you should use dbus_free()
instead of g_free().

> +}
> +
> +static void p2p_device_config_params(DBusMessageIter *iter, void *user_data)
> +{
> +     struct supplicant_p2p_dev_config *config = user_data;
> +     DBusMessageIter dict;
> +
> +     supplicant_dbus_dict_open(iter, &dict);
> +
> +     supplicant_dbus_dict_append_basic(&dict, "DeviceName",
> +                             DBUS_TYPE_STRING, &config->device_name);
> +
> +     supplicant_dbus_dict_close(iter, &dict);
> +}
> +
> +int g_supplicant_interface_set_p2p_device_config(GSupplicantInterface 
> *interface,
> +                                             const char *device_name)
> +{
> +     struct supplicant_p2p_dev_config *config;
> +     int ret;
> +
> +     SUPPLICANT_DBG("P2P Device Name setting %s", device_name);
> +
> +     config = dbus_malloc0(sizeof(*config));
> +     if (!config)
> +             return -ENOMEM;
> +
> +     config->device_name = device_name;

We are safe here, right? We don't have to strdup device_name?

> +
> +     ret = supplicant_dbus_property_set(interface->path,
> +                             SUPPLICANT_INTERFACE ".Interface.P2PDevice",
> +                             "P2PDeviceConfig",
> +                             DBUS_TYPE_ARRAY_AS_STRING
> +                             DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
> +                             DBUS_TYPE_STRING_AS_STRING
> +                             DBUS_TYPE_VARIANT_AS_STRING
> +                             DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
> +                             p2p_device_config_params,
> +                             p2p_device_config_result, config, NULL);
> +     if (ret < 0) {
> +             g_free(config);

Same above.

> +             SUPPLICANT_DBG("Unable to set P2P Device configuration");
> +     }
> +
> +     return ret;
> +}
> +
>  struct interface_data {
>       GSupplicantInterface *interface;
>       char *path; /* Interface path cannot be taken from interface (above) as
> 

cheers,
daniel
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to