Lines Matching +full:cs +full:- +full:3
1 /*-
4 * SPDX-License-Identifier: BSD-2-Clause
47 #include "uuid-private.h"
56 uint8_t const *req = srv->req + sizeof(sdp_pdu_t);
57 uint8_t const *req_end = req + ((sdp_pdu_p)(srv->req))->len;
58 uint8_t *rsp = srv->fdidx[fd].rsp;
63 int32_t type, ssplen, rsp_limit, rcount, cslen, cs;
69 * seq8 len8 - 2 bytes
70 * uuid16 value16 - 3 bytes ServiceSearchPattern
71 * value16 - 2 bytes MaximumServiceRecordCount
72 * value8 - 1 byte ContinuationState
75 if (req_end - req < 8)
113 if (cslen != 2 || req_end - ptr != 2)
116 SDP_GET16(cs, ptr);
118 cs = 0;
121 if (srv->fdidx[fd].rsp_cs != cs)
123 if (srv->fdidx[fd].rsp_size > 0)
129 * value16 - 2 bytes TotalServiceRecordCount (not incl.)
130 * value16 - 2 bytes CurrentServiceRecordCount (not incl.)
131 * value32 - 4 bytes handle
139 rcount = (rsp_end - ptr) / 4;
146 ssplen --;
155 uuid.b[3] = *req ++;
156 ssplen -= 2;
167 uuid.b[3] = *req ++;
168 ssplen -= 4;
177 ssplen -= 16;
188 if (!provider_match_bdaddr(provider, &srv->req_sa.l2cap_bdaddr))
192 puuid.b[2] = provider->profile->uuid >> 8;
193 puuid.b[3] = provider->profile->uuid;
197 SDP_PUT32(provider->handle, ptr);
204 srv->fdidx[fd].rsp_limit = srv->fdidx[fd].omtu - sizeof(sdp_pdu_t) - 4;
205 srv->fdidx[fd].rsp_size = ptr - rsp;
206 srv->fdidx[fd].rsp_cs = 0;
218 uint8_t *rsp = srv->fdidx[fd].rsp + srv->fdidx[fd].rsp_cs;
219 uint8_t *rsp_end = srv->fdidx[fd].rsp + srv->fdidx[fd].rsp_size;
224 uint8_t cs[3];
228 size = rsp_end - rsp;
229 srv->fdidx[fd].rsp_cs += size;
231 if (size + 1 > srv->fdidx[fd].rsp_limit) {
233 * We need to split out response. Add 3 more bytes for the
237 while ((rsp_end - rsp) + 3 > srv->fdidx[fd].rsp_limit) {
238 rsp_end -= 4;
239 srv->fdidx[fd].rsp_cs -= 4;
242 cs[0] = 2;
243 cs[1] = srv->fdidx[fd].rsp_cs >> 8;
244 cs[2] = srv->fdidx[fd].rsp_cs & 0xff;
246 cs[0] = 0;
250 rcounts[0] = srv->fdidx[fd].rsp_size / 4; /* TotalServiceRecordCount */
251 rcounts[1] = (rsp_end - rsp) / 4; /* CurrentServiceRecordCount */
254 pdu.tid = ((sdp_pdu_p)(srv->req))->tid;
255 pdu.len = htons(sizeof(rcounts) + rcounts[1] * 4 + 1 + cs[0]);
267 iov[2].iov_len = rsp_end - rsp;
269 iov[3].iov_base = cs;
270 iov[3].iov_len = 1 + cs[0];
277 if (srv->fdidx[fd].rsp_cs == srv->fdidx[fd].rsp_size) {
278 srv->fdidx[fd].rsp_cs = 0;
279 srv->fdidx[fd].rsp_size = 0;
280 srv->fdidx[fd].rsp_limit = 0;