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