aboutsummaryrefslogtreecommitdiff
path: root/lib/libsdp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libsdp')
-rw-r--r--lib/libsdp/sdp.324
-rw-r--r--lib/libsdp/sdp.h1
-rw-r--r--lib/libsdp/session.c22
3 files changed, 45 insertions, 2 deletions
diff --git a/lib/libsdp/sdp.3 b/lib/libsdp/sdp.3
index 9d394e872497..881996a95c13 100644
--- a/lib/libsdp/sdp.3
+++ b/lib/libsdp/sdp.3
@@ -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.
diff --git a/lib/libsdp/sdp.h b/lib/libsdp/sdp.h
index 8774a0ba8c88..b6d533898582 100644
--- a/lib/libsdp/sdp.h
+++ b/lib/libsdp/sdp.h
@@ -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,
diff --git a/lib/libsdp/session.c b/lib/libsdp/session.c
index 52559585c22e..43be17c0294e 100644
--- a/lib/libsdp/session.c
+++ b/lib/libsdp/session.c
@@ -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);
+}