summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/supplicant-dbus.c12
-rw-r--r--tools/supplicant-test.c24
-rw-r--r--tools/supplicant.c102
-rw-r--r--tools/supplicant.h6
4 files changed, 133 insertions, 11 deletions
diff --git a/tools/supplicant-dbus.c b/tools/supplicant-dbus.c
index 79e75603..95da1d9d 100644
--- a/tools/supplicant-dbus.c
+++ b/tools/supplicant-dbus.c
@@ -298,13 +298,11 @@ static void method_call_reply(DBusPendingCall *call, void *user_data)
else
error = NULL;
- if (dbus_message_iter_init(reply, &iter) == FALSE)
- goto done;
+ dbus_message_iter_init(reply, &iter);
if (data->function != NULL)
data->function(error, &iter, data->user_data);
-done:
dbus_message_unref(reply);
dbus_pending_call_unref(call);
@@ -324,10 +322,7 @@ int supplicant_dbus_method_call(const char *path,
if (connection == NULL)
return -EINVAL;
- if (path == NULL || interface == NULL)
- return -EINVAL;
-
- if (method == NULL || setup == NULL)
+ if (path == NULL || interface == NULL || method == NULL)
return -EINVAL;
data = dbus_malloc0(sizeof(*data));
@@ -344,7 +339,8 @@ int supplicant_dbus_method_call(const char *path,
dbus_message_set_auto_start(message, FALSE);
dbus_message_iter_init_append(message, &iter);
- setup(&iter, user_data);
+ if (setup != NULL)
+ setup(&iter, user_data);
if (dbus_connection_send_with_reply(connection, message,
&call, TIMEOUT) == FALSE) {
diff --git a/tools/supplicant-test.c b/tools/supplicant-test.c
index 87dff6fe..53d058f6 100644
--- a/tools/supplicant-test.c
+++ b/tools/supplicant-test.c
@@ -51,7 +51,7 @@ static void system_ready(void)
{
DBG("*");
- supplicant_interface_create("wlan0", "nl80211",
+ supplicant_interface_create("wlan0", "nl80211,wext",
create_callback, NULL);
}
@@ -63,8 +63,12 @@ static void system_killed(void)
static void interface_added(struct supplicant_interface *interface)
{
const char *ifname = supplicant_interface_get_ifname(interface);
+ const char *driver = supplicant_interface_get_driver(interface);
- DBG("* ifname %s", ifname);
+ DBG("* ifname %s driver %s", ifname, driver);
+
+ if (supplicant_interface_scan(interface) < 0)
+ DBG("scan failed");
}
static void interface_removed(struct supplicant_interface *interface)
@@ -74,6 +78,20 @@ static void interface_removed(struct supplicant_interface *interface)
DBG("* ifname %s", ifname);
}
+static void scan_started(struct supplicant_interface *interface)
+{
+ const char *ifname = supplicant_interface_get_ifname(interface);
+
+ DBG("* ifname %s", ifname);
+}
+
+static void scan_finished(struct supplicant_interface *interface)
+{
+ const char *ifname = supplicant_interface_get_ifname(interface);
+
+ DBG("* ifname %s", ifname);
+}
+
static void network_added(struct supplicant_network *network)
{
const char *name = supplicant_network_get_name(network);
@@ -95,6 +113,8 @@ static const struct supplicant_callbacks callbacks = {
.system_killed = system_killed,
.interface_added = interface_added,
.interface_removed = interface_removed,
+ .scan_started = scan_started,
+ .scan_finished = scan_finished,
.network_added = network_added,
.network_removed = network_removed,
};
diff --git a/tools/supplicant.c b/tools/supplicant.c
index 7a1d0a48..c2120991 100644
--- a/tools/supplicant.c
+++ b/tools/supplicant.c
@@ -71,6 +71,7 @@ static struct strvalmap eap_method_map[] = {
{ "GTC", SUPPLICANT_EAP_METHOD_GTC },
{ "OTP", SUPPLICANT_EAP_METHOD_OTP },
{ "LEAP", SUPPLICANT_EAP_METHOD_LEAP },
+ { "WSC", SUPPLICANT_EAP_METHOD_WSC },
{ }
};
@@ -294,6 +295,28 @@ static void callback_interface_removed(struct supplicant_interface *interface)
callbacks_pointer->interface_removed(interface);
}
+static void callback_scan_started(struct supplicant_interface *interface)
+{
+ if (callbacks_pointer == NULL)
+ return;
+
+ if (callbacks_pointer->scan_started == NULL)
+ return;
+
+ callbacks_pointer->scan_started(interface);
+}
+
+static void callback_scan_finished(struct supplicant_interface *interface)
+{
+ if (callbacks_pointer == NULL)
+ return;
+
+ if (callbacks_pointer->scan_finished == NULL)
+ return;
+
+ callbacks_pointer->scan_finished(interface);
+}
+
static void callback_network_added(struct supplicant_network *network)
{
if (callbacks_pointer == NULL)
@@ -523,6 +546,14 @@ const char *supplicant_interface_get_ifname(struct supplicant_interface *interfa
return interface->ifname;
}
+const char *supplicant_interface_get_driver(struct supplicant_interface *interface)
+{
+ if (interface == NULL)
+ return NULL;
+
+ return interface->driver;
+}
+
struct supplicant_interface *supplicant_network_get_interface(struct supplicant_network *network)
{
if (network == NULL)
@@ -583,6 +614,8 @@ static void interface_network_added(DBusMessageIter *iter, void *user_data)
return;
}
+ DBG("path %s", path);
+
supplicant_dbus_property_get_all(path,
SUPPLICANT_INTERFACE ".Interface.Network",
network_property, NULL);
@@ -979,8 +1012,13 @@ static void interface_property(const char *key, DBusMessageIter *iter,
dbus_message_iter_get_basic(iter, &scanning);
interface->scanning = scanning;
+
+ DBG("scanning %u", interface->scanning);
+
+ if (interface->scanning == TRUE)
+ callback_scan_started(interface);
} else if (g_strcmp0(key, "ApScan") == 0) {
- int apscan;
+ int apscan = 1;
dbus_message_iter_get_basic(iter, &apscan);
interface->apscan = apscan;
@@ -1201,6 +1239,20 @@ static void signal_interface_removed(const char *path, DBusMessageIter *iter)
interface_removed(iter, NULL);
}
+static void signal_scan_done(const char *path, DBusMessageIter *iter)
+{
+ struct supplicant_interface *interface;
+ dbus_bool_t success = FALSE;
+
+ interface = g_hash_table_lookup(interface_table, path);
+ if (interface == NULL)
+ return;
+
+ dbus_message_iter_get_basic(iter, &success);
+
+ callback_scan_finished(interface);
+}
+
static void signal_bss_added(const char *path, DBusMessageIter *iter)
{
struct supplicant_interface *interface;
@@ -1257,6 +1309,7 @@ static struct {
{ SUPPLICANT_INTERFACE, "InterfaceCreated", signal_interface_added },
{ SUPPLICANT_INTERFACE, "InterfaceRemoved", signal_interface_removed },
+ { SUPPLICANT_INTERFACE ".Interface", "ScanDone", signal_scan_done },
{ SUPPLICANT_INTERFACE ".Interface", "BSSAdded", signal_bss_added },
{ SUPPLICANT_INTERFACE ".Interface", "BSSRemoved", signal_bss_removed },
{ SUPPLICANT_INTERFACE ".Interface", "NetworkAdded", signal_network_added },
@@ -1598,3 +1651,50 @@ int supplicant_interface_remove(struct supplicant_interface *interface,
return 0;
}
+
+static void interface_scan_result(const char *error,
+ DBusMessageIter *iter, void *user_data)
+{
+ DBG("error %s", error);
+}
+
+static void interface_scan_params(DBusMessageIter *iter, void *user_data)
+{
+ DBusMessageIter dict;
+ const char *type = "passive";
+
+ DBG("");
+
+ supplicant_dbus_dict_open(iter, &dict);
+
+ supplicant_dbus_dict_append_basic(&dict, "Type",
+ DBUS_TYPE_STRING, &type);
+
+ supplicant_dbus_dict_close(iter, &dict);
+}
+
+int supplicant_interface_scan(struct supplicant_interface *interface)
+{
+ if (system_available == FALSE)
+ return -EFAULT;
+
+ return supplicant_dbus_method_call(interface->path,
+ SUPPLICANT_INTERFACE ".Interface", "Scan",
+ interface_scan_params, interface_scan_result, NULL);
+}
+
+static void interface_disconnect_result(const char *error,
+ DBusMessageIter *iter, void *user_data)
+{
+ DBG("error %s", error);
+}
+
+int supplicant_interface_disconnect(struct supplicant_interface *interface)
+{
+ if (system_available == FALSE)
+ return -EFAULT;
+
+ return supplicant_dbus_method_call(interface->path,
+ SUPPLICANT_INTERFACE ".Interface", "Disconnect",
+ NULL, interface_disconnect_result, NULL);
+}
diff --git a/tools/supplicant.h b/tools/supplicant.h
index 73f6d515..36757422 100644
--- a/tools/supplicant.h
+++ b/tools/supplicant.h
@@ -27,6 +27,7 @@
#define SUPPLICANT_EAP_METHOD_GTC (1 << 5)
#define SUPPLICANT_EAP_METHOD_OTP (1 << 6)
#define SUPPLICANT_EAP_METHOD_LEAP (1 << 7)
+#define SUPPLICANT_EAP_METHOD_WSC (1 << 8)
#define SUPPLICANT_CAPABILITY_KEYMGMT_NONE (1 << 0)
#define SUPPLICANT_CAPABILITY_KEYMGMT_IEEE8021X (1 << 1)
@@ -100,8 +101,11 @@ int supplicant_interface_create(const char *ifname, const char *driver,
int supplicant_interface_remove(struct supplicant_interface *interface,
supplicant_interface_remove_callback callback,
void *user_data);
+int supplicant_interface_scan(struct supplicant_interface *interface);
+int supplicant_interface_disconnect(struct supplicant_interface *interface);
const char *supplicant_interface_get_ifname(struct supplicant_interface *interface);
+const char *supplicant_interface_get_driver(struct supplicant_interface *interface);
struct supplicant_network;
@@ -115,6 +119,8 @@ struct supplicant_callbacks {
void (*system_killed) (void);
void (*interface_added) (struct supplicant_interface *interface);
void (*interface_removed) (struct supplicant_interface *interface);
+ void (*scan_started) (struct supplicant_interface *interface);
+ void (*scan_finished) (struct supplicant_interface *interface);
void (*network_added) (struct supplicant_network *network);
void (*network_removed) (struct supplicant_network *network);
};