Skip to content

Commit 027a56d

Browse files
piotrnarajowskisjanc
authored andcommitted
nimble/host: move att_truncate_to_mtu to ble_att_svr_tx_rsp
Move att_truncate_to_mtu from ble_eatt_tx to ble_att_svr_tx_rsp. This could cause some issues when used by client.
1 parent 1fa9dfd commit 027a56d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

nimble/host/src/ble_att_svr.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,8 @@ static int
625625
ble_att_svr_tx_rsp(uint16_t conn_handle, uint16_t cid, int hs_status, struct os_mbuf *om,
626626
uint8_t att_op, uint8_t err_status, uint16_t err_handle)
627627
{
628+
struct ble_l2cap_chan *chan;
629+
struct ble_hs_conn *conn;
628630
int do_tx;
629631

630632
if (hs_status != 0 && err_status == 0) {
@@ -636,13 +638,32 @@ ble_att_svr_tx_rsp(uint16_t conn_handle, uint16_t cid, int hs_status, struct os_
636638

637639
if (do_tx) {
638640
if (hs_status == 0) {
641+
ble_hs_lock();
642+
conn = ble_hs_conn_find(conn_handle);
643+
if (conn == NULL) {
644+
hs_status = BLE_HS_ENOTCONN;
645+
ble_hs_unlock();
646+
goto done;
647+
}
648+
649+
chan = ble_hs_conn_chan_find_by_scid(conn, cid);
650+
if (chan == NULL) {
651+
hs_status = BLE_HS_ENOENT;
652+
ble_hs_unlock();
653+
goto done;
654+
}
655+
656+
ble_att_truncate_to_mtu(chan, om);
657+
ble_hs_unlock();
658+
639659
hs_status = ble_att_tx(conn_handle, cid, om);
640660
om = NULL;
641661
if (hs_status) {
642662
err_status = BLE_ATT_ERR_UNLIKELY;
643663
}
644664
}
645665

666+
done:
646667
if (hs_status != 0) {
647668
STATS_INC(ble_att_stats, error_rsp_tx);
648669

nimble/host/src/ble_eatt.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,6 @@ ble_eatt_tx(uint16_t conn_handle, uint16_t cid, struct os_mbuf *txom)
476476
goto error;
477477
}
478478

479-
ble_att_truncate_to_mtu(eatt->chan, txom);
480-
481479
rc = ble_l2cap_send(eatt->chan, txom);
482480
if (rc == 0) {
483481
goto done;

0 commit comments

Comments
 (0)