blob: d298ad6af6c7f97efecc9e6250c376941c22df1e [file] [log] [blame]
kschulz9a92a7b2015-03-06 09:15:43 +01001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include "bluetooth.h"
20
21#define SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH 15
22
23__BEGIN_DECLS
24
25/**
26 * These events are handled by the state machine
27 */
28typedef enum {
29 SDP_TYPE_RAW, // Used to carry raw SDP search data for unknown UUID's
30 SDP_TYPE_MAP_MAS,
31 SDP_TYPE_MAP_MNS,
32 SDP_TYPE_PBAP_PSE,
33 SDP_TYPE_PBAP_PCE,
34 SDP_TYPE_OPP_SERVER
35} bluetooth_sdp_types;
36
37typedef struct _bluetooth_sdp_hdr {
38 bluetooth_sdp_types type;
39 bt_uuid_t uuid;
40 uint32_t service_name_length;
41 char *service_name;
42 int32_t rfcomm_channel_number;
43 int32_t l2cap_psm;
44 int32_t profile_version;
45} bluetooth_sdp_hdr;
46
47/**
48 * Some signals need additional pointers, hence we introduce a
49 * generic way to handle these pointers.
50 */
51typedef struct _bluetooth_sdp_hdr_overlay {
52 bluetooth_sdp_types type;
53 bt_uuid_t uuid;
54 uint32_t service_name_length;
55 char *service_name;
56 int32_t rfcomm_channel_number;
57 int32_t l2cap_psm;
58 int32_t profile_version;
59
60 // User pointers, only used for some signals - see bluetooth_sdp_ops_record
61 int user1_ptr_len;
62 uint8_t *user1_ptr;
63 int user2_ptr_len;
64 uint8_t *user2_ptr;
65} bluetooth_sdp_hdr_overlay;
66
67typedef struct _bluetooth_sdp_mas_record {
68 bluetooth_sdp_hdr_overlay hdr;
69 uint32_t mas_instance_id;
70 uint32_t supported_features;
71 uint32_t supported_message_types;
72} bluetooth_sdp_mas_record;
73
74typedef struct _bluetooth_sdp_mns_record {
75 bluetooth_sdp_hdr_overlay hdr;
76 uint32_t supported_features;
77} bluetooth_sdp_mns_record;
78
79typedef struct _bluetooth_sdp_pse_record {
80 bluetooth_sdp_hdr_overlay hdr;
81 uint32_t supported_features;
82 uint32_t supported_repositories;
83} bluetooth_sdp_pse_record;
84
85typedef struct _bluetooth_sdp_pce_record {
86 bluetooth_sdp_hdr_overlay hdr;
87} bluetooth_sdp_pce_record;
88
89typedef struct _bluetooth_sdp_ops_record {
90 bluetooth_sdp_hdr_overlay hdr;
91 int supported_formats_list_len;
92 uint8_t supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH];
93} bluetooth_sdp_ops_record;
94
95typedef union {
96 bluetooth_sdp_hdr_overlay hdr;
97 bluetooth_sdp_mas_record mas;
98 bluetooth_sdp_mns_record mns;
99 bluetooth_sdp_pse_record pse;
100 bluetooth_sdp_pce_record pce;
101 bluetooth_sdp_ops_record ops;
102} bluetooth_sdp_record;
103
104
105/** Callback for SDP search */
106typedef void (*btsdp_search_callback)(bt_status_t status, bt_bdaddr_t *bd_addr, uint8_t* uuid, int num_records, bluetooth_sdp_record *records);
107
108typedef struct {
109 /** Set to sizeof(btsdp_callbacks_t) */
110 size_t size;
111 btsdp_search_callback sdp_search_cb;
112} btsdp_callbacks_t;
113
114typedef struct {
115 /** Set to size of this struct */
116 size_t size;
117
118 /** Register BT SDP search callbacks */
119 bt_status_t (*init)(btsdp_callbacks_t *callbacks);
120
121 /** Unregister BT SDP */
122 bt_status_t (*deinit)();
123
124 /** Search for SDP records with specific uuid on remote device */
125 bt_status_t (*sdp_search)(bt_bdaddr_t *bd_addr, const uint8_t* uuid);
126
127 /**
128 * Use listen in the socket interface to create rfcomm and/or l2cap PSM channels,
129 * (without UUID and service_name and set the BTSOCK_FLAG_NO_SDP flag in flags).
130 * Then use createSdpRecord to create the SDP record associated with the rfcomm/l2cap channels.
131 *
132 * Returns a handle to the SDP record, which can be parsed to remove_sdp_record.
133 *
134 * record (in) The SDP record to create
135 * record_handle (out)The corresponding record handle will be written to this pointer.
136 */
137 bt_status_t (*create_sdp_record)(bluetooth_sdp_record *record, int* record_handle);
138
139 /** Remove a SDP record created by createSdpRecord */
140 bt_status_t (*remove_sdp_record)(int sdp_handle);
141} btsdp_interface_t;
142
143__END_DECLS
144