sdp_compat.c revision 1.2 1 1.2 plunky /* $NetBSD: sdp_compat.c,v 1.2 2009/05/14 19:12:45 plunky Exp $ */
2 1.1 plunky
3 1.1 plunky /*-
4 1.1 plunky * Copyright (c) 2006 Itronix Inc.
5 1.1 plunky * All rights reserved.
6 1.1 plunky *
7 1.1 plunky * Written by Iain Hibbert for Itronix Inc.
8 1.1 plunky *
9 1.1 plunky * Redistribution and use in source and binary forms, with or without
10 1.1 plunky * modification, are permitted provided that the following conditions
11 1.1 plunky * are met:
12 1.1 plunky * 1. Redistributions of source code must retain the above copyright
13 1.1 plunky * notice, this list of conditions and the following disclaimer.
14 1.1 plunky * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 plunky * notice, this list of conditions and the following disclaimer in the
16 1.1 plunky * documentation and/or other materials provided with the distribution.
17 1.1 plunky * 3. The name of Itronix Inc. may not be used to endorse
18 1.1 plunky * or promote products derived from this software without specific
19 1.1 plunky * prior written permission.
20 1.1 plunky *
21 1.1 plunky * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
22 1.1 plunky * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 1.1 plunky * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 1.1 plunky * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
25 1.1 plunky * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 1.1 plunky * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 1.1 plunky * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 1.1 plunky * ON ANY THEORY OF LIABILITY, WHETHER IN
29 1.1 plunky * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 1.1 plunky * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 1.1 plunky * POSSIBILITY OF SUCH DAMAGE.
32 1.1 plunky */
33 1.1 plunky /*-
34 1.1 plunky * Copyright (c) 2001-2003 Maksim Yevmenkin <m_evmenkin (at) yahoo.com>
35 1.1 plunky * All rights reserved.
36 1.1 plunky *
37 1.1 plunky * Redistribution and use in source and binary forms, with or without
38 1.1 plunky * modification, are permitted provided that the following conditions
39 1.1 plunky * are met:
40 1.1 plunky * 1. Redistributions of source code must retain the above copyright
41 1.1 plunky * notice, this list of conditions and the following disclaimer.
42 1.1 plunky * 2. Redistributions in binary form must reproduce the above copyright
43 1.1 plunky * notice, this list of conditions and the following disclaimer in the
44 1.1 plunky * documentation and/or other materials provided with the distribution.
45 1.1 plunky *
46 1.1 plunky * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
47 1.1 plunky * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 1.1 plunky * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 1.1 plunky * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
50 1.1 plunky * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 1.1 plunky * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52 1.1 plunky * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 1.1 plunky * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54 1.1 plunky * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 1.1 plunky * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 1.1 plunky * SUCH DAMAGE.
57 1.1 plunky */
58 1.1 plunky
59 1.1 plunky /*
60 1.1 plunky * This file provides compatibility with the original library API,
61 1.1 plunky * use -DSDP_COMPAT to access it.
62 1.1 plunky *
63 1.1 plunky * These functions are deprecated and will be removed eventually.
64 1.1 plunky *
65 1.1 plunky * sdp_open(laddr, raddr)
66 1.1 plunky * sdp_open_local(control)
67 1.1 plunky * sdp_close(session)
68 1.1 plunky * sdp_error(session)
69 1.1 plunky * sdp_search(session, plen, protos, alen, attrs, vlen, values)
70 1.1 plunky * sdp_register_service(session, uuid, bdaddr, data, datalen, handle)
71 1.1 plunky * sdp_change_service(session, handle, data, datalen)
72 1.1 plunky * sdp_unregister_service(session, handle)
73 1.1 plunky * sdp_attr2desc(attribute)
74 1.1 plunky * sdp_uuid2desc(uuid16)
75 1.1 plunky * sdp_print(level, start, end)
76 1.1 plunky */
77 1.1 plunky #define SDP_COMPAT
78 1.1 plunky
79 1.1 plunky #include <sys/cdefs.h>
80 1.2 plunky __RCSID("$NetBSD: sdp_compat.c,v 1.2 2009/05/14 19:12:45 plunky Exp $");
81 1.1 plunky
82 1.1 plunky #include <errno.h>
83 1.1 plunky #include <sdp.h>
84 1.1 plunky #include <stdlib.h>
85 1.1 plunky #include <string.h>
86 1.1 plunky #include <unistd.h>
87 1.1 plunky
88 1.1 plunky #include "sdp-int.h"
89 1.1 plunky
90 1.1 plunky struct sdp_compat {
91 1.1 plunky sdp_session_t ss;
92 1.1 plunky int error;
93 1.1 plunky uint8_t buf[256];
94 1.1 plunky };
95 1.1 plunky
96 1.1 plunky void *
97 1.1 plunky sdp_open(bdaddr_t const *l, bdaddr_t const *r)
98 1.1 plunky {
99 1.1 plunky struct sdp_compat *sc;
100 1.1 plunky
101 1.1 plunky sc = malloc(sizeof(struct sdp_compat));
102 1.1 plunky if (sc == NULL)
103 1.1 plunky return NULL;
104 1.1 plunky
105 1.1 plunky if (l == NULL || r == NULL) {
106 1.1 plunky sc->error = EINVAL;
107 1.1 plunky return sc;
108 1.1 plunky }
109 1.1 plunky
110 1.1 plunky sc->ss = _sdp_open(l, r);
111 1.1 plunky if (sc->ss == NULL) {
112 1.1 plunky sc->error = errno;
113 1.1 plunky return sc;
114 1.1 plunky }
115 1.1 plunky
116 1.1 plunky sc->error = 0;
117 1.1 plunky return sc;
118 1.1 plunky }
119 1.1 plunky
120 1.1 plunky void *
121 1.1 plunky sdp_open_local(char const *control)
122 1.1 plunky {
123 1.1 plunky struct sdp_compat *sc;
124 1.1 plunky
125 1.1 plunky sc = malloc(sizeof(struct sdp_compat));
126 1.1 plunky if (sc == NULL)
127 1.1 plunky return NULL;
128 1.1 plunky
129 1.1 plunky sc->ss = _sdp_open_local(control);
130 1.1 plunky if (sc->ss == NULL) {
131 1.1 plunky sc->error = errno;
132 1.1 plunky return sc;
133 1.1 plunky }
134 1.1 plunky
135 1.1 plunky sc->error = 0;
136 1.1 plunky return sc;
137 1.1 plunky }
138 1.1 plunky
139 1.1 plunky int32_t
140 1.1 plunky sdp_close(void *xss)
141 1.1 plunky {
142 1.1 plunky struct sdp_compat *sc = xss;
143 1.1 plunky
144 1.1 plunky if (sc == NULL)
145 1.1 plunky return 0;
146 1.1 plunky
147 1.1 plunky if (sc->ss != NULL)
148 1.1 plunky _sdp_close(sc->ss);
149 1.1 plunky
150 1.1 plunky free(sc);
151 1.1 plunky
152 1.1 plunky return 0;
153 1.1 plunky }
154 1.1 plunky
155 1.1 plunky int32_t
156 1.1 plunky sdp_error(void *xss)
157 1.1 plunky {
158 1.1 plunky struct sdp_compat *sc = xss;
159 1.1 plunky
160 1.1 plunky if (sc == NULL)
161 1.1 plunky return EINVAL;
162 1.1 plunky
163 1.1 plunky return sc->error;
164 1.1 plunky }
165 1.1 plunky
166 1.1 plunky int32_t
167 1.1 plunky sdp_search(void *xss, uint32_t plen, uint16_t const *pp, uint32_t alen,
168 1.1 plunky uint32_t const *ap, uint32_t vlen, sdp_attr_t *vp)
169 1.1 plunky {
170 1.1 plunky struct sdp_compat *sc = xss;
171 1.1 plunky sdp_data_t seq, ssp, ail, rsp, value;
172 1.1 plunky uint16_t attr;
173 1.2 plunky size_t i;
174 1.1 plunky bool rv;
175 1.1 plunky
176 1.1 plunky if (sc == NULL)
177 1.1 plunky return -1;
178 1.1 plunky
179 1.1 plunky if (plen == 0 || pp == NULL || alen == 0 || ap == NULL) {
180 1.1 plunky sc->error = EINVAL;
181 1.1 plunky return -1;
182 1.1 plunky }
183 1.1 plunky
184 1.1 plunky /*
185 1.1 plunky * encode ServiceSearchPattern
186 1.1 plunky */
187 1.1 plunky ssp.next = sc->buf;
188 1.1 plunky ssp.end = sc->buf + sizeof(sc->buf);
189 1.1 plunky for (i = 0; i < plen; i++)
190 1.1 plunky sdp_put_uuid16(&ssp, pp[i]);
191 1.1 plunky
192 1.1 plunky ssp.end = ssp.next;
193 1.1 plunky ssp.next = sc->buf;
194 1.1 plunky
195 1.1 plunky /*
196 1.1 plunky * encode AttributeIDList
197 1.1 plunky */
198 1.1 plunky ail.next = ssp.end;
199 1.1 plunky ail.end = sc->buf + sizeof(sc->buf);
200 1.1 plunky for (i = 0; i < alen; i++)
201 1.1 plunky sdp_put_uint32(&ail, ap[i]);
202 1.1 plunky
203 1.1 plunky ail.end = ail.next;
204 1.1 plunky ail.next = ssp.end;
205 1.1 plunky
206 1.1 plunky /*
207 1.1 plunky * perform ServiceSearchAttribute transaction
208 1.1 plunky */
209 1.1 plunky rv = sdp_service_search_attribute(sc->ss, &ssp, &ail, &rsp);
210 1.1 plunky if (rv == false) {
211 1.1 plunky sc->error = errno;
212 1.1 plunky return -1;
213 1.1 plunky }
214 1.1 plunky
215 1.1 plunky if (vp == NULL)
216 1.1 plunky return 0;
217 1.1 plunky
218 1.1 plunky /*
219 1.1 plunky * The response buffer is a list of data element sequences,
220 1.1 plunky * each containing a list of attribute/value pairs. We want to
221 1.1 plunky * parse those to the attribute array that the user passed in.
222 1.1 plunky */
223 1.1 plunky while (vlen > 0 && sdp_get_seq(&rsp, &seq)) {
224 1.1 plunky while (vlen > 0 && sdp_get_attr(&seq, &attr, &value)) {
225 1.1 plunky vp->attr = attr;
226 1.1 plunky if (vp->value != NULL) {
227 1.2 plunky if (value.end - value.next > (ssize_t)vp->vlen) {
228 1.1 plunky vp->flags = SDP_ATTR_TRUNCATED;
229 1.1 plunky } else {
230 1.1 plunky vp->flags = SDP_ATTR_OK;
231 1.1 plunky vp->vlen = value.end - value.next;
232 1.1 plunky }
233 1.1 plunky memcpy(vp->value, value.next, vp->vlen);
234 1.1 plunky } else {
235 1.1 plunky vp->flags = SDP_ATTR_INVALID;
236 1.1 plunky }
237 1.1 plunky
238 1.1 plunky vp++;
239 1.1 plunky vlen--;
240 1.1 plunky }
241 1.1 plunky }
242 1.1 plunky
243 1.1 plunky while (vlen-- > 0)
244 1.1 plunky vp++->flags = SDP_ATTR_INVALID;
245 1.1 plunky
246 1.1 plunky return 0;
247 1.1 plunky }
248 1.1 plunky
249 1.1 plunky int32_t
250 1.1 plunky sdp_register_service(void *xss, uint16_t uuid, bdaddr_t *bdaddr,
251 1.1 plunky uint8_t *data, uint32_t datalen, uint32_t *handle)
252 1.1 plunky {
253 1.1 plunky struct sdp_compat *sc = xss;
254 1.1 plunky struct iovec req[4];
255 1.1 plunky ssize_t len;
256 1.1 plunky
257 1.1 plunky if (sc == NULL)
258 1.1 plunky return -1;
259 1.1 plunky
260 1.1 plunky if (bdaddr == NULL || data == NULL || datalen == 0) {
261 1.1 plunky sc->error = EINVAL;
262 1.1 plunky return -1;
263 1.1 plunky }
264 1.1 plunky
265 1.1 plunky uuid = htobe16(uuid);
266 1.1 plunky req[1].iov_base = &uuid;
267 1.1 plunky req[1].iov_len = sizeof(uint16_t);
268 1.1 plunky
269 1.1 plunky req[2].iov_base = bdaddr;
270 1.1 plunky req[2].iov_len = sizeof(bdaddr_t);
271 1.1 plunky
272 1.1 plunky req[3].iov_base = data;
273 1.1 plunky req[3].iov_len = datalen;
274 1.1 plunky
275 1.1 plunky if (!_sdp_send_pdu(sc->ss, SDP_PDU_SERVICE_REGISTER_REQUEST,
276 1.1 plunky req, __arraycount(req))) {
277 1.1 plunky sc->error = errno;
278 1.1 plunky return -1;
279 1.1 plunky }
280 1.1 plunky
281 1.1 plunky len = _sdp_recv_pdu(sc->ss, SDP_PDU_ERROR_RESPONSE);
282 1.1 plunky if (len == -1) {
283 1.1 plunky sc->error = errno;
284 1.1 plunky return -1;
285 1.1 plunky }
286 1.1 plunky
287 1.1 plunky if (len != sizeof(uint16_t) + sizeof(uint32_t)
288 1.1 plunky || be16dec(sc->ss->ibuf) != 0) {
289 1.1 plunky sc->error = EIO;
290 1.1 plunky return -1;
291 1.1 plunky }
292 1.1 plunky
293 1.1 plunky if (handle != NULL)
294 1.1 plunky *handle = be32dec(sc->ss->ibuf + sizeof(uint16_t));
295 1.1 plunky
296 1.1 plunky return 0;
297 1.1 plunky }
298 1.1 plunky
299 1.1 plunky int32_t
300 1.1 plunky sdp_change_service(void *xss, uint32_t handle,
301 1.1 plunky uint8_t *data, uint32_t datalen)
302 1.1 plunky {
303 1.1 plunky struct sdp_compat *sc = xss;
304 1.1 plunky struct iovec req[3];
305 1.1 plunky ssize_t len;
306 1.1 plunky
307 1.1 plunky if (data == NULL || datalen == 0) {
308 1.1 plunky sc->error = EINVAL;
309 1.1 plunky return -1;
310 1.1 plunky }
311 1.1 plunky
312 1.1 plunky handle = htobe32(handle);
313 1.1 plunky req[1].iov_base = &handle;
314 1.1 plunky req[1].iov_len = sizeof(uint32_t);
315 1.1 plunky
316 1.1 plunky req[2].iov_base = data;
317 1.1 plunky req[2].iov_len = datalen;
318 1.1 plunky
319 1.1 plunky if (!_sdp_send_pdu(sc->ss, SDP_PDU_SERVICE_CHANGE_REQUEST,
320 1.1 plunky req, __arraycount(req))) {
321 1.1 plunky sc->error = errno;
322 1.1 plunky return -1;
323 1.1 plunky }
324 1.1 plunky
325 1.1 plunky len = _sdp_recv_pdu(sc->ss, SDP_PDU_ERROR_RESPONSE);
326 1.1 plunky if (len == -1) {
327 1.1 plunky sc->error = errno;
328 1.1 plunky return -1;
329 1.1 plunky }
330 1.1 plunky
331 1.1 plunky if (len != sizeof(uint16_t)
332 1.1 plunky || be16dec(sc->ss->ibuf) != 0) {
333 1.1 plunky sc->error = EIO;
334 1.1 plunky return -1;
335 1.1 plunky }
336 1.1 plunky
337 1.1 plunky return 0;
338 1.1 plunky }
339 1.1 plunky
340 1.1 plunky int32_t
341 1.1 plunky sdp_unregister_service(void *xss, uint32_t handle)
342 1.1 plunky {
343 1.1 plunky struct sdp_compat *sc = xss;
344 1.1 plunky struct iovec req[2];
345 1.1 plunky ssize_t len;
346 1.1 plunky
347 1.1 plunky handle = htobe32(handle);
348 1.1 plunky req[1].iov_base = &handle;
349 1.1 plunky req[1].iov_len = sizeof(uint32_t);
350 1.1 plunky
351 1.1 plunky if (!_sdp_send_pdu(sc->ss, SDP_PDU_SERVICE_UNREGISTER_REQUEST,
352 1.1 plunky req, __arraycount(req))) {
353 1.1 plunky sc->error = errno;
354 1.1 plunky return -1;
355 1.1 plunky }
356 1.1 plunky
357 1.1 plunky len = _sdp_recv_pdu(sc->ss, SDP_PDU_ERROR_RESPONSE);
358 1.1 plunky if (len == -1) {
359 1.1 plunky sc->error = errno;
360 1.1 plunky return -1;
361 1.1 plunky }
362 1.1 plunky
363 1.1 plunky if (len != sizeof(uint16_t)
364 1.1 plunky || be16dec(sc->ss->ibuf) != 0) {
365 1.1 plunky sc->error = EIO;
366 1.1 plunky return -1;
367 1.1 plunky }
368 1.1 plunky
369 1.1 plunky return 0;
370 1.1 plunky }
371 1.1 plunky
372 1.1 plunky /*
373 1.1 plunky * SDP attribute description
374 1.1 plunky */
375 1.1 plunky
376 1.1 plunky struct sdp_attr_desc {
377 1.1 plunky uint32_t attr;
378 1.1 plunky char const *desc;
379 1.1 plunky };
380 1.1 plunky typedef struct sdp_attr_desc sdp_attr_desc_t;
381 1.1 plunky typedef struct sdp_attr_desc * sdp_attr_desc_p;
382 1.1 plunky
383 1.1 plunky static sdp_attr_desc_t sdp_uuids_desc[] = {
384 1.1 plunky { SDP_UUID_PROTOCOL_SDP, "SDP", },
385 1.1 plunky { SDP_UUID_PROTOCOL_UDP, "UDP", },
386 1.1 plunky { SDP_UUID_PROTOCOL_RFCOMM, "RFCOMM", },
387 1.1 plunky { SDP_UUID_PROTOCOL_TCP, "TCP", },
388 1.1 plunky { SDP_UUID_PROTOCOL_TCS_BIN, "TCS BIN", },
389 1.1 plunky { SDP_UUID_PROTOCOL_TCS_AT, "TCS AT", },
390 1.1 plunky { SDP_UUID_PROTOCOL_OBEX, "OBEX", },
391 1.1 plunky { SDP_UUID_PROTOCOL_IP, "IP", },
392 1.1 plunky { SDP_UUID_PROTOCOL_FTP, "FTP", },
393 1.1 plunky { SDP_UUID_PROTOCOL_HTTP, "HTTP", },
394 1.1 plunky { SDP_UUID_PROTOCOL_WSP, "WSP", },
395 1.1 plunky { SDP_UUID_PROTOCOL_BNEP, "BNEP", },
396 1.1 plunky { SDP_UUID_PROTOCOL_UPNP, "UPNP", },
397 1.1 plunky { SDP_UUID_PROTOCOL_HIDP, "HIDP", },
398 1.1 plunky { SDP_UUID_PROTOCOL_HARDCOPY_CONTROL_CHANNEL, "Hardcopy Control Channel", },
399 1.1 plunky { SDP_UUID_PROTOCOL_HARDCOPY_DATA_CHANNEL, "Hardcopy Data Channel", },
400 1.1 plunky { SDP_UUID_PROTOCOL_HARDCOPY_NOTIFICATION, "Hardcopy Notification", },
401 1.1 plunky { SDP_UUID_PROTOCOL_AVCTP, "AVCTP", },
402 1.1 plunky { SDP_UUID_PROTOCOL_AVDTP, "AVDTP", },
403 1.1 plunky { SDP_UUID_PROTOCOL_CMPT, "CMPT", },
404 1.1 plunky { SDP_UUID_PROTOCOL_UDI_C_PLANE, "UDI C-Plane", },
405 1.1 plunky { SDP_UUID_PROTOCOL_L2CAP, "L2CAP", },
406 1.1 plunky /* Service Class IDs/Bluetooth Profile IDs */
407 1.1 plunky { SDP_SERVICE_CLASS_SERVICE_DISCOVERY_SERVER, "Service Discovery Server", },
408 1.1 plunky { SDP_SERVICE_CLASS_BROWSE_GROUP_DESCRIPTOR, "Browse Group Descriptor", },
409 1.1 plunky { SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP, "Public Browse Group", },
410 1.1 plunky { SDP_SERVICE_CLASS_SERIAL_PORT, "Serial Port", },
411 1.1 plunky { SDP_SERVICE_CLASS_LAN_ACCESS_USING_PPP, "LAN Access Using PPP", },
412 1.1 plunky { SDP_SERVICE_CLASS_DIALUP_NETWORKING, "Dial-Up Networking", },
413 1.1 plunky { SDP_SERVICE_CLASS_IR_MC_SYNC, "IrMC Sync", },
414 1.1 plunky { SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH, "OBEX Object Push", },
415 1.1 plunky { SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER, "OBEX File Transfer", },
416 1.1 plunky { SDP_SERVICE_CLASS_IR_MC_SYNC_COMMAND, "IrMC Sync Command", },
417 1.1 plunky { SDP_SERVICE_CLASS_HEADSET, "Headset", },
418 1.1 plunky { SDP_SERVICE_CLASS_CORDLESS_TELEPHONY, "Cordless Telephony", },
419 1.1 plunky { SDP_SERVICE_CLASS_AUDIO_SOURCE, "Audio Source", },
420 1.1 plunky { SDP_SERVICE_CLASS_AUDIO_SINK, "Audio Sink", },
421 1.1 plunky { SDP_SERVICE_CLASS_AV_REMOTE_CONTROL_TARGET, "A/V Remote Control Target", },
422 1.1 plunky { SDP_SERVICE_CLASS_ADVANCED_AUDIO_DISTRIBUTION, "Advanced Audio Distribution", },
423 1.1 plunky { SDP_SERVICE_CLASS_AV_REMOTE_CONTROL, "A/V Remote Control", },
424 1.1 plunky { SDP_SERVICE_CLASS_VIDEO_CONFERENCING, "Video Conferencing", },
425 1.1 plunky { SDP_SERVICE_CLASS_INTERCOM, "Intercom", },
426 1.1 plunky { SDP_SERVICE_CLASS_FAX, "Fax", },
427 1.1 plunky { SDP_SERVICE_CLASS_HEADSET_AUDIO_GATEWAY, "Headset Audio Gateway", },
428 1.1 plunky { SDP_SERVICE_CLASS_WAP, "WAP", },
429 1.1 plunky { SDP_SERVICE_CLASS_WAP_CLIENT, "WAP Client", },
430 1.1 plunky { SDP_SERVICE_CLASS_PANU, "PANU", },
431 1.1 plunky { SDP_SERVICE_CLASS_NAP, "Network Access Point", },
432 1.1 plunky { SDP_SERVICE_CLASS_GN, "GN", },
433 1.1 plunky { SDP_SERVICE_CLASS_DIRECT_PRINTING, "Direct Printing", },
434 1.1 plunky { SDP_SERVICE_CLASS_REFERENCE_PRINTING, "Reference Printing", },
435 1.1 plunky { SDP_SERVICE_CLASS_IMAGING, "Imaging", },
436 1.1 plunky { SDP_SERVICE_CLASS_IMAGING_RESPONDER, "Imaging Responder", },
437 1.1 plunky { SDP_SERVICE_CLASS_IMAGING_AUTOMATIC_ARCHIVE, "Imaging Automatic Archive", },
438 1.1 plunky { SDP_SERVICE_CLASS_IMAGING_REFERENCED_OBJECTS, "Imaging Referenced Objects", },
439 1.1 plunky { SDP_SERVICE_CLASS_HANDSFREE, "Handsfree", },
440 1.1 plunky { SDP_SERVICE_CLASS_HANDSFREE_AUDIO_GATEWAY, "Handsfree Audio Gateway", },
441 1.1 plunky { SDP_SERVICE_CLASS_DIRECT_PRINTING_REFERENCE_OBJECTS, "Direct Printing Reference Objects", },
442 1.1 plunky { SDP_SERVICE_CLASS_REFLECTED_UI, "Reflected UI", },
443 1.1 plunky { SDP_SERVICE_CLASS_BASIC_PRINTING, "Basic Printing", },
444 1.1 plunky { SDP_SERVICE_CLASS_PRINTING_STATUS, "Printing Status", },
445 1.1 plunky { SDP_SERVICE_CLASS_HUMAN_INTERFACE_DEVICE, "Human Interface Device", },
446 1.1 plunky { SDP_SERVICE_CLASS_HARDCOPY_CABLE_REPLACEMENT, "Hardcopy Cable Replacement", },
447 1.1 plunky { SDP_SERVICE_CLASS_HCR_PRINT, "HCR Print", },
448 1.1 plunky { SDP_SERVICE_CLASS_HCR_SCAN, "HCR Scan", },
449 1.1 plunky { SDP_SERVICE_CLASS_COMMON_ISDN_ACCESS, "Common ISDN Access", },
450 1.1 plunky { SDP_SERVICE_CLASS_VIDEO_CONFERENCING_GW, "Video Conferencing Gateway", },
451 1.1 plunky { SDP_SERVICE_CLASS_UDI_MT, "UDI MT", },
452 1.1 plunky { SDP_SERVICE_CLASS_UDI_TA, "UDI TA", },
453 1.1 plunky { SDP_SERVICE_CLASS_AUDIO_VIDEO, "Audio/Video", },
454 1.1 plunky { SDP_SERVICE_CLASS_SIM_ACCESS, "SIM Access", },
455 1.1 plunky { SDP_SERVICE_CLASS_PNP_INFORMATION, "PNP Information", },
456 1.1 plunky { SDP_SERVICE_CLASS_GENERIC_NETWORKING, "Generic Networking", },
457 1.1 plunky { SDP_SERVICE_CLASS_GENERIC_FILE_TRANSFER, "Generic File Transfer", },
458 1.1 plunky { SDP_SERVICE_CLASS_GENERIC_AUDIO, "Generic Audio", },
459 1.1 plunky { SDP_SERVICE_CLASS_GENERIC_TELEPHONY, "Generic Telephony", },
460 1.1 plunky { SDP_SERVICE_CLASS_UPNP, "UPNP", },
461 1.1 plunky { SDP_SERVICE_CLASS_UPNP_IP, "UPNP IP", },
462 1.1 plunky { SDP_SERVICE_CLASS_ESDP_UPNP_IP_PAN, "ESDP UPNP IP PAN", },
463 1.1 plunky { SDP_SERVICE_CLASS_ESDP_UPNP_IP_LAP, "ESDP UPNP IP LAP", },
464 1.1 plunky { SDP_SERVICE_CLASS_ESDP_UPNP_L2CAP, "ESDP UPNP L2CAP", },
465 1.1 plunky { 0xffff, NULL, }
466 1.1 plunky };
467 1.1 plunky
468 1.1 plunky static sdp_attr_desc_t sdp_attrs_desc[] = {
469 1.1 plunky { SDP_ATTR_SERVICE_RECORD_HANDLE,
470 1.1 plunky "Record handle",
471 1.1 plunky },
472 1.1 plunky { SDP_ATTR_SERVICE_CLASS_ID_LIST,
473 1.1 plunky "Service Class ID list",
474 1.1 plunky },
475 1.1 plunky { SDP_ATTR_SERVICE_RECORD_STATE,
476 1.1 plunky "Service Record State",
477 1.1 plunky },
478 1.1 plunky { SDP_ATTR_SERVICE_ID,
479 1.1 plunky "Service ID",
480 1.1 plunky },
481 1.1 plunky { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST,
482 1.1 plunky "Protocol Descriptor List",
483 1.1 plunky },
484 1.1 plunky { SDP_ATTR_BROWSE_GROUP_LIST,
485 1.1 plunky "Browse Group List",
486 1.1 plunky },
487 1.1 plunky { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST,
488 1.1 plunky "Language Base Attribute ID List",
489 1.1 plunky },
490 1.1 plunky { SDP_ATTR_SERVICE_INFO_TIME_TO_LIVE,
491 1.1 plunky "Service Info Time-To-Live",
492 1.1 plunky },
493 1.1 plunky { SDP_ATTR_SERVICE_AVAILABILITY,
494 1.1 plunky "Service Availability",
495 1.1 plunky },
496 1.1 plunky { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST,
497 1.1 plunky "Bluetooh Profile Descriptor List",
498 1.1 plunky },
499 1.1 plunky { SDP_ATTR_DOCUMENTATION_URL,
500 1.1 plunky "Documentation URL",
501 1.1 plunky },
502 1.1 plunky { SDP_ATTR_CLIENT_EXECUTABLE_URL,
503 1.1 plunky "Client Executable URL",
504 1.1 plunky },
505 1.1 plunky { SDP_ATTR_ICON_URL,
506 1.1 plunky "Icon URL",
507 1.1 plunky },
508 1.1 plunky { SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS,
509 1.1 plunky "Additional Protocol Descriptor Lists" },
510 1.1 plunky { SDP_ATTR_GROUP_ID,
511 1.1 plunky /*SDP_ATTR_IP_SUBNET,
512 1.1 plunky SDP_ATTR_VERSION_NUMBER_LIST*/
513 1.1 plunky "Group ID/IP Subnet/Version Number List",
514 1.1 plunky },
515 1.1 plunky { SDP_ATTR_SERVICE_DATABASE_STATE,
516 1.1 plunky "Service Database State",
517 1.1 plunky },
518 1.1 plunky { SDP_ATTR_SERVICE_VERSION,
519 1.1 plunky "Service Version",
520 1.1 plunky },
521 1.1 plunky { SDP_ATTR_EXTERNAL_NETWORK,
522 1.1 plunky /*SDP_ATTR_NETWORK,
523 1.1 plunky SDP_ATTR_SUPPORTED_DATA_STORES_LIST*/
524 1.1 plunky "External Network/Network/Supported Data Stores List",
525 1.1 plunky },
526 1.1 plunky { SDP_ATTR_FAX_CLASS1_SUPPORT,
527 1.1 plunky /*SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL*/
528 1.1 plunky "Fax Class1 Support/Remote Audio Volume Control",
529 1.1 plunky },
530 1.1 plunky { SDP_ATTR_FAX_CLASS20_SUPPORT,
531 1.1 plunky /*SDP_ATTR_SUPPORTED_FORMATS_LIST*/
532 1.1 plunky "Fax Class20 Support/Supported Formats List",
533 1.1 plunky },
534 1.1 plunky { SDP_ATTR_FAX_CLASS2_SUPPORT,
535 1.1 plunky "Fax Class2 Support",
536 1.1 plunky },
537 1.1 plunky { SDP_ATTR_AUDIO_FEEDBACK_SUPPORT,
538 1.1 plunky "Audio Feedback Support",
539 1.1 plunky },
540 1.1 plunky { SDP_ATTR_NETWORK_ADDRESS,
541 1.1 plunky "Network Address",
542 1.1 plunky },
543 1.1 plunky { SDP_ATTR_WAP_GATEWAY,
544 1.1 plunky "WAP Gateway",
545 1.1 plunky },
546 1.1 plunky { SDP_ATTR_HOME_PAGE_URL,
547 1.1 plunky "Home Page URL",
548 1.1 plunky },
549 1.1 plunky { SDP_ATTR_WAP_STACK_TYPE,
550 1.1 plunky "WAP Stack Type",
551 1.1 plunky },
552 1.1 plunky { SDP_ATTR_SECURITY_DESCRIPTION,
553 1.1 plunky "Security Description",
554 1.1 plunky },
555 1.1 plunky { SDP_ATTR_NET_ACCESS_TYPE,
556 1.1 plunky "Net Access Type",
557 1.1 plunky },
558 1.1 plunky { SDP_ATTR_MAX_NET_ACCESS_RATE,
559 1.1 plunky "Max Net Access Rate",
560 1.1 plunky },
561 1.1 plunky { SDP_ATTR_IPV4_SUBNET,
562 1.1 plunky "IPv4 Subnet",
563 1.1 plunky },
564 1.1 plunky { SDP_ATTR_IPV6_SUBNET,
565 1.1 plunky "IPv6 Subnet",
566 1.1 plunky },
567 1.1 plunky { SDP_ATTR_SUPPORTED_CAPABALITIES,
568 1.1 plunky "Supported Capabalities",
569 1.1 plunky },
570 1.1 plunky { SDP_ATTR_SUPPORTED_FEATURES,
571 1.1 plunky "Supported Features",
572 1.1 plunky },
573 1.1 plunky { SDP_ATTR_SUPPORTED_FUNCTIONS,
574 1.1 plunky "Supported Functions",
575 1.1 plunky },
576 1.1 plunky { SDP_ATTR_TOTAL_IMAGING_DATA_CAPACITY,
577 1.1 plunky "Total Imaging Data Capacity",
578 1.1 plunky },
579 1.1 plunky { 0xffff, NULL, }
580 1.1 plunky };
581 1.1 plunky
582 1.1 plunky char const *
583 1.1 plunky sdp_attr2desc(uint16_t attr)
584 1.1 plunky {
585 1.1 plunky register sdp_attr_desc_p a = sdp_attrs_desc;
586 1.1 plunky
587 1.1 plunky for (; a->desc != NULL; a++)
588 1.1 plunky if (attr == a->attr)
589 1.1 plunky break;
590 1.1 plunky
591 1.1 plunky return ((a->desc != NULL)? a->desc : "Unknown");
592 1.1 plunky }
593 1.1 plunky
594 1.1 plunky char const *
595 1.1 plunky sdp_uuid2desc(uint16_t uuid)
596 1.1 plunky {
597 1.1 plunky register sdp_attr_desc_p a = sdp_uuids_desc;
598 1.1 plunky
599 1.1 plunky for (; a->desc != NULL; a++)
600 1.1 plunky if (uuid == a->attr)
601 1.1 plunky break;
602 1.1 plunky
603 1.1 plunky return ((a->desc != NULL)? a->desc : "Unknown");
604 1.1 plunky }
605 1.1 plunky
606 1.1 plunky void
607 1.1 plunky sdp_print(uint32_t level, uint8_t *start, uint8_t const *end)
608 1.1 plunky {
609 1.1 plunky
610 1.1 plunky (void)_sdp_data_print(start, end, level);
611 1.1 plunky }
612