1746ccb7eSMatthias Ringwald /* 2746ccb7eSMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH 3746ccb7eSMatthias Ringwald * 4746ccb7eSMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5746ccb7eSMatthias Ringwald * modification, are permitted provided that the following conditions 6746ccb7eSMatthias Ringwald * are met: 7746ccb7eSMatthias Ringwald * 8746ccb7eSMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9746ccb7eSMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10746ccb7eSMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11746ccb7eSMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12746ccb7eSMatthias Ringwald * documentation and/or other materials provided with the distribution. 13746ccb7eSMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14746ccb7eSMatthias Ringwald * contributors may be used to endorse or promote products derived 15746ccb7eSMatthias Ringwald * from this software without specific prior written permission. 16746ccb7eSMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 17746ccb7eSMatthias Ringwald * personal benefit and not for any commercial purpose or for 18746ccb7eSMatthias Ringwald * monetary gain. 19746ccb7eSMatthias Ringwald * 20746ccb7eSMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21746ccb7eSMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22746ccb7eSMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 232fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 242fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25746ccb7eSMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26746ccb7eSMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27746ccb7eSMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28746ccb7eSMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29746ccb7eSMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30746ccb7eSMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31746ccb7eSMatthias Ringwald * SUCH DAMAGE. 32746ccb7eSMatthias Ringwald * 33746ccb7eSMatthias Ringwald * Please inquire about commercial licensing options at 34746ccb7eSMatthias Ringwald * [email protected] 35746ccb7eSMatthias Ringwald * 36746ccb7eSMatthias Ringwald */ 37fe5a6c4eSMilanka Ringwald 38fe5a6c4eSMilanka Ringwald /** 39fe5a6c4eSMilanka Ringwald * @title SDP Server 40fe5a6c4eSMilanka Ringwald * 41fe5a6c4eSMilanka Ringwald */ 42fe5a6c4eSMilanka Ringwald 4380e33422SMatthias Ringwald #ifndef SDP_H 4480e33422SMatthias Ringwald #define SDP_H 45746ccb7eSMatthias Ringwald 46746ccb7eSMatthias Ringwald #include <stdint.h> 47746ccb7eSMatthias Ringwald #include "btstack_linked_list.h" 48746ccb7eSMatthias Ringwald 49746ccb7eSMatthias Ringwald #include "btstack_config.h" 50746ccb7eSMatthias Ringwald 51746ccb7eSMatthias Ringwald #if defined __cplusplus 52746ccb7eSMatthias Ringwald extern "C" { 53746ccb7eSMatthias Ringwald #endif 54746ccb7eSMatthias Ringwald 55746ccb7eSMatthias Ringwald typedef struct { 56746ccb7eSMatthias Ringwald // linked list - assert: first field 57746ccb7eSMatthias Ringwald btstack_linked_item_t item; 58746ccb7eSMatthias Ringwald 59746ccb7eSMatthias Ringwald uint32_t service_record_handle; 60746ccb7eSMatthias Ringwald uint8_t * service_record; 61746ccb7eSMatthias Ringwald } service_record_item_t; 62746ccb7eSMatthias Ringwald 63746ccb7eSMatthias Ringwald int sdp_handle_service_search_request(uint8_t * packet, uint16_t remote_mtu); 64746ccb7eSMatthias Ringwald int sdp_handle_service_attribute_request(uint8_t * packet, uint16_t remote_mtu); 65746ccb7eSMatthias Ringwald int sdp_handle_service_search_attribute_request(uint8_t * packet, uint16_t remote_mtu); 66746ccb7eSMatthias Ringwald 67746ccb7eSMatthias Ringwald /* API_START */ 68746ccb7eSMatthias Ringwald 69746ccb7eSMatthias Ringwald /** 700396d6ccSMatthias Ringwald * @brief Set up SDP Server. 71746ccb7eSMatthias Ringwald */ 72746ccb7eSMatthias Ringwald void sdp_init(void); 73746ccb7eSMatthias Ringwald 74746ccb7eSMatthias Ringwald /** 75746ccb7eSMatthias Ringwald * @brief Register Service Record with database using ServiceRecordHandle stored in record 76746ccb7eSMatthias Ringwald * @pre AttributeIDs are in ascending order 77746ccb7eSMatthias Ringwald * @pre ServiceRecordHandle is first attribute and valid 78746ccb7eSMatthias Ringwald * @param record is not copied! 79746ccb7eSMatthias Ringwald * @result status 80746ccb7eSMatthias Ringwald */ 81746ccb7eSMatthias Ringwald uint8_t sdp_register_service(const uint8_t * record); 82746ccb7eSMatthias Ringwald 83746ccb7eSMatthias Ringwald /** 84746ccb7eSMatthias Ringwald * @brief Unregister service record internally. 85746ccb7eSMatthias Ringwald */ 86746ccb7eSMatthias Ringwald void sdp_unregister_service(uint32_t service_record_handle); 87746ccb7eSMatthias Ringwald 880396d6ccSMatthias Ringwald /** 890396d6ccSMatthias Ringwald * @brief gets service record handle from record 900396d6ccSMatthias Ringwald * @resutl service record handle or 0 910396d6ccSMatthias Ringwald */ 920396d6ccSMatthias Ringwald uint32_t sdp_get_service_record_handle(const uint8_t * record); 93746ccb7eSMatthias Ringwald 94746ccb7eSMatthias Ringwald /** 95746ccb7eSMatthias Ringwald * @brief Finds an unused valid service record handle 96746ccb7eSMatthias Ringwald * @result handle 97746ccb7eSMatthias Ringwald */ 98746ccb7eSMatthias Ringwald uint32_t sdp_create_service_record_handle(void); 99746ccb7eSMatthias Ringwald 100746ccb7eSMatthias Ringwald /** 101746ccb7eSMatthias Ringwald * @brief gets record for handle 102746ccb7eSMatthias Ringwald * @result record 103746ccb7eSMatthias Ringwald */ 104746ccb7eSMatthias Ringwald 105746ccb7eSMatthias Ringwald uint8_t * sdp_get_record_for_handle(uint32_t handle); 106746ccb7eSMatthias Ringwald 107746ccb7eSMatthias Ringwald /** 1080396d6ccSMatthias Ringwald * @brief De-Init SDP Server 109746ccb7eSMatthias Ringwald */ 1100396d6ccSMatthias Ringwald void sdp_deinit(void); 1110396d6ccSMatthias Ringwald 1120396d6ccSMatthias Ringwald /* API_END */ 1130396d6ccSMatthias Ringwald 114*22d58ff8SMatthias Ringwald #ifdef ENABLE_TESTING_SUPPORT 115*22d58ff8SMatthias Ringwald void sdp_server_set_single_record_response(bool enabled); 116*22d58ff8SMatthias Ringwald #endif 117*22d58ff8SMatthias Ringwald 118746ccb7eSMatthias Ringwald 119746ccb7eSMatthias Ringwald #if defined __cplusplus 120746ccb7eSMatthias Ringwald } 121746ccb7eSMatthias Ringwald #endif 12280e33422SMatthias Ringwald #endif // SDP_H 123