summaryrefslogtreecommitdiffstats
path: root/plugins/hfp_hf_bluez5.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2013-02-28 13:01:06 -0300
committerDenis Kenzior <denkenz@gmail.com>2013-02-28 10:10:13 -0600
commitfb9b54bc2cef4393db5bddcc2fd044bf8f3fe6d9 (patch)
tree8be9e3d397a92b2fda010c8609ddf847beda387e /plugins/hfp_hf_bluez5.c
parent4ef4d620e4567af6f029c74e4021468d86417a0d (diff)
downloadofono-fb9b54bc2cef4393db5bddcc2fd044bf8f3fe6d9.tar.bz2
hfp_hf_bluez5: Add local address to Audio Card
Diffstat (limited to 'plugins/hfp_hf_bluez5.c')
-rw-r--r--plugins/hfp_hf_bluez5.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 87d7e91b..3960d7a6 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -323,7 +323,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
socklen_t optlen;
DBusMessageIter entry;
const char *device;
- char remote[18];
+ char local[18], remote[18];
int fd, err;
DBG("Profile handler NewConnection");
@@ -363,6 +363,19 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
memset(&saddr, 0, sizeof(saddr));
optlen = sizeof(saddr);
+ if (getsockname(fd, (struct sockaddr *) &saddr, &optlen) < 0) {
+ err = errno;
+ ofono_error("RFCOMM getsockname(): %s (%d)", strerror(err),
+ err);
+ close(fd);
+ goto invalid;
+ }
+
+ bt_ba2str(&saddr.rc_bdaddr, local);
+
+ memset(&saddr, 0, sizeof(saddr));
+ optlen = sizeof(saddr);
+
if (getpeername(fd, (struct sockaddr *) &saddr, &optlen) < 0) {
err = errno;
ofono_error("RFCOMM getpeername(): %s (%d)", strerror(err),
@@ -375,7 +388,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
hfp = ofono_modem_get_data(modem);
hfp->msg = dbus_message_ref(msg);
- hfp->card = ofono_handsfree_card_create(remote, NULL);
+ hfp->card = ofono_handsfree_card_create(remote, local);
return NULL;