diff --git a/subsys/bluetooth/host/sdp.c b/subsys/bluetooth/host/sdp.c index 808f85b18d8..74ce4820af7 100644 --- a/subsys/bluetooth/host/sdp.c +++ b/subsys/bluetooth/host/sdp.c @@ -69,6 +69,8 @@ struct bt_sdp_client { uint16_t tid; /* UUID params holder being now resolved */ const struct bt_sdp_discover_params *param; + /* PDU continuation state object */ + struct bt_sdp_pdu_cstate cstate; }; static struct bt_sdp_client bt_sdp_client_pool[CONFIG_BLUETOOTH_MAX_CONN]; @@ -401,8 +403,19 @@ static int sdp_client_ssa_search(struct bt_sdp_client *session) net_buf_add_be16(buf, 0x0000); net_buf_add_be16(buf, 0xffff); - /* Initial continuation state octet */ - net_buf_add_u8(buf, 0x00); + /* + * Update and validate PDU ContinuationState. Initial SSA Request has + * zero length continuation state since no interaction has place with + * server so far, otherwise use the original state taken from remote's + * last response PDU that is cached by SDP client context. + */ + if (session->cstate.length == 0) { + net_buf_add_u8(buf, 0x00); + } else { + net_buf_add_u8(buf, session->cstate.length); + net_buf_add_mem(buf, session->cstate.data, + session->cstate.length); + } /* set overall PDU length */ hdr->param_len = sys_cpu_to_be16(buf->len - sizeof(*hdr)); diff --git a/subsys/bluetooth/host/sdp_internal.h b/subsys/bluetooth/host/sdp_internal.h index 112c8091fa9..f6356838c6e 100644 --- a/subsys/bluetooth/host/sdp_internal.h +++ b/subsys/bluetooth/host/sdp_internal.h @@ -56,4 +56,13 @@ struct bt_sdp_hdr { /* Allowed attributes length in SSA Request PDU to be taken from server */ #define BT_SDP_MAX_ATTR_LEN 0xffff +/* Max allowed length of PDU Continuation State */ +#define BT_SDP_MAX_PDU_CSTATE_LEN 16 + +/* Type mapping SDP PDU Continuation State */ +struct bt_sdp_pdu_cstate { + uint8_t length; + uint8_t data[BT_SDP_MAX_PDU_CSTATE_LEN]; +} __packed; + void bt_sdp_init(void);