diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index 294156730..48b5002ae 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -51,13 +51,6 @@ static void wpas_dbus_signal_interface(struct wpa_supplicant *wpa_s, if (iface == NULL) return; - path = wpas_dbus_get_path(wpa_s); - if (path == NULL) { - wpa_printf(MSG_ERROR, "wpas_dbus_signal_interface[dbus]: " - "Interface doesn't have a dbus path. " - "Can't send signal."); - return; - } _signal = dbus_message_new_signal(WPAS_DBUS_NEW_PATH, WPAS_DBUS_NEW_INTERFACE, sig_name); if (_signal == NULL) { @@ -68,7 +61,8 @@ static void wpas_dbus_signal_interface(struct wpa_supplicant *wpa_s, dbus_message_iter_init_append(_signal, &iter); - if(!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, + path = wpa_s->dbus_new_path; + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &path)) goto err; @@ -132,7 +126,6 @@ void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success) { struct wpas_dbus_priv *iface; DBusMessage *_signal; - const char *path; dbus_bool_t succ; iface = wpa_s->global->dbus; @@ -141,14 +134,8 @@ void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success) if (iface == NULL) return; - path = wpas_dbus_get_path(wpa_s); - if (path == NULL) { - wpa_printf(MSG_ERROR, "wpas_dbus_signal_scan_done[dbus]: " - "Interface doesn't have a dbus path. " - "Can't send signal."); - return; - } - _signal = dbus_message_new_signal(path, WPAS_DBUS_NEW_IFACE_INTERFACE, + _signal = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, "ScanDone"); if (_signal == NULL) { wpa_printf(MSG_ERROR, "wpas_dbus_signal_scan_done[dbus]: " @@ -184,7 +171,6 @@ static void wpas_dbus_signal_bss(struct wpa_supplicant *wpa_s, struct wpas_dbus_priv *iface; DBusMessage *_signal; DBusMessageIter iter, iter_dict; - const char *path; iface = wpa_s->global->dbus; @@ -192,14 +178,8 @@ static void wpas_dbus_signal_bss(struct wpa_supplicant *wpa_s, if (iface == NULL) return; - path = wpas_dbus_get_path(wpa_s); - if (path == NULL) { - wpa_printf(MSG_ERROR, "wpas_dbus_signal_bss[dbus]: " - "Interface doesn't have a dbus path. " - "Can't send signal."); - return; - } - _signal = dbus_message_new_signal(path, WPAS_DBUS_NEW_IFACE_INTERFACE, + _signal = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, sig_name); if (_signal == NULL) { wpa_printf(MSG_ERROR, "wpas_dbus_signal_bss[dbus]: " @@ -278,7 +258,6 @@ static void wpas_dbus_signal_blob(struct wpa_supplicant *wpa_s, { struct wpas_dbus_priv *iface; DBusMessage *_signal; - const char *path; iface = wpa_s->global->dbus; @@ -286,14 +265,8 @@ static void wpas_dbus_signal_blob(struct wpa_supplicant *wpa_s, if (iface == NULL) return; - path = wpas_dbus_get_path(wpa_s); - if (path == NULL) { - wpa_printf(MSG_ERROR, "wpas_dbus_signal_blob[dbus]: " - "Interface doesn't have a dbus path. " - "Can't send signal."); - return; - } - _signal = dbus_message_new_signal(path, WPAS_DBUS_NEW_IFACE_INTERFACE, + _signal = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, sig_name); if (_signal == NULL) { wpa_printf(MSG_ERROR, "wpas_dbus_signal_blob[dbus]: " @@ -356,7 +329,6 @@ static void wpas_dbus_signal_network(struct wpa_supplicant *wpa_s, struct wpas_dbus_priv *iface; DBusMessage *_signal; DBusMessageIter iter, iter_dict; - const char *path; char *net_obj_path; iface = wpa_s->global->dbus; @@ -365,21 +337,15 @@ static void wpas_dbus_signal_network(struct wpa_supplicant *wpa_s, if (iface == NULL) return; - path = wpas_dbus_get_path(wpa_s); - if (path == NULL) { - wpa_printf(MSG_ERROR, "wpas_dbus_signal_network[dbus]: " - "Interface doesn't have a dbus path. " - "Can't send signal."); - return; - } - net_obj_path = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX); if (net_obj_path == NULL) return; os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, - "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u", path, id); + "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u", + wpa_s->dbus_new_path, id); - _signal = dbus_message_new_signal(path, WPAS_DBUS_NEW_IFACE_INTERFACE, + _signal = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, sig_name); if (_signal == NULL) { wpa_printf(MSG_ERROR, "wpas_dbus_signal_network[dbus]: " @@ -475,7 +441,6 @@ void wpas_dbus_signal_state_changed(struct wpa_supplicant *wpa_s, { struct wpas_dbus_priv *iface; DBusMessage *_signal = NULL; - const char *path; char *new_state_str, *old_state_str; char *tmp; @@ -490,17 +455,8 @@ void wpas_dbus_signal_state_changed(struct wpa_supplicant *wpa_s, if (new_state == old_state) return; - path = wpas_dbus_get_path(wpa_s); - if (path == NULL) { - perror("wpas_dbus_signal_state_changed[dbus]: " - "interface didn't have a dbus path"); - wpa_printf(MSG_ERROR, - "wpas_dbus_signal_state_changed[dbus]: " - "interface didn't have a dbus path; can't send " - "signal."); - return; - } - _signal = dbus_message_new_signal(path, WPAS_DBUS_NEW_IFACE_INTERFACE, + _signal = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, "StateChanged"); if (_signal == NULL) { perror("wpas_dbus_signal_state_changed[dbus]: " @@ -574,7 +530,7 @@ void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s, char path[WPAS_DBUS_OBJECT_PATH_MAX]; os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX, "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%d", - wpas_dbus_get_path(wpa_s), ssid->id); + wpa_s->dbus_new_path, ssid->id); wpa_dbus_signal_property_changed(wpa_s->global->dbus, (WPADBusPropertyAccessor) @@ -599,7 +555,6 @@ void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s) DBusMessageIter iter, dict_iter; struct wpas_dbus_priv *iface; char *key = "success"; - const char *path; iface = wpa_s->global->dbus; @@ -607,15 +562,8 @@ void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s) if (iface == NULL) return; - path = wpas_dbus_get_path(wpa_s); - if (!path) { - wpa_printf(MSG_ERROR, "wpas_dbus_signal_wps_event_success" - "[dbus]: interface has no dbus path set"); - return; - } - - _signal = dbus_message_new_signal(path, WPAS_DBUS_NEW_IFACE_WPS, - "Event"); + _signal = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_WPS, "Event"); if (!_signal) { wpa_printf(MSG_ERROR, "wpas_dbus_signal_wps_event_success" "[dbus]: out of memory when creating a signal"); @@ -653,7 +601,6 @@ void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s, DBusMessageIter iter, dict_iter; struct wpas_dbus_priv *iface; char *key = "fail"; - const char *path; iface = wpa_s->global->dbus; @@ -661,15 +608,8 @@ void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s, if (iface == NULL) return; - path = wpas_dbus_get_path(wpa_s); - if (!path) { - wpa_printf(MSG_ERROR, "wpas_dbus_signal_wps_event_fail[dbus]: " - "interface has no dbus path set"); - return; - } - - _signal = dbus_message_new_signal(path, WPAS_DBUS_NEW_IFACE_WPS, - "Event"); + _signal = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_WPS, "Event"); if (!_signal) { wpa_printf(MSG_ERROR, "wpas_dbus_signal_wps_event_fail[dbus]: " "out of memory when creating a signal"); @@ -708,7 +648,6 @@ void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s, DBusMessageIter iter, dict_iter; struct wpas_dbus_priv *iface; char *key = "m2d"; - const char *path; iface = wpa_s->global->dbus; @@ -716,15 +655,8 @@ void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s, if (iface == NULL) return; - path = wpas_dbus_get_path(wpa_s); - if (!path) { - wpa_printf(MSG_ERROR, "wpas_dbus_signal_wps_event_m2d[dbus]: " - "interface has no dbus path set"); - return; - } - - _signal = dbus_message_new_signal(path, WPAS_DBUS_NEW_IFACE_WPS, - "Event"); + _signal = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_WPS, "Event"); if (!_signal) { wpa_printf(MSG_ERROR, "wpas_dbus_signal_wps_event_m2d[dbus]: " "out of memory when creating a signal"); @@ -784,7 +716,6 @@ void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s, DBusMessage *_signal = NULL; DBusMessageIter iter, dict_iter; struct wpas_dbus_priv *iface; - const char *path; char *auth_type[6]; /* we have six possible authorization types */ int at_num = 0; char *encr_type[4]; /* we have four possible encryption types */ @@ -796,14 +727,8 @@ void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s, if (iface == NULL) return; - path = wpas_dbus_get_path(wpa_s); - if (!path) { - wpa_printf(MSG_ERROR, "wpas_dbus_signal_wps_cred[dbus]: " - "interface has no dbus path set"); - return; - } - - _signal = dbus_message_new_signal(path, WPAS_DBUS_NEW_IFACE_WPS, + _signal = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_WPS, "Credentials"); if (!_signal) { wpa_printf(MSG_ERROR, "wpas_dbus_signal_wps_cred[dbus]: " @@ -937,9 +862,8 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s, } wpa_dbus_signal_property_changed(wpa_s->global->dbus, - getter, arg, - wpas_dbus_get_path(wpa_s), iface, - prop); + getter, arg, wpa_s->dbus_new_path, + iface, prop); } @@ -1251,7 +1175,7 @@ int wpas_dbus_register_network(struct wpa_supplicant *wpa_s, return -1; os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u", - wpas_dbus_get_path(wpa_s), ssid->id); + wpa_s->dbus_new_path, ssid->id); wpa_printf(MSG_DEBUG, "dbus: Register network object '%s'", net_obj_path); @@ -1320,7 +1244,7 @@ int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid) return -1; os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u", - wpas_dbus_get_path(wpa_s), nid); + wpa_s->dbus_new_path, nid); wpa_printf(MSG_DEBUG, "dbus: Unregister network object '%s'", net_obj_path); @@ -1428,7 +1352,7 @@ int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s, os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u", - wpas_dbus_get_path(wpa_s), id); + wpa_s->dbus_new_path, id); wpa_printf(MSG_DEBUG, "dbus: Unregister BSS object '%s'", bss_obj_path); @@ -1478,7 +1402,7 @@ int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s, os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u", - wpas_dbus_get_path(wpa_s), id); + wpa_s->dbus_new_path, id); obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc)); if (!obj_desc) { @@ -1806,9 +1730,9 @@ int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s) return 0; wpa_printf(MSG_DEBUG, "dbus: Unregister interface object '%s'", - wpas_dbus_get_path(wpa_s)); + wpa_s->dbus_new_path); if (wpa_dbus_unregister_object_per_iface(ctrl_iface, - wpas_dbus_get_path(wpa_s))) + wpa_s->dbus_new_path)) return -1; wpas_dbus_signal_interface_removed(wpa_s); @@ -1818,14 +1742,3 @@ int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s) return 0; } - - -/** - * wpas_dbus_get_path - Get an interface's dbus path - * @wpa_s: %wpa_supplicant interface structure - * Returns: Interface's dbus object path, or %NULL on error - */ -const char * wpas_dbus_get_path(struct wpa_supplicant *wpa_s) -{ - return wpa_s->dbus_new_path; -} diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h index 3ba0cb426..896e8f05d 100644 --- a/wpa_supplicant/dbus/dbus_new.h +++ b/wpa_supplicant/dbus/dbus_new.h @@ -72,8 +72,6 @@ enum wpas_dbus_prop { #ifdef CONFIG_CTRL_IFACE_DBUS_NEW -const char * wpas_dbus_get_path(struct wpa_supplicant *wpa_s); - int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv); void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv *iface); diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c index 91f08e09a..d8c3958f3 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers.c +++ b/wpa_supplicant/dbus/dbus_new_handlers.c @@ -626,7 +626,7 @@ DBusMessage * wpas_dbus_handler_create_interface(DBusMessage *message, iface.bridge_ifname = bridge_ifname; /* Otherwise, have wpa_supplicant attach to it. */ if ((wpa_s = wpa_supplicant_add_iface(global, &iface))) { - const char *path = wpas_dbus_get_path(wpa_s); + const char *path = wpa_s->dbus_new_path; reply = dbus_message_new_method_return(message); dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); @@ -707,13 +707,7 @@ DBusMessage * wpas_dbus_handler_get_interface(DBusMessage *message, if (wpa_s == NULL) return wpas_dbus_error_iface_unknown(message); - path = wpas_dbus_get_path(wpa_s); - if (path == NULL) { - wpa_printf(MSG_ERROR, "wpas_dbus_handler_get_interface[dbus]: " - "interface has no dbus object path set"); - return wpas_dbus_error_unknown_error(message, "path not set"); - } - + path = wpa_s->dbus_new_path; reply = dbus_message_new_method_return(message); if (reply == NULL) { perror("wpas_dbus_handler_get_interface[dbus]: out of memory " @@ -896,7 +890,7 @@ DBusMessage * wpas_dbus_getter_interfaces(DBusMessage *message, } for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) - paths[i] = wpas_dbus_get_path(wpa_s); + paths[i] = wpa_s->dbus_new_path; reply = wpas_dbus_simple_array_property_getter(message, DBUS_TYPE_OBJECT_PATH, @@ -1378,8 +1372,7 @@ DBusMessage * wpas_dbus_handler_add_network(DBusMessage *message, /* Construct the object path for this network. */ os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX, "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%d", - wpas_dbus_get_path(wpa_s), - ssid->id); + wpa_s->dbus_new_path, ssid->id); reply = dbus_message_new_method_return(message); if (reply == NULL) { @@ -1435,7 +1428,7 @@ DBusMessage * wpas_dbus_handler_remove_network(DBusMessage *message, /* Extract the network ID and ensure the network */ /* is actually a child of this interface */ iface = wpas_dbus_new_decompose_object_path(op, &net_id, NULL); - if (iface == NULL || strcmp(iface, wpas_dbus_get_path(wpa_s)) != 0) { + if (iface == NULL || os_strcmp(iface, wpa_s->dbus_new_path) != 0) { reply = wpas_dbus_error_invald_args(message, op); goto out; } @@ -1497,7 +1490,7 @@ DBusMessage * wpas_dbus_handler_select_network(DBusMessage *message, /* Extract the network ID and ensure the network */ /* is actually a child of this interface */ iface = wpas_dbus_new_decompose_object_path(op, &net_id, NULL); - if (iface == NULL || strcmp(iface, wpas_dbus_get_path(wpa_s)) != 0) { + if (iface == NULL || os_strcmp(iface, wpa_s->dbus_new_path) != 0) { reply = wpas_dbus_error_invald_args(message, op); goto out; } @@ -2146,7 +2139,6 @@ DBusMessage * wpas_dbus_getter_current_bss(DBusMessage *message, struct wpa_supplicant *wpa_s) { DBusMessage *reply = NULL; - const char *path = wpas_dbus_get_path(wpa_s); char *bss_obj_path = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX); struct wpa_bss *bss = NULL; @@ -2164,7 +2156,7 @@ DBusMessage * wpas_dbus_getter_current_bss(DBusMessage *message, if (bss) os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u", - path, bss->id); + wpa_s->dbus_new_path, bss->id); else os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, "/"); @@ -2190,7 +2182,6 @@ DBusMessage * wpas_dbus_getter_current_network(DBusMessage *message, struct wpa_supplicant *wpa_s) { DBusMessage *reply = NULL; - const char *path = wpas_dbus_get_path(wpa_s); char *net_obj_path = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX); if (net_obj_path == NULL) { @@ -2202,8 +2193,8 @@ DBusMessage * wpas_dbus_getter_current_network(DBusMessage *message, if (wpa_s->current_ssid) os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, - "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u", path, - wpa_s->current_ssid->id); + "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u", + wpa_s->dbus_new_path, wpa_s->current_ssid->id); else os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX, "/"); @@ -2279,7 +2270,7 @@ DBusMessage * wpas_dbus_getter_bsss(DBusMessage *message, /* Construct the object path for this BSS. */ os_snprintf(paths[i++], WPAS_DBUS_OBJECT_PATH_MAX, "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u", - wpas_dbus_get_path(wpa_s), bss->id); + wpa_s->dbus_new_path, bss->id); } reply = wpas_dbus_simple_array_property_getter(message, @@ -2342,7 +2333,7 @@ DBusMessage * wpas_dbus_getter_networks(DBusMessage *message, /* Construct the object path for this network. */ os_snprintf(paths[i++], WPAS_DBUS_OBJECT_PATH_MAX, "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%d", - wpas_dbus_get_path(wpa_s), ssid->id); + wpa_s->dbus_new_path, ssid->id); } reply = wpas_dbus_simple_array_property_getter(message, diff --git a/wpa_supplicant/dbus/dbus_new_handlers_wps.c b/wpa_supplicant/dbus/dbus_new_handlers_wps.c index f512db19f..512b23b33 100644 --- a/wpa_supplicant/dbus/dbus_new_handlers_wps.c +++ b/wpa_supplicant/dbus/dbus_new_handlers_wps.c @@ -288,7 +288,7 @@ DBusMessage * wpas_dbus_setter_process_credentials( wpa_s->global->dbus, (WPADBusPropertyAccessor) wpas_dbus_getter_process_credentials, - wpa_s, wpas_dbus_get_path(wpa_s), + wpa_s, wpa_s->dbus_new_path, WPAS_DBUS_NEW_IFACE_WPS, "ProcessCredentials"); diff --git a/wpa_supplicant/dbus/dbus_old.c b/wpa_supplicant/dbus/dbus_old.c index 674b9ff64..6ed8cfc70 100644 --- a/wpa_supplicant/dbus/dbus_old.c +++ b/wpa_supplicant/dbus/dbus_old.c @@ -397,23 +397,13 @@ void wpa_supplicant_dbus_notify_scan_results(struct wpa_supplicant *wpa_s) { struct wpas_dbus_priv *iface = wpa_s->global->dbus; DBusMessage *_signal; - const char *path; /* Do nothing if the control interface is not turned on */ if (iface == NULL) return; - path = wpa_supplicant_get_dbus_path(wpa_s); - if (path == NULL) { - perror("wpa_supplicant_dbus_notify_scan_results[dbus]: " - "interface didn't have a dbus path"); - wpa_printf(MSG_ERROR, - "wpa_supplicant_dbus_notify_scan_results[dbus]: " - "interface didn't have a dbus path; can't send " - "scan result signal."); - return; - } - _signal = dbus_message_new_signal(path, WPAS_DBUS_IFACE_INTERFACE, + _signal = dbus_message_new_signal(wpa_s->dbus_path, + WPAS_DBUS_IFACE_INTERFACE, "ScanResultsAvailable"); if (_signal == NULL) { perror("wpa_supplicant_dbus_notify_scan_results[dbus]: " @@ -442,7 +432,6 @@ void wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s, { struct wpas_dbus_priv *iface; DBusMessage *_signal = NULL; - const char *path; const char *new_state_str, *old_state_str; /* Do nothing if the control interface is not turned on */ @@ -456,17 +445,8 @@ void wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s, if (new_state == old_state) return; - path = wpa_supplicant_get_dbus_path(wpa_s); - if (path == NULL) { - perror("wpa_supplicant_dbus_notify_state_change[dbus]: " - "interface didn't have a dbus path"); - wpa_printf(MSG_ERROR, - "wpa_supplicant_dbus_notify_state_change[dbus]: " - "interface didn't have a dbus path; can't send " - "signal."); - return; - } - _signal = dbus_message_new_signal(path, WPAS_DBUS_IFACE_INTERFACE, + _signal = dbus_message_new_signal(wpa_s->dbus_path, + WPAS_DBUS_IFACE_INTERFACE, "StateChange"); if (_signal == NULL) { perror("wpa_supplicant_dbus_notify_state_change[dbus]: " @@ -520,23 +500,14 @@ void wpa_supplicant_dbus_notify_scanning(struct wpa_supplicant *wpa_s) { struct wpas_dbus_priv *iface = wpa_s->global->dbus; DBusMessage *_signal; - const char *path; dbus_bool_t scanning = wpa_s->scanning ? TRUE : FALSE; /* Do nothing if the control interface is not turned on */ if (iface == NULL) return; - path = wpa_supplicant_get_dbus_path(wpa_s); - if (path == NULL) { - perror("wpa_supplicant_dbus_notify_scanning[dbus]: interface " - "didn't have a dbus path"); - wpa_printf(MSG_ERROR, - "%s[dbus]: interface didn't have a dbus path; " - "can't send scanning signal.", __FUNCTION__); - return; - } - _signal = dbus_message_new_signal(path, WPAS_DBUS_IFACE_INTERFACE, + _signal = dbus_message_new_signal(wpa_s->dbus_path, + WPAS_DBUS_IFACE_INTERFACE, "Scanning"); if (_signal == NULL) { perror("wpa_supplicant_dbus_notify_scanning[dbus]: couldn't " @@ -567,7 +538,6 @@ void wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s, { struct wpas_dbus_priv *iface; DBusMessage *_signal = NULL; - const char *path; /* Do nothing if the control interface is not turned on */ if (wpa_s->global == NULL) @@ -576,17 +546,8 @@ void wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s, if (iface == NULL) return; - path = wpa_supplicant_get_dbus_path(wpa_s); - if (path == NULL) { - perror("wpa_supplicant_dbus_notify_wps_cred[dbus]: " - "interface didn't have a dbus path"); - wpa_printf(MSG_ERROR, - "wpa_supplicant_dbus_notify_wps_cred[dbus]: " - "interface didn't have a dbus path; can't send " - "signal."); - return; - } - _signal = dbus_message_new_signal(path, WPAS_DBUS_IFACE_INTERFACE, + _signal = dbus_message_new_signal(wpa_s->dbus_path, + WPAS_DBUS_IFACE_INTERFACE, "WpsCred"); if (_signal == NULL) { perror("wpa_supplicant_dbus_notify_wps_cred[dbus]: " @@ -739,7 +700,6 @@ int wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s) { struct wpas_dbus_priv *ctrl_iface; DBusConnection *con; - const char *path; /* Do nothing if the control interface is not turned on */ if (wpa_s == NULL || wpa_s->global == NULL) @@ -749,9 +709,7 @@ int wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s) return 0; con = ctrl_iface->con; - path = wpa_supplicant_get_dbus_path(wpa_s); - - if (!dbus_connection_unregister_object_path(con, path)) + if (!dbus_connection_unregister_object_path(con, wpa_s->dbus_path)) return -1; os_free(wpa_s->dbus_path); @@ -778,14 +736,3 @@ struct wpa_supplicant * wpa_supplicant_get_iface_by_dbus_path( } return NULL; } - - -/** - * wpa_supplicant_get_dbus_path - Get an interface's dbus path - * @wpa_s: %wpa_supplicant interface structure - * Returns: Interface's dbus object path, or %NULL on error - */ -const char * wpa_supplicant_get_dbus_path(struct wpa_supplicant *wpa_s) -{ - return wpa_s->dbus_path; -} diff --git a/wpa_supplicant/dbus/dbus_old.h b/wpa_supplicant/dbus/dbus_old.h index 4c0b50d60..a9840c259 100644 --- a/wpa_supplicant/dbus/dbus_old.h +++ b/wpa_supplicant/dbus/dbus_old.h @@ -91,7 +91,6 @@ int wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s); /* Methods internal to the dbus control interface */ -const char *wpa_supplicant_get_dbus_path(struct wpa_supplicant *wpa_s); struct wpa_supplicant * wpa_supplicant_get_iface_by_dbus_path( struct wpa_global *global, const char *path); diff --git a/wpa_supplicant/dbus/dbus_old_handlers.c b/wpa_supplicant/dbus/dbus_old_handlers.c index 5f48e42dc..83713634d 100644 --- a/wpa_supplicant/dbus/dbus_old_handlers.c +++ b/wpa_supplicant/dbus/dbus_old_handlers.c @@ -170,7 +170,7 @@ DBusMessage * wpas_dbus_global_add_interface(DBusMessage *message, iface.bridge_ifname = bridge_ifname; /* Otherwise, have wpa_supplicant attach to it. */ if ((wpa_s = wpa_supplicant_add_iface(global, &iface))) { - const char *path = wpa_supplicant_get_dbus_path(wpa_s); + const char *path = wpa_s->dbus_path; reply = dbus_message_new_method_return(message); dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); @@ -272,15 +272,7 @@ DBusMessage * wpas_dbus_global_get_interface(DBusMessage *message, goto out; } - path = wpa_supplicant_get_dbus_path(wpa_s); - if (path == NULL) { - reply = dbus_message_new_error(message, - WPAS_ERROR_INTERNAL_ERROR, - "an internal error occurred " - "getting the interface."); - goto out; - } - + path = wpa_s->dbus_path; reply = dbus_message_new_method_return(message); dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path, @@ -403,8 +395,7 @@ DBusMessage * wpas_dbus_iface_scan_results(DBusMessage *message, os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX, "%s/" WPAS_DBUS_BSSIDS_PART "/" WPAS_DBUS_BSSID_FORMAT, - wpa_supplicant_get_dbus_path(wpa_s), - MAC2STR(res->bssid)); + wpa_s->dbus_path, MAC2STR(res->bssid)); dbus_message_iter_append_basic(&sub_iter, DBUS_TYPE_OBJECT_PATH, &path); os_free(path); @@ -842,8 +833,7 @@ DBusMessage * wpas_dbus_iface_add_network(DBusMessage *message, /* Construct the object path for this network. */ os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX, "%s/" WPAS_DBUS_NETWORKS_PART "/%d", - wpa_supplicant_get_dbus_path(wpa_s), - ssid->id); + wpa_s->dbus_path, ssid->id); reply = dbus_message_new_method_return(message); dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, @@ -888,7 +878,7 @@ DBusMessage * wpas_dbus_iface_remove_network(DBusMessage *message, } /* Ensure the network is actually a child of this interface */ - if (strcmp(iface, wpa_supplicant_get_dbus_path(wpa_s)) != 0) { + if (os_strcmp(iface, wpa_s->dbus_path) != 0) { reply = wpas_dbus_new_invalid_network_error(message); goto out; } @@ -1116,7 +1106,6 @@ DBusMessage * wpas_dbus_iface_select_network(DBusMessage *message, /* Any network */ ssid = NULL; } else { - const char *obj_path; int nid; if (!dbus_message_get_args(message, NULL, @@ -1136,8 +1125,7 @@ DBusMessage * wpas_dbus_iface_select_network(DBusMessage *message, goto out; } /* Ensure the object path really points to this interface */ - obj_path = wpa_supplicant_get_dbus_path(wpa_s); - if (os_strcmp(iface_obj_path, obj_path) != 0) { + if (os_strcmp(iface_obj_path, wpa_s->dbus_path) != 0) { reply = wpas_dbus_new_invalid_network_error(message); goto out; }