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 <base/strings/stringprintf.h>
29 
30 #include <string>
31 
32 #include "macros.h"
33 
34 /* Define the service attribute IDs.
35 */
36 #define ATTR_ID_SERVICE_RECORD_HDL 0x0000
37 #define ATTR_ID_SERVICE_CLASS_ID_LIST 0x0001
38 #define ATTR_ID_SERVICE_RECORD_STATE 0x0002
39 #define ATTR_ID_SERVICE_ID 0x0003
40 #define ATTR_ID_PROTOCOL_DESC_LIST 0x0004
41 #define ATTR_ID_BROWSE_GROUP_LIST 0x0005
42 #define ATTR_ID_LANGUAGE_BASE_ATTR_ID_LIST 0x0006
43 #define ATTR_ID_BT_PROFILE_DESC_LIST 0x0009
44 #define ATTR_ID_DOCUMENTATION_URL 0x000A
45 #define ATTR_ID_CLIENT_EXE_URL 0x000B
46 #define ATTR_ID_ADDITION_PROTO_DESC_LISTS 0x000D
47 
48 #define LANGUAGE_BASE_ID 0x0100
49 #define ATTR_ID_SERVICE_NAME (LANGUAGE_BASE_ID + 0x0000)
50 #define ATTR_ID_SERVICE_DESCRIPTION (LANGUAGE_BASE_ID + 0x0001)
51 #define ATTR_ID_PROVIDER_NAME (LANGUAGE_BASE_ID + 0x0002)
52 
53 /* Device Identification (DI)
54 */
55 #define ATTR_ID_SPECIFICATION_ID 0x0200
56 #define ATTR_ID_VENDOR_ID 0x0201
57 #define ATTR_ID_PRODUCT_ID 0x0202
58 #define ATTR_ID_PRODUCT_VERSION 0x0203
59 #define ATTR_ID_PRIMARY_RECORD 0x0204
60 #define ATTR_ID_VENDOR_ID_SOURCE 0x0205
61 
62 #define BLUETOOTH_DI_SPECIFICATION 0x0103 /* 1.3 */
63 #define DI_VENDOR_ID_SOURCE_BTSIG 0x0001
64 #define DI_VENDOR_ID_SOURCE_USBIF 0x0002
65 
66 #define ATTR_ID_GOEP_L2CAP_PSM 0x0200
67 
68 #define ATTR_ID_NETWORK 0x0301
69 #define ATTR_ID_FAX_CLASS_1_SUPPORT 0x0302
70 #define ATTR_ID_REMOTE_AUDIO_VOLUME_CONTROL 0x0302
71 #define ATTR_ID_SUPPORTED_FORMATS_LIST 0x0303
72 #define ATTR_ID_SUPPORTED_FEATURES 0x0311         /* HFP, BIP */
73 #define ATTR_ID_SUPPORTED_REPOSITORIES 0x0314  /* Phone book access Profile */
74 #define ATTR_ID_MAS_INSTANCE_ID 0x0315         /* MAP profile */
75 #define ATTR_ID_SUPPORTED_MSG_TYPE 0x0316      /* MAP profile */
76 #define ATTR_ID_MAP_SUPPORTED_FEATURES 0x0317  /* MAP profile */
77 #define ATTR_ID_PBAP_SUPPORTED_FEATURES 0x0317 /* PBAP profile */
78 
79 /* These values are for the MPS (Multi-Profile Specification) */
80 #define ATTR_ID_MPS_SUPPORTED_SCENARIOS_MPSD 0x0200
81 #define ATTR_ID_MPS_SUPPORTED_SCENARIOS_MPMD 0x0201
82 #define ATTR_ID_MPS_SUPPORTED_DEPENDENCIES 0x0202
83 
84 /* These values are for the PAN profile */
85 #define ATTR_ID_SECURITY_DESCRIPTION 0x030A
86 #define ATTR_ID_NET_ACCESS_TYPE 0x030B
87 #define ATTR_ID_MAX_NET_ACCESS_RATE 0x030C
88 
89 /* These values are for HID profile */
90 #define ATTR_ID_HID_DEVICE_RELNUM 0x0200
91 #define ATTR_ID_HID_PARSER_VERSION 0x0201
92 #define ATTR_ID_HID_DEVICE_SUBCLASS 0x0202
93 #define ATTR_ID_HID_COUNTRY_CODE 0x0203
94 #define ATTR_ID_HID_VIRTUAL_CABLE 0x0204
95 #define ATTR_ID_HID_RECONNECT_INITIATE 0x0205
96 #define ATTR_ID_HID_DESCRIPTOR_LIST 0x0206
97 #define ATTR_ID_HID_LANGUAGE_ID_BASE 0x0207
98 #define ATTR_ID_HID_SDP_DISABLE 0x0208
99 #define ATTR_ID_HID_BATTERY_POWER 0x0209
100 #define ATTR_ID_HID_REMOTE_WAKE 0x020A
101 #define ATTR_ID_HID_PROFILE_VERSION 0x020B
102 #define ATTR_ID_HID_LINK_SUPERVISION_TO 0x020C
103 #define ATTR_ID_HID_NORMALLY_CONNECTABLE 0x020D
104 #define ATTR_ID_HID_BOOT_DEVICE 0x020E
105 #define ATTR_ID_HID_SSR_HOST_MAX_LAT 0x020F
106 #define ATTR_ID_HID_SSR_HOST_MIN_TOUT 0x0210
107 
sdp_attr_id_text(const unsigned & id)108 inline std::string sdp_attr_id_text(const unsigned& id) {
109   switch (id) {
110     CASE_RETURN_TEXT(ATTR_ID_SERVICE_RECORD_HDL);
111     CASE_RETURN_TEXT(ATTR_ID_SERVICE_CLASS_ID_LIST);
112     CASE_RETURN_TEXT(ATTR_ID_SERVICE_RECORD_STATE);
113     CASE_RETURN_TEXT(ATTR_ID_SERVICE_ID);
114     CASE_RETURN_TEXT(ATTR_ID_PROTOCOL_DESC_LIST);
115     CASE_RETURN_TEXT(ATTR_ID_BROWSE_GROUP_LIST);
116     CASE_RETURN_TEXT(ATTR_ID_LANGUAGE_BASE_ATTR_ID_LIST);
117     CASE_RETURN_TEXT(ATTR_ID_BT_PROFILE_DESC_LIST);
118     CASE_RETURN_TEXT(ATTR_ID_DOCUMENTATION_URL);
119     CASE_RETURN_TEXT(ATTR_ID_CLIENT_EXE_URL);
120     CASE_RETURN_TEXT(ATTR_ID_ADDITION_PROTO_DESC_LISTS);
121     CASE_RETURN_TEXT(ATTR_ID_SERVICE_NAME);
122     CASE_RETURN_TEXT(ATTR_ID_SERVICE_DESCRIPTION);
123     CASE_RETURN_TEXT(ATTR_ID_PROVIDER_NAME);
124     default:
125       return base::StringPrintf("SDP_ATTR_ID:[%u]", id);
126   }
127 }
128 
129 #define UUID_CODEC_CVSD 0x0001 /* CVSD */
130 #define UUID_CODEC_MSBC 0x0002 /* mSBC */
131 #define UUID_CODEC_LC3 0x0003  /* LC3 */
132 
133 /* Define all the 'Descriptor Type' values.
134 */
135 enum : unsigned {
136   NIL_DESC_TYPE = 0,
137   UINT_DESC_TYPE = 1,
138   TWO_COMP_INT_DESC_TYPE = 2,
139   UUID_DESC_TYPE = 3,
140   TEXT_STR_DESC_TYPE = 4,
141   BOOLEAN_DESC_TYPE = 5,
142   DATA_ELE_SEQ_DESC_TYPE = 6,
143   DATA_ELE_ALT_DESC_TYPE = 7,
144   URL_DESC_TYPE = 8,
145 };
146 
sdp_attr_type_text(const unsigned & type)147 inline std::string sdp_attr_type_text(const unsigned& type) {
148   switch (type) {
149     CASE_RETURN_TEXT(NIL_DESC_TYPE);
150     CASE_RETURN_TEXT(UINT_DESC_TYPE);
151     CASE_RETURN_TEXT(TWO_COMP_INT_DESC_TYPE);
152     CASE_RETURN_TEXT(UUID_DESC_TYPE);
153     CASE_RETURN_TEXT(TEXT_STR_DESC_TYPE);
154     CASE_RETURN_TEXT(BOOLEAN_DESC_TYPE);
155     CASE_RETURN_TEXT(DATA_ELE_SEQ_DESC_TYPE);
156     CASE_RETURN_TEXT(DATA_ELE_ALT_DESC_TYPE);
157     CASE_RETURN_TEXT(URL_DESC_TYPE);
158     default:
159       return base::StringPrintf("UNKNOWN[%u]", type);
160   }
161 }
162 
163 /* Define all the "Descriptor Size" values.
164 */
165 enum : unsigned {
166   SIZE_ONE_BYTE = 0,
167   SIZE_TWO_BYTES = 1,
168   SIZE_FOUR_BYTES = 2,
169   SIZE_EIGHT_BYTES = 3,
170   SIZE_SIXTEEN_BYTES = 4,
171   SIZE_IN_NEXT_BYTE = 5,
172   SIZE_IN_NEXT_WORD = 6,
173   SIZE_IN_NEXT_LONG = 7,
174 };
175 
sdp_attr_size_text(const unsigned & size)176 inline std::string sdp_attr_size_text(const unsigned& size) {
177   switch (size) {
178     CASE_RETURN_TEXT(SIZE_ONE_BYTE);
179     CASE_RETURN_TEXT(SIZE_TWO_BYTES);
180     CASE_RETURN_TEXT(SIZE_FOUR_BYTES);
181     CASE_RETURN_TEXT(SIZE_EIGHT_BYTES);
182     CASE_RETURN_TEXT(SIZE_SIXTEEN_BYTES);
183     CASE_RETURN_TEXT(SIZE_IN_NEXT_BYTE);
184     CASE_RETURN_TEXT(SIZE_IN_NEXT_WORD);
185     CASE_RETURN_TEXT(SIZE_IN_NEXT_LONG);
186     default:
187       return base::StringPrintf("UNKNOWN[%u]", size);
188   }
189 }
190 
element_type(const uint8_t & element)191 inline unsigned element_type(const uint8_t& element) { return element >> 3; }
192 
element_size(const uint8_t & element)193 inline unsigned element_size(const uint8_t& element) { return element & 0x7; }
194 
195 /* Language Encoding Constants */
196 #define LANG_ID_CODE_ENGLISH ((uint16_t)0x656e)     /* "en" */
197 #define LANG_ID_CHAR_ENCODE_UTF8 ((uint16_t)0x006a) /* UTF-8 */
198 
199 /* Constants used for display purposes only.  These define overlapping attribute
200  * values */
201 #define ATTR_ID_DATA_STORES_OR_NETWORK 0x0301
202 
203 #endif
204