summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hcid/dbus-adapter.c475
-rw-r--r--hcid/dbus-test.c5
-rw-r--r--hcid/dbus.c505
-rw-r--r--hcid/dbus.h28
4 files changed, 602 insertions, 411 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c
index fc00a261..be80debb 100644
--- a/hcid/dbus-adapter.c
+++ b/hcid/dbus-adapter.c
@@ -200,7 +200,8 @@ int pending_remote_name_cancel(struct adapter *adapter)
return err;
}
-static struct bonding_request_info *bonding_request_new(bdaddr_t *peer, DBusConnection *conn,
+static struct bonding_request_info *bonding_request_new(bdaddr_t *peer,
+ DBusConnection *conn,
DBusMessage *msg)
{
struct bonding_request_info *bonding;
@@ -220,7 +221,8 @@ static struct bonding_request_info *bonding_request_new(bdaddr_t *peer, DBusConn
return bonding;
}
-static DBusHandlerResult handle_dev_get_address_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_address(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
const char *paddr = adapter->address;
@@ -239,7 +241,8 @@ static DBusHandlerResult handle_dev_get_address_req(DBusConnection *conn, DBusMe
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_version_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_version(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -263,7 +266,8 @@ static DBusHandlerResult handle_dev_get_version_req(DBusConnection *conn, DBusMe
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_revision_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_revision(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -287,7 +291,8 @@ static DBusHandlerResult handle_dev_get_revision_req(DBusConnection *conn, DBusM
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_manufacturer_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_manufacturer(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -311,7 +316,8 @@ static DBusHandlerResult handle_dev_get_manufacturer_req(DBusConnection *conn, D
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_company_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_company(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -335,7 +341,8 @@ static DBusHandlerResult handle_dev_get_company_req(DBusConnection *conn, DBusMe
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_mode_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_mode(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
const struct adapter *adapter = data;
DBusMessage *reply = NULL;
@@ -372,7 +379,8 @@ static DBusHandlerResult handle_dev_get_mode_req(DBusConnection *conn, DBusMessa
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_set_mode_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_set_mode(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
const struct adapter *adapter = data;
DBusMessage *reply;
@@ -423,7 +431,7 @@ static DBusHandlerResult handle_dev_set_mode_req(DBusConnection *conn, DBusMessa
if (errno != EALREADY) {
int err = errno;
error("Can't init device hci%d: %s (%d)\n",
- adapter->dev_id, strerror(errno), errno);
+ adapter->dev_id, strerror(errno), errno);
hci_close_dev(dd);
return error_failed(conn, msg, err);
@@ -447,13 +455,14 @@ static DBusHandlerResult handle_dev_set_mode_req(DBusConnection *conn, DBusMessa
if (hci_send_req(dd, &rq, 1000) < 0) {
int err = errno;
error("Sending write scan enable command failed: %s (%d)",
- strerror(errno), errno);
+ strerror(errno), errno);
hci_close_dev(dd);
return error_failed(conn, msg, err);
}
if (status) {
- error("Setting scan enable failed with status 0x%02x", status);
+ error("Setting scan enable failed with status 0x%02x",
+ status);
hci_close_dev(dd);
return error_failed(conn, msg, bt_error(status));
}
@@ -469,7 +478,9 @@ done:
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_discoverable_to_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_discoverable_to(DBusConnection *conn,
+ DBusMessage *msg,
+ void *data)
{
const struct adapter *adapter = data;
DBusMessage *reply;
@@ -481,13 +492,15 @@ static DBusHandlerResult handle_dev_get_discoverable_to_req(DBusConnection *conn
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
- dbus_message_append_args(reply, DBUS_TYPE_UINT32, &adapter->discoverable_timeout,
+ dbus_message_append_args(reply, DBUS_TYPE_UINT32, &adapter->discov_timeout,
DBUS_TYPE_INVALID);
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_set_discoverable_to_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_set_discoverable_to(DBusConnection *conn,
+ DBusMessage *msg,
+ void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -519,9 +532,11 @@ static DBusHandlerResult handle_dev_set_discoverable_to_req(DBusConnection *conn
}
if ((timeout != 0) && (adapter->mode & SCAN_INQUIRY))
- adapter->timeout_id = g_timeout_add(timeout * 1000, discoverable_timeout_handler, adapter);
+ adapter->timeout_id = g_timeout_add(timeout * 1000,
+ discov_timeout_handler,
+ adapter);
- adapter->discoverable_timeout = timeout;
+ adapter->discov_timeout = timeout;
str2ba(adapter->address, &bdaddr);
write_discoverable_timeout(&bdaddr, timeout);
@@ -529,7 +544,8 @@ static DBusHandlerResult handle_dev_set_discoverable_to_req(DBusConnection *conn
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_is_connectable_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_is_connectable(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
const struct adapter *adapter = data;
DBusMessage *reply;
@@ -552,7 +568,8 @@ static DBusHandlerResult handle_dev_is_connectable_req(DBusConnection *conn, DBu
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_is_discoverable_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_is_discoverable(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
const struct adapter *adapter = data;
DBusMessage *reply;
@@ -575,7 +592,8 @@ static DBusHandlerResult handle_dev_is_discoverable_req(DBusConnection *conn, DB
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_is_connected_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_is_connected(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
DBusMessage *reply;
DBusError err;
@@ -617,7 +635,8 @@ static DBusHandlerResult handle_dev_is_connected_req(DBusConnection *conn, DBusM
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_list_connections_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_list_connections(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
DBusMessage *reply;
DBusMessageIter iter;
@@ -643,7 +662,8 @@ static DBusHandlerResult handle_dev_list_connections_req(DBusConnection *conn, D
baswap(&tmp, &dev->bdaddr); peer_addr = batostr(&tmp);
- dbus_message_iter_append_basic(&array_iter, DBUS_TYPE_STRING, &peer_addr);
+ dbus_message_iter_append_basic(&array_iter, DBUS_TYPE_STRING,
+ &peer_addr);
bt_free(peer_addr);
l = l->next;
@@ -654,7 +674,8 @@ static DBusHandlerResult handle_dev_list_connections_req(DBusConnection *conn, D
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_major_class_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_major_class(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
const struct adapter *adapter = data;
DBusMessage *reply;
@@ -693,7 +714,8 @@ static DBusHandlerResult handle_dev_get_major_class_req(DBusConnection *conn, DB
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_list_minor_classes_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_list_minor_classes(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
const struct adapter *adapter = data;
DBusMessage *reply = NULL;
@@ -747,14 +769,16 @@ static DBusHandlerResult handle_dev_list_minor_classes_req(DBusConnection *conn,
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
DBUS_TYPE_STRING_AS_STRING, &array_iter);
for (i = 0; i < size; i++)
- dbus_message_iter_append_basic(&array_iter, DBUS_TYPE_STRING, &minor_ptr[i]);
+ dbus_message_iter_append_basic(&array_iter, DBUS_TYPE_STRING,
+ &minor_ptr[i]);
dbus_message_iter_close_container(&iter, &array_iter);
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_minor_class_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_minor_class(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -806,7 +830,8 @@ failed:
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_set_minor_class_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_set_minor_class(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply, *signal;
@@ -891,7 +916,9 @@ static DBusHandlerResult handle_dev_set_minor_class_req(DBusConnection *conn, DB
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_service_classes_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_service_classes(DBusConnection *conn,
+ DBusMessage *msg,
+ void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -941,7 +968,8 @@ static DBusHandlerResult handle_dev_get_service_classes_req(DBusConnection *conn
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_name_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_name(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -974,7 +1002,8 @@ static DBusHandlerResult handle_dev_get_name_req(DBusConnection *conn, DBusMessa
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_set_name_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_set_name(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -1017,17 +1046,21 @@ static DBusHandlerResult handle_dev_set_name_req(DBusConnection *conn, DBusMessa
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_remote_svc_rec(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_remote_svc(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
return get_remote_svc_rec(conn, msg, data);
}
-static DBusHandlerResult handle_dev_get_remote_svc_handles(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_remote_svc_handles(DBusConnection *conn,
+ DBusMessage *msg,
+ void *data)
{
return get_remote_svc_handles(conn, msg, data);
}
-static DBusHandlerResult handle_dev_get_remote_version_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_remote_version(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -1056,7 +1089,8 @@ static DBusHandlerResult handle_dev_get_remote_version_req(DBusConnection *conn,
if (check_address(addr_ptr) < 0)
return error_invalid_arguments(conn, msg);
- create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "manufacturers");
+ create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
+ "manufacturers");
str = textfile_caseget(filename, addr_ptr);
if (!str)
@@ -1075,7 +1109,8 @@ static DBusHandlerResult handle_dev_get_remote_version_req(DBusConnection *conn,
/* default value */
snprintf(info, 64, "Bluetooth %s", str_ver);
- create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "features");
+ create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
+ "features");
str = textfile_caseget(filename, addr_ptr);
if (!str)
@@ -1103,7 +1138,8 @@ failed:
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_remote_revision_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_remote_revision(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -1134,7 +1170,8 @@ static DBusHandlerResult handle_dev_get_remote_revision_req(DBusConnection *conn
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
- create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "manufacturers");
+ create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
+ "manufacturers");
str = textfile_caseget(filename, addr_ptr);
if (!str)
@@ -1151,7 +1188,9 @@ static DBusHandlerResult handle_dev_get_remote_revision_req(DBusConnection *conn
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_remote_manufacturer_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_remote_manufacturer(DBusConnection *conn,
+ DBusMessage *msg,
+ void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -1177,7 +1216,8 @@ static DBusHandlerResult handle_dev_get_remote_manufacturer_req(DBusConnection *
if (check_address(addr_ptr) < 0)
return error_invalid_arguments(conn, msg);
- create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "manufacturers");
+ create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
+ "manufacturers");
str = textfile_caseget(filename, addr_ptr);
if (!str)
@@ -1198,7 +1238,8 @@ static DBusHandlerResult handle_dev_get_remote_manufacturer_req(DBusConnection *
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_remote_company_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_remote_company(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
DBusMessage *reply;
DBusError err;
@@ -1237,7 +1278,8 @@ static DBusHandlerResult handle_dev_get_remote_company_req(DBusConnection *conn,
return send_message_and_unref(conn, reply);
}
-static int get_remote_class(DBusConnection *conn, DBusMessage *msg, void *data, uint32_t *class)
+static int get_remote_class(DBusConnection *conn, DBusMessage *msg, void *data,
+ uint32_t *class)
{
struct adapter *adapter = data;
char *addr_peer;
@@ -1274,7 +1316,9 @@ static int get_remote_class(DBusConnection *conn, DBusMessage *msg, void *data,
return 0;
}
-static DBusHandlerResult handle_dev_get_remote_major_class_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_remote_major_class(DBusConnection *conn,
+ DBusMessage *msg,
+ void *data)
{
DBusMessage *reply;
const char *major_class;
@@ -1295,7 +1339,9 @@ static DBusHandlerResult handle_dev_get_remote_major_class_req(DBusConnection *c
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_remote_minor_class_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_remote_minor_class(DBusConnection *conn,
+ DBusMessage *msg,
+ void *data)
{
DBusMessage *reply;
const char *minor_class;
@@ -1321,7 +1367,9 @@ static void append_class_string(const char *class, DBusMessageIter *iter)
dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &class);
}
-static DBusHandlerResult handle_dev_get_remote_service_cls_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_remote_service_cls(DBusConnection *conn,
+ DBusMessage *msg,
+ void *data)
{
DBusMessage *reply;
DBusMessageIter iter, array_iter;
@@ -1341,7 +1389,8 @@ static DBusHandlerResult handle_dev_get_remote_service_cls_req(DBusConnection *c
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
DBUS_TYPE_STRING_AS_STRING, &array_iter);
- slist_foreach(service_classes, (slist_func_t) append_class_string, &array_iter);
+ slist_foreach(service_classes, (slist_func_t) append_class_string,
+ &array_iter);
dbus_message_iter_close_container(&iter, &array_iter);
@@ -1350,7 +1399,8 @@ static DBusHandlerResult handle_dev_get_remote_service_cls_req(DBusConnection *c
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_remote_class_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_remote_class(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
DBusMessage *reply;
uint32_t class;
@@ -1368,7 +1418,8 @@ static DBusHandlerResult handle_dev_get_remote_class_req(DBusConnection *conn, D
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_remote_name_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_remote_name(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
char filename[PATH_MAX + 1];
struct adapter *adapter = data;
@@ -1423,13 +1474,14 @@ static DBusHandlerResult handle_dev_get_remote_name_req(DBusConnection *conn, DB
* if there is a discover process running, just queue the request.
* Otherwise, send the HCI cmd to get the remote name
*/
- if (!(adapter->disc_active || adapter->pdisc_active))
+ if (!(adapter->discov_active || adapter->pdiscov_active))
disc_device_req_name(adapter);
return error_request_deferred(conn, msg);
}
-static DBusHandlerResult handle_dev_get_remote_alias_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_remote_alias(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -1468,7 +1520,8 @@ static DBusHandlerResult handle_dev_get_remote_alias_req(DBusConnection *conn, D
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_set_remote_alias_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_set_remote_alias(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply, *signal;
@@ -1513,7 +1566,8 @@ static DBusHandlerResult handle_dev_set_remote_alias_req(DBusConnection *conn, D
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_clear_remote_alias_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_clear_remote_alias(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply, *signal;
@@ -1553,16 +1607,18 @@ static DBusHandlerResult handle_dev_clear_remote_alias_req(DBusConnection *conn,
return DBUS_HANDLER_RESULT_NEED_MEMORY;
if (had_alias) {
- signal = dev_signal_factory(adapter->dev_id, "RemoteAliasCleared",
- DBUS_TYPE_STRING, &addr_ptr,
- DBUS_TYPE_INVALID);
+ signal = dev_signal_factory(adapter->dev_id,
+ "RemoteAliasCleared",
+ DBUS_TYPE_STRING, &addr_ptr,
+ DBUS_TYPE_INVALID);
send_message_and_unref(conn, signal);
}
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_last_seen_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_last_seen(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -1584,7 +1640,8 @@ static DBusHandlerResult handle_dev_last_seen_req(DBusConnection *conn, DBusMess
if (check_address(addr_ptr) < 0)
return error_invalid_arguments(conn, msg);
- create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "lastseen");
+ create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
+ "lastseen");
str = textfile_caseget(filename, addr_ptr);
if (!str)
@@ -1604,7 +1661,8 @@ static DBusHandlerResult handle_dev_last_seen_req(DBusConnection *conn, DBusMess
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_last_used_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_last_used(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -1626,7 +1684,8 @@ static DBusHandlerResult handle_dev_last_used_req(DBusConnection *conn, DBusMess
if (check_address(addr_ptr) < 0)
return error_invalid_arguments(conn, msg);
- create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "lastused");
+ create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
+ "lastused");
str = textfile_caseget(filename, addr_ptr);
if (!str)
@@ -1646,7 +1705,8 @@ static DBusHandlerResult handle_dev_last_used_req(DBusConnection *conn, DBusMess
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_disconnect_remote_device_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_dc_remote_device(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
DBusMessage *reply;
DBusError err;
@@ -1689,7 +1749,8 @@ static DBusHandlerResult handle_dev_disconnect_remote_device_req(DBusConnection
return error_no_such_adapter(conn, msg);
/* Send the HCI disconnect command */
- if (hci_disconnect(dd, dev->handle, HCI_OE_USER_ENDED_CONNECTION, 500) < 0) {
+ if (hci_disconnect(dd, dev->handle, HCI_OE_USER_ENDED_CONNECTION,
+ 500) < 0) {
int err = errno;
error("Disconnect failed");
hci_close_dev(dd);
@@ -1738,7 +1799,8 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,
}
if (cond & G_IO_NVAL) {
- error_authentication_canceled(adapter->bonding->conn, adapter->bonding->rq);
+ error_authentication_canceled(adapter->bonding->conn,
+ adapter->bonding->rq);
goto cleanup;
}
@@ -1746,7 +1808,9 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,
debug("Hangup or error on bonding IO channel");
if (!adapter->bonding->auth_active)
- error_connection_attempt_failed(adapter->bonding->conn, adapter->bonding->rq, ENETDOWN);
+ error_connection_attempt_failed(adapter->bonding->conn,
+ adapter->bonding->rq,
+ ENETDOWN);
else
reply_authentication_failure(adapter->bonding);
@@ -1757,8 +1821,10 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,
len = sizeof(ret);
if (getsockopt(sk, SOL_SOCKET, SO_ERROR, &ret, &len) < 0) {
- error("Can't get socket error: %s (%d)", strerror(errno), errno);
- error_failed(adapter->bonding->conn, adapter->bonding->rq, errno);
+ error("Can't get socket error: %s (%d)",
+ strerror(errno), errno);
+ error_failed(adapter->bonding->conn, adapter->bonding->rq,
+ errno);
goto failed;
}
@@ -1766,20 +1832,25 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,
if (adapter->bonding->auth_active)
reply_authentication_failure(adapter->bonding);
else
- error_connection_attempt_failed(adapter->bonding->conn, adapter->bonding->rq, ret);
+ error_connection_attempt_failed(adapter->bonding->conn,
+ adapter->bonding->rq,
+ ret);
goto failed;
}
len = sizeof(cinfo);
if (getsockopt(sk, SOL_L2CAP, L2CAP_CONNINFO, &cinfo, &len) < 0) {
- error("Can't get connection info: %s (%d)", strerror(errno), errno);
- error_failed(adapter->bonding->conn, adapter->bonding->rq, errno);
+ error("Can't get connection info: %s (%d)",
+ strerror(errno), errno);
+ error_failed(adapter->bonding->conn, adapter->bonding->rq,
+ errno);
goto failed;
}
dd = hci_open_dev(adapter->dev_id);
if (dd < 0) {
- error_no_such_adapter(adapter->bonding->conn, adapter->bonding->rq);
+ error_no_such_adapter(adapter->bonding->conn,
+ adapter->bonding->rq);
goto failed;
}
@@ -1800,7 +1871,8 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,
if (hci_send_req(dd, &rq, 500) < 0) {
error("Unable to send HCI request: %s (%d)",
strerror(errno), errno);
- error_failed(adapter->bonding->conn, adapter->bonding->rq, errno);
+ error_failed(adapter->bonding->conn, adapter->bonding->rq,
+ errno);
hci_close_dev(dd);
goto failed;
}
@@ -1808,7 +1880,8 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,
if (rp.status) {
error("HCI_Authentication_Requested failed with status 0x%02x",
rp.status);
- error_failed(adapter->bonding->conn, adapter->bonding->rq, bt_error(rp.status));
+ error_failed(adapter->bonding->conn, adapter->bonding->rq,
+ bt_error(rp.status));
hci_close_dev(dd);
goto failed;
}
@@ -1817,7 +1890,8 @@ static gboolean create_bonding_conn_complete(GIOChannel *io, GIOCondition cond,
adapter->bonding->auth_active = 1;
- adapter->bonding->io_id = g_io_add_watch(io, G_IO_NVAL | G_IO_HUP | G_IO_ERR,
+ adapter->bonding->io_id = g_io_add_watch(io,
+ G_IO_NVAL | G_IO_HUP | G_IO_ERR,
(GIOFunc) create_bonding_conn_complete,
adapter);
@@ -1827,8 +1901,9 @@ failed:
g_io_channel_close(io);
cleanup:
- name_listener_remove(adapter->bonding->conn, dbus_message_get_sender(adapter->bonding->rq),
- (name_cb_t) create_bond_req_exit, adapter);
+ name_listener_remove(adapter->bonding->conn,
+ dbus_message_get_sender(adapter->bonding->rq),
+ (name_cb_t) create_bond_req_exit, adapter);
bonding_request_free(adapter->bonding);
adapter->bonding = NULL;
@@ -1836,7 +1911,8 @@ cleanup:
return FALSE;
}
-static DBusHandlerResult handle_dev_create_bonding_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_create_bonding(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
char filename[PATH_MAX + 1];
DBusError err;
@@ -1865,7 +1941,7 @@ static DBusHandlerResult handle_dev_create_bonding_req(DBusConnection *conn, DBu
str2ba(peer_addr, &peer_bdaddr);
/* check if there is a pending discover: requested by D-Bus/non clients */
- if (adapter->disc_active || (adapter->pdisc_active && !adapter->pinq_idle))
+ if (adapter->discov_active || (adapter->pdiscov_active && !adapter->pinq_idle))
return error_discover_in_progress(conn, msg);
pending_remote_name_cancel(adapter);
@@ -1877,7 +1953,8 @@ static DBusHandlerResult handle_dev_create_bonding_req(DBusConnection *conn, DBu
return error_bonding_in_progress(conn, msg);
/* check if a link key already exists */
- create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "linkkeys");
+ create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
+ "linkkeys");
str = textfile_caseget(filename, peer_addr);
if (str) {
@@ -1897,9 +1974,9 @@ static DBusHandlerResult handle_dev_create_bonding_req(DBusConnection *conn, DBu
adapter->bonding->io = g_io_channel_unix_new(sk);
adapter->bonding->io_id = g_io_add_watch(adapter->bonding->io,
- G_IO_OUT | G_IO_NVAL | G_IO_HUP | G_IO_ERR,
- (GIOFunc) create_bonding_conn_complete,
- adapter);
+ G_IO_OUT | G_IO_NVAL | G_IO_HUP | G_IO_ERR,
+ (GIOFunc) create_bonding_conn_complete,
+ adapter);
name_listener_add(conn, dbus_message_get_sender(msg),
(name_cb_t) create_bond_req_exit, adapter);
@@ -1907,7 +1984,8 @@ static DBusHandlerResult handle_dev_create_bonding_req(DBusConnection *conn, DBu
return DBUS_HANDLER_RESULT_HANDLED;
}
-static DBusHandlerResult handle_dev_cancel_bonding_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_cancel_bonding(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -1938,7 +2016,8 @@ static DBusHandlerResult handle_dev_cancel_bonding_req(DBusConnection *conn, DBu
if (!adapter->bonding || bacmp(&adapter->bonding->bdaddr, &peer_bdaddr))
return error_bonding_not_in_progress(conn, msg);
- if (strcmp(dbus_message_get_sender(adapter->bonding->rq), dbus_message_get_sender(msg)))
+ if (strcmp(dbus_message_get_sender(adapter->bonding->rq),
+ dbus_message_get_sender(msg)))
return error_not_authorized(conn, msg);
adapter->bonding->cancel = 1;
@@ -1949,9 +2028,9 @@ static DBusHandlerResult handle_dev_cancel_bonding_req(DBusConnection *conn, DBu
if (pin_req->replied) {
/*
- * If disconnect can't be applied and the PIN Code Request
- * was already replied it doesn't make sense cancel the
- * remote passkey: return not authorized.
+ * If disconnect can't be applied and the PIN code
+ * request was already replied it doesn't make sense
+ * cancel the remote passkey: return not authorized.
*/
g_io_channel_close(adapter->bonding->io);
return error_not_authorized(conn, msg);
@@ -1963,7 +2042,8 @@ static DBusHandlerResult handle_dev_cancel_bonding_req(DBusConnection *conn, DBu
return DBUS_HANDLER_RESULT_HANDLED;
}
- hci_send_cmd(dd, OGF_LINK_CTL, OCF_PIN_CODE_NEG_REPLY, 6, &peer_bdaddr);
+ hci_send_cmd(dd, OGF_LINK_CTL, OCF_PIN_CODE_NEG_REPLY,
+ 6, &peer_bdaddr);
hci_close_dev(dd);
}
@@ -1980,7 +2060,8 @@ static DBusHandlerResult handle_dev_cancel_bonding_req(DBusConnection *conn, DBu
return DBUS_HANDLER_RESULT_HANDLED;
}
-static DBusHandlerResult handle_dev_remove_bonding_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_remove_bonding(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
struct slist *l;
@@ -2013,7 +2094,8 @@ static DBusHandlerResult handle_dev_remove_bonding_req(DBusConnection *conn, DBu
if (dd < 0)
return error_no_such_adapter(conn, msg);
- create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "linkkeys");
+ create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
+ "linkkeys");
/* textfile_del doesn't return an error when the key is not found */
str = textfile_caseget(filename, addr_ptr);
@@ -2037,11 +2119,13 @@ static DBusHandlerResult handle_dev_remove_bonding_req(DBusConnection *conn, DBu
hci_delete_stored_link_key(dd, &bdaddr, 0, 1000);
/* find the connection */
- l = slist_find(adapter->active_conn, &bdaddr, active_conn_find_by_bdaddr);
+ l = slist_find(adapter->active_conn, &bdaddr,
+ active_conn_find_by_bdaddr);
if (l) {
struct active_conn_info *con = l->data;
/* Send the HCI disconnect command */
- if (hci_disconnect(dd, htobs(con->handle), HCI_OE_USER_ENDED_CONNECTION, 500) < 0) {
+ if (hci_disconnect(dd, htobs(con->handle),
+ HCI_OE_USER_ENDED_CONNECTION, 500) < 0) {
int err = errno;
error("Disconnect failed");
hci_close_dev(dd);
@@ -2062,7 +2146,8 @@ static DBusHandlerResult handle_dev_remove_bonding_req(DBusConnection *conn, DBu
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_has_bonding_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_has_bonding(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -2085,7 +2170,8 @@ static DBusHandlerResult handle_dev_has_bonding_req(DBusConnection *conn, DBusMe
if (check_address(addr_ptr) < 0)
return error_invalid_arguments(conn, msg);
- create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "linkkeys");
+ create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
+ "linkkeys");
str = textfile_caseget(filename, addr_ptr);
if (str) {
@@ -2108,7 +2194,8 @@ static void list_bondings_do_append(char *key, char *value, void *data)
dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &key);
}
-static DBusHandlerResult handle_dev_list_bondings_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_list_bondings(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
DBusMessageIter iter;
@@ -2119,7 +2206,8 @@ static DBusHandlerResult handle_dev_list_bondings_req(DBusConnection *conn, DBus
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
return error_invalid_arguments(conn, msg);
- create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "linkkeys");
+ create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
+ "linkkeys");
reply = dbus_message_new_method_return(msg);
@@ -2135,7 +2223,9 @@ static DBusHandlerResult handle_dev_list_bondings_req(DBusConnection *conn, DBus
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_pin_code_length_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_pin_code_length(DBusConnection *conn,
+ DBusMessage *msg,
+ void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -2177,7 +2267,9 @@ static DBusHandlerResult handle_dev_get_pin_code_length_req(DBusConnection *conn
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_encryption_key_size_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_encryption_key_size(DBusConnection *conn,
+ DBusMessage *msg,
+ void *data)
{
struct adapter *adapter = data;
DBusMessage *reply;
@@ -2217,7 +2309,8 @@ static DBusHandlerResult handle_dev_get_encryption_key_size_req(DBusConnection *
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_start_periodic_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_start_periodic(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
DBusMessage *reply;
periodic_inquiry_cp cp;
@@ -2233,7 +2326,7 @@ static DBusHandlerResult handle_dev_start_periodic_req(DBusConnection *conn, DBu
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
return error_invalid_arguments(conn, msg);
- if (adapter->disc_active || adapter->pdisc_active)
+ if (adapter->discov_active || adapter->pdiscov_active)
return error_discover_in_progress(conn, msg);
pending_remote_name_cancel(adapter);
@@ -2261,36 +2354,40 @@ static DBusHandlerResult handle_dev_start_periodic_req(DBusConnection *conn, DBu
if (hci_send_req(dd, &rq, 1000) < 0) {
int err = errno;
error("Unable to start periodic inquiry: %s (%d)",
- strerror(errno), errno);
+ strerror(errno), errno);
hci_close_dev(dd);
return error_failed(conn, msg, err);
}
if (status) {
- error("HCI_Periodic_Inquiry_Mode command failed with status 0x%02x", status);
+ error("HCI_Periodic_Inquiry_Mode failed with status 0x%02x",
+ status);
hci_close_dev(dd);
return error_failed(conn, msg, bt_error(status));
}
- adapter->pdiscovery_requestor = strdup(dbus_message_get_sender(msg));
+ adapter->pdiscov_requestor = strdup(dbus_message_get_sender(msg));
if (adapter->pdiscov_resolve_names)
- adapter->discover_type = PERIODIC_INQUIRY | RESOLVE_NAME;
+ adapter->discov_type = PERIODIC_INQUIRY | RESOLVE_NAME;
else
- adapter->discover_type = PERIODIC_INQUIRY;
+ adapter->discov_type = PERIODIC_INQUIRY;
reply = dbus_message_new_method_return(msg);
hci_close_dev(dd);
- /* track the request owner to cancel it automatically if the owner exits */
+ /* track the request owner to cancel it automatically if the owner
+ * exits */
name_listener_add(conn, dbus_message_get_sender(msg),
- (name_cb_t) periodic_discover_req_exit, adapter);
+ (name_cb_t) periodic_discover_req_exit,
+ adapter);
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_stop_periodic_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_stop_periodic(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
DBusMessage *reply;
struct adapter *adapter = data;
@@ -2302,7 +2399,7 @@ static DBusHandlerResult handle_dev_stop_periodic_req(DBusConnection *conn, DBus
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
return error_invalid_arguments(conn, msg);
- if (!adapter->pdisc_active)
+ if (!adapter->pdiscov_active)
return error_not_authorized(conn, msg);
/*
@@ -2321,11 +2418,12 @@ static DBusHandlerResult handle_dev_stop_periodic_req(DBusConnection *conn, DBus
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_is_periodic_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_is_periodic(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
DBusMessage *reply;
struct adapter *adapter = data;
- dbus_bool_t active = adapter->pdisc_active;
+ dbus_bool_t active = adapter->pdiscov_active;
reply = dbus_message_new_method_return(msg);
if (!reply)
@@ -2337,8 +2435,9 @@ static DBusHandlerResult handle_dev_is_periodic_req(DBusConnection *conn, DBusMe
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_set_pdiscov_name_resolve(DBusConnection *conn,
- DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_set_pdiscov_resolve(DBusConnection *conn,
+ DBusMessage *msg,
+ void *data)
{
DBusMessage *reply;
DBusError err;
@@ -2362,18 +2461,19 @@ static DBusHandlerResult handle_dev_set_pdiscov_name_resolve(DBusConnection *con
adapter->pdiscov_resolve_names = resolve;
- if (adapter->pdisc_active) {
+ if (adapter->pdiscov_active) {
if (resolve)
- adapter->discover_type |= RESOLVE_NAME;
+ adapter->discov_type |= RESOLVE_NAME;
else
- adapter->discover_type &= ~RESOLVE_NAME;
+ adapter->discov_type &= ~RESOLVE_NAME;
}
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_get_pdiscov_name_resolve(DBusConnection *conn,
- DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_get_pdiscov_resolve(DBusConnection *conn,
+ DBusMessage *msg,
+ void *data)
{
DBusMessage *reply;
struct adapter *adapter = data;
@@ -2392,7 +2492,8 @@ static DBusHandlerResult handle_dev_get_pdiscov_name_resolve(DBusConnection *con
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_discover_devices_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_discover_devices(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
DBusMessage *reply;
const char *method;
@@ -2409,7 +2510,7 @@ static DBusHandlerResult handle_dev_discover_devices_req(DBusConnection *conn, D
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
return error_invalid_arguments(conn, msg);
- if (adapter->disc_active)
+ if (adapter->discov_active)
return error_discover_in_progress(conn, msg);
pending_remote_name_cancel(adapter);
@@ -2438,37 +2539,40 @@ static DBusHandlerResult handle_dev_discover_devices_req(DBusConnection *conn, D
if (hci_send_req(dd, &rq, 500) < 0) {
int err = errno;
error("Unable to start inquiry: %s (%d)",
- strerror(errno), errno);
+ strerror(errno), errno);
hci_close_dev(dd);
return error_failed(conn, msg, err);
}
if (rp.status) {
- error("HCI_Inquiry command failed with status 0x%02x", rp.status);
+ error("HCI_Inquiry command failed with status 0x%02x",
+ rp.status);
hci_close_dev(dd);
return error_failed(conn, msg, bt_error(rp.status));
}
method = dbus_message_get_member(msg);
if (strcmp("DiscoverDevicesWithoutNameResolving", method) == 0)
- adapter->discover_type |= STD_INQUIRY;
+ adapter->discov_type |= STD_INQUIRY;
else
- adapter->discover_type |= (STD_INQUIRY | RESOLVE_NAME);
+ adapter->discov_type |= (STD_INQUIRY | RESOLVE_NAME);
- adapter->discovery_requestor = strdup(dbus_message_get_sender(msg));
+ adapter->discov_requestor = strdup(dbus_message_get_sender(msg));
reply = dbus_message_new_method_return(msg);
hci_close_dev(dd);
- /* track the request owner to cancel it automatically if the owner exits */
+ /* track the request owner to cancel it automatically if the owner
+ * exits */
name_listener_add(conn, dbus_message_get_sender(msg),
(name_cb_t) discover_devices_req_exit, adapter);
return send_message_and_unref(conn, reply);
}
-static DBusHandlerResult handle_dev_cancel_discovery_req(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult adapter_cancel_discovery(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
struct adapter *adapter = data;
int err;
@@ -2479,13 +2583,14 @@ static DBusHandlerResult handle_dev_cancel_discovery_req(DBusConnection *conn, D
if (!dbus_message_has_signature(msg, DBUS_TYPE_INVALID_AS_STRING))
return error_invalid_arguments(conn, msg);
- /* is there discover pending? or discovery cancel was requested previously */
- if (!adapter->disc_active || adapter->discovery_cancel)
+ /* is there discover pending? or discovery cancel was requested
+ * previously */
+ if (!adapter->discov_active || adapter->discovery_cancel)
return error_not_authorized(conn, msg);
/* only the discover requestor can cancel the inquiry process */
- if (!adapter->discovery_requestor ||
- strcmp(adapter->discovery_requestor, dbus_message_get_sender(msg)))
+ if (!adapter->discov_requestor ||
+ strcmp(adapter->discov_requestor, dbus_message_get_sender(msg)))
return error_not_authorized(conn, msg);
/*
@@ -2577,65 +2682,65 @@ struct slist *service_classes_str(uint32_t class)
}
static struct service_data dev_services[] = {
- { "GetAddress", handle_dev_get_address_req },
- { "GetVersion", handle_dev_get_version_req },
- { "GetRevision", handle_dev_get_revision_req },
- { "GetManufacturer", handle_dev_get_manufacturer_req },
- { "GetCompany", handle_dev_get_company_req },
- { "GetMode", handle_dev_get_mode_req },
- { "SetMode", handle_dev_set_mode_req },
- { "GetDiscoverableTimeout", handle_dev_get_discoverable_to_req },
- { "SetDiscoverableTimeout", handle_dev_set_discoverable_to_req },
- { "IsConnectable", handle_dev_is_connectable_req },
- { "IsDiscoverable", handle_dev_is_discoverable_req },
- { "IsConnected", handle_dev_is_connected_req },
- { "ListConnections", handle_dev_list_connections_req },
- { "GetMajorClass", handle_dev_get_major_class_req },
- { "ListAvailableMinorClasses", handle_dev_list_minor_classes_req },
- { "GetMinorClass", handle_dev_get_minor_class_req },
- { "SetMinorClass", handle_dev_set_minor_class_req },
- { "GetServiceClasses", handle_dev_get_service_classes_req },
- { "GetName", handle_dev_get_name_req },
- { "SetName", handle_dev_set_name_req },
+ { "GetAddress", adapter_get_address },
+ { "GetVersion", adapter_get_version },
+ { "GetRevision", adapter_get_revision },
+ { "GetManufacturer", adapter_get_manufacturer },
+ { "GetCompany", adapter_get_company },
+ { "GetMode", adapter_get_mode },
+ { "SetMode", adapter_set_mode },
+ { "GetDiscoverableTimeout", adapter_get_discoverable_to },
+ { "SetDiscoverableTimeout", adapter_set_discoverable_to },
+ { "IsConnectable", adapter_is_connectable },
+ { "IsDiscoverable", adapter_is_discoverable },
+ { "IsConnected", adapter_is_connected },
+ { "ListConnections", adapter_list_connections },
+ { "GetMajorClass", adapter_get_major_class },
+ { "ListAvailableMinorClasses", adapter_list_minor_classes },
+ { "GetMinorClass", adapter_get_minor_class },
+ { "SetMinorClass", adapter_set_minor_class },
+ { "GetServiceClasses", adapter_get_service_classes },
+ { "GetName", adapter_get_name },
+ { "SetName", adapter_set_name },
- { "GetRemoteServiceRecord", handle_dev_get_remote_svc_rec },
- { "GetRemoteServiceHandles", handle_dev_get_remote_svc_handles },
-
- { "GetRemoteVersion", handle_dev_get_remote_version_req },
- { "GetRemoteRevision", handle_dev_get_remote_revision_req },
- { "GetRemoteManufacturer", handle_dev_get_remote_manufacturer_req },
- { "GetRemoteCompany", handle_dev_get_remote_company_req },
- { "GetRemoteMajorClass", handle_dev_get_remote_major_class_req },
- { "GetRemoteMinorClass", handle_dev_get_remote_minor_class_req },
- { "GetRemoteServiceClasses", handle_dev_get_remote_service_cls_req },
- { "GetRemoteClass", handle_dev_get_remote_class_req },
- { "GetRemoteName", handle_dev_get_remote_name_req },
- { "GetRemoteAlias", handle_dev_get_remote_alias_req },
- { "SetRemoteAlias", handle_dev_set_remote_alias_req },
- { "ClearRemoteAlias", handle_dev_clear_remote_alias_req },
-
- { "LastSeen", handle_dev_last_seen_req },
- { "LastUsed", handle_dev_last_used_req },
-
- { "DisconnectRemoteDevice", handle_dev_disconnect_remote_device_req },
-
- { "CreateBonding", handle_dev_create_bonding_req },
- { "CancelBondingProcess", handle_dev_cancel_bonding_req },
- { "RemoveBonding", handle_dev_remove_bonding_req },
- { "HasBonding", handle_dev_has_bonding_req },
- { "ListBondings", handle_dev_list_bondings_req },
- { "GetPinCodeLength", handle_dev_get_pin_code_length_req },
- { "GetEncryptionKeySize", handle_dev_get_encryption_key_size_req },
-
- { "StartPeriodicDiscovery", handle_dev_start_periodic_req },
- { "StopPeriodicDiscovery", handle_dev_stop_periodic_req },
- { "IsPeriodicDiscovery", handle_dev_is_periodic_req },
- { "SetPeriodicDiscoveryNameResolving", handle_dev_set_pdiscov_name_resolve },
- { "GetPeriodicDiscoveryNameResolving", handle_dev_get_pdiscov_name_resolve },
-
- { "DiscoverDevices", handle_dev_discover_devices_req },
- { "DiscoverDevicesWithoutNameResolving", handle_dev_discover_devices_req },
- { "CancelDiscovery", handle_dev_cancel_discovery_req },
+ { "GetRemoteServiceRecord", adapter_get_remote_svc },
+ { "GetRemoteServiceHandles", adapter_get_remote_svc_handles },
+
+ { "GetRemoteVersion", adapter_get_remote_version },
+ { "GetRemoteRevision", adapter_get_remote_revision },
+ { "GetRemoteManufacturer", adapter_get_remote_manufacturer },
+ { "GetRemoteCompany", adapter_get_remote_company },
+ { "GetRemoteMajorClass", adapter_get_remote_major_class },
+ { "GetRemoteMinorClass", adapter_get_remote_minor_class },
+ { "GetRemoteServiceClasses", adapter_get_remote_service_cls },
+ { "GetRemoteClass", adapter_get_remote_class },
+ { "GetRemoteName", adapter_get_remote_name },
+ { "GetRemoteAlias", adapter_get_remote_alias },
+ { "SetRemoteAlias", adapter_set_remote_alias },
+ { "ClearRemoteAlias", adapter_clear_remote_alias },
+
+ { "LastSeen", adapter_last_seen },
+ { "LastUsed", adapter_last_used },
+
+ { "DisconnectRemoteDevice", adapter_dc_remote_device },
+
+ { "CreateBonding", adapter_create_bonding },
+ { "CancelBondingProcess", adapter_cancel_bonding },
+ { "RemoveBonding", adapter_remove_bonding },
+ { "HasBonding", adapter_has_bonding },
+ { "ListBondings", adapter_list_bondings },
+ { "GetPinCodeLength", adapter_get_pin_code_length },
+ { "GetEncryptionKeySize", adapter_get_encryption_key_size },
+
+ { "StartPeriodicDiscovery", adapter_start_periodic },
+ { "StopPeriodicDiscovery", adapter_stop_periodic },
+ { "IsPeriodicDiscovery", adapter_is_periodic },
+ { "SetPeriodicDiscoveryNameResolving", adapter_set_pdiscov_resolve },
+ { "GetPeriodicDiscoveryNameResolving", adapter_get_pdiscov_resolve },
+
+ { "DiscoverDevices", adapter_discover_devices },
+ { "DiscoverDevicesWithoutNameResolving", adapter_discover_devices },
+ { "CancelDiscovery", adapter_cancel_discovery },
{ NULL, NULL }
};
diff --git a/hcid/dbus-test.c b/hcid/dbus-test.c
index a18a5005..c8c977ea 100644
--- a/hcid/dbus-test.c
+++ b/hcid/dbus-test.c
@@ -401,7 +401,7 @@ static DBusHandlerResult audit_remote_device(DBusConnection *conn,
if (!read_l2cap_info(&local, &peer, NULL, NULL, NULL, NULL))
return error_audit_already_exists(conn, msg);
- if (adapter->disc_active || (adapter->pdisc_active && !adapter->pinq_idle))
+ if (adapter->discov_active || (adapter->pdiscov_active && !adapter->pinq_idle))
queue = TRUE;
else
queue = audit_in_progress();
@@ -639,7 +639,8 @@ void process_audits_list(const char *adapter_path)
continue;
}
- if (adapter->disc_active || (adapter->pdisc_active && !adapter->pinq_idle))
+ if (adapter->discov_active || (adapter->pdiscov_active
+ && !adapter->pinq_idle))
continue;
sk = l2raw_connect(adapter->address, &audit->peer);
diff --git a/hcid/dbus.c b/hcid/dbus.c
index cc82731a..a2527e6c 100644
--- a/hcid/dbus.c
+++ b/hcid/dbus.c
@@ -94,7 +94,8 @@ void bonding_request_free(struct bonding_request_info *bonding)
free(bonding);
}
-int disc_device_find(const struct discovered_dev_info *d1, const struct discovered_dev_info *d2)
+int disc_device_find(const struct discovered_dev_info *d1,
+ const struct discovered_dev_info *d2)
{
int ret;
@@ -205,7 +206,8 @@ static int active_conn_find_by_handle(const void *data, const void *user_data)
return -1;
}
-static int active_conn_append(struct slist **list, bdaddr_t *bdaddr, uint16_t handle)
+static int active_conn_append(struct slist **list, bdaddr_t *bdaddr,
+ uint16_t handle)
{
struct active_conn_info *dev;
@@ -250,24 +252,28 @@ DBusMessage *new_authentication_return(DBusMessage *msg, uint8_t status)
case 0x10: /* connection accept timeout */
case 0x22: /* LMP response timeout */
case 0x28: /* instant passed - is this a timeout? */
- return dbus_message_new_error(msg, ERROR_INTERFACE".AuthenticationTimeout",
- "Authentication Timeout");
+ return dbus_message_new_error(msg,
+ ERROR_INTERFACE ".AuthenticationTimeout",
+ "Authentication Timeout");
case 0x17: /* too frequent pairing attempts */
- return dbus_message_new_error(msg, ERROR_INTERFACE".RepeatedAttemps",
- "Repeated Attempts");
+ return dbus_message_new_error(msg,
+ ERROR_INTERFACE ".RepeatedAttemps",
+ "Repeated Attempts");
case 0x06:
case 0x18: /* pairing not allowed (e.g. gw rejected attempt) */
- return dbus_message_new_error(msg, ERROR_INTERFACE".AuthenticationRejected",
- "Authentication Rejected");
+ return dbus_message_new_error(msg,
+ ERROR_INTERFACE ".AuthenticationRejected",
+ "Authentication Rejected");
case 0x07: /* memory capacity */
case 0x09: /* connection limit */
case 0x0a: /* synchronous connection limit */
case 0x0d: /* limited resources */
case 0x14: /* terminated due to low resources */
- return dbus_message_new_error(msg, ERROR_INTERFACE".AuthenticationCanceled",
- "Authentication Canceled");
+ return dbus_message_new_error(msg,
+ ERROR_INTERFACE ".AuthenticationCanceled",
+ "Authentication Canceled");
case 0x05: /* authentication failure */
case 0x0E: /* rejected due to security reasons - is this auth failure? */
@@ -276,8 +282,9 @@ DBusMessage *new_authentication_return(DBusMessage *msg, uint8_t status)
case 0x29: /* pairing with unit key unsupported - is this auth failure? */
case 0x2f: /* insufficient security - is this auth failure? */
default:
- return dbus_message_new_error(msg, ERROR_INTERFACE".AuthenticationFailed",
- "Authentication Failed");
+ return dbus_message_new_error(msg,
+ ERROR_INTERFACE ".AuthenticationFailed",
+ "Authentication Failed");
}
}
@@ -286,7 +293,8 @@ int get_default_dev_id(void)
return default_dev;
}
-static inline int dev_append_signal_args(DBusMessage *signal, int first, va_list var_args)
+static inline int dev_append_signal_args(DBusMessage *signal, int first,
+ va_list var_args)
{
void *value;
DBusMessageIter iter;
@@ -308,7 +316,8 @@ static inline int dev_append_signal_args(DBusMessage *signal, int first, va_list
return 0;
}
-DBusMessage *dev_signal_factory(int devid, const char *prop_name, int first, ...)
+DBusMessage *dev_signal_factory(int devid, const char *prop_name, int first,
+ ...)
{
va_list var_args;
DBusMessage *signal;
@@ -351,10 +360,12 @@ static const DBusObjectPathVTable obj_mgr_vtable = {
/*
* HCI D-Bus services
*/
-static DBusHandlerResult hci_dbus_signal_filter(DBusConnection *conn, DBusMessage *msg, void *data);
+static DBusHandlerResult hci_dbus_signal_filter(DBusConnection *conn,
+ DBusMessage *msg, void *data);
static int register_dbus_path(const char *path, uint16_t dev_id,
- const DBusObjectPathVTable *pvtable, gboolean fallback)
+ const DBusObjectPathVTable *pvtable,
+ gboolean fallback)
{
struct adapter *data;
@@ -362,7 +373,8 @@ static int register_dbus_path(const char *path, uint16_t dev_id,
data = malloc(sizeof(struct adapter));
if (!data) {
- error("Failed to alloc memory to DBUS path register data (%s)", path);
+ error("Failed to alloc memory to DBUS path register data (%s)",
+ path);
return -1;
}
@@ -371,13 +383,15 @@ static int register_dbus_path(const char *path, uint16_t dev_id,
data->dev_id = dev_id;
if (fallback) {
- if (!dbus_connection_register_fallback(connection, path, pvtable, data)) {
+ if (!dbus_connection_register_fallback(connection, path,
+ pvtable, data)) {
error("D-Bus failed to register %s fallback", path);
free(data);
return -1;
}
} else {
- if (!dbus_connection_register_object_path(connection, path, pvtable, data)) {
+ if (!dbus_connection_register_object_path(connection, path,
+ pvtable, data)) {
error("D-Bus failed to register %s object", path);
free(data);
return -1;
@@ -397,8 +411,10 @@ static void reply_pending_requests(const char *path, struct adapter *adapter)
/* pending bonding */
if (adapter->bonding) {
error_authentication_canceled(connection, adapter->bonding->rq);
- name_listener_remove(connection, dbus_message_get_sender(adapter->bonding->rq),
- (name_cb_t) create_bond_req_exit, adapter);
+ name_listener_remove(connection,
+ dbus_message_get_sender(adapter->bonding->rq),
+ (name_cb_t) create_bond_req_exit,
+ adapter);
if (adapter->bonding->io_id)
g_io_remove_watch(adapter->bonding->io_id);
g_io_channel_close(adapter->bonding->io);
@@ -414,7 +430,7 @@ static void reply_pending_requests(const char *path, struct adapter *adapter)
adapter->discovery_cancel = NULL;
}
- if (adapter->disc_active) {
+ if (adapter->discov_active) {
/* Send discovery completed signal if there isn't name
* to resolve */
message = dbus_message_new_signal(path, ADAPTER_INTERFACE,
@@ -422,11 +438,11 @@ static void reply_pending_requests(const char *path, struct adapter *adapter)
send_message_and_unref(connection, message);
/* Cancel inquiry initiated by D-Bus client */
- if (adapter->discovery_requestor)
+ if (adapter->discov_requestor)
cancel_discovery(adapter);
}
- if (adapter->pdisc_active) {
+ if (adapter->pdiscov_active) {
/* Send periodic discovery stopped signal exit or stop
* the device */
message = dbus_message_new_signal(path, ADAPTER_INTERFACE,
@@ -434,73 +450,78 @@ static void reply_pending_requests(const char *path, struct adapter *adapter)
send_message_and_unref(connection, message);
/* Stop periodic inquiry initiated by D-Bus client */
- if (adapter->pdiscovery_requestor)
+ if (adapter->pdiscov_requestor)
cancel_periodic_discovery(adapter);
}
}
static int unregister_dbus_path(const char *path)
{
- struct adapter *adapter;
+ struct adapter *adapter = NULL;
+
+ info("Unregister path: %s", path);
- info("Unregister path:%s", path);
+ dbus_connection_get_object_path_data(connection, path,
+ (void *) &adapter);
- if (dbus_connection_get_object_path_data(connection, path, (void *) &adapter) && adapter) {
+ if (!adapter)
+ goto unreg;
- /* check pending requests */
- reply_pending_requests(path, adapter);
+ /* check pending requests */
+ reply_pending_requests(path, adapter);
- cancel_passkey_agent_requests(adapter->passkey_agents, path, NULL);
+ cancel_passkey_agent_requests(adapter->passkey_agents, path, NULL);
- release_passkey_agents(adapter, NULL);
+ release_passkey_agents(adapter, NULL);
- if (adapter->discovery_requestor) {
- name_listener_remove(connection,
- adapter->discovery_requestor,
+ if (adapter->discov_requestor) {
+ name_listener_remove(connection,
+ adapter->discov_requestor,
(name_cb_t) discover_devices_req_exit, adapter);
- free(adapter->discovery_requestor);
- adapter->discovery_requestor = NULL;
- }
-
- if (adapter->pdiscovery_requestor) {
- name_listener_remove(connection,
- adapter->pdiscovery_requestor,
- (name_cb_t) periodic_discover_req_exit, adapter);
- free(adapter->pdiscovery_requestor);
- adapter->pdiscovery_requestor = NULL;
- }
+ free(adapter->discov_requestor);
+ adapter->discov_requestor = NULL;
+ }
- if (adapter->disc_devices) {
- slist_foreach(adapter->disc_devices,
- (slist_func_t) free, NULL);
- slist_free(adapter->disc_devices);
- adapter->disc_devices = NULL;
- }
+ if (adapter->pdiscov_requestor) {
+ name_listener_remove(connection,
+ adapter->pdiscov_requestor,
+ (name_cb_t) periodic_discover_req_exit,
+ adapter);
+ free(adapter->pdiscov_requestor);
+ adapter->pdiscov_requestor = NULL;
+ }
- if (adapter->oor_devices) {
- slist_foreach(adapter->oor_devices,
- (slist_func_t) free, NULL);
- slist_free(adapter->oor_devices);
- adapter->oor_devices = NULL;
- }
+ if (adapter->disc_devices) {
+ slist_foreach(adapter->disc_devices,
+ (slist_func_t) free, NULL);
+ slist_free(adapter->disc_devices);
+ adapter->disc_devices = NULL;
+ }
- if (adapter->pin_reqs) {
- slist_foreach(adapter->pin_reqs,
- (slist_func_t) free, NULL);
- slist_free(adapter->pin_reqs);
- adapter->pin_reqs = NULL;
- }
+ if (adapter->oor_devices) {
+ slist_foreach(adapter->oor_devices,
+ (slist_func_t) free, NULL);
+ slist_free(adapter->oor_devices);
+ adapter->oor_devices = NULL;
+ }
- if (adapter->active_conn) {
- slist_foreach(adapter->active_conn,
- (slist_func_t) free, NULL);
- slist_free(adapter->active_conn);
- adapter->active_conn = NULL;
- }
+ if (adapter->pin_reqs) {
+ slist_foreach(adapter->pin_reqs,
+ (slist_func_t) free, NULL);
+ slist_free(adapter->pin_reqs);
+ adapter->pin_reqs = NULL;
+ }
- free (adapter);
+ if (adapter->active_conn) {
+ slist_foreach(adapter->active_conn,
+ (slist_func_t) free, NULL);
+ slist_free(adapter->active_conn);
+ adapter->active_conn = NULL;
}
+ free (adapter);
+
+unreg:
if (!dbus_connection_unregister_object_path (connection, path)) {
error("D-Bus failed to unregister %s object", path);
return -1;
@@ -531,7 +552,7 @@ int hcid_dbus_register_device(uint16_t id)
* Send the adapter added signal
*/
message = dbus_message_new_signal(BASE_PATH, MANAGER_INTERFACE,
- "AdapterAdded");
+ "AdapterAdded");
if (message == NULL) {
error("Can't allocate D-Bus message");
dbus_connection_unregister_object_path(connection, path);
@@ -557,7 +578,7 @@ int hcid_dbus_unregister_device(uint16_t id)
snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, id);
message = dbus_message_new_signal(BASE_PATH, MANAGER_INTERFACE,
- "AdapterRemoved");
+ "AdapterRemoved");
if (message == NULL) {
error("Can't allocate D-Bus message");
goto failed;
@@ -614,34 +635,36 @@ int hcid_dbus_start_device(uint16_t id)
if (hci_send_req(dd, &rq, 1000) < 0) {
error("Sending read scan enable command failed: %s (%d)",
- strerror(errno), errno);
+ strerror(errno), errno);
rp.enable = SCAN_PAGE | SCAN_INQUIRY;
} else if (rp.status) {
error("Getting scan enable failed with status 0x%02x",
- rp.status);
+ rp.status);
rp.enable = SCAN_PAGE | SCAN_INQUIRY;
}
}
- if (!dbus_connection_get_object_path_data(connection, path, (void *) &adapter)) {
+ if (!dbus_connection_get_object_path_data(connection, path,
+ (void *) &adapter)) {
error("Getting %s path data failed!", path);
goto failed;
}
if (hci_test_bit(HCI_INQUIRY, &di.flags))
- adapter->disc_active = 1;
+ adapter->discov_active = 1;
else
- adapter->disc_active = 0;
+ adapter->discov_active = 0;
adapter->mode = rp.enable; /* Keep the current scan status */
adapter->up = 1;
- adapter->discoverable_timeout = get_discoverable_timeout(id);
- adapter->discover_type = DISCOVER_TYPE_NONE;
+ adapter->discov_timeout = get_discoverable_timeout(id);
+ adapter->discov_type = DISCOVER_TYPE_NONE;
/*
* Get the adapter Bluetooth address
*/
- err = get_device_address(adapter->dev_id, adapter->address, sizeof(adapter->address));
+ err = get_device_address(adapter->dev_id, adapter->address,
+ sizeof(adapter->address));
if (err < 0)
goto failed;
@@ -692,7 +715,8 @@ int hcid_dbus_stop_device(uint16_t id)
snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, id);
- if (!dbus_connection_get_object_path_data(connection, path, (void *) &adapter)) {
+ if (!dbus_connection_get_object_path_data(connection, path,
+ (void *) &adapter)) {
error("Getting %s path data failed!", path);
return -1;
}
@@ -716,18 +740,20 @@ int hcid_dbus_stop_device(uint16_t id)
release_passkey_agents(adapter, NULL);
- if (adapter->discovery_requestor) {
- name_listener_remove(connection, adapter->discovery_requestor,
- (name_cb_t) discover_devices_req_exit, adapter);
- free(adapter->discovery_requestor);
- adapter->discovery_requestor = NULL;
+ if (adapter->discov_requestor) {
+ name_listener_remove(connection, adapter->discov_requestor,
+ (name_cb_t) discover_devices_req_exit,
+ adapter);
+ free(adapter->discov_requestor);
+ adapter->discov_requestor = NULL;
}
- if (adapter->pdiscovery_requestor) {
- name_listener_remove(connection, adapter->pdiscovery_requestor,
- (name_cb_t) periodic_discover_req_exit, adapter);
- free(adapter->pdiscovery_requestor);
- adapter->pdiscovery_requestor = NULL;
+ if (adapter->pdiscov_requestor) {
+ name_listener_remove(connection, adapter->pdiscov_requestor,
+ (name_cb_t) periodic_discover_req_exit,
+ adapter);
+ free(adapter->pdiscov_requestor);
+ adapter->pdiscov_requestor = NULL;
}
if (adapter->disc_devices) {
@@ -756,10 +782,10 @@ int hcid_dbus_stop_device(uint16_t id)
adapter->up = 0;
adapter->mode = SCAN_DISABLED;
- adapter->disc_active = 0;
- adapter->pdisc_active = 0;
+ adapter->discov_active = 0;
+ adapter->pdiscov_active = 0;
adapter->pinq_idle = 0;
- adapter->discover_type = DISCOVER_TYPE_NONE;
+ adapter->discov_type = DISCOVER_TYPE_NONE;
return 0;
}
@@ -789,7 +815,8 @@ void hcid_dbus_pending_pin_req_add(bdaddr_t *sba, bdaddr_t *dba)
snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, id);
- if (!dbus_connection_get_object_path_data(connection, path, (void *) &adapter)) {
+ if (!dbus_connection_get_object_path_data(connection, path,
+ (void *) &adapter)) {
error("Getting %s path data failed!", path);
return;
}
@@ -826,7 +853,8 @@ int hcid_dbus_request_pin(int dev, bdaddr_t *sba, struct hci_conn_info *ci)
return handle_passkey_request(connection, dev, path, sba, &ci->bdaddr);
}
-void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t status)
+void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer,
+ uint8_t status)
{
struct adapter *adapter;
DBusMessage *message;
@@ -848,13 +876,15 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t
snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, id);
/* create the authentication reply */
- if (!dbus_connection_get_object_path_data(connection, path, (void *) &adapter)) {
+ if (!dbus_connection_get_object_path_data(connection, path,
+ (void *) &adapter)) {
error("Getting %s path data failed!", path);
goto failed;
}
if (status)
- cancel_passkey_agent_requests(adapter->passkey_agents, path, peer);
+ cancel_passkey_agent_requests(adapter->passkey_agents, path,
+ peer);
l = slist_find(adapter->pin_reqs, peer, pin_req_cmp);
if (l) {
@@ -863,7 +893,8 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t
free(d);
if (!status) {
- message = dev_signal_factory(adapter->dev_id, "BondingCreated",
+ message = dev_signal_factory(adapter->dev_id,
+ "BondingCreated",
DBUS_TYPE_STRING, &peer_addr,
DBUS_TYPE_INVALID);
send_message_and_unref(connection, message);
@@ -880,12 +911,14 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t
error_authentication_canceled(connection, adapter->bonding->rq);
} else {
/* reply authentication success or an error */
- message = new_authentication_return(adapter->bonding->rq, status);
+ message = new_authentication_return(adapter->bonding->rq,
+ status);
send_message_and_unref(connection, message);
}
- name_listener_remove(connection, dbus_message_get_sender(adapter->bonding->rq),
- (name_cb_t) create_bond_req_exit, adapter);
+ name_listener_remove(connection,
+ dbus_message_get_sender(adapter->bonding->rq),
+ (name_cb_t) create_bond_req_exit, adapter);
if (adapter->bonding->io_id)
g_io_remove_watch(adapter->bonding->io_id);
@@ -917,18 +950,19 @@ void hcid_dbus_inquiry_start(bdaddr_t *local)
snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, id);
- if (dbus_connection_get_object_path_data(connection, path, (void *) &adapter)) {
- adapter->disc_active = 1;
+ if (dbus_connection_get_object_path_data(connection, path,
+ (void *) &adapter)) {
+ adapter->discov_active = 1;
/*
* Cancel pending remote name request and clean the device list
* when inquiry is supported in periodic inquiry idle state.
*/
- if (adapter->pdisc_active)
+ if (adapter->pdiscov_active)
pending_remote_name_cancel(adapter);
/* Disable name resolution for non D-Bus clients */
- if (!adapter->discovery_requestor)
- adapter->discover_type &= ~RESOLVE_NAME;
+ if (!adapter->discov_requestor)
+ adapter->discov_type &= ~RESOLVE_NAME;
}
message = dev_signal_factory(adapter->dev_id, "DiscoveryStarted",
@@ -1001,7 +1035,8 @@ int disc_device_req_name(struct adapter *adapter)
}
if (rp.status) {
- error("Remote name request failed with status 0x%02x", rp.status);
+ error("Remote name request failed with status 0x%02x",
+ rp.status);
failed_signal = dev_signal_factory(adapter->dev_id,
"RemoteNameFailed",
DBUS_TYPE_STRING, &peer_addr,
@@ -1078,13 +1113,14 @@ void hcid_dbus_inquiry_complete(bdaddr_t *local)
snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, id);
- if (!dbus_connection_get_object_path_data(connection, path, (void *) &adapter)) {
+ if (!dbus_connection_get_object_path_data(connection, path,
+ (void *) &adapter)) {
error("Getting %s path data failed!", path);
goto done;
}
/* Out of range verification */
- if (adapter->pdisc_active && !adapter->disc_active) {
+ if (adapter->pdiscov_active && !adapter->discov_active) {
send_out_of_range(path, adapter->oor_devices);
slist_foreach(adapter->oor_devices, (slist_func_t) free, NULL);
@@ -1095,7 +1131,8 @@ void hcid_dbus_inquiry_complete(bdaddr_t *local)
while (l) {
dev = l->data;
baswap(&tmp, &dev->bdaddr);
- adapter->oor_devices = slist_append(adapter->oor_devices, batostr(&tmp));
+ adapter->oor_devices = slist_append(adapter->oor_devices,
+ batostr(&tmp));
l = l->next;
}
}
@@ -1106,8 +1143,8 @@ void hcid_dbus_inquiry_complete(bdaddr_t *local)
* Enable resolution again: standard inquiry can be
* received in the periodic inquiry idle state.
*/
- if (adapter->pdiscovery_requestor)
- adapter->discover_type |= RESOLVE_NAME;
+ if (adapter->pdiscov_requestor)
+ adapter->discov_type |= RESOLVE_NAME;
/*
* The following scenarios can happen:
@@ -1124,12 +1161,12 @@ void hcid_dbus_inquiry_complete(bdaddr_t *local)
if (!disc_device_req_name(adapter))
goto done; /* skip - there is name to resolve */
- if (adapter->disc_active) {
+ if (adapter->discov_active) {
message = dbus_message_new_signal(path, ADAPTER_INTERFACE,
"DiscoveryCompleted");
send_message_and_unref(connection, message);
- adapter->disc_active = 0;
+ adapter->discov_active = 0;
}
/* free discovered devices list */
@@ -1137,11 +1174,11 @@ void hcid_dbus_inquiry_complete(bdaddr_t *local)
slist_free(adapter->disc_devices);
adapter->disc_devices = NULL;
- if (adapter->discovery_requestor) {
- name_listener_remove(connection, adapter->discovery_requestor,
+ if (adapter->discov_requestor) {
+ name_listener_remove(connection, adapter->discov_requestor,
(name_cb_t) discover_devices_req_exit, adapter);
- free(adapter->discovery_requestor);
- adapter->discovery_requestor = NULL;
+ free(adapter->discov_requestor);
+ adapter->discov_requestor = NULL;
/* If there is a pending reply for discovery cancel */
if (adapter->discovery_cancel) {
@@ -1152,7 +1189,7 @@ void hcid_dbus_inquiry_complete(bdaddr_t *local)
}
/* reset the discover type for standard inquiry only */
- adapter->discover_type &= ~STD_INQUIRY;
+ adapter->discov_type &= ~STD_INQUIRY;
}
done:
@@ -1185,12 +1222,13 @@ void hcid_dbus_periodic_inquiry_start(bdaddr_t *local, uint8_t status)
snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, id);
- if (dbus_connection_get_object_path_data(connection, path, (void *) &adapter)) {
- adapter->pdisc_active = 1;
+ if (dbus_connection_get_object_path_data(connection, path,
+ (void *) &adapter)) {
+ adapter->pdiscov_active = 1;
/* Disable name resolution for non D-Bus clients */
- if (!adapter->pdiscovery_requestor)
- adapter->discover_type &= ~RESOLVE_NAME;
+ if (!adapter->pdiscov_requestor)
+ adapter->discov_type &= ~RESOLVE_NAME;
}
message = dbus_message_new_signal(path, ADAPTER_INTERFACE,
@@ -1224,14 +1262,16 @@ void hcid_dbus_periodic_inquiry_exit(bdaddr_t *local, uint8_t status)
snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, id);
- if (!dbus_connection_get_object_path_data(connection, path, (void *) &adapter)) {
+ if (!dbus_connection_get_object_path_data(connection, path,
+ (void *) &adapter)) {
error("Getting %s path data failed!", path);
goto done;
}
- /* reset the discover type to be able to handle D-Bus and non D-Bus requests */
- adapter->pdisc_active = 0;
- adapter->discover_type &= ~(PERIODIC_INQUIRY | RESOLVE_NAME);
+ /* reset the discover type to be able to handle D-Bus and non D-Bus
+ * requests */
+ adapter->pdiscov_active = 0;
+ adapter->discov_type &= ~(PERIODIC_INQUIRY | RESOLVE_NAME);
/* free discovered devices list */
slist_foreach(adapter->disc_devices, (slist_func_t) free, NULL);
@@ -1243,20 +1283,22 @@ void hcid_dbus_periodic_inquiry_exit(bdaddr_t *local, uint8_t status)
slist_free(adapter->oor_devices);
adapter->oor_devices = NULL;
- if (adapter->pdiscovery_requestor) {
- name_listener_remove(connection, adapter->pdiscovery_requestor,
- (name_cb_t) periodic_discover_req_exit, adapter);
- free(adapter->pdiscovery_requestor);
- adapter->pdiscovery_requestor = NULL;
+ if (adapter->pdiscov_requestor) {
+ name_listener_remove(connection, adapter->pdiscov_requestor,
+ (name_cb_t) periodic_discover_req_exit,
+ adapter);
+ free(adapter->pdiscov_requestor);
+ adapter->pdiscov_requestor = NULL;
}
- /* workaround: inquiry completed is not sent when exiting from periodic inquiry */
- if (adapter->disc_active) {
+ /* workaround: inquiry completed is not sent when exiting from
+ * periodic inquiry */
+ if (adapter->discov_active) {
message = dbus_message_new_signal(path, ADAPTER_INTERFACE,
"DiscoveryCompleted");
send_message_and_unref(connection, message);
- adapter->disc_active = 0;
+ adapter->discov_active = 0;
}
/* Send discovery completed signal if there isn't name to resolve */
@@ -1286,7 +1328,8 @@ static char *extract_eir_name(uint8_t *data, uint8_t *type)
return NULL;
}
-void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class, int8_t rssi, uint8_t *data)
+void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
+ int8_t rssi, uint8_t *data)
{
char filename[PATH_MAX + 1];
DBusMessage *signal_device;
@@ -1313,7 +1356,8 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class, i
snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, id);
- if (!dbus_connection_get_object_path_data(connection, path, (void *) &adapter)) {
+ if (!dbus_connection_get_object_path_data(connection, path,
+ (void *) &adapter)) {
error("Getting %s path data failed!", path);
goto done;
}
@@ -1324,17 +1368,19 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class, i
* workaround to identify situation when the daemon started and
* a standard inquiry or periodic inquiry was already running
*/
- if (!adapter->disc_active && !adapter->pdisc_active)
- adapter->pdisc_active = 1;
+ if (!adapter->discov_active && !adapter->pdiscov_active)
+ adapter->pdiscov_active = 1;
/* reset the idle flag when the inquiry complete event arrives */
- if (adapter->pdisc_active) {
+ if (adapter->pdiscov_active) {
adapter->pinq_idle = 0;
/* Out of range list update */
- l = slist_find(adapter->oor_devices, peer_addr, (cmp_func_t) strcmp);
+ l = slist_find(adapter->oor_devices, peer_addr,
+ (cmp_func_t) strcmp);
if (l)
- adapter->oor_devices = slist_remove(adapter->oor_devices, l->data);
+ adapter->oor_devices = slist_remove(adapter->oor_devices,
+ l->data);
}
/* send the device found signal */
@@ -1350,12 +1396,13 @@ void hcid_dbus_inquiry_result(bdaddr_t *local, bdaddr_t *peer, uint32_t class, i
bacpy(&match.bdaddr, peer);
match.name_status = NAME_SENT;
/* if found: don't sent the name again */
- l = slist_find(adapter->disc_devices, &match, (cmp_func_t) disc_device_find);
+ l = slist_find(adapter->disc_devices, &match,
+ (cmp_func_t) disc_device_find);
if (l)
goto done;
/* the inquiry result can be triggered by NON D-Bus client */
- if (adapter->discover_type & RESOLVE_NAME)
+ if (adapter->discov_type & RESOLVE_NAME)
name_status = NAME_REQUIRED;
else
name_status = NAME_NOT_REQUIRED;
@@ -1434,7 +1481,8 @@ failed:
bt_free(peer_addr);
}
-void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status, char *name)
+void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status,
+ char *name)
{
struct adapter *adapter;
DBusMessage *message;
@@ -1454,7 +1502,8 @@ void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status, char
snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, id);
- if (!dbus_connection_get_object_path_data(connection, path, (void *) &adapter)) {
+ if (!dbus_connection_get_object_path_data(connection, path,
+ (void *) &adapter)) {
error("Getting %s path data failed!", path);
goto done;
}
@@ -1489,11 +1538,11 @@ void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status, char
* The discovery completed signal must be sent only for discover
* devices request WITH name resolving
*/
- if (adapter->discovery_requestor) {
- name_listener_remove(connection, adapter->discovery_requestor,
+ if (adapter->discov_requestor) {
+ name_listener_remove(connection, adapter->discov_requestor,
(name_cb_t) discover_devices_req_exit, adapter);
- free(adapter->discovery_requestor);
- adapter->discovery_requestor = NULL;
+ free(adapter->discov_requestor);
+ adapter->discov_requestor = NULL;
/* If there is a pending reply for discovery cancel */
if (adapter->discovery_cancel) {
@@ -1504,16 +1553,16 @@ void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status, char
}
/* Disable name resolution for non D-Bus clients */
- if (!adapter->pdiscovery_requestor)
- adapter->discover_type &= ~RESOLVE_NAME;
+ if (!adapter->pdiscov_requestor)
+ adapter->discov_type &= ~RESOLVE_NAME;
}
- if (adapter->disc_active) {
+ if (adapter->discov_active) {
message = dbus_message_new_signal(path,
ADAPTER_INTERFACE, "DiscoveryCompleted");
send_message_and_unref(connection, message);
- adapter->disc_active = 0;
+ adapter->discov_active = 0;
}
done:
@@ -1521,7 +1570,8 @@ done:
bt_free(peer_addr);
}
-void hcid_dbus_conn_complete(bdaddr_t *local, uint8_t status, uint16_t handle, bdaddr_t *peer)
+void hcid_dbus_conn_complete(bdaddr_t *local, uint8_t status, uint16_t handle,
+ bdaddr_t *peer)
{
char path[MAX_PATH_LENGTH];
DBusMessage *message;
@@ -1541,7 +1591,8 @@ void hcid_dbus_conn_complete(bdaddr_t *local, uint8_t status, uint16_t handle, b
snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, id);
- if (!dbus_connection_get_object_path_data(connection, path, (void *) &adapter)) {
+ if (!dbus_connection_get_object_path_data(connection, path,
+ (void *) &adapter)) {
error("Getting %s path data failed!", path);
goto done;
}
@@ -1549,7 +1600,8 @@ void hcid_dbus_conn_complete(bdaddr_t *local, uint8_t status, uint16_t handle, b
if (status) {
struct slist *l;
- cancel_passkey_agent_requests(adapter->passkey_agents, path, peer);
+ cancel_passkey_agent_requests(adapter->passkey_agents, path,
+ peer);
release_passkey_agents(adapter, peer);
l = slist_find(adapter->pin_reqs, peer, pin_req_cmp);
@@ -1563,7 +1615,8 @@ void hcid_dbus_conn_complete(bdaddr_t *local, uint8_t status, uint16_t handle, b
adapter->bonding->hci_status = status;
} else {
/* Sent the remote device connected signal */
- message = dev_signal_factory(adapter->dev_id, "RemoteDeviceConnected",
+ message = dev_signal_factory(adapter->dev_id,
+ "RemoteDeviceConnected",
DBUS_TYPE_STRING, &peer_addr,
DBUS_TYPE_INVALID);
@@ -1578,7 +1631,8 @@ done:
bt_free(peer_addr);
}
-void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status, uint16_t handle, uint8_t reason)
+void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status,
+ uint16_t handle, uint8_t reason)
{
char path[MAX_PATH_LENGTH];
struct adapter *adapter;
@@ -1604,12 +1658,14 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status, uint16_t handle
snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, id);
- if (!dbus_connection_get_object_path_data(connection, path, (void *) &adapter)) {
+ if (!dbus_connection_get_object_path_data(connection, path,
+ (void *) &adapter)) {
error("Getting %s path data failed!", path);
goto failed;
}
- l = slist_find(adapter->active_conn, &handle, active_conn_find_by_handle);
+ l = slist_find(adapter->active_conn, &handle,
+ active_conn_find_by_handle);
if (!l)
goto failed;
@@ -1622,7 +1678,8 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status, uint16_t handle
hci_req_queue_remove(adapter->dev_id, &dev->bdaddr);
/* Cancel D-Bus/non D-Bus requests */
- cancel_passkey_agent_requests(adapter->passkey_agents, path, &dev->bdaddr);
+ cancel_passkey_agent_requests(adapter->passkey_agents, path,
+ &dev->bdaddr);
release_passkey_agents(adapter, &dev->bdaddr);
l = slist_find(adapter->pin_reqs, &dev->bdaddr, pin_req_cmp);
@@ -1636,14 +1693,18 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status, uint16_t handle
if (adapter->bonding && (bacmp(&adapter->bonding->bdaddr, &dev->bdaddr) == 0)) {
if (adapter->bonding->cancel) {
/* reply authentication canceled */
- error_authentication_canceled(connection, adapter->bonding->rq);
+ error_authentication_canceled(connection,
+ adapter->bonding->rq);
} else {
- message = new_authentication_return(adapter->bonding->rq, HCI_AUTHENTICATION_FAILURE);
+ message = new_authentication_return(adapter->bonding->rq,
+ HCI_AUTHENTICATION_FAILURE);
send_message_and_unref(connection, message);
}
- name_listener_remove(connection, dbus_message_get_sender(adapter->bonding->rq),
- (name_cb_t) create_bond_req_exit, adapter);
+ name_listener_remove(connection,
+ dbus_message_get_sender(adapter->bonding->rq),
+ (name_cb_t) create_bond_req_exit,
+ adapter);
if (adapter->bonding->io_id)
g_io_remove_watch(adapter->bonding->io_id);
g_io_channel_close(adapter->bonding->io);
@@ -1651,7 +1712,8 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status, uint16_t handle
adapter->bonding = NULL;
}
/* Sent the remote device disconnected signal */
- message = dev_signal_factory(adapter->dev_id, "RemoteDeviceDisconnected",
+ message = dev_signal_factory(adapter->dev_id,
+ "RemoteDeviceDisconnected",
DBUS_TYPE_STRING, &peer_addr,
DBUS_TYPE_INVALID);
@@ -1826,7 +1888,8 @@ int hcid_dbus_init(void)
connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
if (dbus_error_is_set(&err)) {
- error("Can't open system message bus connection: %s", err.message);
+ error("Can't open system message bus connection: %s",
+ err.message);
dbus_error_free(&err);
return -1;
}
@@ -1846,10 +1909,12 @@ int hcid_dbus_init(void)
return -1;
}
- if (register_dbus_path(BASE_PATH, INVALID_DEV_ID, &obj_mgr_vtable, TRUE) < 0)
+ if (register_dbus_path(BASE_PATH, INVALID_DEV_ID, &obj_mgr_vtable,
+ TRUE) < 0)
return -1;
- if (!dbus_connection_add_filter(connection, hci_dbus_signal_filter, NULL, NULL)) {
+ if (!dbus_connection_add_filter(connection, hci_dbus_signal_filter,
+ NULL, NULL)) {
error("Can't add new HCI filter");
return -1;
}
@@ -1858,7 +1923,8 @@ int hcid_dbus_init(void)
add_watch, remove_watch, watch_toggled, NULL, NULL);
dbus_connection_set_timeout_functions(connection,
- add_timeout, remove_timeout, timeout_toggled, NULL, NULL);
+ add_timeout, remove_timeout, timeout_toggled, NULL,
+ NULL);
dbus_connection_set_dispatch_status_function(connection,
dispatch_status_cb, NULL, NULL);
@@ -1883,7 +1949,8 @@ void hcid_dbus_exit(void)
for (i = 0; children[i]; i++) {
char dev_path[MAX_PATH_LENGTH];
- snprintf(dev_path, sizeof(dev_path), "%s/%s", BASE_PATH, children[i]);
+ snprintf(dev_path, sizeof(dev_path), "%s/%s", BASE_PATH,
+ children[i]);
unregister_dbus_path(dev_path);
}
@@ -1902,7 +1969,7 @@ done:
*
*****************************************************************/
-gboolean discoverable_timeout_handler(void *data)
+gboolean discov_timeout_handler(void *data)
{
struct adapter *adapter = data;
struct hci_request rq;
@@ -1965,7 +2032,7 @@ static gboolean system_bus_reconnect(void *data)
sk = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
if (sk < 0) {
error("Can't open HCI socket: %s (%d)",
- strerror(errno), errno);
+ strerror(errno), errno);
return TRUE;
}
@@ -2007,7 +2074,8 @@ failed:
* Section reserved to D-Bus signal/messages handling function
*
*****************************************************************/
-static DBusHandlerResult hci_dbus_signal_filter(DBusConnection *conn, DBusMessage *msg, void *data)
+static DBusHandlerResult hci_dbus_signal_filter(DBusConnection *conn,
+ DBusMessage *msg, void *data)
{
DBusHandlerResult ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
const char *iface;
@@ -2026,7 +2094,8 @@ static DBusHandlerResult hci_dbus_signal_filter(DBusConnection *conn, DBusMessag
(strcmp(method, "Disconnected") == 0)) {
error("Got disconnected from the system message bus");
dbus_connection_unref(conn);
- g_timeout_add(RECONNECT_RETRY_TIMEOUT, system_bus_reconnect, NULL);
+ g_timeout_add(RECONNECT_RETRY_TIMEOUT, system_bus_reconnect,
+ NULL);
}
return ret;
@@ -2076,7 +2145,8 @@ void hcid_dbus_setname_complete(bdaddr_t *local)
}
if (rp.status) {
- error("Getting name failed with status 0x%02x", rp.status);
+ error("Getting name failed with status 0x%02x",
+ rp.status);
rp.name[0] = '\0';
}
}
@@ -2133,16 +2203,18 @@ void hcid_dbus_setscan_enable_complete(bdaddr_t *local)
if (hci_send_req(dd, &rq, 1000) < 0) {
error("Sending read scan enable command failed: %s (%d)",
- strerror(errno), errno);
+ strerror(errno), errno);
goto failed;
}
if (rp.status) {
- error("Getting scan enable failed with status 0x%02x", rp.status);
+ error("Getting scan enable failed with status 0x%02x",
+ rp.status);
goto failed;
}
- if (!dbus_connection_get_object_path_data(connection, path, (void *) &adapter)) {
+ if (!dbus_connection_get_object_path_data(connection, path,
+ (void *) &adapter)) {
error("Getting %s path data failed!", path);
goto failed;
}
@@ -2164,15 +2236,18 @@ void hcid_dbus_setscan_enable_complete(bdaddr_t *local)
break;
case (SCAN_PAGE | SCAN_INQUIRY):
scan_mode = MODE_DISCOVERABLE;
- if (adapter->discoverable_timeout != 0)
- adapter->timeout_id = g_timeout_add(adapter->discoverable_timeout * 1000,
- discoverable_timeout_handler, adapter);
+ if (adapter->discov_timeout != 0)
+ adapter->timeout_id = g_timeout_add(adapter->discov_timeout * 1000,
+ discov_timeout_handler,
+ adapter);
break;
case SCAN_INQUIRY:
- /* Address the scenario where another app changed the scan mode */
- if (adapter->discoverable_timeout != 0)
- adapter->timeout_id = g_timeout_add(adapter->discoverable_timeout * 1000,
- discoverable_timeout_handler, adapter);
+ /* Address the scenario when another app changed the scan
+ * mode */
+ if (adapter->discov_timeout != 0)
+ adapter->timeout_id = g_timeout_add(adapter->discov_timeout * 1000,
+ discov_timeout_handler,
+ adapter);
/* ignore, this event should not be sent*/
default:
/* ignore, reserved */
@@ -2218,7 +2293,8 @@ void hcid_dbus_pin_code_reply(bdaddr_t *local, void *ptr)
snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, id);
- if (!dbus_connection_get_object_path_data(connection, path, (void *) &adapter)) {
+ if (!dbus_connection_get_object_path_data(connection, path,
+ (void *) &adapter)) {
error("Getting %s path data failed!", path);
goto failed;
}
@@ -2240,12 +2316,15 @@ void create_bond_req_exit(const char *name, struct adapter *adapter)
snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, adapter->dev_id);
- debug("CreateConnection requestor at %s exited before bonding was completed", name);
+ debug("CreateConnection requestor (%s) exited before bonding was completed",
+ name);
- cancel_passkey_agent_requests(adapter->passkey_agents, path, &adapter->bonding->bdaddr);
+ cancel_passkey_agent_requests(adapter->passkey_agents, path,
+ &adapter->bonding->bdaddr);
release_passkey_agents(adapter, &adapter->bonding->bdaddr);
- l = slist_find(adapter->pin_reqs, &adapter->bonding->bdaddr, pin_req_cmp);
+ l = slist_find(adapter->pin_reqs, &adapter->bonding->bdaddr,
+ pin_req_cmp);
if (l) {
struct pending_pin_info *p = l->data;
@@ -2254,7 +2333,8 @@ void create_bond_req_exit(const char *name, struct adapter *adapter)
dd = hci_open_dev(adapter->dev_id);
if (dd >= 0) {
- hci_send_cmd(dd, OGF_LINK_CTL, OCF_PIN_CODE_NEG_REPLY,
+ hci_send_cmd(dd, OGF_LINK_CTL,
+ OCF_PIN_CODE_NEG_REPLY,
6, &adapter->bonding->bdaddr);
hci_close_dev(dd);
}
@@ -2273,7 +2353,7 @@ void create_bond_req_exit(const char *name, struct adapter *adapter)
void discover_devices_req_exit(const char *name, struct adapter *adapter)
{
- debug("DiscoverDevices requestor at %s exited before the operation finished", name);
+ debug("DiscoverDevices requestor (%s) exited", name);
/*
* Cleanup the discovered devices list and send the command to
@@ -2342,7 +2422,7 @@ int cancel_discovery(struct adapter *adapter)
struct slist *l;
int dd, err = 0;
- if (!adapter->disc_active)
+ if (!adapter->discov_active)
goto cleanup;
dd = hci_open_dev(adapter->dev_id);
@@ -2365,13 +2445,13 @@ int cancel_discovery(struct adapter *adapter)
dev = l->data;
if (remote_name_cancel(dd, &dev->bdaddr, 1000) < 0) {
error("Read remote name cancel failed: %s, (%d)",
- strerror(errno), errno);
+ strerror(errno), errno);
err = -errno;
}
} else {
if (inquiry_cancel(dd, 1000) < 0) {
error("Inquiry cancel failed:%s (%d)",
- strerror(errno), errno);
+ strerror(errno), errno);
err = -errno;
}
}
@@ -2380,7 +2460,7 @@ int cancel_discovery(struct adapter *adapter)
cleanup:
/*
- * Reset discovery_requestor and discover_state in the remote name
+ * Reset discov_requestor and discover_state in the remote name
* request event handler or in the inquiry complete handler.
*/
slist_foreach(adapter->disc_devices, (slist_func_t) free, NULL);
@@ -2388,19 +2468,20 @@ cleanup:
adapter->disc_devices = NULL;
/* Disable name resolution for non D-Bus clients */
- if (!adapter->pdiscovery_requestor)
- adapter->discover_type &= ~RESOLVE_NAME;
+ if (!adapter->pdiscov_requestor)
+ adapter->discov_type &= ~RESOLVE_NAME;
return err;
}
void periodic_discover_req_exit(const char *name, struct adapter *adapter)
{
- debug("Periodic Discover requestor at %s exited before the operation finishes", name);
+ debug("PeriodicDiscovery requestor (%s) exited", name);
/*
- * Cleanup the discovered devices list and send the cmd to exit from periodic inquiry
- * or cancel remote name request. The return value can be ignored.
+ * Cleanup the discovered devices list and send the cmd to exit from
+ * periodic inquiry or cancel remote name request. The return value can
+ * be ignored.
*/
cancel_periodic_discovery(adapter);
@@ -2435,7 +2516,7 @@ int cancel_periodic_discovery(struct adapter *adapter)
struct slist *l;
int dd, err = 0;
- if (!adapter->pdisc_active)
+ if (!adapter->pdiscov_active)
goto cleanup;
dd = hci_open_dev(adapter->dev_id);
@@ -2448,25 +2529,29 @@ int cancel_periodic_discovery(struct adapter *adapter)
bacpy(&match.bdaddr, BDADDR_ANY);
match.name_status = NAME_REQUESTED;
- l = slist_find(adapter->disc_devices, &match, (cmp_func_t) disc_device_find);
+ l = slist_find(adapter->disc_devices, &match,
+ (cmp_func_t) disc_device_find);
if (l) {
dev = l->data;
if (remote_name_cancel(dd, &dev->bdaddr, 1000) < 0) {
- error("Read remote name cancel failed: %s, (%d)", strerror(errno), errno);
+ error("Read remote name cancel failed: %s, (%d)",
+ strerror(errno), errno);
err = -errno;
}
}
- /* ovewrite err if necessary: stop periodic inquiry has higher priority */
+ /* ovewrite err if necessary: stop periodic inquiry has higher
+ * priority */
if (periodic_inquiry_exit(dd, 1000) < 0) {
- error("Periodic Inquiry exit failed:%s (%d)", strerror(errno), errno);
+ error("Periodic Inquiry exit failed:%s (%d)",
+ strerror(errno), errno);
err = -errno;
}
hci_close_dev(dd);
cleanup:
/*
- * Reset pdiscovery_requestor and pdisc_active is done when the
+ * Reset pdiscov_requestor and pdiscov_active is done when the
* cmd complete event for exit periodic inquiry mode cmd arrives.
*/
slist_foreach(adapter->disc_devices, (slist_func_t) free, NULL);
diff --git a/hcid/dbus.h b/hcid/dbus.h
index 561f39b0..6235e50e 100644
--- a/hcid/dbus.h
+++ b/hcid/dbus.h
@@ -109,20 +109,20 @@ struct active_conn_info {
struct adapter {
uint16_t dev_id;
int up;
- char address[18]; /* adapter Bluetooth Address */
- uint32_t timeout_id; /* discoverable timeout id */
- uint32_t discoverable_timeout; /* discoverable time(msec) */
- uint8_t mode; /* scan mode */
- int disc_active; /* standard discovery active: includes name resolution step */
- int pdisc_active; /* periodic discovery active */
- int pinq_idle; /* tracks the idle time for periodic inquiry */
- int discover_type; /* type requested */
- int pdiscov_resolve_names; /* Resolve names when doing periodic discovery */
+ char address[18]; /* adapter Bluetooth Address */
+ uint32_t timeout_id; /* discoverable timeout id */
+ uint32_t discov_timeout; /* discoverable time(msec) */
+ uint8_t mode; /* scan mode */
+ int discov_active; /* standard discovery active: includes name resolution step */
+ int pdiscov_active; /* periodic discovery active */
+ int pinq_idle; /* tracks the idle time for periodic inquiry */
+ int discov_type; /* type requested */
+ int pdiscov_resolve_names; /* Resolve names when doing periodic discovery */
struct slist *disc_devices;
- struct slist *oor_devices; /* out of range device list */
- char *pdiscovery_requestor; /* periodic discovery requestor unique name */
- char *discovery_requestor; /* discovery requestor unique name */
- DBusMessage *discovery_cancel; /* discovery cancel message request */
+ struct slist *oor_devices; /* out of range device list */
+ char *pdiscov_requestor; /* periodic discovery requestor unique name */
+ char *discov_requestor; /* discovery requestor unique name */
+ DBusMessage *discovery_cancel; /* discovery cancel message request */
struct slist *passkey_agents;
struct slist *active_conn;
struct bonding_request_info *bonding;
@@ -258,7 +258,7 @@ int disc_device_find(const struct discovered_dev_info *d1, const struct discover
int disc_device_add(struct slist **list, bdaddr_t *bdaddr, int8_t rssi, name_status_t name_status);
int disc_device_req_name(struct adapter *dbus_data);
-int discoverable_timeout_handler(void *data);
+int discov_timeout_handler(void *data);
uint16_t sdp_str2svclass(const char *str);
typedef void get_record_cb_t(sdp_record_t *rec, void *data, int err);