diff options
author | Andrei Emeltchenko <andrei.emeltchenko@intel.com> | 2013-12-19 10:49:19 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2013-12-19 11:08:22 +0200 |
commit | eaf50643750257db4b8f482acaecc9a2bc2eeb66 (patch) | |
tree | f5d4ff580697aeefbbb2ad6a24ce53611cbe9544 /android/socket.c | |
parent | b81374ec8001e307507cd98bf3902fc594f4d428 (diff) | |
download | bluez-eaf50643750257db4b8f482acaecc9a2bc2eeb66.tar.gz |
android/socket: Connect directly to RFCOMM channel if uuid is zero
Check uuid and connect to specified RFCOMM channel directly if uuid is
zeroed.
Diffstat (limited to 'android/socket.c')
-rw-r--r-- | android/socket.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/android/socket.c b/android/socket.c index 656222ea7..561a1d5ba 100644 --- a/android/socket.c +++ b/android/socket.c @@ -928,6 +928,7 @@ fail: static void handle_connect(const void *buf, uint16_t len) { const struct hal_cmd_sock_connect *cmd = buf; + static const uint8_t zero_uuid[16] = { 0 }; struct rfcomm_sock *rfsock; uuid_t uuid; int hal_fd = -1; @@ -940,17 +941,21 @@ static void handle_connect(const void *buf, uint16_t len) android2bdaddr(cmd->bdaddr, &rfsock->dst); - memset(&uuid, 0, sizeof(uuid)); - uuid.type = SDP_UUID128; - memcpy(&uuid.value.uuid128, cmd->uuid, sizeof(uint128_t)); + if (!memcmp(cmd->uuid, zero_uuid, sizeof(zero_uuid))) { + if (!do_connect(rfsock, cmd->channel)) + goto failed; + } else { + memset(&uuid, 0, sizeof(uuid)); + uuid.type = SDP_UUID128; + memcpy(&uuid.value.uuid128, cmd->uuid, sizeof(uint128_t)); - rfsock->profile = get_profile_by_uuid(cmd->uuid); + rfsock->profile = get_profile_by_uuid(cmd->uuid); - if (bt_search_service(&adapter_addr, &rfsock->dst, &uuid, + if (bt_search_service(&adapter_addr, &rfsock->dst, &uuid, sdp_search_cb, rfsock, NULL) < 0) { - error("Failed to search SDP records"); - cleanup_rfsock(rfsock); - goto failed; + error("Failed to search SDP records"); + goto failed; + } } ipc_send_rsp_full(HAL_SERVICE_ID_SOCK, HAL_OP_SOCK_CONNECT, 0, NULL, @@ -962,6 +967,9 @@ failed: ipc_send_rsp(HAL_SERVICE_ID_SOCK, HAL_OP_SOCK_CONNECT, HAL_STATUS_FAILED); + if (rfsock) + cleanup_rfsock(rfsock); + if (hal_fd >= 0) close(hal_fd); } |