summaryrefslogtreecommitdiff
path: root/gsupplicant
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@nokia.com>2011-01-26 10:09:33 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2011-01-27 12:12:14 +0100
commitbeec5f11ed9c7d343d56bc29638196051a308217 (patch)
treeb51e7f77a4b292b59f7c790f7fcf7f97c6331f3d /gsupplicant
parentda4e20faacfb86123b53c6b723408e1141f09f8c (diff)
downloadconnman-beec5f11ed9c7d343d56bc29638196051a308217.tar.gz
connman-beec5f11ed9c7d343d56bc29638196051a308217.tar.bz2
connman-beec5f11ed9c7d343d56bc29638196051a308217.zip
gsupplicant: WPS start() method implementation
Diffstat (limited to 'gsupplicant')
-rw-r--r--gsupplicant/gsupplicant.h2
-rw-r--r--gsupplicant/supplicant.c82
2 files changed, 83 insertions, 1 deletions
diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index 05f5c358..0df86408 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -116,6 +116,8 @@ struct _GSupplicantSSID {
const char *private_key_path;
const char *private_key_passphrase;
const char *phase2_auth;
+ dbus_bool_t use_wps;
+ const char *pin_wps;
};
typedef struct _GSupplicantSSID GSupplicantSSID;
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index a3349b35..bed049aa 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -2672,6 +2672,75 @@ static void interface_add_network_params(DBusMessageIter *iter, void *user_data)
supplicant_dbus_dict_close(iter, &dict);
}
+static void interface_wps_start_result(const char *error,
+ DBusMessageIter *iter, void *user_data)
+{
+ struct interface_connect_data *data = user_data;
+
+ SUPPLICANT_DBG("");
+ if (error != NULL)
+ SUPPLICANT_DBG("error: %s", error);
+
+ g_free(data->ssid);
+ dbus_free(data);
+}
+
+static void interface_add_wps_params(DBusMessageIter *iter, void *user_data)
+{
+ struct interface_connect_data *data = user_data;
+ GSupplicantSSID *ssid = data->ssid;
+ const char *role = "enrollee", *type;
+ DBusMessageIter dict;
+
+ SUPPLICANT_DBG("");
+
+ supplicant_dbus_dict_open(iter, &dict);
+
+ supplicant_dbus_dict_append_basic(&dict, "Role",
+ DBUS_TYPE_STRING, &role);
+
+ type = "pbc";
+ if (ssid->pin_wps != NULL) {
+ type = "pin";
+ supplicant_dbus_dict_append_basic(&dict, "Pin",
+ DBUS_TYPE_STRING, &ssid->pin_wps);
+ }
+
+ supplicant_dbus_dict_append_basic(&dict, "Type",
+ DBUS_TYPE_STRING, &type);
+
+ supplicant_dbus_dict_close(iter, &dict);
+}
+
+static void wps_start(const char *error, DBusMessageIter *iter, void *user_data)
+{
+ struct interface_connect_data *data = user_data;
+
+ SUPPLICANT_DBG("");
+
+ if (error != NULL) {
+ SUPPLICANT_DBG("error: %s", error);
+ g_free(data->ssid);
+ dbus_free(data);
+ return;
+ }
+
+ supplicant_dbus_method_call(data->interface->path,
+ SUPPLICANT_INTERFACE ".Interface.WPS", "Start",
+ interface_add_wps_params,
+ interface_wps_start_result, data);
+}
+
+static void wps_process_credentials(DBusMessageIter *iter, void *user_data)
+{
+ dbus_bool_t credentials = TRUE;
+
+ SUPPLICANT_DBG("");
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &credentials);
+}
+
+
int g_supplicant_interface_connect(GSupplicantInterface *interface,
GSupplicantSSID *ssid,
GSupplicantInterfaceCallback callback,
@@ -2697,10 +2766,21 @@ int g_supplicant_interface_connect(GSupplicantInterface *interface,
data->ssid = ssid;
data->user_data = user_data;
- ret = supplicant_dbus_method_call(interface->path,
+ if (ssid->use_wps == TRUE) {
+ g_free(interface->wps_cred.key);
+ memset(&interface->wps_cred, 0,
+ sizeof(struct _GSupplicantWpsCredentials));
+
+ ret = supplicant_dbus_property_set(interface->path,
+ SUPPLICANT_INTERFACE ".Interface.WPS",
+ "ProcessCredentials", DBUS_TYPE_BOOLEAN_AS_STRING,
+ wps_process_credentials, wps_start, data);
+ } else
+ ret = supplicant_dbus_method_call(interface->path,
SUPPLICANT_INTERFACE ".Interface", "AddNetwork",
interface_add_network_params,
interface_add_network_result, data);
+
if (ret < 0)
return ret;