D-Bus: Coding style cleanup

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-12-31 23:21:10 +02:00
parent e3c4f0b5d5
commit 38279bdb35
17 changed files with 636 additions and 630 deletions

View file

@ -165,6 +165,7 @@ static void process_timeout(void *eloop_ctx, void *sock_ctx)
static dbus_bool_t add_timeout(DBusTimeout *timeout, void *data) static dbus_bool_t add_timeout(DBusTimeout *timeout, void *data)
{ {
struct wpas_dbus_priv *priv = data; struct wpas_dbus_priv *priv = data;
if (!dbus_timeout_get_enabled(timeout)) if (!dbus_timeout_get_enabled(timeout))
return TRUE; return TRUE;
@ -180,6 +181,7 @@ static dbus_bool_t add_timeout(DBusTimeout *timeout, void *data)
static void remove_timeout(DBusTimeout *timeout, void *data) static void remove_timeout(DBusTimeout *timeout, void *data)
{ {
struct wpas_dbus_priv *priv = data; struct wpas_dbus_priv *priv = data;
eloop_cancel_timeout(process_timeout, priv, timeout); eloop_cancel_timeout(process_timeout, priv, timeout);
dbus_timeout_set_data(timeout, NULL, NULL); dbus_timeout_set_data(timeout, NULL, NULL);
} }
@ -244,8 +246,7 @@ static int integrate_with_eloop(struct wpas_dbus_priv *priv)
remove_timeout, remove_timeout,
timeout_toggled, priv, timeout_toggled, priv,
NULL)) { NULL)) {
wpa_printf(MSG_ERROR, "dbus: Failed to set callback " wpa_printf(MSG_ERROR, "dbus: Failed to set callback functions");
"functions");
return -1; return -1;
} }
@ -286,8 +287,9 @@ static int wpas_dbus_init_common(struct wpas_dbus_priv *priv)
dbus_connection_add_filter(priv->con, disconnect_filter, priv, dbus_connection_add_filter(priv->con, disconnect_filter, priv,
NULL); NULL);
} else { } else {
wpa_printf(MSG_ERROR, "dbus: Could not acquire the system " wpa_printf(MSG_ERROR,
"bus: %s - %s", error.name, error.message); "dbus: Could not acquire the system bus: %s - %s",
error.name, error.message);
ret = -1; ret = -1;
} }
dbus_error_free(&error); dbus_error_free(&error);

View file

@ -711,10 +711,9 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_byte_array(
BYTE_ARRAY_ITEM_SIZE); BYTE_ARRAY_ITEM_SIZE);
if (nbuffer == NULL) { if (nbuffer == NULL) {
os_free(buffer); os_free(buffer);
wpa_printf(MSG_ERROR, "dbus: _wpa_dbus_dict_" wpa_printf(MSG_ERROR,
"entry_get_byte_array out of " "dbus: %s out of memory trying to retrieve the string array",
"memory trying to retrieve the " __func__);
"string array");
goto done; goto done;
} }
buffer = nbuffer; buffer = nbuffer;
@ -772,10 +771,9 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_string_array(
STR_ARRAY_ITEM_SIZE); STR_ARRAY_ITEM_SIZE);
if (nbuffer == NULL) { if (nbuffer == NULL) {
os_free(buffer); os_free(buffer);
wpa_printf(MSG_ERROR, "dbus: _wpa_dbus_dict_" wpa_printf(MSG_ERROR,
"entry_get_string_array out of " "dbus: %s out of memory trying to retrieve the string array",
"memory trying to retrieve the " __func__);
"string array");
goto done; goto done;
} }
buffer = nbuffer; buffer = nbuffer;
@ -787,9 +785,9 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_string_array(
__func__, wpa_debug_show_keys ? value : "[omitted]"); __func__, wpa_debug_show_keys ? value : "[omitted]");
str = os_strdup(value); str = os_strdup(value);
if (str == NULL) { if (str == NULL) {
wpa_printf(MSG_ERROR, "dbus: _wpa_dbus_dict_entry_get_" wpa_printf(MSG_ERROR,
"string_array out of memory trying to " "dbus: %s out of memory trying to duplicate the string array",
"duplicate the string array"); __func__);
goto done; goto done;
} }
entry->strarray_value[count] = str; entry->strarray_value[count] = str;

View file

@ -75,8 +75,7 @@ static DBusHandlerResult noc_filter(DBusConnection *conn,
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
} }
for (wpa_s = priv->global->ifaces; wpa_s; wpa_s = wpa_s->next) for (wpa_s = priv->global->ifaces; wpa_s; wpa_s = wpa_s->next) {
{
if (wpa_s->preq_notify_peer != NULL && if (wpa_s->preq_notify_peer != NULL &&
os_strcmp(name, wpa_s->preq_notify_peer) == 0 && os_strcmp(name, wpa_s->preq_notify_peer) == 0 &&
(new_owner == NULL || os_strlen(new_owner) == 0)) { (new_owner == NULL || os_strlen(new_owner) == 0)) {
@ -511,6 +510,7 @@ void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s,
{ {
char path[WPAS_DBUS_OBJECT_PATH_MAX]; char path[WPAS_DBUS_OBJECT_PATH_MAX];
os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX, os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
"%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%d", "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%d",
wpa_s->dbus_new_path, ssid->id); wpa_s->dbus_new_path, ssid->id);
@ -1537,6 +1537,7 @@ void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
DBusMessageIter iter, dict_iter; DBusMessageIter iter, dict_iter;
struct wpas_dbus_priv *iface; struct wpas_dbus_priv *iface;
char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path; char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
iface = wpa_s->global->dbus; iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */ /* Do nothing if the control interface is not turned on */
@ -1602,6 +1603,7 @@ void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
DBusMessageIter iter, dict_iter; DBusMessageIter iter, dict_iter;
struct wpas_dbus_priv *iface; struct wpas_dbus_priv *iface;
char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path; char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
iface = wpa_s->global->dbus; iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */ /* Do nothing if the control interface is not turned on */
@ -1970,7 +1972,7 @@ static void wpas_dbus_register(struct wpa_dbus_object_desc *obj_desc,
static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = { static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
{ "CreateInterface", WPAS_DBUS_NEW_INTERFACE, { "CreateInterface", WPAS_DBUS_NEW_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_create_interface, (WPADBusMethodHandler) wpas_dbus_handler_create_interface,
{ {
{ "args", "a{sv}", ARG_IN }, { "args", "a{sv}", ARG_IN },
{ "path", "o", ARG_OUT }, { "path", "o", ARG_OUT },
@ -1978,14 +1980,14 @@ static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
} }
}, },
{ "RemoveInterface", WPAS_DBUS_NEW_INTERFACE, { "RemoveInterface", WPAS_DBUS_NEW_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_remove_interface, (WPADBusMethodHandler) wpas_dbus_handler_remove_interface,
{ {
{ "path", "o", ARG_IN }, { "path", "o", ARG_IN },
END_ARGS END_ARGS
} }
}, },
{ "GetInterface", WPAS_DBUS_NEW_INTERFACE, { "GetInterface", WPAS_DBUS_NEW_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_get_interface, (WPADBusMethodHandler) wpas_dbus_handler_get_interface,
{ {
{ "ifname", "s", ARG_IN }, { "ifname", "s", ARG_IN },
{ "path", "o", ARG_OUT }, { "path", "o", ARG_OUT },
@ -2077,8 +2079,8 @@ int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv)
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc)); obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
if (!obj_desc) { if (!obj_desc) {
wpa_printf(MSG_ERROR, "Not enough memory " wpa_printf(MSG_ERROR,
"to create object description"); "Not enough memory to create object description");
return -1; return -1;
} }
@ -2192,16 +2194,16 @@ int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
net_obj_path); net_obj_path);
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc)); obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
if (!obj_desc) { if (!obj_desc) {
wpa_printf(MSG_ERROR, "Not enough memory " wpa_printf(MSG_ERROR,
"to create object description"); "Not enough memory to create object description");
goto err; goto err;
} }
/* allocate memory for handlers arguments */ /* allocate memory for handlers arguments */
arg = os_zalloc(sizeof(struct network_handler_args)); arg = os_zalloc(sizeof(struct network_handler_args));
if (!arg) { if (!arg) {
wpa_printf(MSG_ERROR, "Not enough memory " wpa_printf(MSG_ERROR,
"to create arguments for method"); "Not enough memory to create arguments for method");
goto err; goto err;
} }
@ -2407,15 +2409,15 @@ int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc)); obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
if (!obj_desc) { if (!obj_desc) {
wpa_printf(MSG_ERROR, "Not enough memory " wpa_printf(MSG_ERROR,
"to create object description"); "Not enough memory to create object description");
goto err; goto err;
} }
arg = os_zalloc(sizeof(struct bss_handler_args)); arg = os_zalloc(sizeof(struct bss_handler_args));
if (!arg) { if (!arg) {
wpa_printf(MSG_ERROR, "Not enough memory " wpa_printf(MSG_ERROR,
"to create arguments for handler"); "Not enough memory to create arguments for handler");
goto err; goto err;
} }
arg->wpa_s = wpa_s; arg->wpa_s = wpa_s;
@ -2448,27 +2450,27 @@ err:
static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = { static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
{ "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE, { "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_scan, (WPADBusMethodHandler) wpas_dbus_handler_scan,
{ {
{ "args", "a{sv}", ARG_IN }, { "args", "a{sv}", ARG_IN },
END_ARGS END_ARGS
} }
}, },
{ "SignalPoll", WPAS_DBUS_NEW_IFACE_INTERFACE, { "SignalPoll", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_signal_poll, (WPADBusMethodHandler) wpas_dbus_handler_signal_poll,
{ {
{ "args", "a{sv}", ARG_OUT }, { "args", "a{sv}", ARG_OUT },
END_ARGS END_ARGS
} }
}, },
{ "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE, { "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_disconnect, (WPADBusMethodHandler) wpas_dbus_handler_disconnect,
{ {
END_ARGS END_ARGS
} }
}, },
{ "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE, { "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_add_network, (WPADBusMethodHandler) wpas_dbus_handler_add_network,
{ {
{ "args", "a{sv}", ARG_IN }, { "args", "a{sv}", ARG_IN },
{ "path", "o", ARG_OUT }, { "path", "o", ARG_OUT },
@ -2476,39 +2478,39 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
} }
}, },
{ "Reassociate", WPAS_DBUS_NEW_IFACE_INTERFACE, { "Reassociate", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_reassociate, (WPADBusMethodHandler) wpas_dbus_handler_reassociate,
{ {
END_ARGS END_ARGS
} }
}, },
{ "Reattach", WPAS_DBUS_NEW_IFACE_INTERFACE, { "Reattach", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_reattach, (WPADBusMethodHandler) wpas_dbus_handler_reattach,
{ {
END_ARGS END_ARGS
} }
}, },
{ "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE, { "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_remove_network, (WPADBusMethodHandler) wpas_dbus_handler_remove_network,
{ {
{ "path", "o", ARG_IN }, { "path", "o", ARG_IN },
END_ARGS END_ARGS
} }
}, },
{ "RemoveAllNetworks", WPAS_DBUS_NEW_IFACE_INTERFACE, { "RemoveAllNetworks", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_remove_all_networks, (WPADBusMethodHandler) wpas_dbus_handler_remove_all_networks,
{ {
END_ARGS END_ARGS
} }
}, },
{ "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE, { "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_select_network, (WPADBusMethodHandler) wpas_dbus_handler_select_network,
{ {
{ "path", "o", ARG_IN }, { "path", "o", ARG_IN },
END_ARGS END_ARGS
} }
}, },
{ "NetworkReply", WPAS_DBUS_NEW_IFACE_INTERFACE, { "NetworkReply", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_network_reply, (WPADBusMethodHandler) wpas_dbus_handler_network_reply,
{ {
{ "path", "o", ARG_IN }, { "path", "o", ARG_IN },
{ "field", "s", ARG_IN }, { "field", "s", ARG_IN },
@ -2518,7 +2520,7 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
}, },
#ifndef CONFIG_NO_CONFIG_BLOBS #ifndef CONFIG_NO_CONFIG_BLOBS
{ "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE, { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_add_blob, (WPADBusMethodHandler) wpas_dbus_handler_add_blob,
{ {
{ "name", "s", ARG_IN }, { "name", "s", ARG_IN },
{ "data", "ay", ARG_IN }, { "data", "ay", ARG_IN },
@ -2526,7 +2528,7 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
} }
}, },
{ "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE, { "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_get_blob, (WPADBusMethodHandler) wpas_dbus_handler_get_blob,
{ {
{ "name", "s", ARG_IN }, { "name", "s", ARG_IN },
{ "data", "ay", ARG_OUT }, { "data", "ay", ARG_OUT },
@ -2534,7 +2536,7 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
} }
}, },
{ "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE, { "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_remove_blob, (WPADBusMethodHandler) wpas_dbus_handler_remove_blob,
{ {
{ "name", "s", ARG_IN }, { "name", "s", ARG_IN },
END_ARGS END_ARGS
@ -2543,7 +2545,7 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
#endif /* CONFIG_NO_CONFIG_BLOBS */ #endif /* CONFIG_NO_CONFIG_BLOBS */
{ "SetPKCS11EngineAndModulePath", WPAS_DBUS_NEW_IFACE_INTERFACE, { "SetPKCS11EngineAndModulePath", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) (WPADBusMethodHandler)
&wpas_dbus_handler_set_pkcs11_engine_and_module_path, wpas_dbus_handler_set_pkcs11_engine_and_module_path,
{ {
{ "pkcs11_engine_path", "s", ARG_IN }, { "pkcs11_engine_path", "s", ARG_IN },
{ "pkcs11_module_path", "s", ARG_IN }, { "pkcs11_module_path", "s", ARG_IN },
@ -2552,7 +2554,7 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
}, },
#ifdef CONFIG_WPS #ifdef CONFIG_WPS
{ "Start", WPAS_DBUS_NEW_IFACE_WPS, { "Start", WPAS_DBUS_NEW_IFACE_WPS,
(WPADBusMethodHandler) &wpas_dbus_handler_wps_start, (WPADBusMethodHandler) wpas_dbus_handler_wps_start,
{ {
{ "args", "a{sv}", ARG_IN }, { "args", "a{sv}", ARG_IN },
{ "output", "a{sv}", ARG_OUT }, { "output", "a{sv}", ARG_OUT },
@ -2723,7 +2725,7 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
}, },
#endif /* CONFIG_P2P */ #endif /* CONFIG_P2P */
{ "FlushBSS", WPAS_DBUS_NEW_IFACE_INTERFACE, { "FlushBSS", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_flush_bss, (WPADBusMethodHandler) wpas_dbus_handler_flush_bss,
{ {
{ "age", "u", ARG_IN }, { "age", "u", ARG_IN },
END_ARGS END_ARGS
@ -2744,20 +2746,20 @@ static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
}, },
#endif /* CONFIG_AP */ #endif /* CONFIG_AP */
{ "EAPLogoff", WPAS_DBUS_NEW_IFACE_INTERFACE, { "EAPLogoff", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_eap_logoff, (WPADBusMethodHandler) wpas_dbus_handler_eap_logoff,
{ {
END_ARGS END_ARGS
} }
}, },
{ "EAPLogon", WPAS_DBUS_NEW_IFACE_INTERFACE, { "EAPLogon", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_eap_logon, (WPADBusMethodHandler) wpas_dbus_handler_eap_logon,
{ {
END_ARGS END_ARGS
} }
}, },
#ifdef CONFIG_AUTOSCAN #ifdef CONFIG_AUTOSCAN
{ "AutoScan", WPAS_DBUS_NEW_IFACE_INTERFACE, { "AutoScan", WPAS_DBUS_NEW_IFACE_INTERFACE,
(WPADBusMethodHandler) &wpas_dbus_handler_autoscan, (WPADBusMethodHandler) wpas_dbus_handler_autoscan,
{ {
{ "arg", "s", ARG_IN }, { "arg", "s", ARG_IN },
END_ARGS END_ARGS
@ -3195,8 +3197,8 @@ int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc)); obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
if (!obj_desc) { if (!obj_desc) {
wpa_printf(MSG_ERROR, "Not enough memory " wpa_printf(MSG_ERROR,
"to create object description"); "Not enough memory to create object description");
goto err; goto err;
} }
@ -3432,16 +3434,16 @@ int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr)
peer_obj_path); peer_obj_path);
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc)); obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
if (!obj_desc) { if (!obj_desc) {
wpa_printf(MSG_ERROR, "Not enough memory " wpa_printf(MSG_ERROR,
"to create object description"); "Not enough memory to create object description");
goto err; goto err;
} }
/* allocate memory for handlers arguments */ /* allocate memory for handlers arguments */
arg = os_zalloc(sizeof(struct peer_handler_args)); arg = os_zalloc(sizeof(struct peer_handler_args));
if (!arg) { if (!arg) {
wpa_printf(MSG_ERROR, "Not enough memory " wpa_printf(MSG_ERROR,
"to create arguments for method"); "Not enough memory to create arguments for method");
goto err; goto err;
} }
@ -3616,8 +3618,8 @@ void wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
group_obj_path); group_obj_path);
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc)); obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
if (!obj_desc) { if (!obj_desc) {
wpa_printf(MSG_ERROR, "Not enough memory " wpa_printf(MSG_ERROR,
"to create object description"); "Not enough memory to create object description");
goto err; goto err;
} }
@ -3736,8 +3738,8 @@ int wpas_dbus_register_persistent_group(struct wpa_supplicant *wpa_s,
pgrp_obj_path); pgrp_obj_path);
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc)); obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
if (!obj_desc) { if (!obj_desc) {
wpa_printf(MSG_ERROR, "dbus: Not enough memory to create " wpa_printf(MSG_ERROR,
"object description"); "dbus: Not enough memory to create object description");
goto err; goto err;
} }
@ -3748,8 +3750,8 @@ int wpas_dbus_register_persistent_group(struct wpa_supplicant *wpa_s,
/* allocate memory for handlers arguments */ /* allocate memory for handlers arguments */
arg = os_zalloc(sizeof(struct network_handler_args)); arg = os_zalloc(sizeof(struct network_handler_args));
if (!arg) { if (!arg) {
wpa_printf(MSG_ERROR, "dbus: Not enough memory to create " wpa_printf(MSG_ERROR,
"arguments for method"); "dbus: Not enough memory to create arguments for method");
goto err; goto err;
} }

View file

@ -29,7 +29,7 @@
#include "dbus_common_i.h" #include "dbus_common_i.h"
#include "drivers/driver.h" #include "drivers/driver.h"
static const char *debug_strings[] = { static const char * const debug_strings[] = {
"excessive", "msgdump", "debug", "info", "warning", "error", NULL "excessive", "msgdump", "debug", "info", "warning", "error", NULL
}; };
@ -53,9 +53,9 @@ DBusMessage * wpas_dbus_error_unknown_error(DBusMessage *message,
* in this case, we should not call it. * in this case, we should not call it.
*/ */
if (message == NULL) { if (message == NULL) {
wpa_printf(MSG_INFO, "dbus: wpas_dbus_error_unknown_error " wpa_printf(MSG_INFO,
"called with NULL message (arg=%s)", "dbus: %s called with NULL message (arg=%s)",
arg ? arg : "N/A"); __func__, arg ? arg : "N/A");
return NULL; return NULL;
} }
@ -73,9 +73,9 @@ DBusMessage * wpas_dbus_error_unknown_error(DBusMessage *message,
*/ */
static DBusMessage * wpas_dbus_error_iface_unknown(DBusMessage *message) static DBusMessage * wpas_dbus_error_iface_unknown(DBusMessage *message)
{ {
return dbus_message_new_error(message, WPAS_DBUS_ERROR_IFACE_UNKNOWN, return dbus_message_new_error(
"wpa_supplicant knows nothing about " message, WPAS_DBUS_ERROR_IFACE_UNKNOWN,
"this interface."); "wpa_supplicant knows nothing about this interface.");
} }
@ -88,9 +88,9 @@ static DBusMessage * wpas_dbus_error_iface_unknown(DBusMessage *message)
*/ */
static DBusMessage * wpas_dbus_error_network_unknown(DBusMessage *message) static DBusMessage * wpas_dbus_error_network_unknown(DBusMessage *message)
{ {
return dbus_message_new_error(message, WPAS_DBUS_ERROR_NETWORK_UNKNOWN, return dbus_message_new_error(
"There is no such a network in this " message, WPAS_DBUS_ERROR_NETWORK_UNKNOWN,
"interface."); "There is no such a network in this interface.");
} }
@ -106,9 +106,9 @@ DBusMessage * wpas_dbus_error_invalid_args(DBusMessage *message,
{ {
DBusMessage *reply; DBusMessage *reply;
reply = dbus_message_new_error(message, WPAS_DBUS_ERROR_INVALID_ARGS, reply = dbus_message_new_error(
"Did not receive correct message " message, WPAS_DBUS_ERROR_INVALID_ARGS,
"arguments."); "Did not receive correct message arguments.");
if (arg != NULL) if (arg != NULL)
dbus_message_append_args(reply, DBUS_TYPE_STRING, &arg, dbus_message_append_args(reply, DBUS_TYPE_STRING, &arg,
DBUS_TYPE_INVALID); DBUS_TYPE_INVALID);
@ -134,7 +134,7 @@ static DBusMessage * wpas_dbus_error_scan_error(DBusMessage *message,
} }
static const char *dont_quote[] = { static const char * const dont_quote[] = {
"key_mgmt", "proto", "pairwise", "auth_alg", "group", "eap", "key_mgmt", "proto", "pairwise", "auth_alg", "group", "eap",
"opensc_engine_path", "pkcs11_engine_path", "pkcs11_module_path", "opensc_engine_path", "pkcs11_engine_path", "pkcs11_module_path",
"bssid", "scan_freq", "freq_list", NULL "bssid", "scan_freq", "freq_list", NULL
@ -143,6 +143,7 @@ static const char *dont_quote[] = {
static dbus_bool_t should_quote_opt(const char *key) static dbus_bool_t should_quote_opt(const char *key)
{ {
int i = 0; int i = 0;
while (dont_quote[i] != NULL) { while (dont_quote[i] != NULL) {
if (os_strcmp(key, dont_quote[i]) == 0) if (os_strcmp(key, dont_quote[i]) == 0)
return FALSE; return FALSE;
@ -537,29 +538,29 @@ DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message,
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) { while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
goto error; goto error;
if (!os_strcmp(entry.key, "Driver") && if (os_strcmp(entry.key, "Driver") == 0 &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
os_free(driver); os_free(driver);
driver = os_strdup(entry.str_value); driver = os_strdup(entry.str_value);
wpa_dbus_dict_entry_clear(&entry); wpa_dbus_dict_entry_clear(&entry);
if (driver == NULL) if (driver == NULL)
goto error; goto error;
} else if (!os_strcmp(entry.key, "Ifname") && } else if (os_strcmp(entry.key, "Ifname") == 0 &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
os_free(ifname); os_free(ifname);
ifname = os_strdup(entry.str_value); ifname = os_strdup(entry.str_value);
wpa_dbus_dict_entry_clear(&entry); wpa_dbus_dict_entry_clear(&entry);
if (ifname == NULL) if (ifname == NULL)
goto error; goto error;
} else if (!os_strcmp(entry.key, "ConfigFile") && } else if (os_strcmp(entry.key, "ConfigFile") == 0 &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
os_free(confname); os_free(confname);
confname = os_strdup(entry.str_value); confname = os_strdup(entry.str_value);
wpa_dbus_dict_entry_clear(&entry); wpa_dbus_dict_entry_clear(&entry);
if (confname == NULL) if (confname == NULL)
goto error; goto error;
} else if (!os_strcmp(entry.key, "BridgeIfname") && } else if (os_strcmp(entry.key, "BridgeIfname") == 0 &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
os_free(bridge_ifname); os_free(bridge_ifname);
bridge_ifname = os_strdup(entry.str_value); bridge_ifname = os_strdup(entry.str_value);
wpa_dbus_dict_entry_clear(&entry); wpa_dbus_dict_entry_clear(&entry);
@ -579,28 +580,30 @@ DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message,
* an error if we already control it. * an error if we already control it.
*/ */
if (wpa_supplicant_get_iface(global, ifname) != NULL) { if (wpa_supplicant_get_iface(global, ifname) != NULL) {
reply = dbus_message_new_error(message, reply = dbus_message_new_error(
WPAS_DBUS_ERROR_IFACE_EXISTS, message, WPAS_DBUS_ERROR_IFACE_EXISTS,
"wpa_supplicant already " "wpa_supplicant already controls this interface.");
"controls this interface.");
} else { } else {
struct wpa_supplicant *wpa_s; struct wpa_supplicant *wpa_s;
struct wpa_interface iface; struct wpa_interface iface;
os_memset(&iface, 0, sizeof(iface)); os_memset(&iface, 0, sizeof(iface));
iface.driver = driver; iface.driver = driver;
iface.ifname = ifname; iface.ifname = ifname;
iface.confname = confname; iface.confname = confname;
iface.bridge_ifname = bridge_ifname; iface.bridge_ifname = bridge_ifname;
/* Otherwise, have wpa_supplicant attach to it. */ /* Otherwise, have wpa_supplicant attach to it. */
if ((wpa_s = wpa_supplicant_add_iface(global, &iface))) { wpa_s = wpa_supplicant_add_iface(global, &iface);
if (wpa_s) {
const char *path = wpa_s->dbus_new_path; const char *path = wpa_s->dbus_new_path;
reply = dbus_message_new_method_return(message); reply = dbus_message_new_method_return(message);
dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH,
&path, DBUS_TYPE_INVALID); &path, DBUS_TYPE_INVALID);
} else { } else {
reply = wpas_dbus_error_unknown_error( reply = wpas_dbus_error_unknown_error(
message, "wpa_supplicant couldn't grab this " message,
"interface."); "wpa_supplicant couldn't grab this interface.");
} }
} }
@ -643,8 +646,8 @@ DBusMessage * wpas_dbus_handler_remove_interface(DBusMessage *message,
reply = wpas_dbus_error_iface_unknown(message); reply = wpas_dbus_error_iface_unknown(message);
else if (wpa_supplicant_remove_iface(global, wpa_s, 0)) { else if (wpa_supplicant_remove_iface(global, wpa_s, 0)) {
reply = wpas_dbus_error_unknown_error( reply = wpas_dbus_error_unknown_error(
message, "wpa_supplicant couldn't remove this " message,
"interface."); "wpa_supplicant couldn't remove this interface.");
} }
return reply; return reply;
@ -783,8 +786,8 @@ dbus_bool_t wpas_dbus_setter_debug_level(DBusMessageIter *iter,
if (val < 0 || if (val < 0 ||
wpa_supplicant_set_debug_params(global, val, wpa_debug_timestamp, wpa_supplicant_set_debug_params(global, val, wpa_debug_timestamp,
wpa_debug_show_keys)) { wpa_debug_show_keys)) {
dbus_set_error_const(error, DBUS_ERROR_FAILED, "wrong debug " dbus_set_error_const(error, DBUS_ERROR_FAILED,
"level value"); "wrong debug level value");
return FALSE; return FALSE;
} }
@ -964,8 +967,8 @@ static int wpas_dbus_get_scan_type(DBusMessage *message, DBusMessageIter *var,
char **type, DBusMessage **reply) char **type, DBusMessage **reply)
{ {
if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_STRING) { if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_STRING) {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: " wpa_printf(MSG_DEBUG, "%s[dbus]: Type must be a string",
"Type must be a string"); __func__);
*reply = wpas_dbus_error_invalid_args( *reply = wpas_dbus_error_invalid_args(
message, "Wrong Type value type. String required"); message, "Wrong Type value type. String required");
return -1; return -1;
@ -987,36 +990,36 @@ static int wpas_dbus_get_scan_ssids(DBusMessage *message, DBusMessageIter *var,
int len; int len;
if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_ARRAY) { if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_ARRAY) {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: ssids " wpa_printf(MSG_DEBUG,
"must be an array of arrays of bytes"); "%s[dbus]: ssids must be an array of arrays of bytes",
__func__);
*reply = wpas_dbus_error_invalid_args( *reply = wpas_dbus_error_invalid_args(
message, "Wrong SSIDs value type. Array of arrays of " message,
"bytes required"); "Wrong SSIDs value type. Array of arrays of bytes required");
return -1; return -1;
} }
dbus_message_iter_recurse(var, &array_iter); dbus_message_iter_recurse(var, &array_iter);
if (dbus_message_iter_get_arg_type(&array_iter) != DBUS_TYPE_ARRAY || if (dbus_message_iter_get_arg_type(&array_iter) != DBUS_TYPE_ARRAY ||
dbus_message_iter_get_element_type(&array_iter) != DBUS_TYPE_BYTE) dbus_message_iter_get_element_type(&array_iter) != DBUS_TYPE_BYTE) {
{ wpa_printf(MSG_DEBUG,
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: ssids " "%s[dbus]: ssids must be an array of arrays of bytes",
"must be an array of arrays of bytes"); __func__);
*reply = wpas_dbus_error_invalid_args( *reply = wpas_dbus_error_invalid_args(
message, "Wrong SSIDs value type. Array of arrays of " message,
"bytes required"); "Wrong SSIDs value type. Array of arrays of bytes required");
return -1; return -1;
} }
while (dbus_message_iter_get_arg_type(&array_iter) == DBUS_TYPE_ARRAY) while (dbus_message_iter_get_arg_type(&array_iter) == DBUS_TYPE_ARRAY) {
{
if (ssids_num >= WPAS_MAX_SCAN_SSIDS) { if (ssids_num >= WPAS_MAX_SCAN_SSIDS) {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: " wpa_printf(MSG_DEBUG,
"Too many ssids specified on scan dbus " "%s[dbus]: Too many ssids specified on scan dbus call",
"call"); __func__);
*reply = wpas_dbus_error_invalid_args( *reply = wpas_dbus_error_invalid_args(
message, "Too many ssids specified. Specify " message,
"at most four"); "Too many ssids specified. Specify at most four");
return -1; return -1;
} }
@ -1026,9 +1029,8 @@ static int wpas_dbus_get_scan_ssids(DBusMessage *message, DBusMessageIter *var,
if (len > MAX_SSID_LEN) { if (len > MAX_SSID_LEN) {
wpa_printf(MSG_DEBUG, wpa_printf(MSG_DEBUG,
"wpas_dbus_handler_scan[dbus]: " "%s[dbus]: SSID too long (len=%d max_len=%d)",
"SSID too long (len=%d max_len=%d)", __func__, len, MAX_SSID_LEN);
len, MAX_SSID_LEN);
*reply = wpas_dbus_error_invalid_args( *reply = wpas_dbus_error_invalid_args(
message, "Invalid SSID: too long"); message, "Invalid SSID: too long");
return -1; return -1;
@ -1038,9 +1040,8 @@ static int wpas_dbus_get_scan_ssids(DBusMessage *message, DBusMessageIter *var,
ssid = os_malloc(len); ssid = os_malloc(len);
if (ssid == NULL) { if (ssid == NULL) {
wpa_printf(MSG_DEBUG, wpa_printf(MSG_DEBUG,
"wpas_dbus_handler_scan[dbus]: " "%s[dbus]: out of memory. Cannot allocate memory for SSID",
"out of memory. Cannot allocate " __func__);
"memory for SSID");
*reply = dbus_message_new_error( *reply = dbus_message_new_error(
message, DBUS_ERROR_NO_MEMORY, NULL); message, DBUS_ERROR_NO_MEMORY, NULL);
return -1; return -1;
@ -1074,28 +1075,28 @@ static int wpas_dbus_get_scan_ies(DBusMessage *message, DBusMessageIter *var,
int len; int len;
if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_ARRAY) { if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_ARRAY) {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: ies must " wpa_printf(MSG_DEBUG,
"be an array of arrays of bytes"); "%s[dbus]: ies must be an array of arrays of bytes",
__func__);
*reply = wpas_dbus_error_invalid_args( *reply = wpas_dbus_error_invalid_args(
message, "Wrong IEs value type. Array of arrays of " message,
"bytes required"); "Wrong IEs value type. Array of arrays of bytes required");
return -1; return -1;
} }
dbus_message_iter_recurse(var, &array_iter); dbus_message_iter_recurse(var, &array_iter);
if (dbus_message_iter_get_arg_type(&array_iter) != DBUS_TYPE_ARRAY || if (dbus_message_iter_get_arg_type(&array_iter) != DBUS_TYPE_ARRAY ||
dbus_message_iter_get_element_type(&array_iter) != DBUS_TYPE_BYTE) dbus_message_iter_get_element_type(&array_iter) != DBUS_TYPE_BYTE) {
{ wpa_printf(MSG_DEBUG,
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: ies must " "%s[dbus]: ies must be an array of arrays of bytes",
"be an array of arrays of bytes"); __func__);
*reply = wpas_dbus_error_invalid_args( *reply = wpas_dbus_error_invalid_args(
message, "Wrong IEs value type. Array required"); message, "Wrong IEs value type. Array required");
return -1; return -1;
} }
while (dbus_message_iter_get_arg_type(&array_iter) == DBUS_TYPE_ARRAY) while (dbus_message_iter_get_arg_type(&array_iter) == DBUS_TYPE_ARRAY) {
{
dbus_message_iter_recurse(&array_iter, &sub_array_iter); dbus_message_iter_recurse(&array_iter, &sub_array_iter);
dbus_message_iter_get_fixed_array(&sub_array_iter, &val, &len); dbus_message_iter_get_fixed_array(&sub_array_iter, &val, &len);
@ -1106,9 +1107,9 @@ static int wpas_dbus_get_scan_ies(DBusMessage *message, DBusMessageIter *var,
nies = os_realloc(ies, ies_len + len); nies = os_realloc(ies, ies_len + len);
if (nies == NULL) { if (nies == NULL) {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: " wpa_printf(MSG_DEBUG,
"out of memory. Cannot allocate memory for " "%s[dbus]: out of memory. Cannot allocate memory for IE",
"IE"); __func__);
os_free(ies); os_free(ies);
*reply = dbus_message_new_error( *reply = dbus_message_new_error(
message, DBUS_ERROR_NO_MEMORY, NULL); message, DBUS_ERROR_NO_MEMORY, NULL);
@ -1137,11 +1138,12 @@ static int wpas_dbus_get_scan_channels(DBusMessage *message,
int freqs_num = 0; int freqs_num = 0;
if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_ARRAY) { if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_ARRAY) {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: " wpa_printf(MSG_DEBUG,
"Channels must be an array of structs"); "%s[dbus]: Channels must be an array of structs",
__func__);
*reply = wpas_dbus_error_invalid_args( *reply = wpas_dbus_error_invalid_args(
message, "Wrong Channels value type. Array of structs " message,
"required"); "Wrong Channels value type. Array of structs required");
return -1; return -1;
} }
@ -1149,11 +1151,11 @@ static int wpas_dbus_get_scan_channels(DBusMessage *message,
if (dbus_message_iter_get_arg_type(&array_iter) != DBUS_TYPE_STRUCT) { if (dbus_message_iter_get_arg_type(&array_iter) != DBUS_TYPE_STRUCT) {
wpa_printf(MSG_DEBUG, wpa_printf(MSG_DEBUG,
"wpas_dbus_handler_scan[dbus]: Channels must be an " "%s[dbus]: Channels must be an array of structs",
"array of structs"); __func__);
*reply = wpas_dbus_error_invalid_args( *reply = wpas_dbus_error_invalid_args(
message, "Wrong Channels value type. Array of structs " message,
"required"); "Wrong Channels value type. Array of structs required");
return -1; return -1;
} }
@ -1165,14 +1167,14 @@ static int wpas_dbus_get_scan_channels(DBusMessage *message,
if (dbus_message_iter_get_arg_type(&sub_array_iter) != if (dbus_message_iter_get_arg_type(&sub_array_iter) !=
DBUS_TYPE_UINT32) { DBUS_TYPE_UINT32) {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: " wpa_printf(MSG_DEBUG,
"Channel must by specified by struct of " "%s[dbus]: Channel must by specified by struct of two UINT32s %c",
"two UINT32s %c", __func__,
dbus_message_iter_get_arg_type( dbus_message_iter_get_arg_type(
&sub_array_iter)); &sub_array_iter));
*reply = wpas_dbus_error_invalid_args( *reply = wpas_dbus_error_invalid_args(
message, "Wrong Channel struct. Two UINT32s " message,
"required"); "Wrong Channel struct. Two UINT32s required");
os_free(freqs); os_free(freqs);
return -1; return -1;
} }
@ -1181,9 +1183,9 @@ static int wpas_dbus_get_scan_channels(DBusMessage *message,
if (!dbus_message_iter_next(&sub_array_iter) || if (!dbus_message_iter_next(&sub_array_iter) ||
dbus_message_iter_get_arg_type(&sub_array_iter) != dbus_message_iter_get_arg_type(&sub_array_iter) !=
DBUS_TYPE_UINT32) { DBUS_TYPE_UINT32) {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: " wpa_printf(MSG_DEBUG,
"Channel must by specified by struct of " "%s[dbus]: Channel must by specified by struct of two UINT32s",
"two UINT32s"); __func__);
*reply = wpas_dbus_error_invalid_args( *reply = wpas_dbus_error_invalid_args(
message, message,
"Wrong Channel struct. Two UINT32s required"); "Wrong Channel struct. Two UINT32s required");
@ -1203,9 +1205,9 @@ static int wpas_dbus_get_scan_channels(DBusMessage *message,
freqs = nfreqs; freqs = nfreqs;
} }
if (freqs == NULL) { if (freqs == NULL) {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: " wpa_printf(MSG_DEBUG,
"out of memory. can't allocate memory for " "%s[dbus]: out of memory. can't allocate memory for freqs",
"freqs"); __func__);
*reply = dbus_message_new_error( *reply = dbus_message_new_error(
message, DBUS_ERROR_NO_MEMORY, NULL); message, DBUS_ERROR_NO_MEMORY, NULL);
return -1; return -1;
@ -1222,8 +1224,9 @@ static int wpas_dbus_get_scan_channels(DBusMessage *message,
os_free(freqs); os_free(freqs);
freqs = nfreqs; freqs = nfreqs;
if (freqs == NULL) { if (freqs == NULL) {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: " wpa_printf(MSG_DEBUG,
"out of memory. Can't allocate memory for freqs"); "%s[dbus]: out of memory. Can't allocate memory for freqs",
__func__);
*reply = dbus_message_new_error( *reply = dbus_message_new_error(
message, DBUS_ERROR_NO_MEMORY, NULL); message, DBUS_ERROR_NO_MEMORY, NULL);
return -1; return -1;
@ -1241,8 +1244,8 @@ static int wpas_dbus_get_scan_allow_roam(DBusMessage *message,
DBusMessage **reply) DBusMessage **reply)
{ {
if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_BOOLEAN) { if (dbus_message_iter_get_arg_type(var) != DBUS_TYPE_BOOLEAN) {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: " wpa_printf(MSG_DEBUG, "%s[dbus]: Type must be a boolean",
"Type must be a boolean"); __func__);
*reply = wpas_dbus_error_invalid_args( *reply = wpas_dbus_error_invalid_args(
message, "Wrong Type value type. Boolean required"); message, "Wrong Type value type. Boolean required");
return -1; return -1;
@ -1308,8 +1311,8 @@ DBusMessage * wpas_dbus_handler_scan(DBusMessage *message,
&reply) < 0) &reply) < 0)
goto out; goto out;
} else { } else {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: " wpa_printf(MSG_DEBUG, "%s[dbus]: Unknown argument %s",
"Unknown argument %s", key); __func__, key);
reply = wpas_dbus_error_invalid_args(message, key); reply = wpas_dbus_error_invalid_args(message, key);
goto out; goto out;
} }
@ -1318,19 +1321,20 @@ DBusMessage * wpas_dbus_handler_scan(DBusMessage *message,
} }
if (!type) { if (!type) {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: " wpa_printf(MSG_DEBUG, "%s[dbus]: Scan type not specified",
"Scan type not specified"); __func__);
reply = wpas_dbus_error_invalid_args(message, key); reply = wpas_dbus_error_invalid_args(message, key);
goto out; goto out;
} }
if (!os_strcmp(type, "passive")) { if (os_strcmp(type, "passive") == 0) {
if (params.num_ssids || params.extra_ies_len) { if (params.num_ssids || params.extra_ies_len) {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: " wpa_printf(MSG_DEBUG,
"SSIDs or IEs specified for passive scan."); "%s[dbus]: SSIDs or IEs specified for passive scan.",
__func__);
reply = wpas_dbus_error_invalid_args( reply = wpas_dbus_error_invalid_args(
message, "You can specify only Channels in " message,
"passive scan"); "You can specify only Channels in passive scan");
goto out; goto out;
} else if (params.freqs && params.freqs[0]) { } else if (params.freqs && params.freqs[0]) {
if (wpa_supplicant_trigger_scan(wpa_s, &params)) { if (wpa_supplicant_trigger_scan(wpa_s, &params)) {
@ -1341,7 +1345,7 @@ DBusMessage * wpas_dbus_handler_scan(DBusMessage *message,
wpa_s->scan_req = MANUAL_SCAN_REQ; wpa_s->scan_req = MANUAL_SCAN_REQ;
wpa_supplicant_req_scan(wpa_s, 0, 0); wpa_supplicant_req_scan(wpa_s, 0, 0);
} }
} else if (!os_strcmp(type, "active")) { } else if (os_strcmp(type, "active") == 0) {
if (!params.num_ssids) { if (!params.num_ssids) {
/* Add wildcard ssid */ /* Add wildcard ssid */
params.num_ssids++; params.num_ssids++;
@ -1354,8 +1358,8 @@ DBusMessage * wpas_dbus_handler_scan(DBusMessage *message,
message, "Scan request rejected"); message, "Scan request rejected");
} }
} else { } else {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_scan[dbus]: " wpa_printf(MSG_DEBUG, "%s[dbus]: Unknown scan type: %s",
"Unknown scan type: %s", type); __func__, type);
reply = wpas_dbus_error_invalid_args(message, reply = wpas_dbus_error_invalid_args(message,
"Wrong scan type"); "Wrong scan type");
goto out; goto out;
@ -1486,12 +1490,11 @@ DBusMessage * wpas_dbus_handler_add_network(DBusMessage *message,
ssid = wpa_config_add_network(wpa_s->conf); ssid = wpa_config_add_network(wpa_s->conf);
if (ssid == NULL) { if (ssid == NULL) {
wpa_printf(MSG_ERROR, "wpas_dbus_handler_add_network[dbus]: " wpa_printf(MSG_ERROR, "%s[dbus]: can't add new interface.",
"can't add new interface."); __func__);
reply = wpas_dbus_error_unknown_error( reply = wpas_dbus_error_unknown_error(
message, message,
"wpa_supplicant could not add " "wpa_supplicant could not add a network on this interface.");
"a network on this interface.");
goto err; goto err;
} }
wpas_notify_network_added(wpa_s, ssid); wpas_notify_network_added(wpa_s, ssid);
@ -1500,9 +1503,9 @@ DBusMessage * wpas_dbus_handler_add_network(DBusMessage *message,
dbus_error_init(&error); dbus_error_init(&error);
if (!set_network_properties(wpa_s, ssid, &iter, &error)) { if (!set_network_properties(wpa_s, ssid, &iter, &error)) {
wpa_printf(MSG_DEBUG, "wpas_dbus_handler_add_network[dbus]:" wpa_printf(MSG_DEBUG,
"control interface couldn't set network " "%s[dbus]: control interface couldn't set network properties",
"properties"); __func__);
reply = wpas_dbus_reply_new_from_error(message, &error, reply = wpas_dbus_reply_new_from_error(message, &error,
DBUS_ERROR_INVALID_ARGS, DBUS_ERROR_INVALID_ARGS,
"Failed to add network"); "Failed to add network");
@ -1638,19 +1641,19 @@ DBusMessage * wpas_dbus_handler_remove_network(DBusMessage *message,
wpa_supplicant_deauthenticate(wpa_s, wpa_supplicant_deauthenticate(wpa_s,
WLAN_REASON_DEAUTH_LEAVING); WLAN_REASON_DEAUTH_LEAVING);
else if (!was_disabled && wpa_s->sched_scanning) { else if (!was_disabled && wpa_s->sched_scanning) {
wpa_printf(MSG_DEBUG, "Stop ongoing sched_scan to remove " wpa_printf(MSG_DEBUG,
"network from filters"); "Stop ongoing sched_scan to remove network from filters");
wpa_supplicant_cancel_sched_scan(wpa_s); wpa_supplicant_cancel_sched_scan(wpa_s);
wpa_supplicant_req_scan(wpa_s, 0, 0); wpa_supplicant_req_scan(wpa_s, 0, 0);
} }
if (wpa_config_remove_network(wpa_s->conf, id) < 0) { if (wpa_config_remove_network(wpa_s->conf, id) < 0) {
wpa_printf(MSG_ERROR, wpa_printf(MSG_ERROR,
"wpas_dbus_handler_remove_network[dbus]: " "%s[dbus]: error occurred when removing network %d",
"error occurred when removing network %d", id); __func__, id);
reply = wpas_dbus_error_unknown_error( reply = wpas_dbus_error_unknown_error(
message, "error removing the specified network on " message,
"this interface."); "error removing the specified network on is interface.");
goto out; goto out;
} }
@ -1668,9 +1671,8 @@ static void remove_network(void *arg, struct wpa_ssid *ssid)
if (wpa_config_remove_network(wpa_s->conf, ssid->id) < 0) { if (wpa_config_remove_network(wpa_s->conf, ssid->id) < 0) {
wpa_printf(MSG_ERROR, wpa_printf(MSG_ERROR,
"wpas_dbus_handler_remove_all_networks[dbus]: " "%s[dbus]: error occurred when removing network %d",
"error occurred when removing network %d", __func__, ssid->id);
ssid->id);
return; return;
} }
@ -2035,6 +2037,7 @@ DBusMessage * wpas_dbus_handler_autoscan(DBusMessage *message,
if (arg != NULL && os_strlen(arg) > 0) { if (arg != NULL && os_strlen(arg) > 0) {
char *tmp; char *tmp;
tmp = os_strdup(arg); tmp = os_strdup(arg);
if (tmp == NULL) { if (tmp == NULL) {
reply = dbus_message_new_error(message, reply = dbus_message_new_error(message,
@ -2301,8 +2304,7 @@ DBusMessage * wpas_dbus_handler_set_pkcs11_engine_and_module_path(
pkcs11_module_path)) pkcs11_module_path))
return dbus_message_new_error( return dbus_message_new_error(
message, DBUS_ERROR_FAILED, message, DBUS_ERROR_FAILED,
"Reinit of the EAPOL state machine with the new PKCS " "Reinit of the EAPOL state machine with the new PKCS #11 engine and module path failed.");
"#11 engine and module path failed.");
wpa_dbus_mark_property_changed( wpa_dbus_mark_property_changed(
wpa_s->global->dbus, wpa_s->dbus_new_path, wpa_s->global->dbus, wpa_s->dbus_new_path,
@ -2344,6 +2346,7 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
/***** pairwise cipher */ /***** pairwise cipher */
if (res < 0) { if (res < 0) {
const char *args[] = {"ccmp", "tkip", "none"}; const char *args[] = {"ccmp", "tkip", "none"};
if (!wpa_dbus_dict_append_string_array( if (!wpa_dbus_dict_append_string_array(
&iter_dict, "Pairwise", args, &iter_dict, "Pairwise", args,
ARRAY_SIZE(args))) ARRAY_SIZE(args)))
@ -2383,6 +2386,7 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
const char *args[] = { const char *args[] = {
"ccmp", "tkip", "wep104", "wep40" "ccmp", "tkip", "wep104", "wep40"
}; };
if (!wpa_dbus_dict_append_string_array( if (!wpa_dbus_dict_append_string_array(
&iter_dict, "Group", args, &iter_dict, "Group", args,
ARRAY_SIZE(args))) ARRAY_SIZE(args)))
@ -2501,6 +2505,7 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
/***** WPA protocol */ /***** WPA protocol */
if (res < 0) { if (res < 0) {
const char *args[] = { "rsn", "wpa" }; const char *args[] = { "rsn", "wpa" };
if (!wpa_dbus_dict_append_string_array( if (!wpa_dbus_dict_append_string_array(
&iter_dict, "Protocol", args, &iter_dict, "Protocol", args,
ARRAY_SIZE(args))) ARRAY_SIZE(args)))
@ -2528,6 +2533,7 @@ dbus_bool_t wpas_dbus_getter_capabilities(DBusMessageIter *iter,
/***** auth alg */ /***** auth alg */
if (res < 0) { if (res < 0) {
const char *args[] = { "open", "shared", "leap" }; const char *args[] = { "open", "shared", "leap" };
if (!wpa_dbus_dict_append_string_array( if (!wpa_dbus_dict_append_string_array(
&iter_dict, "AuthAlg", args, &iter_dict, "AuthAlg", args,
ARRAY_SIZE(args))) ARRAY_SIZE(args)))
@ -2774,6 +2780,7 @@ dbus_bool_t wpas_dbus_getter_disconnect_reason(DBusMessageIter *iter,
{ {
struct wpa_supplicant *wpa_s = user_data; struct wpa_supplicant *wpa_s = user_data;
dbus_int32_t reason = wpa_s->disconnect_reason; dbus_int32_t reason = wpa_s->disconnect_reason;
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32, return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_INT32,
&reason, error); &reason, error);
} }
@ -3028,8 +3035,8 @@ dbus_bool_t wpas_dbus_getter_driver(DBusMessageIter *iter, DBusError *error,
const char *driver; const char *driver;
if (wpa_s->driver == NULL || wpa_s->driver->name == NULL) { if (wpa_s->driver == NULL || wpa_s->driver->name == NULL) {
wpa_printf(MSG_DEBUG, "wpas_dbus_getter_driver[dbus]: " wpa_printf(MSG_DEBUG, "%s[dbus]: wpa_s has no driver set",
"wpa_s has no driver set"); __func__);
dbus_set_error(error, DBUS_ERROR_FAILED, "%s: no driver set", dbus_set_error(error, DBUS_ERROR_FAILED, "%s: no driver set",
__func__); __func__);
return FALSE; return FALSE;
@ -3149,6 +3156,7 @@ dbus_bool_t wpas_dbus_getter_bridge_ifname(DBusMessageIter *iter,
{ {
struct wpa_supplicant *wpa_s = user_data; struct wpa_supplicant *wpa_s = user_data;
const char *bridge_ifname = wpa_s->bridge_ifname; const char *bridge_ifname = wpa_s->bridge_ifname;
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING, return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_STRING,
&bridge_ifname, error); &bridge_ifname, error);
} }
@ -3239,7 +3247,8 @@ dbus_bool_t wpas_dbus_getter_networks(DBusMessageIter *iter, DBusError *error,
continue; continue;
paths[i] = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX); paths[i] = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX);
if (paths[i] == NULL) { if (paths[i] == NULL) {
dbus_set_error(error, DBUS_ERROR_NO_MEMORY, "no memory"); dbus_set_error(error, DBUS_ERROR_NO_MEMORY,
"no memory");
goto out; goto out;
} }

View file

@ -57,12 +57,12 @@ static int parse_peer_object_path(const char *peer_path, u8 addr[ETH_ALEN])
* *
* Convenience function to create and return an invalid persistent group error. * Convenience function to create and return an invalid persistent group error.
*/ */
static DBusMessage * wpas_dbus_error_persistent_group_unknown( static DBusMessage *
DBusMessage *message) wpas_dbus_error_persistent_group_unknown(DBusMessage *message)
{ {
return dbus_message_new_error(message, WPAS_DBUS_ERROR_NETWORK_UNKNOWN, return dbus_message_new_error(
"There is no such persistent group in " message, WPAS_DBUS_ERROR_NETWORK_UNKNOWN,
"this P2P device."); "There is no such persistent group in this P2P device.");
} }
@ -89,12 +89,12 @@ DBusMessage * wpas_dbus_handler_p2p_find(DBusMessage *message,
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
goto error; goto error;
if (!os_strcmp(entry.key, "Timeout") && if (os_strcmp(entry.key, "Timeout") == 0 &&
(entry.type == DBUS_TYPE_INT32)) { entry.type == DBUS_TYPE_INT32) {
timeout = entry.uint32_value; timeout = entry.uint32_value;
} else if (os_strcmp(entry.key, "RequestedDeviceTypes") == 0) { } else if (os_strcmp(entry.key, "RequestedDeviceTypes") == 0) {
if ((entry.type != DBUS_TYPE_ARRAY) || if (entry.type != DBUS_TYPE_ARRAY ||
(entry.array_type != WPAS_DBUS_TYPE_BINARRAY)) entry.array_type != WPAS_DBUS_TYPE_BINARRAY)
goto error_clear; goto error_clear;
os_free(req_dev_types); os_free(req_dev_types);
@ -112,13 +112,13 @@ DBusMessage * wpas_dbus_handler_p2p_find(DBusMessage *message,
WPS_DEV_TYPE_LEN); WPS_DEV_TYPE_LEN);
} }
num_req_dev_types = entry.array_len; num_req_dev_types = entry.array_len;
} else if (!os_strcmp(entry.key, "DiscoveryType") && } else if (os_strcmp(entry.key, "DiscoveryType") == 0 &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
if (!os_strcmp(entry.str_value, "start_with_full")) if (os_strcmp(entry.str_value, "start_with_full") == 0)
type = P2P_FIND_START_WITH_FULL; type = P2P_FIND_START_WITH_FULL;
else if (!os_strcmp(entry.str_value, "social")) else if (os_strcmp(entry.str_value, "social") == 0)
type = P2P_FIND_ONLY_SOCIAL; type = P2P_FIND_ONLY_SOCIAL;
else if (!os_strcmp(entry.str_value, "progressive")) else if (os_strcmp(entry.str_value, "progressive") == 0)
type = P2P_FIND_PROGRESSIVE; type = P2P_FIND_PROGRESSIVE;
else else
goto error_clear; goto error_clear;
@ -220,11 +220,11 @@ DBusMessage * wpas_dbus_handler_p2p_extendedlisten(
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
goto error; goto error;
if (!os_strcmp(entry.key, "period") && if (os_strcmp(entry.key, "period") == 0 &&
(entry.type == DBUS_TYPE_INT32)) entry.type == DBUS_TYPE_INT32)
period = entry.uint32_value; period = entry.uint32_value;
else if (!os_strcmp(entry.key, "interval") && else if (os_strcmp(entry.key, "interval") == 0 &&
(entry.type == DBUS_TYPE_INT32)) entry.type == DBUS_TYPE_INT32)
interval = entry.uint32_value; interval = entry.uint32_value;
else else
goto error_clear; goto error_clear;
@ -265,16 +265,16 @@ DBusMessage * wpas_dbus_handler_p2p_presence_request(
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
goto error; goto error;
if (!os_strcmp(entry.key, "duration1") && if (os_strcmp(entry.key, "duration1") == 0 &&
(entry.type == DBUS_TYPE_INT32)) entry.type == DBUS_TYPE_INT32)
dur1 = entry.uint32_value; dur1 = entry.uint32_value;
else if (!os_strcmp(entry.key, "interval1") && else if (os_strcmp(entry.key, "interval1") == 0 &&
entry.type == DBUS_TYPE_INT32) entry.type == DBUS_TYPE_INT32)
int1 = entry.uint32_value; int1 = entry.uint32_value;
else if (!os_strcmp(entry.key, "duration2") && else if (os_strcmp(entry.key, "duration2") == 0 &&
entry.type == DBUS_TYPE_INT32) entry.type == DBUS_TYPE_INT32)
dur2 = entry.uint32_value; dur2 = entry.uint32_value;
else if (!os_strcmp(entry.key, "interval2") && else if (os_strcmp(entry.key, "interval2") == 0 &&
entry.type == DBUS_TYPE_INT32) entry.type == DBUS_TYPE_INT32)
int2 = entry.uint32_value; int2 = entry.uint32_value;
else else
@ -322,15 +322,16 @@ DBusMessage * wpas_dbus_handler_p2p_group_add(DBusMessage *message,
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
goto inv_args; goto inv_args;
if (!os_strcmp(entry.key, "persistent") && if (os_strcmp(entry.key, "persistent") == 0 &&
(entry.type == DBUS_TYPE_BOOLEAN)) { entry.type == DBUS_TYPE_BOOLEAN) {
persistent_group = (entry.bool_value == TRUE) ? 1 : 0; persistent_group = entry.bool_value;
} else if (!os_strcmp(entry.key, "frequency") && } else if (os_strcmp(entry.key, "frequency") == 0 &&
(entry.type == DBUS_TYPE_INT32)) { entry.type == DBUS_TYPE_INT32) {
freq = entry.int32_value; freq = entry.int32_value;
if (freq <= 0) if (freq <= 0)
goto inv_args_clear; goto inv_args_clear;
} else if (!os_strcmp(entry.key, "persistent_group_object") && } else if (os_strcmp(entry.key, "persistent_group_object") ==
0 &&
entry.type == DBUS_TYPE_OBJECT_PATH) entry.type == DBUS_TYPE_OBJECT_PATH)
pg_object_path = os_strdup(entry.str_value); pg_object_path = os_strdup(entry.str_value);
else else
@ -419,8 +420,7 @@ static dbus_bool_t wpa_dbus_p2p_check_enabled(struct wpa_supplicant *wpa_s,
"P2P is not available for this interface"); "P2P is not available for this interface");
} }
dbus_set_error_const(error, DBUS_ERROR_FAILED, dbus_set_error_const(error, DBUS_ERROR_FAILED,
"P2P is not available for this " "P2P is not available for this interface");
"interface");
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
@ -478,42 +478,42 @@ DBusMessage * wpas_dbus_handler_p2p_connect(DBusMessage *message,
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
goto inv_args; goto inv_args;
if (!os_strcmp(entry.key, "peer") && if (os_strcmp(entry.key, "peer") == 0 &&
(entry.type == DBUS_TYPE_OBJECT_PATH)) { entry.type == DBUS_TYPE_OBJECT_PATH) {
peer_object_path = os_strdup(entry.str_value); peer_object_path = os_strdup(entry.str_value);
} else if (!os_strcmp(entry.key, "persistent") && } else if (os_strcmp(entry.key, "persistent") == 0 &&
(entry.type == DBUS_TYPE_BOOLEAN)) { entry.type == DBUS_TYPE_BOOLEAN) {
persistent_group = (entry.bool_value == TRUE) ? 1 : 0; persistent_group = entry.bool_value;
} else if (!os_strcmp(entry.key, "join") && } else if (os_strcmp(entry.key, "join") == 0 &&
(entry.type == DBUS_TYPE_BOOLEAN)) { entry.type == DBUS_TYPE_BOOLEAN) {
join = (entry.bool_value == TRUE) ? 1 : 0; join = entry.bool_value;
} else if (!os_strcmp(entry.key, "authorize_only") && } else if (os_strcmp(entry.key, "authorize_only") == 0 &&
(entry.type == DBUS_TYPE_BOOLEAN)) { entry.type == DBUS_TYPE_BOOLEAN) {
authorize_only = (entry.bool_value == TRUE) ? 1 : 0; authorize_only = entry.bool_value;
} else if (!os_strcmp(entry.key, "frequency") && } else if (os_strcmp(entry.key, "frequency") == 0 &&
(entry.type == DBUS_TYPE_INT32)) { entry.type == DBUS_TYPE_INT32) {
freq = entry.int32_value; freq = entry.int32_value;
if (freq <= 0) if (freq <= 0)
goto inv_args_clear; goto inv_args_clear;
} else if (!os_strcmp(entry.key, "go_intent") && } else if (os_strcmp(entry.key, "go_intent") == 0 &&
(entry.type == DBUS_TYPE_INT32)) { entry.type == DBUS_TYPE_INT32) {
go_intent = entry.int32_value; go_intent = entry.int32_value;
if ((go_intent < 0) || (go_intent > 15)) if ((go_intent < 0) || (go_intent > 15))
goto inv_args_clear; goto inv_args_clear;
} else if (!os_strcmp(entry.key, "wps_method") && } else if (os_strcmp(entry.key, "wps_method") == 0 &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
if (!os_strcmp(entry.str_value, "pbc")) if (os_strcmp(entry.str_value, "pbc") == 0)
wps_method = WPS_PBC; wps_method = WPS_PBC;
else if (!os_strcmp(entry.str_value, "pin")) else if (os_strcmp(entry.str_value, "pin") == 0)
wps_method = WPS_PIN_DISPLAY; wps_method = WPS_PIN_DISPLAY;
else if (!os_strcmp(entry.str_value, "display")) else if (os_strcmp(entry.str_value, "display") == 0)
wps_method = WPS_PIN_DISPLAY; wps_method = WPS_PIN_DISPLAY;
else if (!os_strcmp(entry.str_value, "keypad")) else if (os_strcmp(entry.str_value, "keypad") == 0)
wps_method = WPS_PIN_KEYPAD; wps_method = WPS_PIN_KEYPAD;
else else
goto inv_args_clear; goto inv_args_clear;
} else if (!os_strcmp(entry.key, "pin") && } else if (os_strcmp(entry.key, "pin") == 0 &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
pin = os_strdup(entry.str_value); pin = os_strdup(entry.str_value);
} else } else
goto inv_args_clear; goto inv_args_clear;
@ -529,7 +529,7 @@ DBusMessage * wpas_dbus_handler_p2p_connect(DBusMessage *message,
/* /*
* Validate the wps_method specified and the pin value. * Validate the wps_method specified and the pin value.
*/ */
if ((!pin || !pin[0]) && (wps_method == WPS_PIN_KEYPAD)) if ((!pin || !pin[0]) && wps_method == WPS_PIN_KEYPAD)
goto inv_args; goto inv_args;
if (wpa_s->p2p_dev) if (wpa_s->p2p_dev)
@ -542,6 +542,7 @@ DBusMessage * wpas_dbus_handler_p2p_connect(DBusMessage *message,
if (new_pin >= 0) { if (new_pin >= 0) {
char npin[9]; char npin[9];
char *generated_pin; char *generated_pin;
os_snprintf(npin, sizeof(npin), "%08d", new_pin); os_snprintf(npin, sizeof(npin), "%08d", new_pin);
generated_pin = npin; generated_pin = npin;
reply = dbus_message_new_method_return(message); reply = dbus_message_new_method_return(message);
@ -550,8 +551,8 @@ DBusMessage * wpas_dbus_handler_p2p_connect(DBusMessage *message,
} else { } else {
switch (new_pin) { switch (new_pin) {
case -2: case -2:
err_msg = "connect failed due to channel " err_msg =
"unavailability."; "connect failed due to channel unavailability.";
iface = WPAS_DBUS_ERROR_CONNECT_CHANNEL_UNAVAILABLE; iface = WPAS_DBUS_ERROR_CONNECT_CHANNEL_UNAVAILABLE;
break; break;
@ -614,12 +615,13 @@ DBusMessage * wpas_dbus_handler_p2p_invite(DBusMessage *message,
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
goto err; goto err;
if (!os_strcmp(entry.key, "peer") && if (os_strcmp(entry.key, "peer") == 0 &&
(entry.type == DBUS_TYPE_OBJECT_PATH)) { entry.type == DBUS_TYPE_OBJECT_PATH) {
peer_object_path = os_strdup(entry.str_value); peer_object_path = os_strdup(entry.str_value);
wpa_dbus_dict_entry_clear(&entry); wpa_dbus_dict_entry_clear(&entry);
} else if (!os_strcmp(entry.key, "persistent_group_object") && } else if (os_strcmp(entry.key, "persistent_group_object") ==
(entry.type == DBUS_TYPE_OBJECT_PATH)) { 0 &&
entry.type == DBUS_TYPE_OBJECT_PATH) {
pg_object_path = os_strdup(entry.str_value); pg_object_path = os_strdup(entry.str_value);
persistent = 1; persistent = 1;
wpa_dbus_dict_entry_clear(&entry); wpa_dbus_dict_entry_clear(&entry);
@ -921,8 +923,8 @@ dbus_bool_t wpas_dbus_setter_p2p_device_config(DBusMessageIter *iter,
wpa_s->conf->changed_parameters |= wpa_s->conf->changed_parameters |=
CFG_CHANGED_SEC_DEVICE_TYPE; CFG_CHANGED_SEC_DEVICE_TYPE;
} else if (os_strcmp(entry.key, "VendorExtension") == 0) { } else if (os_strcmp(entry.key, "VendorExtension") == 0) {
if ((entry.type != DBUS_TYPE_ARRAY) || if (entry.type != DBUS_TYPE_ARRAY ||
(entry.array_type != WPAS_DBUS_TYPE_BINARRAY) || entry.array_type != WPAS_DBUS_TYPE_BINARRAY ||
(entry.array_len > P2P_MAX_WPS_VENDOR_EXT)) (entry.array_len > P2P_MAX_WPS_VENDOR_EXT))
goto error; goto error;
@ -938,30 +940,30 @@ dbus_bool_t wpas_dbus_setter_p2p_device_config(DBusMessageIter *iter,
} else } else
wpa_s->conf->wps_vendor_ext[i] = NULL; wpa_s->conf->wps_vendor_ext[i] = NULL;
} }
} else if ((os_strcmp(entry.key, "GOIntent") == 0) && } else if (os_strcmp(entry.key, "GOIntent") == 0 &&
(entry.type == DBUS_TYPE_UINT32) && entry.type == DBUS_TYPE_UINT32 &&
(entry.uint32_value <= 15)) (entry.uint32_value <= 15))
wpa_s->conf->p2p_go_intent = entry.uint32_value; wpa_s->conf->p2p_go_intent = entry.uint32_value;
else if ((os_strcmp(entry.key, "PersistentReconnect") == 0) && else if (os_strcmp(entry.key, "PersistentReconnect") == 0 &&
(entry.type == DBUS_TYPE_BOOLEAN)) entry.type == DBUS_TYPE_BOOLEAN)
wpa_s->conf->persistent_reconnect = entry.bool_value; wpa_s->conf->persistent_reconnect = entry.bool_value;
else if ((os_strcmp(entry.key, "ListenRegClass") == 0) && else if (os_strcmp(entry.key, "ListenRegClass") == 0 &&
(entry.type == DBUS_TYPE_UINT32)) { entry.type == DBUS_TYPE_UINT32) {
wpa_s->conf->p2p_listen_reg_class = entry.uint32_value; wpa_s->conf->p2p_listen_reg_class = entry.uint32_value;
wpa_s->conf->changed_parameters |= wpa_s->conf->changed_parameters |=
CFG_CHANGED_P2P_LISTEN_CHANNEL; CFG_CHANGED_P2P_LISTEN_CHANNEL;
} else if ((os_strcmp(entry.key, "ListenChannel") == 0) && } else if (os_strcmp(entry.key, "ListenChannel") == 0 &&
(entry.type == DBUS_TYPE_UINT32)) { entry.type == DBUS_TYPE_UINT32) {
wpa_s->conf->p2p_listen_channel = entry.uint32_value; wpa_s->conf->p2p_listen_channel = entry.uint32_value;
wpa_s->conf->changed_parameters |= wpa_s->conf->changed_parameters |=
CFG_CHANGED_P2P_LISTEN_CHANNEL; CFG_CHANGED_P2P_LISTEN_CHANNEL;
} else if ((os_strcmp(entry.key, "OperRegClass") == 0) && } else if (os_strcmp(entry.key, "OperRegClass") == 0 &&
(entry.type == DBUS_TYPE_UINT32)) { entry.type == DBUS_TYPE_UINT32) {
wpa_s->conf->p2p_oper_reg_class = entry.uint32_value; wpa_s->conf->p2p_oper_reg_class = entry.uint32_value;
wpa_s->conf->changed_parameters |= wpa_s->conf->changed_parameters |=
CFG_CHANGED_P2P_OPER_CHANNEL; CFG_CHANGED_P2P_OPER_CHANNEL;
} else if ((os_strcmp(entry.key, "OperChannel") == 0) && } else if (os_strcmp(entry.key, "OperChannel") == 0 &&
(entry.type == DBUS_TYPE_UINT32)) { entry.type == DBUS_TYPE_UINT32) {
wpa_s->conf->p2p_oper_channel = entry.uint32_value; wpa_s->conf->p2p_oper_channel = entry.uint32_value;
wpa_s->conf->changed_parameters |= wpa_s->conf->changed_parameters |=
CFG_CHANGED_P2P_OPER_CHANNEL; CFG_CHANGED_P2P_OPER_CHANNEL;
@ -980,13 +982,13 @@ dbus_bool_t wpas_dbus_setter_p2p_device_config(DBusMessageIter *iter,
wpa_s->conf->changed_parameters |= wpa_s->conf->changed_parameters |=
CFG_CHANGED_P2P_SSID_POSTFIX; CFG_CHANGED_P2P_SSID_POSTFIX;
} else if ((os_strcmp(entry.key, "IntraBss") == 0) && } else if (os_strcmp(entry.key, "IntraBss") == 0 &&
(entry.type == DBUS_TYPE_BOOLEAN)) { entry.type == DBUS_TYPE_BOOLEAN) {
wpa_s->conf->p2p_intra_bss = entry.bool_value; wpa_s->conf->p2p_intra_bss = entry.bool_value;
wpa_s->conf->changed_parameters |= wpa_s->conf->changed_parameters |=
CFG_CHANGED_P2P_INTRA_BSS; CFG_CHANGED_P2P_INTRA_BSS;
} else if ((os_strcmp(entry.key, "GroupIdle") == 0) && } else if (os_strcmp(entry.key, "GroupIdle") == 0 &&
(entry.type == DBUS_TYPE_UINT32)) entry.type == DBUS_TYPE_UINT32)
wpa_s->conf->p2p_group_idle = entry.uint32_value; wpa_s->conf->p2p_group_idle = entry.uint32_value;
else if (os_strcmp(entry.key, "disassoc_low_ack") == 0 && else if (os_strcmp(entry.key, "disassoc_low_ack") == 0 &&
entry.type == DBUS_TYPE_UINT32) entry.type == DBUS_TYPE_UINT32)
@ -1747,12 +1749,12 @@ DBusMessage * wpas_dbus_handler_add_persistent_group(
ssid = wpa_config_add_network(wpa_s->conf); ssid = wpa_config_add_network(wpa_s->conf);
if (ssid == NULL) { if (ssid == NULL) {
wpa_printf(MSG_ERROR, "dbus: %s: " wpa_printf(MSG_ERROR,
"Cannot add new persistent group", __func__); "dbus: %s: Cannot add new persistent group",
__func__);
reply = wpas_dbus_error_unknown_error( reply = wpas_dbus_error_unknown_error(
message, message,
"wpa_supplicant could not add " "wpa_supplicant could not add a persistent group on this interface.");
"a persistent group on this interface.");
goto err; goto err;
} }
@ -1765,13 +1767,12 @@ DBusMessage * wpas_dbus_handler_add_persistent_group(
dbus_error_init(&error); dbus_error_init(&error);
if (!set_network_properties(wpa_s, ssid, &iter, &error)) { if (!set_network_properties(wpa_s, ssid, &iter, &error)) {
wpa_printf(MSG_DEBUG, "dbus: %s: " wpa_printf(MSG_DEBUG,
"Control interface could not set persistent group " "dbus: %s: Control interface could not set persistent group properties",
"properties", __func__); __func__);
reply = wpas_dbus_reply_new_from_error(message, &error, reply = wpas_dbus_reply_new_from_error(
DBUS_ERROR_INVALID_ARGS, message, &error, DBUS_ERROR_INVALID_ARGS,
"Failed to set network " "Failed to set network properties");
"properties");
dbus_error_free(&error); dbus_error_free(&error);
goto err; goto err;
} }
@ -1856,13 +1857,12 @@ DBusMessage * wpas_dbus_handler_remove_persistent_group(
wpas_notify_persistent_group_removed(wpa_s, ssid); wpas_notify_persistent_group_removed(wpa_s, ssid);
if (wpa_config_remove_network(wpa_s->conf, id) < 0) { if (wpa_config_remove_network(wpa_s->conf, id) < 0) {
wpa_printf(MSG_ERROR, "dbus: %s: " wpa_printf(MSG_ERROR,
"error occurred when removing persistent group %d", "dbus: %s: error occurred when removing persistent group %d",
__func__, id); __func__, id);
reply = wpas_dbus_error_unknown_error( reply = wpas_dbus_error_unknown_error(
message, message,
"error removing the specified persistent group on " "error removing the specified persistent group on this interface.");
"this interface.");
goto out; goto out;
} }
@ -1878,8 +1878,8 @@ static void remove_persistent_group(struct wpa_supplicant *wpa_s,
wpas_notify_persistent_group_removed(wpa_s, ssid); wpas_notify_persistent_group_removed(wpa_s, ssid);
if (wpa_config_remove_network(wpa_s->conf, ssid->id) < 0) { if (wpa_config_remove_network(wpa_s->conf, ssid->id) < 0) {
wpa_printf(MSG_ERROR, "dbus: %s: " wpa_printf(MSG_ERROR,
"error occurred when removing persistent group %d", "dbus: %s: error occurred when removing persistent group %d",
__func__, ssid->id); __func__, ssid->id);
return; return;
} }
@ -1987,6 +1987,7 @@ dbus_bool_t wpas_dbus_getter_p2p_group_ssid(DBusMessageIter *iter,
DBusError *error, void *user_data) DBusError *error, void *user_data)
{ {
struct wpa_supplicant *wpa_s = user_data; struct wpa_supplicant *wpa_s = user_data;
if (wpa_s->current_ssid == NULL) if (wpa_s->current_ssid == NULL)
return FALSE; return FALSE;
return wpas_dbus_simple_array_property_getter( return wpas_dbus_simple_array_property_getter(
@ -2279,31 +2280,31 @@ DBusMessage * wpas_dbus_handler_p2p_add_service(DBusMessage *message,
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
goto error; goto error;
if (!os_strcmp(entry.key, "service_type") && if (os_strcmp(entry.key, "service_type") == 0 &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
if (!os_strcmp(entry.str_value, "upnp")) if (os_strcmp(entry.str_value, "upnp") == 0)
upnp = 1; upnp = 1;
else if (!os_strcmp(entry.str_value, "bonjour")) else if (os_strcmp(entry.str_value, "bonjour") == 0)
bonjour = 1; bonjour = 1;
else else
goto error_clear; goto error_clear;
} else if (!os_strcmp(entry.key, "version") && } else if (os_strcmp(entry.key, "version") == 0 &&
entry.type == DBUS_TYPE_INT32) { entry.type == DBUS_TYPE_INT32) {
version = entry.uint32_value; version = entry.uint32_value;
} else if (!os_strcmp(entry.key, "service") && } else if (os_strcmp(entry.key, "service") == 0 &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
os_free(service); os_free(service);
service = os_strdup(entry.str_value); service = os_strdup(entry.str_value);
} else if (!os_strcmp(entry.key, "query")) { } else if (os_strcmp(entry.key, "query") == 0) {
if ((entry.type != DBUS_TYPE_ARRAY) || if (entry.type != DBUS_TYPE_ARRAY ||
(entry.array_type != DBUS_TYPE_BYTE)) entry.array_type != DBUS_TYPE_BYTE)
goto error_clear; goto error_clear;
query = wpabuf_alloc_copy( query = wpabuf_alloc_copy(
entry.bytearray_value, entry.bytearray_value,
entry.array_len); entry.array_len);
} else if (!os_strcmp(entry.key, "response")) { } else if (os_strcmp(entry.key, "response") == 0) {
if ((entry.type != DBUS_TYPE_ARRAY) || if (entry.type != DBUS_TYPE_ARRAY ||
(entry.array_type != DBUS_TYPE_BYTE)) entry.array_type != DBUS_TYPE_BYTE)
goto error_clear; goto error_clear;
resp = wpabuf_alloc_copy(entry.bytearray_value, resp = wpabuf_alloc_copy(entry.bytearray_value,
entry.array_len); entry.array_len);
@ -2364,11 +2365,11 @@ DBusMessage * wpas_dbus_handler_p2p_delete_service(
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
goto error; goto error;
if (!os_strcmp(entry.key, "service_type") && if (os_strcmp(entry.key, "service_type") == 0 &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
if (!os_strcmp(entry.str_value, "upnp")) if (os_strcmp(entry.str_value, "upnp") == 0)
upnp = 1; upnp = 1;
else if (!os_strcmp(entry.str_value, "bonjour")) else if (os_strcmp(entry.str_value, "bonjour") == 0)
bonjour = 1; bonjour = 1;
else else
goto error_clear; goto error_clear;
@ -2379,10 +2380,10 @@ DBusMessage * wpas_dbus_handler_p2p_delete_service(
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) { while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
goto error; goto error;
if (!os_strcmp(entry.key, "version") && if (os_strcmp(entry.key, "version") == 0 &&
entry.type == DBUS_TYPE_INT32) entry.type == DBUS_TYPE_INT32)
version = entry.uint32_value; version = entry.uint32_value;
else if (!os_strcmp(entry.key, "service") && else if (os_strcmp(entry.key, "service") == 0 &&
entry.type == DBUS_TYPE_STRING) { entry.type == DBUS_TYPE_STRING) {
os_free(service); os_free(service);
service = os_strdup(entry.str_value); service = os_strdup(entry.str_value);
@ -2403,9 +2404,9 @@ DBusMessage * wpas_dbus_handler_p2p_delete_service(
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
goto error; goto error;
if (!os_strcmp(entry.key, "query")) { if (os_strcmp(entry.key, "query") == 0) {
if ((entry.type != DBUS_TYPE_ARRAY) || if (entry.type != DBUS_TYPE_ARRAY ||
(entry.array_type != DBUS_TYPE_BYTE)) entry.array_type != DBUS_TYPE_BYTE)
goto error_clear; goto error_clear;
wpabuf_free(query); wpabuf_free(query);
query = wpabuf_alloc_copy( query = wpabuf_alloc_copy(
@ -2469,22 +2470,22 @@ DBusMessage * wpas_dbus_handler_p2p_service_sd_req(
while (wpa_dbus_dict_has_dict_entry(&iter_dict)) { while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
goto error; goto error;
if (!os_strcmp(entry.key, "peer_object") && if (os_strcmp(entry.key, "peer_object") == 0 &&
entry.type == DBUS_TYPE_OBJECT_PATH) { entry.type == DBUS_TYPE_OBJECT_PATH) {
peer_object_path = os_strdup(entry.str_value); peer_object_path = os_strdup(entry.str_value);
} else if (!os_strcmp(entry.key, "service_type") && } else if (os_strcmp(entry.key, "service_type") == 0 &&
entry.type == DBUS_TYPE_STRING) { entry.type == DBUS_TYPE_STRING) {
if (!os_strcmp(entry.str_value, "upnp")) if (os_strcmp(entry.str_value, "upnp") == 0)
upnp = 1; upnp = 1;
else else
goto error_clear; goto error_clear;
} else if (!os_strcmp(entry.key, "version") && } else if (os_strcmp(entry.key, "version") == 0 &&
entry.type == DBUS_TYPE_INT32) { entry.type == DBUS_TYPE_INT32) {
version = entry.uint32_value; version = entry.uint32_value;
} else if (!os_strcmp(entry.key, "service") && } else if (os_strcmp(entry.key, "service") == 0 &&
entry.type == DBUS_TYPE_STRING) { entry.type == DBUS_TYPE_STRING) {
service = os_strdup(entry.str_value); service = os_strdup(entry.str_value);
} else if (!os_strcmp(entry.key, "tlv")) { } else if (os_strcmp(entry.key, "tlv") == 0) {
if (entry.type != DBUS_TYPE_ARRAY || if (entry.type != DBUS_TYPE_ARRAY ||
entry.array_type != DBUS_TYPE_BYTE) entry.array_type != DBUS_TYPE_BYTE)
goto error_clear; goto error_clear;
@ -2562,17 +2563,17 @@ DBusMessage * wpas_dbus_handler_p2p_service_sd_res(
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
goto error; goto error;
if (!os_strcmp(entry.key, "peer_object") && if (os_strcmp(entry.key, "peer_object") == 0 &&
entry.type == DBUS_TYPE_OBJECT_PATH) { entry.type == DBUS_TYPE_OBJECT_PATH) {
peer_object_path = os_strdup(entry.str_value); peer_object_path = os_strdup(entry.str_value);
} else if (!os_strcmp(entry.key, "frequency") && } else if (os_strcmp(entry.key, "frequency") == 0 &&
entry.type == DBUS_TYPE_INT32) { entry.type == DBUS_TYPE_INT32) {
freq = entry.uint32_value; freq = entry.uint32_value;
} else if (!os_strcmp(entry.key, "dialog_token") && } else if (os_strcmp(entry.key, "dialog_token") == 0 &&
(entry.type == DBUS_TYPE_UINT32 || (entry.type == DBUS_TYPE_UINT32 ||
entry.type == DBUS_TYPE_INT32)) { entry.type == DBUS_TYPE_INT32)) {
dlg_tok = entry.uint32_value; dlg_tok = entry.uint32_value;
} else if (!os_strcmp(entry.key, "tlvs")) { } else if (os_strcmp(entry.key, "tlvs") == 0) {
if (entry.type != DBUS_TYPE_ARRAY || if (entry.type != DBUS_TYPE_ARRAY ||
entry.array_type != DBUS_TYPE_BYTE) entry.array_type != DBUS_TYPE_BYTE)
goto error_clear; goto error_clear;

View file

@ -41,8 +41,8 @@ static int wpas_dbus_handler_wps_role(DBusMessage *message,
dbus_message_iter_recurse(entry_iter, &variant_iter); dbus_message_iter_recurse(entry_iter, &variant_iter);
if (dbus_message_iter_get_arg_type(&variant_iter) != if (dbus_message_iter_get_arg_type(&variant_iter) !=
DBUS_TYPE_STRING) { DBUS_TYPE_STRING) {
wpa_printf(MSG_DEBUG, "dbus: WPS.Start - Wrong Role type, " wpa_printf(MSG_DEBUG,
"string required"); "dbus: WPS.Start - Wrong Role type, string required");
*reply = wpas_dbus_error_invalid_args(message, *reply = wpas_dbus_error_invalid_args(message,
"Role must be a string"); "Role must be a string");
return -1; return -1;
@ -70,10 +70,9 @@ static int wpas_dbus_handler_wps_type(DBusMessage *message,
char *val; char *val;
dbus_message_iter_recurse(entry_iter, &variant_iter); dbus_message_iter_recurse(entry_iter, &variant_iter);
if (dbus_message_iter_get_arg_type(&variant_iter) != if (dbus_message_iter_get_arg_type(&variant_iter) != DBUS_TYPE_STRING) {
DBUS_TYPE_STRING) { wpa_printf(MSG_DEBUG,
wpa_printf(MSG_DEBUG, "dbus: WPS.Start - Wrong Type type, " "dbus: WPS.Start - Wrong Type type, string required");
"string required");
*reply = wpas_dbus_error_invalid_args(message, *reply = wpas_dbus_error_invalid_args(message,
"Type must be a string"); "Type must be a string");
return -1; return -1;
@ -105,8 +104,8 @@ static int wpas_dbus_handler_wps_bssid(DBusMessage *message,
if (dbus_message_iter_get_arg_type(&variant_iter) != DBUS_TYPE_ARRAY || if (dbus_message_iter_get_arg_type(&variant_iter) != DBUS_TYPE_ARRAY ||
dbus_message_iter_get_element_type(&variant_iter) != dbus_message_iter_get_element_type(&variant_iter) !=
DBUS_TYPE_BYTE) { DBUS_TYPE_BYTE) {
wpa_printf(MSG_DEBUG, "dbus: WPS.Start - Wrong Bssid type, " wpa_printf(MSG_DEBUG,
"byte array required"); "dbus: WPS.Start - Wrong Bssid type, byte array required");
*reply = wpas_dbus_error_invalid_args( *reply = wpas_dbus_error_invalid_args(
message, "Bssid must be a byte array"); message, "Bssid must be a byte array");
return -1; return -1;
@ -114,8 +113,8 @@ static int wpas_dbus_handler_wps_bssid(DBusMessage *message,
dbus_message_iter_recurse(&variant_iter, &array_iter); dbus_message_iter_recurse(&variant_iter, &array_iter);
dbus_message_iter_get_fixed_array(&array_iter, &params->bssid, &len); dbus_message_iter_get_fixed_array(&array_iter, &params->bssid, &len);
if (len != ETH_ALEN) { if (len != ETH_ALEN) {
wpa_printf(MSG_DEBUG, "dbus: WPS.Stsrt - Wrong Bssid length " wpa_printf(MSG_DEBUG, "dbus: WPS.Stsrt - Wrong Bssid length %d",
"%d", len); len);
*reply = wpas_dbus_error_invalid_args(message, *reply = wpas_dbus_error_invalid_args(message,
"Bssid is wrong length"); "Bssid is wrong length");
return -1; return -1;
@ -132,10 +131,9 @@ static int wpas_dbus_handler_wps_pin(DBusMessage *message,
DBusMessageIter variant_iter; DBusMessageIter variant_iter;
dbus_message_iter_recurse(entry_iter, &variant_iter); dbus_message_iter_recurse(entry_iter, &variant_iter);
if (dbus_message_iter_get_arg_type(&variant_iter) != if (dbus_message_iter_get_arg_type(&variant_iter) != DBUS_TYPE_STRING) {
DBUS_TYPE_STRING) { wpa_printf(MSG_DEBUG,
wpa_printf(MSG_DEBUG, "dbus: WPS.Start - Wrong Pin type, " "dbus: WPS.Start - Wrong Pin type, string required");
"string required");
*reply = wpas_dbus_error_invalid_args(message, *reply = wpas_dbus_error_invalid_args(message,
"Pin must be a string"); "Pin must be a string");
return -1; return -1;
@ -158,8 +156,8 @@ static int wpas_dbus_handler_wps_p2p_dev_addr(DBusMessage *message,
if (dbus_message_iter_get_arg_type(&variant_iter) != DBUS_TYPE_ARRAY || if (dbus_message_iter_get_arg_type(&variant_iter) != DBUS_TYPE_ARRAY ||
dbus_message_iter_get_element_type(&variant_iter) != dbus_message_iter_get_element_type(&variant_iter) !=
DBUS_TYPE_BYTE) { DBUS_TYPE_BYTE) {
wpa_printf(MSG_DEBUG, "dbus: WPS.Start - Wrong " wpa_printf(MSG_DEBUG,
"P2PDeviceAddress type, byte array required"); "dbus: WPS.Start - Wrong P2PDeviceAddress type, byte array required");
*reply = wpas_dbus_error_invalid_args( *reply = wpas_dbus_error_invalid_args(
message, "P2PDeviceAddress must be a byte array"); message, "P2PDeviceAddress must be a byte array");
return -1; return -1;
@ -168,11 +166,11 @@ static int wpas_dbus_handler_wps_p2p_dev_addr(DBusMessage *message,
dbus_message_iter_get_fixed_array(&array_iter, &params->p2p_dev_addr, dbus_message_iter_get_fixed_array(&array_iter, &params->p2p_dev_addr,
&len); &len);
if (len != ETH_ALEN) { if (len != ETH_ALEN) {
wpa_printf(MSG_DEBUG, "dbus: WPS.Start - Wrong " wpa_printf(MSG_DEBUG,
"P2PDeviceAddress length %d", len); "dbus: WPS.Start - Wrong P2PDeviceAddress length %d",
*reply = wpas_dbus_error_invalid_args(message, len);
"P2PDeviceAddress " *reply = wpas_dbus_error_invalid_args(
"has wrong length"); message, "P2PDeviceAddress has wrong length");
return -1; return -1;
} }
return 0; return 0;
@ -258,8 +256,8 @@ DBusMessage * wpas_dbus_handler_wps_start(DBusMessage *message,
return wpas_dbus_error_invalid_args(message, return wpas_dbus_error_invalid_args(message,
"Type not specified"); "Type not specified");
} else if (params.role == 2 && params.pin == NULL) { } else if (params.role == 2 && params.pin == NULL) {
wpa_printf(MSG_DEBUG, "dbus: WPS.Start - Pin required for " wpa_printf(MSG_DEBUG,
"registrar role"); "dbus: WPS.Start - Pin required for registrar role");
return wpas_dbus_error_invalid_args( return wpas_dbus_error_invalid_args(
message, "Pin required for registrar role."); message, "Pin required for registrar role.");
} }
@ -295,8 +293,8 @@ DBusMessage * wpas_dbus_handler_wps_start(DBusMessage *message,
} }
if (ret < 0) { if (ret < 0) {
wpa_printf(MSG_DEBUG, "dbus: WPS.Start wpas_wps_failed in " wpa_printf(MSG_DEBUG,
"role %s and key %s", "dbus: WPS.Start wpas_wps_failed in role %s and key %s",
(params.role == 1 ? "enrollee" : "registrar"), (params.role == 1 ? "enrollee" : "registrar"),
(params.type == 0 ? "" : (params.type == 0 ? "" :
(params.type == 1 ? "pin" : "pbc"))); (params.type == 1 ? "pin" : "pbc")));
@ -339,7 +337,8 @@ dbus_bool_t wpas_dbus_getter_process_credentials(DBusMessageIter *iter,
void *user_data) void *user_data)
{ {
struct wpa_supplicant *wpa_s = user_data; struct wpa_supplicant *wpa_s = user_data;
dbus_bool_t process = (wpa_s->conf->wps_cred_processing != 1); dbus_bool_t process = wpa_s->conf->wps_cred_processing != 1;
return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN, return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
&process, error); &process, error);
} }
@ -366,7 +365,7 @@ dbus_bool_t wpas_dbus_setter_process_credentials(DBusMessageIter *iter,
&process_credentials)) &process_credentials))
return FALSE; return FALSE;
old_pc = (wpa_s->conf->wps_cred_processing != 1); old_pc = wpa_s->conf->wps_cred_processing != 1;
wpa_s->conf->wps_cred_processing = (process_credentials ? 2 : 1); wpa_s->conf->wps_cred_processing = (process_credentials ? 2 : 1);
if ((wpa_s->conf->wps_cred_processing != 1) != old_pc) if ((wpa_s->conf->wps_cred_processing != 1) != old_pc)

View file

@ -91,20 +91,17 @@ static DBusMessage * get_all_properties(DBusMessage *message, char *interface,
wpa_printf(MSG_ERROR, "%s: out of memory creating reply", wpa_printf(MSG_ERROR, "%s: out of memory creating reply",
__func__); __func__);
dbus_message_unref(reply); dbus_message_unref(reply);
reply = dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY, return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
"out of memory"); "out of memory");
return reply;
} }
dbus_error_init(&error); dbus_error_init(&error);
if (!fill_dict_with_properties(&dict_iter, obj_dsc->properties, if (!fill_dict_with_properties(&dict_iter, obj_dsc->properties,
interface, obj_dsc->user_data, &error)) interface, obj_dsc->user_data, &error)) {
{
dbus_message_unref(reply); dbus_message_unref(reply);
reply = wpas_dbus_reply_new_from_error(message, &error, reply = wpas_dbus_reply_new_from_error(
DBUS_ERROR_INVALID_ARGS, message, &error, DBUS_ERROR_INVALID_ARGS,
"No readable properties" "No readable properties in this interface");
" in this interface");
dbus_error_free(&error); dbus_error_free(&error);
return reply; return reply;
} }
@ -135,6 +132,7 @@ static int is_signature_correct(DBusMessage *message,
for (arg = method_dsc->args; arg && arg->name; arg++) { for (arg = method_dsc->args; arg && arg->name; arg++) {
if (arg->dir == ARG_IN) { if (arg->dir == ARG_IN) {
size_t blen = registered_sig + MAX_SIG_LEN - pos; size_t blen = registered_sig + MAX_SIG_LEN - pos;
ret = os_snprintf(pos, blen, "%s", arg->type); ret = os_snprintf(pos, blen, "%s", arg->type);
if (os_snprintf_error(blen, ret)) if (os_snprintf_error(blen, ret))
return 0; return 0;
@ -298,8 +296,7 @@ static DBusMessage * properties_handler(DBusMessage *message,
!os_strncmp(WPA_DBUS_PROPERTIES_GETALL, method, !os_strncmp(WPA_DBUS_PROPERTIES_GETALL, method,
WPAS_DBUS_METHOD_SIGNAL_PROP_MAX)) { WPAS_DBUS_METHOD_SIGNAL_PROP_MAX)) {
/* First argument: interface name (DBUS_TYPE_STRING) */ /* First argument: interface name (DBUS_TYPE_STRING) */
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) {
{
return dbus_message_new_error(message, return dbus_message_new_error(message,
DBUS_ERROR_INVALID_ARGS, DBUS_ERROR_INVALID_ARGS,
NULL); NULL);
@ -355,8 +352,7 @@ static DBusMessage * msg_method_handler(DBusMessage *message,
NULL); NULL);
} }
return method_dsc->method_handler(message, return method_dsc->method_handler(message, obj_dsc->user_data);
obj_dsc->user_data);
} }
@ -405,8 +401,7 @@ static DBusHandlerResult message_handler(DBusConnection *connection,
#else /* CONFIG_CTRL_IFACE_DBUS_INTRO */ #else /* CONFIG_CTRL_IFACE_DBUS_INTRO */
reply = dbus_message_new_error( reply = dbus_message_new_error(
message, DBUS_ERROR_UNKNOWN_METHOD, message, DBUS_ERROR_UNKNOWN_METHOD,
"wpa_supplicant was compiled without " "wpa_supplicant was compiled without introspection support.");
"introspection support.");
#endif /* CONFIG_CTRL_IFACE_DBUS_INTRO */ #endif /* CONFIG_CTRL_IFACE_DBUS_INTRO */
} else if (!os_strncmp(WPA_DBUS_PROPERTIES_INTERFACE, msg_interface, } else if (!os_strncmp(WPA_DBUS_PROPERTIES_INTERFACE, msg_interface,
WPAS_DBUS_INTERFACE_MAX)) { WPAS_DBUS_INTERFACE_MAX)) {
@ -459,6 +454,7 @@ static void free_dbus_object_desc_cb(DBusConnection *connection, void *obj_dsc)
free_dbus_object_desc(obj_dsc); free_dbus_object_desc(obj_dsc);
} }
/** /**
* wpa_dbus_ctrl_iface_init - Initialize dbus control interface * wpa_dbus_ctrl_iface_init - Initialize dbus control interface
* @application_data: Pointer to application specific data structure * @application_data: Pointer to application specific data structure
@ -486,30 +482,28 @@ int wpa_dbus_ctrl_iface_init(struct wpas_dbus_priv *iface,
obj_desc->path = os_strdup(dbus_path); obj_desc->path = os_strdup(dbus_path);
/* Register the message handler for the global dbus interface */ /* Register the message handler for the global dbus interface */
if (!dbus_connection_register_object_path(iface->con, if (!dbus_connection_register_object_path(iface->con, dbus_path,
dbus_path, &wpa_vtable, &wpa_vtable, obj_desc)) {
obj_desc)) { wpa_printf(MSG_ERROR, "dbus: Could not set up message handler");
wpa_printf(MSG_ERROR, "dbus: Could not set up message "
"handler");
return -1; return -1;
} }
/* Register our service with the message bus */ /* Register our service with the message bus */
dbus_error_init(&error); dbus_error_init(&error);
switch (dbus_bus_request_name(iface->con, dbus_service, switch (dbus_bus_request_name(iface->con, dbus_service, 0, &error)) {
0, &error)) {
case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER: case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
ret = 0; ret = 0;
break; break;
case DBUS_REQUEST_NAME_REPLY_EXISTS: case DBUS_REQUEST_NAME_REPLY_EXISTS:
case DBUS_REQUEST_NAME_REPLY_IN_QUEUE: case DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER: case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER:
wpa_printf(MSG_ERROR, "dbus: Could not request service name: " wpa_printf(MSG_ERROR,
"already registered"); "dbus: Could not request service name: already registered");
break; break;
default: default:
wpa_printf(MSG_ERROR, "dbus: Could not request service name: " wpa_printf(MSG_ERROR,
"%s %s", error.name, error.message); "dbus: Could not request service name: %s %s",
error.name, error.message);
break; break;
} }
dbus_error_free(&error); dbus_error_free(&error);
@ -533,14 +527,12 @@ int wpa_dbus_ctrl_iface_init(struct wpas_dbus_priv *iface,
* *
* Registers a new interface with dbus and assigns it a dbus object path. * Registers a new interface with dbus and assigns it a dbus object path.
*/ */
int wpa_dbus_register_object_per_iface( int wpa_dbus_register_object_per_iface(struct wpas_dbus_priv *ctrl_iface,
struct wpas_dbus_priv *ctrl_iface,
const char *path, const char *ifname, const char *path, const char *ifname,
struct wpa_dbus_object_desc *obj_desc) struct wpa_dbus_object_desc *obj_desc)
{ {
DBusConnection *con; DBusConnection *con;
DBusError error; DBusError error;
DBusObjectPathVTable vtable = { DBusObjectPathVTable vtable = {
&free_dbus_object_desc_cb, &message_handler, &free_dbus_object_desc_cb, &message_handler,
NULL, NULL, NULL, NULL NULL, NULL, NULL, NULL
@ -558,14 +550,12 @@ int wpa_dbus_register_object_per_iface(
/* Register the message handler for the interface functions */ /* Register the message handler for the interface functions */
if (!dbus_connection_try_register_object_path(con, path, &vtable, if (!dbus_connection_try_register_object_path(con, path, &vtable,
obj_desc, &error)) { obj_desc, &error)) {
if (!os_strcmp(error.name, DBUS_ERROR_OBJECT_PATH_IN_USE)) { if (os_strcmp(error.name, DBUS_ERROR_OBJECT_PATH_IN_USE) == 0) {
wpa_printf(MSG_DEBUG, "dbus: %s", error.message); wpa_printf(MSG_DEBUG, "dbus: %s", error.message);
} else { } else {
wpa_printf(MSG_ERROR, "dbus: Could not set up message " wpa_printf(MSG_ERROR,
"handler for interface %s object %s", "dbus: Could not set up message handler for interface %s object %s (error: %s message: %s)",
ifname, path); ifname, path, error.name, error.message);
wpa_printf(MSG_ERROR, "dbus error: %s", error.name);
wpa_printf(MSG_ERROR, "dbus: %s", error.message);
} }
dbus_error_free(&error); dbus_error_free(&error);
return -1; return -1;
@ -595,8 +585,9 @@ int wpa_dbus_unregister_object_per_iface(
dbus_connection_get_object_path_data(con, path, (void **) &obj_desc); dbus_connection_get_object_path_data(con, path, (void **) &obj_desc);
if (!obj_desc) { if (!obj_desc) {
wpa_printf(MSG_ERROR, "dbus: %s: Could not obtain object's " wpa_printf(MSG_ERROR,
"private data: %s", __func__, path); "dbus: %s: Could not obtain object's private data: %s",
__func__, path);
return 0; return 0;
} }
@ -639,13 +630,13 @@ static dbus_bool_t put_changed_properties(
dbus_error_init(&error); dbus_error_init(&error);
if (!dsc->getter(&entry_iter, &error, obj_dsc->user_data)) { if (!dsc->getter(&entry_iter, &error, obj_dsc->user_data)) {
if (dbus_error_is_set(&error)) { if (dbus_error_is_set(&error)) {
wpa_printf(MSG_ERROR, "dbus: %s: Cannot get " wpa_printf(MSG_ERROR,
"new value of property %s: (%s) %s", "dbus: %s: Cannot get new value of property %s: (%s) %s",
__func__, dsc->dbus_property, __func__, dsc->dbus_property,
error.name, error.message); error.name, error.message);
} else { } else {
wpa_printf(MSG_ERROR, "dbus: %s: Cannot get " wpa_printf(MSG_ERROR,
"new value of property %s", "dbus: %s: Cannot get new value of property %s",
__func__, dsc->dbus_property); __func__, dsc->dbus_property);
} }
dbus_error_free(&error); dbus_error_free(&error);
@ -684,19 +675,14 @@ static void do_send_prop_changed_signal(
/* Invalidated properties array (empty) */ /* Invalidated properties array (empty) */
!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY, !dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
"s", &dict_iter) || "s", &dict_iter) ||
!dbus_message_iter_close_container(&signal_iter, &dict_iter)) !dbus_message_iter_close_container(&signal_iter, &dict_iter)) {
goto err;
dbus_connection_send(con, msg, NULL);
out:
dbus_message_unref(msg);
return;
err:
wpa_printf(MSG_DEBUG, "dbus: %s: Failed to construct signal", wpa_printf(MSG_DEBUG, "dbus: %s: Failed to construct signal",
__func__); __func__);
goto out; } else {
dbus_connection_send(con, msg, NULL);
}
dbus_message_unref(msg);
} }
@ -716,19 +702,14 @@ static void do_send_deprecated_prop_changed_signal(
if (!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY, if (!dbus_message_iter_open_container(&signal_iter, DBUS_TYPE_ARRAY,
"{sv}", &dict_iter) || "{sv}", &dict_iter) ||
!put_changed_properties(obj_dsc, interface, &dict_iter, 1) || !put_changed_properties(obj_dsc, interface, &dict_iter, 1) ||
!dbus_message_iter_close_container(&signal_iter, &dict_iter)) !dbus_message_iter_close_container(&signal_iter, &dict_iter)) {
goto err;
dbus_connection_send(con, msg, NULL);
out:
dbus_message_unref(msg);
return;
err:
wpa_printf(MSG_DEBUG, "dbus: %s: Failed to construct signal", wpa_printf(MSG_DEBUG, "dbus: %s: Failed to construct signal",
__func__); __func__);
goto out; } else {
dbus_connection_send(con, msg, NULL);
}
dbus_message_unref(msg);
} }
@ -760,8 +741,9 @@ static void flush_object_timeout_handler(void *eloop_ctx, void *timeout_ctx)
DBusConnection *con = eloop_ctx; DBusConnection *con = eloop_ctx;
struct wpa_dbus_object_desc *obj_desc = timeout_ctx; struct wpa_dbus_object_desc *obj_desc = timeout_ctx;
wpa_printf(MSG_DEBUG, "dbus: %s: Timeout - sending changed properties " wpa_printf(MSG_DEBUG,
"of object %s", __func__, obj_desc->path); "dbus: %s: Timeout - sending changed properties of object %s",
__func__, obj_desc->path);
wpa_dbus_flush_object_changed_properties(con, obj_desc->path); wpa_dbus_flush_object_changed_properties(con, obj_desc->path);
} }
@ -872,8 +854,9 @@ void wpa_dbus_mark_property_changed(struct wpas_dbus_priv *iface,
dbus_connection_get_object_path_data(iface->con, path, dbus_connection_get_object_path_data(iface->con, path,
(void **) &obj_desc); (void **) &obj_desc);
if (!obj_desc) { if (!obj_desc) {
wpa_printf(MSG_ERROR, "dbus: wpa_dbus_property_changed: " wpa_printf(MSG_ERROR,
"could not obtain object's private data: %s", path); "dbus: wpa_dbus_property_changed: could not obtain object's private data: %s",
path);
return; return;
} }
@ -886,8 +869,9 @@ void wpa_dbus_mark_property_changed(struct wpas_dbus_priv *iface,
} }
if (!dsc || !dsc->dbus_property) { if (!dsc || !dsc->dbus_property) {
wpa_printf(MSG_ERROR, "dbus: wpa_dbus_property_changed: " wpa_printf(MSG_ERROR,
"no property %s in object %s", property, path); "dbus: wpa_dbus_property_changed: no property %s in object %s",
property, path);
return; return;
} }
@ -924,8 +908,9 @@ dbus_bool_t wpa_dbus_get_object_properties(struct wpas_dbus_priv *iface,
dbus_connection_get_object_path_data(iface->con, path, dbus_connection_get_object_path_data(iface->con, path,
(void **) &obj_desc); (void **) &obj_desc);
if (!obj_desc) { if (!obj_desc) {
wpa_printf(MSG_ERROR, "dbus: %s: could not obtain object's " wpa_printf(MSG_ERROR,
"private data: %s", __func__, path); "dbus: %s: could not obtain object's private data: %s",
__func__, path);
return FALSE; return FALSE;
} }
@ -939,8 +924,9 @@ dbus_bool_t wpa_dbus_get_object_properties(struct wpas_dbus_priv *iface,
if (!fill_dict_with_properties(&dict_iter, obj_desc->properties, if (!fill_dict_with_properties(&dict_iter, obj_desc->properties,
interface, obj_desc->user_data, interface, obj_desc->user_data,
&error)) { &error)) {
wpa_printf(MSG_ERROR, "dbus: %s: failed to get object" wpa_printf(MSG_ERROR,
" properties: (%s) %s", __func__, "dbus: %s: failed to get object properties: (%s) %s",
__func__,
dbus_error_is_set(&error) ? error.name : "none", dbus_error_is_set(&error) ? error.name : "none",
dbus_error_is_set(&error) ? error.message : "none"); dbus_error_is_set(&error) ? error.message : "none");
dbus_error_free(&error); dbus_error_free(&error);

View file

@ -96,6 +96,7 @@ static void extract_interfaces_methods(
{ {
const struct wpa_dbus_method_desc *dsc; const struct wpa_dbus_method_desc *dsc;
struct interfaces *iface; struct interfaces *iface;
for (dsc = methods; dsc && dsc->dbus_method; dsc++) { for (dsc = methods; dsc && dsc->dbus_method; dsc++) {
iface = add_interface(list, dsc->dbus_interface); iface = add_interface(list, dsc->dbus_interface);
if (iface) if (iface)
@ -110,6 +111,7 @@ static void extract_interfaces_signals(
{ {
const struct wpa_dbus_signal_desc *dsc; const struct wpa_dbus_signal_desc *dsc;
struct interfaces *iface; struct interfaces *iface;
for (dsc = signals; dsc && dsc->dbus_signal; dsc++) { for (dsc = signals; dsc && dsc->dbus_signal; dsc++) {
iface = add_interface(list, dsc->dbus_interface); iface = add_interface(list, dsc->dbus_interface);
if (iface) if (iface)
@ -124,6 +126,7 @@ static void extract_interfaces_properties(
{ {
const struct wpa_dbus_property_desc *dsc; const struct wpa_dbus_property_desc *dsc;
struct interfaces *iface; struct interfaces *iface;
for (dsc = properties; dsc && dsc->dbus_property; dsc++) { for (dsc = properties; dsc && dsc->dbus_property; dsc++) {
iface = add_interface(list, dsc->dbus_interface); iface = add_interface(list, dsc->dbus_interface);
if (iface) if (iface)
@ -154,14 +157,14 @@ static void extract_interfaces(struct dl_list *list,
static void add_interfaces(struct dl_list *list, struct wpabuf *xml) static void add_interfaces(struct dl_list *list, struct wpabuf *xml)
{ {
struct interfaces *iface, *n; struct interfaces *iface, *n;
dl_list_for_each_safe(iface, n, list, struct interfaces, list) { dl_list_for_each_safe(iface, n, list, struct interfaces, list) {
if (wpabuf_len(iface->xml) + 20 < wpabuf_tailroom(xml)) { if (wpabuf_len(iface->xml) + 20 < wpabuf_tailroom(xml)) {
wpabuf_put_buf(xml, iface->xml); wpabuf_put_buf(xml, iface->xml);
wpabuf_put_str(xml, "</interface>"); wpabuf_put_str(xml, "</interface>");
} else { } else {
wpa_printf(MSG_DEBUG, "dbus: Not enough room for " wpa_printf(MSG_DEBUG,
"add_interfaces inspect data: tailroom %u, " "dbus: Not enough room for add_interfaces inspect data: tailroom %u, add %u",
"add %u",
(unsigned int) wpabuf_tailroom(xml), (unsigned int) wpabuf_tailroom(xml),
(unsigned int) wpabuf_len(iface->xml)); (unsigned int) wpabuf_len(iface->xml));
} }
@ -229,6 +232,7 @@ static void add_wpas_interfaces(struct wpabuf *xml,
struct wpa_dbus_object_desc *obj_dsc) struct wpa_dbus_object_desc *obj_dsc)
{ {
struct dl_list ifaces; struct dl_list ifaces;
dl_list_init(&ifaces); dl_list_init(&ifaces);
extract_interfaces(&ifaces, obj_dsc); extract_interfaces(&ifaces, obj_dsc);
add_interfaces(&ifaces, xml); add_interfaces(&ifaces, xml);
@ -270,6 +274,7 @@ DBusMessage * wpa_dbus_introspect(DBusMessage *message,
reply = dbus_message_new_method_return(message); reply = dbus_message_new_method_return(message);
if (reply) { if (reply) {
const char *intro_str = wpabuf_head(xml); const char *intro_str = wpabuf_head(xml);
dbus_message_append_args(reply, DBUS_TYPE_STRING, &intro_str, dbus_message_append_args(reply, DBUS_TYPE_STRING, &intro_str,
DBUS_TYPE_INVALID); DBUS_TYPE_INVALID);
} }

View file

@ -92,9 +92,9 @@ char * wpas_dbus_decompose_object_path(const char *path, char **network,
*/ */
DBusMessage * wpas_dbus_new_invalid_iface_error(DBusMessage *message) DBusMessage * wpas_dbus_new_invalid_iface_error(DBusMessage *message)
{ {
return dbus_message_new_error(message, WPAS_ERROR_INVALID_IFACE, return dbus_message_new_error(
"wpa_supplicant knows nothing about " message, WPAS_ERROR_INVALID_IFACE,
"this interface."); "wpa_supplicant knows nothing about this interface.");
} }
@ -239,6 +239,7 @@ static DBusHandlerResult wpas_iface_message_handler(DBusConnection *connection,
if (network && !strcmp(msg_interface, WPAS_DBUS_IFACE_NETWORK)) { if (network && !strcmp(msg_interface, WPAS_DBUS_IFACE_NETWORK)) {
/* A method for one of this interface's configured networks */ /* A method for one of this interface's configured networks */
int nid = strtoul(network, NULL, 10); int nid = strtoul(network, NULL, 10);
if (errno != EINVAL) if (errno != EINVAL)
reply = wpas_dispatch_network_method(message, wpa_s, reply = wpas_dispatch_network_method(message, wpa_s,
nid); nid);
@ -279,14 +280,14 @@ static DBusHandlerResult wpas_iface_message_handler(DBusConnection *connection,
reply = wpas_dbus_iface_remove_blobs(message, wpa_s); reply = wpas_dbus_iface_remove_blobs(message, wpa_s);
#endif /* CONFIG_NO_CONFIG_BLOBS */ #endif /* CONFIG_NO_CONFIG_BLOBS */
#ifdef CONFIG_WPS #ifdef CONFIG_WPS
else if (!os_strcmp(method, "wpsPbc")) else if (os_strcmp(method, "wpsPbc") == 0)
reply = wpas_dbus_iface_wps_pbc(message, wpa_s); reply = wpas_dbus_iface_wps_pbc(message, wpa_s);
else if (!os_strcmp(method, "wpsPin")) else if (os_strcmp(method, "wpsPin") == 0)
reply = wpas_dbus_iface_wps_pin(message, wpa_s); reply = wpas_dbus_iface_wps_pin(message, wpa_s);
else if (!os_strcmp(method, "wpsReg")) else if (os_strcmp(method, "wpsReg") == 0)
reply = wpas_dbus_iface_wps_reg(message, wpa_s); reply = wpas_dbus_iface_wps_reg(message, wpa_s);
#endif /* CONFIG_WPS */ #endif /* CONFIG_WPS */
else if (!os_strcmp(method, "flush")) else if (os_strcmp(method, "flush") == 0)
reply = wpas_dbus_iface_flush(message, wpa_s); reply = wpas_dbus_iface_flush(message, wpa_s);
} }
@ -389,8 +390,8 @@ void wpa_supplicant_dbus_notify_scan_results(struct wpa_supplicant *wpa_s)
WPAS_DBUS_IFACE_INTERFACE, WPAS_DBUS_IFACE_INTERFACE,
"ScanResultsAvailable"); "ScanResultsAvailable");
if (_signal == NULL) { if (_signal == NULL) {
wpa_printf(MSG_ERROR, "dbus: Not enough memory to send scan " wpa_printf(MSG_ERROR,
"results signal"); "dbus: Not enough memory to send scan results signal");
return; return;
} }
dbus_connection_send(iface->con, _signal, NULL); dbus_connection_send(iface->con, _signal, NULL);
@ -434,9 +435,8 @@ void wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
"StateChange"); "StateChange");
if (_signal == NULL) { if (_signal == NULL) {
wpa_printf(MSG_ERROR, wpa_printf(MSG_ERROR,
"dbus: wpa_supplicant_dbus_notify_state_change: " "dbus: %s: could not create dbus signal; likely out of memory",
"could not create dbus signal; likely out of " __func__);
"memory");
return; return;
} }
@ -448,9 +448,8 @@ void wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
DBUS_TYPE_STRING, &old_state_str, DBUS_TYPE_STRING, &old_state_str,
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
wpa_printf(MSG_ERROR, wpa_printf(MSG_ERROR,
"dbus: wpa_supplicant_dbus_notify_state_change: " "dbus: %s: Not enough memory to construct state change signal",
"Not enough memory to construct state change " __func__);
"signal");
goto out; goto out;
} }
@ -482,8 +481,8 @@ void wpa_supplicant_dbus_notify_scanning(struct wpa_supplicant *wpa_s)
WPAS_DBUS_IFACE_INTERFACE, WPAS_DBUS_IFACE_INTERFACE,
"Scanning"); "Scanning");
if (_signal == NULL) { if (_signal == NULL) {
wpa_printf(MSG_ERROR, "dbus: Not enough memory to send scan " wpa_printf(MSG_ERROR,
"results signal"); "dbus: Not enough memory to send scan results signal");
return; return;
} }
@ -492,8 +491,8 @@ void wpa_supplicant_dbus_notify_scanning(struct wpa_supplicant *wpa_s)
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
dbus_connection_send(iface->con, _signal, NULL); dbus_connection_send(iface->con, _signal, NULL);
} else { } else {
wpa_printf(MSG_ERROR, "dbus: Not enough memory to construct " wpa_printf(MSG_ERROR,
"signal"); "dbus: Not enough memory to construct signal");
} }
dbus_message_unref(_signal); dbus_message_unref(_signal);
} }
@ -518,9 +517,8 @@ void wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,
"WpsCred"); "WpsCred");
if (_signal == NULL) { if (_signal == NULL) {
wpa_printf(MSG_ERROR, wpa_printf(MSG_ERROR,
"dbus: wpa_supplicant_dbus_notify_wps_cred: " "dbus: %s: Could not create dbus signal; likely out of memory",
"Could not create dbus signal; likely out of " __func__);
"memory");
return; return;
} }
@ -529,8 +527,8 @@ void wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,
&cred->cred_attr, cred->cred_attr_len, &cred->cred_attr, cred->cred_attr_len,
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
wpa_printf(MSG_ERROR, wpa_printf(MSG_ERROR,
"dbus: wpa_supplicant_dbus_notify_wps_cred: " "dbus: %s: Not enough memory to construct signal",
"Not enough memory to construct signal"); __func__);
goto out; goto out;
} }
@ -569,9 +567,8 @@ void wpa_supplicant_dbus_notify_certification(struct wpa_supplicant *wpa_s,
"Certification"); "Certification");
if (_signal == NULL) { if (_signal == NULL) {
wpa_printf(MSG_ERROR, wpa_printf(MSG_ERROR,
"dbus: wpa_supplicant_dbus_notify_certification: " "dbus: %s: Could not create dbus signal; likely out of memory",
"Could not create dbus signal; likely out of " __func__);
"memory");
return; return;
} }
@ -587,8 +584,8 @@ void wpa_supplicant_dbus_notify_certification(struct wpa_supplicant *wpa_s,
&cert_hex, cert_hex_len, &cert_hex, cert_hex_len,
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
wpa_printf(MSG_ERROR, wpa_printf(MSG_ERROR,
"dbus: wpa_supplicant_dbus_notify_certification: " "dbus: %s: Not enough memory to construct signal",
"Not enough memory to construct signal"); __func__);
goto out; goto out;
} }
@ -620,8 +617,7 @@ int wpa_supplicant_dbus_ctrl_iface_init(struct wpas_dbus_priv *iface)
if (!dbus_connection_register_object_path(iface->con, if (!dbus_connection_register_object_path(iface->con,
WPAS_DBUS_PATH, &wpas_vtable, WPAS_DBUS_PATH, &wpas_vtable,
iface)) { iface)) {
wpa_printf(MSG_ERROR, "dbus: Could not set up message " wpa_printf(MSG_ERROR, "dbus: Could not set up message handler");
"handler");
return -1; return -1;
} }
@ -635,12 +631,13 @@ int wpa_supplicant_dbus_ctrl_iface_init(struct wpas_dbus_priv *iface)
case DBUS_REQUEST_NAME_REPLY_EXISTS: case DBUS_REQUEST_NAME_REPLY_EXISTS:
case DBUS_REQUEST_NAME_REPLY_IN_QUEUE: case DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER: case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER:
wpa_printf(MSG_ERROR, "dbus: Could not request service name: " wpa_printf(MSG_ERROR,
"already registered"); "dbus: Could not request service name: already registered");
break; break;
default: default:
wpa_printf(MSG_ERROR, "dbus: Could not request service name: " wpa_printf(MSG_ERROR,
"%s %s", error.name, error.message); "dbus: Could not request service name: %s %s",
error.name, error.message);
break; break;
} }
dbus_error_free(&error); dbus_error_free(&error);
@ -689,8 +686,9 @@ int wpas_dbus_register_iface(struct wpa_supplicant *wpa_s)
/* Register the message handler for the interface functions */ /* Register the message handler for the interface functions */
if (!dbus_connection_register_fallback(con, wpa_s->dbus_path, &vtable, if (!dbus_connection_register_fallback(con, wpa_s->dbus_path, &vtable,
wpa_s)) { wpa_s)) {
wpa_printf(MSG_ERROR, "dbus: Could not set up message " wpa_printf(MSG_ERROR,
"handler for interface %s", wpa_s->ifname); "dbus: Could not set up message handler for interface %s",
wpa_s->ifname);
return -1; return -1;
} }

View file

@ -104,7 +104,12 @@ wpa_supplicant_dbus_notify_scanning(struct wpa_supplicant *wpa_s)
{ {
} }
#define wpa_supplicant_dbus_notify_state_change(w,n,o) do { } while (0) static inline void
wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
enum wpa_states new_state,
enum wpa_states old_state)
{
}
static inline void static inline void
wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s, wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,

View file

@ -37,9 +37,9 @@ DBusMessage * wpas_dbus_new_invalid_opts_error(DBusMessage *message,
{ {
DBusMessage *reply; DBusMessage *reply;
reply = dbus_message_new_error(message, WPAS_ERROR_INVALID_OPTS, reply = dbus_message_new_error(
"Did not receive correct message " message, WPAS_ERROR_INVALID_OPTS,
"arguments."); "Did not receive correct message arguments.");
if (arg != NULL) if (arg != NULL)
dbus_message_append_args(reply, DBUS_TYPE_STRING, &arg, dbus_message_append_args(reply, DBUS_TYPE_STRING, &arg,
DBUS_TYPE_INVALID); DBUS_TYPE_INVALID);
@ -112,28 +112,28 @@ DBusMessage * wpas_dbus_global_add_interface(DBusMessage *message,
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
goto error; goto error;
if (!strcmp(entry.key, "driver") && if (!strcmp(entry.key, "driver") &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
os_free(driver); os_free(driver);
driver = os_strdup(entry.str_value); driver = os_strdup(entry.str_value);
wpa_dbus_dict_entry_clear(&entry); wpa_dbus_dict_entry_clear(&entry);
if (driver == NULL) if (driver == NULL)
goto error; goto error;
} else if (!strcmp(entry.key, "driver-params") && } else if (!strcmp(entry.key, "driver-params") &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
os_free(driver_param); os_free(driver_param);
driver_param = os_strdup(entry.str_value); driver_param = os_strdup(entry.str_value);
wpa_dbus_dict_entry_clear(&entry); wpa_dbus_dict_entry_clear(&entry);
if (driver_param == NULL) if (driver_param == NULL)
goto error; goto error;
} else if (!strcmp(entry.key, "config-file") && } else if (!strcmp(entry.key, "config-file") &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
os_free(confname); os_free(confname);
confname = os_strdup(entry.str_value); confname = os_strdup(entry.str_value);
wpa_dbus_dict_entry_clear(&entry); wpa_dbus_dict_entry_clear(&entry);
if (confname == NULL) if (confname == NULL)
goto error; goto error;
} else if (!strcmp(entry.key, "bridge-ifname") && } else if (!strcmp(entry.key, "bridge-ifname") &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
os_free(bridge_ifname); os_free(bridge_ifname);
bridge_ifname = os_strdup(entry.str_value); bridge_ifname = os_strdup(entry.str_value);
wpa_dbus_dict_entry_clear(&entry); wpa_dbus_dict_entry_clear(&entry);
@ -151,13 +151,13 @@ DBusMessage * wpas_dbus_global_add_interface(DBusMessage *message,
* an error if we already control it. * an error if we already control it.
*/ */
if (wpa_supplicant_get_iface(global, ifname) != NULL) { if (wpa_supplicant_get_iface(global, ifname) != NULL) {
reply = dbus_message_new_error(message, reply = dbus_message_new_error(
WPAS_ERROR_EXISTS_ERROR, message, WPAS_ERROR_EXISTS_ERROR,
"wpa_supplicant already " "wpa_supplicant already controls this interface.");
"controls this interface.");
} else { } else {
struct wpa_supplicant *wpa_s; struct wpa_supplicant *wpa_s;
struct wpa_interface iface; struct wpa_interface iface;
os_memset(&iface, 0, sizeof(iface)); os_memset(&iface, 0, sizeof(iface));
iface.ifname = ifname; iface.ifname = ifname;
iface.driver = driver; iface.driver = driver;
@ -165,17 +165,17 @@ DBusMessage * wpas_dbus_global_add_interface(DBusMessage *message,
iface.confname = confname; iface.confname = confname;
iface.bridge_ifname = bridge_ifname; iface.bridge_ifname = bridge_ifname;
/* Otherwise, have wpa_supplicant attach to it. */ /* Otherwise, have wpa_supplicant attach to it. */
if ((wpa_s = wpa_supplicant_add_iface(global, &iface))) { wpa_s = wpa_supplicant_add_iface(global, &iface);
if (wpa_s) {
const char *path = wpa_s->dbus_path; const char *path = wpa_s->dbus_path;
reply = dbus_message_new_method_return(message); reply = dbus_message_new_method_return(message);
dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH,
&path, DBUS_TYPE_INVALID); &path, DBUS_TYPE_INVALID);
} else { } else {
reply = dbus_message_new_error(message, reply = dbus_message_new_error(
WPAS_ERROR_ADD_ERROR, message, WPAS_ERROR_ADD_ERROR,
"wpa_supplicant " "wpa_supplicant couldn't grab this interface.");
"couldn't grab this "
"interface.");
} }
} }
@ -226,10 +226,9 @@ DBusMessage * wpas_dbus_global_remove_interface(DBusMessage *message,
if (!wpa_supplicant_remove_iface(global, wpa_s, 0)) { if (!wpa_supplicant_remove_iface(global, wpa_s, 0)) {
reply = wpas_dbus_new_success_reply(message); reply = wpas_dbus_new_success_reply(message);
} else { } else {
reply = dbus_message_new_error(message, reply = dbus_message_new_error(
WPAS_ERROR_REMOVE_ERROR, message, WPAS_ERROR_REMOVE_ERROR,
"wpa_supplicant couldn't " "wpa_supplicant couldn't remove this interface.");
"remove this interface.");
} }
out: out:
@ -518,6 +517,7 @@ DBusMessage * wpas_dbus_iface_capabilities(DBusMessage *message,
if (res < 0) { if (res < 0) {
if (!strict) { if (!strict) {
const char *args[] = {"CCMP", "TKIP", "NONE"}; const char *args[] = {"CCMP", "TKIP", "NONE"};
if (!wpa_dbus_dict_append_string_array( if (!wpa_dbus_dict_append_string_array(
&iter_dict, "pairwise", args, &iter_dict, "pairwise", args,
ARRAY_SIZE(args))) ARRAY_SIZE(args)))
@ -550,6 +550,7 @@ DBusMessage * wpas_dbus_iface_capabilities(DBusMessage *message,
const char *args[] = { const char *args[] = {
"CCMP", "TKIP", "WEP104", "WEP40" "CCMP", "TKIP", "WEP104", "WEP40"
}; };
if (!wpa_dbus_dict_append_string_array( if (!wpa_dbus_dict_append_string_array(
&iter_dict, "group", args, &iter_dict, "group", args,
ARRAY_SIZE(args))) ARRAY_SIZE(args)))
@ -624,6 +625,7 @@ DBusMessage * wpas_dbus_iface_capabilities(DBusMessage *message,
if (res < 0) { if (res < 0) {
if (!strict) { if (!strict) {
const char *args[] = { "RSN", "WPA" }; const char *args[] = { "RSN", "WPA" };
if (!wpa_dbus_dict_append_string_array( if (!wpa_dbus_dict_append_string_array(
&iter_dict, "proto", args, &iter_dict, "proto", args,
ARRAY_SIZE(args))) ARRAY_SIZE(args)))
@ -653,6 +655,7 @@ DBusMessage * wpas_dbus_iface_capabilities(DBusMessage *message,
if (res < 0) { if (res < 0) {
if (!strict) { if (!strict) {
const char *args[] = { "OPEN", "SHARED", "LEAP" }; const char *args[] = { "OPEN", "SHARED", "LEAP" };
if (!wpa_dbus_dict_append_string_array( if (!wpa_dbus_dict_append_string_array(
&iter_dict, "auth_alg", args, &iter_dict, "auth_alg", args,
ARRAY_SIZE(args))) ARRAY_SIZE(args)))
@ -687,9 +690,9 @@ DBusMessage * wpas_dbus_iface_capabilities(DBusMessage *message,
error: error:
if (reply) if (reply)
dbus_message_unref(reply); dbus_message_unref(reply);
return dbus_message_new_error(message, WPAS_ERROR_INTERNAL_ERROR, return dbus_message_new_error(
"an internal error occurred returning " message, WPAS_ERROR_INTERNAL_ERROR,
"interface capabilities."); "an internal error occurred returning interface capabilities.");
} }
@ -710,10 +713,9 @@ DBusMessage * wpas_dbus_iface_add_network(DBusMessage *message,
ssid = wpa_config_add_network(wpa_s->conf); ssid = wpa_config_add_network(wpa_s->conf);
if (ssid == NULL) { if (ssid == NULL) {
reply = dbus_message_new_error(message, reply = dbus_message_new_error(
WPAS_ERROR_ADD_NETWORK_ERROR, message, WPAS_ERROR_ADD_NETWORK_ERROR,
"wpa_supplicant could not add " "wpa_supplicant could not add a network on this interface.");
"a network on this interface.");
goto out; goto out;
} }
wpas_notify_network_added(wpa_s, ssid); wpas_notify_network_added(wpa_s, ssid);
@ -786,10 +788,9 @@ DBusMessage * wpas_dbus_iface_remove_network(DBusMessage *message,
WLAN_REASON_DEAUTH_LEAVING); WLAN_REASON_DEAUTH_LEAVING);
if (wpa_config_remove_network(wpa_s->conf, id) < 0) { if (wpa_config_remove_network(wpa_s->conf, id) < 0) {
reply = dbus_message_new_error(message, reply = dbus_message_new_error(
WPAS_ERROR_REMOVE_NETWORK_ERROR, message, WPAS_ERROR_REMOVE_NETWORK_ERROR,
"error removing the specified " "error removing the specified on this interface.");
"on this interface.");
goto out; goto out;
} }
@ -802,7 +803,7 @@ out:
} }
static const char *dont_quote[] = { static const char const *dont_quote[] = {
"key_mgmt", "proto", "pairwise", "auth_alg", "group", "eap", "key_mgmt", "proto", "pairwise", "auth_alg", "group", "eap",
"opensc_engine_path", "pkcs11_engine_path", "pkcs11_module_path", "opensc_engine_path", "pkcs11_engine_path", "pkcs11_module_path",
"bssid", NULL "bssid", NULL
@ -812,8 +813,9 @@ static const char *dont_quote[] = {
static dbus_bool_t should_quote_opt(const char *key) static dbus_bool_t should_quote_opt(const char *key)
{ {
int i = 0; int i = 0;
while (dont_quote[i] != NULL) { while (dont_quote[i] != NULL) {
if (strcmp(key, dont_quote[i]) == 0) if (os_strcmp(key, dont_quote[i]) == 0)
return FALSE; return FALSE;
i++; i++;
} }
@ -1129,19 +1131,19 @@ DBusMessage * wpas_dbus_iface_set_smartcard_modules(
if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
goto error; goto error;
if (!strcmp(entry.key, "opensc_engine_path") && if (!strcmp(entry.key, "opensc_engine_path") &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
os_free(opensc_engine_path); os_free(opensc_engine_path);
opensc_engine_path = os_strdup(entry.str_value); opensc_engine_path = os_strdup(entry.str_value);
if (opensc_engine_path == NULL) if (opensc_engine_path == NULL)
goto error; goto error;
} else if (!strcmp(entry.key, "pkcs11_engine_path") && } else if (!strcmp(entry.key, "pkcs11_engine_path") &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
os_free(pkcs11_engine_path); os_free(pkcs11_engine_path);
pkcs11_engine_path = os_strdup(entry.str_value); pkcs11_engine_path = os_strdup(entry.str_value);
if (pkcs11_engine_path == NULL) if (pkcs11_engine_path == NULL)
goto error; goto error;
} else if (!strcmp(entry.key, "pkcs11_module_path") && } else if (!strcmp(entry.key, "pkcs11_module_path") &&
(entry.type == DBUS_TYPE_STRING)) { entry.type == DBUS_TYPE_STRING) {
os_free(pkcs11_module_path); os_free(pkcs11_module_path);
pkcs11_module_path = os_strdup(entry.str_value); pkcs11_module_path = os_strdup(entry.str_value);
if (pkcs11_module_path == NULL) if (pkcs11_module_path == NULL)
@ -1221,8 +1223,8 @@ DBusMessage * wpas_dbus_iface_get_scanning(DBusMessage *message,
dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &scanning, dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &scanning,
DBUS_TYPE_INVALID); DBUS_TYPE_INVALID);
} else { } else {
wpa_printf(MSG_ERROR, "dbus: Not enough memory to return " wpa_printf(MSG_ERROR,
"scanning state"); "dbus: Not enough memory to return scanning state");
} }
return reply; return reply;
@ -1334,8 +1336,8 @@ DBusMessage * wpas_dbus_iface_remove_blobs(DBusMessage *message,
dbus_message_iter_init(message, &iter); dbus_message_iter_init(message, &iter);
if ((dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY) || if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
(dbus_message_iter_get_element_type (&iter) != DBUS_TYPE_STRING)) dbus_message_iter_get_element_type(&iter) != DBUS_TYPE_STRING)
return wpas_dbus_new_invalid_opts_error(message, NULL); return wpas_dbus_new_invalid_opts_error(message, NULL);
dbus_message_iter_recurse(&iter, &array); dbus_message_iter_recurse(&iter, &array);

View file

@ -36,7 +36,7 @@ DBusMessage * wpas_dbus_iface_wps_pbc(DBusMessage *message,
DBUS_TYPE_INVALID)) DBUS_TYPE_INVALID))
return wpas_dbus_new_invalid_opts_error(message, NULL); return wpas_dbus_new_invalid_opts_error(message, NULL);
if (!os_strcmp(arg_bssid, "any")) if (os_strcmp(arg_bssid, "any") == 0)
ret = wpas_wps_start_pbc(wpa_s, NULL, 0); ret = wpas_wps_start_pbc(wpa_s, NULL, 0);
else if (!hwaddr_aton(arg_bssid, bssid)) else if (!hwaddr_aton(arg_bssid, bssid))
ret = wpas_wps_start_pbc(wpa_s, bssid, 0); ret = wpas_wps_start_pbc(wpa_s, bssid, 0);
@ -46,10 +46,9 @@ DBusMessage * wpas_dbus_iface_wps_pbc(DBusMessage *message,
} }
if (ret < 0) { if (ret < 0) {
return dbus_message_new_error(message, return dbus_message_new_error(
WPAS_ERROR_WPS_PBC_ERROR, message, WPAS_ERROR_WPS_PBC_ERROR,
"Could not start PBC " "Could not start PBC negotiation");
"negotiation");
} }
return wpas_dbus_new_success_reply(message); return wpas_dbus_new_success_reply(message);
@ -79,7 +78,7 @@ DBusMessage * wpas_dbus_iface_wps_pin(DBusMessage *message,
DBUS_TYPE_STRING, &pin, DBUS_TYPE_INVALID)) DBUS_TYPE_STRING, &pin, DBUS_TYPE_INVALID))
return wpas_dbus_new_invalid_opts_error(message, NULL); return wpas_dbus_new_invalid_opts_error(message, NULL);
if (!os_strcmp(arg_bssid, "any")) if (os_strcmp(arg_bssid, "any") == 0)
_bssid = NULL; _bssid = NULL;
else if (!hwaddr_aton(arg_bssid, bssid)) else if (!hwaddr_aton(arg_bssid, bssid))
_bssid = bssid; _bssid = bssid;