1 /******************************************************************************
2 *
3 * Copyright 1999-2012 Broadcom Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19 /******************************************************************************
20 *
21 * This file contains the definitions for the SDP API
22 *
23 ******************************************************************************/
24
25 #ifndef SDP_DEFS_H
26 #define SDP_DEFS_H
27
28 #include <format>
29 #include <string>
30
31 #include "macros.h"
32
33 /* Define the service attribute IDs.
34 */
35 #define ATTR_ID_SERVICE_RECORD_HDL 0x0000
36 #define ATTR_ID_SERVICE_CLASS_ID_LIST 0x0001
37 #define ATTR_ID_SERVICE_RECORD_STATE 0x0002
38 #define ATTR_ID_SERVICE_ID 0x0003
39 #define ATTR_ID_PROTOCOL_DESC_LIST 0x0004
40 #define ATTR_ID_BROWSE_GROUP_LIST 0x0005
41 #define ATTR_ID_LANGUAGE_BASE_ATTR_ID_LIST 0x0006
42 #define ATTR_ID_BT_PROFILE_DESC_LIST 0x0009
43 #define ATTR_ID_DOCUMENTATION_URL 0x000A
44 #define ATTR_ID_CLIENT_EXE_URL 0x000B
45 #define ATTR_ID_ADDITION_PROTO_DESC_LISTS 0x000D
46
47 #define LANGUAGE_BASE_ID 0x0100
48 #define ATTR_ID_SERVICE_NAME (LANGUAGE_BASE_ID + 0x0000)
49 #define ATTR_ID_SERVICE_DESCRIPTION (LANGUAGE_BASE_ID + 0x0001)
50 #define ATTR_ID_PROVIDER_NAME (LANGUAGE_BASE_ID + 0x0002)
51
52 /* Device Identification (DI)
53 */
54 #define ATTR_ID_SPECIFICATION_ID 0x0200
55 #define ATTR_ID_VENDOR_ID 0x0201
56 #define ATTR_ID_PRODUCT_ID 0x0202
57 #define ATTR_ID_PRODUCT_VERSION 0x0203
58 #define ATTR_ID_PRIMARY_RECORD 0x0204
59 #define ATTR_ID_VENDOR_ID_SOURCE 0x0205
60
61 #define BLUETOOTH_DI_SPECIFICATION 0x0103 /* 1.3 */
62 #define DI_VENDOR_ID_SOURCE_BTSIG 0x0001
63 #define DI_VENDOR_ID_SOURCE_USBIF 0x0002
64
65 #define ATTR_ID_GOEP_L2CAP_PSM 0x0200
66
67 #define ATTR_ID_NETWORK 0x0301
68 #define ATTR_ID_FAX_CLASS_1_SUPPORT 0x0302
69 #define ATTR_ID_REMOTE_AUDIO_VOLUME_CONTROL 0x0302
70 #define ATTR_ID_SUPPORTED_FORMATS_LIST 0x0303
71 #define ATTR_ID_SUPPORTED_FEATURES 0x0311 /* HFP, BIP */
72 #define ATTR_ID_SUPPORTED_REPOSITORIES 0x0314 /* Phone book access Profile */
73 #define ATTR_ID_MAS_INSTANCE_ID 0x0315 /* MAP profile */
74 #define ATTR_ID_SUPPORTED_MSG_TYPE 0x0316 /* MAP profile */
75 #define ATTR_ID_MAP_SUPPORTED_FEATURES 0x0317 /* MAP profile */
76 #define ATTR_ID_PBAP_SUPPORTED_FEATURES 0x0317 /* PBAP profile */
77
78 /* These values are for the MPS (Multi-Profile Specification) */
79 #define ATTR_ID_MPS_SUPPORTED_SCENARIOS_MPSD 0x0200
80 #define ATTR_ID_MPS_SUPPORTED_SCENARIOS_MPMD 0x0201
81 #define ATTR_ID_MPS_SUPPORTED_DEPENDENCIES 0x0202
82
83 /* These values are for the PAN profile */
84 #define ATTR_ID_SECURITY_DESCRIPTION 0x030A
85 #define ATTR_ID_NET_ACCESS_TYPE 0x030B
86 #define ATTR_ID_MAX_NET_ACCESS_RATE 0x030C
87
88 /* These values are for HID profile */
89 #define ATTR_ID_HID_DEVICE_RELNUM 0x0200
90 #define ATTR_ID_HID_PARSER_VERSION 0x0201
91 #define ATTR_ID_HID_DEVICE_SUBCLASS 0x0202
92 #define ATTR_ID_HID_COUNTRY_CODE 0x0203
93 #define ATTR_ID_HID_VIRTUAL_CABLE 0x0204
94 #define ATTR_ID_HID_RECONNECT_INITIATE 0x0205
95 #define ATTR_ID_HID_DESCRIPTOR_LIST 0x0206
96 #define ATTR_ID_HID_LANGUAGE_ID_BASE 0x0207
97 #define ATTR_ID_HID_SDP_DISABLE 0x0208
98 #define ATTR_ID_HID_BATTERY_POWER 0x0209
99 #define ATTR_ID_HID_REMOTE_WAKE 0x020A
100 #define ATTR_ID_HID_PROFILE_VERSION 0x020B
101 #define ATTR_ID_HID_LINK_SUPERVISION_TO 0x020C
102 #define ATTR_ID_HID_NORMALLY_CONNECTABLE 0x020D
103 #define ATTR_ID_HID_BOOT_DEVICE 0x020E
104 #define ATTR_ID_HID_SSR_HOST_MAX_LAT 0x020F
105 #define ATTR_ID_HID_SSR_HOST_MIN_TOUT 0x0210
106
sdp_attr_id_text(const unsigned & id)107 inline std::string sdp_attr_id_text(const unsigned& id) {
108 switch (id) {
109 CASE_RETURN_TEXT(ATTR_ID_SERVICE_RECORD_HDL);
110 CASE_RETURN_TEXT(ATTR_ID_SERVICE_CLASS_ID_LIST);
111 CASE_RETURN_TEXT(ATTR_ID_SERVICE_RECORD_STATE);
112 CASE_RETURN_TEXT(ATTR_ID_SERVICE_ID);
113 CASE_RETURN_TEXT(ATTR_ID_PROTOCOL_DESC_LIST);
114 CASE_RETURN_TEXT(ATTR_ID_BROWSE_GROUP_LIST);
115 CASE_RETURN_TEXT(ATTR_ID_LANGUAGE_BASE_ATTR_ID_LIST);
116 CASE_RETURN_TEXT(ATTR_ID_BT_PROFILE_DESC_LIST);
117 CASE_RETURN_TEXT(ATTR_ID_DOCUMENTATION_URL);
118 CASE_RETURN_TEXT(ATTR_ID_CLIENT_EXE_URL);
119 CASE_RETURN_TEXT(ATTR_ID_ADDITION_PROTO_DESC_LISTS);
120 CASE_RETURN_TEXT(ATTR_ID_SERVICE_NAME);
121 CASE_RETURN_TEXT(ATTR_ID_SERVICE_DESCRIPTION);
122 CASE_RETURN_TEXT(ATTR_ID_PROVIDER_NAME);
123 default:
124 return std::format("SDP_ATTR_ID:[{}]", id);
125 }
126 }
127
128 /* Define all the 'Descriptor Type' values.
129 */
130 enum : unsigned {
131 NIL_DESC_TYPE = 0,
132 UINT_DESC_TYPE = 1,
133 TWO_COMP_INT_DESC_TYPE = 2,
134 UUID_DESC_TYPE = 3,
135 TEXT_STR_DESC_TYPE = 4,
136 BOOLEAN_DESC_TYPE = 5,
137 DATA_ELE_SEQ_DESC_TYPE = 6,
138 DATA_ELE_ALT_DESC_TYPE = 7,
139 URL_DESC_TYPE = 8,
140 };
141
sdp_attr_type_text(const unsigned & type)142 inline std::string sdp_attr_type_text(const unsigned& type) {
143 switch (type) {
144 CASE_RETURN_TEXT(NIL_DESC_TYPE);
145 CASE_RETURN_TEXT(UINT_DESC_TYPE);
146 CASE_RETURN_TEXT(TWO_COMP_INT_DESC_TYPE);
147 CASE_RETURN_TEXT(UUID_DESC_TYPE);
148 CASE_RETURN_TEXT(TEXT_STR_DESC_TYPE);
149 CASE_RETURN_TEXT(BOOLEAN_DESC_TYPE);
150 CASE_RETURN_TEXT(DATA_ELE_SEQ_DESC_TYPE);
151 CASE_RETURN_TEXT(DATA_ELE_ALT_DESC_TYPE);
152 CASE_RETURN_TEXT(URL_DESC_TYPE);
153 default:
154 return std::format("UNKNOWN[{}]", type);
155 }
156 }
157
158 /* Define all the "Descriptor Size" values.
159 */
160 enum : unsigned {
161 SIZE_ONE_BYTE = 0,
162 SIZE_TWO_BYTES = 1,
163 SIZE_FOUR_BYTES = 2,
164 SIZE_EIGHT_BYTES = 3,
165 SIZE_SIXTEEN_BYTES = 4,
166 SIZE_IN_NEXT_BYTE = 5,
167 SIZE_IN_NEXT_WORD = 6,
168 SIZE_IN_NEXT_LONG = 7,
169 };
170
sdp_attr_size_text(const unsigned & size)171 inline std::string sdp_attr_size_text(const unsigned& size) {
172 switch (size) {
173 CASE_RETURN_TEXT(SIZE_ONE_BYTE);
174 CASE_RETURN_TEXT(SIZE_TWO_BYTES);
175 CASE_RETURN_TEXT(SIZE_FOUR_BYTES);
176 CASE_RETURN_TEXT(SIZE_EIGHT_BYTES);
177 CASE_RETURN_TEXT(SIZE_SIXTEEN_BYTES);
178 CASE_RETURN_TEXT(SIZE_IN_NEXT_BYTE);
179 CASE_RETURN_TEXT(SIZE_IN_NEXT_WORD);
180 CASE_RETURN_TEXT(SIZE_IN_NEXT_LONG);
181 default:
182 return std::format("UNKNOWN[{}]", size);
183 }
184 }
185
element_type(const uint8_t & element)186 inline unsigned element_type(const uint8_t& element) { return element >> 3; }
187
element_size(const uint8_t & element)188 inline unsigned element_size(const uint8_t& element) { return element & 0x7; }
189
190 /* Language Encoding Constants */
191 #define LANG_ID_CODE_ENGLISH ((uint16_t)0x656e) /* "en" */
192 #define LANG_ID_CHAR_ENCODE_UTF8 ((uint16_t)0x006a) /* UTF-8 */
193
194 /* Constants used for display purposes only. These define overlapping attribute
195 * values */
196 #define ATTR_ID_DATA_STORES_OR_NETWORK 0x0301
197
198 #endif
199