Hi Tomasz,

On pe, 2014-03-21 at 14:06 +0200, Tomasz Bursztyka wrote:
> It's actually about differentiating the technology, which will be
> useful when requesting a scan from P2P technology. Since this technology
> is the child of wifi technology, it will get a scan triggered through
> the same scanning method. It will be up to the wifi plugin to
> differentiate what to do according on the given type.
> ---
>  include/device.h |  4 +++-
>  plugins/wifi.c   |  9 +++++----
>  src/device.c     | 22 ++++++++++++++--------
>  3 files changed, 22 insertions(+), 13 deletions(-)
> 
> diff --git a/include/device.h b/include/device.h
> index 721cc84..d2bc1f3 100644
> --- a/include/device.h
> +++ b/include/device.h
> @@ -23,6 +23,7 @@
>  #define __CONNMAN_DEVICE_H
>  
>  #include <connman/network.h>
> +#include <connman/service.h>
>  
>  #ifdef __cplusplus
>  extern "C" {
> @@ -124,7 +125,8 @@ struct connman_device_driver {
>       void (*remove) (struct connman_device *device);
>       int (*enable) (struct connman_device *device);
>       int (*disable) (struct connman_device *device);
> -     int (*scan)(struct connman_device *device,
> +     int (*scan)(enum connman_service_type type,
> +                     struct connman_device *device,
>                       const char *ssid, unsigned int ssid_len,
>                       const char *identity, const char* passphrase,
>                       const char *security, void *user_data);
> diff --git a/plugins/wifi.c b/plugins/wifi.c
> index f19dd34..d43a74e 100644
> --- a/plugins/wifi.c
> +++ b/plugins/wifi.c
> @@ -1084,10 +1084,11 @@ static int wifi_scan_simple(struct connman_device 
> *device)
>   * Note that the hidden scan is only used when connecting to this specific
>   * hidden AP first time. It is not used when system autoconnects to hidden 
> AP.
>   */
> -static int wifi_scan(struct connman_device *device,
> -             const char *ssid, unsigned int ssid_len,
> -             const char *identity, const char* passphrase,
> -             const char *security, void *user_data)
> +static int wifi_scan(enum connman_service_type type,
> +                     struct connman_device *device,
> +                     const char *ssid, unsigned int ssid_len,
> +                     const char *identity, const char* passphrase,
> +                     const char *security, void *user_data)
>  {
>       struct wifi_data *wifi = connman_device_get_data(device);
>       GSupplicantScanParams *scan_params = NULL;
> diff --git a/src/device.c b/src/device.c
> index bc835be..8306617 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -591,7 +591,8 @@ int connman_device_set_powered(struct connman_device 
> *device,
>       device->scanning = false;
>  
>       if (device->driver && device->driver->scan)
> -             device->driver->scan(device, NULL, 0, NULL, NULL, NULL, NULL);
> +             device->driver->scan(0, device, NULL, 0,

Perhaps CONNMAN_SERVICE_TYPE_UNKNOWN instead of 0?

> +                                     NULL, NULL, NULL, NULL);

Also could we use the service type to notice who did the scan, instead
of hackish looking scan_pending check in patch #08.

>  
>       return 0;
>  }
> @@ -601,7 +602,8 @@ bool connman_device_get_powered(struct connman_device 
> *device)
>       return device->powered;
>  }
>  
> -static int device_scan(struct connman_device *device)
> +static int device_scan(enum connman_service_type type,
> +                             struct connman_device *device)
>  {
>       if (!device->driver || !device->driver->scan)
>               return -EOPNOTSUPP;
> @@ -609,7 +611,8 @@ static int device_scan(struct connman_device *device)
>       if (!device->powered)
>               return -ENOLINK;
>  
> -     return device->driver->scan(device, NULL, 0, NULL, NULL, NULL, NULL);
> +     return device->driver->scan(type, device, NULL, 0,
> +                                     NULL, NULL, NULL, NULL);
>  }
>  
>  int __connman_device_disconnect(struct connman_device *device)
> @@ -1122,12 +1125,15 @@ int __connman_device_request_scan(enum 
> connman_service_type type)
>               enum connman_service_type service_type =
>                       __connman_device_get_service_type(device);
>  
> -             if (service_type != CONNMAN_SERVICE_TYPE_UNKNOWN &&
> -                             service_type != type) {
> -                     continue;
> +             if (service_type != CONNMAN_SERVICE_TYPE_UNKNOWN) {
> +                     if (type == CONNMAN_SERVICE_TYPE_P2P) {
> +                             if (service_type != CONNMAN_SERVICE_TYPE_WIFI)
> +                                     continue;
> +                     } else if (service_type != type)
> +                             continue;
>               }
>  
> -             err = device_scan(device);
> +             err = device_scan(type, device);
>               if (err == 0 || err == -EALREADY || err == -EINPROGRESS) {
>                       success = true;
>               } else {
> @@ -1153,7 +1159,7 @@ int __connman_device_request_hidden_scan(struct 
> connman_device *device,
>                       !device->driver->scan)
>               return -EINVAL;
>  
> -     return device->driver->scan(device, ssid, ssid_len, identity,
> +     return device->driver->scan(0, device, ssid, ssid_len, identity,
>                                       passphrase, security, user_data);
>  }
>  


Cheers,
Jukka


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

Reply via email to