summaryrefslogtreecommitdiffstats
path: root/hcid/dbus.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2005-10-23 21:27:41 +0000
committerMarcel Holtmann <marcel@holtmann.org>2005-10-23 21:27:41 +0000
commit55b5343679121898bbc999c38a670c444f602e17 (patch)
tree6cb7075583a53d9b65f1e90b40678708d6d05c9e /hcid/dbus.c
parent6ebb0299dc72b9b6141be5f2712b1319eb0ac1c1 (diff)
Add support for inquiry cancel functionality
Diffstat (limited to 'hcid/dbus.c')
-rw-r--r--hcid/dbus.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/hcid/dbus.c b/hcid/dbus.c
index 8f0217ec..ce6f4e70 100644
--- a/hcid/dbus.c
+++ b/hcid/dbus.c
@@ -285,6 +285,7 @@ static DBusHandlerResult hci_signal_filter (DBusConnection *conn, DBusMessage *m
static DBusMessage* handle_periodic_inq_req(DBusMessage *msg, void *data);
static DBusMessage* handle_cancel_periodic_inq_req(DBusMessage *msg, void *data);
static DBusMessage* handle_inq_req(DBusMessage *msg, void *data);
+static DBusMessage* handle_cancel_inq_req(DBusMessage *msg, void *data);
static DBusMessage* handle_role_switch_req(DBusMessage *msg, void *data);
static DBusMessage* handle_remote_name_req(DBusMessage *msg, void *data);
static DBusMessage* handle_display_conn_req(DBusMessage *msg, void *data);
@@ -295,6 +296,7 @@ static const struct service_data hci_services[] = {
{ HCI_CANCEL_PERIODIC_INQ, handle_cancel_periodic_inq_req, HCI_CANCEL_PERIODIC_INQ_SIGNATURE },
{ HCI_ROLE_SWITCH, handle_role_switch_req, HCI_ROLE_SWITCH_SIGNATURE },
{ HCI_INQ, handle_inq_req, HCI_INQ_SIGNATURE },
+ { HCI_CANCEL_INQ, handle_cancel_inq_req, HCI_CANCEL_INQ_SIGNATURE },
{ HCI_REMOTE_NAME, handle_remote_name_req, HCI_REMOTE_NAME_SIGNATURE },
{ HCI_CONNECTIONS, handle_display_conn_req, HCI_CONNECTIONS_SIGNATURE },
{ HCI_AUTHENTICATE, handle_auth_req, HCI_AUTHENTICATE_SIGNATURE },
@@ -1383,6 +1385,48 @@ failed:
return reply;
}
+static DBusMessage* handle_cancel_inq_req(DBusMessage *msg, void *data)
+{
+ DBusMessage *reply = NULL;
+ struct hci_request rq;
+ struct hci_dbus_data *dbus_data = data;
+ int dev_id = -1, dd = -1;
+
+ if (dbus_data->id == DEFAULT_DEVICE_PATH_ID) {
+ if ((dev_id = hci_get_route(NULL)) < 0) {
+ syslog(LOG_ERR, "Bluetooth device is not available");
+ reply = bluez_new_failure_msg(msg, BLUEZ_ESYSTEM_ENODEV);
+ goto failed;
+ }
+ } else
+ dev_id = dbus_data->id;
+
+ dd = hci_open_dev(dev_id);
+ if (dd < 0) {
+ syslog(LOG_ERR, "Unable to open device %d: %s", dev_id, strerror(errno));
+ reply = bluez_new_failure_msg(msg, BLUEZ_ESYSTEM_OFFSET + errno);
+ goto failed;
+ }
+
+ memset(&rq, 0, sizeof(rq));
+ rq.ogf = OGF_LINK_CTL;
+ rq.ocf = OCF_INQUIRY_CANCEL;
+
+ if (hci_send_req(dd, &rq, 100) < 0) {
+ syslog(LOG_ERR, "Unable to cancel inquiry: %s", strerror(errno));
+ reply = bluez_new_failure_msg(msg, BLUEZ_ESYSTEM_OFFSET + errno);
+ goto failed;
+ }
+
+ reply = dbus_message_new_method_return(msg);
+
+failed:
+ if (dd >= 0)
+ hci_close_dev(dd);
+
+ return reply;
+}
+
static DBusMessage* handle_role_switch_req(DBusMessage *msg, void *data)
{
DBusMessageIter iter;