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 | 3 ++-
plugins/wifi.c | 9 +++++----
src/device.c | 23 +++++++++++++++--------
3 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/include/device.h b/include/device.h
index 14ad1bb..f703bba 100644
--- a/include/device.h
+++ b/include/device.h
@@ -125,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 c593c70..cbb2dd8 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1088,10 +1088,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 3856080..929553a 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(CONNMAN_SERVICE_TYPE_UNKNOWN, device,
+ NULL, 0, NULL, NULL, NULL, NULL);
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,8 @@ 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(CONNMAN_SERVICE_TYPE_UNKNOWN,
+ device, ssid, ssid_len, identity,
passphrase, security, user_data);
}
--
1.8.3.2
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman