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