10986ab12SMaksim Yevmenkin.\" Copyright (c) 2003 Maksim Yevmenkin <m_evmenkin@yahoo.com> 20986ab12SMaksim Yevmenkin.\" All rights reserved. 30986ab12SMaksim Yevmenkin.\" 40986ab12SMaksim Yevmenkin.\" Redistribution and use in source and binary forms, with or without 50986ab12SMaksim Yevmenkin.\" modification, are permitted provided that the following conditions 60986ab12SMaksim Yevmenkin.\" are met: 70986ab12SMaksim Yevmenkin.\" 1. Redistributions of source code must retain the above copyright 80986ab12SMaksim Yevmenkin.\" notice, this list of conditions and the following disclaimer. 90986ab12SMaksim Yevmenkin.\" 2. Redistributions in binary form must reproduce the above copyright 100986ab12SMaksim Yevmenkin.\" notice, this list of conditions and the following disclaimer in the 110986ab12SMaksim Yevmenkin.\" documentation and/or other materials provided with the distribution. 120986ab12SMaksim Yevmenkin.\" 130986ab12SMaksim Yevmenkin.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 140986ab12SMaksim Yevmenkin.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 150986ab12SMaksim Yevmenkin.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 160986ab12SMaksim Yevmenkin.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 170986ab12SMaksim Yevmenkin.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 180986ab12SMaksim Yevmenkin.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 190986ab12SMaksim Yevmenkin.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 200986ab12SMaksim Yevmenkin.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 210986ab12SMaksim Yevmenkin.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 220986ab12SMaksim Yevmenkin.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 230986ab12SMaksim Yevmenkin.\" SUCH DAMAGE. 240986ab12SMaksim Yevmenkin.\" 250986ab12SMaksim Yevmenkin.\" $Id: sdp.3,v 1.1 2003/09/07 20:34:19 max Exp $ 260986ab12SMaksim Yevmenkin.\" 27*515bb54cSVladimir Kondratyev.Dd April 30, 2018 280986ab12SMaksim Yevmenkin.Dt SDP 3 290986ab12SMaksim Yevmenkin.Os 300986ab12SMaksim Yevmenkin.Sh NAME 310986ab12SMaksim Yevmenkin.Nm SDP_GET8 , 320986ab12SMaksim Yevmenkin.Nm SDP_GET16 , 330986ab12SMaksim Yevmenkin.Nm SDP_GET32 , 340986ab12SMaksim Yevmenkin.Nm SDP_GET64 , 350d0f0252SRuslan Ermilov.Nm SDP_GET128 , 3643d33de9SMaksim Yevmenkin.Nm SDP_GET_UUID128 , 370986ab12SMaksim Yevmenkin.Nm SDP_PUT8 , 380986ab12SMaksim Yevmenkin.Nm SDP_PUT16 , 390986ab12SMaksim Yevmenkin.Nm SDP_PUT32 , 400986ab12SMaksim Yevmenkin.Nm SDP_PUT64 , 410d0f0252SRuslan Ermilov.Nm SDP_PUT128 , 4243d33de9SMaksim Yevmenkin.Nm SDP_PUT_UUID128 , 430986ab12SMaksim Yevmenkin.Nm sdp_open , 440986ab12SMaksim Yevmenkin.Nm sdp_open_local , 450d0f0252SRuslan Ermilov.Nm sdp_close , 460d0f0252SRuslan Ermilov.Nm sdp_error , 47*515bb54cSVladimir Kondratyev.Nm sdp_get_lcaddr , 480d0f0252SRuslan Ermilov.Nm sdp_search , 490986ab12SMaksim Yevmenkin.Nm sdp_attr2desc , 500986ab12SMaksim Yevmenkin.Nm sdp_uuid2desc 510d0f0252SRuslan Ermilov.Nd Bluetooth SDP routines 520986ab12SMaksim Yevmenkin.Sh LIBRARY 530986ab12SMaksim Yevmenkin.Lb libsdp 540986ab12SMaksim Yevmenkin.Sh SYNOPSIS 550986ab12SMaksim Yevmenkin.In bluetooth.h 560986ab12SMaksim Yevmenkin.In sdp.h 570986ab12SMaksim Yevmenkin.Fn SDP_GET8 "b" "cp" 580986ab12SMaksim Yevmenkin.Fn SDP_GET16 "s" "cp" 590986ab12SMaksim Yevmenkin.Fn SDP_GET32 "l" "cp" 600986ab12SMaksim Yevmenkin.Fn SDP_GET64 "l" "cp" 610986ab12SMaksim Yevmenkin.Fn SDP_GET128 "l" "cp" 6243d33de9SMaksim Yevmenkin.Fn SDP_GET_UUID128 "l" "cp" 630986ab12SMaksim Yevmenkin.Fn SDP_PUT8 "b" "cp" 640986ab12SMaksim Yevmenkin.Fn SDP_PUT16 "s" "cp" 650986ab12SMaksim Yevmenkin.Fn SDP_PUT32 "l" "cp" 660986ab12SMaksim Yevmenkin.Fn SDP_PUT64 "l" "cp" 670986ab12SMaksim Yevmenkin.Fn SDP_PUT128 "l" "cp" 6843d33de9SMaksim Yevmenkin.Fn SDP_PUT_UUID128 "l" "cp" 690d0f0252SRuslan Ermilov.Ft "void *" 700986ab12SMaksim Yevmenkin.Fn sdp_open "bdaddr_t const *l" "bdaddr_t const *r" 710d0f0252SRuslan Ermilov.Ft "void *" 72a4b187faSMaksim Yevmenkin.Fn sdp_open_local "char const *control" 730986ab12SMaksim Yevmenkin.Ft int32_t 740986ab12SMaksim Yevmenkin.Fn sdp_close "void *xs" 750986ab12SMaksim Yevmenkin.Ft int32_t 760986ab12SMaksim Yevmenkin.Fn sdp_error "void *xs" 770986ab12SMaksim Yevmenkin.Ft int32_t 78*515bb54cSVladimir Kondratyev.Fn sdp_get_lcaddr "void *xs" "bdaddr_t *l" 79*515bb54cSVladimir Kondratyev.Ft int32_t 800d0f0252SRuslan Ermilov.Fo sdp_search 810d0f0252SRuslan Ermilov.Fa "void *xs" "uint32_t plen" "uint16_t const *pp" "uint32_t alen" 820d0f0252SRuslan Ermilov.Fa "uint32_t const *ap" "uint32_t vlen" "sdp_attr_t *vp" 830d0f0252SRuslan Ermilov.Fc 840d0f0252SRuslan Ermilov.Ft "char const * const" 856aae6f7eSMaksim Yevmenkin.Fn sdp_attr2desc "uint16_t attr" 860d0f0252SRuslan Ermilov.Ft "char const * const" 876aae6f7eSMaksim Yevmenkin.Fn sdp_uuid2desc "uint16_t uuid" 8807be7a6cSMaksim Yevmenkin.Ft int32_t 890d0f0252SRuslan Ermilov.Fo sdp_register_service 900d0f0252SRuslan Ermilov.Fa "void *xss" "uint16_t uuid" "bdaddr_p const bdaddr" "uint8_t const *data" 910d0f0252SRuslan Ermilov.Fa "uint32_t datalen" "uint32_t *handle" 920d0f0252SRuslan Ermilov.Fc 9307be7a6cSMaksim Yevmenkin.Ft int32_t 9407be7a6cSMaksim Yevmenkin.Fn sdp_unregister_service "void *xss" "uint32_t handle" 9507be7a6cSMaksim Yevmenkin.Ft int32_t 960d0f0252SRuslan Ermilov.Fo sdp_change_service 970d0f0252SRuslan Ermilov.Fa "void *xss" "uint32_t handle" "uint8_t const *data" "uint32_t datalen" 980d0f0252SRuslan Ermilov.Fc 990986ab12SMaksim Yevmenkin.Sh DESCRIPTION 1000986ab12SMaksim YevmenkinThe 1010986ab12SMaksim Yevmenkin.Fn SDP_GET8 , 1020986ab12SMaksim Yevmenkin.Fn SDP_GET16 , 1030986ab12SMaksim Yevmenkin.Fn SDP_GET32 , 1040986ab12SMaksim Yevmenkin.Fn SDP_GET64 1050986ab12SMaksim Yevmenkinand 1060986ab12SMaksim Yevmenkin.Fn SDP_GET128 1070986ab12SMaksim Yevmenkinmacros are used to get byte, short, long, long long and 128-bit integer 1080986ab12SMaksim Yevmenkinfrom the buffer pointed by 1090d0f0252SRuslan Ermilov.Fa cp 1101a0a9345SRuslan Ermilovpointer. 1111a0a9345SRuslan ErmilovThe pointer is automatically advanced. 1120986ab12SMaksim Yevmenkin.Pp 1130986ab12SMaksim YevmenkinThe 1140986ab12SMaksim Yevmenkin.Fn SDP_PUT8 , 1150986ab12SMaksim Yevmenkin.Fn SDP_PUT16 , 1160986ab12SMaksim Yevmenkin.Fn SDP_PUT32 , 1170986ab12SMaksim Yevmenkin.Fn SDP_PUT64 1180986ab12SMaksim Yevmenkinand 1190986ab12SMaksim Yevmenkin.Fn SDP_PUT128 1200986ab12SMaksim Yevmenkinmacros are used to put byte, short, long, long long and 128-bit integer 1210986ab12SMaksim Yevmenkininto the buffer pointed by 1220d0f0252SRuslan Ermilov.Fa cp 1231a0a9345SRuslan Ermilovpointer. 1241a0a9345SRuslan ErmilovThe pointer is automatically advanced. 1250986ab12SMaksim Yevmenkin.Pp 12643d33de9SMaksim Yevmenkin.Fn SDP_GET_UUID128 12743d33de9SMaksim Yevmenkinand 12843d33de9SMaksim Yevmenkin.Fn SDP_PUT_UUID128 12943d33de9SMaksim Yevmenkinmacros are used to get and put 128-bit UUID into the buffer pointed by 13043d33de9SMaksim Yevmenkin.Fa cp 13143d33de9SMaksim Yevmenkinpointer. 13243d33de9SMaksim YevmenkinThe pointer is automatically advanced. 13343d33de9SMaksim Yevmenkin.Pp 1340d0f0252SRuslan ErmilovThe 1350986ab12SMaksim Yevmenkin.Fn sdp_open 1360986ab12SMaksim Yevmenkinand 1370986ab12SMaksim Yevmenkin.Fn sdp_open_local 1380986ab12SMaksim Yevmenkinfunctions each return a pointer to an opaque object describing SDP session. 1390986ab12SMaksim YevmenkinThe 1400d0f0252SRuslan Ermilov.Fa l 1410986ab12SMaksim Yevmenkinargument passed to 1420986ab12SMaksim Yevmenkin.Fn sdp_open 1430986ab12SMaksim Yevmenkinfunction should point to a source BD_ADDR. 1440986ab12SMaksim YevmenkinIf source BD_ADDR is 1450986ab12SMaksim Yevmenkin.Dv NULL 1460986ab12SMaksim Yevmenkinthen source address 1470986ab12SMaksim Yevmenkin.Dv NG_HCI_BDADDR_ANY 1480986ab12SMaksim Yevmenkinis used. 1490986ab12SMaksim YevmenkinThe 1500d0f0252SRuslan Ermilov.Fa r 1510986ab12SMaksim Yevmenkinargument passed to 1520986ab12SMaksim Yevmenkin.Fn sdp_open 1530d0f0252SRuslan Ermilovfunction should point to a 1540d0f0252SRuslan Ermilov.Pf non- Dv NULL 1550986ab12SMaksim Yevmenkinremote BD_ADDR. 1560986ab12SMaksim YevmenkinRemote BD_ADDR cannot be 1570986ab12SMaksim Yevmenkin.Dv NG_HCI_BDADDR_ANY . 1580986ab12SMaksim YevmenkinThe 1590986ab12SMaksim Yevmenkin.Fn sdp_open_local 160a4b187faSMaksim Yevmenkinfunction takes path to the control socket and opens a connection to a local 161a4b187faSMaksim YevmenkinSDP server. 162a4b187faSMaksim YevmenkinIf path to the control socket is 163a4b187faSMaksim Yevmenkin.Dv NULL 164a4b187faSMaksim Yevmenkinthen default 165a4b187faSMaksim Yevmenkin.Pa /var/run/sdp 166a4b187faSMaksim Yevmenkinpath will be used. 1670986ab12SMaksim Yevmenkin.Pp 1680986ab12SMaksim YevmenkinThe 1690986ab12SMaksim Yevmenkin.Fn sdp_close 1700986ab12SMaksim Yevmenkinfunction terminates active SDP session and deletes SDP session object. 1710986ab12SMaksim YevmenkinThe 1720d0f0252SRuslan Ermilov.Fa xs 1730986ab12SMaksim Yevmenkinparameter should point to a valid SDP session object created with 1740986ab12SMaksim Yevmenkin.Fn sdp_open 1750986ab12SMaksim Yevmenkinor 1760986ab12SMaksim Yevmenkin.Fn sdp_open_local . 1770986ab12SMaksim Yevmenkin.Pp 1780986ab12SMaksim YevmenkinThe 1790986ab12SMaksim Yevmenkin.Fn sdp_error 1800986ab12SMaksim Yevmenkinfunction returns last error that is stored inside SDP session object. 1810986ab12SMaksim YevmenkinThe 1820d0f0252SRuslan Ermilov.Fa xs 1830986ab12SMaksim Yevmenkinparameter should point to a valid SDP session object created with 1840986ab12SMaksim Yevmenkin.Fn sdp_open 1850986ab12SMaksim Yevmenkinor 1860986ab12SMaksim Yevmenkin.Fn sdp_open_local . 1870986ab12SMaksim YevmenkinThe error value returned can be converted to a human readable message by 1880986ab12SMaksim Yevmenkincalling 1890986ab12SMaksim Yevmenkin.Xr strerror 3 1900986ab12SMaksim Yevmenkinfunction. 1910986ab12SMaksim Yevmenkin.Pp 1920986ab12SMaksim YevmenkinThe 193*515bb54cSVladimir Kondratyev.Fn sdp_get_lcaddr 194*515bb54cSVladimir Kondratyevfunction returns the SDP session actual source BD_ADDR. 195*515bb54cSVladimir KondratyevThe 196*515bb54cSVladimir Kondratyev.Fa xs 197*515bb54cSVladimir Kondratyevparameter should point to a valid SDP session object created with 198*515bb54cSVladimir Kondratyev.Fn sdp_open . 199*515bb54cSVladimir KondratyevThe 200*515bb54cSVladimir Kondratyev.Fa l 201*515bb54cSVladimir Kondratyevparameter should point to a buffer in which the value for the requested BD_ADDR 202*515bb54cSVladimir Kondratyevis to be returned. 203*515bb54cSVladimir Kondratyev.Fn sdp_get_lcaddr 204*515bb54cSVladimir Kondratyevfunction is useful if the current SDP session has been opened with the 205*515bb54cSVladimir Kondratyev.Dv NG_HCI_BDADDR_ANY 206*515bb54cSVladimir Kondratyevvalue passed as a source address. 207*515bb54cSVladimir Kondratyev.Pp 208*515bb54cSVladimir KondratyevThe 2090986ab12SMaksim Yevmenkin.Fn sdp_search 2100986ab12SMaksim Yevmenkinfunction is used to perform SDP Service Search Attribute Request. 2110986ab12SMaksim YevmenkinThe 2120d0f0252SRuslan Ermilov.Fa xs 2130986ab12SMaksim Yevmenkinparameter should point to a valid SDP session object created with 2140986ab12SMaksim Yevmenkin.Fn sdp_open 2150986ab12SMaksim Yevmenkinor 2160986ab12SMaksim Yevmenkin.Fn sdp_open_local . 2170986ab12SMaksim YevmenkinThe 2180d0f0252SRuslan Ermilov.Fa pp 2190986ab12SMaksim Yevmenkinparameter is a Service Search Pattern - an array of one or more Service 2200986ab12SMaksim YevmenkinClass IDs. 2210986ab12SMaksim YevmenkinThe maximum number of Service Class IDs in the array is 12. 2220986ab12SMaksim YevmenkinThe 2230d0f0252SRuslan Ermilov.Fa plen 2240986ab12SMaksim Yevmenkinparameter is the length of the Service Search pattern. 2250986ab12SMaksim YevmenkinThe 2260d0f0252SRuslan Ermilov.Fa ap 2270d0f0252SRuslan Ermilovparameter is an Attribute ID Range List - an array of one or more SDP Attribute 2281a0a9345SRuslan ErmilovID Range. 2291a0a9345SRuslan ErmilovEach attribute ID Range is encoded as a 32-bit unsigned integer data 2300986ab12SMaksim Yevmenkinelement, where the high order 16 bits are interpreted as the beginning 2310986ab12SMaksim Yevmenkinattribute ID of the range and the low order 16 bits are interpreted as the 2320986ab12SMaksim Yevmenkinending attribute ID of the range. 2330986ab12SMaksim YevmenkinThe attribute IDs contained in the Attribute ID Ranges List must be listed in 2340986ab12SMaksim Yevmenkinascending order without duplication of any attribute ID values. 2350986ab12SMaksim YevmenkinNote that all attributes may be requested by specifying a range of 2360986ab12SMaksim Yevmenkin0x0000-0xFFFF. 2370986ab12SMaksim YevmenkinThe 2380d0f0252SRuslan Ermilov.Fa alen 2390986ab12SMaksim Yevmenkinparameter is the length of the Attribute ID Ranges List. 2400986ab12SMaksim YevmenkinThe 2410986ab12SMaksim Yevmenkin.Fn SDP_ATTR_RANGE "lo" "hi" 2420986ab12SMaksim Yevmenkinmacro can be used to prepare Attribute ID Range. 2430986ab12SMaksim YevmenkinThe 2440d0f0252SRuslan Ermilov.Fa vp 2450986ab12SMaksim Yevmenkinparameter should be an array of 2460986ab12SMaksim Yevmenkin.Vt sdp_attr_t 2470986ab12SMaksim Yevmenkinstructures. 2480986ab12SMaksim YevmenkinEach 2490986ab12SMaksim Yevmenkin.Vt sdp_attr_t 2500986ab12SMaksim Yevmenkinstructure describes single SDP attribute and defined as follows: 2510986ab12SMaksim Yevmenkin.Bd -literal -offset indent 2520986ab12SMaksim Yevmenkinstruct sdp_attr { 2536aae6f7eSMaksim Yevmenkin uint16_t flags; 2540986ab12SMaksim Yevmenkin#define SDP_ATTR_OK (0 << 0) 2550986ab12SMaksim Yevmenkin#define SDP_ATTR_INVALID (1 << 0) 2560986ab12SMaksim Yevmenkin#define SDP_ATTR_TRUNCATED (1 << 1) 2576aae6f7eSMaksim Yevmenkin uint16_t attr; /* SDP_ATTR_xxx */ 2586aae6f7eSMaksim Yevmenkin uint32_t vlen; /* length of the value[] in bytes */ 2596aae6f7eSMaksim Yevmenkin uint8_t *value; /* base pointer */ 2600986ab12SMaksim Yevmenkin}; 2610986ab12SMaksim Yevmenkintypedef struct sdp_attr sdp_attr_t; 2620986ab12SMaksim Yevmenkintypedef struct sdp_attr * sdp_attr_p; 2630986ab12SMaksim Yevmenkin.Ed 2640986ab12SMaksim Yevmenkin.Pp 2650986ab12SMaksim YevmenkinThe caller of the 2660986ab12SMaksim Yevmenkin.Fn sdp_search 2670986ab12SMaksim Yevmenkinfunction is expected to prepare the array of 2680986ab12SMaksim Yevmenkin.Vt sdp_attr 2690986ab12SMaksim Yevmenkinstructures and for each element of the array both 2700d0f0252SRuslan Ermilov.Va vlen 2710986ab12SMaksim Yevmenkinand 2720d0f0252SRuslan Ermilov.Va value 2730986ab12SMaksim Yevmenkinmust be set. 2740986ab12SMaksim YevmenkinThe 2750986ab12SMaksim Yevmenkin.Fn sdp_search 2760986ab12SMaksim Yevmenkinfunction will fill each 2770986ab12SMaksim Yevmenkin.Vt sdp_attr_t 2781a0a9345SRuslan Ermilovstructure with attribute and value, i.e., it will set 2790d0f0252SRuslan Ermilov.Va flags , 2800d0f0252SRuslan Ermilov.Va attr 2810986ab12SMaksim Yevmenkinand 2820d0f0252SRuslan Ermilov.Va vlen 2830986ab12SMaksim Yevmenkinfields. 2840986ab12SMaksim YevmenkinThe actual value of the attribute will be copied into 2850d0f0252SRuslan Ermilov.Va value 2860986ab12SMaksim Yevmenkinbuffer. 2870986ab12SMaksim YevmenkinNote: attributes are returned in the order they appear in the Service Search 2880986ab12SMaksim YevmenkinAttribute Response. 2890986ab12SMaksim YevmenkinSDP server could return several attributes for the same record. 2900986ab12SMaksim YevmenkinIn this case the order of the attributes will be: all attributes for the first 291c2025a76SJoel Dahlrecords, then all attributes for the second record etc. 2920986ab12SMaksim Yevmenkin.Pp 2930986ab12SMaksim YevmenkinThe 2940986ab12SMaksim Yevmenkin.Fn sdp_attr2desc 2950986ab12SMaksim Yevmenkinand 2960986ab12SMaksim Yevmenkin.Fn sdp_uuid2desc 2970986ab12SMaksim Yevmenkinfunctions each take a numeric attribute ID/UUID value and convert it to a 2980986ab12SMaksim Yevmenkinhuman readable description. 29907be7a6cSMaksim Yevmenkin.Pp 30007be7a6cSMaksim YevmenkinThe 30107be7a6cSMaksim Yevmenkin.Fn sdp_register_service 3020d0f0252SRuslan Ermilovfunction 30307be7a6cSMaksim Yevmenkinis used to register service with the local SDP server. 30407be7a6cSMaksim YevmenkinThe 3050d0f0252SRuslan Ermilov.Fa xss 30607be7a6cSMaksim Yevmenkinparameter should point to a valid SDP session object obtained from 30707be7a6cSMaksim Yevmenkin.Fn sdp_open_local . 30807be7a6cSMaksim YevmenkinThe 3090d0f0252SRuslan Ermilov.Fa uuid 31007be7a6cSMaksim Yevmenkinparameter is a SDP Service Class ID for the service to be registered. 31107be7a6cSMaksim YevmenkinThe 3120d0f0252SRuslan Ermilov.Fa bdaddr 31307be7a6cSMaksim Yevmenkinparameter should point to a valid BD_ADDR. 31407be7a6cSMaksim YevmenkinThe service will be only advertised if request was received by the local device 31507be7a6cSMaksim Yevmenkinwith 3160d0f0252SRuslan Ermilov.Fa bdaddr . 31707be7a6cSMaksim YevmenkinIf 3180d0f0252SRuslan Ermilov.Fa bdaddr 31907be7a6cSMaksim Yevmenkinis set to 32007be7a6cSMaksim Yevmenkin.Dv NG_HCI_BDADDR_ANY 32107be7a6cSMaksim Yevmenkinthen the service will be advertised to any remote devices that queries for it. 32207be7a6cSMaksim YevmenkinThe 3230d0f0252SRuslan Ermilov.Fa data 32407be7a6cSMaksim Yevmenkinand 3250d0f0252SRuslan Ermilov.Fa datalen 32607be7a6cSMaksim Yevmenkinparameters specify data and size of the data for the service. 32707be7a6cSMaksim YevmenkinUpon successful return 32807be7a6cSMaksim Yevmenkin.Fn sdp_register_service 32907be7a6cSMaksim Yevmenkinwill populate 3300d0f0252SRuslan Ermilov.Fa handle 33107be7a6cSMaksim Yevmenkinwith the SDP record handle. 33207be7a6cSMaksim YevmenkinThis parameter is optional and can be set to 33307be7a6cSMaksim Yevmenkin.Dv NULL . 33407be7a6cSMaksim Yevmenkin.Pp 33507be7a6cSMaksim YevmenkinThe 33607be7a6cSMaksim Yevmenkin.Fn sdp_unregister_service 3370d0f0252SRuslan Ermilovfunction 33807be7a6cSMaksim Yevmenkinis used to unregister service with the local SDP server. 33907be7a6cSMaksim YevmenkinThe 3400d0f0252SRuslan Ermilov.Fa xss 34107be7a6cSMaksim Yevmenkinparameter should point to a valid SDP session object obtained from 34207be7a6cSMaksim Yevmenkin.Fn sdp_open_local . 34307be7a6cSMaksim YevmenkinThe 3440d0f0252SRuslan Ermilov.Fa handle 34507be7a6cSMaksim Yevmenkinparameter should contain a valid SDP record handle of the service to be 34607be7a6cSMaksim Yevmenkinunregistered. 34707be7a6cSMaksim Yevmenkin.Pp 34807be7a6cSMaksim YevmenkinThe 34907be7a6cSMaksim Yevmenkin.Fn sdp_change_service 35007be7a6cSMaksim Yevmenkinfunction is used to change data associated with the existing service on 35107be7a6cSMaksim Yevmenkinthe local SDP server. 35207be7a6cSMaksim YevmenkinThe 3530d0f0252SRuslan Ermilov.Fa xss 35407be7a6cSMaksim Yevmenkinparameter should point to a valid SDP session object obtained from 35507be7a6cSMaksim Yevmenkin.Fn sdp_open_local . 35607be7a6cSMaksim YevmenkinThe 3570d0f0252SRuslan Ermilov.Fa handle 35807be7a6cSMaksim Yevmenkinparameter should contain a valid SDP record handle of the service to be changed. 35907be7a6cSMaksim YevmenkinThe 3600d0f0252SRuslan Ermilov.Fa data 36107be7a6cSMaksim Yevmenkinand 3620d0f0252SRuslan Ermilov.Fa datalen 36307be7a6cSMaksim Yevmenkinparameters specify data and size of the data for the service. 36407be7a6cSMaksim Yevmenkin.Sh CAVEAT 36507be7a6cSMaksim YevmenkinWhen registering services with the local SDP server the application must 36607be7a6cSMaksim Yevmenkinkeep the SDP session open. 36707be7a6cSMaksim YevmenkinIf SDP session is closed then the local SDP server will remove all services 36807be7a6cSMaksim Yevmenkinthat were registered over the session. 36907be7a6cSMaksim YevmenkinThe application is allowed to change or unregister service if it was registered 37007be7a6cSMaksim Yevmenkinover the same session. 3710986ab12SMaksim Yevmenkin.Sh EXAMPLES 3720986ab12SMaksim YevmenkinThe following example shows how to get 3730986ab12SMaksim Yevmenkin.Dv SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST 3740986ab12SMaksim Yevmenkinattribute for the 3750986ab12SMaksim Yevmenkin.Dv SDP_SERVICE_CLASS_SERIAL_PORT 3760986ab12SMaksim Yevmenkinservice from the remote device. 3770986ab12SMaksim Yevmenkin.Bd -literal -offset indent 3780986ab12SMaksim Yevmenkinbdaddr_t remote; 3796aae6f7eSMaksim Yevmenkinuint8_t buffer[1024]; 3800986ab12SMaksim Yevmenkinvoid *ss = NULL; 3816aae6f7eSMaksim Yevmenkinuint16_t serv = SDP_SERVICE_CLASS_SERIAL_PORT; 3826aae6f7eSMaksim Yevmenkinuint32_t attr = SDP_ATTR_RANGE( 3830986ab12SMaksim Yevmenkin SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, 3840986ab12SMaksim Yevmenkin SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST); 3850986ab12SMaksim Yevmenkinsdp_attr_t proto = { SDP_ATTR_INVALID,0,sizeof(buffer),buffer }; 3860986ab12SMaksim Yevmenkin 3870986ab12SMaksim Yevmenkin/* Obtain/set remote BDADDR here */ 3880986ab12SMaksim Yevmenkin 3890986ab12SMaksim Yevmenkinif ((ss = sdp_open(NG_HCI_BDADDR_ANY, remote)) == NULL) 3900986ab12SMaksim Yevmenkin /* exit ENOMEM */ 3910986ab12SMaksim Yevmenkinif (sdp_error(ss) != 0) 39243d33de9SMaksim Yevmenkin /* exit sdp_error(ss) */ 3930986ab12SMaksim Yevmenkin 3940986ab12SMaksim Yevmenkinif (sdp_search(ss, 1, &serv, 1, &attr, 1, &proto) != 0) 3950986ab12SMaksim Yevmenkin /* exit sdp_error(ss) */ 3960986ab12SMaksim Yevmenkin 3970986ab12SMaksim Yevmenkinif (proto.flags != SDP_ATTR_OK) 3980986ab12SMaksim Yevmenkin /* exit see proto.flags for details */ 3990986ab12SMaksim Yevmenkin 4000986ab12SMaksim Yevmenkin/* If we got here then we have attribute value in proto.value */ 4010986ab12SMaksim Yevmenkin.Ed 4020986ab12SMaksim Yevmenkin.Sh DIAGNOSTICS 4030986ab12SMaksim YevmenkinBoth 4040986ab12SMaksim Yevmenkin.Fn sdp_open 4050986ab12SMaksim Yevmenkinand 4060986ab12SMaksim Yevmenkin.Fn sdp_open_local 4070986ab12SMaksim Yevmenkinwill return 4080986ab12SMaksim Yevmenkin.Dv NULL 4090986ab12SMaksim Yevmenkinif memory allocation for the new SDP session object fails. 4100986ab12SMaksim YevmenkinIf the new SDP object was created then caller is still expected to call 4110986ab12SMaksim Yevmenkin.Fn sdp_error 4120986ab12SMaksim Yevmenkinto check if there was connection error. 4130986ab12SMaksim Yevmenkin.Pp 4140986ab12SMaksim YevmenkinThe 415*515bb54cSVladimir Kondratyev.Fn sdp_get_lcaddr , 41607be7a6cSMaksim Yevmenkin.Fn sdp_search , 41707be7a6cSMaksim Yevmenkin.Fn sdp_register_service , 418*515bb54cSVladimir Kondratyev.Fn sdp_unregister_service , 41907be7a6cSMaksim Yevmenkinand 42007be7a6cSMaksim Yevmenkin.Fn sdp_change_service 42107be7a6cSMaksim Yevmenkinfunctions return non-zero value on error. 4220986ab12SMaksim YevmenkinThe caller is expected to call 4230986ab12SMaksim Yevmenkin.Fn sdp_error 4240986ab12SMaksim Yevmenkinto find out more about error. 4250986ab12SMaksim Yevmenkin.Sh SEE ALSO 4260986ab12SMaksim Yevmenkin.Xr bluetooth 3 , 42707be7a6cSMaksim Yevmenkin.Xr strerror 3 , 42807be7a6cSMaksim Yevmenkin.Xr sdpcontrol 8 , 42907be7a6cSMaksim Yevmenkin.Xr sdpd 8 43024a0682cSRuslan Ermilov.Sh AUTHORS 4312b7af31cSBaptiste Daroussin.An Maksim Yevmenkin Aq Mt m_evmenkin@yahoo.com 4320986ab12SMaksim Yevmenkin.Sh BUGS 43307be7a6cSMaksim YevmenkinMost likely. 4340986ab12SMaksim YevmenkinPlease report bugs if found. 435