*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->FreeBSD man pages -> sdp_close (3)              
Title
Content
Arch
Section
 

SDP(3)

Contents


NAME    [Toc]    [Back]

     SDP_GET8, SDP_GET16, SDP_GET32, SDP_GET64, SDP_GET128 -- get SDP integer

     SDP_PUT8, SDP_PUT16, SDP_PUT32, SDP_PUT64, SDP_PUT128 -- put SPD integer

     sdp_open, sdp_open_local, sdp_close sdp_error -- control SDP session

     sdp_search -- perform SDP query

     sdp_attr2desc, sdp_uuid2desc -- convert numeric SDP attribute/UUID value
     into human readable description

LIBRARY    [Toc]    [Back]

     library ``libsdp''

SYNOPSIS    [Toc]    [Back]

     #include <bluetooth.h>
     #include <sdp.h>

     SDP_GET8(b, cp);

     SDP_GET16(s, cp);

     SDP_GET32(l, cp);

     SDP_GET64(l, cp);

     SDP_GET128(l, cp);

     SDP_PUT8(b, cp);

     SDP_PUT16(s, cp);

     SDP_PUT32(l, cp);

     SDP_PUT64(l, cp);

     SDP_PUT128(l, cp);

     void *
     sdp_open(bdaddr_t const *l, bdaddr_t const *r);

     void *
     sdp_open_local(void);

     int32_t
     sdp_close(void *xs);

     int32_t
     sdp_error(void *xs);

     int32_t
     sdp_search(void *xs, u_int32_t plen, u_int16_t const *pp, u_int32_t alen,
	 u_int32_t const *ap, u_int32_t vlen, sdp_attr_t *vp);

     char const * const
     sdp_attr2desc(u_int16_t attr);

     char const * const
     sdp_uuid2desc(u_int16_t uuid);

DESCRIPTION    [Toc]    [Back]

     The SDP_GET8(), SDP_GET16(), SDP_GET32(), SDP_GET64() and SDP_GET128()
     macros are used to get byte, short, long, long long and 128-bit integer
     from the buffer pointed by cp pointer. The pointer is automatically
     advanced.

     The SDP_PUT8(), SDP_PUT16(), SDP_PUT32(), SDP_PUT64() and SDP_PUT128()
     macros are used to put byte, short, long, long long and 128-bit integer
     into the buffer pointed by cp pointer. The pointer is automatically
     advanced.

     sdp_open() and sdp_open_local() functions each return a pointer to an
     opaque object describing SDP session.  The l argument passed to
     sdp_open() function should point to a source BD_ADDR.  If source BD_ADDR
     is NULL then source address NG_HCI_BDADDR_ANY is used.  The r argument
     passed to sdp_open() function should point to a non NULL remote BD_ADDR.
     Remote BD_ADDR can not be NG_HCI_BDADDR_ANY.  The sdp_open_local() function
 takes no arguments and opens a connection to a local SDP server.

     The sdp_close() function terminates active SDP session and deletes SDP
     session object.  The xs parameter should point to a valid SDP session
     object created with sdp_open() or sdp_open_local().

     The sdp_error() function returns last error that is stored inside SDP
     session object.  The xs parameter should point to a valid SDP session
     object created with sdp_open() or sdp_open_local().  The error value
     returned can be converted to a human readable message by calling
     strerror(3) function.

     The sdp_search() function is used to perform SDP Service Search Attribute
     Request.  The xs parameter should point to a valid SDP session object
     created with sdp_open() or sdp_open_local().  The pp parameter is a Service
 Search Pattern - an array of one or more Service Class IDs.  The
     maximum number of Service Class IDs in the array is 12.  The plen parameter
 is the length of the Service Search pattern.  The ap parameter is a
     Attribute ID Range List - an array of one or more SDP Attribute ID Range.
     Each attribute ID Range is encoded as a 32-bit unsigned integer data element,
 where the high order 16 bits are interpreted as the beginning
     attribute ID of the range and the low order 16 bits are interpreted as
     the ending attribute ID of the range.  The attribute IDs contained in the
     Attribute ID Ranges List must be listed in ascending order without duplication
 of any attribute ID values.  Note that all attributes may be
     requested by specifying a range of 0x0000-0xFFFF.	The alen parameter is
     the length of the Attribute ID Ranges List.  The SDP_ATTR_RANGE(lo, hi)
     macro can be used to prepare Attribute ID Range.  The vp parameter should
     be an array of sdp_attr_t structures.  Each sdp_attr_t structure
     describes single SDP attribute and defined as follows:

	   struct sdp_attr {
		   u_int16_t	    flags;
	   #define SDP_ATTR_OK		   (0 << 0)
	   #define SDP_ATTR_INVALID	   (1 << 0)
	   #define SDP_ATTR_TRUNCATED	   (1 << 1)
		   u_int16_t	    attr;  /* SDP_ATTR_xxx */
		   u_int32_t	    vlen;  /* length of the value[] in bytes */
		   u_int8_t	   *value; /* base pointer */
	   };
	   typedef struct sdp_attr	   sdp_attr_t;
	   typedef struct sdp_attr *	   sdp_attr_p;

     The caller of the sdp_search() function is expected to prepare the array
     of sdp_attr structures and for each element of the array both vlen and
     value must be set.  The sdp_search() function will fill each sdp_attr_t
     structure with attribute and value, i.e. it will set flags, attr and vlen
     fields.  The actual value of the attribute will be copied into value
     buffer.  Note: attributes are returned in the order they appear in the
     Service Search Attribute Response.  SDP server could return several
     attributes for the same record.  In this case the order of the attributes
     will be: all attributes for the first records, then all attributes for
     the secord record etc.

     The sdp_attr2desc() and sdp_uuid2desc() functions each take a numeric
     attribute ID/UUID value and convert it to a human readable description.

EXAMPLES    [Toc]    [Back]

     The following example shows how to get SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST
     attribute for the SDP_SERVICE_CLASS_SERIAL_PORT service from the remote
     device.

	   bdaddr_t	  remote;
	   u_int8_t	  buffer[1024];
	   void 	 *ss	= NULL;
	   u_int16_t	  serv	= SDP_SERVICE_CLASS_SERIAL_PORT;
	   u_int32_t	  attr	= SDP_ATTR_RANGE(
				       SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST,
				       SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST);
	   sdp_attr_t	  proto = { SDP_ATTR_INVALID,0,sizeof(buffer),buffer };

	   /* Obtain/set remote BDADDR here */

	   if ((ss = sdp_open(NG_HCI_BDADDR_ANY, remote)) == NULL)
		   /* exit ENOMEM */
	   if (sdp_error(ss) != 0)
		   /* exit spd_error(ss) */

	   if (sdp_search(ss, 1, &serv, 1, &attr, 1, &proto) != 0)
		   /* exit sdp_error(ss) */

	   if (proto.flags != SDP_ATTR_OK)
		   /* exit see proto.flags for details */

	   /* If we got here then we have attribute value in proto.value */

DIAGNOSTICS    [Toc]    [Back]

     Both sdp_open() and sdp_open_local() will return NULL if memory allocation
 for the new SDP session object fails.  If the new SDP object was
     created then caller is still expected to call sdp_error() to check if
     there was connection error.

     The sdp_search() function returns non-zero value on error.  The caller is
     expected to call sdp_error() to find out more about error.

SEE ALSO    [Toc]    [Back]

      
      
     bluetooth(3), strerror(3)

BUGS    [Toc]    [Back]

     This is client only library for now.  Please report bugs if found.

AUTHORS    [Toc]    [Back]

     Maksim Yevmenkin <[email protected]>


FreeBSD 5.2.1		       September 7, 2003		 FreeBSD 5.2.1
[ Back ]
 Similar pages
Name OS Title
ERR_reason_error_string OpenBSD obtain human-readable error message
ERR_lib_error_string OpenBSD obtain human-readable error message
ERR_error_string NetBSD obtain human-readable error message
fmt_scaled OpenBSD handle numbers with a human-readable scale
scan_scaled OpenBSD handle numbers with a human-readable scale
ERR_error_string_n Tru64 Obtain human-readable error message
humanize_number NetBSD format a number into a human readable form
format_bytes NetBSD format a number into a human readable form
ERR_reason_error_string Tru64 Obtain human-readable error message
ERR_lib_error_string Tru64 Obtain human-readable error message
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service