attrib: Fix naming and variable types of security requirements

There's a single read/write requirement value so the variables should be
named in singular form. Also, until there's e.g. an enum typedef for
them a simple int shall do.
This commit is contained in:
Johan Hedberg 2012-08-15 18:20:09 +03:00
parent 2b44cd2fba
commit 46c59677c2
4 changed files with 24 additions and 24 deletions

View File

@ -31,8 +31,8 @@ enum {
struct attribute {
uint16_t handle;
bt_uuid_t uuid;
size_t read_reqs;
size_t write_reqs;
int read_req; /* Read requirement */
int write_req; /* Write requirement */
uint8_t (*read_cb)(struct attribute *a, struct btd_device *device,
gpointer user_data);
uint8_t (*write_cb)(struct attribute *a, struct btd_device *device,

View File

@ -139,7 +139,7 @@ static struct attribute *add_service_declaration(struct btd_adapter *adapter,
ATT_NOT_PERMITTED, atval, len);
}
static int att_read_reqs(int authorization, int authentication, uint8_t props)
static int att_read_req(int authorization, int authentication, uint8_t props)
{
if (authorization == GATT_CHR_VALUE_READ ||
authorization == GATT_CHR_VALUE_BOTH)
@ -153,7 +153,7 @@ static int att_read_reqs(int authorization, int authentication, uint8_t props)
return ATT_NONE;
}
static int att_write_reqs(int authorization, int authentication, uint8_t props)
static int att_write_req(int authorization, int authentication, uint8_t props)
{
if (authorization == GATT_CHR_VALUE_WRITE ||
authorization == GATT_CHR_VALUE_BOTH)
@ -179,7 +179,7 @@ static gint find_callback(gconstpointer a, gconstpointer b)
static gboolean add_characteristic(struct btd_adapter *adapter,
uint16_t *handle, struct gatt_info *info)
{
int read_reqs, write_reqs;
int read_req, write_req;
uint16_t h = *handle;
struct attribute *a;
bt_uuid_t bt_uuid;
@ -191,14 +191,14 @@ static gboolean add_characteristic(struct btd_adapter *adapter,
return FALSE;
}
read_reqs = att_read_reqs(info->authorization, info->authentication,
read_req = att_read_req(info->authorization, info->authentication,
info->props);
write_reqs = att_write_reqs(info->authorization, info->authentication,
write_req = att_write_req(info->authorization, info->authentication,
info->props);
/* TODO: static characteristic values are not supported, therefore a
* callback must be always provided if a read/write property is set */
if (read_reqs != ATT_NOT_PERMITTED) {
if (read_req != ATT_NOT_PERMITTED) {
gpointer reqs = GUINT_TO_POINTER(ATTRIB_READ);
if (!g_slist_find_custom(info->callbacks, reqs,
@ -208,7 +208,7 @@ static gboolean add_characteristic(struct btd_adapter *adapter,
}
}
if (write_reqs != ATT_NOT_PERMITTED) {
if (write_req != ATT_NOT_PERMITTED) {
gpointer reqs = GUINT_TO_POINTER(ATTRIB_WRITE);
if (!g_slist_find_custom(info->callbacks, reqs,
@ -228,7 +228,7 @@ static gboolean add_characteristic(struct btd_adapter *adapter,
return FALSE;
/* characteristic value */
a = attrib_db_add(adapter, h++, &info->uuid, read_reqs, write_reqs,
a = attrib_db_add(adapter, h++, &info->uuid, read_req, write_req,
NULL, 0);
if (a == NULL)
return FALSE;

View File

@ -339,7 +339,7 @@ static uint32_t attrib_create_sdp_new(struct gatt_server *server,
static struct attribute *attrib_db_add_new(struct gatt_server *server,
uint16_t handle, bt_uuid_t *uuid,
size_t read_reqs, size_t write_reqs,
int read_req, int write_req,
const uint8_t *value, size_t len)
{
struct attribute *a;
@ -356,8 +356,8 @@ static struct attribute *attrib_db_add_new(struct gatt_server *server,
a->data = g_memdup(value, len);
a->handle = handle;
a->uuid = *uuid;
a->read_reqs = read_reqs;
a->write_reqs = write_reqs;
a->read_req = read_req;
a->write_req = write_req;
server->database = g_list_insert_sorted(server->database, a,
attribute_cmp);
@ -456,7 +456,7 @@ static uint16_t read_by_group(struct gatt_channel *channel, uint16_t start,
break;
status = att_check_reqs(channel, ATT_OP_READ_BY_GROUP_REQ,
a->read_reqs);
a->read_req);
if (status == 0x00 && a->read_cb)
status = a->read_cb(a, channel->device,
@ -546,7 +546,7 @@ static uint16_t read_by_type(struct gatt_channel *channel, uint16_t start,
continue;
status = att_check_reqs(channel, ATT_OP_READ_BY_TYPE_REQ,
a->read_reqs);
a->read_req);
if (status == 0x00 && a->read_cb)
status = a->read_cb(a, channel->device,
@ -763,7 +763,7 @@ static uint16_t read_value(struct gatt_channel *channel, uint16_t handle,
return enc_read_resp(config, sizeof(config), pdu, len);
}
status = att_check_reqs(channel, ATT_OP_READ_REQ, a->read_reqs);
status = att_check_reqs(channel, ATT_OP_READ_REQ, a->read_req);
if (status == 0x00 && a->read_cb)
status = a->read_cb(a, channel->device, a->cb_user_data);
@ -809,7 +809,7 @@ static uint16_t read_blob(struct gatt_channel *channel, uint16_t handle,
pdu, len);
}
status = att_check_reqs(channel, ATT_OP_READ_BLOB_REQ, a->read_reqs);
status = att_check_reqs(channel, ATT_OP_READ_BLOB_REQ, a->read_req);
if (status == 0x00 && a->read_cb)
status = a->read_cb(a, channel->device, a->cb_user_data);
@ -838,7 +838,7 @@ static uint16_t write_value(struct gatt_channel *channel, uint16_t handle,
a = l->data;
status = att_check_reqs(channel, ATT_OP_WRITE_REQ, a->write_reqs);
status = att_check_reqs(channel, ATT_OP_WRITE_REQ, a->write_req);
if (status)
return enc_error_resp(ATT_OP_WRITE_REQ, handle, status, pdu,
len);
@ -1431,9 +1431,9 @@ uint16_t attrib_db_find_avail(struct btd_adapter *adapter, bt_uuid_t *svc_uuid,
}
struct attribute *attrib_db_add(struct btd_adapter *adapter, uint16_t handle,
bt_uuid_t *uuid, size_t read_reqs,
size_t write_reqs,
const uint8_t *value, size_t len)
bt_uuid_t *uuid, int read_req,
int write_req, const uint8_t *value,
size_t len)
{
GSList *l;
@ -1441,7 +1441,7 @@ struct attribute *attrib_db_add(struct btd_adapter *adapter, uint16_t handle,
if (l == NULL)
return NULL;
return attrib_db_add_new(l->data, handle, uuid, read_reqs, write_reqs,
return attrib_db_add_new(l->data, handle, uuid, read_req, write_req,
value, len);
}

View File

@ -25,8 +25,8 @@
uint16_t attrib_db_find_avail(struct btd_adapter *adapter, bt_uuid_t *svc_uuid,
uint16_t nitems);
struct attribute *attrib_db_add(struct btd_adapter *adapter, uint16_t handle,
bt_uuid_t *uuid, size_t read_reqs,
size_t write_reqs, const uint8_t *value,
bt_uuid_t *uuid, int read_req,
int write_req, const uint8_t *value,
size_t len);
int attrib_db_update(struct btd_adapter *adapter, uint16_t handle,
bt_uuid_t *uuid, const uint8_t *value,