summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArman Uguray <armansito@chromium.org>2014-10-13 14:09:59 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-10-20 15:02:34 +0300
commite12e7698b226c0547725c0282ccd843ebd0a6d17 (patch)
tree53035b5ad63f2cb2ddab370fa93efd111a251c6c /src
parenta95a75483158d00dcce2f7c724175aefa8783f17 (diff)
downloadbluez-e12e7698b226c0547725c0282ccd843ebd0a6d17.tar.gz
shared/att: Fix not responding to some requests
With this patch bt_att automatically responds with ERROR_REQUEST_NOT_SUPPORTED to an incoming request for which no handler has been registered via bt_att_register.
Diffstat (limited to 'src')
-rw-r--r--src/shared/att.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/shared/att.c b/src/shared/att.c
index 63cd19ba0..503e06ced 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
@@ -562,6 +562,7 @@ struct notify_data {
uint8_t opcode;
uint8_t *pdu;
ssize_t pdu_len;
+ bool handler_found;
};
static void notify_handler(void *data, void *user_data)
@@ -575,11 +576,26 @@ static void notify_handler(void *data, void *user_data)
if (notify->opcode != not_data->opcode)
return;
+ not_data->handler_found = true;
+
if (notify->callback)
notify->callback(not_data->opcode, not_data->pdu,
not_data->pdu_len, notify->user_data);
}
+static void respond_not_supported(struct bt_att *att, uint8_t opcode)
+{
+ uint8_t pdu[4];
+
+ pdu[0] = opcode;
+ pdu[1] = 0;
+ pdu[2] = 0;
+ pdu[3] = BT_ATT_ERROR_REQUEST_NOT_SUPPORTED;
+
+ bt_att_send(att, BT_ATT_OP_ERROR_RSP, pdu, sizeof(pdu), NULL, NULL,
+ NULL);
+}
+
static void handle_notify(struct bt_att *att, uint8_t opcode, uint8_t *pdu,
ssize_t pdu_len)
{
@@ -607,6 +623,13 @@ static void handle_notify(struct bt_att *att, uint8_t opcode, uint8_t *pdu,
}
bt_att_unref(att);
+
+ /*
+ * If this was a request and no handler was registered for it, respond
+ * with "Not Supported"
+ */
+ if (!data.handler_found && get_op_type(opcode) == ATT_OP_TYPE_REQ)
+ respond_not_supported(att, opcode);
}
static void disconn_handler(void *data, void *user_data)