sdp.h revision 124317
1121054Semax/*
2121054Semax * sdp.h
3121054Semax *
4121054Semax * Copyright (c) 2001-2003 Maksim Yevmenkin <m_evmenkin@yahoo.com>
5121054Semax * All rights reserved.
6121054Semax *
7121054Semax * Redistribution and use in source and binary forms, with or without
8121054Semax * modification, are permitted provided that the following conditions
9121054Semax * are met:
10121054Semax * 1. Redistributions of source code must retain the above copyright
11121054Semax *    notice, this list of conditions and the following disclaimer.
12121054Semax * 2. Redistributions in binary form must reproduce the above copyright
13121054Semax *    notice, this list of conditions and the following disclaimer in the
14121054Semax *    documentation and/or other materials provided with the distribution.
15121054Semax *
16121054Semax * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17121054Semax * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18121054Semax * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19121054Semax * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20121054Semax * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21121054Semax * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22121054Semax * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23121054Semax * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24121054Semax * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25121054Semax * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26121054Semax * SUCH DAMAGE.
27121054Semax *
28121054Semax * $Id: sdp.h,v 1.3 2003/09/05 00:33:59 max Exp $
29121054Semax * $FreeBSD: head/lib/libsdp/sdp.h 124317 2004-01-09 22:44:28Z emax $
30121054Semax */
31121054Semax
32121054Semax#ifndef _SDP_H_
33121054Semax#define _SDP_H_
34121054Semax
35121054Semax__BEGIN_DECLS
36121054Semax
37121054Semax/*
38121054Semax * Data representation (page 349)
39121054Semax */
40121054Semax
41121054Semax/* Nil, the null type */
42121054Semax#define SDP_DATA_NIL					0x00
43121054Semax
44121054Semax/* Unsigned integer */
45121054Semax#define SDP_DATA_UINT8					0x08
46121054Semax#define SDP_DATA_UINT16					0x09
47121054Semax#define SDP_DATA_UINT32					0x0A
48121054Semax#define SDP_DATA_UINT64					0x0B
49121054Semax#define SDP_DATA_UINT128				0x0C
50121054Semax
51121054Semax/* Signed two's-complement integer */
52121054Semax#define SDP_DATA_INT8					0x10
53121054Semax#define SDP_DATA_INT16					0x11
54121054Semax#define SDP_DATA_INT32					0x12
55121054Semax#define SDP_DATA_INT64					0x13
56121054Semax#define SDP_DATA_INT128					0x14
57121054Semax
58121054Semax/* UUID, a universally unique identifier */
59121054Semax#define SDP_DATA_UUID16					0x19
60121054Semax#define SDP_DATA_UUID32					0x1A
61121054Semax#define SDP_DATA_UUID128				0x1C
62121054Semax
63121054Semax/* Text string */
64121054Semax#define SDP_DATA_STR8					0x25
65121054Semax#define SDP_DATA_STR16					0x26
66121054Semax#define SDP_DATA_STR32					0x27
67121054Semax
68121054Semax/* Boolean */
69121054Semax#define SDP_DATA_BOOL					0x28
70121054Semax
71121054Semax/*
72121054Semax * Data element sequence.
73121054Semax * A data element whose data field is a sequence of data elements
74121054Semax */
75121054Semax#define SDP_DATA_SEQ8					0x35
76121054Semax#define SDP_DATA_SEQ16					0x36
77121054Semax#define SDP_DATA_SEQ32					0x37
78121054Semax
79121054Semax/*
80121054Semax * Data element alternative.
81121054Semax * A data element whose data field is a sequence of data elements from
82121054Semax * which one data element is to be selected.
83121054Semax */
84121054Semax#define SDP_DATA_ALT8					0x3D
85121054Semax#define SDP_DATA_ALT16					0x3E
86121054Semax#define SDP_DATA_ALT32					0x3F
87121054Semax
88121054Semax/* URL, a uniform resource locator */
89121054Semax#define SDP_DATA_URL8					0x45
90121054Semax#define SDP_DATA_URL16					0x46
91121054Semax#define SDP_DATA_URL32					0x47
92121054Semax
93121054Semax/*
94121054Semax * Protocols UUID (short) http://www.bluetoothsig.org/assigned-numbers/sdp.htm
95121054Semax * BASE UUID 00000000-0000-1000-8000-00805F9B34FB
96121054Semax */
97121054Semax
98121054Semax#define SDP_UUID_PROTOCOL_SDP				0x0001
99121054Semax#define SDP_UUID_PROTOCOL_UDP				0x0002
100121054Semax#define SDP_UUID_PROTOCOL_RFCOMM			0x0003
101121054Semax#define SDP_UUID_PROTOCOL_TCP				0x0004
102121054Semax#define SDP_UUID_PROTOCOL_TCS_BIN			0x0005
103121054Semax#define SDP_UUID_PROTOCOL_TCS_AT			0x0006
104121054Semax#define SDP_UUID_PROTOCOL_OBEX				0x0008
105121054Semax#define SDP_UUID_PROTOCOL_IP				0x0009
106121054Semax#define SDP_UUID_PROTOCOL_FTP				0x000A
107121054Semax#define SDP_UUID_PROTOCOL_HTTP				0x000C
108121054Semax#define SDP_UUID_PROTOCOL_WSP				0x000E
109121054Semax#define SDP_UUID_PROTOCOL_BNEP				0x000F
110121054Semax#define SDP_UUID_PROTOCOL_UPNP				0x0010
111121054Semax#define SDP_UUID_PROTOCOL_HIDP				0x0011
112121054Semax#define SDP_UUID_PROTOCOL_HARDCOPY_CONTROL_CHANNEL	0x0012
113121054Semax#define SDP_UUID_PROTOCOL_HARDCOPY_DATA_CHANNEL		0x0014
114121054Semax#define SDP_UUID_PROTOCOL_HARDCOPY_NOTIFICATION		0x0016
115121054Semax#define SDP_UUID_PROTOCOL_AVCTP				0x0017
116121054Semax#define SDP_UUID_PROTOCOL_AVDTP				0x0019
117121054Semax#define SDP_UUID_PROTOCOL_CMPT				0x001B
118121054Semax#define SDP_UUID_PROTOCOL_UDI_C_PLANE			0x001D
119121054Semax#define SDP_UUID_PROTOCOL_L2CAP				0x0100
120121054Semax
121121054Semax/*
122121054Semax * Service class IDs http://www.bluetoothsig.org/assigned-numbers/sdp.htm
123121054Semax */
124121054Semax
125121054Semax#define SDP_SERVICE_CLASS_SERVICE_DISCOVERY_SERVER	0x1000
126121054Semax#define SDP_SERVICE_CLASS_BROWSE_GROUP_DESCRIPTOR	0x1001
127121054Semax#define SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP		0x1002
128121054Semax#define SDP_SERVICE_CLASS_SERIAL_PORT			0x1101
129121054Semax#define SDP_SERVICE_CLASS_LAN_ACCESS_USING_PPP		0x1102
130121054Semax#define SDP_SERVICE_CLASS_DIALUP_NETWORKING		0x1103
131121054Semax#define SDP_SERVICE_CLASS_IR_MC_SYNC			0x1104
132121054Semax#define SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH		0x1105
133121054Semax#define SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER		0x1106
134121054Semax#define SDP_SERVICE_CLASS_IR_MC_SYNC_COMMAND		0x1107
135121054Semax#define SDP_SERVICE_CLASS_HEADSET			0x1108
136121054Semax#define SDP_SERVICE_CLASS_CORDLESS_TELEPHONY		0x1109
137121054Semax#define SDP_SERVICE_CLASS_AUDIO_SOURCE			0x110A
138121054Semax#define SDP_SERVICE_CLASS_AUDIO_SINK			0x110B
139121054Semax#define SDP_SERVICE_CLASS_AV_REMOTE_CONTROL_TARGET	0x110C
140121054Semax#define SDP_SERVICE_CLASS_ADVANCED_AUDIO_DISTRIBUTION	0x110D
141121054Semax#define SDP_SERVICE_CLASS_AV_REMOTE_CONTROL		0x110E
142121054Semax#define SDP_SERVICE_CLASS_VIDEO_CONFERENCING		0x110F
143121054Semax#define SDP_SERVICE_CLASS_INTERCOM			0x1110
144121054Semax#define SDP_SERVICE_CLASS_FAX				0x1111
145121054Semax#define SDP_SERVICE_CLASS_HEADSET_AUDIO_GATEWAY		0x1112
146121054Semax#define SDP_SERVICE_CLASS_WAP				0x1113
147121054Semax#define SDP_SERVICE_CLASS_WAP_CLIENT			0x1114
148121054Semax#define SDP_SERVICE_CLASS_PANU				0x1115
149121054Semax#define SDP_SERVICE_CLASS_NAP				0x1116
150121054Semax#define SDP_SERVICE_CLASS_GN				0x1117
151121054Semax#define SDP_SERVICE_CLASS_DIRECT_PRINTING		0x1118
152121054Semax#define SDP_SERVICE_CLASS_REFERENCE_PRINTING		0x1119
153121054Semax#define SDP_SERVICE_CLASS_IMAGING			0x111A
154121054Semax#define SDP_SERVICE_CLASS_IMAGING_RESPONDER		0x111B
155121054Semax#define SDP_SERVICE_CLASS_IMAGING_AUTOMATIC_ARCHIVE	0x111C
156121054Semax#define SDP_SERVICE_CLASS_IMAGING_REFERENCED_OBJECTS	0x111D
157121054Semax#define SDP_SERVICE_CLASS_HANDSFREE			0x111E
158121054Semax#define SDP_SERVICE_CLASS_HANDSFREE_AUDIO_GATEWAY	0x111F
159121054Semax#define SDP_SERVICE_CLASS_DIRECT_PRINTING_REFERENCE_OBJECTS	0x1120
160121054Semax#define SDP_SERVICE_CLASS_REFLECTED_UI			0x1121
161121054Semax#define SDP_SERVICE_CLASS_BASIC_PRINTING		0x1122
162121054Semax#define SDP_SERVICE_CLASS_PRINTING_STATUS		0x1123
163121054Semax#define SDP_SERVICE_CLASS_HUMAN_INTERFACE_DEVICE	0x1124
164121054Semax#define SDP_SERVICE_CLASS_HARDCOPY_CABLE_REPLACEMENT	0x1125
165121054Semax#define SDP_SERVICE_CLASS_HCR_PRINT			0x1126
166121054Semax#define SDP_SERVICE_CLASS_HCR_SCAN			0x1127
167121054Semax#define SDP_SERVICE_CLASS_COMMON_ISDN_ACCESS		0x1128
168121054Semax#define SDP_SERVICE_CLASS_VIDEO_CONFERENCING_GW		0x1129
169121054Semax#define SDP_SERVICE_CLASS_UDI_MT			0x112A
170121054Semax#define SDP_SERVICE_CLASS_UDI_TA			0x112B
171121054Semax#define SDP_SERVICE_CLASS_AUDIO_VIDEO			0x112C
172121054Semax#define SDP_SERVICE_CLASS_SIM_ACCESS			0x112D
173121054Semax#define SDP_SERVICE_CLASS_PNP_INFORMATION		0x1200
174121054Semax#define SDP_SERVICE_CLASS_GENERIC_NETWORKING		0x1201
175121054Semax#define SDP_SERVICE_CLASS_GENERIC_FILE_TRANSFER		0x1202
176121054Semax#define SDP_SERVICE_CLASS_GENERIC_AUDIO			0x1203
177121054Semax#define SDP_SERVICE_CLASS_GENERIC_TELEPHONY		0x1204
178121054Semax#define SDP_SERVICE_CLASS_UPNP				0x1205
179121054Semax#define SDP_SERVICE_CLASS_UPNP_IP			0x1206
180121054Semax#define SDP_SERVICE_CLASS_ESDP_UPNP_IP_PAN		0x1300
181121054Semax#define SDP_SERVICE_CLASS_ESDP_UPNP_IP_LAP		0x1301
182121054Semax#define SDP_SERVICE_CLASS_ESDP_UPNP_L2CAP		0x1302
183121054Semax
184121054Semax/*
185121054Semax * Universal attribute definitions (page 366) and
186121054Semax * http://www.bluetoothsig.org/assigned-numbers/sdp.htm
187121054Semax */
188121054Semax
189121054Semax#define SDP_ATTR_RANGE(lo, hi) \
190124305Semax	(uint32_t)(((uint16_t)(lo) << 16) | ((uint16_t)(hi)))
191121054Semax
192121054Semax#define SDP_ATTR_SERVICE_RECORD_HANDLE			0x0000
193121054Semax#define SDP_ATTR_SERVICE_CLASS_ID_LIST			0x0001
194121054Semax#define SDP_ATTR_SERVICE_RECORD_STATE			0x0002
195121054Semax#define SDP_ATTR_SERVICE_ID				0x0003
196121054Semax#define SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST		0x0004
197121054Semax#define SDP_ATTR_BROWSE_GROUP_LIST			0x0005
198121054Semax#define SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST	0x0006
199121054Semax#define SDP_ATTR_SERVICE_INFO_TIME_TO_LIVE		0x0007
200121054Semax#define SDP_ATTR_SERVICE_AVAILABILITY			0x0008
201121054Semax#define SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST	0x0009
202121054Semax#define SDP_ATTR_DOCUMENTATION_URL			0x000A
203121054Semax#define SDP_ATTR_CLIENT_EXECUTABLE_URL			0x000B
204121054Semax#define SDP_ATTR_ICON_URL				0x000C
205121054Semax#define SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS	0x000D
206121054Semax#define SDP_ATTR_GROUP_ID				0x0200
207121054Semax#define SDP_ATTR_IP_SUBNET				0x0200
208121054Semax#define SDP_ATTR_VERSION_NUMBER_LIST			0x0200
209121054Semax#define SDP_ATTR_SERVICE_DATABASE_STATE			0x0201
210121054Semax#define SDP_ATTR_SERVICE_VERSION			0x0300
211121054Semax#define SDP_ATTR_EXTERNAL_NETWORK			0x0301
212121054Semax#define SDP_ATTR_NETWORK				0x0301
213121054Semax#define SDP_ATTR_SUPPORTED_DATA_STORES_LIST		0x0301
214121054Semax#define SDP_ATTR_FAX_CLASS1_SUPPORT			0x0302
215121054Semax#define SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL		0x0302
216121054Semax#define SDP_ATTR_FAX_CLASS20_SUPPORT			0x0303
217121054Semax#define SDP_ATTR_SUPPORTED_FORMATS_LIST			0x0303
218121054Semax#define SDP_ATTR_FAX_CLASS2_SUPPORT			0x0304
219121054Semax#define SDP_ATTR_AUDIO_FEEDBACK_SUPPORT			0x0305
220121054Semax#define SDP_ATTR_NETWORK_ADDRESS			0x0306
221121054Semax#define SDP_ATTR_WAP_GATEWAY				0x0307
222121054Semax#define SDP_ATTR_HOME_PAGE_URL				0x0308
223121054Semax#define SDP_ATTR_WAP_STACK_TYPE				0x0309
224121054Semax#define SDP_ATTR_SECURITY_DESCRIPTION			0x030A
225121054Semax#define SDP_ATTR_NET_ACCESS_TYPE			0x030B
226121054Semax#define SDP_ATTR_MAX_NET_ACCESS_RATE			0x030C
227121054Semax#define SDP_ATTR_IPV4_SUBNET				0x030D
228121054Semax#define SDP_ATTR_IPV6_SUBNET				0x030E
229121054Semax#define SDP_ATTR_SUPPORTED_CAPABALITIES			0x0310
230121054Semax#define SDP_ATTR_SUPPORTED_FEATURES			0x0311
231121054Semax#define SDP_ATTR_SUPPORTED_FUNCTIONS			0x0312
232121054Semax#define SDP_ATTR_TOTAL_IMAGING_DATA_CAPACITY		0x0313
233121054Semax
234121054Semax/*
235121054Semax * The offset must be added to the attribute ID base (contained in the
236121054Semax * LANGUAGE_BASE_ATTRIBUTE_ID_LIST attribute) in order to compute the
237121054Semax * attribute ID for these attributes.
238121054Semax */
239121054Semax
240124305Semax#define SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID		0x0100
241121054Semax#define SDP_ATTR_SERVICE_NAME_OFFSET			0x0000
242121054Semax#define SDP_ATTR_SERVICE_DESCRIPTION_OFFSET		0x0001
243121054Semax#define SDP_ATTR_PROVIDER_NAME_OFFSET			0x0002
244121054Semax
245121054Semax/*
246121054Semax * Protocol data unit (PDU) format (page 352)
247121054Semax */
248121054Semax
249121054Semax#define SDP_PDU_ERROR_RESPONSE				0x01
250121054Semax#define SDP_PDU_SERVICE_SEARCH_REQUEST			0x02
251121054Semax#define SDP_PDU_SERVICE_SEARCH_RESPONSE			0x03
252121054Semax#define SDP_PDU_SERVICE_ATTRIBUTE_REQUEST		0x04
253121054Semax#define SDP_PDU_SERVICE_ATTRIBUTE_RESPONSE		0x05
254121054Semax#define SDP_PDU_SERVICE_SEARCH_ATTRIBUTE_REQUEST	0x06
255121054Semax#define SDP_PDU_SERVICE_SEARCH_ATTRIBUTE_RESPONSE	0x07
256121054Semax
257121054Semaxstruct sdp_pdu {
258124305Semax	uint8_t		pid;	/* PDU ID - SDP_PDU_xxx */
259124305Semax	uint16_t	tid;	/* transaction ID */
260124305Semax	uint16_t	len;	/* parameters length (in bytes) */
261121054Semax} __attribute__ ((packed));
262121054Semaxtypedef struct sdp_pdu		sdp_pdu_t;
263121054Semaxtypedef struct sdp_pdu *	sdp_pdu_p;
264121054Semax
265121054Semax/*
266124305Semax * Error codes for SDP_PDU_ERROR_RESPONSE
267124305Semax */
268124305Semax
269124305Semax#define SDP_ERROR_CODE_INVALID_SDP_VERSION		0x0001
270124305Semax#define SDP_ERROR_CODE_INVALID_SERVICE_RECORD_HANDLE	0x0002
271124305Semax#define SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX		0x0003
272124305Semax#define SDP_ERROR_CODE_INVALID_PDU_SIZE			0x0004
273124305Semax#define SDP_ERROR_CODE_INVALID_CONTINUATION_STATE	0x0005
274124305Semax#define SDP_ERROR_CODE_INSUFFICIENT_RESOURCES		0x0006
275124305Semax
276124305Semax/*
277121054Semax * SDP int128/uint128 parameter
278121054Semax */
279121054Semax
280121054Semaxstruct int128 {
281121054Semax	int8_t	b[16];
282121054Semax};
283121054Semaxtypedef struct int128	int128_t;
284124305Semaxtypedef struct int128	uint128_t;
285121054Semax
286121054Semax/*
287121054Semax * SDP attribute
288121054Semax */
289121054Semax
290121054Semaxstruct sdp_attr {
291124305Semax	uint16_t	 flags;
292121054Semax#define SDP_ATTR_OK		(0 << 0)
293121054Semax#define SDP_ATTR_INVALID	(1 << 0)
294121054Semax#define SDP_ATTR_TRUNCATED	(1 << 1)
295124305Semax	uint16_t	 attr;  /* SDP_ATTR_xxx */
296124305Semax	uint32_t	 vlen;	/* length of the value[] in bytes */
297124305Semax	uint8_t		*value;	/* base pointer */
298121054Semax};
299121054Semaxtypedef struct sdp_attr		sdp_attr_t;
300121054Semaxtypedef struct sdp_attr *	sdp_attr_p;
301121054Semax
302121054Semax/******************************************************************************
303121054Semax * User interface
304121054Semax *****************************************************************************/
305121054Semax
306121054Semax/* Inline versions of get/put byte/short/long. Pointer is advanced */
307121054Semax#define SDP_GET8(b, cp) { \
308124305Semax	register uint8_t *t_cp = (uint8_t *)(cp); \
309121054Semax	(b) = *t_cp; \
310121054Semax	(cp) ++; \
311121054Semax}
312121054Semax
313121054Semax#define SDP_GET16(s, cp) { \
314124305Semax	register uint8_t *t_cp = (uint8_t *)(cp); \
315124305Semax	(s) = ((uint16_t)t_cp[0] << 8) \
316124305Semax	    | ((uint16_t)t_cp[1]) \
317121054Semax	    ; \
318121054Semax	(cp) += 2; \
319121054Semax}
320121054Semax
321121054Semax#define SDP_GET32(l, cp) { \
322124305Semax	register uint8_t *t_cp = (uint8_t *)(cp); \
323124305Semax	(l) = ((uint32_t)t_cp[0] << 24) \
324124305Semax	    | ((uint32_t)t_cp[1] << 16) \
325124305Semax	    | ((uint32_t)t_cp[2] << 8) \
326124305Semax	    | ((uint32_t)t_cp[3]) \
327121054Semax	    ; \
328121054Semax	(cp) += 4; \
329121054Semax}
330121054Semax
331121054Semax#define SDP_GET64(l, cp) { \
332124305Semax	register uint8_t *t_cp = (uint8_t *)(cp); \
333124305Semax	(l) = ((uint64_t)t_cp[0] << 56) \
334124305Semax	    | ((uint64_t)t_cp[1] << 48) \
335124305Semax	    | ((uint64_t)t_cp[2] << 40) \
336124305Semax	    | ((uint64_t)t_cp[3] << 32) \
337124305Semax	    | ((uint64_t)t_cp[4] << 24) \
338124305Semax	    | ((uint64_t)t_cp[5] << 16) \
339124305Semax	    | ((uint64_t)t_cp[6] << 8) \
340124305Semax	    | ((uint64_t)t_cp[7]) \
341121054Semax	    ; \
342121054Semax	(cp) += 8; \
343121054Semax}
344121054Semax
345121054Semax#if BYTE_ORDER == LITTLE_ENDIAN
346121054Semax#define SDP_GET128(l, cp) { \
347124305Semax	register uint8_t *t_cp = (uint8_t *)(cp); \
348121054Semax	(l)->b[15] = *t_cp++; \
349121054Semax	(l)->b[14] = *t_cp++; \
350121054Semax	(l)->b[13] = *t_cp++; \
351121054Semax	(l)->b[12] = *t_cp++; \
352121054Semax	(l)->b[11] = *t_cp++; \
353121054Semax	(l)->b[10] = *t_cp++; \
354121054Semax	(l)->b[9]  = *t_cp++; \
355121054Semax	(l)->b[8]  = *t_cp++; \
356121054Semax	(l)->b[7]  = *t_cp++; \
357121054Semax	(l)->b[6]  = *t_cp++; \
358121054Semax	(l)->b[5]  = *t_cp++; \
359121054Semax	(l)->b[4]  = *t_cp++; \
360121054Semax	(l)->b[3]  = *t_cp++; \
361121054Semax	(l)->b[2]  = *t_cp++; \
362121054Semax	(l)->b[1]  = *t_cp++; \
363121054Semax	(cp) += 16; \
364121054Semax}
365121054Semax#else /* BYTE_ORDER != LITTLE_ENDIAN */
366121054Semax#define SDP_GET128(l, cp) { \
367124305Semax	register uint8_t *t_cp = (uint8_t *)(cp); \
368121054Semax	(l)->b[0]  = *t_cp++; \
369121054Semax	(l)->b[1]  = *t_cp++; \
370121054Semax	(l)->b[2]  = *t_cp++; \
371121054Semax	(l)->b[3]  = *t_cp++; \
372121054Semax	(l)->b[4]  = *t_cp++; \
373121054Semax	(l)->b[5]  = *t_cp++; \
374121054Semax	(l)->b[6]  = *t_cp++; \
375121054Semax	(l)->b[7]  = *t_cp++; \
376121054Semax	(l)->b[8]  = *t_cp++; \
377121054Semax	(l)->b[9]  = *t_cp++; \
378121054Semax	(l)->b[10] = *t_cp++; \
379121054Semax	(l)->b[11] = *t_cp++; \
380121054Semax	(l)->b[12] = *t_cp++; \
381121054Semax	(l)->b[13] = *t_cp++; \
382121054Semax	(l)->b[14] = *t_cp++; \
383121054Semax	(l)->b[15] = *t_cp++; \
384121054Semax	(cp) += 16; \
385121054Semax}
386121054Semax#endif /* BYTE_ORDER */
387121054Semax
388121054Semax#define SDP_PUT8(b, cp) { \
389124305Semax	register uint8_t t_b = (uint8_t)(b); \
390124305Semax	register uint8_t *t_cp = (uint8_t *)(cp); \
391121054Semax	*t_cp = t_b; \
392121054Semax	(cp) ++; \
393121054Semax}
394121054Semax
395121054Semax#define SDP_PUT16(s, cp) { \
396124305Semax	register uint16_t t_s = (uint16_t)(s); \
397124305Semax	register uint8_t *t_cp = (uint8_t *)(cp); \
398121054Semax	*t_cp++ = t_s >> 8; \
399121054Semax	*t_cp   = t_s; \
400121054Semax	(cp) += 2; \
401121054Semax}
402121054Semax
403121054Semax#define SDP_PUT32(l, cp) { \
404124305Semax	register uint32_t t_l = (uint32_t)(l); \
405124305Semax	register uint8_t *t_cp = (uint8_t *)(cp); \
406121054Semax	*t_cp++ = t_l >> 24; \
407121054Semax	*t_cp++ = t_l >> 16; \
408121054Semax	*t_cp++ = t_l >> 8; \
409121054Semax	*t_cp   = t_l; \
410121054Semax	(cp) += 4; \
411121054Semax}
412121054Semax
413121054Semax#define SDP_PUT64(l, cp) { \
414124305Semax	register uint64_t t_l = (uint64_t)(l); \
415124305Semax	register uint8_t *t_cp = (uint8_t *)(cp); \
416121054Semax	*t_cp++ = t_l >> 56; \
417121054Semax	*t_cp++ = t_l >> 48; \
418121054Semax	*t_cp++ = t_l >> 40; \
419121054Semax	*t_cp++ = t_l >> 32; \
420121054Semax	*t_cp++ = t_l >> 24; \
421121054Semax	*t_cp++ = t_l >> 16; \
422121054Semax	*t_cp++ = t_l >> 8; \
423121054Semax	*t_cp   = t_l; \
424121054Semax	(cp) += 8; \
425121054Semax}
426121054Semax
427121054Semax#if BYTE_ORDER == LITTLE_ENDIAN
428121054Semax#define SDP_PUT128(l, cp) { \
429124305Semax	register uint8_t *t_cp = (uint8_t *)(cp); \
430121054Semax	*t_cp++ = (l)->b[15]; \
431121054Semax	*t_cp++ = (l)->b[14]; \
432121054Semax	*t_cp++ = (l)->b[13]; \
433121054Semax	*t_cp++ = (l)->b[12]; \
434121054Semax	*t_cp++ = (l)->b[11]; \
435121054Semax	*t_cp++ = (l)->b[10]; \
436121054Semax	*t_cp++ = (l)->b[9];  \
437121054Semax	*t_cp++ = (l)->b[8];  \
438121054Semax	*t_cp++ = (l)->b[7];  \
439121054Semax	*t_cp++ = (l)->b[6];  \
440121054Semax	*t_cp++ = (l)->b[5];  \
441121054Semax	*t_cp++ = (l)->b[4];  \
442121054Semax	*t_cp++ = (l)->b[3];  \
443121054Semax	*t_cp++ = (l)->b[2];  \
444121054Semax	*t_cp++ = (l)->b[1];  \
445121054Semax	*t_cp   = (l)->b[0];  \
446121054Semax	(cp) += 16; \
447121054Semax}
448121054Semax#else /* BYTE_ORDER != LITTLE_ENDIAN */
449121054Semax#define SDP_PUT128(l, cp) { \
450124305Semax	register uint8_t *t_cp = (uint8_t *)(cp); \
451121054Semax	*t_cp++ = (l)->b[0];  \
452121054Semax	*t_cp++ = (l)->b[1];  \
453121054Semax	*t_cp++ = (l)->b[2];  \
454121054Semax	*t_cp++ = (l)->b[3];  \
455121054Semax	*t_cp++ = (l)->b[4];  \
456121054Semax	*t_cp++ = (l)->b[5];  \
457121054Semax	*t_cp++ = (l)->b[6];  \
458121054Semax	*t_cp++ = (l)->b[7];  \
459121054Semax	*t_cp++ = (l)->b[8];  \
460121054Semax	*t_cp++ = (l)->b[9];  \
461121054Semax	*t_cp++ = (l)->b[10]; \
462121054Semax	*t_cp++ = (l)->b[11]; \
463121054Semax	*t_cp++ = (l)->b[12]; \
464121054Semax	*t_cp++ = (l)->b[13]; \
465121054Semax	*t_cp++ = (l)->b[14]; \
466121054Semax	*t_cp   = (l)->b[15]; \
467121054Semax	(cp) += 16; \
468121054Semax}
469121054Semax#endif /* BYTE_ORDER */
470121054Semax
471121054Semaxvoid *             sdp_open       (bdaddr_t const *l, bdaddr_t const *r);
472124317Semaxvoid *             sdp_open_local (char const *control);
473121054Semaxint32_t            sdp_close      (void *xs);
474121054Semaxint32_t            sdp_error      (void *xs);
475121054Semax
476121054Semaxint32_t            sdp_search     (void *xs,
477124305Semax                                   uint32_t plen, uint16_t const *pp,
478124305Semax                                   uint32_t alen, uint32_t const *ap,
479124305Semax                                   uint32_t vlen, sdp_attr_t *vp);
480121054Semax
481124305Semaxchar const * const sdp_attr2desc  (uint16_t attr);
482124305Semaxchar const * const sdp_uuid2desc  (uint16_t uuid);
483124305Semaxvoid               sdp_print      (uint32_t level, uint8_t const *start,
484124305Semax                                   uint8_t const *end);
485121054Semax
486124305Semax/******************************************************************************
487124305Semax * sdpd interface and Bluetooth profiles data
488124305Semax *****************************************************************************/
489124305Semax
490124305Semax#define SDP_LOCAL_PATH	"/var/run/sdp"
491124305Semax#define SDP_LOCAL_MTU	4096
492124305Semax
493124305Semaxstruct sdp_dun_profile
494124305Semax{
495124305Semax	uint8_t	server_channel;
496124305Semax	uint8_t	audio_feedback_support;
497124305Semax	uint8_t	reserved[2];
498124305Semax};
499124305Semaxtypedef struct sdp_dun_profile		sdp_dun_profile_t;
500124305Semaxtypedef struct sdp_dun_profile *	sdp_dun_profile_p;
501124305Semax
502124305Semaxstruct sdp_ftrn_profile
503124305Semax{
504124305Semax	uint8_t	server_channel;
505124305Semax	uint8_t	reserved[3];
506124305Semax};
507124305Semaxtypedef struct sdp_ftrn_profile		sdp_ftrn_profile_t;
508124305Semaxtypedef struct sdp_ftrn_profile *	sdp_ftrn_profile_p;
509124305Semax
510124305Semaxstruct sdp_irmc_profile
511124305Semax{
512124305Semax	uint8_t	server_channel;
513124305Semax	uint8_t	supported_formats_size;
514124305Semax	uint8_t	supported_formats[30];
515124305Semax};
516124305Semaxtypedef struct sdp_irmc_profile		sdp_irmc_profile_t;
517124305Semaxtypedef struct sdp_irmc_profile *	sdp_irmc_profile_p;
518124305Semax
519124305Semaxstruct sdp_irmc_command_profile
520124305Semax{
521124305Semax	uint8_t	server_channel;
522124305Semax	uint8_t	reserved[3];
523124305Semax};
524124305Semaxtypedef struct sdp_irmc_command_profile		sdp_irmc_command_profile_t;
525124305Semaxtypedef struct sdp_irmc_command_profile *	sdp_irmc_command_profile_p;
526124305Semax
527124305Semaxstruct sdp_lan_profile
528124305Semax{
529124305Semax	uint8_t		server_channel;
530124305Semax	uint8_t		load_factor;
531124305Semax	uint8_t		reserved;
532124305Semax	uint8_t		ip_subnet_radius;
533124305Semax	uint32_t	ip_subnet;
534124305Semax};
535124305Semaxtypedef struct sdp_lan_profile		sdp_lan_profile_t;
536124305Semaxtypedef struct sdp_lan_profile *	sdp_lan_profile_p;
537124305Semax
538124305Semaxstruct sdp_opush_profile
539124305Semax{
540124305Semax	uint8_t	server_channel;
541124305Semax	uint8_t	supported_formats_size;
542124305Semax	uint8_t	supported_formats[30];
543124305Semax};
544124305Semaxtypedef struct sdp_opush_profile	sdp_opush_profile_t;
545124305Semaxtypedef struct sdp_opush_profile *	sdp_opush_profile_p;
546124305Semax
547124305Semaxstruct sdp_sp_profile
548124305Semax{
549124305Semax	uint8_t	server_channel;
550124305Semax	uint8_t	reserved[3];
551124305Semax};
552124305Semaxtypedef struct sdp_sp_profile	sdp_sp_profile_t;
553124305Semaxtypedef struct sdp_sp_profile *	sdp_sp_profile_p;
554124305Semax
555121054Semax__END_DECLS
556121054Semax
557121054Semax#endif /* ndef _SDP_H_ */
558121054Semax
559