Send connman mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."
Today's Topics:
1. [PATCHv3 3/6] wps: add new WPS API implementation
([email protected])
2. [PATCHv3 4/6] wps: add new WPS API implementation
([email protected])
----------------------------------------------------------------------
Message: 1
Date: Thu, 11 Oct 2018 16:06:43 +0000
From: <[email protected]>
To: <[email protected]>
Cc: <[email protected]>, <[email protected]>
Subject: [PATCHv3 3/6] wps: add new WPS API implementation
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="us-ascii"
Add new WPS start API which does not specify any service.
Signed-off-by: n-itaya <[email protected]>
---
plugins/wifi.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
diff --git a/plugins/wifi.c b/plugins/wifi.c
index dc08c6af..0d096aa2 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -42,6 +42,7 @@
#include <glib.h>
#define CONNMAN_API_SUBJECT_TO_CHANGE
+#include <connman.h>
#include <connman/plugin.h>
#include <connman/inet.h>
#include <connman/device.h>
@@ -123,6 +124,12 @@ struct wifi_tethering_info {
GSupplicantSSID *ssid;
};
+struct wifi_wps_offered_data {
+ struct connman_service *service;
+ char *expect_ident;
+ char *passphrase;
+};
+
struct wifi_data {
char *identifier;
struct connman_device *device;
@@ -156,11 +163,19 @@ struct wifi_data {
unsigned int p2p_connection_timeout;
struct connman_peer *pending_peer;
GSList *peers;
+ bool p2p_connected;
bool p2p_connecting;
bool p2p_device;
int servicing;
int disconnect_code;
int assoc_code;
+
+ bool wps_running;
+ bool wps_success;
+ unsigned int wps_timeout;
+ GSList *wps_offered_list;
+ bool wps_after_scan;
+ GSupplicantWPSParams wps_params;
};
static GList *iface_list = NULL;
@@ -174,6 +189,26 @@ static int tech_set_tethering(struct connman_technology
*technology,
const char *identifier, const char *passphrase,
const char *bridge, bool enabled);
+/* WPS Functions */
+#define WPS_TIMEOUT_INTERVAL_MSECS (125 * 1000)
+
+static void wps_event_success(GSupplicantInterface *interface);
+static void wps_event_fail(GSupplicantInterface *interface, int error);
+static struct wifi_wps_offered_data *wps_alloc_offered_data(
+ struct wifi_data *wifi, const char *group,
+ const char *passphrase);
+static void wps_free_offered_data(struct wifi_wps_offered_data *wps_data);
+static unsigned int wps_get_accepted_count(struct wifi_data *wifi);
+static unsigned int wps_get_offered_count(struct wifi_data *wifi);
+static bool wps_try_update_services(struct wifi_data *wifi);
+static void wps_finish(struct wifi_data *wifi, int error);
+static void wps_cleanup(struct wifi_data *wifi);
+static void wps_scan_callback(int result, GSupplicantInterface *interface,
+ void *user_data);
+static gboolean wps_timeout(gpointer data);
+static void wps_retry_callback(int result, GSupplicantInterface *interface,
+ void *user_data);
+
static int p2p_tech_probe(struct connman_technology *technology)
{
p2p_technology = technology;
@@ -417,6 +452,29 @@ static int peer_disconnect(struct connman_peer *peer)
return ret;
}
+static int peer_disconnect_all(struct wifi_data *wifi)
+{
+ GSList *list;
+ int result = 0, err = -EALREADY;
+
+ DBG("");
+
+ for (list = wifi->peers; list; list = list->next) {
+ struct connman_peer *peer = list->data;
+ GSupplicantPeer *gs_peer =
+ g_supplicant_interface_peer_lookup
+ (wifi->interface,
connman_peer_get_identifier(peer));
+
+ if (g_supplicant_peer_is_in_a_group(gs_peer)) {
+ err = peer_disconnect(peer);
+ if (err != -EINPROGRESS)
+ result = err;
+ }
+ }
+
+ return result;
+}
+
struct peer_service_registration {
peer_service_registration_cb_t callback;
void *user_data;
@@ -1583,6 +1641,7 @@ static int wifi_disable(struct connman_device *device)
return -ENODEV;
wifi->connected = false;
+ wifi->p2p_connected = false;
wifi->disconnecting = false;
if (wifi->pending_network)
@@ -2199,6 +2258,9 @@ static int network_connect(struct connman_network
*network)
if (!wifi)
return -ENODEV;
+ if (wifi->wps_running)
+ return -EBUSY;
+
ssid = g_try_malloc0(sizeof(GSupplicantSSID));
if (!ssid)
return -ENOMEM;
@@ -2375,6 +2437,8 @@ static bool handle_wps_completion(GSupplicantInterface
*interface,
{
bool wps;
+ DBG("");
+
wps = connman_network_get_bool(network, "WiFi.UseWPS");
if (wps) {
const unsigned char *ssid, *wps_ssid;
@@ -2486,6 +2550,36 @@ static void interface_state(GSupplicantInterface
*interface)
finalize_interface_creation(wifi);
}
+ if (wifi->wps_running) {
+ DBG("WPS running");
+ switch (state) {
+ case G_SUPPLICANT_STATE_SCANNING:
+ if (!wifi->wps_success)
+ connman_technology_wps_state_change_notify
+ (wifi_technology, "scan");
+ return;
+ case G_SUPPLICANT_STATE_ASSOCIATED:
+ connman_technology_wps_state_change_notify
+ (wifi_technology, "processing");
+ return;
+ case G_SUPPLICANT_STATE_DISCONNECTED:
+ if (wifi->wps_success) {
+ if (wps_try_update_services(wifi)) {
+ wps_finish(wifi, 0);
+ } else {
+ wifi->wps_after_scan = true;
+ DBG("Need scan");
+ reset_autoscan(wifi->device);
+ throw_wifi_scan(device,
+ wps_scan_callback);
+ }
+ }
+ return;
+ default:
+ return;
+ }
+ }
+
network = wifi->network;
if (!network)
return;
--
2.17.1
------------------------------
Message: 2
Date: Thu, 11 Oct 2018 16:06:54 +0000
From: <[email protected]>
To: <[email protected]>
Cc: <[email protected]>, <[email protected]>
Subject: [PATCHv3 4/6] wps: add new WPS API implementation
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="us-ascii"
Add the handler which receive WPS credential and force save information
into applicable service.
Add new status property for display WPS status.
Signed-off-by: n-itaya <[email protected]>
---
src/connman.h | 6 ++++++
src/error.c | 16 ++++++++++++++++
src/peer.c | 5 ++---
src/service.c | 21 +++++++++++++++++++++
4 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/src/connman.h b/src/connman.h
index 82e77d37..16ecbb5a 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -54,6 +54,8 @@ DBusMessage *__connman_error_operation_aborted(DBusMessage
*msg);
DBusMessage *__connman_error_operation_timeout(DBusMessage *msg);
DBusMessage *__connman_error_invalid_service(DBusMessage *msg);
DBusMessage *__connman_error_invalid_property(DBusMessage *msg);
+DBusMessage *__connman_error_pin_rejected(DBusMessage *msg);
+DBusMessage *__connman_error_pbc_overlap(DBusMessage *msg);
int __connman_manager_init(void);
void __connman_manager_cleanup(void);
@@ -665,6 +667,8 @@ int __connman_service_init(void);
void __connman_service_cleanup(void);
int __connman_service_load_modifiable(struct connman_service *service);
+void __connman_service_append_struct(struct connman_service *service,
+ DBusMessageIter *iter);
void __connman_service_list_struct(DBusMessageIter *iter);
int __connman_service_compare(const struct connman_service *a,
@@ -843,6 +847,7 @@ int __connman_peer_service_unregister(const char *owner,
int specification_length,
const unsigned char *query,
int query_length, int version);
+enum connman_peer_wps_method __connman_check_wps_method(const char *wpspin);
#include <connman/session.h>
@@ -853,6 +858,7 @@ int __connman_service_iterate_services(service_iterate_cb
cb, void *user_data);
void __connman_service_mark_dirty();
void __connman_service_save(struct connman_service *service);
+void __connman_service_force_save(struct connman_service *service);
#include <connman/notifier.h>
diff --git a/src/error.c b/src/error.c
index 4f24ae25..f0b35bdc 100644
--- a/src/error.c
+++ b/src/error.c
@@ -67,6 +67,10 @@ DBusMessage *__connman_error_failed(DBusMessage *msg, int
errnum)
return __connman_error_in_progress(msg);
case ENOKEY:
return __connman_error_passphrase_required(msg);
+ case EKEYREJECTED:
+ return __connman_error_pin_rejected(msg);
+ case EAGAIN:
+ return __connman_error_pbc_overlap(msg);
}
return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
@@ -185,3 +189,15 @@ DBusMessage *__connman_error_invalid_property(DBusMessage
*msg)
return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
".InvalidProperty", "Invalid property");
}
+
+DBusMessage *__connman_error_pin_rejected(DBusMessage *msg)
+{
+ return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
+ ".PinRejected", "PIN Rejected");
+}
+
+DBusMessage *__connman_error_pbc_overlap(DBusMessage *msg)
+{
+ return g_dbus_create_error(msg, CONNMAN_ERROR_INTERFACE
+ ".PbcOverlap", "PBC Overlap");
+}
diff --git a/src/peer.c b/src/peer.c
index 1b9b80e3..70ffeab4 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -545,8 +545,7 @@ static const char *get_dbus_sender(struct connman_peer
*peer)
return dbus_message_get_sender(peer->pending);
}
-static enum connman_peer_wps_method check_wpspin(struct connman_peer *peer,
- const char *wpspin)
+enum connman_peer_wps_method __connman_check_wps_method(const char *wpspin)
{
int len, i;
@@ -591,7 +590,7 @@ static void request_authorization_cb(struct connman_peer
*peer,
goto out;
}
- wps_method = check_wpspin(peer, wpspin);
+ wps_method = __connman_check_wps_method(wpspin);
err = peer_driver->connect(peer, wps_method, wpspin);
if (err == -EINPROGRESS)
diff --git a/src/service.c b/src/service.c
index 733c0728..da323d0d 100644
--- a/src/service.c
+++ b/src/service.c
@@ -817,6 +817,15 @@ void __connman_service_save(struct connman_service
*service)
service_save(service);
}
+void __connman_service_force_save(struct connman_service *service)
+{
+ if (!service)
+ return;
+
+ service->new_service = false;
+ service_save(service);
+}
+
static enum connman_service_state combine_state(
enum connman_service_state state_a,
enum connman_service_state state_b)
@@ -2577,6 +2586,18 @@ static void append_struct(gpointer value, gpointer
user_data)
append_struct_service(iter, append_dict_properties, service);
}
+void __connman_service_append_struct(struct connman_service *service,
+ DBusMessageIter *iter)
+{
+ if (!service)
+ return;
+
+ if (!iter)
+ return;
+
+ append_struct(service, iter);
+}
+
void __connman_service_list_struct(DBusMessageIter *iter)
{
g_list_foreach(service_list, append_struct, iter);
--
2.17.1
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 36, Issue 12
***************************************