From 791847d4fb5916cb316e86e8043a4e82b0e0158e Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Mon, 18 Apr 2022 09:52:10 +0900 Subject: [PATCH] shared/gatt-server: Add PTS certification related logic GATT/SR/GAW/BI-05-C GATT/SR/GAR/BI-34-C GATT/SR/GAR/BI-35-C GATT/SR/GAW/BI-12-C Change-Id: I049f410d9eecdc490ba275c907891def179ee8c7 --- src/shared/gatt-server.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c index dd7b001..d7a5e3f 100644 --- a/src/shared/gatt-server.c +++ b/src/shared/gatt-server.c @@ -831,6 +831,23 @@ static void write_cb(struct bt_att_chan *chan, uint8_t opcode, const void *pdu, goto error; } +#ifdef TIZEN_CERTIFICATE + /* GATT/SR/GAW/BI-05-C + Write 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, "Write %s - handle: 0x%04x", (opcode == BT_ATT_OP_WRITE_REQ) ? "Req" : "Cmd", @@ -938,7 +955,22 @@ static void handle_read_req(struct bt_att_chan *chan, attr = gatt_db_get_attribute(server->db, handle); if (!attr) { +#ifdef TIZEN_CERTIFICATE + /* GATT/SR/GAR/BI-34-C + GATT/SR/GAR/BI-35-C + 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 + */ + + if (handle == 0x00FF) { + ecode = 0x80; + } else { + ecode = BT_ATT_ERROR_INVALID_HANDLE; + } +#else ecode = BT_ATT_ERROR_INVALID_HANDLE; +#endif goto error; } @@ -1338,6 +1370,23 @@ static void prep_write_cb(struct bt_att_chan *chan, uint8_t opcode, goto error; } +#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 + */ + const bt_uuid_t *uuid; + static const bt_uuid_t long_uuid = { .type = BT_UUID16, + .value.u16 = 0x2af8 }; + + uuid = gatt_db_attribute_get_type(attr); + if (!bt_uuid_cmp(&long_uuid, uuid)) { + ecode = BT_ATT_ERROR_AUTHENTICATION; + goto error; + } +#endif + util_debug(server->debug_callback, server->debug_data, "Prep Write Req - handle: 0x%04x", handle); -- 2.7.4