#include "includes.h"
#include "common.h"
+#include "common/ieee802_11_defs.h"
#include "wps/wps.h"
#include "../config.h"
#include "../wpa_supplicant_i.h"
#include "dbus_new_handlers.h"
#include "dbus_common.h"
#include "dbus_common_i.h"
+#include "dbus_new_handlers_p2p.h"
+#include "p2p/p2p.h"
/**
#endif /* CONFIG_WPS */
+#ifdef CONFIG_P2P
/**
- * wpas_dbus_signal_prop_changed - Signals change of property
+ * wpas_dbus_signal_p2p_group_removed - Signals P2P group was removed
* @wpa_s: %wpa_supplicant network interface data
- * @property: indicates which property has changed
- *
- * Sends ProertyChanged signals with path, interface and arguments
- * depending on which property has changed.
+ * @role: role of this device (client or GO)
+ * Sends signal with i/f name and role as string arguments
*/
-void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
- enum wpas_dbus_prop property)
+void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
+ const char *role)
{
- WPADBusPropertyAccessor getter;
- char *prop;
- if (wpa_s->dbus_new_path == NULL)
- return; /* Skip signal since D-Bus setup is not yet ready */
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ struct wpas_dbus_priv *iface = wpa_s->global->dbus;
+ char *ifname = wpa_s->ifname;
- switch (property) {
- case WPAS_DBUS_PROP_AP_SCAN:
- getter = (WPADBusPropertyAccessor) wpas_dbus_getter_ap_scan;
- prop = "ApScan";
- break;
- case WPAS_DBUS_PROP_SCANNING:
- getter = (WPADBusPropertyAccessor) wpas_dbus_getter_scanning;
- prop = "Scanning";
- break;
- case WPAS_DBUS_PROP_STATE:
- getter = (WPADBusPropertyAccessor) wpas_dbus_getter_state;
- prop = "State";
- break;
- case WPAS_DBUS_PROP_CURRENT_BSS:
- getter = (WPADBusPropertyAccessor)
- wpas_dbus_getter_current_bss;
- prop = "CurrentBSS";
- break;
- case WPAS_DBUS_PROP_CURRENT_NETWORK:
- getter = (WPADBusPropertyAccessor)
- wpas_dbus_getter_current_network;
- prop = "CurrentNetwork";
- break;
- case WPAS_DBUS_PROP_BSSS:
- getter = (WPADBusPropertyAccessor) wpas_dbus_getter_bsss;
- prop = "BSSs";
- break;
- case WPAS_DBUS_PROP_CURRENT_AUTH_MODE:
- getter = (WPADBusPropertyAccessor)
- wpas_dbus_getter_current_auth_mode;
- prop = "CurrentAuthMode";
- break;
- default:
- wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
- __func__, property);
+ /* Do nothing if the control interface is not turned on */
+ if (iface == NULL)
+ return;
+
+ msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+ WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ "GroupFinished");
+ if (msg == NULL)
return;
+
+ dbus_message_iter_init_append(msg, &iter);
+
+ if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &ifname)) {
+ wpa_printf(MSG_ERROR, "dbus: Failed to construct GroupFinished"
+ "signal -not enough memory for ifname ");
+ goto err;
}
- wpa_dbus_mark_property_changed(wpa_s->global->dbus,
- wpa_s->dbus_new_path,
- WPAS_DBUS_NEW_IFACE_INTERFACE, prop);
+ if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &role))
+ wpa_printf(MSG_ERROR, "dbus: Failed to construct GroupFinished"
+ "signal -not enough memory for role ");
+ else
+ dbus_connection_send(iface->con, msg, NULL);
+
+err:
+ dbus_message_unref(msg);
}
/**
- * wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
- * @wpa_s: %wpa_supplicant network interface data
- * @property: indicates which property has changed
- * @id: unique BSS identifier
+ * wpas_dbus_signal_p2p_provision_discovery - Signals various PD events
*
- * Sends PropertyChanged signals with path, interface, and arguments depending
- * on which property has changed.
+ * @dev_addr - who sent the request or responded to our request.
+ * @request - Will be 1 if request, 0 for response.
+ * @status - valid only in case of response
+ * @config_methods - wps config methods
+ * @generated_pin - pin to be displayed in case of WPS_CONFIG_DISPLAY method
+ *
+ * Sends following provision discovery related events:
+ * ProvisionDiscoveryRequestDisplayPin
+ * ProvisionDiscoveryResponseDisplayPin
+ * ProvisionDiscoveryRequestEnterPin
+ * ProvisionDiscoveryResponseEnterPin
+ * ProvisionDiscoveryPBCRequest
+ * ProvisionDiscoveryPBCResponse
+ *
+ * TODO::
+ * ProvisionDiscoveryFailure (timeout case)
*/
-void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
- enum wpas_dbus_bss_prop property,
- unsigned int id)
+void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
+ const u8 *dev_addr, int request,
+ enum p2p_prov_disc_status status,
+ u16 config_methods,
+ unsigned int generated_pin)
{
- char path[WPAS_DBUS_OBJECT_PATH_MAX];
- char *prop;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ struct wpas_dbus_priv *iface;
+ char *_signal;
+ int add_pin = 0;
+ char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
+ int error_ret = 1;
+ char pin[9], *p_pin = NULL;
- switch (property) {
- case WPAS_DBUS_BSS_PROP_SIGNAL:
- prop = "Signal";
- break;
- case WPAS_DBUS_BSS_PROP_FREQ:
- prop = "Frequency";
- break;
- case WPAS_DBUS_BSS_PROP_MODE:
- prop = "Mode";
- break;
- case WPAS_DBUS_BSS_PROP_PRIVACY:
- prop = "Privacy";
- break;
- case WPAS_DBUS_BSS_PROP_RATES:
- prop = "Rates";
- break;
- case WPAS_DBUS_BSS_PROP_WPA:
- prop = "WPA";
- break;
- case WPAS_DBUS_BSS_PROP_RSN:
- prop = "RSN";
- break;
- case WPAS_DBUS_BSS_PROP_IES:
- prop = "IEs";
- break;
- default:
- wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
- __func__, property);
+ iface = wpa_s->global->dbus;
+
+ /* Do nothing if the control interface is not turned on */
+ if (iface == NULL)
return;
+
+ if (request || !status) {
+ if (config_methods & WPS_CONFIG_DISPLAY)
+ _signal = request ?
+ "ProvisionDiscoveryRequestDisplayPin" :
+ "ProvisionDiscoveryResponseEnterPin";
+ else if (config_methods & WPS_CONFIG_KEYPAD)
+ _signal = request ?
+ "ProvisionDiscoveryRequestEnterPin" :
+ "ProvisionDiscoveryResponseDisplayPin";
+ else if (config_methods & WPS_CONFIG_PUSHBUTTON)
+ _signal = request ? "ProvisionDiscoveryPBCRequest" :
+ "ProvisionDiscoveryPBCResponse";
+ else
+ return; /* Unknown or un-supported method */
+ } else if (!request && status)
+ /* Explicit check for failure response */
+ _signal = "ProvisionDiscoveryFailure";
+
+ add_pin = ((request && (config_methods & WPS_CONFIG_DISPLAY)) ||
+ (!request && !status &&
+ (config_methods & WPS_CONFIG_KEYPAD)));
+
+ if (add_pin) {
+ os_snprintf(pin, sizeof(pin), "%08d", generated_pin);
+ p_pin = pin;
}
- os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
- "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
- wpa_s->dbus_new_path, id);
+ msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+ WPAS_DBUS_NEW_IFACE_P2PDEVICE, _signal);
+ if (msg == NULL)
+ return;
- wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
- WPAS_DBUS_NEW_IFACE_BSS, prop);
+ /* Check if this is a known peer */
+ if (p2p_get_peer_info(wpa_s->global->p2p, dev_addr, 0, NULL, 0) < 0)
+ goto error;
+
+ os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
+ COMPACT_MACSTR,
+ wpa_s->dbus_new_path, MAC2STR(dev_addr));
+
+ path = peer_obj_path;
+
+ dbus_message_iter_init_append(msg, &iter);
+
+ if (!dbus_message_iter_append_basic(&iter,
+ DBUS_TYPE_OBJECT_PATH,
+ &path))
+ goto error;
+
+ if (!request && status)
+ /* Attach status to ProvisionDiscoveryFailure */
+ error_ret = !dbus_message_iter_append_basic(&iter,
+ DBUS_TYPE_INT32,
+ &status);
+ else
+ error_ret = (add_pin &&
+ !dbus_message_iter_append_basic(&iter,
+ DBUS_TYPE_STRING,
+ &p_pin));
+
+error:
+ if (!error_ret)
+ dbus_connection_send(iface->con, msg, NULL);
+ else
+ wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
+
+ dbus_message_unref(msg);
}
-/**
- * wpas_dbus_signal_debug_level_changed - Signals change of debug param
- * @global: wpa_global structure
- *
- * Sends ProertyChanged signals informing that debug level has changed.
- */
-void wpas_dbus_signal_debug_level_changed(struct wpa_global *global)
+void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
+ const u8 *src, u16 dev_passwd_id)
{
- wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
- WPAS_DBUS_NEW_INTERFACE,
- "DebugLevel");
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ struct wpas_dbus_priv *iface;
+ char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
+
+ iface = wpa_s->global->dbus;
+
+ /* Do nothing if the control interface is not turned on */
+ if (iface == NULL)
+ return;
+
+ os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
+ wpa_s->dbus_new_path, MAC2STR(src));
+ path = peer_obj_path;
+
+ msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+ WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ "GONegotiationRequest");
+ if (msg == NULL)
+ return;
+
+ dbus_message_iter_init_append(msg, &iter);
+
+ if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
+ &path) ||
+ !dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT16,
+ &dev_passwd_id))
+ wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
+ else
+ dbus_connection_send(iface->con, msg, NULL);
+
+ dbus_message_unref(msg);
}
-/**
- * wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
- * @global: wpa_global structure
- *
- * Sends ProertyChanged signals informing that debug timestamp has changed.
- */
-void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global)
+static int wpas_dbus_get_group_obj_path(struct wpa_supplicant *wpa_s,
+ const struct wpa_ssid *ssid,
+ char *group_obj_path)
{
- wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
- WPAS_DBUS_NEW_INTERFACE,
- "DebugTimestamp");
+ char group_name[3];
+
+ if (os_memcmp(ssid->ssid, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN))
+ return -1;
+
+ memcpy(group_name, ssid->ssid + P2P_WILDCARD_SSID_LEN, 2);
+ group_name[2] = '\0';
+
+ os_snprintf(group_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_P2P_GROUPS_PART "/%s",
+ wpa_s->dbus_new_path, group_name);
+
+ return 0;
}
/**
- * wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
- * @global: wpa_global structure
+ * wpas_dbus_signal_p2p_group_started - Signals P2P group has
+ * started.Emitted when a group is succesfully started
+ * irrespective of the role (client/GO) of the current device
*
- * Sends ProertyChanged signals informing that debug show_keys has changed.
+ * @wpa_s: %wpa_supplicant network interface data
+ * @ssid: SSID object
+ * @client: this device is P2P client
+ * @network_id: network id of the group started, use instead of ssid->id
+ * to account for persistent groups
*/
-void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global)
+void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
+ const struct wpa_ssid *ssid,
+ int client, int network_id)
{
- wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
- WPAS_DBUS_NEW_INTERFACE,
- "DebugShowKeys");
-}
+ DBusMessage *msg;
+ DBusMessageIter iter, dict_iter;
+ struct wpas_dbus_priv *iface;
+ char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
+ char group_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
+ iface = wpa_s->parent->global->dbus;
-static void wpas_dbus_register(struct wpa_dbus_object_desc *obj_desc,
- void *priv,
- WPADBusArgumentFreeFunction priv_free,
- const struct wpa_dbus_method_desc *methods,
- const struct wpa_dbus_property_desc *properties,
- const struct wpa_dbus_signal_desc *signals)
-{
- int n;
+ /* Do nothing if the control interface is not turned on */
+ if (iface == NULL)
+ return;
- obj_desc->user_data = priv;
- obj_desc->user_data_free_func = priv_free;
- obj_desc->methods = methods;
- obj_desc->properties = properties;
- obj_desc->signals = signals;
+ if (wpas_dbus_get_group_obj_path(wpa_s, ssid, group_obj_path) < 0)
+ return;
- for (n = 0; properties && properties->dbus_property; properties++)
- n++;
+ /* New interface has been created for this group */
+ msg = dbus_message_new_signal(wpa_s->parent->dbus_new_path,
+ WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ "GroupStarted");
- obj_desc->prop_changed_flags = os_zalloc(n);
- if (!obj_desc->prop_changed_flags)
- wpa_printf(MSG_DEBUG, "dbus: %s: can't register handlers",
- __func__);
-}
+ if (msg == NULL)
+ return;
+ dbus_message_iter_init_append(msg, &iter);
+ if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
+ goto nomem;
-static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
- { "CreateInterface", WPAS_DBUS_NEW_INTERFACE,
- (WPADBusMethodHandler) &wpas_dbus_handler_create_interface,
- {
- { "args", "a{sv}", ARG_IN },
- { "path", "o", ARG_OUT },
- END_ARGS
- }
- },
- { "RemoveInterface", WPAS_DBUS_NEW_INTERFACE,
- (WPADBusMethodHandler) &wpas_dbus_handler_remove_interface,
- {
- { "path", "o", ARG_IN },
- END_ARGS
- }
- },
- { "GetInterface", WPAS_DBUS_NEW_INTERFACE,
- (WPADBusMethodHandler) &wpas_dbus_handler_get_interface,
- {
- { "ifname", "s", ARG_IN },
- { "path", "o", ARG_OUT },
- END_ARGS
- }
- },
- { NULL, NULL, NULL, { END_ARGS } }
-};
+ /*
+ * In case the device supports creating a separate interface the
+ * DBus client will need to know the object path for the interface
+ * object this group was created on, so include it here.
+ */
+ if (!wpa_dbus_dict_append_object_path(&dict_iter,
+ "interface_object",
+ wpa_s->dbus_new_path))
+ goto nomem;
-static const struct wpa_dbus_property_desc wpas_dbus_global_properties[] = {
- { "DebugLevel", WPAS_DBUS_NEW_INTERFACE, "s",
- (WPADBusPropertyAccessor) wpas_dbus_getter_debug_level,
- (WPADBusPropertyAccessor) wpas_dbus_setter_debug_level,
- RW
- },
- { "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE, "b",
- (WPADBusPropertyAccessor) wpas_dbus_getter_debug_timestamp,
- (WPADBusPropertyAccessor) wpas_dbus_setter_debug_timestamp,
- RW
- },
- { "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE, "b",
- (WPADBusPropertyAccessor) wpas_dbus_getter_debug_show_keys,
- (WPADBusPropertyAccessor) wpas_dbus_setter_debug_show_keys,
- RW
- },
- { "Interfaces", WPAS_DBUS_NEW_INTERFACE, "ao",
- (WPADBusPropertyAccessor) &wpas_dbus_getter_interfaces,
- NULL,
- R
- },
- { "EapMethods", WPAS_DBUS_NEW_INTERFACE, "as",
- (WPADBusPropertyAccessor) wpas_dbus_getter_eap_methods,
- NULL,
- R
- },
- { NULL, NULL, NULL, NULL, NULL, 0 }
-};
+ if (!wpa_dbus_dict_append_string(&dict_iter, "role",
+ client ? "client" : "GO"))
+ goto nomem;
-static const struct wpa_dbus_signal_desc wpas_dbus_global_signals[] = {
- { "InterfaceAdded", WPAS_DBUS_NEW_INTERFACE,
- {
- { "path", "o", ARG_OUT },
- { "properties", "a{sv}", ARG_OUT },
- END_ARGS
- }
- },
- { "InterfaceRemoved", WPAS_DBUS_NEW_INTERFACE,
- {
- { "path", "o", ARG_OUT },
- END_ARGS
- }
- },
- { "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE,
- {
- { "properties", "a{sv}", ARG_OUT },
- END_ARGS
- }
- },
- { NULL, NULL, { END_ARGS } }
-};
+ os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
+ wpa_s->parent->dbus_new_path, network_id);
+
+ if (!wpa_dbus_dict_append_object_path(&dict_iter, "group_object",
+ group_obj_path) ||
+ !wpa_dbus_dict_append_object_path(&dict_iter, "network_object",
+ net_obj_path) ||
+ !wpa_dbus_dict_close_write(&iter, &dict_iter))
+ goto nomem;
+
+ dbus_connection_send(iface->con, msg, NULL);
+
+nomem:
+ dbus_message_unref(msg);
+}
/**
- * wpas_dbus_ctrl_iface_init - Initialize dbus control interface
- * @global: Pointer to global data from wpa_supplicant_init()
- * Returns: 0 on success or -1 on failure
*
- * Initialize the dbus control interface for wpa_supplicantand and start
- * receiving commands from external programs over the bus.
+ * Method to emit GONeogtiation Success or Failure signals based
+ * on status.
+ * @status: Status of the GO neg request. 0 for success, other for errors.
*/
-int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv)
+void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s, int status)
{
- struct wpa_dbus_object_desc *obj_desc;
- int ret;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ struct wpas_dbus_priv *iface;
- obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
- if (!obj_desc) {
- wpa_printf(MSG_ERROR, "Not enough memory "
- "to create object description");
- return -1;
- }
+ iface = wpa_s->global->dbus;
- wpas_dbus_register(obj_desc, priv->global, NULL,
- wpas_dbus_global_methods,
- wpas_dbus_global_properties,
- wpas_dbus_global_signals);
+ /* Do nothing if the control interface is not turned on */
+ if (iface == NULL)
+ return;
- wpa_printf(MSG_DEBUG, "dbus: Register D-Bus object '%s'",
- WPAS_DBUS_NEW_PATH);
- ret = wpa_dbus_ctrl_iface_init(priv, WPAS_DBUS_NEW_PATH,
- WPAS_DBUS_NEW_SERVICE,
- obj_desc);
- if (ret < 0)
- free_dbus_object_desc(obj_desc);
- else
- priv->dbus_new_initialized = 1;
+ msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+ WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ status ? "GONegotiationFailure" :
+ "GONegotiationSuccess");
+ if (msg == NULL)
+ return;
- return ret;
+ if (status) {
+ dbus_message_iter_init_append(msg, &iter);
+ if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32,
+ &status)) {
+ wpa_printf(MSG_ERROR,
+ "dbus: Failed to construct signal");
+ goto err;
+ }
+ }
+
+ dbus_connection_send(iface->con, msg, NULL);
+err:
+ dbus_message_unref(msg);
}
/**
- * wpas_dbus_ctrl_iface_deinit - Deinitialize dbus ctrl interface for
- * wpa_supplicant
- * @iface: Pointer to dbus private data from wpas_dbus_init()
*
- * Deinitialize the dbus control interface that was initialized with
- * wpas_dbus_ctrl_iface_init().
+ * Method to emit Invitation Result signal based on status and
+ * bssid
+ * @status: Status of the Invite request. 0 for success, other
+ * for errors
+ * @bssid : Basic Service Set Identifier
*/
-void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv *iface)
+void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
+ int status, const u8 *bssid)
{
- if (!iface->dbus_new_initialized)
+ DBusMessage *msg;
+ DBusMessageIter iter, dict_iter;
+ struct wpas_dbus_priv *iface;
+
+ wpa_printf(MSG_INFO, "%s\n", __func__);
+
+ iface = wpa_s->global->dbus;
+ /* Do nothing if the control interface is not turned on */
+ if (iface == NULL)
return;
- wpa_printf(MSG_DEBUG, "dbus: Unregister D-Bus object '%s'",
- WPAS_DBUS_NEW_PATH);
- dbus_connection_unregister_object_path(iface->con,
- WPAS_DBUS_NEW_PATH);
-}
+ msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+ WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ "InvitationResult");
-static void wpa_dbus_free(void *ptr)
-{
- os_free(ptr);
-}
+ if (msg == NULL)
+ return;
+ dbus_message_iter_init_append(msg, &iter);
+ if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
+ goto nomem;
-static const struct wpa_dbus_property_desc wpas_dbus_network_properties[] = {
- { "Properties", WPAS_DBUS_NEW_IFACE_NETWORK, "a{sv}",
- (WPADBusPropertyAccessor) wpas_dbus_getter_network_properties,
- (WPADBusPropertyAccessor) wpas_dbus_setter_network_properties,
- RW
- },
- { "Enabled", WPAS_DBUS_NEW_IFACE_NETWORK, "b",
- (WPADBusPropertyAccessor) wpas_dbus_getter_enabled,
- (WPADBusPropertyAccessor) wpas_dbus_setter_enabled,
- RW
- },
- { NULL, NULL, NULL, NULL, NULL, 0 }
-};
+ if (!wpa_dbus_dict_append_int32(&dict_iter, "status", status))
+ goto nomem;
+ if (bssid) {
+ if (!wpa_dbus_dict_append_byte_array(&dict_iter, "BSSID",
+ (const char *) bssid,
+ ETH_ALEN))
+ goto nomem;
+ }
+ if (!wpa_dbus_dict_close_write(&iter, &dict_iter))
+ goto nomem;
+ dbus_connection_send(iface->con, msg, NULL);
-static const struct wpa_dbus_signal_desc wpas_dbus_network_signals[] = {
- { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_NETWORK,
- {
- { "properties", "a{sv}", ARG_OUT },
- END_ARGS
- }
- },
- { NULL, NULL, { END_ARGS } }
-};
+nomem:
+ dbus_message_unref(msg);
+}
/**
- * wpas_dbus_register_network - Register a configured network with dbus
- * @wpa_s: wpa_supplicant interface structure
- * @ssid: network configuration data
- * Returns: 0 on success, -1 on failure
*
- * Registers network representing object with dbus
+ * Method to emit a signal for a peer joining the group.
+ * The signal will carry path to the group member object
+ * constructed using p2p i/f addr used for connecting.
+ *
+ * @wpa_s: %wpa_supplicant network interface data
+ * @member_addr: addr (p2p i/f) of the peer joining the group
*/
-int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
- struct wpa_ssid *ssid)
+void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
+ const u8 *member)
{
- struct wpas_dbus_priv *ctrl_iface;
- struct wpa_dbus_object_desc *obj_desc;
- struct network_handler_args *arg;
- char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
-
- /* Do nothing if the control interface is not turned on */
- if (wpa_s == NULL || wpa_s->global == NULL)
- return 0;
- ctrl_iface = wpa_s->global->dbus;
- if (ctrl_iface == NULL)
- return 0;
+ struct wpas_dbus_priv *iface;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ char groupmember_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
- os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
- "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
- wpa_s->dbus_new_path, ssid->id);
+ iface = wpa_s->global->dbus;
- wpa_printf(MSG_DEBUG, "dbus: Register network object '%s'",
- net_obj_path);
- obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
- if (!obj_desc) {
- wpa_printf(MSG_ERROR, "Not enough memory "
- "to create object description");
- goto err;
- }
+ /* Do nothing if the control interface is not turned on */
+ if (iface == NULL)
+ return;
- /* allocate memory for handlers arguments */
- arg = os_zalloc(sizeof(struct network_handler_args));
- if (!arg) {
- wpa_printf(MSG_ERROR, "Not enough memory "
- "to create arguments for method");
- goto err;
- }
+ if (!wpa_s->dbus_groupobj_path)
+ return;
- arg->wpa_s = wpa_s;
- arg->ssid = ssid;
+ os_snprintf(groupmember_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART "/"
+ COMPACT_MACSTR,
+ wpa_s->dbus_groupobj_path, MAC2STR(member));
- wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
- wpas_dbus_network_properties,
- wpas_dbus_network_signals);
+ msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
+ WPAS_DBUS_NEW_IFACE_P2P_GROUP,
+ "PeerJoined");
+ if (msg == NULL)
+ return;
- if (wpa_dbus_register_object_per_iface(ctrl_iface, net_obj_path,
- wpa_s->ifname, obj_desc))
+ dbus_message_iter_init_append(msg, &iter);
+ path = groupmember_obj_path;
+ if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
+ &path))
goto err;
- wpas_dbus_signal_network_added(wpa_s, ssid->id);
+ dbus_connection_send(iface->con, msg, NULL);
- return 0;
+ dbus_message_unref(msg);
+ return;
err:
- free_dbus_object_desc(obj_desc);
- return -1;
+ wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
+ dbus_message_unref(msg);
}
/**
- * wpas_dbus_unregister_network - Unregister a configured network from dbus
- * @wpa_s: wpa_supplicant interface structure
- * @nid: network id
- * Returns: 0 on success, -1 on failure
*
- * Unregisters network representing object from dbus
+ * Method to emit a signal for a peer disconnecting the group.
+ * The signal will carry path to the group member object
+ * constructed using p2p i/f addr used for connecting.
+ *
+ * @wpa_s: %wpa_supplicant network interface data
+ * @member_addr: addr (p2p i/f) of the peer joining the group
*/
-int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid)
+void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
+ const u8 *member)
{
- struct wpas_dbus_priv *ctrl_iface;
- char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
- int ret;
+ struct wpas_dbus_priv *iface;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ char groupmember_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
+
+ iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (wpa_s == NULL || wpa_s->global == NULL ||
- wpa_s->dbus_new_path == NULL)
- return 0;
- ctrl_iface = wpa_s->global->dbus;
- if (ctrl_iface == NULL)
- return 0;
+ if (iface == NULL)
+ return;
- os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
- "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
- wpa_s->dbus_new_path, nid);
+ if (!wpa_s->dbus_groupobj_path)
+ return;
- wpa_printf(MSG_DEBUG, "dbus: Unregister network object '%s'",
- net_obj_path);
- ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, net_obj_path);
+ os_snprintf(groupmember_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART "/"
+ COMPACT_MACSTR,
+ wpa_s->dbus_groupobj_path, MAC2STR(member));
- if (!ret)
- wpas_dbus_signal_network_removed(wpa_s, nid);
-
- return ret;
-}
+ msg = dbus_message_new_signal(wpa_s->dbus_groupobj_path,
+ WPAS_DBUS_NEW_IFACE_P2P_GROUP,
+ "PeerDisconnected");
+ if (msg == NULL)
+ return;
+ dbus_message_iter_init_append(msg, &iter);
+ path = groupmember_obj_path;
+ if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
+ &path))
+ goto err;
-static const struct wpa_dbus_property_desc wpas_dbus_bss_properties[] = {
- { "SSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
- (WPADBusPropertyAccessor) wpas_dbus_getter_bss_ssid,
- NULL,
- R
- },
- { "BSSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
- (WPADBusPropertyAccessor) wpas_dbus_getter_bss_bssid,
- NULL,
- R
- },
- { "Privacy", WPAS_DBUS_NEW_IFACE_BSS, "b",
- (WPADBusPropertyAccessor) wpas_dbus_getter_bss_privacy,
- NULL,
- R
- },
- { "Mode", WPAS_DBUS_NEW_IFACE_BSS, "s",
- (WPADBusPropertyAccessor) wpas_dbus_getter_bss_mode,
- NULL,
- R
- },
- { "Signal", WPAS_DBUS_NEW_IFACE_BSS, "n",
- (WPADBusPropertyAccessor) wpas_dbus_getter_bss_signal,
- NULL,
- R
- },
- { "Frequency", WPAS_DBUS_NEW_IFACE_BSS, "q",
- (WPADBusPropertyAccessor) wpas_dbus_getter_bss_frequency,
- NULL,
- R
- },
- { "Rates", WPAS_DBUS_NEW_IFACE_BSS, "au",
- (WPADBusPropertyAccessor) wpas_dbus_getter_bss_rates,
- NULL,
- R
- },
- { "WPA", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
- (WPADBusPropertyAccessor) wpas_dbus_getter_bss_wpa,
- NULL,
- R
- },
- { "RSN", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
- (WPADBusPropertyAccessor) wpas_dbus_getter_bss_rsn,
- NULL,
- R
- },
- { "IEs", WPAS_DBUS_NEW_IFACE_BSS, "ay",
- (WPADBusPropertyAccessor) wpas_dbus_getter_bss_ies,
- NULL,
- R
- },
- { NULL, NULL, NULL, NULL, NULL, 0 }
-};
+ dbus_connection_send(iface->con, msg, NULL);
+ dbus_message_unref(msg);
+ return;
-static const struct wpa_dbus_signal_desc wpas_dbus_bss_signals[] = {
- { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_BSS,
- {
- { "properties", "a{sv}", ARG_OUT },
- END_ARGS
- }
- },
- { NULL, NULL, { END_ARGS } }
-};
+err:
+ wpa_printf(MSG_ERROR, "dbus: Failed to construct PeerDisconnected "
+ "signal");
+ dbus_message_unref(msg);
+}
/**
- * wpas_dbus_unregister_bss - Unregister a scanned BSS from dbus
- * @wpa_s: wpa_supplicant interface structure
- * @bssid: scanned network bssid
- * @id: unique BSS identifier
- * Returns: 0 on success, -1 on failure
*
- * Unregisters BSS representing object from dbus
+ * Method to emit a signal for a service discovery request.
+ * The signal will carry station address, frequency, dialog token,
+ * update indicator and it tlvs
+ *
+ * @wpa_s: %wpa_supplicant network interface data
+ * @sa: station addr (p2p i/f) of the peer
+ * @dialog_token: service discovery request dialog token
+ * @update_indic: service discovery request update indicator
+ * @tlvs: service discovery request genrated byte array of tlvs
+ * @tlvs_len: service discovery request tlvs length
*/
-int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
- u8 bssid[ETH_ALEN], unsigned int id)
+void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
+ int freq, const u8 *sa, u8 dialog_token,
+ u16 update_indic, const u8 *tlvs,
+ size_t tlvs_len)
{
- struct wpas_dbus_priv *ctrl_iface;
- char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
+ DBusMessage *msg;
+ DBusMessageIter iter, dict_iter;
+ struct wpas_dbus_priv *iface;
+ char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
+ iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (wpa_s == NULL || wpa_s->global == NULL)
- return 0;
- ctrl_iface = wpa_s->global->dbus;
- if (ctrl_iface == NULL)
- return 0;
+ if (iface == NULL)
+ return;
- os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
- "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
- wpa_s->dbus_new_path, id);
+ msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+ WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ "ServiceDiscoveryRequest");
+ if (msg == NULL)
+ return;
- wpa_printf(MSG_DEBUG, "dbus: Unregister BSS object '%s'",
- bss_obj_path);
- if (wpa_dbus_unregister_object_per_iface(ctrl_iface, bss_obj_path)) {
- wpa_printf(MSG_ERROR, "dbus: Cannot unregister BSS object %s",
- bss_obj_path);
- return -1;
- }
+ /* Check if this is a known peer */
+ if (p2p_get_peer_info(wpa_s->global->p2p, sa, 0, NULL, 0) < 0)
+ goto error;
- wpas_dbus_signal_bss_removed(wpa_s, bss_obj_path);
- wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
+ os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
+ COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
- return 0;
+ path = peer_obj_path;
+
+ dbus_message_iter_init_append(msg, &iter);
+ if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
+ goto error;
+
+
+ if (!wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
+ path) ||
+ !wpa_dbus_dict_append_int32(&dict_iter, "frequency", freq) ||
+ !wpa_dbus_dict_append_int32(&dict_iter, "dialog_token",
+ dialog_token) ||
+ !wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
+ update_indic) ||
+ !wpa_dbus_dict_append_byte_array(&dict_iter, "tlvs",
+ (const char *) tlvs,
+ tlvs_len) ||
+ !wpa_dbus_dict_close_write(&iter, &dict_iter))
+ goto error;
+
+ dbus_connection_send(iface->con, msg, NULL);
+ dbus_message_unref(msg);
+ return;
+error:
+ wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
+ dbus_message_unref(msg);
}
/**
- * wpas_dbus_register_bss - Register a scanned BSS with dbus
- * @wpa_s: wpa_supplicant interface structure
- * @bssid: scanned network bssid
- * @id: unique BSS identifier
- * Returns: 0 on success, -1 on failure
*
- * Registers BSS representing object with dbus
+ * Method to emit a signal for a service discovery response.
+ * The signal will carry station address, update indicator and it
+ * tlvs
+ *
+ * @wpa_s: %wpa_supplicant network interface data
+ * @sa: station addr (p2p i/f) of the peer
+ * @update_indic: service discovery request update indicator
+ * @tlvs: service discovery request genrated byte array of tlvs
+ * @tlvs_len: service discovery request tlvs length
*/
-int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
- u8 bssid[ETH_ALEN], unsigned int id)
+void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
+ const u8 *sa, u16 update_indic,
+ const u8 *tlvs, size_t tlvs_len)
{
- struct wpas_dbus_priv *ctrl_iface;
- struct wpa_dbus_object_desc *obj_desc;
- char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
- struct bss_handler_args *arg;
+ DBusMessage *msg;
+ DBusMessageIter iter, dict_iter;
+ struct wpas_dbus_priv *iface;
+ char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
+ iface = wpa_s->global->dbus;
/* Do nothing if the control interface is not turned on */
- if (wpa_s == NULL || wpa_s->global == NULL)
- return 0;
- ctrl_iface = wpa_s->global->dbus;
- if (ctrl_iface == NULL)
- return 0;
-
- os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
- "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
- wpa_s->dbus_new_path, id);
+ if (iface == NULL)
+ return;
- obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
- if (!obj_desc) {
- wpa_printf(MSG_ERROR, "Not enough memory "
- "to create object description");
- goto err;
- }
+ msg = dbus_message_new_signal(wpa_s->dbus_new_path,
+ WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ "ServiceDiscoveryResponse");
+ if (msg == NULL)
+ return;
- arg = os_zalloc(sizeof(struct bss_handler_args));
- if (!arg) {
- wpa_printf(MSG_ERROR, "Not enough memory "
- "to create arguments for handler");
- goto err;
- }
- arg->wpa_s = wpa_s;
- arg->id = id;
+ /* Check if this is a known peer */
+ if (p2p_get_peer_info(wpa_s->global->p2p, sa, 0, NULL, 0) < 0)
+ goto error;
- wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
- wpas_dbus_bss_properties,
- wpas_dbus_bss_signals);
+ os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/"
+ COMPACT_MACSTR, wpa_s->dbus_new_path, MAC2STR(sa));
- wpa_printf(MSG_DEBUG, "dbus: Register BSS object '%s'",
- bss_obj_path);
- if (wpa_dbus_register_object_per_iface(ctrl_iface, bss_obj_path,
- wpa_s->ifname, obj_desc)) {
- wpa_printf(MSG_ERROR,
- "Cannot register BSSID dbus object %s.",
- bss_obj_path);
- goto err;
- }
+ path = peer_obj_path;
- wpas_dbus_signal_bss_added(wpa_s, bss_obj_path);
- wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
+ dbus_message_iter_init_append(msg, &iter);
+ if (!wpa_dbus_dict_open_write(&iter, &dict_iter))
+ goto error;
+
+ if (!wpa_dbus_dict_append_object_path(&dict_iter, "peer_object",
+ path) ||
+ !wpa_dbus_dict_append_uint16(&dict_iter, "update_indicator",
+ update_indic) ||
+ !wpa_dbus_dict_append_byte_array(&dict_iter, "tlvs",
+ (const char *) tlvs,
+ tlvs_len) ||
+ !wpa_dbus_dict_close_write(&iter, &dict_iter))
+ goto error;
- return 0;
-err:
- free_dbus_object_desc(obj_desc);
- return -1;
+ dbus_connection_send(iface->con, msg, NULL);
+ dbus_message_unref(msg);
+ return;
+error:
+ wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
+ dbus_message_unref(msg);
}
+#endif /*CONFIG_P2P*/
-static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
- { "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE,
- (WPADBusMethodHandler) &wpas_dbus_handler_scan,
- {
- { "args", "a{sv}", ARG_IN },
- END_ARGS
- }
- },
- { "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE,
- (WPADBusMethodHandler) &wpas_dbus_handler_disconnect,
- {
- END_ARGS
- }
- },
- { "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
- (WPADBusMethodHandler) &wpas_dbus_handler_add_network,
- {
- { "args", "a{sv}", ARG_IN },
- { "path", "o", ARG_OUT },
+
+/**
+ * wpas_dbus_signal_prop_changed - Signals change of property
+ * @wpa_s: %wpa_supplicant network interface data
+ * @property: indicates which property has changed
+ *
+ * Sends ProertyChanged signals with path, interface and arguments
+ * depending on which property has changed.
+ */
+void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
+ enum wpas_dbus_prop property)
+{
+ WPADBusPropertyAccessor getter;
+ char *prop;
+
+ if (wpa_s->dbus_new_path == NULL)
+ return; /* Skip signal since D-Bus setup is not yet ready */
+
+ switch (property) {
+ case WPAS_DBUS_PROP_AP_SCAN:
+ getter = (WPADBusPropertyAccessor) wpas_dbus_getter_ap_scan;
+ prop = "ApScan";
+ break;
+ case WPAS_DBUS_PROP_SCANNING:
+ getter = (WPADBusPropertyAccessor) wpas_dbus_getter_scanning;
+ prop = "Scanning";
+ break;
+ case WPAS_DBUS_PROP_STATE:
+ getter = (WPADBusPropertyAccessor) wpas_dbus_getter_state;
+ prop = "State";
+ break;
+ case WPAS_DBUS_PROP_CURRENT_BSS:
+ getter = (WPADBusPropertyAccessor)
+ wpas_dbus_getter_current_bss;
+ prop = "CurrentBSS";
+ break;
+ case WPAS_DBUS_PROP_CURRENT_NETWORK:
+ getter = (WPADBusPropertyAccessor)
+ wpas_dbus_getter_current_network;
+ prop = "CurrentNetwork";
+ break;
+ case WPAS_DBUS_PROP_BSSS:
+ getter = (WPADBusPropertyAccessor) wpas_dbus_getter_bsss;
+ prop = "BSSs";
+ break;
+ case WPAS_DBUS_PROP_CURRENT_AUTH_MODE:
+ getter = (WPADBusPropertyAccessor)
+ wpas_dbus_getter_current_auth_mode;
+ prop = "CurrentAuthMode";
+ break;
+ default:
+ wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
+ __func__, property);
+ return;
+ }
+
+ wpa_dbus_mark_property_changed(wpa_s->global->dbus,
+ wpa_s->dbus_new_path,
+ WPAS_DBUS_NEW_IFACE_INTERFACE, prop);
+}
+
+
+/**
+ * wpas_dbus_bss_signal_prop_changed - Signals change of BSS property
+ * @wpa_s: %wpa_supplicant network interface data
+ * @property: indicates which property has changed
+ * @id: unique BSS identifier
+ *
+ * Sends PropertyChanged signals with path, interface, and arguments depending
+ * on which property has changed.
+ */
+void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
+ enum wpas_dbus_bss_prop property,
+ unsigned int id)
+{
+ char path[WPAS_DBUS_OBJECT_PATH_MAX];
+ char *prop;
+
+ switch (property) {
+ case WPAS_DBUS_BSS_PROP_SIGNAL:
+ prop = "Signal";
+ break;
+ case WPAS_DBUS_BSS_PROP_FREQ:
+ prop = "Frequency";
+ break;
+ case WPAS_DBUS_BSS_PROP_MODE:
+ prop = "Mode";
+ break;
+ case WPAS_DBUS_BSS_PROP_PRIVACY:
+ prop = "Privacy";
+ break;
+ case WPAS_DBUS_BSS_PROP_RATES:
+ prop = "Rates";
+ break;
+ case WPAS_DBUS_BSS_PROP_WPA:
+ prop = "WPA";
+ break;
+ case WPAS_DBUS_BSS_PROP_RSN:
+ prop = "RSN";
+ break;
+ case WPAS_DBUS_BSS_PROP_IES:
+ prop = "IEs";
+ break;
+ default:
+ wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
+ __func__, property);
+ return;
+ }
+
+ os_snprintf(path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
+ wpa_s->dbus_new_path, id);
+
+ wpa_dbus_mark_property_changed(wpa_s->global->dbus, path,
+ WPAS_DBUS_NEW_IFACE_BSS, prop);
+}
+
+
+/**
+ * wpas_dbus_signal_debug_level_changed - Signals change of debug param
+ * @global: wpa_global structure
+ *
+ * Sends ProertyChanged signals informing that debug level has changed.
+ */
+void wpas_dbus_signal_debug_level_changed(struct wpa_global *global)
+{
+ wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
+ WPAS_DBUS_NEW_INTERFACE,
+ "DebugLevel");
+}
+
+
+/**
+ * wpas_dbus_signal_debug_timestamp_changed - Signals change of debug param
+ * @global: wpa_global structure
+ *
+ * Sends ProertyChanged signals informing that debug timestamp has changed.
+ */
+void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global)
+{
+ wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
+ WPAS_DBUS_NEW_INTERFACE,
+ "DebugTimestamp");
+}
+
+
+/**
+ * wpas_dbus_signal_debug_show_keys_changed - Signals change of debug param
+ * @global: wpa_global structure
+ *
+ * Sends ProertyChanged signals informing that debug show_keys has changed.
+ */
+void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global)
+{
+ wpa_dbus_mark_property_changed(global->dbus, WPAS_DBUS_NEW_PATH,
+ WPAS_DBUS_NEW_INTERFACE,
+ "DebugShowKeys");
+}
+
+
+static void wpas_dbus_register(struct wpa_dbus_object_desc *obj_desc,
+ void *priv,
+ WPADBusArgumentFreeFunction priv_free,
+ const struct wpa_dbus_method_desc *methods,
+ const struct wpa_dbus_property_desc *properties,
+ const struct wpa_dbus_signal_desc *signals)
+{
+ int n;
+
+ obj_desc->user_data = priv;
+ obj_desc->user_data_free_func = priv_free;
+ obj_desc->methods = methods;
+ obj_desc->properties = properties;
+ obj_desc->signals = signals;
+
+ for (n = 0; properties && properties->dbus_property; properties++)
+ n++;
+
+ obj_desc->prop_changed_flags = os_zalloc(n);
+ if (!obj_desc->prop_changed_flags)
+ wpa_printf(MSG_DEBUG, "dbus: %s: can't register handlers",
+ __func__);
+}
+
+
+static const struct wpa_dbus_method_desc wpas_dbus_global_methods[] = {
+ { "CreateInterface", WPAS_DBUS_NEW_INTERFACE,
+ (WPADBusMethodHandler) &wpas_dbus_handler_create_interface,
+ {
+ { "args", "a{sv}", ARG_IN },
+ { "path", "o", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "RemoveInterface", WPAS_DBUS_NEW_INTERFACE,
+ (WPADBusMethodHandler) &wpas_dbus_handler_remove_interface,
+ {
+ { "path", "o", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "GetInterface", WPAS_DBUS_NEW_INTERFACE,
+ (WPADBusMethodHandler) &wpas_dbus_handler_get_interface,
+ {
+ { "ifname", "s", ARG_IN },
+ { "path", "o", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { NULL, NULL, NULL, { END_ARGS } }
+};
+
+static const struct wpa_dbus_property_desc wpas_dbus_global_properties[] = {
+ { "DebugLevel", WPAS_DBUS_NEW_INTERFACE, "s",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_debug_level,
+ (WPADBusPropertyAccessor) wpas_dbus_setter_debug_level,
+ RW
+ },
+ { "DebugTimestamp", WPAS_DBUS_NEW_INTERFACE, "b",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_debug_timestamp,
+ (WPADBusPropertyAccessor) wpas_dbus_setter_debug_timestamp,
+ RW
+ },
+ { "DebugShowKeys", WPAS_DBUS_NEW_INTERFACE, "b",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_debug_show_keys,
+ (WPADBusPropertyAccessor) wpas_dbus_setter_debug_show_keys,
+ RW
+ },
+ { "Interfaces", WPAS_DBUS_NEW_INTERFACE, "ao",
+ (WPADBusPropertyAccessor) &wpas_dbus_getter_interfaces,
+ NULL,
+ R
+ },
+ { "EapMethods", WPAS_DBUS_NEW_INTERFACE, "as",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_eap_methods,
+ NULL,
+ R
+ },
+ { NULL, NULL, NULL, NULL, NULL, 0 }
+};
+
+static const struct wpa_dbus_signal_desc wpas_dbus_global_signals[] = {
+ { "InterfaceAdded", WPAS_DBUS_NEW_INTERFACE,
+ {
+ { "path", "o", ARG_OUT },
+ { "properties", "a{sv}", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "InterfaceRemoved", WPAS_DBUS_NEW_INTERFACE,
+ {
+ { "path", "o", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "PropertiesChanged", WPAS_DBUS_NEW_INTERFACE,
+ {
+ { "properties", "a{sv}", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { NULL, NULL, { END_ARGS } }
+};
+
+
+/**
+ * wpas_dbus_ctrl_iface_init - Initialize dbus control interface
+ * @global: Pointer to global data from wpa_supplicant_init()
+ * Returns: 0 on success or -1 on failure
+ *
+ * Initialize the dbus control interface for wpa_supplicantand and start
+ * receiving commands from external programs over the bus.
+ */
+int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv)
+{
+ struct wpa_dbus_object_desc *obj_desc;
+ int ret;
+
+ obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
+ if (!obj_desc) {
+ wpa_printf(MSG_ERROR, "Not enough memory "
+ "to create object description");
+ return -1;
+ }
+
+ wpas_dbus_register(obj_desc, priv->global, NULL,
+ wpas_dbus_global_methods,
+ wpas_dbus_global_properties,
+ wpas_dbus_global_signals);
+
+ wpa_printf(MSG_DEBUG, "dbus: Register D-Bus object '%s'",
+ WPAS_DBUS_NEW_PATH);
+ ret = wpa_dbus_ctrl_iface_init(priv, WPAS_DBUS_NEW_PATH,
+ WPAS_DBUS_NEW_SERVICE,
+ obj_desc);
+ if (ret < 0)
+ free_dbus_object_desc(obj_desc);
+ else
+ priv->dbus_new_initialized = 1;
+
+ return ret;
+}
+
+
+/**
+ * wpas_dbus_ctrl_iface_deinit - Deinitialize dbus ctrl interface for
+ * wpa_supplicant
+ * @iface: Pointer to dbus private data from wpas_dbus_init()
+ *
+ * Deinitialize the dbus control interface that was initialized with
+ * wpas_dbus_ctrl_iface_init().
+ */
+void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv *iface)
+{
+ if (!iface->dbus_new_initialized)
+ return;
+ wpa_printf(MSG_DEBUG, "dbus: Unregister D-Bus object '%s'",
+ WPAS_DBUS_NEW_PATH);
+ dbus_connection_unregister_object_path(iface->con,
+ WPAS_DBUS_NEW_PATH);
+}
+
+
+static void wpa_dbus_free(void *ptr)
+{
+ os_free(ptr);
+}
+
+
+static const struct wpa_dbus_property_desc wpas_dbus_network_properties[] = {
+ { "Properties", WPAS_DBUS_NEW_IFACE_NETWORK, "a{sv}",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_network_properties,
+ (WPADBusPropertyAccessor) wpas_dbus_setter_network_properties,
+ RW
+ },
+ { "Enabled", WPAS_DBUS_NEW_IFACE_NETWORK, "b",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_enabled,
+ (WPADBusPropertyAccessor) wpas_dbus_setter_enabled,
+ RW
+ },
+ { NULL, NULL, NULL, NULL, NULL, 0 }
+};
+
+
+static const struct wpa_dbus_signal_desc wpas_dbus_network_signals[] = {
+ { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_NETWORK,
+ {
+ { "properties", "a{sv}", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { NULL, NULL, { END_ARGS } }
+};
+
+
+/**
+ * wpas_dbus_register_network - Register a configured network with dbus
+ * @wpa_s: wpa_supplicant interface structure
+ * @ssid: network configuration data
+ * Returns: 0 on success, -1 on failure
+ *
+ * Registers network representing object with dbus
+ */
+int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
+ struct wpa_ssid *ssid)
+{
+ struct wpas_dbus_priv *ctrl_iface;
+ struct wpa_dbus_object_desc *obj_desc;
+ struct network_handler_args *arg;
+ char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
+
+ /* Do nothing if the control interface is not turned on */
+ if (wpa_s == NULL || wpa_s->global == NULL)
+ return 0;
+ ctrl_iface = wpa_s->global->dbus;
+ if (ctrl_iface == NULL)
+ return 0;
+
+ os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
+ wpa_s->dbus_new_path, ssid->id);
+
+ wpa_printf(MSG_DEBUG, "dbus: Register network object '%s'",
+ net_obj_path);
+ obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
+ if (!obj_desc) {
+ wpa_printf(MSG_ERROR, "Not enough memory "
+ "to create object description");
+ goto err;
+ }
+
+ /* allocate memory for handlers arguments */
+ arg = os_zalloc(sizeof(struct network_handler_args));
+ if (!arg) {
+ wpa_printf(MSG_ERROR, "Not enough memory "
+ "to create arguments for method");
+ goto err;
+ }
+
+ arg->wpa_s = wpa_s;
+ arg->ssid = ssid;
+
+ wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
+ wpas_dbus_network_properties,
+ wpas_dbus_network_signals);
+
+ if (wpa_dbus_register_object_per_iface(ctrl_iface, net_obj_path,
+ wpa_s->ifname, obj_desc))
+ goto err;
+
+ wpas_dbus_signal_network_added(wpa_s, ssid->id);
+
+ return 0;
+
+err:
+ free_dbus_object_desc(obj_desc);
+ return -1;
+}
+
+
+/**
+ * wpas_dbus_unregister_network - Unregister a configured network from dbus
+ * @wpa_s: wpa_supplicant interface structure
+ * @nid: network id
+ * Returns: 0 on success, -1 on failure
+ *
+ * Unregisters network representing object from dbus
+ */
+int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid)
+{
+ struct wpas_dbus_priv *ctrl_iface;
+ char net_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
+ int ret;
+
+ /* Do nothing if the control interface is not turned on */
+ if (wpa_s == NULL || wpa_s->global == NULL ||
+ wpa_s->dbus_new_path == NULL)
+ return 0;
+ ctrl_iface = wpa_s->global->dbus;
+ if (ctrl_iface == NULL)
+ return 0;
+
+ os_snprintf(net_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_NETWORKS_PART "/%u",
+ wpa_s->dbus_new_path, nid);
+
+ wpa_printf(MSG_DEBUG, "dbus: Unregister network object '%s'",
+ net_obj_path);
+ ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, net_obj_path);
+
+ if (!ret)
+ wpas_dbus_signal_network_removed(wpa_s, nid);
+
+ return ret;
+}
+
+
+static const struct wpa_dbus_property_desc wpas_dbus_bss_properties[] = {
+ { "SSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_bss_ssid,
+ NULL,
+ R
+ },
+ { "BSSID", WPAS_DBUS_NEW_IFACE_BSS, "ay",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_bss_bssid,
+ NULL,
+ R
+ },
+ { "Privacy", WPAS_DBUS_NEW_IFACE_BSS, "b",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_bss_privacy,
+ NULL,
+ R
+ },
+ { "Mode", WPAS_DBUS_NEW_IFACE_BSS, "s",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_bss_mode,
+ NULL,
+ R
+ },
+ { "Signal", WPAS_DBUS_NEW_IFACE_BSS, "n",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_bss_signal,
+ NULL,
+ R
+ },
+ { "Frequency", WPAS_DBUS_NEW_IFACE_BSS, "q",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_bss_frequency,
+ NULL,
+ R
+ },
+ { "Rates", WPAS_DBUS_NEW_IFACE_BSS, "au",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_bss_rates,
+ NULL,
+ R
+ },
+ { "WPA", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_bss_wpa,
+ NULL,
+ R
+ },
+ { "RSN", WPAS_DBUS_NEW_IFACE_BSS, "a{sv}",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_bss_rsn,
+ NULL,
+ R
+ },
+ { "IEs", WPAS_DBUS_NEW_IFACE_BSS, "ay",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_bss_ies,
+ NULL,
+ R
+ },
+ { NULL, NULL, NULL, NULL, NULL, 0 }
+};
+
+
+static const struct wpa_dbus_signal_desc wpas_dbus_bss_signals[] = {
+ { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_BSS,
+ {
+ { "properties", "a{sv}", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { NULL, NULL, { END_ARGS } }
+};
+
+
+/**
+ * wpas_dbus_unregister_bss - Unregister a scanned BSS from dbus
+ * @wpa_s: wpa_supplicant interface structure
+ * @bssid: scanned network bssid
+ * @id: unique BSS identifier
+ * Returns: 0 on success, -1 on failure
+ *
+ * Unregisters BSS representing object from dbus
+ */
+int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
+ u8 bssid[ETH_ALEN], unsigned int id)
+{
+ struct wpas_dbus_priv *ctrl_iface;
+ char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
+
+ /* Do nothing if the control interface is not turned on */
+ if (wpa_s == NULL || wpa_s->global == NULL)
+ return 0;
+ ctrl_iface = wpa_s->global->dbus;
+ if (ctrl_iface == NULL)
+ return 0;
+
+ os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
+ wpa_s->dbus_new_path, id);
+
+ wpa_printf(MSG_DEBUG, "dbus: Unregister BSS object '%s'",
+ bss_obj_path);
+ if (wpa_dbus_unregister_object_per_iface(ctrl_iface, bss_obj_path)) {
+ wpa_printf(MSG_ERROR, "dbus: Cannot unregister BSS object %s",
+ bss_obj_path);
+ return -1;
+ }
+
+ wpas_dbus_signal_bss_removed(wpa_s, bss_obj_path);
+ wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
+
+ return 0;
+}
+
+
+/**
+ * wpas_dbus_register_bss - Register a scanned BSS with dbus
+ * @wpa_s: wpa_supplicant interface structure
+ * @bssid: scanned network bssid
+ * @id: unique BSS identifier
+ * Returns: 0 on success, -1 on failure
+ *
+ * Registers BSS representing object with dbus
+ */
+int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
+ u8 bssid[ETH_ALEN], unsigned int id)
+{
+ struct wpas_dbus_priv *ctrl_iface;
+ struct wpa_dbus_object_desc *obj_desc;
+ char bss_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
+ struct bss_handler_args *arg;
+
+ /* Do nothing if the control interface is not turned on */
+ if (wpa_s == NULL || wpa_s->global == NULL)
+ return 0;
+ ctrl_iface = wpa_s->global->dbus;
+ if (ctrl_iface == NULL)
+ return 0;
+
+ os_snprintf(bss_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_BSSIDS_PART "/%u",
+ wpa_s->dbus_new_path, id);
+
+ obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
+ if (!obj_desc) {
+ wpa_printf(MSG_ERROR, "Not enough memory "
+ "to create object description");
+ goto err;
+ }
+
+ arg = os_zalloc(sizeof(struct bss_handler_args));
+ if (!arg) {
+ wpa_printf(MSG_ERROR, "Not enough memory "
+ "to create arguments for handler");
+ goto err;
+ }
+ arg->wpa_s = wpa_s;
+ arg->id = id;
+
+ wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
+ wpas_dbus_bss_properties,
+ wpas_dbus_bss_signals);
+
+ wpa_printf(MSG_DEBUG, "dbus: Register BSS object '%s'",
+ bss_obj_path);
+ if (wpa_dbus_register_object_per_iface(ctrl_iface, bss_obj_path,
+ wpa_s->ifname, obj_desc)) {
+ wpa_printf(MSG_ERROR,
+ "Cannot register BSSID dbus object %s.",
+ bss_obj_path);
+ goto err;
+ }
+
+ wpas_dbus_signal_bss_added(wpa_s, bss_obj_path);
+ wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSSS);
+
+ return 0;
+
+err:
+ free_dbus_object_desc(obj_desc);
+ return -1;
+}
+
+
+static const struct wpa_dbus_method_desc wpas_dbus_interface_methods[] = {
+ { "Scan", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ (WPADBusMethodHandler) &wpas_dbus_handler_scan,
+ {
+ { "args", "a{sv}", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "Disconnect", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ (WPADBusMethodHandler) &wpas_dbus_handler_disconnect,
+ {
+ END_ARGS
+ }
+ },
+ { "AddNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ (WPADBusMethodHandler) &wpas_dbus_handler_add_network,
+ {
+ { "args", "a{sv}", ARG_IN },
+ { "path", "o", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ (WPADBusMethodHandler) &wpas_dbus_handler_remove_network,
+ {
+ { "path", "o", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "RemoveAllNetworks", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ (WPADBusMethodHandler) &wpas_dbus_handler_remove_all_networks,
+ {
+ END_ARGS
+ }
+ },
+ { "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ (WPADBusMethodHandler) &wpas_dbus_handler_select_network,
+ {
+ { "path", "o", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ (WPADBusMethodHandler) &wpas_dbus_handler_add_blob,
+ {
+ { "name", "s", ARG_IN },
+ { "data", "ay", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ (WPADBusMethodHandler) &wpas_dbus_handler_get_blob,
+ {
+ { "name", "s", ARG_IN },
+ { "data", "ay", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ (WPADBusMethodHandler) &wpas_dbus_handler_remove_blob,
+ {
+ { "name", "s", ARG_IN },
+ END_ARGS
+ }
+ },
+#ifdef CONFIG_WPS
+ { "Start", WPAS_DBUS_NEW_IFACE_WPS,
+ (WPADBusMethodHandler) &wpas_dbus_handler_wps_start,
+ {
+ { "args", "a{sv}", ARG_IN },
+ { "output", "a{sv}", ARG_OUT },
+ END_ARGS
+ }
+ },
+#endif /* CONFIG_WPS */
+#ifdef CONFIG_P2P
+ { "Find", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_find,
+ {
+ { "args", "a{sv}", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "StopFind", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_stop_find,
+ {
+ END_ARGS
+ }
+ },
+ { "Listen", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_listen,
+ {
+ { "timeout", "i", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "ExtendedListen", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_extendedlisten,
+ {
+ { "args", "a{sv}", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "PresenceRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_presence_request,
+ {
+ { "args", "a{sv}", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "ProvisionDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_prov_disc_req,
+ {
+ { "peer", "o", ARG_IN },
+ { "config_method", "s", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "Connect", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_connect,
+ {
+ { "args", "a{sv}", ARG_IN },
+ { "generated_pin", "i", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "GroupAdd", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_group_add,
+ {
+ { "args", "a{sv}", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "Invite", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_invite,
+ {
+ { "args", "a{sv}", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "Disconnect", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_disconnect,
+ {
+ END_ARGS
+ }
+ },
+ { "RejectPeer", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_rejectpeer,
+ {
+ { "peer", "o", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "Flush", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_flush,
+ {
+ END_ARGS
+ }
+ },
+ { "AddService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_add_service,
+ {
+ { "args", "a{sv}", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "DeleteService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_delete_service,
+ {
+ { "args", "a{sv}", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "FlushService", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_flush_service,
+ {
+ END_ARGS
+ }
+ },
+ { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_service_sd_req,
+ {
+ { "args", "a{sv}", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_service_sd_res,
+ {
+ { "args", "a{sv}", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "ServiceDiscoveryCancelRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_service_sd_cancel_req,
+ {
+ { "args", "t", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "ServiceUpdate", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_service_update,
+ {
+ END_ARGS
+ }
+ },
+ { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_serv_disc_external,
+ {
+ { "arg", "i", ARG_IN },
+ END_ARGS
+ }
+ },
+ { "ServiceDiscoveryExternal", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ (WPADBusMethodHandler)wpas_dbus_handler_p2p_serv_disc_external,
+ {
+ { "arg", "i", ARG_IN },
+ END_ARGS
+ }
+ },
+#endif /* CONFIG_P2P */
+ { "FlushBSS", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ (WPADBusMethodHandler) &wpas_dbus_handler_flush_bss,
+ {
+ { "age", "u", ARG_IN },
+ END_ARGS
+ }
+ },
+ { NULL, NULL, NULL, { END_ARGS } }
+};
+
+static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
+ { "Capabilities", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{sv}",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_capabilities,
+ NULL, R
+ },
+ { "State", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_state,
+ NULL, R
+ },
+ { "Scanning", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_scanning,
+ NULL, R
+ },
+ { "ApScan", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_ap_scan,
+ (WPADBusPropertyAccessor) wpas_dbus_setter_ap_scan,
+ RW
+ },
+ { "BSSExpireAge", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_bss_expire_age,
+ (WPADBusPropertyAccessor) wpas_dbus_setter_bss_expire_age,
+ RW
+ },
+ { "BSSExpireCount", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_bss_expire_count,
+ (WPADBusPropertyAccessor) wpas_dbus_setter_bss_expire_count,
+ RW
+ },
+ { "Country", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_country,
+ (WPADBusPropertyAccessor) wpas_dbus_setter_country,
+ RW
+ },
+ { "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_ifname,
+ NULL, R
+ },
+ { "Driver", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_driver,
+ NULL, R
+ },
+ { "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_bridge_ifname,
+ NULL, R
+ },
+ { "CurrentBSS", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_current_bss,
+ NULL, R
+ },
+ { "CurrentNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_current_network,
+ NULL, R
+ },
+ { "CurrentAuthMode", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_current_auth_mode,
+ NULL, R
+ },
+ { "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{say}",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_blobs,
+ NULL, R
+ },
+ { "BSSs", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_bsss,
+ NULL, R
+ },
+ { "Networks", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_networks,
+ NULL, R
+ },
+#ifdef CONFIG_WPS
+ { "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS, "b",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_process_credentials,
+ (WPADBusPropertyAccessor) wpas_dbus_setter_process_credentials,
+ RW
+ },
+#endif /* CONFIG_WPS */
+#ifdef CONFIG_P2P
+ { "P2PDeviceProperties", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "a{sv}",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_p2p_device_properties,
+ (WPADBusPropertyAccessor) wpas_dbus_setter_p2p_device_properties,
+ RW
+ },
+ { "Peers", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "ao",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_p2p_peers,
+ NULL, R
+ },
+ { "Role", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "s",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_p2p_role,
+ NULL, R
+ },
+ { "Group", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "o",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_p2p_group,
+ NULL, R
+ },
+ { "PeerGO", WPAS_DBUS_NEW_IFACE_P2PDEVICE, "o",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_p2p_peergo,
+ NULL, R
+ },
+#endif /* CONFIG_P2P */
+ { NULL, NULL, NULL, NULL, NULL, 0 }
+};
+
+static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
+ { "ScanDone", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ {
+ { "success", "b", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ {
+ { "path", "o", ARG_OUT },
+ { "properties", "a{sv}", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "BSSRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ {
+ { "path", "o", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "BlobAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ {
+ { "name", "s", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "BlobRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ {
+ { "name", "s", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "NetworkAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ {
+ { "path", "o", ARG_OUT },
+ { "properties", "a{sv}", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "NetworkRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ {
+ { "path", "o", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "NetworkSelected", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ {
+ { "path", "o", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_INTERFACE,
+ {
+ { "properties", "a{sv}", ARG_OUT },
+ END_ARGS
+ }
+ },
+#ifdef CONFIG_WPS
+ { "Event", WPAS_DBUS_NEW_IFACE_WPS,
+ {
+ { "name", "s", ARG_OUT },
+ { "args", "a{sv}", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "Credentials", WPAS_DBUS_NEW_IFACE_WPS,
+ {
+ { "credentials", "a{sv}", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_WPS,
+ {
+ { "properties", "a{sv}", ARG_OUT },
+ END_ARGS
+ }
+ },
+#endif /* CONFIG_WPS */
+#ifdef CONFIG_P2P
+ { "P2PStateChanged", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ {
+ { "states", "a{ss}", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "DeviceFound", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ {
+ { "path", "o", ARG_OUT },
+ { "properties", "a{sv}", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "DeviceLost", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ {
+ { "path", "o", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "ProvisionDiscoveryRequestDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ {
+ { "peer_object", "o", ARG_OUT },
+ { "pin", "s", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "ProvisionDiscoveryResponseDisplayPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ {
+ { "peer_object", "o", ARG_OUT },
+ { "pin", "s", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "ProvisionDiscoveryRequestEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ {
+ { "peer_object", "o", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "ProvisionDiscoveryResponseEnterPin", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ {
+ { "peer_object", "o", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "ProvisionDiscoveryPBCRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ {
+ { "peer_object", "o", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "ProvisionDiscoveryPBCResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ {
+ { "peer_object", "o", ARG_OUT },
+ END_ARGS
+ }
+ },
+ { "ProvisionDiscoveryFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ {
+ { "peer_object", "o", ARG_OUT },
+ { "status", "i", ARG_OUT },
END_ARGS
}
},
- { "RemoveNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
- (WPADBusMethodHandler) &wpas_dbus_handler_remove_network,
+ { "GroupStarted", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
{
- { "path", "o", ARG_IN },
+ { "properties", "a{sv}", ARG_OUT },
END_ARGS
}
},
- { "RemoveAllNetworks", WPAS_DBUS_NEW_IFACE_INTERFACE,
- (WPADBusMethodHandler) &wpas_dbus_handler_remove_all_networks,
+ { "GONegotiationSuccess", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
{
END_ARGS
}
},
- { "SelectNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE,
- (WPADBusMethodHandler) &wpas_dbus_handler_select_network,
+ { "GONegotiationFailure", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
{
- { "path", "o", ARG_IN },
+ { "status", "i", ARG_OUT },
END_ARGS
}
},
- { "AddBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
- (WPADBusMethodHandler) &wpas_dbus_handler_add_blob,
+ { "GONegotiationRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
{
- { "name", "s", ARG_IN },
- { "data", "ay", ARG_IN },
+ { "path", "o", ARG_OUT },
+ { "dev_passwd_id", "i", ARG_OUT },
END_ARGS
}
},
- { "GetBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
- (WPADBusMethodHandler) &wpas_dbus_handler_get_blob,
+ { "InvitationResult", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
{
- { "name", "s", ARG_IN },
- { "data", "ay", ARG_OUT },
+ { "invite_result", "a{sv}", ARG_OUT },
END_ARGS
}
},
- { "RemoveBlob", WPAS_DBUS_NEW_IFACE_INTERFACE,
- (WPADBusMethodHandler) &wpas_dbus_handler_remove_blob,
+ { "GroupFinished", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
{
- { "name", "s", ARG_IN },
+ { "ifname", "s", ARG_OUT },
+ { "role", "s", ARG_OUT },
END_ARGS
}
},
-#ifdef CONFIG_WPS
- { "Start", WPAS_DBUS_NEW_IFACE_WPS,
- (WPADBusMethodHandler) &wpas_dbus_handler_wps_start,
+ { "ServiceDiscoveryRequest", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
{
- { "args", "a{sv}", ARG_IN },
- { "output", "a{sv}", ARG_OUT },
+ { "sd_request", "a{sv}", ARG_OUT },
END_ARGS
}
},
-#endif /* CONFIG_WPS */
- { "FlushBSS", WPAS_DBUS_NEW_IFACE_INTERFACE,
- (WPADBusMethodHandler) &wpas_dbus_handler_flush_bss,
+ { "ServiceDiscoveryResponse", WPAS_DBUS_NEW_IFACE_P2PDEVICE,
{
- { "age", "u", ARG_IN },
+ { "sd_response", "a{sv}", ARG_OUT },
END_ARGS
}
},
- { NULL, NULL, NULL, { END_ARGS } }
+#endif /* CONFIG_P2P */
+ { NULL, NULL, { END_ARGS } }
};
-static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
- { "Capabilities", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{sv}",
- (WPADBusPropertyAccessor) wpas_dbus_getter_capabilities,
- NULL, R
- },
- { "State", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
- (WPADBusPropertyAccessor) wpas_dbus_getter_state,
- NULL, R
- },
- { "Scanning", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
- (WPADBusPropertyAccessor) wpas_dbus_getter_scanning,
- NULL, R
- },
- { "ApScan", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
- (WPADBusPropertyAccessor) wpas_dbus_getter_ap_scan,
- (WPADBusPropertyAccessor) wpas_dbus_setter_ap_scan,
- RW
- },
- { "BSSExpireAge", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
- (WPADBusPropertyAccessor) wpas_dbus_getter_bss_expire_age,
- (WPADBusPropertyAccessor) wpas_dbus_setter_bss_expire_age,
- RW
- },
- { "BSSExpireCount", WPAS_DBUS_NEW_IFACE_INTERFACE, "u",
- (WPADBusPropertyAccessor) wpas_dbus_getter_bss_expire_count,
- (WPADBusPropertyAccessor) wpas_dbus_setter_bss_expire_count,
- RW
- },
- { "Country", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
- (WPADBusPropertyAccessor) wpas_dbus_getter_country,
- (WPADBusPropertyAccessor) wpas_dbus_setter_country,
- RW
- },
- { "Ifname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
- (WPADBusPropertyAccessor) wpas_dbus_getter_ifname,
- NULL, R
- },
- { "Driver", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
- (WPADBusPropertyAccessor) wpas_dbus_getter_driver,
- NULL, R
- },
- { "BridgeIfname", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
- (WPADBusPropertyAccessor) wpas_dbus_getter_bridge_ifname,
- NULL, R
- },
- { "CurrentBSS", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
- (WPADBusPropertyAccessor) wpas_dbus_getter_current_bss,
- NULL, R
- },
- { "CurrentNetwork", WPAS_DBUS_NEW_IFACE_INTERFACE, "o",
- (WPADBusPropertyAccessor) wpas_dbus_getter_current_network,
- NULL, R
- },
- { "CurrentAuthMode", WPAS_DBUS_NEW_IFACE_INTERFACE, "s",
- (WPADBusPropertyAccessor) wpas_dbus_getter_current_auth_mode,
- NULL, R
- },
- { "Blobs", WPAS_DBUS_NEW_IFACE_INTERFACE, "a{say}",
- (WPADBusPropertyAccessor) wpas_dbus_getter_blobs,
+
+int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
+{
+
+ struct wpa_dbus_object_desc *obj_desc = NULL;
+ struct wpas_dbus_priv *ctrl_iface = wpa_s->global->dbus;
+ int next;
+
+ /* Do nothing if the control interface is not turned on */
+ if (ctrl_iface == NULL)
+ return 0;
+
+ /* Create and set the interface's object path */
+ wpa_s->dbus_new_path = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX);
+ if (wpa_s->dbus_new_path == NULL)
+ return -1;
+ next = ctrl_iface->next_objid++;
+ os_snprintf(wpa_s->dbus_new_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ WPAS_DBUS_NEW_PATH_INTERFACES "/%u",
+ next);
+
+ obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
+ if (!obj_desc) {
+ wpa_printf(MSG_ERROR, "Not enough memory "
+ "to create object description");
+ goto err;
+ }
+
+ wpas_dbus_register(obj_desc, wpa_s, NULL, wpas_dbus_interface_methods,
+ wpas_dbus_interface_properties,
+ wpas_dbus_interface_signals);
+
+ wpa_printf(MSG_DEBUG, "dbus: Register interface object '%s'",
+ wpa_s->dbus_new_path);
+ if (wpa_dbus_register_object_per_iface(ctrl_iface,
+ wpa_s->dbus_new_path,
+ wpa_s->ifname, obj_desc))
+ goto err;
+
+ wpas_dbus_signal_interface_added(wpa_s);
+
+ return 0;
+
+err:
+ os_free(wpa_s->dbus_new_path);
+ wpa_s->dbus_new_path = NULL;
+ free_dbus_object_desc(obj_desc);
+ return -1;
+}
+
+
+int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
+{
+ struct wpas_dbus_priv *ctrl_iface;
+
+ /* Do nothing if the control interface is not turned on */
+ if (wpa_s == NULL || wpa_s->global == NULL)
+ return 0;
+ ctrl_iface = wpa_s->global->dbus;
+ if (ctrl_iface == NULL)
+ return 0;
+
+ wpa_printf(MSG_DEBUG, "dbus: Unregister interface object '%s'",
+ wpa_s->dbus_new_path);
+ if (wpa_dbus_unregister_object_per_iface(ctrl_iface,
+ wpa_s->dbus_new_path))
+ return -1;
+
+ wpas_dbus_signal_interface_removed(wpa_s);
+
+ os_free(wpa_s->dbus_new_path);
+ wpa_s->dbus_new_path = NULL;
+
+ return 0;
+}
+
+#ifdef CONFIG_P2P
+
+static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
+ { "Properties", WPAS_DBUS_NEW_IFACE_P2P_PEER, "a{sv}",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_p2p_peer_properties,
NULL, R
},
- { "BSSs", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
- (WPADBusPropertyAccessor) wpas_dbus_getter_bsss,
+ { "IEs", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_p2p_peer_ies,
NULL, R
},
- { "Networks", WPAS_DBUS_NEW_IFACE_INTERFACE, "ao",
- (WPADBusPropertyAccessor) wpas_dbus_getter_networks,
+ { NULL, NULL, NULL, NULL, NULL, 0 }
+};
+
+static const struct wpa_dbus_signal_desc wpas_dbus_p2p_peer_signals[] = {
+
+ { NULL, NULL, { END_ARGS } }
+};
+
+/**
+ * wpas_dbus_signal_peer - Send a peer related event signal
+ * @wpa_s: %wpa_supplicant network interface data
+ * @dev: peer device object
+ * @interface: name of the interface emitting this signal.
+ * In case of peer objects, it would be emitted by either
+ * the "interface object" or by "peer objects"
+ * @sig_name: signal name - DeviceFound
+ *
+ * Notify listeners about event related with newly found p2p peer device
+ */
+static void wpas_dbus_signal_peer(struct wpa_supplicant *wpa_s,
+ const u8 *dev_addr, const char *interface,
+ const char *sig_name)
+{
+ struct wpas_dbus_priv *iface;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
+
+ iface = wpa_s->global->dbus;
+
+ /* Do nothing if the control interface is not turned on */
+ if (iface == NULL)
+ return;
+
+ os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
+ wpa_s->dbus_new_path, MAC2STR(dev_addr));
+
+ msg = dbus_message_new_signal(wpa_s->dbus_new_path, interface,
+ sig_name);
+ if (msg == NULL)
+ return;
+
+ dbus_message_iter_init_append(msg, &iter);
+ path = peer_obj_path;
+ if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
+ &path))
+ goto err;
+
+ dbus_connection_send(iface->con, msg, NULL);
+
+ dbus_message_unref(msg);
+ return;
+
+err:
+ wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
+ dbus_message_unref(msg);
+}
+
+
+/**
+ * wpas_dbus_signal_peer_found - Send a peer found signal
+ * @wpa_s: %wpa_supplicant network interface data
+ * @dev: peer device object
+ *
+ * Notify listeners about find a p2p peer device found
+ */
+void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
+ const u8 *dev_addr)
+{
+ wpas_dbus_signal_peer(wpa_s, dev_addr,
+ WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ "DeviceFound");
+}
+
+/**
+ * wpas_dbus_signal_peer_lost - Send a peer lost signal
+ * @wpa_s: %wpa_supplicant network interface data
+ * @dev: peer device object
+ *
+ * Notify listeners about lost a p2p peer device
+ */
+void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
+ const u8 *dev_addr)
+{
+ wpas_dbus_signal_peer(wpa_s, dev_addr,
+ WPAS_DBUS_NEW_IFACE_P2PDEVICE,
+ "DeviceLost");
+}
+
+/**
+ * wpas_dbus_register_peer - Register a discovered peer object with dbus
+ * @wpa_s: wpa_supplicant interface structure
+ * @ssid: network configuration data
+ * Returns: 0 on success, -1 on failure
+ *
+ * Registers network representing object with dbus
+ */
+int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr)
+{
+ struct wpas_dbus_priv *ctrl_iface;
+ struct wpa_dbus_object_desc *obj_desc;
+ struct peer_handler_args *arg;
+ char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
+
+ /* Do nothing if the control interface is not turned on */
+ if (wpa_s == NULL || wpa_s->global == NULL)
+ return 0;
+
+ ctrl_iface = wpa_s->global->dbus;
+ if (ctrl_iface == NULL)
+ return 0;
+
+ os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
+ wpa_s->dbus_new_path, MAC2STR(dev_addr));
+
+ wpa_printf(MSG_INFO, "dbus: Register peer object '%s'",
+ peer_obj_path);
+ obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
+ if (!obj_desc) {
+ wpa_printf(MSG_ERROR, "Not enough memory "
+ "to create object description");
+ goto err;
+ }
+
+ /* allocate memory for handlers arguments */
+ arg = os_zalloc(sizeof(struct peer_handler_args));
+ if (!arg) {
+ wpa_printf(MSG_ERROR, "Not enough memory "
+ "to create arguments for method");
+ goto err;
+ }
+
+ arg->wpa_s = wpa_s;
+ os_memcpy(arg->p2p_device_addr, dev_addr, ETH_ALEN);
+
+ wpas_dbus_register(obj_desc, arg, wpa_dbus_free,
+ NULL,
+ wpas_dbus_p2p_peer_properties,
+ wpas_dbus_p2p_peer_signals);
+
+ if (wpa_dbus_register_object_per_iface(ctrl_iface, peer_obj_path,
+ wpa_s->ifname, obj_desc))
+ goto err;
+
+ return 0;
+
+err:
+ free_dbus_object_desc(obj_desc);
+ return -1;
+}
+
+/**
+ * wpas_dbus_unregister_peer - Unregister a peer object with dbus
+ * @wpa_s: wpa_supplicant interface structure
+ * @dev_addr: p2p device addr
+ * Returns: 0 on success, -1 on failure
+ *
+ * Registers network representing object with dbus
+ */
+int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
+ const u8 *dev_addr)
+{
+ struct wpas_dbus_priv *ctrl_iface;
+ char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
+ int ret;
+
+ /* Do nothing if the control interface is not turned on */
+ if (wpa_s == NULL || wpa_s->global == NULL ||
+ wpa_s->dbus_new_path == NULL)
+ return 0;
+ ctrl_iface = wpa_s->global->dbus;
+ if (ctrl_iface == NULL)
+ return 0;
+
+ os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_P2P_PEERS_PART "/" COMPACT_MACSTR,
+ wpa_s->dbus_new_path, MAC2STR(dev_addr));
+
+ wpa_printf(MSG_INFO, "dbus: Unregister peer object '%s'",
+ peer_obj_path);
+ ret = wpa_dbus_unregister_object_per_iface(ctrl_iface, peer_obj_path);
+
+ return ret;
+}
+
+
+static const struct wpa_dbus_property_desc wpas_dbus_p2p_group_properties[] = {
+ { "Members", WPAS_DBUS_NEW_IFACE_P2P_GROUP, "ao",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_p2p_group_members,
NULL, R
},
-#ifdef CONFIG_WPS
- { "ProcessCredentials", WPAS_DBUS_NEW_IFACE_WPS, "b",
- (WPADBusPropertyAccessor) wpas_dbus_getter_process_credentials,
- (WPADBusPropertyAccessor) wpas_dbus_setter_process_credentials,
+ { "Properties",
+ WPAS_DBUS_NEW_IFACE_P2P_GROUP, "a{sv}",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_p2p_group_properties,
+ (WPADBusPropertyAccessor) wpas_dbus_setter_p2p_group_properties,
RW
},
-#endif /* CONFIG_WPS */
{ NULL, NULL, NULL, NULL, NULL, 0 }
};
-static const struct wpa_dbus_signal_desc wpas_dbus_interface_signals[] = {
- { "ScanDone", WPAS_DBUS_NEW_IFACE_INTERFACE,
- {
- { "success", "b", ARG_OUT },
- END_ARGS
- }
- },
- { "BSSAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
- {
- { "path", "o", ARG_OUT },
- { "properties", "a{sv}", ARG_OUT },
- END_ARGS
- }
- },
- { "BSSRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
+static const struct wpa_dbus_signal_desc wpas_dbus_p2p_group_signals[] = {
+ { "PeerJoined", WPAS_DBUS_NEW_IFACE_P2P_GROUP,
{
- { "path", "o", ARG_OUT },
- END_ARGS
- }
- },
- { "BlobAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
- {
- { "name", "s", ARG_OUT },
- END_ARGS
- }
- },
- { "BlobRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
- {
- { "name", "s", ARG_OUT },
- END_ARGS
- }
- },
- { "NetworkAdded", WPAS_DBUS_NEW_IFACE_INTERFACE,
- {
- { "path", "o", ARG_OUT },
- { "properties", "a{sv}", ARG_OUT },
- END_ARGS
- }
- },
- { "NetworkRemoved", WPAS_DBUS_NEW_IFACE_INTERFACE,
- {
- { "path", "o", ARG_OUT },
- END_ARGS
- }
- },
- { "NetworkSelected", WPAS_DBUS_NEW_IFACE_INTERFACE,
- {
- { "path", "o", ARG_OUT },
+ { "peer", "o", ARG_OUT },
END_ARGS
}
},
- { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_INTERFACE,
- {
- { "properties", "a{sv}", ARG_OUT },
- END_ARGS
- }
- },
-#ifdef CONFIG_WPS
- { "Event", WPAS_DBUS_NEW_IFACE_WPS,
- {
- { "name", "s", ARG_OUT },
- { "args", "a{sv}", ARG_OUT },
- END_ARGS
- }
- },
- { "Credentials", WPAS_DBUS_NEW_IFACE_WPS,
- {
- { "credentials", "a{sv}", ARG_OUT },
- END_ARGS
- }
- },
- { "PropertiesChanged", WPAS_DBUS_NEW_IFACE_WPS,
+ { "PeerDisconnected", WPAS_DBUS_NEW_IFACE_P2P_GROUP,
{
- { "properties", "a{sv}", ARG_OUT },
+ { "peer", "o", ARG_OUT },
END_ARGS
}
},
-#endif /* CONFIG_WPS */
{ NULL, NULL, { END_ARGS } }
};
+/**
+ * wpas_dbus_register_p2p_group - Register a p2p group object with dbus
+ * @wpa_s: wpa_supplicant interface structure
+ * @ssid: SSID struct
+ * Returns: 0 on success, -1 on failure
+ *
+ * Registers p2p group representing object with dbus
+ */
+void wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
+ struct wpa_ssid *ssid)
+{
+ struct wpas_dbus_priv *ctrl_iface;
+ struct wpa_dbus_object_desc *obj_desc;
+ char group_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
-int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
+ /* Do nothing if the control interface is not turned on */
+ if (wpa_s == NULL || wpa_s->global == NULL)
+ return;
+
+ ctrl_iface = wpa_s->global->dbus;
+ if (ctrl_iface == NULL)
+ return;
+
+ if (wpa_s->dbus_groupobj_path) {
+ wpa_printf(MSG_INFO, "%s: Group object '%s' already exists",
+ __func__, wpa_s->dbus_groupobj_path);
+ return;
+ }
+
+ if (wpas_dbus_get_group_obj_path(wpa_s, ssid, group_obj_path) < 0)
+ return;
+
+ wpa_s->dbus_groupobj_path = os_strdup(group_obj_path);
+ if (wpa_s->dbus_groupobj_path == NULL)
+ return;
+
+ wpa_printf(MSG_INFO, "dbus: Register group object '%s'",
+ group_obj_path);
+ obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
+ if (!obj_desc) {
+ wpa_printf(MSG_ERROR, "Not enough memory "
+ "to create object description");
+ goto err;
+ }
+
+ wpas_dbus_register(obj_desc, wpa_s, NULL, NULL,
+ wpas_dbus_p2p_group_properties,
+ wpas_dbus_p2p_group_signals);
+
+ if (wpa_dbus_register_object_per_iface(ctrl_iface, group_obj_path,
+ wpa_s->ifname, obj_desc))
+ goto err;
+
+ return;
+
+err:
+ if (wpa_s->dbus_groupobj_path) {
+ os_free(wpa_s->dbus_groupobj_path);
+ wpa_s->dbus_groupobj_path = NULL;
+ }
+
+ free_dbus_object_desc(obj_desc);
+}
+
+/**
+ * wpas_dbus_unregister_p2p_group - Unregister a p2p group object from dbus
+ * @wpa_s: wpa_supplicant interface structure
+ * @ssid: network name of the p2p group started
+ */
+void wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
+ const struct wpa_ssid *ssid)
{
+ struct wpas_dbus_priv *ctrl_iface;
+
+ /* Do nothing if the control interface is not turned on */
+ if (wpa_s == NULL || wpa_s->global == NULL)
+ return;
+
+ ctrl_iface = wpa_s->global->dbus;
+ if (ctrl_iface == NULL)
+ return;
+
+ if (!wpa_s->dbus_groupobj_path) {
+ wpa_printf(MSG_DEBUG,
+ "%s: Group object '%s' already unregistered",
+ __func__, wpa_s->dbus_groupobj_path);
+ return;
+ }
+
+ wpa_printf(MSG_DEBUG, "dbus: Unregister group object '%s'",
+ wpa_s->dbus_groupobj_path);
+
+ wpa_dbus_unregister_object_per_iface(ctrl_iface,
+ wpa_s->dbus_groupobj_path);
+
+ os_free(wpa_s->dbus_groupobj_path);
+ wpa_s->dbus_groupobj_path = NULL;
+}
+
+static const struct wpa_dbus_property_desc
+wpas_dbus_p2p_groupmember_properties[] = {
+ { "Properties", WPAS_DBUS_NEW_IFACE_P2P_GROUPMEMBER, "a{sv}",
+ (WPADBusPropertyAccessor) wpas_dbus_getter_p2p_group_properties,
+ NULL, R
+ },
+ { NULL, NULL, NULL, NULL, NULL, 0 }
+};
+/**
+ * wpas_dbus_register_p2p_groupmember - Register a p2p groupmember
+ * object with dbus
+ * @wpa_s: wpa_supplicant interface structure
+ * @p2p_if_addr: i/f addr of the device joining this group
+ *
+ * Registers p2p groupmember representing object with dbus
+ */
+void wpas_dbus_register_p2p_groupmember(struct wpa_supplicant *wpa_s,
+ const u8 *p2p_if_addr)
+{
+ struct wpas_dbus_priv *ctrl_iface;
struct wpa_dbus_object_desc *obj_desc = NULL;
- struct wpas_dbus_priv *ctrl_iface = wpa_s->global->dbus;
- int next;
+ struct groupmember_handler_args *arg;
+ char groupmember_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
/* Do nothing if the control interface is not turned on */
+ if (wpa_s == NULL || wpa_s->global == NULL)
+ return;
+
+ ctrl_iface = wpa_s->global->dbus;
if (ctrl_iface == NULL)
- return 0;
+ return;
- /* Create and set the interface's object path */
- wpa_s->dbus_new_path = os_zalloc(WPAS_DBUS_OBJECT_PATH_MAX);
- if (wpa_s->dbus_new_path == NULL)
- return -1;
- next = ctrl_iface->next_objid++;
- os_snprintf(wpa_s->dbus_new_path, WPAS_DBUS_OBJECT_PATH_MAX,
- WPAS_DBUS_NEW_PATH_INTERFACES "/%u",
- next);
+ if (!wpa_s->dbus_groupobj_path)
+ return;
+
+ os_snprintf(groupmember_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART "/" COMPACT_MACSTR,
+ wpa_s->dbus_groupobj_path, MAC2STR(p2p_if_addr));
obj_desc = os_zalloc(sizeof(struct wpa_dbus_object_desc));
if (!obj_desc) {
goto err;
}
- wpas_dbus_register(obj_desc, wpa_s, NULL, wpas_dbus_interface_methods,
- wpas_dbus_interface_properties,
- wpas_dbus_interface_signals);
+ /* allocate memory for handlers arguments */
+ arg = os_zalloc(sizeof(struct groupmember_handler_args));
+ if (!arg) {
+ wpa_printf(MSG_ERROR, "Not enough memory "
+ "to create arguments for method");
+ goto err;
+ }
- wpa_printf(MSG_DEBUG, "dbus: Register interface object '%s'",
- wpa_s->dbus_new_path);
- if (wpa_dbus_register_object_per_iface(ctrl_iface,
- wpa_s->dbus_new_path,
+ arg->wpa_s = wpa_s;
+ os_memcpy(arg->member_addr, p2p_if_addr, ETH_ALEN);
+
+ wpas_dbus_register(obj_desc, arg, wpa_dbus_free, NULL,
+ wpas_dbus_p2p_groupmember_properties, NULL);
+
+ if (wpa_dbus_register_object_per_iface(ctrl_iface, groupmember_obj_path,
wpa_s->ifname, obj_desc))
goto err;
- wpas_dbus_signal_interface_added(wpa_s);
-
- return 0;
+ wpa_printf(MSG_INFO,
+ "dbus: Registered group member object '%s' successfully",
+ groupmember_obj_path);
+ return;
err:
- os_free(wpa_s->dbus_new_path);
- wpa_s->dbus_new_path = NULL;
free_dbus_object_desc(obj_desc);
- return -1;
}
-
-int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
+/**
+ * wpas_dbus_unregister_p2p_groupmember - Unregister a p2p groupmember
+ * object with dbus
+ * @wpa_s: wpa_supplicant interface structure
+ * @p2p_if_addr: i/f addr of the device joining this group
+ *
+ * Unregisters p2p groupmember representing object with dbus
+ */
+void wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant *wpa_s,
+ const u8 *p2p_if_addr)
{
struct wpas_dbus_priv *ctrl_iface;
+ char groupmember_obj_path[WPAS_DBUS_OBJECT_PATH_MAX];
/* Do nothing if the control interface is not turned on */
if (wpa_s == NULL || wpa_s->global == NULL)
- return 0;
+ return;
+
ctrl_iface = wpa_s->global->dbus;
if (ctrl_iface == NULL)
- return 0;
-
- wpa_printf(MSG_DEBUG, "dbus: Unregister interface object '%s'",
- wpa_s->dbus_new_path);
- if (wpa_dbus_unregister_object_per_iface(ctrl_iface,
- wpa_s->dbus_new_path))
- return -1;
+ return;
- wpas_dbus_signal_interface_removed(wpa_s);
+ if (!wpa_s->dbus_groupobj_path)
+ return;
- os_free(wpa_s->dbus_new_path);
- wpa_s->dbus_new_path = NULL;
+ os_snprintf(groupmember_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
+ "%s/" WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART "/" COMPACT_MACSTR,
+ wpa_s->dbus_groupobj_path, MAC2STR(p2p_if_addr));
- return 0;
+ wpa_dbus_unregister_object_per_iface(ctrl_iface, groupmember_obj_path);
}
+#endif /* CONFIG_P2P */