---
 plugins/hfp_hf_bluez5.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index dbb1303..ac2ed61 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");
@@ -362,6 +362,18 @@ 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),
@@ -374,7 +386,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;
 
-- 
1.7.11.7

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to