CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: orangepi-xunlong/orangepi-build
Path: blob/next/external/cache/sources/hcitools/monitor/uuid.c
Views: 3959
1
/*
2
*
3
* BlueZ - Bluetooth protocol stack for Linux
4
*
5
* Copyright (C) 2011-2012 Intel Corporation
6
* Copyright (C) 2004-2010 Marcel Holtmann <[email protected]>
7
*
8
*
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
13
*
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
18
*
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
*
23
*/
24
25
#ifdef HAVE_CONFIG_H
26
#include <config.h>
27
#endif
28
29
#include <stdio.h>
30
#include <string.h>
31
32
#include "uuid.h"
33
34
static struct {
35
uint16_t uuid;
36
const char *str;
37
} uuid16_table[] = {
38
{ 0x0001, "SDP" },
39
{ 0x0003, "RFCOMM" },
40
{ 0x0005, "TCS-BIN" },
41
{ 0x0007, "ATT" },
42
{ 0x0008, "OBEX" },
43
{ 0x000f, "BNEP" },
44
{ 0x0010, "UPNP" },
45
{ 0x0011, "HIDP" },
46
{ 0x0012, "Hardcopy Control Channel" },
47
{ 0x0014, "Hardcopy Data Channel" },
48
{ 0x0016, "Hardcopy Notification" },
49
{ 0x0017, "AVCTP" },
50
{ 0x0019, "AVDTP" },
51
{ 0x001b, "CMTP" },
52
{ 0x001e, "MCAP Control Channel" },
53
{ 0x001f, "MCAP Data Channel" },
54
{ 0x0100, "L2CAP" },
55
{ 0x1000, "Service Discovery Server Service Class" },
56
{ 0x1001, "Browse Group Descriptor Service Class" },
57
{ 0x1002, "Public Browse Root" },
58
{ 0x1101, "Serial Port" },
59
{ 0x1102, "LAN Access Using PPP" },
60
{ 0x1103, "Dialup Networking" },
61
{ 0x1104, "IrMC Sync" },
62
{ 0x1105, "OBEX Object Push" },
63
{ 0x1106, "OBEX File Transfer" },
64
{ 0x1107, "IrMC Sync Command" },
65
{ 0x1108, "Headset" },
66
{ 0x1109, "Cordless Telephony" },
67
{ 0x110a, "Audio Source" },
68
{ 0x110b, "Audio Sink" },
69
{ 0x110c, "A/V Remote Control Target" },
70
{ 0x110d, "Advanced Audio Distribution" },
71
{ 0x110e, "A/V Remote Control" },
72
{ 0x110f, "A/V Remote Control Controller" },
73
{ 0x1110, "Intercom" },
74
{ 0x1111, "Fax" },
75
{ 0x1112, "Headset AG" },
76
{ 0x1113, "WAP" },
77
{ 0x1114, "WAP Client" },
78
{ 0x1115, "PANU" },
79
{ 0x1116, "NAP" },
80
{ 0x1117, "GN" },
81
{ 0x1118, "Direct Printing" },
82
{ 0x1119, "Reference Printing" },
83
{ 0x111a, "Basic Imaging Profile" },
84
{ 0x111b, "Imaging Responder" },
85
{ 0x111c, "Imaging Automatic Archive" },
86
{ 0x111d, "Imaging Referenced Objects" },
87
{ 0x111e, "Handsfree" },
88
{ 0x111f, "Handsfree Audio Gateway" },
89
{ 0x1120, "Direct Printing Refrence Objects Service" },
90
{ 0x1121, "Reflected UI" },
91
{ 0x1122, "Basic Printing" },
92
{ 0x1123, "Printing Status" },
93
{ 0x1124, "Human Interface Device Service" },
94
{ 0x1125, "Hardcopy Cable Replacement" },
95
{ 0x1126, "HCR Print" },
96
{ 0x1127, "HCR Scan" },
97
{ 0x1128, "Common ISDN Access" },
98
{ 0x112d, "SIM Access" },
99
{ 0x112e, "Phonebook Access Client" },
100
{ 0x112f, "Phonebook Access Server" },
101
{ 0x1130, "Phonebook Access" },
102
{ 0x1131, "Headset HS" },
103
{ 0x1132, "Message Access Server" },
104
{ 0x1133, "Message Notification Server" },
105
{ 0x1134, "Message Access Profile" },
106
{ 0x1135, "GNSS" },
107
{ 0x1136, "GNSS Server" },
108
{ 0x1200, "PnP Information" },
109
{ 0x1201, "Generic Networking" },
110
{ 0x1202, "Generic File Transfer" },
111
{ 0x1203, "Generic Audio" },
112
{ 0x1204, "Generic Telephony" },
113
{ 0x1205, "UPNP Service" },
114
{ 0x1206, "UPNP IP Service" },
115
{ 0x1300, "UPNP IP PAN" },
116
{ 0x1301, "UPNP IP LAP" },
117
{ 0x1302, "UPNP IP L2CAP" },
118
{ 0x1303, "Video Source" },
119
{ 0x1304, "Video Sink" },
120
{ 0x1305, "Video Distribution" },
121
{ 0x1400, "HDP" },
122
{ 0x1401, "HDP Source" },
123
{ 0x1402, "HDP Sink" },
124
{ 0x1800, "Generic Access Profile" },
125
{ 0x1801, "Generic Attribute Profile" },
126
{ 0x1802, "Immediate Alert" },
127
{ 0x1803, "Link Loss" },
128
{ 0x1804, "Tx Power" },
129
{ 0x1805, "Current Time Service" },
130
{ 0x1806, "Reference Time Update Service" },
131
{ 0x1807, "Next DST Change Service" },
132
{ 0x1808, "Glucose" },
133
{ 0x1809, "Health Thermometer" },
134
{ 0x180a, "Device Information" },
135
/* 0x180b and 0x180c undefined */
136
{ 0x180d, "Heart Rate" },
137
{ 0x180e, "Phone Alert Status Service" },
138
{ 0x180f, "Battery Service" },
139
{ 0x1810, "Blood Pressure" },
140
{ 0x1811, "Alert Notification Service" },
141
{ 0x1812, "Human Interface Device" },
142
{ 0x1813, "Scan Parameters" },
143
{ 0x1814, "Running Speed and Cadence" },
144
/* 0x1815 undefined */
145
{ 0x1816, "Cycling Speed and Cadence" },
146
{ 0x2800, "Primary Service" },
147
{ 0x2801, "Secondary Service" },
148
{ 0x2802, "Include" },
149
{ 0x2803, "Characteristic" },
150
{ 0x2900, "Characteristic Extended Properties" },
151
{ 0x2901, "Characteristic User Description" },
152
{ 0x2902, "Client Characteristic Configuration" },
153
{ 0x2903, "Server Characteristic Configuration" },
154
{ 0x2904, "Characteristic Format" },
155
{ 0x2905, "Characteristic Aggregate Formate" },
156
{ 0x2906, "Valid Range" },
157
{ 0x2907, "External Report Reference" },
158
{ 0x2908, "Report Reference" },
159
{ 0x2a00, "Device Name" },
160
{ 0x2a01, "Appearance" },
161
{ 0x2a02, "Peripheral Privacy Flag" },
162
{ 0x2a03, "Reconnection Address" },
163
{ 0x2a04, "Peripheral Preferred Connection Parameters" },
164
{ 0x2a05, "Service Changed" },
165
{ 0x2a06, "Alert Level" },
166
{ 0x2a07, "Tx Power Level" },
167
{ 0x2a08, "Date Time" },
168
{ 0x2a09, "Day of Week" },
169
{ 0x2a0a, "Day Date Time" },
170
/* 0x2a0b undefined */
171
{ 0x2a0c, "Exact Time 256" },
172
{ 0x2a0d, "DST Offset" },
173
{ 0x2a0e, "Time Zone" },
174
{ 0x2a0f, "Local Time Information" },
175
/* 0x2a10 undefined */
176
{ 0x2a11, "Time with DST" },
177
{ 0x2a12, "Time Accuracy" },
178
{ 0x2a13, "Time Source" },
179
{ 0x2a14, "Reference Time Information" },
180
/* 0x2a15 undefined */
181
{ 0x2a16, "Time Update Control Point" },
182
{ 0x2a17, "Time Update State" },
183
{ 0x2a18, "Glucose Measurement" },
184
{ 0x2a19, "Battery Level" },
185
/* 0x2a1a and 0x2a1b undefined */
186
{ 0x2a1c, "Temperature Measurement" },
187
{ 0x2a1d, "Temperature Type" },
188
{ 0x2a1e, "Intermediate Temperature" },
189
/* 0x2a1f and 0x2a20 undefined */
190
{ 0x2a21, "Measurement Interval" },
191
{ 0x2a22, "Boot Keyboard Input Report" },
192
{ 0x2a23, "System ID" },
193
{ 0x2a24, "Model Number String" },
194
{ 0x2a25, "Serial Number String" },
195
{ 0x2a26, "Firmware Revision String" },
196
{ 0x2a27, "Hardware Revision String" },
197
{ 0x2a28, "Software Revision String" },
198
{ 0x2a29, "Manufacturer Name String" },
199
{ 0x2a2a, "IEEE 11073-20601 Regulatory Cert. Data List" },
200
{ 0x2a2b, "Current Time" },
201
/* 0x2a2c to 0x2a30 undefined */
202
{ 0x2a31, "Scan Refresh" },
203
{ 0x2a32, "Boot Keyboard Output Report" },
204
{ 0x2a33, "Boot Mouse Input Report" },
205
{ 0x2a34, "Glucose Measurement Context" },
206
{ 0x2a35, "Blood Pressure Measurement" },
207
{ 0x2a36, "Intermediate Cuff Pressure" },
208
{ 0x2a37, "Heart Rate Measurement" },
209
{ 0x2a38, "Body Sensor Location" },
210
{ 0x2a39, "Heart Rate Control Point" },
211
/* 0x2a3a to 0x2a3e undefined */
212
{ 0x2a3f, "Alert Status" },
213
{ 0x2a40, "Ringer Control Point" },
214
{ 0x2a41, "Ringer Setting" },
215
{ 0x2a42, "Alert Category ID Bit Mask" },
216
{ 0x2a43, "Alert Category ID" },
217
{ 0x2a44, "Alert Notification Control Point" },
218
{ 0x2a45, "Unread Alert Status" },
219
{ 0x2a46, "New Alert" },
220
{ 0x2a47, "Supported New Alert Category" },
221
{ 0x2a48, "Supported Unread Alert Category" },
222
{ 0x2a49, "Blood Pressure Feature" },
223
{ 0x2a4a, "HID Information" },
224
{ 0x2a4b, "Report Map" },
225
{ 0x2a4c, "HID Control Point" },
226
{ 0x2a4d, "Report" },
227
{ 0x2a4e, "Protocol Mode" },
228
{ 0x2a4f, "Scan Interval Window" },
229
{ 0x2a50, "PnP ID" },
230
{ 0x2a51, "Glucose Feature" },
231
{ 0x2a52, "Record Access Control Point" },
232
{ 0x2a53, "RSC Measurement" },
233
{ 0x2a54, "RSC Feature" },
234
{ 0x2a55, "SC Control Point" },
235
/* 0x2a56 to 0x2a5a undefined */
236
{ 0x2a5b, "CSC Measurement" },
237
{ 0x2a5c, "CSC Feature" },
238
{ 0x2a5d, "Sensor Location" },
239
{ }
240
};
241
242
const char *uuid16_to_str(uint16_t uuid)
243
{
244
int i;
245
246
for (i = 0; uuid16_table[i].str; i++) {
247
if (uuid16_table[i].uuid == uuid)
248
return uuid16_table[i].str;
249
}
250
251
return "Unknown";
252
}
253
254
const char *uuid32_to_str(uint32_t uuid)
255
{
256
if ((uuid & 0xffff0000) == 0x0000)
257
return uuid16_to_str(uuid & 0x0000ffff);
258
259
return "Unknown";
260
}
261
262
const char *uuid128_to_str(const unsigned char *uuid)
263
{
264
return "Unknown";
265
}
266
267
const char *uuidstr_to_str(const char *uuid)
268
{
269
uint32_t val;
270
271
if (!uuid)
272
return NULL;
273
274
if (strlen(uuid) != 36)
275
return NULL;
276
277
if (strncasecmp(uuid + 8, "-0000-1000-8000-00805f9b34fb", 28))
278
return "Vendor specific";
279
280
if (sscanf(uuid, "%08x-0000-1000-8000-00805f9b34fb", &val) != 1)
281
return NULL;
282
283
return uuid32_to_str(val);
284
}
285
286