Lines Matching +full:cs +full:- +full:2
1 /*-
4 * SPDX-License-Identifier: BSD-2-Clause
14 * 2. Redistributions in binary form must reproduce the above copyright
52 * uint16 value16 - 3 bytes (attribute)
53 * value - N bytes (value)
61 profile_attr_create_p cf = profile_get_attr(provider->profile, attr); in server_prepare_attr_value_pair()
68 return (-1); in server_prepare_attr_value_pair()
75 return (-1); in server_prepare_attr_value_pair()
81 * seq16 value16 - 3 bytes
82 * attr value - 3+ bytes
95 return (-1); in server_prepare_attr_list()
102 if (req + 2 > req_end) in server_prepare_attr_list()
103 return (-1); in server_prepare_attr_list()
111 return (-1); in server_prepare_attr_list()
118 return (-1); in server_prepare_attr_list()
125 return (-1); in server_prepare_attr_list()
131 len = ptr - rsp; /* we put this much bytes in rsp */ in server_prepare_attr_list()
135 SDP_PUT16(len - 3, rsp); in server_prepare_attr_list()
147 uint8_t const *req = srv->req + sizeof(sdp_pdu_t); in server_prepare_service_attribute_response()
148 uint8_t const *req_end = req + ((sdp_pdu_p)(srv->req))->len; in server_prepare_service_attribute_response()
149 uint8_t *rsp = srv->fdidx[fd].rsp; in server_prepare_service_attribute_response()
155 int32_t type, rsp_limit, aidlen, cslen, cs; in server_prepare_service_attribute_response() local
160 * value32 - 4 bytes ServiceRecordHandle in server_prepare_service_attribute_response()
161 * value16 - 2 bytes MaximumAttributeByteCount in server_prepare_service_attribute_response()
162 * seq8 len8 - 2 bytes in server_prepare_service_attribute_response()
163 * uint16 value16 - 3 bytes AttributeIDList in server_prepare_service_attribute_response()
164 * value8 - 1 byte ContinuationState in server_prepare_service_attribute_response()
167 if (req_end - req < 12) in server_prepare_service_attribute_response()
203 if (cslen != 2 || req_end - ptr != 2) in server_prepare_service_attribute_response()
206 SDP_GET16(cs, ptr); in server_prepare_service_attribute_response()
208 cs = 0; in server_prepare_service_attribute_response()
211 if (srv->fdidx[fd].rsp_cs != cs) in server_prepare_service_attribute_response()
213 if (srv->fdidx[fd].rsp_size > 0) in server_prepare_service_attribute_response()
223 * value16 - 2 bytes AttributeListByteCount (not incl.) in server_prepare_service_attribute_response()
224 * seq8 len16 - 3 bytes in server_prepare_service_attribute_response()
225 * attr value - 3+ bytes AttributeList in server_prepare_service_attribute_response()
229 cs = server_prepare_attr_list(provider, req, req+aidlen, rsp, rsp_end); in server_prepare_service_attribute_response()
230 if (cs < 0) in server_prepare_service_attribute_response()
234 srv->fdidx[fd].rsp_limit = srv->fdidx[fd].omtu - sizeof(sdp_pdu_t) - 2; in server_prepare_service_attribute_response()
235 if (srv->fdidx[fd].rsp_limit > rsp_limit) in server_prepare_service_attribute_response()
236 srv->fdidx[fd].rsp_limit = rsp_limit; in server_prepare_service_attribute_response()
238 srv->fdidx[fd].rsp_size = cs; in server_prepare_service_attribute_response()
239 srv->fdidx[fd].rsp_cs = 0; in server_prepare_service_attribute_response()
251 uint8_t *rsp = srv->fdidx[fd].rsp + srv->fdidx[fd].rsp_cs; in server_send_service_attribute_response()
252 uint8_t *rsp_end = srv->fdidx[fd].rsp + srv->fdidx[fd].rsp_size; in server_send_service_attribute_response()
257 uint8_t cs[3]; in server_send_service_attribute_response() local
261 size = rsp_end - rsp; in server_send_service_attribute_response()
262 srv->fdidx[fd].rsp_cs += size; in server_send_service_attribute_response()
264 if (size + 1 > srv->fdidx[fd].rsp_limit) { in server_send_service_attribute_response()
270 while ((rsp_end - rsp) + 3 > srv->fdidx[fd].rsp_limit) { in server_send_service_attribute_response()
271 rsp_end --; in server_send_service_attribute_response()
272 srv->fdidx[fd].rsp_cs --; in server_send_service_attribute_response()
275 cs[0] = 2; in server_send_service_attribute_response()
276 cs[1] = srv->fdidx[fd].rsp_cs >> 8; in server_send_service_attribute_response()
277 cs[2] = srv->fdidx[fd].rsp_cs & 0xff; in server_send_service_attribute_response()
279 cs[0] = 0; in server_send_service_attribute_response()
283 bcount = rsp_end - rsp; in server_send_service_attribute_response()
285 if (((sdp_pdu_p)(srv->req))->pid == SDP_PDU_SERVICE_ATTRIBUTE_REQUEST) in server_send_service_attribute_response()
290 pdu.tid = ((sdp_pdu_p)(srv->req))->tid; in server_send_service_attribute_response()
291 pdu.len = htons(sizeof(bcount) + bcount + 1 + cs[0]); in server_send_service_attribute_response()
301 iov[2].iov_base = rsp; in server_send_service_attribute_response()
302 iov[2].iov_len = rsp_end - rsp; in server_send_service_attribute_response()
304 iov[3].iov_base = cs; in server_send_service_attribute_response()
305 iov[3].iov_len = 1 + cs[0]; in server_send_service_attribute_response()
312 if (srv->fdidx[fd].rsp_cs == srv->fdidx[fd].rsp_size) { in server_send_service_attribute_response()
313 srv->fdidx[fd].rsp_cs = 0; in server_send_service_attribute_response()
314 srv->fdidx[fd].rsp_size = 0; in server_send_service_attribute_response()
315 srv->fdidx[fd].rsp_limit = 0; in server_send_service_attribute_response()