blob: 8f39bc5bdc467cc4f750db8e87f8bd773e0a1fbc [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 {
Casper Bonde207331d2015-04-16 15:25:41 +020029 SDP_TYPE_RAW, // Used to carry raw SDP search data for unknown UUIDs
30 SDP_TYPE_MAP_MAS, // Message Access Profile - Server
31 SDP_TYPE_MAP_MNS, // Message Access Profile - Client (Notification Server)
32 SDP_TYPE_PBAP_PSE, // Phone Book Profile - Server
33 SDP_TYPE_PBAP_PCE, // Phone Book Profile - Client
34 SDP_TYPE_OPP_SERVER, // Object Push Profile
35 SDP_TYPE_SAP_SERVER // SIM Access Profile
kschulz9a92a7b2015-03-06 09:15:43 +010036} bluetooth_sdp_types;
37
38typedef struct _bluetooth_sdp_hdr {
39 bluetooth_sdp_types type;
40 bt_uuid_t uuid;
41 uint32_t service_name_length;
42 char *service_name;
43 int32_t rfcomm_channel_number;
44 int32_t l2cap_psm;
45 int32_t profile_version;
46} bluetooth_sdp_hdr;
47
48/**
49 * Some signals need additional pointers, hence we introduce a
50 * generic way to handle these pointers.
51 */
52typedef struct _bluetooth_sdp_hdr_overlay {
53 bluetooth_sdp_types type;
54 bt_uuid_t uuid;
55 uint32_t service_name_length;
56 char *service_name;
57 int32_t rfcomm_channel_number;
58 int32_t l2cap_psm;
59 int32_t profile_version;
60
61 // User pointers, only used for some signals - see bluetooth_sdp_ops_record
62 int user1_ptr_len;
63 uint8_t *user1_ptr;
64 int user2_ptr_len;
65 uint8_t *user2_ptr;
66} bluetooth_sdp_hdr_overlay;
67
68typedef struct _bluetooth_sdp_mas_record {
69 bluetooth_sdp_hdr_overlay hdr;
70 uint32_t mas_instance_id;
71 uint32_t supported_features;
72 uint32_t supported_message_types;
73} bluetooth_sdp_mas_record;
74
75typedef struct _bluetooth_sdp_mns_record {
76 bluetooth_sdp_hdr_overlay hdr;
77 uint32_t supported_features;
78} bluetooth_sdp_mns_record;
79
80typedef struct _bluetooth_sdp_pse_record {
81 bluetooth_sdp_hdr_overlay hdr;
82 uint32_t supported_features;
83 uint32_t supported_repositories;
84} bluetooth_sdp_pse_record;
85
86typedef struct _bluetooth_sdp_pce_record {
87 bluetooth_sdp_hdr_overlay hdr;
88} bluetooth_sdp_pce_record;
89
90typedef struct _bluetooth_sdp_ops_record {
91 bluetooth_sdp_hdr_overlay hdr;
92 int supported_formats_list_len;
93 uint8_t supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH];
94} bluetooth_sdp_ops_record;
95
Casper Bonde207331d2015-04-16 15:25:41 +020096typedef struct _bluetooth_sdp_sap_record {
97 bluetooth_sdp_hdr_overlay hdr;
98} bluetooth_sdp_sap_record;
99
kschulz9a92a7b2015-03-06 09:15:43 +0100100typedef union {
101 bluetooth_sdp_hdr_overlay hdr;
102 bluetooth_sdp_mas_record mas;
103 bluetooth_sdp_mns_record mns;
104 bluetooth_sdp_pse_record pse;
105 bluetooth_sdp_pce_record pce;
106 bluetooth_sdp_ops_record ops;
Casper Bonde207331d2015-04-16 15:25:41 +0200107 bluetooth_sdp_sap_record sap;
kschulz9a92a7b2015-03-06 09:15:43 +0100108} bluetooth_sdp_record;
109
110
111/** Callback for SDP search */
112typedef void (*btsdp_search_callback)(bt_status_t status, bt_bdaddr_t *bd_addr, uint8_t* uuid, int num_records, bluetooth_sdp_record *records);
113
114typedef struct {
115 /** Set to sizeof(btsdp_callbacks_t) */
116 size_t size;
117 btsdp_search_callback sdp_search_cb;
118} btsdp_callbacks_t;
119
120typedef struct {
121 /** Set to size of this struct */
122 size_t size;
123
124 /** Register BT SDP search callbacks */
125 bt_status_t (*init)(btsdp_callbacks_t *callbacks);
126
127 /** Unregister BT SDP */
128 bt_status_t (*deinit)();
129
130 /** Search for SDP records with specific uuid on remote device */
131 bt_status_t (*sdp_search)(bt_bdaddr_t *bd_addr, const uint8_t* uuid);
132
133 /**
134 * Use listen in the socket interface to create rfcomm and/or l2cap PSM channels,
135 * (without UUID and service_name and set the BTSOCK_FLAG_NO_SDP flag in flags).
136 * Then use createSdpRecord to create the SDP record associated with the rfcomm/l2cap channels.
137 *
138 * Returns a handle to the SDP record, which can be parsed to remove_sdp_record.
139 *
140 * record (in) The SDP record to create
141 * record_handle (out)The corresponding record handle will be written to this pointer.
142 */
143 bt_status_t (*create_sdp_record)(bluetooth_sdp_record *record, int* record_handle);
144
145 /** Remove a SDP record created by createSdpRecord */
146 bt_status_t (*remove_sdp_record)(int sdp_handle);
147} btsdp_interface_t;
148
149__END_DECLS
150