1 /* $NetBSD: print.c,v 1.22 2015/12/11 21:05:18 plunky Exp $ */ 2 3 /*- 4 * Copyright (c) 2009 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Iain Hibbert. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #include <sys/cdefs.h> 33 __RCSID("$NetBSD: print.c,v 1.22 2015/12/11 21:05:18 plunky Exp $"); 34 35 #include <ctype.h> 36 #include <iconv.h> 37 #include <langinfo.h> 38 #include <sdp.h> 39 #include <stdbool.h> 40 #include <stdio.h> 41 #include <stdlib.h> 42 #include <string.h> 43 #include <uuid.h> 44 #include <vis.h> 45 46 #include "sdpquery.h" 47 48 typedef struct { 49 uint16_t id; 50 const char * desc; 51 void (*print)(sdp_data_t *); 52 } attr_t; 53 54 typedef struct { 55 uint16_t class; 56 const char * desc; 57 attr_t * attrs; 58 size_t nattr; 59 } service_t; 60 61 typedef struct { 62 uint16_t base; 63 const char * codeset; 64 } language_t; 65 66 static const char *string_uuid(uuid_t *); 67 static const char *string_vis(const char *, size_t); 68 69 static void print_hexdump(const char *, const uint8_t *, size_t); 70 static bool print_attribute(uint16_t, sdp_data_t *, attr_t *, size_t); 71 static bool print_universal_attribute(uint16_t, sdp_data_t *); 72 static bool print_language_attribute(uint16_t, sdp_data_t *); 73 static bool print_service_attribute(uint16_t, sdp_data_t *); 74 75 static void print_bool(sdp_data_t *); 76 static void print_uint8d(sdp_data_t *); 77 static void print_uint8x(sdp_data_t *); 78 static void print_uint16d(sdp_data_t *); 79 static void print_uint16x(sdp_data_t *); 80 static void print_uint32d(sdp_data_t *); 81 static void print_uint32x(sdp_data_t *); 82 static void print_uuid(sdp_data_t *); 83 static void print_uuid_list(sdp_data_t *); 84 static void print_string(sdp_data_t *); 85 static void print_string_list(sdp_data_t *); 86 static void print_url(sdp_data_t *); 87 static void print_profile_version(sdp_data_t *); 88 static void print_codeset_string(const char *, size_t, const char *); 89 static void print_language_string(sdp_data_t *); 90 static void print_utf8_string(sdp_data_t *); 91 92 static void print_service_class_id_list(sdp_data_t *); 93 static void print_protocol_descriptor(sdp_data_t *); 94 static void print_protocol_descriptor_list(sdp_data_t *); 95 static void print_language_base_attribute_id_list(sdp_data_t *); 96 static void print_service_availability(sdp_data_t *); 97 static void print_bluetooth_profile_descriptor_list(sdp_data_t *); 98 static void print_additional_protocol_descriptor_lists(sdp_data_t *); 99 static void print_sds_version_number_list(sdp_data_t *); 100 static void print_ct_network(sdp_data_t *); 101 static void print_asrc_features(sdp_data_t *); 102 static void print_asink_features(sdp_data_t *); 103 static void print_avrcp_features(sdp_data_t *); 104 static void print_supported_data_stores(sdp_data_t *); 105 static void print_supported_formats(sdp_data_t *); 106 static void print_wap_addr(sdp_data_t *); 107 static void print_wap_gateway(sdp_data_t *); 108 static void print_wap_type(sdp_data_t *); 109 static void print_hid_version(sdp_data_t *); 110 static void print_hid_device_subclass(sdp_data_t *); 111 static void print_hid_descriptor_list(sdp_data_t *); 112 static void print_hid_langid_base_list(sdp_data_t *); 113 static void print_security_description(sdp_data_t *); 114 static void print_hf_features(sdp_data_t *); 115 static void print_hfag_network(sdp_data_t *); 116 static void print_hfag_features(sdp_data_t *); 117 static void print_net_access_type(sdp_data_t *); 118 static void print_pnp_source(sdp_data_t *); 119 static void print_mas_types(sdp_data_t *); 120 static void print_map_features(sdp_data_t *); 121 static void print_pse_repositories(sdp_data_t *); 122 static void print_pse_features(sdp_data_t *); 123 static void print_hdp_features(sdp_data_t *); 124 static void print_hdp_specification(sdp_data_t *); 125 static void print_mcap_procedures(sdp_data_t *); 126 static void print_character_repertoires(sdp_data_t *); 127 static void print_bip_capabilities(sdp_data_t *); 128 static void print_bip_features(sdp_data_t *); 129 static void print_bip_functions(sdp_data_t *); 130 static void print_bip_capacity(sdp_data_t *); 131 static void print_1284id(sdp_data_t *); 132 static void print_ctn_features(sdp_data_t *); 133 134 static void print_rfcomm(sdp_data_t *); 135 static void print_att(sdp_data_t *); 136 static void print_bnep(sdp_data_t *); 137 static void print_avctp(sdp_data_t *); 138 static void print_avdtp(sdp_data_t *); 139 static void print_l2cap(sdp_data_t *); 140 141 attr_t protocol_list[] = { 142 { 0x0001, "SDP", NULL }, 143 { 0x0002, "UDP", NULL }, 144 { 0x0003, "RFCOMM", print_rfcomm }, 145 { 0x0004, "TCP", NULL }, 146 { 0x0005, "TCS_BIN", NULL }, 147 { 0x0006, "TCS_AT", NULL }, 148 { 0x0007, "ATT", print_att }, 149 { 0x0008, "OBEX", NULL }, 150 { 0x0009, "IP", NULL }, 151 { 0x000a, "FTP", NULL }, 152 { 0x000c, "HTTP", NULL }, 153 { 0x000e, "WSP", NULL }, 154 { 0x000f, "BNEP", print_bnep }, 155 { 0x0010, "UPNP", NULL }, 156 { 0x0011, "HIDP", NULL }, 157 { 0x0012, "HARDCOPY_CONTROL_CHANNEL", NULL }, 158 { 0x0014, "HARDCOPY_DATA_CHANNEL", NULL }, 159 { 0x0016, "HARDCOPY_NOTIFICATION", NULL }, 160 { 0x0017, "AVCTP", print_avctp }, 161 { 0x0019, "AVDTP", print_avdtp }, 162 { 0x001b, "CMTP", NULL }, 163 { 0x001d, "UDI_C_PLANE", NULL }, 164 { 0x001e, "MCAP_CONTROL_CHANNEL", NULL }, 165 { 0x001f, "MCAP_DATA_CHANNEL", NULL }, 166 { 0x0100, "L2CAP", print_l2cap }, 167 }; 168 169 attr_t universal_attrs[] = { 170 { 0x0000, "ServiceRecordHandle", print_uint32x }, 171 { 0x0001, "ServiceClassIDList", print_service_class_id_list }, 172 { 0x0002, "ServiceRecordState", print_uint32x }, 173 { 0x0003, "ServiceID", print_uuid }, 174 { 0x0004, "ProtocolDescriptorList", print_protocol_descriptor_list }, 175 { 0x0005, "BrowseGroupList", print_uuid_list }, 176 { 0x0006, "LanguageBaseAttributeIDList", print_language_base_attribute_id_list }, 177 { 0x0007, "ServiceInfoTimeToLive", print_uint32d }, 178 { 0x0008, "ServiceAvailability", print_service_availability }, 179 { 0x0009, "BluetoothProfileDescriptorList", print_bluetooth_profile_descriptor_list }, 180 { 0x000a, "DocumentationURL", print_url }, 181 { 0x000b, "ClientExecutableURL", print_url }, 182 { 0x000c, "IconURL", print_url }, 183 { 0x000d, "AdditionalProtocolDescriptorLists", print_additional_protocol_descriptor_lists }, 184 }; 185 186 attr_t language_attrs[] = { /* Language Attribute Offsets */ 187 { 0x0000, "ServiceName", print_language_string }, 188 { 0x0001, "ServiceDescription", print_language_string }, 189 { 0x0002, "ProviderName", print_language_string }, 190 }; 191 192 attr_t sds_attrs[] = { /* Service Discovery Server */ 193 { 0x0200, "VersionNumberList", print_sds_version_number_list }, 194 { 0x0201, "ServiceDatabaseState", print_uint32x }, 195 }; 196 197 attr_t bgd_attrs[] = { /* Browse Group Descriptor */ 198 { 0x0200, "GroupID", print_uuid }, 199 }; 200 201 attr_t ct_attrs[] = { /* Cordless Telephony */ 202 { 0x0301, "ExternalNetwork", print_ct_network }, 203 }; 204 205 attr_t asrc_attrs[] = { /* Audio Source */ 206 { 0x0311, "SupportedFeatures", print_asrc_features }, 207 }; 208 209 attr_t asink_attrs[] = { /* Audio Sink */ 210 { 0x0311, "SupportedFeatures", print_asink_features }, 211 }; 212 213 attr_t avrcp_attrs[] = { /* Audio Video Remote Control Profile */ 214 { 0x0311, "SupportedFeatures", print_avrcp_features }, 215 }; 216 217 attr_t lan_attrs[] = { /* LAN Access Using PPP */ 218 { 0x0200, "IPSubnet", print_string }, 219 }; 220 221 attr_t dun_attrs[] = { /* Dialup Networking */ 222 { 0x0305, "AudioFeedbackSupport", print_bool }, 223 }; 224 225 attr_t irmc_sync_attrs[] = { /* IrMC Sync */ 226 { 0x0301, "SupportedDataStoresList", print_supported_data_stores }, 227 }; 228 229 attr_t opush_attrs[] = { /* Object Push */ 230 { 0x0200, "GeopL2capPSM", print_uint16x }, 231 { 0x0303, "SupportedFormatsList", print_supported_formats }, 232 }; 233 234 attr_t ft_attrs[] = { /* File Transfer */ 235 { 0x0200, "GeopL2capPSM", print_uint16x }, 236 }; 237 238 attr_t hset_attrs[] = { /* Headset */ 239 { 0x0302, "RemoteAudioVolumeControl", print_bool }, 240 }; 241 242 attr_t fax_attrs[] = { /* Fax */ 243 { 0x0302, "FAXClass1", print_bool }, 244 { 0x0303, "FAXClass2.0", print_bool }, 245 { 0x0304, "FAXClass2", print_bool }, 246 { 0x0305, "AudioFeedbackSupport", print_bool }, 247 }; 248 249 attr_t wap_attrs[] = { /* WAP Bearer */ 250 { 0x0306, "NetworkAddress", print_wap_addr }, 251 { 0x0307, "WAPGateway", print_wap_gateway }, 252 { 0x0308, "HomePageURL", print_url }, 253 { 0x0309, "WAPStackType", print_wap_type }, 254 }; 255 256 attr_t panu_attrs[] = { /* Personal Area Networking User */ 257 { 0x0200, "IpSubnet", print_string }, 258 { 0x030a, "SecurityDescription", print_security_description }, 259 }; 260 261 attr_t nap_attrs[] = { /* Network Access Point */ 262 { 0x0200, "IpSubnet", print_string }, 263 { 0x030a, "SecurityDescription", print_security_description }, 264 { 0x030b, "NetAccessType", print_net_access_type }, 265 { 0x030c, "MaxNetAccessRate", print_uint32d }, 266 { 0x030d, "IPv4Subnet", print_string }, 267 { 0x030e, "IPv6Subnet", print_string }, 268 }; 269 270 attr_t gn_attrs[] = { /* Group Network */ 271 { 0x0200, "IpSubnet", print_string }, 272 { 0x030a, "SecurityDescription", print_security_description }, 273 { 0x030d, "IPv4Subnet", print_string }, 274 { 0x030e, "IPv6Subnet", print_string }, 275 }; 276 277 attr_t bp_attrs[] = { /* Basic Printing */ 278 { 0x0350, "DocumentFormatsSupported", print_string_list }, 279 { 0x0352, "CharacterRepertoiresSupported", print_character_repertoires }, 280 { 0x0354, "XHTML-PrintImageFormatsSupported", print_string_list }, 281 { 0x0356, "ColorSupported", print_bool }, 282 { 0x0358, "1284ID", print_1284id }, 283 { 0x035a, "PrinterName", print_utf8_string }, 284 { 0x035c, "PrinterLocation", print_utf8_string }, 285 { 0x035e, "DuplexSupported", print_bool }, 286 { 0x0360, "MediaTypesSupported", print_string_list }, 287 { 0x0362, "MaxMediaWidth", print_uint16d }, 288 { 0x0364, "MaxMediaLength", print_uint16d }, 289 { 0x0366, "EnhancedLayoutSupport", print_bool }, 290 { 0x0368, "RUIFormatsSupported", print_string_list }, 291 { 0x0370, "ReferencePrintingRUISupported", print_bool }, 292 { 0x0372, "DirectPrintingRUISupported", print_bool }, 293 { 0x0374, "ReferencePrintingTopURL", print_url }, 294 { 0x0376, "DirectPrintingTopURL", print_url }, 295 { 0x037a, "DeviceName", print_utf8_string }, 296 }; 297 298 attr_t bi_attrs[] = { /* Basic Imaging */ 299 { 0x0200, "GeopL2capPSM", print_uint16x }, 300 { 0x0310, "SupportedCapabilities", print_bip_capabilities }, 301 { 0x0311, "SupportedFeatures", print_bip_features }, 302 { 0x0312, "SupportedFunctions", print_bip_functions }, 303 { 0x0313, "TotalImagingDataCapacity", print_bip_capacity }, 304 }; 305 306 attr_t hf_attrs[] = { /* Handsfree */ 307 { 0x0311, "SupportedFeatures", print_hf_features }, 308 }; 309 310 attr_t hfag_attrs[] = { /* Handsfree Audio Gateway */ 311 { 0x0301, "Network", print_hfag_network }, 312 { 0x0311, "SupportedFeatures", print_hfag_features }, 313 }; 314 315 attr_t rui_attrs[] = { /* Reflected User Interface */ 316 { 0x0368, "RUIFormatsSupported", print_string_list }, 317 { 0x0378, "PrinterAdminRUITopURL", print_url }, 318 }; 319 320 attr_t hid_attrs[] = { /* Human Interface Device */ 321 { 0x0200, "HIDDeviceReleaseNumber", print_hid_version }, 322 { 0x0201, "HIDParserVersion", print_hid_version }, 323 { 0x0202, "HIDDeviceSubClass", print_hid_device_subclass }, 324 { 0x0203, "HIDCountryCode", print_uint8x }, 325 { 0x0204, "HIDVirtualCable", print_bool }, 326 { 0x0205, "HIDReconnectInitiate", print_bool }, 327 { 0x0206, "HIDDescriptorList", print_hid_descriptor_list }, 328 { 0x0207, "HIDLANGIDBaseList", print_hid_langid_base_list }, 329 { 0x0208, "HIDSDPDisable", print_bool }, 330 { 0x0209, "HIDBatteryPower", print_bool }, 331 { 0x020a, "HIDRemoteWake", print_bool }, 332 { 0x020b, "HIDProfileVersion", print_profile_version }, 333 { 0x020c, "HIDSupervisionTimeout", print_uint16d }, 334 { 0x020d, "HIDNormallyConnectable", print_bool }, 335 { 0x020e, "HIDBootDevice", print_bool }, 336 { 0x020f, "HIDHostMaxLatency", print_uint16d }, 337 { 0x0210, "HIDHostMinTimeout", print_uint16d }, 338 }; 339 340 attr_t hcr_attrs[] = { /* Hardcopy Cable Replacement */ 341 { 0x0300, "1284ID", print_1284id }, 342 { 0x0302, "DeviceName", print_utf8_string }, 343 { 0x0304, "FriendlyName", print_utf8_string }, 344 { 0x0306, "DeviceLocation", print_utf8_string }, 345 }; 346 347 attr_t mps_attrs[] = { /* Multi-Profile Specification */ 348 { 0x0200, "SingleDeviceSupportedScenarios", NULL }, 349 { 0x0201, "MultiDeviceSupportedScenarios", NULL }, 350 { 0x0202, "SupportedProfileAndProtocolDependencies", print_uint16x }, 351 }; 352 353 attr_t cas_attrs[] = { /* Calendar, Tasks & Notes Access */ 354 { 0x0315, "InstanceID", print_uint8d }, 355 { 0x0317, "SupportedFeatures", print_ctn_features }, 356 }; 357 358 attr_t cns_attrs[] = { /* Calendar, Tasks & Notes Notification */ 359 { 0x0317, "SupportedFeatures", print_ctn_features }, 360 }; 361 362 attr_t pnp_attrs[] = { /* Device ID */ 363 { 0x0200, "SpecificationID", print_profile_version }, 364 { 0x0201, "VendorID", print_uint16x }, 365 { 0x0202, "ProductID", print_uint16x }, 366 { 0x0203, "Version", print_hid_version }, 367 { 0x0204, "PrimaryRecord", print_bool }, 368 { 0x0205, "VendorIDSource", print_pnp_source }, 369 }; 370 371 attr_t mas_attrs[] = { /* Message Access Server */ 372 { 0x0200, "GeopL2capPSM", print_uint16x }, 373 { 0x0315, "InstanceID", print_uint8d }, 374 { 0x0316, "SupportedMessageTypes", print_mas_types }, 375 { 0x0317, "SupportedFeatures", print_map_features }, 376 }; 377 378 attr_t mns_attrs[] = { /* Message Notification Server */ 379 { 0x0200, "GeopL2capPSM", print_uint16x }, 380 { 0x0317, "SupportedFeatures", print_map_features }, 381 }; 382 383 attr_t gnss_attrs[] = { /* Global Navigation Satellite System Server */ 384 { 0x0200, "SupportedFeatures", print_uint16x }, 385 }; 386 387 attr_t pse_attrs[] = { /* Phonebook Access Server */ 388 { 0x0200, "GeopL2capPSM", print_uint16x }, 389 { 0x0314, "SupportedRepositories", print_pse_repositories }, 390 { 0x0317, "SupportedFeatures", print_pse_features }, 391 }; 392 393 attr_t hdp_attrs[] = { /* Health Device Profile */ 394 { 0x0200, "SupportedFeaturesList", print_hdp_features }, 395 { 0x0301, "DataExchangeSpecification", print_hdp_specification }, 396 { 0x0302, "MCAPSupportedProcedures", print_mcap_procedures }, 397 }; 398 399 #define A(a) a, __arraycount(a) 400 service_t service_list[] = { 401 { 0x1000, "Service Discovery Server", A(sds_attrs) }, 402 { 0x1001, "Browse Group Descriptor", A(bgd_attrs) }, 403 { 0x1002, "Public Browse Root", NULL, 0 }, 404 { 0x1101, "Serial Port", NULL, 0 }, 405 { 0x1102, "LAN Access Using PPP", A(lan_attrs) }, 406 { 0x1103, "Dialup Networking", A(dun_attrs) }, 407 { 0x1104, "IrMC Sync", A(irmc_sync_attrs) }, 408 { 0x1105, "Object Push", A(opush_attrs) }, 409 { 0x1106, "File Transfer", A(ft_attrs) }, 410 { 0x1107, "IrMC Sync Command", NULL, 0 }, 411 { 0x1108, "Headset", A(hset_attrs) }, 412 { 0x1109, "Cordless Telephony", A(ct_attrs) }, 413 { 0x110a, "Audio Source", A(asrc_attrs) }, 414 { 0x110b, "Audio Sink", A(asink_attrs) }, 415 { 0x110c, "A/V Remote Control Target", A(avrcp_attrs) }, 416 { 0x110d, "Advanced Audio Distribution", NULL, 0 }, 417 { 0x110e, "A/V Remote Control", A(avrcp_attrs) }, 418 { 0x110f, "Video Conferencing", NULL, 0 }, 419 { 0x1110, "Intercom", NULL, 0 }, 420 { 0x1111, "Fax", A(fax_attrs) }, 421 { 0x1112, "Headset Audio Gateway", NULL, 0 }, 422 { 0x1113, "WAP", A(wap_attrs) }, 423 { 0x1114, "WAP Client", NULL, 0 }, 424 { 0x1115, "Personal Area Networking User", A(panu_attrs) }, 425 { 0x1116, "Network Access Point", A(nap_attrs) }, 426 { 0x1117, "Group Network", A(gn_attrs) }, 427 { 0x1118, "Direct Printing", A(bp_attrs) }, 428 { 0x1119, "Reference Printing", A(bp_attrs) }, 429 { 0x111a, "Imaging", NULL, 0 }, 430 { 0x111b, "Imaging Responder", A(bi_attrs) }, 431 { 0x111c, "Imaging Automatic Archive", A(bi_attrs) }, 432 { 0x111d, "Imaging Referenced Objects", A(bi_attrs) }, 433 { 0x111e, "Handsfree", A(hf_attrs) }, 434 { 0x111f, "Handsfree Audio Gateway", A(hfag_attrs) }, 435 { 0x1120, "Direct Printing Reference Objects", NULL, 0 }, 436 { 0x1121, "Reflected User Interface", A(rui_attrs) }, 437 { 0x1122, "Basic Printing", NULL, 0 }, 438 { 0x1123, "Printing Status", A(bp_attrs) }, 439 { 0x1124, "Human Interface Device", A(hid_attrs) }, 440 { 0x1125, "Hardcopy Cable Replacement", NULL, 0 }, 441 { 0x1126, "Hardcopy Cable Replacement Print", A(hcr_attrs) }, 442 { 0x1127, "Hardcopy Cable Replacement Scan", A(hcr_attrs) }, 443 { 0x1128, "Common ISDN Access", NULL, 0 }, 444 { 0x1129, "Video Conferencing GW", NULL, 0 }, 445 { 0x112a, "UDI MT", NULL, 0 }, 446 { 0x112b, "UDI TA", NULL, 0 }, 447 { 0x112c, "Audio/Video", NULL, 0 }, 448 { 0x112d, "SIM Access", NULL, 0 }, 449 { 0x112e, "Phonebook Access Client", NULL, 0 }, 450 { 0x112f, "Phonebook Access Server", A(pse_attrs) }, 451 { 0x1130, "Phonebook Access", NULL, 0 }, 452 { 0x1131, "Headset HS", NULL, 0 }, 453 { 0x1132, "Message Access Server", A(mas_attrs) }, 454 { 0x1133, "Message Notification Server", A(mns_attrs) }, 455 { 0x1134, "Message Access Profile", NULL, 0 }, 456 { 0x1135, "Global Navigation Satellite System Profile", NULL, 0 }, 457 { 0x1136, "Global Navigation Satellite System Server", A(gnss_attrs) }, 458 { 0x1137, "3D Display", NULL, 0 }, 459 { 0x1138, "3D Glasses", NULL, 0 }, 460 { 0x1139, "3D Synchronization", NULL, 0 }, 461 { 0x113a, "Multi-Profile Specification Profile",NULL, 0 }, 462 { 0x113b, "Multi-Profile Specification Server", A(mps_attrs) }, 463 { 0x113c, "Calendar, Tasks & Notes Access", A(cas_attrs) }, 464 { 0x113d, "Calendar, Tasks & Notes Notification",A(cns_attrs) }, 465 { 0x113e, "Calendar, Tasks & Notes Profile", NULL, 0 }, 466 { 0x1200, "PNP Information", A(pnp_attrs) }, 467 { 0x1201, "Generic Networking", NULL, 0 }, 468 { 0x1202, "Generic File Transfer", NULL, 0 }, 469 { 0x1203, "Generic Audio", NULL, 0 }, 470 { 0x1204, "Generic Telephony", NULL, 0 }, 471 { 0x1205, "UPNP", NULL, 0 }, 472 { 0x1206, "UPNP IP", NULL, 0 }, 473 { 0x1300, "UPNP IP PAN", NULL, 0 }, 474 { 0x1301, "UPNP IP LAP", NULL, 0 }, 475 { 0x1302, "UPNP IP L2CAP", NULL, 0 }, 476 { 0x1303, "Video Source", NULL, 0 }, 477 { 0x1304, "Video Sink", NULL, 0 }, 478 { 0x1305, "Video Distribution", NULL, 0 }, 479 { 0x1400, "HDP", NULL, 0 }, 480 { 0x1401, "HDP Source", A(hdp_attrs) }, 481 { 0x1402, "HDP Sink", A(hdp_attrs) }, 482 { 0x1800, "Generic Access Profile", NULL, 0 }, 483 { 0x1801, "Generic Attribute Server", NULL, 0 }, 484 }; 485 #undef A 486 487 /* extracted Service Class ID List */ 488 #define MAX_SERVICES 16 489 static size_t nservices; 490 static uint16_t service_class[MAX_SERVICES]; 491 492 /* extracted Language Base Attribute ID List */ 493 #define MAX_LANGUAGES 16 494 static int nlanguages; 495 static language_t language[MAX_LANGUAGES]; 496 static int current; 497 498 static bool 499 sdp_get_uint8(sdp_data_t *d, uint8_t *vp) 500 { 501 uintmax_t v; 502 503 if (sdp_data_type(d) != SDP_DATA_UINT8 504 || !sdp_get_uint(d, &v)) 505 return false; 506 507 *vp = (uint8_t)v; 508 return true; 509 } 510 511 static bool 512 sdp_get_uint16(sdp_data_t *d, uint16_t *vp) 513 { 514 uintmax_t v; 515 516 if (sdp_data_type(d) != SDP_DATA_UINT16 517 || !sdp_get_uint(d, &v)) 518 return false; 519 520 *vp = (uint16_t)v; 521 return true; 522 } 523 524 static bool 525 sdp_get_uint32(sdp_data_t *d, uint32_t *vp) 526 { 527 uintmax_t v; 528 529 if (sdp_data_type(d) != SDP_DATA_UINT32 530 || !sdp_get_uint(d, &v)) 531 return false; 532 533 *vp = (uint32_t)v; 534 return true; 535 } 536 537 static bool 538 sdp_get_uint64(sdp_data_t *d, uint64_t *vp) 539 { 540 uintmax_t v; 541 542 if (sdp_data_type(d) != SDP_DATA_UINT64 543 || !sdp_get_uint(d, &v)) 544 return false; 545 546 *vp = (uint64_t)v; 547 return true; 548 } 549 550 void 551 print_record(sdp_data_t *rec) 552 { 553 sdp_data_t value; 554 uint16_t id; 555 556 nservices = 0; 557 nlanguages = 0; 558 current = -1; 559 560 while (sdp_get_attr(rec, &id, &value)) { 561 if (Xflag) { 562 printf("AttributeID 0x%04x:\n", id); 563 print_hexdump(" ", value.next, 564 (size_t)(value.end - value.next)); 565 } else if (Rflag) { 566 printf("AttributeID 0x%04x:\n", id); 567 sdp_data_print(&value, 4); 568 } else if (print_universal_attribute(id, &value) 569 || print_language_attribute(id, &value) 570 || print_service_attribute(id, &value)) { 571 if (value.next != value.end) 572 printf(" [additional data ignored]\n"); 573 } else { 574 printf("AttributeID 0x%04x:\n", id); 575 sdp_data_print(&value, 4); 576 } 577 } 578 } 579 580 static const char * 581 string_uuid(uuid_t *uuid) 582 { 583 static char buf[64]; 584 const char *desc; 585 uuid_t u; 586 size_t i; 587 588 u = *uuid; 589 u.time_low = 0; 590 if (!uuid_equal(&u, &BLUETOOTH_BASE_UUID, NULL)) { 591 snprintf(buf, sizeof(buf), 592 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", 593 uuid->time_low, uuid->time_mid, uuid->time_hi_and_version, 594 uuid->clock_seq_hi_and_reserved, uuid->clock_seq_low, 595 uuid->node[0], uuid->node[1], uuid->node[2], 596 uuid->node[3], uuid->node[4], uuid->node[5]); 597 598 return buf; 599 } 600 601 desc = NULL; 602 for (i = 0; i < __arraycount(service_list); i++) { 603 if (uuid->time_low == service_list[i].class) { 604 desc = service_list[i].desc; 605 break; 606 } 607 } 608 609 for (i = 0; i < __arraycount(protocol_list); i++) { 610 if (uuid->time_low == protocol_list[i].id) { 611 desc = protocol_list[i].desc; 612 break; 613 } 614 } 615 616 if (!Nflag && desc) { 617 snprintf(buf, sizeof(buf), "%s", desc); 618 return buf; 619 } 620 621 snprintf(buf, sizeof(buf), "%s%s(0x%*.*x)", 622 (desc == NULL ? "" : desc), 623 (desc == NULL ? "" : " "), 624 (uuid->time_low > UINT16_MAX ? 8 : 4), 625 (uuid->time_low > UINT16_MAX ? 8 : 4), 626 uuid->time_low); 627 628 return buf; 629 } 630 631 static const char * 632 string_vis(const char *src, size_t len) 633 { 634 static char buf[50]; 635 char *dst = buf; 636 int style; 637 638 buf[0] = '\0'; 639 style = VIS_CSTYLE | VIS_NL; 640 while (len > 0 && (dst + 5) < (buf + sizeof(buf))) { 641 dst = vis(dst, src[0], style, (len > 1 ? src[1] : 0)); 642 src++; 643 len--; 644 } 645 646 return buf; 647 } 648 649 static void 650 print_hexdump(const char *title, const uint8_t *data, size_t len) 651 { 652 int n, i; 653 654 i = 0; 655 n = printf("%s", title); 656 657 while (len-- > 0) { 658 if (++i > 8) { 659 printf("\n%*s", n, ""); 660 i = 1; 661 } 662 663 printf(" 0x%02x", *data++); 664 } 665 666 printf("\n"); 667 } 668 669 static bool 670 print_attribute(uint16_t id, sdp_data_t *value, attr_t *attr, size_t count) 671 { 672 size_t i; 673 674 for (i = 0; i < count; i++) { 675 if (id == attr[i].id) { 676 printf("%s", attr[i].desc); 677 678 if (Nflag) { 679 printf(" ("); 680 681 if (current != -1) 682 printf("0x%04x + ", language[current].base); 683 684 printf("0x%04x)", id); 685 } 686 687 printf(": "); 688 689 if (attr[i].print == NULL) { 690 printf("\n"); 691 sdp_data_print(value, 4); 692 value->next = value->end; 693 } else { 694 (attr[i].print)(value); 695 } 696 697 return true; 698 } 699 } 700 701 return false; 702 } 703 704 static bool 705 print_universal_attribute(uint16_t id, sdp_data_t *value) 706 { 707 708 return print_attribute(id, value, 709 universal_attrs, __arraycount(universal_attrs)); 710 } 711 712 static bool 713 print_language_attribute(uint16_t id, sdp_data_t *value) 714 { 715 bool done = false; 716 717 for (current = 0; current < nlanguages && !done; current++) 718 done = print_attribute(id - language[current].base, value, 719 language_attrs, __arraycount(language_attrs)); 720 721 current = -1; 722 return done; 723 } 724 725 static bool 726 print_service_attribute(uint16_t id, sdp_data_t *value) 727 { 728 size_t i, j; 729 730 for (i = 0; i < nservices; i++) { 731 for (j = 0; j < __arraycount(service_list); j++) { 732 if (service_class[i] == service_list[j].class 733 && print_attribute(id, value, 734 service_list[j].attrs, service_list[j].nattr)) 735 return true; 736 } 737 } 738 739 return false; 740 } 741 742 static void 743 print_bool(sdp_data_t *data) 744 { 745 bool v; 746 747 if (!sdp_get_bool(data, &v)) 748 return; 749 750 printf("%s\n", (v ? "true" : "false")); 751 } 752 753 static void 754 print_uint8d(sdp_data_t *data) 755 { 756 uint8_t v; 757 758 if (!sdp_get_uint8(data, &v)) 759 return; 760 761 printf("%d\n", v); 762 } 763 764 static void 765 print_uint8x(sdp_data_t *data) 766 { 767 uint8_t v; 768 769 if (!sdp_get_uint8(data, &v)) 770 return; 771 772 printf("0x%02x\n", v); 773 } 774 775 static void 776 print_uint16d(sdp_data_t *data) 777 { 778 uint16_t v; 779 780 if (!sdp_get_uint16(data, &v)) 781 return; 782 783 printf("%d\n", v); 784 } 785 786 static void 787 print_uint16x(sdp_data_t *data) 788 { 789 uint16_t v; 790 791 if (!sdp_get_uint16(data, &v)) 792 return; 793 794 printf("0x%04x\n", v); 795 } 796 797 static void 798 print_uint32x(sdp_data_t *data) 799 { 800 uint32_t v; 801 802 if (!sdp_get_uint32(data, &v)) 803 return; 804 805 printf("0x%08x\n", v); 806 } 807 808 static void 809 print_uint32d(sdp_data_t *data) 810 { 811 uint32_t v; 812 813 if (!sdp_get_uint32(data, &v)) 814 return; 815 816 printf("%d\n", v); 817 } 818 819 static void 820 print_uuid(sdp_data_t *data) 821 { 822 uuid_t uuid; 823 824 if (!sdp_get_uuid(data, &uuid)) 825 return; 826 827 printf("%s\n", string_uuid(&uuid)); 828 } 829 830 static void 831 print_uuid_list(sdp_data_t *data) 832 { 833 sdp_data_t seq; 834 uuid_t uuid; 835 836 if (!sdp_get_seq(data, &seq)) 837 return; 838 839 printf("\n"); 840 while (sdp_get_uuid(&seq, &uuid)) 841 printf(" %s\n", string_uuid(&uuid)); 842 843 if (seq.next != seq.end) 844 printf(" [additional data]\n"); 845 } 846 847 static void 848 print_string(sdp_data_t *data) 849 { 850 char *str; 851 size_t len; 852 853 if (!sdp_get_str(data, &str, &len)) 854 return; 855 856 printf("\"%s\"\n", string_vis(str, len)); 857 } 858 859 static void 860 print_string_list(sdp_data_t *data) 861 { 862 char *str, *ep; 863 size_t len, l; 864 865 if (!sdp_get_str(data, &str, &len)) 866 return; 867 868 printf("\n"); 869 while (len > 0) { 870 ep = memchr(str, (int)',', len); 871 if (ep == NULL) { 872 l = len; 873 len = 0; 874 } else { 875 l = (size_t)(ep - str); 876 len -= l + 1; 877 ep++; 878 } 879 printf(" %s\n", string_vis(str, l)); 880 str = ep; 881 } 882 } 883 884 static void 885 print_url(sdp_data_t *data) 886 { 887 char *url; 888 size_t len; 889 890 if (!sdp_get_url(data, &url, &len)) 891 return; 892 893 printf("\"%s\"\n", string_vis(url, len)); 894 } 895 896 static void 897 print_profile_version(sdp_data_t *data) 898 { 899 uint16_t v; 900 901 if (!sdp_get_uint16(data, &v)) 902 return; 903 904 printf("v%d.%d\n", (v >> 8), (v & 0xff)); 905 } 906 907 static void 908 print_codeset_string(const char *src, size_t srclen, const char *codeset) 909 { 910 char buf[50], *dst; 911 iconv_t ih; 912 size_t dstlen; 913 914 dst = buf; 915 dstlen = sizeof(buf); 916 917 ih = iconv_open(nl_langinfo(CODESET), codeset); 918 if (ih == (iconv_t)-1) { 919 printf("Can't convert %s string\n", codeset); 920 return; 921 } 922 923 (void)iconv(ih, &src, &srclen, &dst, &dstlen); 924 925 iconv_close(ih); 926 927 printf("\"%.*s%s\n", (int)(sizeof(buf) - dstlen), buf, 928 (srclen > 0 ? " ..." : "\"")); 929 } 930 931 /* 932 * This should only be called through print_language_attribute() which 933 * sets codeset of the string to be printed. 934 */ 935 static void 936 print_language_string(sdp_data_t *data) 937 { 938 char *str; 939 size_t len; 940 941 if (!sdp_get_str(data, &str, &len)) 942 return; 943 944 print_codeset_string(str, len, language[current].codeset); 945 } 946 947 948 static void 949 print_utf8_string(sdp_data_t *data) 950 { 951 char *str; 952 size_t len; 953 954 if (!sdp_get_str(data, &str, &len)) 955 return; 956 957 print_codeset_string(str, len, "UTF-8"); 958 } 959 960 static void 961 print_service_class_id_list(sdp_data_t *data) 962 { 963 sdp_data_t seq; 964 uuid_t uuid; 965 966 if (!sdp_get_seq(data, &seq)) 967 return; 968 969 printf("\n"); 970 while (sdp_get_uuid(&seq, &uuid)) { 971 printf(" %s\n", string_uuid(&uuid)); 972 973 if (nservices < MAX_SERVICES) { 974 service_class[nservices] = uuid.time_low; 975 uuid.time_low = 0; 976 if (uuid_equal(&uuid, &BLUETOOTH_BASE_UUID, NULL)) 977 nservices++; 978 } 979 } 980 981 if (seq.next != seq.end) 982 printf(" [additional data]\n"); 983 } 984 985 static void 986 print_protocol_descriptor(sdp_data_t *data) 987 { 988 uuid_t u0, uuid; 989 size_t i; 990 991 if (!sdp_get_uuid(data, &uuid)) 992 return; 993 994 u0 = uuid; 995 u0.time_low = 0; 996 if (uuid_equal(&u0, &BLUETOOTH_BASE_UUID, NULL)) { 997 for (i = 0; i < __arraycount(protocol_list); i++) { 998 if (uuid.time_low == protocol_list[i].id) { 999 printf(" %s", protocol_list[i].desc); 1000 1001 if (Nflag) 1002 printf(" (0x%04x)", protocol_list[i].id); 1003 1004 if (protocol_list[i].print) 1005 (protocol_list[i].print)(data); 1006 1007 if (data->next != data->end) 1008 printf(" [additional data]"); 1009 1010 printf("\n"); 1011 return; 1012 } 1013 } 1014 } 1015 1016 printf(" %s\n", string_uuid(&uuid)); 1017 sdp_data_print(data, 4); 1018 data->next = data->end; 1019 } 1020 1021 static void 1022 print_protocol_descriptor_list(sdp_data_t *data) 1023 { 1024 sdp_data_t seq, proto; 1025 1026 printf("\n"); 1027 sdp_get_alt(data, data); /* strip [optional] alt header */ 1028 1029 while (sdp_get_seq(data, &seq)) { 1030 while (sdp_get_seq(&seq, &proto)) 1031 print_protocol_descriptor(&proto); 1032 1033 if (seq.next != seq.end) 1034 printf(" [additional protocol data]\n"); 1035 } 1036 1037 if (data->next != data->end) 1038 printf(" [additional data]\n"); 1039 } 1040 1041 static void 1042 print_language_base_attribute_id_list(sdp_data_t *data) 1043 { 1044 sdp_data_t list; 1045 uint16_t v; 1046 const char *codeset; 1047 char lang[2]; 1048 1049 if (!sdp_get_seq(data, &list)) 1050 return; 1051 1052 printf("\n"); 1053 while (list.next < list.end) { 1054 /* 1055 * ISO-639-1 natural language values are published at 1056 * http://www.loc.gov/standards/iso639-2/php/code-list.php 1057 */ 1058 if (!sdp_get_uint16(&list, &v)) 1059 break; 1060 1061 be16enc(lang, v); 1062 if (!islower((int)lang[0]) || !islower((int)lang[1])) 1063 break; 1064 1065 /* 1066 * MIBenum values are published at 1067 * http://www.iana.org/assignments/character-sets 1068 */ 1069 if (!sdp_get_uint16(&list, &v)) 1070 break; 1071 1072 switch(v) { 1073 case 3: codeset = "US-ASCII"; break; 1074 case 4: codeset = "ISO-8859-1"; break; 1075 case 5: codeset = "ISO-8859-2"; break; 1076 case 106: codeset = "UTF-8"; break; 1077 case 1013: codeset = "UTF-16BE"; break; 1078 case 1014: codeset = "UTF-16LE"; break; 1079 default: codeset = "Unknown"; break; 1080 } 1081 1082 if (!sdp_get_uint16(&list, &v)) 1083 break; 1084 1085 printf(" %.2s.%s base 0x%04x\n", lang, codeset, v); 1086 1087 if (nlanguages < MAX_LANGUAGES) { 1088 language[nlanguages].base = v; 1089 language[nlanguages].codeset = codeset; 1090 nlanguages++; 1091 } 1092 } 1093 1094 if (list.next != list.end) 1095 printf(" [additional data]\n"); 1096 } 1097 1098 static void 1099 print_service_availability(sdp_data_t *data) 1100 { 1101 uint8_t v; 1102 1103 if (!sdp_get_uint8(data, &v)) 1104 return; 1105 1106 printf("%d/%d\n", v, UINT8_MAX); 1107 } 1108 1109 static void 1110 print_bluetooth_profile_descriptor_list(sdp_data_t *data) 1111 { 1112 sdp_data_t seq, profile; 1113 uuid_t uuid; 1114 uint16_t v; 1115 1116 if (!sdp_get_seq(data, &seq)) 1117 return; 1118 1119 printf("\n"); 1120 while (seq.next < seq.end) { 1121 if (!sdp_get_seq(&seq, &profile) 1122 || !sdp_get_uuid(&profile, &uuid) 1123 || !sdp_get_uint16(&profile, &v)) 1124 break; 1125 1126 printf(" %s, v%d.%d", string_uuid(&uuid), 1127 (v >> 8), (v & 0xff)); 1128 1129 if (profile.next != profile.end) 1130 printf(" [additional profile data]"); 1131 1132 printf("\n"); 1133 } 1134 1135 if (seq.next != seq.end) 1136 printf(" [additional data]\n"); 1137 } 1138 1139 static void 1140 print_additional_protocol_descriptor_lists(sdp_data_t *data) 1141 { 1142 sdp_data_t seq, stack, proto; 1143 1144 printf("\n"); 1145 sdp_get_seq(data, &seq); 1146 1147 while (sdp_get_seq(&seq, &stack)) 1148 while (sdp_get_seq(&stack, &proto)) 1149 print_protocol_descriptor(&proto); 1150 1151 if (seq.next != seq.end) 1152 printf(" [additional data]\n"); 1153 } 1154 1155 static void 1156 print_sds_version_number_list(sdp_data_t *data) 1157 { 1158 sdp_data_t list; 1159 const char *sep; 1160 uint16_t v; 1161 1162 if (!sdp_get_seq(data, &list)) 1163 return; 1164 1165 sep = ""; 1166 while (sdp_get_uint16(&list, &v)) { 1167 printf("%sv%d.%d", sep, (v >> 8), (v & 0xff)); 1168 sep = ", "; 1169 } 1170 1171 if (list.next != list.end) 1172 printf(" [additional data]"); 1173 1174 printf("\n"); 1175 } 1176 1177 static void 1178 print_ct_network(sdp_data_t *data) 1179 { 1180 uint8_t v; 1181 1182 if (!sdp_get_uint8(data, &v)) 1183 return; 1184 1185 switch (v) { 1186 case 0x01: printf("PSTN"); break; 1187 case 0x02: printf("ISDN"); break; 1188 case 0x03: printf("GSM"); break; 1189 case 0x04: printf("CDMA"); break; 1190 case 0x05: printf("Analogue Cellular"); break; 1191 case 0x06: printf("Packet Switched"); break; 1192 case 0x07: printf("Other"); break; 1193 default: printf("0x%02x", v); break; 1194 } 1195 1196 printf("\n"); 1197 } 1198 1199 static void 1200 print_asrc_features(sdp_data_t *data) 1201 { 1202 uint16_t v; 1203 1204 if (!sdp_get_uint16(data, &v)) 1205 return; 1206 1207 if (Nflag) 1208 printf("(0x%04x)", v); 1209 1210 printf("\n"); 1211 if (v & (1<<0)) printf(" Player\n"); 1212 if (v & (1<<1)) printf(" Microphone\n"); 1213 if (v & (1<<2)) printf(" Tuner\n"); 1214 if (v & (1<<3)) printf(" Mixer\n"); 1215 } 1216 1217 static void 1218 print_asink_features(sdp_data_t *data) 1219 { 1220 uint16_t v; 1221 1222 if (!sdp_get_uint16(data, &v)) 1223 return; 1224 1225 if (Nflag) 1226 printf("(0x%04x)", v); 1227 1228 printf("\n"); 1229 if (v & (1<<0)) printf(" Headphone\n"); 1230 if (v & (1<<1)) printf(" Speaker\n"); 1231 if (v & (1<<2)) printf(" Recorder\n"); 1232 if (v & (1<<3)) printf(" Amplifier\n"); 1233 } 1234 1235 static void 1236 print_avrcp_features(sdp_data_t *data) 1237 { 1238 uint16_t v; 1239 1240 if (!sdp_get_uint16(data, &v)) 1241 return; 1242 1243 if (Nflag) 1244 printf("(0x%04x)", v); 1245 1246 printf("\n"); 1247 if (v & (1<<0)) printf(" Category 1\n"); 1248 if (v & (1<<1)) printf(" Category 2\n"); 1249 if (v & (1<<2)) printf(" Category 3\n"); 1250 if (v & (1<<3)) printf(" Category 4\n"); 1251 } 1252 1253 static void 1254 print_supported_data_stores(sdp_data_t *data) 1255 { 1256 sdp_data_t list; 1257 const char *sep; 1258 uint8_t v; 1259 1260 if (!sdp_get_seq(data, &list)) 1261 return; 1262 1263 sep = "\n "; 1264 while (sdp_get_uint8(&list, &v)) { 1265 printf("%s", sep); 1266 sep = ", "; 1267 1268 switch(v) { 1269 case 0x01: printf("Phonebook"); break; 1270 case 0x03: printf("Calendar"); break; 1271 case 0x05: printf("Notes"); break; 1272 case 0x06: printf("Messages"); break; 1273 default: printf("0x%02x", v); break; 1274 } 1275 } 1276 1277 if (list.next != list.end) 1278 printf(" [additional data]"); 1279 1280 printf("\n"); 1281 } 1282 1283 static void 1284 print_supported_formats(sdp_data_t *data) 1285 { 1286 sdp_data_t list; 1287 const char *sep; 1288 uint8_t v; 1289 1290 if (!sdp_get_seq(data, &list)) 1291 return; 1292 1293 sep = "\n "; 1294 while (sdp_get_uint8(&list, &v)) { 1295 printf("%s", sep); 1296 sep = ", "; 1297 1298 switch(v) { 1299 case 0x01: printf("vCard 2.1"); break; 1300 case 0x02: printf("vCard 3.0"); break; 1301 case 0x03: printf("vCal 1.0"); break; 1302 case 0x04: printf("iCal 2.0"); break; 1303 case 0x05: printf("vNote"); break; 1304 case 0x06: printf("vMessage"); break; 1305 case 0xff: printf("Any"); break; 1306 default: printf("0x%02x", v); break; 1307 } 1308 } 1309 1310 if (list.next != list.end) 1311 printf(" [additional data]"); 1312 1313 printf("\n"); 1314 } 1315 1316 static void 1317 print_wap_addr(sdp_data_t *data) 1318 { 1319 uint32_t v; 1320 1321 if (!sdp_get_uint32(data, &v)) 1322 return; 1323 1324 printf("%d.%d.%d.%d\n", 1325 ((v & 0xff000000) >> 24), ((v & 0x00ff0000) >> 16), 1326 ((v & 0x0000ff00) >> 8), (v & 0x000000ff)); 1327 } 1328 1329 static void 1330 print_wap_gateway(sdp_data_t *data) 1331 { 1332 uint8_t v; 1333 1334 if (!sdp_get_uint8(data, &v)) 1335 return; 1336 1337 switch(v) { 1338 case 0x01: printf("Origin Server\n"); break; 1339 case 0x02: printf("Proxy\n"); break; 1340 default: printf("0x%02x\n", v); break; 1341 } 1342 } 1343 1344 static void 1345 print_wap_type(sdp_data_t *data) 1346 { 1347 uint8_t v; 1348 1349 if (!sdp_get_uint8(data, &v)) 1350 return; 1351 1352 switch(v) { 1353 case 0x01: printf("Connectionless\n"); break; 1354 case 0x02: printf("Connection Oriented\n");break; 1355 case 0x03: printf("Both\n"); break; 1356 default: printf("0x%02x\n", v); break; 1357 } 1358 } 1359 1360 static void 1361 print_hid_version(sdp_data_t *data) 1362 { 1363 uint16_t v; 1364 1365 if (!sdp_get_uint16(data, &v)) 1366 return; 1367 1368 printf("v%d.%d.%d\n", 1369 ((v & 0xff00) >> 8), ((v & 0x00f0) >> 4), (v & 0x000f)); 1370 } 1371 1372 static void 1373 print_hid_device_subclass(sdp_data_t *data) 1374 { 1375 uint8_t v; 1376 1377 if (!sdp_get_uint8(data, &v)) 1378 return; 1379 1380 switch ((v & 0x3c) >> 2) { 1381 case 1: printf("Joystick"); break; 1382 case 2: printf("Gamepad"); break; 1383 case 3: printf("Remote Control"); break; 1384 case 4: printf("Sensing Device"); break; 1385 case 5: printf("Digitiser Tablet"); break; 1386 case 6: printf("Card Reader"); break; 1387 default: printf("Peripheral"); break; 1388 } 1389 1390 if (v & 0x40) printf(" <Keyboard>"); 1391 if (v & 0x80) printf(" <Mouse>"); 1392 1393 printf("\n"); 1394 } 1395 1396 static void 1397 print_hid_descriptor_list(sdp_data_t *data) 1398 { 1399 sdp_data_t list, seq; 1400 uint8_t type; 1401 const char *name; 1402 char *str; 1403 size_t len; 1404 1405 if (!sdp_get_seq(data, &list)) 1406 return; 1407 1408 printf("\n"); 1409 while (list.next < list.end) { 1410 if (!sdp_get_seq(&list, &seq) 1411 || !sdp_get_uint8(&seq, &type) 1412 || !sdp_get_str(&seq, &str, &len)) 1413 return; 1414 1415 switch (type) { 1416 case 0x22: name = "Report"; break; 1417 case 0x23: name = "Physical Descriptor"; break; 1418 default: name = ""; break; 1419 } 1420 1421 printf(" Type 0x%02x: %s\n", type, name); 1422 print_hexdump(" Data", (uint8_t *)str, len); 1423 1424 if (seq.next != seq.end) 1425 printf(" [additional data]\n"); 1426 } 1427 } 1428 1429 static void 1430 print_hid_langid_base_list(sdp_data_t *data) 1431 { 1432 sdp_data_t list, seq; 1433 uint16_t lang, base; 1434 1435 if (!sdp_get_seq(data, &list)) 1436 return; 1437 1438 while (list.next < list.end) { 1439 if (!sdp_get_seq(&list, &seq) 1440 || !sdp_get_uint16(&seq, &lang) 1441 || !sdp_get_uint16(&seq, &base)) 1442 return; 1443 1444 printf("\n "); 1445 /* 1446 * The language is encoded according to the 1447 * "Universal Serial Bus Language Identifiers (LANGIDs)" 1448 * specification. It does not seem worth listing them all 1449 * here, but feel free to add if you notice any being used. 1450 */ 1451 switch (lang) { 1452 case 0x0409: printf("English (US)"); break; 1453 case 0x0809: printf("English (UK)"); break; 1454 default: printf("0x%04x", lang); break; 1455 } 1456 1457 printf(" base 0x%04x%s\n", base, 1458 (seq.next == seq.end ? "" : " [additional data]")); 1459 } 1460 } 1461 1462 static void 1463 print_security_description(sdp_data_t *data) 1464 { 1465 uint16_t v; 1466 1467 if (!sdp_get_uint16(data, &v)) 1468 return; 1469 1470 switch (v) { 1471 case 0x0000: printf("None"); break; 1472 case 0x0001: printf("Service-level Security"); break; 1473 case 0x0002: printf("802.1x Security"); break; 1474 default: printf("0x%04x", v); break; 1475 } 1476 1477 printf("\n"); 1478 } 1479 1480 static void 1481 print_hf_features(sdp_data_t *data) 1482 { 1483 uint16_t v; 1484 1485 if (!sdp_get_uint16(data, &v)) 1486 return; 1487 1488 if (Nflag) 1489 printf("(0x%04x)", v); 1490 1491 printf("\n"); 1492 if (v & (1<<0)) printf(" Echo Cancellation/Noise Reduction\n"); 1493 if (v & (1<<1)) printf(" Call Waiting\n"); 1494 if (v & (1<<2)) printf(" Caller Line Identification\n"); 1495 if (v & (1<<3)) printf(" Voice Recognition\n"); 1496 if (v & (1<<4)) printf(" Volume Control\n"); 1497 } 1498 1499 static void 1500 print_hfag_network(sdp_data_t *data) 1501 { 1502 uint8_t v; 1503 1504 if (!sdp_get_uint8(data, &v)) 1505 return; 1506 1507 switch (v) { 1508 case 0x01: printf("Ability to reject a call"); break; 1509 case 0x02: printf("No ability to reject a call"); break; 1510 default: printf("0x%02x", v); break; 1511 } 1512 1513 printf("\n"); 1514 } 1515 1516 static void 1517 print_hfag_features(sdp_data_t *data) 1518 { 1519 uint16_t v; 1520 1521 if (!sdp_get_uint16(data, &v)) 1522 return; 1523 1524 if (Nflag) 1525 printf("(0x%04x)", v); 1526 1527 printf("\n"); 1528 if (v & (1<<0)) printf(" 3 Way Calling\n"); 1529 if (v & (1<<1)) printf(" Echo Cancellation/Noise Reduction\n"); 1530 if (v & (1<<2)) printf(" Voice Recognition\n"); 1531 if (v & (1<<3)) printf(" In-band Ring Tone\n"); 1532 if (v & (1<<4)) printf(" Voice Tags\n"); 1533 } 1534 1535 static void 1536 print_net_access_type(sdp_data_t *data) 1537 { 1538 uint16_t v; 1539 1540 if (!sdp_get_uint16(data, &v)) 1541 return; 1542 1543 switch(v) { 1544 case 0x0000: printf("PSTN"); break; 1545 case 0x0001: printf("ISDN"); break; 1546 case 0x0002: printf("DSL"); break; 1547 case 0x0003: printf("Cable Modem"); break; 1548 case 0x0004: printf("10Mb Ethernet"); break; 1549 case 0x0005: printf("100Mb Ethernet"); break; 1550 case 0x0006: printf("4Mb Token Ring"); break; 1551 case 0x0007: printf("16Mb Token Ring"); break; 1552 case 0x0008: printf("100Mb Token Ring"); break; 1553 case 0x0009: printf("FDDI"); break; 1554 case 0x000a: printf("GSM"); break; 1555 case 0x000b: printf("CDMA"); break; 1556 case 0x000c: printf("GPRS"); break; 1557 case 0x000d: printf("3G Cellular"); break; 1558 case 0xfffe: printf("other"); break; 1559 default: printf("0x%04x", v); break; 1560 } 1561 1562 printf("\n"); 1563 } 1564 1565 static void 1566 print_pnp_source(sdp_data_t *data) 1567 { 1568 uint16_t v; 1569 1570 if (!sdp_get_uint16(data, &v)) 1571 return; 1572 1573 switch (v) { 1574 case 0x0001: printf("Bluetooth SIG"); break; 1575 case 0x0002: printf("USB Implementers Forum"); break; 1576 default: printf("0x%04x", v); break; 1577 } 1578 1579 printf("\n"); 1580 } 1581 1582 static void 1583 print_mas_types(sdp_data_t *data) 1584 { 1585 uint8_t v; 1586 1587 if (!sdp_get_uint8(data, &v)) 1588 return; 1589 1590 if (Nflag) 1591 printf("(0x%02x)", v); 1592 1593 printf("\n"); 1594 if (v & (1<<0)) printf(" EMAIL\n"); 1595 if (v & (1<<1)) printf(" SMS_GSM\n"); 1596 if (v & (1<<2)) printf(" SMS_CDMA\n"); 1597 if (v & (1<<3)) printf(" MMS\n"); 1598 } 1599 1600 static void 1601 print_map_features(sdp_data_t *data) 1602 { 1603 uint32_t v; 1604 1605 if (!sdp_get_uint32(data, &v)) 1606 return; 1607 1608 if (Nflag) 1609 printf("(0x%08x)", v); 1610 1611 printf("\n"); 1612 if (v & (1<<0)) printf(" Notification Registration\n"); 1613 if (v & (1<<1)) printf(" Notification\n"); 1614 if (v & (1<<2)) printf(" Browsing\n"); 1615 if (v & (1<<3)) printf(" Uploading\n"); 1616 if (v & (1<<4)) printf(" Delete\n"); 1617 if (v & (1<<5)) printf(" Instance Information\n"); 1618 if (v & (1<<6)) printf(" Extended Event Report 1.1\n"); 1619 } 1620 1621 static void 1622 print_pse_repositories(sdp_data_t *data) 1623 { 1624 uint8_t v; 1625 1626 if (!sdp_get_uint8(data, &v)) 1627 return; 1628 1629 if (Nflag) 1630 printf("(0x%02x)", v); 1631 1632 printf("\n"); 1633 if (v & (1<<0)) printf(" Local Phonebook\n"); 1634 if (v & (1<<1)) printf(" SIM Card\n"); 1635 if (v & (1<<2)) printf(" Speed Dial\n"); 1636 if (v & (1<<3)) printf(" Favorites\n"); 1637 } 1638 1639 static void 1640 print_pse_features(sdp_data_t *data) 1641 { 1642 uint32_t v; 1643 1644 if (!sdp_get_uint32(data, &v)) 1645 return; 1646 1647 if (Nflag) 1648 printf("(0x%08x)", v); 1649 1650 printf("\n"); 1651 if (v & (1<<0)) printf(" Download\n"); 1652 if (v & (1<<1)) printf(" Browsing\n"); 1653 if (v & (1<<2)) printf(" Database Identifier\n"); 1654 if (v & (1<<3)) printf(" Folder Version Counters\n"); 1655 if (v & (1<<4)) printf(" vCard Selecting\n"); 1656 if (v & (1<<5)) printf(" Enhanced Missed Calls\n"); 1657 if (v & (1<<6)) printf(" X-BT-UCI vCard Property\n"); 1658 if (v & (1<<7)) printf(" X-BT-UID vCard Property\n"); 1659 if (v & (1<<8)) printf(" Contact Referencing\n"); 1660 if (v & (1<<9)) printf(" Default Contact Image Format\n"); 1661 } 1662 1663 static void 1664 print_hdp_features(sdp_data_t *data) 1665 { 1666 sdp_data_t seq, feature; 1667 char *str; 1668 size_t len; 1669 uint16_t type; 1670 uint8_t id, role; 1671 1672 if (!sdp_get_seq(data, &seq)) 1673 return; 1674 1675 printf("\n"); 1676 while (sdp_get_seq(&seq, &feature)) { 1677 if (!sdp_get_uint8(&feature, &id) 1678 || !sdp_get_uint16(&feature, &type) 1679 || !sdp_get_uint8(&feature, &role)) 1680 break; 1681 1682 printf(" # %d: ", id); 1683 1684 switch(type) { 1685 case 0x1004: printf("Pulse Oximeter"); break; 1686 case 0x1006: printf("Basic ECG"); break; 1687 case 0x1007: printf("Blood Pressure Monitor"); break; 1688 case 0x1008: printf("Body Thermometer"); break; 1689 case 0x100F: printf("Body Weight Scale"); break; 1690 case 0x1011: printf("Glucose Meter"); break; 1691 case 0x1012: printf("International Normalized Ratio Monitor"); break; 1692 case 0x1014: printf("Body Composition Analyzer"); break; 1693 case 0x1015: printf("Peak Flow Monitor"); break; 1694 case 0x1029: printf("Cardiovascular Fitness and Activity Monitor"); break; 1695 case 0x1068: printf("Step Counter"); break; 1696 case 0x102A: printf("Strength Fitness Equipment"); break; 1697 case 0x1047: printf("Independent Living Activity Hub"); break; 1698 case 0x1075: printf("Fall Sensor"); break; 1699 case 0x1076: printf("Personal Emergency Response Sensor"); break; 1700 case 0x1077: printf("Smoke Sensor"); break; 1701 case 0x1078: printf("Carbon Monoxide Sensor"); break; 1702 case 0x1079: printf("Water Sensor"); break; 1703 case 0x107A: printf("Gas Sensor"); break; 1704 case 0x107B: printf("Motion Sensor"); break; 1705 case 0x107C: printf("Property Exit Sensor"); break; 1706 case 0x107D: printf("Enuresis Sensor"); break; 1707 case 0x107E: printf("Contact Closure Sensor"); break; 1708 case 0x107F: printf("Usage Sensor"); break; 1709 case 0x1080: printf("Switch Sensor"); break; 1710 case 0x1081: printf("Medication Dosing Sensor"); break; 1711 case 0x1082: printf("Temperature Sensor"); break; 1712 case 0x1048: printf("Medication monitor"); break; 1713 default: printf("Type 0x%04x", type); break; 1714 } 1715 1716 switch(role) { 1717 case 0x00: printf(" [Source]"); break; 1718 case 0x01: printf(" [Sink]"); break; 1719 default: printf(" [Role 0x%02x]", role); break; 1720 } 1721 1722 printf("\n"); 1723 1724 if (sdp_get_str(&feature, &str, &len)) { 1725 int n; 1726 1727 /* This optional human-readable description should 1728 * be in the primary language encoding, which ought 1729 * to have a base of 0x0100 or if there isn't one, 1730 * use the first encoding listed 1731 */ 1732 for (n = 0; n < nlanguages; n++) { 1733 if (language[n].base == 0x0100) 1734 break; 1735 } 1736 1737 printf(" # %d: ", id); 1738 if (n < nlanguages) 1739 print_codeset_string(str, len, language[n].codeset); 1740 else if (n > 0) 1741 print_codeset_string(str, len, language[0].codeset); 1742 else 1743 printf("%s", string_vis(str, len)); 1744 1745 printf("\n"); 1746 } 1747 1748 if (feature.next != feature.end) 1749 printf(" [additional data in feature]\n"); 1750 } 1751 1752 if (seq.next != seq.end) 1753 printf(" [additional data]\n"); 1754 } 1755 1756 static void 1757 print_hdp_specification(sdp_data_t *data) 1758 { 1759 uint8_t v; 1760 1761 if (!sdp_get_uint8(data, &v)) 1762 return; 1763 1764 switch(v) { 1765 case 0x01: printf("ISO/IEEE 11073-20601\n"); break; 1766 default: printf("0x%02x\n", v); break; 1767 } 1768 } 1769 1770 static void 1771 print_mcap_procedures(sdp_data_t *data) 1772 { 1773 uint8_t v; 1774 1775 if (!sdp_get_uint8(data, &v)) 1776 return; 1777 1778 if (Nflag) 1779 printf("(0x%02x)", v); 1780 1781 printf("\n"); 1782 if (v & (1<<1)) printf(" Reconnect Initiation\n"); 1783 if (v & (1<<2)) printf(" Reconnect Acceptance\n"); 1784 if (v & (1<<3)) printf(" Clock Synchronization Protocol\n"); 1785 if (v & (1<<4)) printf(" Sync-Master Role\n"); 1786 } 1787 1788 static void 1789 print_character_repertoires(sdp_data_t *data) 1790 { 1791 uintmax_t v; 1792 1793 /* 1794 * we have no uint128 type so use uintmax as only 1795 * only 17-bits are currently defined, and if the 1796 * value is out of bounds it will be printed anyway 1797 */ 1798 if (sdp_data_type(data) != SDP_DATA_UINT128 1799 || !sdp_get_uint(data, &v)) 1800 return; 1801 1802 if (Nflag) 1803 printf("(0x%016jx)", v); 1804 1805 printf("\n"); 1806 if (v & (1<< 0)) printf(" ISO-8859-1\n"); 1807 if (v & (1<< 1)) printf(" ISO-8859-2\n"); 1808 if (v & (1<< 2)) printf(" ISO-8859-3\n"); 1809 if (v & (1<< 3)) printf(" ISO-8859-4\n"); 1810 if (v & (1<< 4)) printf(" ISO-8859-5\n"); 1811 if (v & (1<< 5)) printf(" ISO-8859-6\n"); 1812 if (v & (1<< 6)) printf(" ISO-8859-7\n"); 1813 if (v & (1<< 7)) printf(" ISO-8859-8\n"); 1814 if (v & (1<< 8)) printf(" ISO-8859-9\n"); 1815 if (v & (1<< 9)) printf(" ISO-8859-10\n"); 1816 if (v & (1<<10)) printf(" ISO-8859-13\n"); 1817 if (v & (1<<11)) printf(" ISO-8859-14\n"); 1818 if (v & (1<<12)) printf(" ISO-8859-15\n"); 1819 if (v & (1<<13)) printf(" GB18030\n"); 1820 if (v & (1<<14)) printf(" JIS X0208-1990, JIS X0201-1976\n"); 1821 if (v & (1<<15)) printf(" KSC 5601-1992\n"); 1822 if (v & (1<<16)) printf(" Big5\n"); 1823 if (v & (1<<17)) printf(" TIS-620\n"); 1824 } 1825 1826 static void 1827 print_bip_capabilities(sdp_data_t *data) 1828 { 1829 uint8_t v; 1830 1831 if (!sdp_get_uint8(data, &v)) 1832 return; 1833 1834 if (Nflag) 1835 printf("(0x%02x)", v); 1836 1837 printf("\n"); 1838 if (v & (1<< 0)) printf(" Generic imaging\n"); 1839 if (v & (1<< 1)) printf(" Capturing\n"); 1840 if (v & (1<< 2)) printf(" Printing\n"); 1841 if (v & (1<< 3)) printf(" Displaying\n"); 1842 } 1843 1844 static void 1845 print_bip_features(sdp_data_t *data) 1846 { 1847 uint16_t v; 1848 1849 if (!sdp_get_uint16(data, &v)) 1850 return; 1851 1852 if (Nflag) 1853 printf("(0x%04x)", v); 1854 1855 printf("\n"); 1856 if (v & (1<<0)) printf(" ImagePush\n"); 1857 if (v & (1<<1)) printf(" ImagePush-Store\n"); 1858 if (v & (1<<2)) printf(" ImagePush-Print\n"); 1859 if (v & (1<<3)) printf(" ImagePush-Display\n"); 1860 if (v & (1<<4)) printf(" ImagePull\n"); 1861 if (v & (1<<5)) printf(" AdvancedImagePrinting\n"); 1862 if (v & (1<<6)) printf(" AutomaticArchive\n"); 1863 if (v & (1<<7)) printf(" RemoteCamera\n"); 1864 if (v & (1<<8)) printf(" RemoteDisplay\n"); 1865 } 1866 1867 static void 1868 print_bip_functions(sdp_data_t *data) 1869 { 1870 uint32_t v; 1871 1872 if (!sdp_get_uint32(data, &v)) 1873 return; 1874 1875 if (Nflag) 1876 printf("(0x%08x)", v); 1877 1878 printf("\n"); 1879 if (v & (1<< 0)) printf(" GetCapabilities\n"); 1880 if (v & (1<< 1)) printf(" PutImage\n"); 1881 if (v & (1<< 2)) printf(" PutLinkedAttachment\n"); 1882 if (v & (1<< 3)) printf(" PutLinkedThumbnail\n"); 1883 if (v & (1<< 4)) printf(" RemoteDisplay\n"); 1884 if (v & (1<< 5)) printf(" GetImagesList\n"); 1885 if (v & (1<< 6)) printf(" GetImageProperties\n"); 1886 if (v & (1<< 7)) printf(" GetImage\n"); 1887 if (v & (1<< 8)) printf(" GetLinkedThumbnail\n"); 1888 if (v & (1<< 9)) printf(" GetLinkedAttachment\n"); 1889 if (v & (1<<10)) printf(" DeleteImage\n"); 1890 if (v & (1<<11)) printf(" StartPrint\n"); 1891 if (v & (1<<12)) printf(" GetPartialImage\n"); 1892 if (v & (1<<13)) printf(" StartArchive\n"); 1893 if (v & (1<<14)) printf(" GetMonitoringImage\n"); 1894 if (v & (1<<16)) printf(" GetStatus\n"); 1895 } 1896 1897 static void 1898 print_bip_capacity(sdp_data_t *data) 1899 { 1900 char buf[9]; 1901 uint64_t v; 1902 1903 if (!sdp_get_uint64(data, &v)) 1904 return; 1905 1906 if (v > INT64_MAX) { 1907 printf("more than "); 1908 v = INT64_MAX; 1909 } 1910 1911 (void)humanize_number(buf, sizeof(buf), (int64_t)v, 1912 "bytes", HN_AUTOSCALE, HN_NOSPACE); 1913 1914 printf("%s\n", buf); 1915 } 1916 1917 static void 1918 print_1284id(sdp_data_t *data) 1919 { 1920 char *str, *ep; 1921 size_t len, l; 1922 1923 if (!sdp_get_str(data, &str, &len)) 1924 return; 1925 1926 if (len < 2 || len != be16dec(str)) { 1927 printf("[invalid IEEE 1284 Device ID]\n"); 1928 return; 1929 } 1930 1931 str += 2; 1932 len -= 2; 1933 1934 printf("\n"); 1935 while (len > 0) { 1936 ep = memchr(str, (int)';', len); 1937 if (ep == NULL) { 1938 printf("[invalid IEEE 1284 Device ID]\n"); 1939 return; 1940 } 1941 1942 l = (size_t)(ep - str + 1); 1943 printf(" %s\n", string_vis(str, l)); 1944 str += l; 1945 len -= l; 1946 } 1947 } 1948 1949 static void 1950 print_ctn_features(sdp_data_t *data) 1951 { 1952 uint32_t v; 1953 1954 if (!sdp_get_uint32(data, &v)) 1955 return; 1956 1957 if (Nflag) 1958 printf("(0x%08x)", v); 1959 1960 printf("\n"); 1961 if (v & (1<<0)) printf(" Account Management\n"); 1962 if (v & (1<<1)) printf(" Notification\n"); 1963 if (v & (1<<2)) printf(" Browsing\n"); 1964 if (v & (1<<3)) printf(" Downloading\n"); 1965 if (v & (1<<4)) printf(" Uploading\n"); 1966 if (v & (1<<5)) printf(" Delete\n"); 1967 if (v & (1<<6)) printf(" Forward\n"); 1968 } 1969 1970 static void 1971 print_rfcomm(sdp_data_t *data) 1972 { 1973 uint8_t v; 1974 1975 if (sdp_get_uint8(data, &v)) 1976 printf(" (channel %d)", v); 1977 } 1978 1979 static void 1980 print_att(sdp_data_t *data) 1981 { 1982 uint16_t s, e; 1983 1984 if (sdp_get_uint16(data, &s) && sdp_get_uint16(data, &e)) 1985 printf(" (0x%04x .. 0x%04x)", s, e); 1986 } 1987 1988 static void 1989 print_bnep(sdp_data_t *data) 1990 { 1991 sdp_data_t seq; 1992 uint16_t v; 1993 const char *sep; 1994 1995 if (!sdp_get_uint16(data, &v) 1996 || !sdp_get_seq(data, &seq)) 1997 return; 1998 1999 printf(" (v%d.%d", (v >> 8), (v & 0xff)); 2000 sep = "; "; 2001 while (sdp_get_uint16(&seq, &v)) { 2002 printf("%s", sep); 2003 sep = ", "; 2004 2005 switch (v) { 2006 case 0x0800: printf("IPv4"); break; 2007 case 0x0806: printf("ARP"); break; 2008 case 0x8100: printf("802.1Q"); break; 2009 case 0x86dd: printf("IPv6"); break; 2010 default: printf("0x%04x", v); break; 2011 } 2012 } 2013 printf(")"); 2014 2015 if (seq.next != seq.end) 2016 printf(" [additional data]"); 2017 } 2018 2019 static void 2020 print_avctp(sdp_data_t *data) 2021 { 2022 uint16_t v; 2023 2024 if (sdp_get_uint16(data, &v)) 2025 printf(" (v%d.%d)", (v >> 8), (v & 0xff)); 2026 } 2027 2028 static void 2029 print_avdtp(sdp_data_t *data) 2030 { 2031 uint16_t v; 2032 2033 if (sdp_get_uint16(data, &v)) 2034 printf(" (v%d.%d)", (v >> 8), (v & 0xff)); 2035 } 2036 2037 static void 2038 print_l2cap(sdp_data_t *data) 2039 { 2040 uint16_t v; 2041 2042 if (sdp_get_uint16(data, &v)) 2043 printf(" (PSM 0x%04x)", v); 2044 } 2045