Skip to content

Commit

Permalink
Bluetooth: SDP: Start receiving response data on SDP PSM
Browse files Browse the repository at this point in the history
Adds handler responsible for receiving SDP data on SDP client request.
For now simple validation are done on SDP response header data.

Jira: ZEP-1112

Change-Id: Ic6009030db34e26dfdbd57fa1b0a22f6e27b6a11
Signed-off-by: Arkadiusz Lichwa <[email protected]>
  • Loading branch information
xpuarli authored and Johan Hedberg committed Dec 24, 2016
1 parent fa8a27f commit d460181
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions subsys/bluetooth/host/sdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,33 @@ int bt_sdp_register_service(struct bt_sdp_record *service)
return 0;
}

static void sdp_client_receive(struct bt_l2cap_chan *chan, struct net_buf *buf)
{
struct bt_sdp_client *session = SDP_CLIENT_CHAN(chan);
struct bt_sdp_hdr *hdr = (void *)buf->data;
uint16_t len, tid;

ARG_UNUSED(session);

BT_DBG("session %p buf %p", session, buf);

if (buf->len < sizeof(*hdr)) {
BT_ERR("Too small SDP PDU");
return;
}

len = sys_be16_to_cpu(hdr->param_len);
tid = sys_be16_to_cpu(hdr->tid);
net_buf_pull(buf, sizeof(*hdr));

BT_DBG("SDP PDU tid %u len %u", tid, len);

if (buf->len != len) {
BT_ERR("SDP PDU length mismatch (%u != %u)", buf->len, len);
return;
}
}

static int sdp_client_chan_connect(struct bt_sdp_client *session)
{
return bt_l2cap_br_chan_connect(session->chan.chan.conn,
Expand Down Expand Up @@ -350,6 +377,7 @@ static void sdp_client_disconnected(struct bt_l2cap_chan *chan)
static struct bt_l2cap_chan_ops sdp_client_chan_ops = {
.connected = sdp_client_connected,
.disconnected = sdp_client_disconnected,
.recv = sdp_client_receive,
};

static struct bt_sdp_client *sdp_client_new_session(struct bt_conn *conn)
Expand Down

0 comments on commit d460181

Please sign in to comment.