From fb9b54bc2cef4393db5bddcc2fd044bf8f3fe6d9 Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Thu, 28 Feb 2013 13:01:06 -0300 Subject: hfp_hf_bluez5: Add local address to Audio Card --- plugins/hfp_hf_bluez5.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'plugins/hfp_hf_bluez5.c') 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; -- cgit v1.2.3