@@ -143,11 +143,6 @@ static uint16_t bt_att_mtu(struct bt_att_chan *chan)
143
143
return MIN (chan -> chan .rx .mtu , chan -> chan .tx .mtu );
144
144
}
145
145
146
- /* Descriptor of application-specific authorization callbacks that are used
147
- * with the CONFIG_BT_GATT_AUTHORIZATION_CUSTOM Kconfig enabled.
148
- */
149
- static const struct bt_gatt_authorization_cb * authorization_cb ;
150
-
151
146
/* ATT connection specific data */
152
147
struct bt_att {
153
148
struct bt_conn * conn ;
@@ -1350,20 +1345,6 @@ struct read_type_data {
1350
1345
typedef bool (* attr_read_cb )(struct net_buf * buf , ssize_t read ,
1351
1346
void * user_data );
1352
1347
1353
- static bool attr_read_authorize (struct bt_conn * conn ,
1354
- const struct bt_gatt_attr * attr )
1355
- {
1356
- if (!IS_ENABLED (CONFIG_BT_GATT_AUTHORIZATION_CUSTOM )) {
1357
- return true;
1358
- }
1359
-
1360
- if (!authorization_cb || !authorization_cb -> read_authorize ) {
1361
- return true;
1362
- }
1363
-
1364
- return authorization_cb -> read_authorize (conn , attr );
1365
- }
1366
-
1367
1348
static bool attr_read_type_cb (struct net_buf * frag , ssize_t read ,
1368
1349
void * user_data )
1369
1350
{
@@ -1474,7 +1455,7 @@ static uint8_t read_type_cb(const struct bt_gatt_attr *attr, uint16_t handle,
1474
1455
}
1475
1456
1476
1457
/* Check the attribute authorization logic */
1477
- if (!attr_read_authorize (conn , attr )) {
1458
+ if (!bt_gatt_attr_read_authorize (conn , attr )) {
1478
1459
data -> err = BT_ATT_ERR_AUTHORIZATION ;
1479
1460
return BT_GATT_ITER_STOP ;
1480
1461
}
@@ -1630,7 +1611,7 @@ static uint8_t read_cb(const struct bt_gatt_attr *attr, uint16_t handle,
1630
1611
}
1631
1612
1632
1613
/* Check the attribute authorization logic */
1633
- if (!attr_read_authorize (conn , attr )) {
1614
+ if (!bt_gatt_attr_read_authorize (conn , attr )) {
1634
1615
data -> err = BT_ATT_ERR_AUTHORIZATION ;
1635
1616
return BT_GATT_ITER_STOP ;
1636
1617
}
@@ -1801,7 +1782,7 @@ static uint8_t read_vl_cb(const struct bt_gatt_attr *attr, uint16_t handle,
1801
1782
}
1802
1783
1803
1784
/* Check the attribute authorization logic */
1804
- if (!attr_read_authorize (conn , attr )) {
1785
+ if (!bt_gatt_attr_read_authorize (conn , attr )) {
1805
1786
data -> err = BT_ATT_ERR_AUTHORIZATION ;
1806
1787
return BT_GATT_ITER_STOP ;
1807
1788
}
@@ -2050,20 +2031,6 @@ struct write_data {
2050
2031
uint8_t err ;
2051
2032
};
2052
2033
2053
- static bool attr_write_authorize (struct bt_conn * conn ,
2054
- const struct bt_gatt_attr * attr )
2055
- {
2056
- if (!IS_ENABLED (CONFIG_BT_GATT_AUTHORIZATION_CUSTOM )) {
2057
- return true;
2058
- }
2059
-
2060
- if (!authorization_cb || !authorization_cb -> write_authorize ) {
2061
- return true;
2062
- }
2063
-
2064
- return authorization_cb -> write_authorize (conn , attr );
2065
- }
2066
-
2067
2034
static uint8_t write_cb (const struct bt_gatt_attr * attr , uint16_t handle ,
2068
2035
void * user_data )
2069
2036
{
@@ -2081,7 +2048,7 @@ static uint8_t write_cb(const struct bt_gatt_attr *attr, uint16_t handle,
2081
2048
}
2082
2049
2083
2050
/* Check the attribute authorization logic */
2084
- if (!attr_write_authorize (data -> conn , attr )) {
2051
+ if (!bt_gatt_attr_write_authorize (data -> conn , attr )) {
2085
2052
data -> err = BT_ATT_ERR_AUTHORIZATION ;
2086
2053
return BT_GATT_ITER_STOP ;
2087
2054
}
@@ -2200,7 +2167,7 @@ static uint8_t prep_write_cb(const struct bt_gatt_attr *attr, uint16_t handle,
2200
2167
}
2201
2168
2202
2169
/* Check the attribute authorization logic */
2203
- if (!attr_write_authorize (data -> conn , attr )) {
2170
+ if (!bt_gatt_attr_write_authorize (data -> conn , attr )) {
2204
2171
data -> err = BT_ATT_ERR_AUTHORIZATION ;
2205
2172
return BT_GATT_ITER_STOP ;
2206
2173
}
@@ -4169,23 +4136,3 @@ bool bt_att_chan_opt_valid(struct bt_conn *conn, enum bt_att_chan_opt chan_opt)
4169
4136
4170
4137
return true;
4171
4138
}
4172
-
4173
- int bt_gatt_authorization_cb_register (const struct bt_gatt_authorization_cb * cb )
4174
- {
4175
- if (!IS_ENABLED (CONFIG_BT_GATT_AUTHORIZATION_CUSTOM )) {
4176
- return - ENOSYS ;
4177
- }
4178
-
4179
- if (!cb ) {
4180
- authorization_cb = NULL ;
4181
- return 0 ;
4182
- }
4183
-
4184
- if (authorization_cb ) {
4185
- return - EALREADY ;
4186
- }
4187
-
4188
- authorization_cb = cb ;
4189
-
4190
- return 0 ;
4191
- }
0 commit comments