Skip to content

Commit

Permalink
Bluetooth: Host: SDP: Fix endianness issue of tid
Browse files Browse the repository at this point in the history
The transfer byte order of SDP is big-endian.

The transaction ID(tid) should be big-endian before
sending.

And tid needs to be converted to CPU byte order
after receiving.

Signed-off-by: Lyle Zhu <[email protected]>
  • Loading branch information
lylezhu2012 committed Feb 27, 2024
1 parent 1a3bb3f commit d553efc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions subsys/bluetooth/host/sdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ static int bt_sdp_send(struct bt_l2cap_chan *chan, struct net_buf *buf,

hdr = net_buf_push(buf, sizeof(struct bt_sdp_hdr));
hdr->op_code = op;
hdr->tid = tid;
hdr->tid = sys_cpu_to_be16(tid);
hdr->param_len = sys_cpu_to_be16(param_len);

err = bt_l2cap_chan_send(chan, buf);
Expand Down Expand Up @@ -1366,14 +1366,14 @@ static int bt_sdp_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
continue;
}

err = handlers[i].func(sdp, buf, hdr->tid);
err = handlers[i].func(sdp, buf, sys_be16_to_cpu(hdr->tid));
break;
}
}

if (err) {
LOG_WRN("SDP error 0x%02x", err);
send_err_rsp(chan, err, hdr->tid);
send_err_rsp(chan, err, sys_be16_to_cpu(hdr->tid));
}

return 0;
Expand Down

0 comments on commit d553efc

Please sign in to comment.