From: Wootak Jung Date: Mon, 9 May 2022 01:31:26 +0000 (+0900) Subject: shared/gatt-server: Add PTS certification logic X-Git-Tag: submit/tizen/20220531.044319~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F49%2F274749%2F1;p=platform%2Fupstream%2Fbluez.git shared/gatt-server: Add PTS certification logic GATT/CL/GAI/BI-01-C GATT/SR/GAR/BI-04-C GATT/SR/GAR/BI-10-C GATT/SR/GAW/BI-12-C Change-Id: I4fce46e7f2ea669b445767b597d0a6475e71381f --- diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c index d7a5e3f..733a21d 100644 --- a/src/shared/gatt-server.c +++ b/src/shared/gatt-server.c @@ -512,6 +512,12 @@ static void read_by_type_cb(struct bt_att_chan *chan, uint8_t opcode, gatt_db_read_by_type(server->db, start, end, type, q); if (queue_isempty(q)) { +#ifdef TIZEN_CERTIFICATE + if (start == 0x00ff && end == 0x00ff) { + ecode = BT_ATT_ERROR_AUTHENTICATION; + goto error; + } +#endif ecode = BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND; goto error; } @@ -961,10 +967,27 @@ static void handle_read_req(struct bt_att_chan *chan, Read Characteristic Value - Invalid Transport Access over LE or BR/EDR (0x80) For 0x00FF UUID, return Invalid Transport Access Error We need to register 0x00FF UUID for this + + GATT/SR/GAR/BI-04-C + Read Characteristic Value . Insufficient Authentication (0x05) + For 0x2aff UUID, return authentication error + We need to register 0x2aff UUID for this */ + const bt_uuid_t *uuid; + char uuidstr[MAX_LEN_UUID_STR + 1]; + + static const bt_uuid_t error_uuid = { .type = BT_UUID16, + .value.u16 = 0x2aff }; + + uuid = gatt_db_attribute_get_type(attr); + + bt_uuid_to_string(uuid, uuidstr, sizeof(uuidstr)); + if (handle == 0x00FF) { ecode = 0x80; + } else if (!bt_uuid_cmp(&error_uuid, uuid)) { + ecode = BT_ATT_ERROR_AUTHENTICATION; } else { ecode = BT_ATT_ERROR_INVALID_HANDLE; } @@ -974,6 +997,24 @@ static void handle_read_req(struct bt_att_chan *chan, goto error; } +#ifdef TIZEN_CERTIFICATE + /* GATT/SR/GAR/BI-04-C + Read Characteristic Value . Insufficient Authentication (0x05) + For 0x2AFF UUID, return authentication error + We need to register 0x2aff UUID for this + + */ + const bt_uuid_t *uuid; + static const bt_uuid_t error_uuid = { .type = BT_UUID16, + .value.u16 = 0x2aff }; + + uuid = gatt_db_attribute_get_type(attr); + if (!bt_uuid_cmp(&error_uuid, uuid)) { + ecode = BT_ATT_ERROR_AUTHENTICATION; + goto error; + } +#endif + util_debug(server->debug_callback, server->debug_data, "Read %sReq - handle: 0x%04x", opcode == BT_ATT_OP_READ_BLOB_REQ ? "Blob " : "", @@ -1373,15 +1414,17 @@ static void prep_write_cb(struct bt_att_chan *chan, uint8_t opcode, #ifdef TIZEN_CERTIFICATE /* GATT/SR/GAW/BI-12-C Write Long Characteristic Value - Insufficient Authentication (0x05) - For 0x2af8 UUID, return authentication error - We need to register 0x2af8 UUID for this + For 0x2af8 or 0x2aff UUID, return authentication error + We need to register 0x2af8 or 0x2aff UUID for this */ const bt_uuid_t *uuid; static const bt_uuid_t long_uuid = { .type = BT_UUID16, .value.u16 = 0x2af8 }; + static const bt_uuid_t error_uuid = { .type = BT_UUID16, + .value.u16 = 0x2aff }; uuid = gatt_db_attribute_get_type(attr); - if (!bt_uuid_cmp(&long_uuid, uuid)) { + if (!bt_uuid_cmp(&long_uuid, uuid) || !bt_uuid_cmp(&error_uuid, uuid)) { ecode = BT_ATT_ERROR_AUTHENTICATION; goto error; }