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