Hi Tomasz,

On 07/09/2014 02:36 PM, Tomasz Bursztyka wrote:
> This will be used to request the proper wps method when connecting to
> the peer.
> ---
>  gsupplicant/gsupplicant.h |  4 ++++
>  gsupplicant/supplicant.c  | 28 ++++++++++++++++++++++++++++
>  2 files changed, 32 insertions(+)
> 
> diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
> index 7a3c843..5fb2928 100644
> --- a/gsupplicant/gsupplicant.h
> +++ b/gsupplicant/gsupplicant.h
> @@ -78,6 +78,8 @@ extern "C" {
>  #define G_SUPPLICANT_WPS_PIN            (1 << 2)
>  #define G_SUPPLICANT_WPS_REGISTRAR      (1 << 3)
>  
> +#define G_SUPPLICANT_WPS_CONFIG_PBC  0x0080
> +

Is there a special reason it is not like the defines above (1 << x)?

>  typedef enum {
>       G_SUPPLICANT_MODE_UNKNOWN,
>       G_SUPPLICANT_MODE_INFRA,
> @@ -258,6 +260,8 @@ GSupplicantInterface 
> *g_supplicant_peer_get_interface(GSupplicantPeer *peer);
>  const char *g_supplicant_peer_get_identifier(GSupplicantPeer *peer);
>  const void *g_supplicant_peer_get_device_address(GSupplicantPeer *peer);
>  const char *g_supplicant_peer_get_name(GSupplicantPeer *peer);
> +bool g_supplicant_peer_is_wps_pbc(GSupplicantPeer *peer);
> +bool g_supplicant_peer_is_wps_pin(GSupplicantPeer *peer);
>  
>  struct _GSupplicantCallbacks {
>       void (*system_ready) (void);
> diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
> index d538181..7685bd7 100644
> --- a/gsupplicant/supplicant.c
> +++ b/gsupplicant/supplicant.c
> @@ -223,6 +223,7 @@ struct _GSupplicantPeer {
>       unsigned char device_address[6];
>       char *name;
>       char *identifier;
> +     unsigned int wps_capabilities;
>  };
>  
>  static inline void debug(const char *format, ...)
> @@ -1011,6 +1012,24 @@ const char *g_supplicant_peer_get_name(GSupplicantPeer 
> *peer)
>       return peer->name;
>  }
>  
> +bool g_supplicant_peer_is_wps_pbc(GSupplicantPeer *peer)
> +{
> +     if (!peer)
> +             return false;
> +
> +     return ((peer->wps_capabilities & G_SUPPLICANT_WPS_PBC) ==
> +                                                     G_SUPPLICANT_WPS_PBC);
> +}
> +
> +bool g_supplicant_peer_is_wps_pin(GSupplicantPeer *peer)
> +{
> +     if (!peer)
> +             return false;
> +
> +     return ((peer->wps_capabilities & G_SUPPLICANT_WPS_PIN) ==
> +                                                     G_SUPPLICANT_WPS_PIN);
> +}

In the linse above this change the pattern used is:

dbus_bool_t g_supplicant_network_is_wps_advertizing(GSupplicantNetwork
*network)
{
        if (!network)
                return FALSE;

        if (network->wps_capabilities & G_SUPPLICANT_WPS_REGISTRAR)
                return TRUE;

        return FALSE;
}

I would suggest to stick to the pattern. That  brings the next question
if the return type 'bool' should not be dbus_bool_t to be consistent.


> +
>  static void merge_network(GSupplicantNetwork *network)
>  {
>       GString *str;
> @@ -2455,6 +2474,15 @@ static void peer_property(const char *key, 
> DBusMessageIter *iter,
>               dbus_message_iter_get_basic(iter, &str);
>               if (str)
>                       peer->name = g_strdup(str);
> +     } else if (g_strcmp0(key, "config_method") == 0) {
> +             uint16_t wps_config;
> +
> +             dbus_message_iter_get_basic(iter, &wps_config);
> +
> +             if (wps_config & G_SUPPLICANT_WPS_CONFIG_PBC)
> +                     peer->wps_capabilities |= G_SUPPLICANT_WPS_PBC;
> +             if (wps_config & ~G_SUPPLICANT_WPS_CONFIG_PBC)
> +                     peer->wps_capabilities |= G_SUPPLICANT_WPS_PIN;
>       }
>  }
>  
> 

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

Reply via email to