1 .\" Copyright (c) 2003 Maksim Yevmenkin <m_evmenkin@yahoo.com>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 .\" $Id: sdp.3,v 1.1 2003/09/07 20:34:19 max Exp $
51 .Nd Bluetooth SDP routines
58 .Fn SDP_GET16 "s" "cp"
59 .Fn SDP_GET32 "l" "cp"
60 .Fn SDP_GET64 "l" "cp"
61 .Fn SDP_GET128 "l" "cp"
62 .Fn SDP_GET_UUID128 "l" "cp"
64 .Fn SDP_PUT16 "s" "cp"
65 .Fn SDP_PUT32 "l" "cp"
66 .Fn SDP_PUT64 "l" "cp"
67 .Fn SDP_PUT128 "l" "cp"
68 .Fn SDP_PUT_UUID128 "l" "cp"
70 .Fn sdp_open "bdaddr_t const *l" "bdaddr_t const *r"
72 .Fn sdp_open_local "char const *control"
74 .Fn sdp_close "void *xs"
76 .Fn sdp_error "void *xs"
79 .Fa "void *xs" "uint32_t plen" "uint16_t const *pp" "uint32_t alen"
80 .Fa "uint32_t const *ap" "uint32_t vlen" "sdp_attr_t *vp"
82 .Ft "char const * const"
83 .Fn sdp_attr2desc "uint16_t attr"
84 .Ft "char const * const"
85 .Fn sdp_uuid2desc "uint16_t uuid"
87 .Fo sdp_register_service
88 .Fa "void *xss" "uint16_t uuid" "bdaddr_p const bdaddr" "uint8_t const *data"
89 .Fa "uint32_t datalen" "uint32_t *handle"
92 .Fn sdp_unregister_service "void *xss" "uint32_t handle"
94 .Fo sdp_change_service
95 .Fa "void *xss" "uint32_t handle" "uint8_t const *data" "uint32_t datalen"
105 macros are used to get byte, short, long, long long and 128-bit integer
106 from the buffer pointed by
109 The pointer is automatically advanced.
118 macros are used to put byte, short, long, long long and 128-bit integer
119 into the buffer pointed by
122 The pointer is automatically advanced.
127 macros are used to get and put 128-bit UUID into the buffer pointed by
130 The pointer is automatically advanced.
136 functions each return a pointer to an opaque object describing SDP session.
141 function should point to a source BD_ADDR.
145 .Dv NG_HCI_BDADDR_ANY
151 function should point to a
154 Remote BD_ADDR cannot be
155 .Dv NG_HCI_BDADDR_ANY .
158 function takes path to the control socket and opens a connection to a local
160 If path to the control socket is
168 function terminates active SDP session and deletes SDP session object.
171 parameter should point to a valid SDP session object created with
178 function returns last error that is stored inside SDP session object.
181 parameter should point to a valid SDP session object created with
185 The error value returned can be converted to a human readable message by
192 function is used to perform SDP Service Search Attribute Request.
195 parameter should point to a valid SDP session object created with
201 parameter is a Service Search Pattern - an array of one or more Service
203 The maximum number of Service Class IDs in the array is 12.
206 parameter is the length of the Service Search pattern.
209 parameter is an Attribute ID Range List - an array of one or more SDP Attribute
211 Each attribute ID Range is encoded as a 32-bit unsigned integer data
212 element, where the high order 16 bits are interpreted as the beginning
213 attribute ID of the range and the low order 16 bits are interpreted as the
214 ending attribute ID of the range.
215 The attribute IDs contained in the Attribute ID Ranges List must be listed in
216 ascending order without duplication of any attribute ID values.
217 Note that all attributes may be requested by specifying a range of
221 parameter is the length of the Attribute ID Ranges List.
223 .Fn SDP_ATTR_RANGE "lo" "hi"
224 macro can be used to prepare Attribute ID Range.
227 parameter should be an array of
232 structure describes single SDP attribute and defined as follows:
233 .Bd -literal -offset indent
236 #define SDP_ATTR_OK (0 << 0)
237 #define SDP_ATTR_INVALID (1 << 0)
238 #define SDP_ATTR_TRUNCATED (1 << 1)
239 uint16_t attr; /* SDP_ATTR_xxx */
240 uint32_t vlen; /* length of the value[] in bytes */
241 uint8_t *value; /* base pointer */
243 typedef struct sdp_attr sdp_attr_t;
244 typedef struct sdp_attr * sdp_attr_p;
249 function is expected to prepare the array of
251 structures and for each element of the array both
258 function will fill each
260 structure with attribute and value, i.e., it will set
266 The actual value of the attribute will be copied into
269 Note: attributes are returned in the order they appear in the Service Search
271 SDP server could return several attributes for the same record.
272 In this case the order of the attributes will be: all attributes for the first
273 records, then all attributes for the second record etc.
279 functions each take a numeric attribute ID/UUID value and convert it to a
280 human readable description.
283 .Fn sdp_register_service
285 is used to register service with the local SDP server.
288 parameter should point to a valid SDP session object obtained from
292 parameter is a SDP Service Class ID for the service to be registered.
295 parameter should point to a valid BD_ADDR.
296 The service will be only advertised if request was received by the local device
302 .Dv NG_HCI_BDADDR_ANY
303 then the service will be advertised to any remote devices that queries for it.
308 parameters specify data and size of the data for the service.
309 Upon successful return
310 .Fn sdp_register_service
313 with the SDP record handle.
314 This parameter is optional and can be set to
318 .Fn sdp_unregister_service
320 is used to unregister service with the local SDP server.
323 parameter should point to a valid SDP session object obtained from
327 parameter should contain a valid SDP record handle of the service to be
331 .Fn sdp_change_service
332 function is used to change data associated with the existing service on
333 the local SDP server.
336 parameter should point to a valid SDP session object obtained from
340 parameter should contain a valid SDP record handle of the service to be changed.
345 parameters specify data and size of the data for the service.
347 When registering services with the local SDP server the application must
348 keep the SDP session open.
349 If SDP session is closed then the local SDP server will remove all services
350 that were registered over the session.
351 The application is allowed to change or unregister service if it was registered
352 over the same session.
354 The following example shows how to get
355 .Dv SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST
357 .Dv SDP_SERVICE_CLASS_SERIAL_PORT
358 service from the remote device.
359 .Bd -literal -offset indent
361 uint8_t buffer[1024];
363 uint16_t serv = SDP_SERVICE_CLASS_SERIAL_PORT;
364 uint32_t attr = SDP_ATTR_RANGE(
365 SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST,
366 SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST);
367 sdp_attr_t proto = { SDP_ATTR_INVALID,0,sizeof(buffer),buffer };
369 /* Obtain/set remote BDADDR here */
371 if ((ss = sdp_open(NG_HCI_BDADDR_ANY, remote)) == NULL)
373 if (sdp_error(ss) != 0)
374 /* exit sdp_error(ss) */
376 if (sdp_search(ss, 1, &serv, 1, &attr, 1, &proto) != 0)
377 /* exit sdp_error(ss) */
379 if (proto.flags != SDP_ATTR_OK)
380 /* exit see proto.flags for details */
382 /* If we got here then we have attribute value in proto.value */
391 if memory allocation for the new SDP session object fails.
392 If the new SDP object was created then caller is still expected to call
394 to check if there was connection error.
398 .Fn sdp_register_service ,
399 .Fn sdp_unregister_service
401 .Fn sdp_change_service
402 functions return non-zero value on error.
403 The caller is expected to call
405 to find out more about error.
412 .An Maksim Yevmenkin Aq Mt m_evmenkin@yahoo.com
415 Please report bugs if found.