sdp_server.c (cc643af3292c775e98d0a570c1f9597dc9476e04) | sdp_server.c (eb404cdcf0d85ca3e40db207902a8f49ad0a04e1) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 359 unchanged lines hidden (view full) --- 368static uint16_t sdp_get_size_for_service_search_attribute_response(uint8_t * serviceSearchPattern, uint8_t * attributeIDList){ 369 uint16_t total_response_size = 0; 370 btstack_linked_item_t *it; 371 for (it = (btstack_linked_item_t *) sdp_server_service_records; it ; it = it->next){ 372 service_record_item_t * item = (service_record_item_t *) it; 373 374 if (!sdp_record_matches_service_search_pattern(item->service_record, serviceSearchPattern)) continue; 375 | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 359 unchanged lines hidden (view full) --- 368static uint16_t sdp_get_size_for_service_search_attribute_response(uint8_t * serviceSearchPattern, uint8_t * attributeIDList){ 369 uint16_t total_response_size = 0; 370 btstack_linked_item_t *it; 371 for (it = (btstack_linked_item_t *) sdp_server_service_records; it ; it = it->next){ 372 service_record_item_t * item = (service_record_item_t *) it; 373 374 if (!sdp_record_matches_service_search_pattern(item->service_record, serviceSearchPattern)) continue; 375 |
376 // for all service records that match 377 total_response_size += 3 + sdp_get_filtered_size(item->service_record, attributeIDList); | 376 // for all service records that match, ignoring empty attribute lists 377 uint16_t filtered_size = sdp_get_filtered_size(item->service_record, attributeIDList); 378 if (filtered_size > 0){ 379 total_response_size += 3 + filtered_size; 380 } |
378 } 379 return total_response_size; 380} 381 382int sdp_handle_service_search_attribute_request(uint8_t * packet, uint16_t remote_mtu){ 383 | 381 } 382 return total_response_size; 383} 384 385int sdp_handle_service_search_attribute_request(uint8_t * packet, uint16_t remote_mtu){ 386 |
384 // SDP header before attribute sevice list: 7 | 387 // SDP header before attribute service list: 7 |
385 // Continuation, worst case: 5 386 387 // get request details 388 uint16_t transaction_id = big_endian_read_16(packet, 1); 389 uint16_t param_len = big_endian_read_16(packet, 3); 390 uint8_t * serviceSearchPattern = &packet[5]; 391 uint16_t serviceSearchPatternLen = de_get_len_safe(serviceSearchPattern, param_len); 392 if (sdp_valid_service_search_pattern(serviceSearchPattern) == false){ --- 58 unchanged lines hidden (view full) --- 451 452 if (current_service_index < continuation_service_index ) continue; 453 if (!sdp_record_matches_service_search_pattern(item->service_record, serviceSearchPattern)) continue; 454 455 if (continuation_offset == 0){ 456 457 // get size of this record 458 uint16_t filtered_attributes_size = sdp_get_filtered_size(item->service_record, attributeIDList); | 388 // Continuation, worst case: 5 389 390 // get request details 391 uint16_t transaction_id = big_endian_read_16(packet, 1); 392 uint16_t param_len = big_endian_read_16(packet, 3); 393 uint8_t * serviceSearchPattern = &packet[5]; 394 uint16_t serviceSearchPatternLen = de_get_len_safe(serviceSearchPattern, param_len); 395 if (sdp_valid_service_search_pattern(serviceSearchPattern) == false){ --- 58 unchanged lines hidden (view full) --- 454 455 if (current_service_index < continuation_service_index ) continue; 456 if (!sdp_record_matches_service_search_pattern(item->service_record, serviceSearchPattern)) continue; 457 458 if (continuation_offset == 0){ 459 460 // get size of this record 461 uint16_t filtered_attributes_size = sdp_get_filtered_size(item->service_record, attributeIDList); |
459 | 462 463 // ignore empty lists 464 if (filtered_attributes_size == 0) continue; 465 |
460 // stop if complete record doesn't fits into response but we already have a partial response 461 if (((filtered_attributes_size + 3) > maximumAttributeByteCount) && !first_answer) { 462 continuation = 1; 463 break; 464 } 465 466 // store DES 467 de_store_descriptor_with_len(&sdp_response_buffer[pos], DE_DES, DE_SIZE_VAR_16, filtered_attributes_size); --- 187 unchanged lines hidden --- | 466 // stop if complete record doesn't fits into response but we already have a partial response 467 if (((filtered_attributes_size + 3) > maximumAttributeByteCount) && !first_answer) { 468 continuation = 1; 469 break; 470 } 471 472 // store DES 473 de_store_descriptor_with_len(&sdp_response_buffer[pos], DE_DES, DE_SIZE_VAR_16, filtered_attributes_size); --- 187 unchanged lines hidden --- |