sdp_server.c (db96503f81968bb4478d64830e25280e64f0c492) | sdp_server.c (22d58ff8de23f4f8df27e78fade3aa864f1db00c) |
---|---|
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 --- 70 unchanged lines hidden (view full) --- 79 80static uint8_t sdp_response_buffer[SDP_RESPONSE_BUFFER_SIZE]; 81 82static uint16_t sdp_server_l2cap_cid; 83static uint16_t sdp_server_response_size; 84static uint16_t sdp_server_l2cap_waiting_list_cids[SDP_WAITING_LIST_MAX_COUNT]; 85static int sdp_server_l2cap_waiting_list_count; 86 | 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 --- 70 unchanged lines hidden (view full) --- 79 80static uint8_t sdp_response_buffer[SDP_RESPONSE_BUFFER_SIZE]; 81 82static uint16_t sdp_server_l2cap_cid; 83static uint16_t sdp_server_response_size; 84static uint16_t sdp_server_l2cap_waiting_list_cids[SDP_WAITING_LIST_MAX_COUNT]; 85static int sdp_server_l2cap_waiting_list_count; 86 |
87#ifdef ENABLE_TESTING_SUPPORT 88static bool sdp_server_testing_single_record_reponse = false; 89#endif 90 |
|
87void sdp_init(void){ 88 sdp_server_next_service_record_handle = ((uint32_t) MAX_RESERVED_SERVICE_RECORD_HANDLE) + 2; 89 // register with l2cap psm sevices - max MTU 90 l2cap_register_service(sdp_packet_handler, BLUETOOTH_PSM_SDP, 0xffff, LEVEL_0); 91} 92 93void sdp_deinit(void){ 94 sdp_server_service_records = NULL; --- 105 unchanged lines hidden (view full) --- 200 // assert continuation state len is contained in param_len 201 if (param_len < 1) return 0; 202 uint8_t * continuationState = &packet[5+serviceSearchPatternLen+2]; 203 // assert continuation state is contained in param_len 204 if ((1 + continuationState[0]) > param_len) return 0; 205 206 // calc maximumServiceRecordCount based on remote MTU 207 uint16_t maxNrServiceRecordsPerResponse = (remote_mtu - (9+3))/4; | 91void sdp_init(void){ 92 sdp_server_next_service_record_handle = ((uint32_t) MAX_RESERVED_SERVICE_RECORD_HANDLE) + 2; 93 // register with l2cap psm sevices - max MTU 94 l2cap_register_service(sdp_packet_handler, BLUETOOTH_PSM_SDP, 0xffff, LEVEL_0); 95} 96 97void sdp_deinit(void){ 98 sdp_server_service_records = NULL; --- 105 unchanged lines hidden (view full) --- 204 // assert continuation state len is contained in param_len 205 if (param_len < 1) return 0; 206 uint8_t * continuationState = &packet[5+serviceSearchPatternLen+2]; 207 // assert continuation state is contained in param_len 208 if ((1 + continuationState[0]) > param_len) return 0; 209 210 // calc maximumServiceRecordCount based on remote MTU 211 uint16_t maxNrServiceRecordsPerResponse = (remote_mtu - (9+3))/4; |
208 | 212#ifdef ENABLE_TESTING_SUPPORT 213 if (sdp_server_testing_single_record_reponse){ 214 maxNrServiceRecordsPerResponse = 1; 215 } 216#endif 217 |
209 // continuation state contains index of next service record to examine 210 int continuation = 0; 211 uint16_t continuation_index = 0; 212 if (continuationState[0] == 2){ 213 continuation_index = big_endian_read_16(continuationState, 1); 214 } 215 216 // get and limit total count --- 77 unchanged lines hidden (view full) --- 294 // assert continuation state is contained in param_len 295 if ((1 + continuationState[0]) > param_len) return 0; 296 297 // calc maximumAttributeByteCount based on remote MTU 298 uint16_t maximumAttributeByteCount2 = remote_mtu - (7+3); 299 if (maximumAttributeByteCount2 < maximumAttributeByteCount) { 300 maximumAttributeByteCount = maximumAttributeByteCount2; 301 } | 218 // continuation state contains index of next service record to examine 219 int continuation = 0; 220 uint16_t continuation_index = 0; 221 if (continuationState[0] == 2){ 222 continuation_index = big_endian_read_16(continuationState, 1); 223 } 224 225 // get and limit total count --- 77 unchanged lines hidden (view full) --- 303 // assert continuation state is contained in param_len 304 if ((1 + continuationState[0]) > param_len) return 0; 305 306 // calc maximumAttributeByteCount based on remote MTU 307 uint16_t maximumAttributeByteCount2 = remote_mtu - (7+3); 308 if (maximumAttributeByteCount2 < maximumAttributeByteCount) { 309 maximumAttributeByteCount = maximumAttributeByteCount2; 310 } |
302 | 311 |
303 // continuation state contains the offset into the complete response 304 uint16_t continuation_offset = 0; 305 if (continuationState[0] == 2){ 306 continuation_offset = big_endian_read_16(continuationState, 1); 307 } 308 309 // get service record 310 service_record_item_t * item = sdp_get_record_item_for_handle(serviceRecordHandle); --- 316 unchanged lines hidden (view full) --- 627 break; 628 629 default: 630 // other packet type 631 break; 632 } 633} 634 | 312 // continuation state contains the offset into the complete response 313 uint16_t continuation_offset = 0; 314 if (continuationState[0] == 2){ 315 continuation_offset = big_endian_read_16(continuationState, 1); 316 } 317 318 // get service record 319 service_record_item_t * item = sdp_get_record_item_for_handle(serviceRecordHandle); --- 316 unchanged lines hidden (view full) --- 636 break; 637 638 default: 639 // other packet type 640 break; 641 } 642} 643 |
644#ifdef ENABLE_TESTING_SUPPORT 645void sdp_server_set_single_record_response(bool enable){ 646 sdp_server_testing_single_record_reponse = enable; 647} 648#endif |
|