libsdp: Add method that returns actual source BD_ADDR of SDP session.

Reviewed by:	emax, wblock (docs)
Differential Revision:	https://reviews.freebsd.org/D13456
This commit is contained in:
Vladimir Kondratyev 2018-04-30 10:15:58 +00:00
parent 45aca3b1a1
commit 515bb54c9f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=333109
3 changed files with 45 additions and 2 deletions

View File

@ -25,7 +25,7 @@
.\" $Id: sdp.3,v 1.1 2003/09/07 20:34:19 max Exp $
.\" $FreeBSD$
.\"
.Dd May 27, 2005
.Dd April 30, 2018
.Dt SDP 3
.Os
.Sh NAME
@ -45,6 +45,7 @@
.Nm sdp_open_local ,
.Nm sdp_close ,
.Nm sdp_error ,
.Nm sdp_get_lcaddr ,
.Nm sdp_search ,
.Nm sdp_attr2desc ,
.Nm sdp_uuid2desc
@ -75,6 +76,8 @@
.Ft int32_t
.Fn sdp_error "void *xs"
.Ft int32_t
.Fn sdp_get_lcaddr "void *xs" "bdaddr_t *l"
.Ft int32_t
.Fo sdp_search
.Fa "void *xs" "uint32_t plen" "uint16_t const *pp" "uint32_t alen"
.Fa "uint32_t const *ap" "uint32_t vlen" "sdp_attr_t *vp"
@ -188,6 +191,22 @@ calling
function.
.Pp
The
.Fn sdp_get_lcaddr
function returns the SDP session actual source BD_ADDR.
The
.Fa xs
parameter should point to a valid SDP session object created with
.Fn sdp_open .
The
.Fa l
parameter should point to a buffer in which the value for the requested BD_ADDR
is to be returned.
.Fn sdp_get_lcaddr
function is useful if the current SDP session has been opened with the
.Dv NG_HCI_BDADDR_ANY
value passed as a source address.
.Pp
The
.Fn sdp_search
function is used to perform SDP Service Search Attribute Request.
The
@ -394,9 +413,10 @@ If the new SDP object was created then caller is still expected to call
to check if there was connection error.
.Pp
The
.Fn sdp_get_lcaddr ,
.Fn sdp_search ,
.Fn sdp_register_service ,
.Fn sdp_unregister_service
.Fn sdp_unregister_service ,
and
.Fn sdp_change_service
functions return non-zero value on error.

View File

@ -532,6 +532,7 @@ void * sdp_open (bdaddr_t const *l, bdaddr_t const *r);
void * sdp_open_local (char const *control);
int32_t sdp_close (void *xs);
int32_t sdp_error (void *xs);
int32_t sdp_get_lcaddr (void *xs, bdaddr_t *l);
int32_t sdp_search (void *xs,
uint32_t plen, uint16_t const *pp,

View File

@ -180,3 +180,25 @@ sdp_error(void *xss)
return ((ss != NULL)? ss->error : EINVAL);
}
int32_t
sdp_get_lcaddr(void *xss, bdaddr_t *l)
{
sdp_session_p ss = (sdp_session_p) xss;
struct sockaddr_l2cap sa;
socklen_t size;
if (l == NULL || ss == NULL || ss->flags & SDP_SESSION_LOCAL) {
ss->error = EINVAL;
goto fail;
}
size = sizeof(sa);
if (getsockname(ss->s, (struct sockaddr *)&sa, &size) == 0) {
bdaddr_copy(l, &sa.l2cap_bdaddr);
ss->error = 0;
} else
ss->error = errno;
fail:
return ((ss->error == 0) ? 0 : -1);
}