sdp.h revision 1.1.2.2 1 /* $NetBSD: sdp.h,v 1.1.2.2 2009/05/13 19:18:20 jym Exp $ */
2
3 /*-
4 * Copyright (c) 2006 Itronix Inc.
5 * All rights reserved.
6 *
7 * Written by Iain Hibbert for Itronix Inc.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of Itronix Inc. may not be used to endorse
18 * or promote products derived from this software without specific
19 * prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 * ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33 /*
34 * Copyright (c) 2001-2003, 2008 Maksim Yevmenkin <m_evmenkin (at) yahoo.com>
35 * All rights reserved.
36 *
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
39 * are met:
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 *
46 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
47 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
50 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 * SUCH DAMAGE.
57 *
58 * $FreeBSD: src/lib/libsdp/sdp.h,v 1.5 2005/05/27 19:11:33 emax Exp $
59 */
60
61 #ifndef _SDP_H_
62 #define _SDP_H_
63
64 #include <stdbool.h>
65 #include <uuid.h>
66
67 #include <bluetooth.h>
68
69 /*
70 * SDP Data Element types
71 */
72
73 #define SDP_DATA_TYPE(b) ((b) & 0xf8)
74 #define SDP_DATA_SIZE(b) ((b) & 0x07)
75
76 /* data size descriptors */
77 #define SDP_DATA_8 0x00
78 #define SDP_DATA_16 0x01
79 #define SDP_DATA_32 0x02
80 #define SDP_DATA_64 0x03
81 #define SDP_DATA_128 0x04
82 #define SDP_DATA_EXT8 0x05
83 #define SDP_DATA_EXT16 0x06
84 #define SDP_DATA_EXT32 0x07
85
86 /* data type descriptors */
87 #define SDP_DATA_NIL 0x00
88 #define SDP_DATA_UINT 0x08
89 #define SDP_DATA_INT 0x10
90 #define SDP_DATA_UUID 0x18
91 #define SDP_DATA_STR 0x20
92 #define SDP_DATA_BOOL 0x28
93 #define SDP_DATA_SEQ 0x30
94 #define SDP_DATA_ALT 0x38
95 #define SDP_DATA_URL 0x40
96
97 /* Unsigned integer */
98 #define SDP_DATA_UINT8 (SDP_DATA_UINT | SDP_DATA_8)
99 #define SDP_DATA_UINT16 (SDP_DATA_UINT | SDP_DATA_16)
100 #define SDP_DATA_UINT32 (SDP_DATA_UINT | SDP_DATA_32)
101 #define SDP_DATA_UINT64 (SDP_DATA_UINT | SDP_DATA_64)
102 #define SDP_DATA_UINT128 (SDP_DATA_UINT | SDP_DATA_128)
103
104 /* Signed two's-complement integer */
105 #define SDP_DATA_INT8 (SDP_DATA_INT | SDP_DATA_8)
106 #define SDP_DATA_INT16 (SDP_DATA_INT | SDP_DATA_16)
107 #define SDP_DATA_INT32 (SDP_DATA_INT | SDP_DATA_32)
108 #define SDP_DATA_INT64 (SDP_DATA_INT | SDP_DATA_64)
109 #define SDP_DATA_INT128 (SDP_DATA_INT | SDP_DATA_128)
110
111 /* UUID, a universally unique identifier */
112 #define SDP_DATA_UUID16 (SDP_DATA_UUID | SDP_DATA_16)
113 #define SDP_DATA_UUID32 (SDP_DATA_UUID | SDP_DATA_32)
114 #define SDP_DATA_UUID128 (SDP_DATA_UUID | SDP_DATA_128)
115
116 /* Text string */
117 #define SDP_DATA_STR8 (SDP_DATA_STR | SDP_DATA_EXT8)
118 #define SDP_DATA_STR16 (SDP_DATA_STR | SDP_DATA_EXT16)
119 #define SDP_DATA_STR32 (SDP_DATA_STR | SDP_DATA_EXT32)
120
121 /* Data element sequence */
122 #define SDP_DATA_SEQ8 (SDP_DATA_SEQ | SDP_DATA_EXT8)
123 #define SDP_DATA_SEQ16 (SDP_DATA_SEQ | SDP_DATA_EXT16)
124 #define SDP_DATA_SEQ32 (SDP_DATA_SEQ | SDP_DATA_EXT32)
125
126 /* Data element alternative */
127 #define SDP_DATA_ALT8 (SDP_DATA_ALT | SDP_DATA_EXT8)
128 #define SDP_DATA_ALT16 (SDP_DATA_ALT | SDP_DATA_EXT16)
129 #define SDP_DATA_ALT32 (SDP_DATA_ALT | SDP_DATA_EXT32)
130
131 /* URL, a uniform resource locator */
132 #define SDP_DATA_URL8 (SDP_DATA_URL | SDP_DATA_EXT8)
133 #define SDP_DATA_URL16 (SDP_DATA_URL | SDP_DATA_EXT16)
134 #define SDP_DATA_URL32 (SDP_DATA_URL | SDP_DATA_EXT32)
135
136 /*
137 * Protocol UUIDs (short alias version)
138 *
139 * BLUETOOTH BASE UUID 00000000-0000-1000-8000-00805F9B34FB
140 */
141 #define SDP_UUID_PROTOCOL_SDP 0x0001
142 #define SDP_UUID_PROTOCOL_UDP 0x0002
143 #define SDP_UUID_PROTOCOL_RFCOMM 0x0003
144 #define SDP_UUID_PROTOCOL_TCP 0x0004
145 #define SDP_UUID_PROTOCOL_TCS_BIN 0x0005
146 #define SDP_UUID_PROTOCOL_TCS_AT 0x0006
147 #define SDP_UUID_PROTOCOL_OBEX 0x0008
148 #define SDP_UUID_PROTOCOL_IP 0x0009
149 #define SDP_UUID_PROTOCOL_FTP 0x000A
150 #define SDP_UUID_PROTOCOL_HTTP 0x000C
151 #define SDP_UUID_PROTOCOL_WSP 0x000E
152 #define SDP_UUID_PROTOCOL_BNEP 0x000F
153 #define SDP_UUID_PROTOCOL_UPNP 0x0010
154 #define SDP_UUID_PROTOCOL_HIDP 0x0011
155 #define SDP_UUID_PROTOCOL_HARDCOPY_CONTROL_CHANNEL 0x0012
156 #define SDP_UUID_PROTOCOL_HARDCOPY_DATA_CHANNEL 0x0014
157 #define SDP_UUID_PROTOCOL_HARDCOPY_NOTIFICATION 0x0016
158 #define SDP_UUID_PROTOCOL_AVCTP 0x0017
159 #define SDP_UUID_PROTOCOL_AVDTP 0x0019
160 #define SDP_UUID_PROTOCOL_CMPT 0x001B
161 #define SDP_UUID_PROTOCOL_UDI_C_PLANE 0x001D
162 #define SDP_UUID_PROTOCOL_L2CAP 0x0100
163
164 /*
165 * Service Class IDs
166 */
167 #define SDP_SERVICE_CLASS_SERVICE_DISCOVERY_SERVER 0x1000
168 #define SDP_SERVICE_CLASS_BROWSE_GROUP_DESCRIPTOR 0x1001
169 #define SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP 0x1002
170 #define SDP_SERVICE_CLASS_SERIAL_PORT 0x1101
171 #define SDP_SERVICE_CLASS_LAN_ACCESS_USING_PPP 0x1102
172 #define SDP_SERVICE_CLASS_DIALUP_NETWORKING 0x1103
173 #define SDP_SERVICE_CLASS_IR_MC_SYNC 0x1104
174 #define SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH 0x1105
175 #define SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER 0x1106
176 #define SDP_SERVICE_CLASS_IR_MC_SYNC_COMMAND 0x1107
177 #define SDP_SERVICE_CLASS_HEADSET 0x1108
178 #define SDP_SERVICE_CLASS_CORDLESS_TELEPHONY 0x1109
179 #define SDP_SERVICE_CLASS_AUDIO_SOURCE 0x110A
180 #define SDP_SERVICE_CLASS_AUDIO_SINK 0x110B
181 #define SDP_SERVICE_CLASS_AV_REMOTE_CONTROL_TARGET 0x110C
182 #define SDP_SERVICE_CLASS_ADVANCED_AUDIO_DISTRIBUTION 0x110D
183 #define SDP_SERVICE_CLASS_AV_REMOTE_CONTROL 0x110E
184 #define SDP_SERVICE_CLASS_VIDEO_CONFERENCING 0x110F
185 #define SDP_SERVICE_CLASS_INTERCOM 0x1110
186 #define SDP_SERVICE_CLASS_FAX 0x1111
187 #define SDP_SERVICE_CLASS_HEADSET_AUDIO_GATEWAY 0x1112
188 #define SDP_SERVICE_CLASS_WAP 0x1113
189 #define SDP_SERVICE_CLASS_WAP_CLIENT 0x1114
190 #define SDP_SERVICE_CLASS_PANU 0x1115
191 #define SDP_SERVICE_CLASS_NAP 0x1116
192 #define SDP_SERVICE_CLASS_GN 0x1117
193 #define SDP_SERVICE_CLASS_DIRECT_PRINTING 0x1118
194 #define SDP_SERVICE_CLASS_REFERENCE_PRINTING 0x1119
195 #define SDP_SERVICE_CLASS_IMAGING 0x111A
196 #define SDP_SERVICE_CLASS_IMAGING_RESPONDER 0x111B
197 #define SDP_SERVICE_CLASS_IMAGING_AUTOMATIC_ARCHIVE 0x111C
198 #define SDP_SERVICE_CLASS_IMAGING_REFERENCED_OBJECTS 0x111D
199 #define SDP_SERVICE_CLASS_HANDSFREE 0x111E
200 #define SDP_SERVICE_CLASS_HANDSFREE_AUDIO_GATEWAY 0x111F
201 #define SDP_SERVICE_CLASS_DIRECT_PRINTING_REFERENCE_OBJECTS 0x1120
202 #define SDP_SERVICE_CLASS_REFLECTED_UI 0x1121
203 #define SDP_SERVICE_CLASS_BASIC_PRINTING 0x1122
204 #define SDP_SERVICE_CLASS_PRINTING_STATUS 0x1123
205 #define SDP_SERVICE_CLASS_HUMAN_INTERFACE_DEVICE 0x1124
206 #define SDP_SERVICE_CLASS_HARDCOPY_CABLE_REPLACEMENT 0x1125
207 #define SDP_SERVICE_CLASS_HCR_PRINT 0x1126
208 #define SDP_SERVICE_CLASS_HCR_SCAN 0x1127
209 #define SDP_SERVICE_CLASS_COMMON_ISDN_ACCESS 0x1128
210 #define SDP_SERVICE_CLASS_VIDEO_CONFERENCING_GW 0x1129
211 #define SDP_SERVICE_CLASS_UDI_MT 0x112A
212 #define SDP_SERVICE_CLASS_UDI_TA 0x112B
213 #define SDP_SERVICE_CLASS_AUDIO_VIDEO 0x112C
214 #define SDP_SERVICE_CLASS_SIM_ACCESS 0x112D
215 #define SDP_SERVICE_CLASS_PNP_INFORMATION 0x1200
216 #define SDP_SERVICE_CLASS_GENERIC_NETWORKING 0x1201
217 #define SDP_SERVICE_CLASS_GENERIC_FILE_TRANSFER 0x1202
218 #define SDP_SERVICE_CLASS_GENERIC_AUDIO 0x1203
219 #define SDP_SERVICE_CLASS_GENERIC_TELEPHONY 0x1204
220 #define SDP_SERVICE_CLASS_UPNP 0x1205
221 #define SDP_SERVICE_CLASS_UPNP_IP 0x1206
222 #define SDP_SERVICE_CLASS_ESDP_UPNP_IP_PAN 0x1300
223 #define SDP_SERVICE_CLASS_ESDP_UPNP_IP_LAP 0x1301
224 #define SDP_SERVICE_CLASS_ESDP_UPNP_L2CAP 0x1302
225
226 /*
227 * Universal Attribute definitions valid in all service classes
228 */
229 #define SDP_ATTR_SERVICE_RECORD_HANDLE 0x0000
230 #define SDP_ATTR_SERVICE_CLASS_ID_LIST 0x0001
231 #define SDP_ATTR_SERVICE_RECORD_STATE 0x0002
232 #define SDP_ATTR_SERVICE_ID 0x0003
233 #define SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST 0x0004
234 #define SDP_ATTR_BROWSE_GROUP_LIST 0x0005
235 #define SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST 0x0006
236 #define SDP_ATTR_SERVICE_INFO_TIME_TO_LIVE 0x0007
237 #define SDP_ATTR_SERVICE_AVAILABILITY 0x0008
238 #define SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST 0x0009
239 #define SDP_ATTR_DOCUMENTATION_URL 0x000A
240 #define SDP_ATTR_CLIENT_EXECUTABLE_URL 0x000B
241 #define SDP_ATTR_ICON_URL 0x000C
242 #define SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS 0x000D
243 /* 0x000E-0x01ff are reserved */
244
245 /*
246 * The offset must be added to the attribute ID base (contained in the
247 * LANGUAGE_BASE_ATTRIBUTE_ID_LIST attribute value) in order to compute
248 * the attribute ID for these attributes.
249 * The primary language base is always 0x0100.
250 */
251 #define SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID 0x0100
252 #define SDP_ATTR_SERVICE_NAME_OFFSET 0x0000
253 #define SDP_ATTR_SERVICE_DESCRIPTION_OFFSET 0x0001
254 #define SDP_ATTR_PROVIDER_NAME_OFFSET 0x0002
255
256 /* ServiceDiscoveryServer profile attribute definitions */
257 #define SDP_ATTR_VERSION_NUMBER_LIST 0x0200
258 #define SDP_ATTR_SERVICE_DATABASE_STATE 0x0201
259
260 /* BrowseGroupDescriptor profile attribute definitions */
261 #define SDP_ATTR_GROUP_ID 0x0200
262
263 /* Other profile attribute definitions */
264 #define SDP_ATTR_IP_SUBNET 0x0200
265 #define SDP_ATTR_SERVICE_VERSION 0x0300
266 #define SDP_ATTR_EXTERNAL_NETWORK 0x0301
267 #define SDP_ATTR_NETWORK 0x0301
268 #define SDP_ATTR_SUPPORTED_DATA_STORES_LIST 0x0301
269 #define SDP_ATTR_FAX_CLASS1_SUPPORT 0x0302
270 #define SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL 0x0302
271 #define SDP_ATTR_FAX_CLASS20_SUPPORT 0x0303
272 #define SDP_ATTR_SUPPORTED_FORMATS_LIST 0x0303
273 #define SDP_ATTR_FAX_CLASS2_SUPPORT 0x0304
274 #define SDP_ATTR_AUDIO_FEEDBACK_SUPPORT 0x0305
275 #define SDP_ATTR_NETWORK_ADDRESS 0x0306
276 #define SDP_ATTR_WAP_GATEWAY 0x0307
277 #define SDP_ATTR_HOME_PAGE_URL 0x0308
278 #define SDP_ATTR_WAP_STACK_TYPE 0x0309
279 #define SDP_ATTR_SECURITY_DESCRIPTION 0x030A
280 #define SDP_ATTR_NET_ACCESS_TYPE 0x030B
281 #define SDP_ATTR_MAX_NET_ACCESS_RATE 0x030C
282 #define SDP_ATTR_IPV4_SUBNET 0x030D
283 #define SDP_ATTR_IPV6_SUBNET 0x030E
284 #define SDP_ATTR_SUPPORTED_CAPABALITIES 0x0310
285 #define SDP_ATTR_SUPPORTED_FEATURES 0x0311
286 #define SDP_ATTR_SUPPORTED_FUNCTIONS 0x0312
287 #define SDP_ATTR_TOTAL_IMAGING_DATA_CAPACITY 0x0313
288
289 /*
290 * Protocol Data Unit (PDU) header format
291 */
292
293 typedef struct {
294 uint8_t pid; /* PDU ID - SDP_PDU_xxx */
295 uint16_t tid; /* transaction ID */
296 uint16_t len; /* parameters length (in bytes) */
297 } __packed sdp_pdu_t;
298
299 /* PDU IDs */
300 #define SDP_PDU_ERROR_RESPONSE 0x01
301 #define SDP_PDU_SERVICE_SEARCH_REQUEST 0x02
302 #define SDP_PDU_SERVICE_SEARCH_RESPONSE 0x03
303 #define SDP_PDU_SERVICE_ATTRIBUTE_REQUEST 0x04
304 #define SDP_PDU_SERVICE_ATTRIBUTE_RESPONSE 0x05
305 #define SDP_PDU_SERVICE_SEARCH_ATTRIBUTE_REQUEST 0x06
306 #define SDP_PDU_SERVICE_SEARCH_ATTRIBUTE_RESPONSE 0x07
307
308 /* Error codes for SDP_PDU_ERROR_RESPONSE */
309 #define SDP_ERROR_CODE_INVALID_SDP_VERSION 0x0001
310 #define SDP_ERROR_CODE_INVALID_SERVICE_RECORD_HANDLE 0x0002
311 #define SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX 0x0003
312 #define SDP_ERROR_CODE_INVALID_PDU_SIZE 0x0004
313 #define SDP_ERROR_CODE_INVALID_CONTINUATION_STATE 0x0005
314 #define SDP_ERROR_CODE_INSUFFICIENT_RESOURCES 0x0006
315
316
317 /*****************************************************************************
318 * sdpd(8) interface
319 */
320
321 #define SDP_LOCAL_PATH "/var/run/sdp"
322 #define SDP_LOCAL_MTU L2CAP_MTU_DEFAULT
323
324 /*
325 * These are NOT defined in spec and the requests are only accepted
326 * by sdpd(8) on the control socket. The response will be an Error
327 * Response with an ErrorCode of 0x0000 indicating success.
328 */
329 #define SDP_PDU_RECORD_INSERT_REQUEST 0x84
330 #define SDP_PDU_RECORD_UPDATE_REQUEST 0x86
331 #define SDP_PDU_RECORD_REMOVE_REQUEST 0x82
332
333
334 /******************************************************************************
335 * Service Discovery API in libbluetooth(3)
336 */
337
338 typedef struct {
339 uint8_t *next;
340 uint8_t *end;
341 } sdp_data_t;
342
343 typedef struct sdp_session *sdp_session_t;
344
345 /* sdp_uuid.c */
346 extern const uuid_t BLUETOOTH_BASE_UUID;
347
348 #ifndef SDP_COMPAT
349 /* sdp_session.c */
350 sdp_session_t sdp_open(const bdaddr_t *, const bdaddr_t *) __RENAME(_sdp_open);
351 sdp_session_t sdp_open_local(const char *) __RENAME(_sdp_open_local);
352 void sdp_close(sdp_session_t) __RENAME(_sdp_close);
353
354 /* sdp_record.c */
355 bool sdp_record_insert(sdp_session_t, bdaddr_t *, uint32_t *, const sdp_data_t *);
356 bool sdp_record_update(sdp_session_t, uint32_t, const sdp_data_t *);
357 bool sdp_record_remove(sdp_session_t, uint32_t);
358
359 /* sdp_service.c */
360 bool sdp_service_search(sdp_session_t, const sdp_data_t *, uint32_t *, int *);
361 bool sdp_service_attribute(sdp_session_t, uint32_t, const sdp_data_t *, sdp_data_t *);
362 bool sdp_service_search_attribute(sdp_session_t, const sdp_data_t *, const sdp_data_t *, sdp_data_t *);
363 #endif
364
365 /* sdp_match.c */
366 bool sdp_match_uuid16(sdp_data_t *, uint16_t);
367
368 /* sdp_get.c */
369 bool sdp_get_data(sdp_data_t *, sdp_data_t *);
370 bool sdp_get_attr(sdp_data_t *, uint16_t *, sdp_data_t *);
371 bool sdp_get_uuid(sdp_data_t *, uuid_t *);
372 bool sdp_get_bool(sdp_data_t *, bool *);
373 bool sdp_get_seq(sdp_data_t *, sdp_data_t *);
374 bool sdp_get_alt(sdp_data_t *, sdp_data_t *);
375 bool sdp_get_uint(sdp_data_t *, uintmax_t *);
376 bool sdp_get_int(sdp_data_t *, intmax_t *);
377 bool sdp_get_str(sdp_data_t *, char **, size_t *);
378 bool sdp_get_url(sdp_data_t *, char **, size_t *);
379
380 /* sdp_put.c */
381 bool sdp_put_data(sdp_data_t *, sdp_data_t *);
382 bool sdp_put_attr(sdp_data_t *, uint16_t, sdp_data_t *);
383 bool sdp_put_uuid(sdp_data_t *, const uuid_t *);
384 bool sdp_put_uuid16(sdp_data_t *, uint16_t);
385 bool sdp_put_uuid32(sdp_data_t *, uint32_t);
386 bool sdp_put_uuid128(sdp_data_t *, const uuid_t *);
387 bool sdp_put_bool(sdp_data_t *, bool);
388 bool sdp_put_uint(sdp_data_t *, uintmax_t);
389 bool sdp_put_uint8(sdp_data_t *, uint8_t);
390 bool sdp_put_uint16(sdp_data_t *, uint16_t);
391 bool sdp_put_uint32(sdp_data_t *, uint32_t);
392 bool sdp_put_uint64(sdp_data_t *, uint64_t);
393 bool sdp_put_int(sdp_data_t *, intmax_t);
394 bool sdp_put_int8(sdp_data_t *, int8_t);
395 bool sdp_put_int16(sdp_data_t *, int16_t);
396 bool sdp_put_int32(sdp_data_t *, int32_t);
397 bool sdp_put_int64(sdp_data_t *, int64_t);
398 bool sdp_put_seq(sdp_data_t *, ssize_t);
399 bool sdp_put_alt(sdp_data_t *, ssize_t);
400 bool sdp_put_str(sdp_data_t *, const char *, ssize_t);
401 bool sdp_put_url(sdp_data_t *, const char *, ssize_t);
402
403 /* sdp_set.c */
404 bool sdp_set_bool(const sdp_data_t *, bool);
405 bool sdp_set_uint(const sdp_data_t *, uintmax_t);
406 bool sdp_set_int(const sdp_data_t *, intmax_t);
407 bool sdp_set_seq(const sdp_data_t *, ssize_t);
408 bool sdp_set_alt(const sdp_data_t *, ssize_t);
409
410 /* sdp_data.c */
411 ssize_t sdp_data_size(const sdp_data_t *);
412 int sdp_data_type(const sdp_data_t *);
413 bool sdp_data_valid(const sdp_data_t *);
414 void sdp_data_print(const sdp_data_t *, int);
415
416 /******************************************************************************
417 *
418 * Source level compatibility with old API
419 *
420 * enable with -DSDP_COMPAT but it will be removed eventually
421 *
422 ******************************************************************************/
423
424 #ifdef SDP_COMPAT
425 #include <strings.h>
426
427 typedef sdp_pdu_t *sdp_pdu_p;
428
429 #define SDP_PDU_SERVICE_REGISTER_REQUEST 0x81
430 #define SDP_PDU_SERVICE_UNREGISTER_REQUEST 0x82
431 #define SDP_PDU_SERVICE_CHANGE_REQUEST 0x83
432
433 /*
434 * SDP int128/uint128 parameter
435 */
436
437 struct int128 {
438 int8_t b[16];
439 };
440 typedef struct int128 int128_t;
441 typedef struct int128 uint128_t;
442
443 /*
444 * SDP attribute
445 */
446
447 struct sdp_attr {
448 uint16_t flags;
449 #define SDP_ATTR_OK (0 << 0)
450 #define SDP_ATTR_INVALID (1 << 0)
451 #define SDP_ATTR_TRUNCATED (1 << 1)
452 uint16_t attr; /* SDP_ATTR_xxx */
453 uint32_t vlen; /* length of the value[] in bytes */
454 uint8_t *value; /* base pointer */
455 };
456 typedef struct sdp_attr sdp_attr_t;
457 typedef struct sdp_attr * sdp_attr_p;
458
459 #define SDP_ATTR_RANGE(lo, hi) \
460 (uint32_t)(((uint16_t)(lo) << 16) | ((uint16_t)(hi)))
461
462 /* sdp_compat.c */
463 void *sdp_open(bdaddr_t const *, bdaddr_t const *);
464 void *sdp_open_local(char const *);
465 int32_t sdp_close(void *);
466 int32_t sdp_error(void *);
467 int32_t sdp_search(void *, uint32_t, uint16_t const *, uint32_t, uint32_t const *, uint32_t, sdp_attr_t *);
468 int32_t sdp_register_service(void *, uint16_t, bdaddr_t *, uint8_t *, uint32_t, uint32_t *);
469 int32_t sdp_unregister_service(void *, uint32_t);
470 int32_t sdp_change_service(void *, uint32_t, uint8_t *, uint32_t);
471 const char *sdp_attr2desc(uint16_t);
472 const char *sdp_uuid2desc(uint16_t);
473 void sdp_print(uint32_t, uint8_t *, uint8_t const *);
474
475 /* Inline versions of get/put byte/short/long. Pointer is advanced */
476 #define SDP_GET8(b, cp) do { \
477 (b) = *(const uint8_t *)(cp); \
478 (cp) += sizeof(uint8_t); \
479 } while (/* CONSTCOND */0)
480
481 #define SDP_GET16(s, cp) do { \
482 (s) = be16dec(cp); \
483 (cp) += sizeof(uint16_t); \
484 } while (/* CONSTCOND */0)
485
486 #define SDP_GET32(l, cp) do { \
487 (l) = be32dec(cp); \
488 (cp) += sizeof(uint32_t); \
489 } while (/* CONSTCOND */0)
490
491 #define SDP_GET64(l, cp) do { \
492 (l) = be64dec(cp); \
493 (cp) += sizeof(uint64_t); \
494 } while (/* CONSTCOND */0)
495
496 #if BYTE_ORDER == LITTLE_ENDIAN
497 #define SDP_GET128(l, cp) do { \
498 register const uint8_t *t_cp = (const uint8_t *)(cp); \
499 (l)->b[15] = *t_cp++; \
500 (l)->b[14] = *t_cp++; \
501 (l)->b[13] = *t_cp++; \
502 (l)->b[12] = *t_cp++; \
503 (l)->b[11] = *t_cp++; \
504 (l)->b[10] = *t_cp++; \
505 (l)->b[9] = *t_cp++; \
506 (l)->b[8] = *t_cp++; \
507 (l)->b[7] = *t_cp++; \
508 (l)->b[6] = *t_cp++; \
509 (l)->b[5] = *t_cp++; \
510 (l)->b[4] = *t_cp++; \
511 (l)->b[3] = *t_cp++; \
512 (l)->b[2] = *t_cp++; \
513 (l)->b[1] = *t_cp++; \
514 (l)->b[0] = *t_cp++; \
515 (cp) += 16; \
516 } while (/* CONSTCOND */0)
517
518 #define SDP_GET_UUID128(l, cp) do { \
519 memcpy(&((l)->b), (cp), 16); \
520 (cp) += 16; \
521 } while (/* CONSTCOND */0)
522 #elif BYTE_ORDER == BIG_ENDIAN
523 #define SDP_GET128(l, cp) do { \
524 memcpy(&((l)->b), (cp), 16); \
525 (cp) += 16; \
526 } while (/* CONSTCOND */0)
527
528 #define SDP_GET_UUID128(l, cp) SDP_GET128(l, cp)
529 #else
530 #error "Unsupported BYTE_ORDER"
531 #endif /* BYTE_ORDER */
532
533 #define SDP_PUT8(b, cp) do { \
534 *(uint8_t *)(cp) = (b); \
535 (cp) += sizeof(uint8_t); \
536 } while (/* CONSTCOND */0)
537
538 #define SDP_PUT16(s, cp) do { \
539 be16enc((cp), (s)); \
540 (cp) += sizeof(uint16_t); \
541 } while (/* CONSTCOND */0)
542
543 #define SDP_PUT32(s, cp) do { \
544 be32enc((cp), (s)); \
545 (cp) += sizeof(uint32_t); \
546 } while (/* CONSTCOND */0)
547
548 #define SDP_PUT64(s, cp) do { \
549 be64enc((cp), (s)); \
550 (cp) += sizeof(uint64_t); \
551 } while (/* CONSTCOND */0)
552
553 #if BYTE_ORDER == LITTLE_ENDIAN
554 #define SDP_PUT128(l, cp) do { \
555 register const uint8_t *t_cp = (const uint8_t *)(cp); \
556 *t_cp++ = (l)->b[15]; \
557 *t_cp++ = (l)->b[14]; \
558 *t_cp++ = (l)->b[13]; \
559 *t_cp++ = (l)->b[12]; \
560 *t_cp++ = (l)->b[11]; \
561 *t_cp++ = (l)->b[10]; \
562 *t_cp++ = (l)->b[9]; \
563 *t_cp++ = (l)->b[8]; \
564 *t_cp++ = (l)->b[7]; \
565 *t_cp++ = (l)->b[6]; \
566 *t_cp++ = (l)->b[5]; \
567 *t_cp++ = (l)->b[4]; \
568 *t_cp++ = (l)->b[3]; \
569 *t_cp++ = (l)->b[2]; \
570 *t_cp++ = (l)->b[1]; \
571 *t_cp = (l)->b[0]; \
572 (cp) += 16; \
573 } while (/* CONSTCOND */0)
574
575 #define SDP_PUT_UUID128(l, cp) do { \
576 memcpy((cp), &((l)->b), 16); \
577 (cp) += 16; \
578 } while (/* CONSTCOND */0)
579 #elif BYTE_ORDER == BIG_ENDIAN
580 #define SDP_PUT128(l, cp) do { \
581 memcpy((cp), &((l)->b), 16); \
582 (cp) += 16; \
583 } while (/* CONSTCOND */0)
584
585 #define SDP_PUT_UUID128(l, cp) SDP_PUT128(l, cp)
586 #else
587 #error "Unsupported BYTE_ORDER"
588 #endif /* BYTE_ORDER */
589
590 struct sdp_dun_profile
591 {
592 uint8_t server_channel;
593 uint8_t audio_feedback_support;
594 uint8_t reserved[2];
595 };
596 typedef struct sdp_dun_profile sdp_dun_profile_t;
597 typedef struct sdp_dun_profile * sdp_dun_profile_p;
598
599 struct sdp_ftrn_profile
600 {
601 uint8_t server_channel;
602 uint8_t reserved[3];
603 };
604 typedef struct sdp_ftrn_profile sdp_ftrn_profile_t;
605 typedef struct sdp_ftrn_profile * sdp_ftrn_profile_p;
606
607 struct sdp_hset_profile
608 {
609 uint8_t server_channel;
610 uint8_t reserved[3];
611 };
612 typedef struct sdp_hset_profile sdp_hset_profile_t;
613 typedef struct sdp_hset_profile * sdp_hset_profile_p;
614
615 struct sdp_hf_profile
616 {
617 uint8_t server_channel;
618 uint16_t supported_features;
619 };
620 typedef struct sdp_hf_profile sdp_hf_profile_t;
621 typedef struct sdp_hf_profile * sdp_hf_profile_p;
622
623 /* Keep this in sync with sdp_opush_profile */
624 struct sdp_irmc_profile
625 {
626 uint8_t server_channel;
627 uint8_t supported_formats_size;
628 uint8_t supported_formats[30];
629 };
630 typedef struct sdp_irmc_profile sdp_irmc_profile_t;
631 typedef struct sdp_irmc_profile * sdp_irmc_profile_p;
632
633 struct sdp_irmc_command_profile
634 {
635 uint8_t server_channel;
636 uint8_t reserved[3];
637 };
638 typedef struct sdp_irmc_command_profile sdp_irmc_command_profile_t;
639 typedef struct sdp_irmc_command_profile * sdp_irmc_command_profile_p;
640
641 struct sdp_lan_profile
642 {
643 uint8_t server_channel;
644 uint8_t load_factor;
645 uint8_t reserved;
646 uint8_t ip_subnet_radius;
647 uint32_t ip_subnet;
648 };
649 typedef struct sdp_lan_profile sdp_lan_profile_t;
650 typedef struct sdp_lan_profile * sdp_lan_profile_p;
651
652 /* Keep this in sync with sdp_irmc_profile */
653 struct sdp_opush_profile
654 {
655 uint8_t server_channel;
656 uint8_t supported_formats_size;
657 uint8_t supported_formats[30];
658 };
659 typedef struct sdp_opush_profile sdp_opush_profile_t;
660 typedef struct sdp_opush_profile * sdp_opush_profile_p;
661
662 struct sdp_sp_profile
663 {
664 uint8_t server_channel;
665 uint8_t reserved[3];
666 };
667 typedef struct sdp_sp_profile sdp_sp_profile_t;
668 typedef struct sdp_sp_profile * sdp_sp_profile_p;
669
670 struct sdp_nap_profile
671 {
672 uint8_t reserved;
673 uint8_t load_factor;
674 uint16_t psm;
675 uint16_t security_description;
676 uint16_t net_access_type;
677 uint32_t max_net_access_rate;
678 };
679 typedef struct sdp_nap_profile sdp_nap_profile_t;
680 typedef struct sdp_nap_profile * sdp_nap_profile_p;
681
682 struct sdp_gn_profile
683 {
684 uint8_t reserved;
685 uint8_t load_factor;
686 uint16_t psm;
687 uint16_t security_description;
688 uint16_t reserved2;
689 uint32_t reserved3;
690 };
691 typedef struct sdp_gn_profile sdp_gn_profile_t;
692 typedef struct sdp_gn_profile * sdp_gn_profile_p;
693
694 struct sdp_panu_profile
695 {
696 uint8_t reserved;
697 uint8_t load_factor;
698 uint16_t psm;
699 uint16_t security_description;
700 uint16_t reserved2;
701 uint32_t reserved3;
702 };
703 typedef struct sdp_panu_profile sdp_panu_profile_t;
704 typedef struct sdp_panu_profile * sdp_panu_profile_p;
705
706 #endif /* SDP_COMPAT */
707
708 #endif /* _SDP_H_ */
709