Skip to content

Commit

Permalink
shared/att: Add own security definitions
Browse files Browse the repository at this point in the history
This defines security level at ATT level so it is not necessary to use
transport specific defines.
  • Loading branch information
Vudentz committed Apr 28, 2015
1 parent 758c4eb commit 4f41086
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/shared/att-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
#define __packed __attribute__((packed))
#endif

#define BT_ATT_SECURITY_NONE 0
#define BT_ATT_SECURITY_LOW 1
#define BT_ATT_SECURITY_MEDIUM 2
#define BT_ATT_SECURITY_HIGH 3

#define BT_ATT_DEFAULT_LE_MTU 23
#define BT_ATT_MAX_LE_MTU 517
#define BT_ATT_MAX_VALUE_LEN 512
Expand Down
2 changes: 1 addition & 1 deletion src/shared/att.c
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ bool bt_att_set_sec_level(struct bt_att *att, int level)
{
struct bt_security sec;

if (!att || level < BT_SECURITY_LOW || level > BT_SECURITY_HIGH)
if (!att || level < BT_ATT_SECURITY_LOW || level > BT_ATT_SECURITY_HIGH)
return false;

if (!att->io_on_l2cap) {
Expand Down
2 changes: 1 addition & 1 deletion unit/test-gatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ static void test_signed_write_seclevel(struct context *context)
g_assert(bt_att_set_local_key(context->att, key, local_counter,
context));

g_assert(bt_att_set_sec_level(context->att, BT_SECURITY_MEDIUM));
g_assert(bt_att_set_sec_level(context->att, BT_ATT_SECURITY_MEDIUM));

g_assert(bt_gatt_client_write_without_response(context->client,
step->handle,
Expand Down

0 comments on commit 4f41086

Please sign in to comment.