#endif
#include <errno.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <glib.h>
#include <gdbus.h>
-#define CONNMAN_API_SUBJECT_TO_CHANGE
-#include <connman/log.h>
-
#include "dbus.h"
#include "gsupplicant.h"
dbus_bool_t ieee8021x;
};
+static inline void debug(const char *format, ...)
+{
+ char str[256];
+ va_list ap;
+
+ if (callbacks_pointer->debug == NULL)
+ return;
+
+ va_start(ap, format);
+
+ if (vsnprintf(str, sizeof(str), format, ap) > 0)
+ callbacks_pointer->debug(str);
+
+ va_end(ap);
+}
+
static GSupplicantMode string2mode(const char *mode)
{
if (mode == NULL)
static void callback_interface_added(GSupplicantInterface *interface)
{
- DBG("");
+ debug("");
if (callbacks_pointer == NULL)
return;
for (i = 0; map[i].str != NULL; i++) {
if (val & map[i].val)
- DBG("%s: %s", label, map[i].str);
+ debug("%s: %s", label, map[i].str);
}
}
supplicant_dbus_array_foreach(iter,
interface_capability_mode, interface);
else
- DBG("key %s type %c",
+ debug("key %s type %c",
key, dbus_message_iter_get_arg_type(iter));
}
mode = g_hash_table_lookup(network->config_table, "mode");
key_mgmt = g_hash_table_lookup(network->config_table, "key_mgmt");
- DBG("ssid %s mode %s", ssid, mode);
+ debug("ssid %s mode %s", ssid, mode);
if (ssid != NULL)
ssid_len = strlen(ssid);
group = g_string_free(str, FALSE);
- DBG("%s", group);
+ debug("%s", group);
g_free(group);
g_strdup(key), g_strdup(str));
}
} else
- DBG("key %s type %c",
+ debug("key %s type %c",
key, dbus_message_iter_get_arg_type(iter));
}
GSupplicantNetwork *network;
const char *path = NULL;
- DBG("");
+ debug("");
dbus_message_iter_get_basic(iter, &path);
if (path == NULL)
if (bss->interface == NULL)
return;
- DBG("key %s", key);
+ debug("key %s", key);
if (key == NULL) {
if (bss->ieee8021x == TRUE)
G_SUPPLICANT_KEYMGMT_WPA_PSK_256))
bss->psk = TRUE;
} else
- DBG("key %s type %c",
+ debug("key %s type %c",
key, dbus_message_iter_get_arg_type(iter));
}
struct g_supplicant_bss *bss;
const char *path = NULL;
- DBG("");
+ debug("");
dbus_message_iter_get_basic(iter, &path);
if (path == NULL)
if (g_strcmp0(path, "/") == 0)
return;
- DBG("%s", path);
+ debug("%s", path);
network = g_hash_table_lookup(interface->bss_mapping, path);
if (network != NULL) {
if (interface == NULL)
return;
- DBG("%s", key);
+ debug("%s", key);
if (key == NULL) {
debug_strvalmap("KeyMgmt capability", keymgmt_map,
callback_interface_state(interface);
}
- DBG("state %s (%d)", str, interface->state);
+ debug("state %s (%d)", str, interface->state);
} else if (g_strcmp0(key, "Scanning") == 0) {
dbus_bool_t scanning = FALSE;
supplicant_dbus_array_foreach(iter, interface_network_added,
interface);
} else
- DBG("key %s type %c",
+ debug("key %s type %c",
key, dbus_message_iter_get_arg_type(iter));
}
GSupplicantInterface *interface;
const char *path = NULL;
- DBG("");
+ debug("");
dbus_message_iter_get_basic(iter, &path);
if (path == NULL)
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INVALID) {
supplicant_dbus_property_foreach(iter, interface_property,
interface);
- DBG("NULL prop");
interface_property(NULL, NULL, interface);
- DBG("DONE");
return;
}
debug_level = i;
break;
}
- DBG("Debug level %d", debug_level);
+ debug("Debug level %d", debug_level);
} else if (g_strcmp0(key, "DebugTimestamp") == 0) {
dbus_message_iter_get_basic(iter, &debug_timestamp);
- DBG("Debug timestamp %u", debug_timestamp);
+ debug("Debug timestamp %u", debug_timestamp);
} else if (g_strcmp0(key, "DebugShowKeys") == 0) {
dbus_message_iter_get_basic(iter, &debug_showkeys);
- DBG("Debug show keys %u", debug_showkeys);
+ debug("Debug show keys %u", debug_showkeys);
} else if (g_strcmp0(key, "Interfaces") == 0) {
supplicant_dbus_array_foreach(iter, interface_added, NULL);
} else if (g_strcmp0(key, "EapMethods") == 0) {
supplicant_dbus_array_foreach(iter, eap_method, NULL);
debug_strvalmap("EAP method", eap_method_map, eap_methods);
} else
- DBG("key %s type %c",
+ debug("key %s type %c",
key, dbus_message_iter_get_arg_type(iter));
}
{
const char *name = NULL, *old = NULL, *new = NULL;
- DBG("");
+ debug("");
if (g_strcmp0(path, DBUS_PATH_DBUS) != 0)
return;
static void signal_properties_changed(const char *path, DBusMessageIter *iter)
{
- DBG("");
+ debug("");
if (g_strcmp0(path, SUPPLICANT_PATH) != 0)
return;
static void signal_interface_added(const char *path, DBusMessageIter *iter)
{
- DBG("path %s %s", path, SUPPLICANT_PATH);
+ debug("path %s %s", path, SUPPLICANT_PATH);
if (g_strcmp0(path, SUPPLICANT_PATH) == 0)
interface_added(iter, NULL);
static void signal_interface_removed(const char *path, DBusMessageIter *iter)
{
- DBG("");
+ debug("");
if (g_strcmp0(path, SUPPLICANT_PATH) == 0)
interface_removed(iter, NULL);
{
GSupplicantInterface *interface;
- DBG("");
+ debug("");
interface = g_hash_table_lookup(interface_table, path);
if (interface == NULL)
GSupplicantInterface *interface;
dbus_bool_t success = FALSE;
- DBG("");
+ debug("");
interface = g_hash_table_lookup(interface_table, path);
if (interface == NULL)
{
GSupplicantInterface *interface;
- DBG("");
+ debug("");
interface = g_hash_table_lookup(interface_table, path);
if (interface == NULL)
{
GSupplicantInterface *interface;
- DBG("");
+ debug("");
interface = g_hash_table_lookup(interface_table, path);
if (interface == NULL)
{
GSupplicantInterface *interface;
- DBG("");
+ debug("");
interface = g_hash_table_lookup(interface_table, path);
if (interface == NULL)
{
GSupplicantInterface *interface;
- DBG("");
+ debug("");
interface = g_hash_table_lookup(interface_table, path);
if (interface == NULL)
GSupplicantNetwork *network;
struct g_supplicant_bss *bss;
- DBG("");
+ debug("");
interface = g_hash_table_lookup(bss_mapping, path);
if (interface == NULL)
const char *path = NULL;
int err;
- DBG("");
+ debug("");
if (error != NULL) {
- connman_error("error %s", error);
+ g_critical("error %s", error);
err = -EIO;
goto done;
}
struct interface_create_data *data = user_data;
DBusMessageIter dict;
- DBG("");
+ debug("");
supplicant_dbus_dict_open(iter, &dict);
const char *path = NULL;
int err;
- DBG("");
+ debug("");
if (error != NULL) {
- connman_error("error %s", error);
+ g_warning("error %s", error);
err = -EIO;
goto create;
}
goto done;
}
- DBG("Creating interface");
+ debug("Creating interface");
err = supplicant_dbus_method_call(SUPPLICANT_PATH,
SUPPLICANT_INTERFACE,
{
struct interface_create_data *data = user_data;
- DBG("");
+ debug("");
dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &data->ifname);
}
{
struct interface_create_data *data;
- DBG("ifname %s", ifname);
+ debug("ifname %s", ifname);
if (ifname == NULL)
return -EINVAL;
static void interface_select_network_result(const char *error,
DBusMessageIter *iter, void *user_data)
{
- DBG("");
+ debug("");
}
static void interface_select_network_params(DBusMessageIter *iter,
if (path == NULL)
goto done;
- DBG("PATH: %s", path);
+ debug("PATH: %s", path);
supplicant_dbus_method_call(data->interface->path,
SUPPLICANT_INTERFACE ".Interface", "SelectNetwork",
struct interface_data *data = user_data;
int result = 0;
- DBG("");
+ debug("");
if (error != NULL)
result = -EIO;
{
struct interface_data *data;
- DBG("");
+ debug("");
if (interface == NULL)
return -EINVAL;
int g_supplicant_register(const GSupplicantCallbacks *callbacks)
{
- DBG("");
-
connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
if (connection == NULL)
return -EIO;
void g_supplicant_unregister(const GSupplicantCallbacks *callbacks)
{
- DBG("");
+ debug("");
if (connection != NULL) {
dbus_bus_remove_match(connection, g_supplicant_rule6, NULL);