* [PATCH] android/bluetooth: Fix memory leak
From: Andrei Emeltchenko @ 2013-11-22 14:21 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/bluetooth.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 11b9d76..aa684bd 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -450,6 +450,7 @@ static void update_records(struct browse_req *req, sdp_list_t *recs)
memcpy(&uuid128, tmp, sizeof(uuid_t));
break;
default:
+ sdp_list_free(svcclass, free);
continue;
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH] bluetoothctl: Fix handling of (G_IO_IN | G_IO_HUP) input case
From: Philip Withnall @ 2013-11-22 12:47 UTC (permalink / raw)
To: linux-bluetooth
[-- Attachment #1: Type: text/plain, Size: 965 bytes --]
If running bluetoothctl as a subprocess from another process, and piping
input to it, it’s possible for the stdin pipe to be closed by the parent
process while there’s still data pending in its buffer. This results in
input handler callbacks with condition (G_IO_IN | G_IO_HUP). All of the
pending input should be handled before closing bluetoothctl.
---
client/main.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/client/main.c b/client/main.c
index 0dd1510..0ec40c7 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1197,12 +1197,16 @@ done:
static gboolean input_handler(GIOChannel *channel, GIOCondition condition,
gpointer user_data)
{
+ if (condition & G_IO_IN) {
+ rl_callback_read_char();
+ return TRUE;
+ }
+
if (condition & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) {
g_main_loop_quit(main_loop);
return FALSE;
}
- rl_callback_read_char();
return TRUE;
}
--
1.8.3.1
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 230 bytes --]
^ permalink raw reply related
* [PATCH 4/4] android/build: Add DID PICS file to EXTRA_DIST
From: Jakub Tyszkowski @ 2013-11-22 10:47 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385117261-25270-1-git-send-email-jakub.tyszkowski@tieto.com>
---
android/Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/Makefile.am b/android/Makefile.am
index eeff912..5f6b1a3 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -85,4 +85,4 @@ endif
EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
android/pics-gap.txt android/pics-hid.txt \
- android/pics-pan.txt
+ android/pics-pan.txt android/pics-did.txt
--
1.8.4.1
^ permalink raw reply related
* [PATCH 3/4] android/pics: Add PTS PICS for DID
From: Jakub Tyszkowski @ 2013-11-22 10:47 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385117261-25270-1-git-send-email-jakub.tyszkowski@tieto.com>
PTS PICS for DID, targeting Android 4.4.
---
android/pics-did.txt | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 android/pics-did.txt
diff --git a/android/pics-did.txt b/android/pics-did.txt
new file mode 100644
index 0000000..8f92bc1
--- /dev/null
+++ b/android/pics-did.txt
@@ -0,0 +1,31 @@
+DID PICS for the PTS tool.
+
+* - different than PTS defaults
+# - not yet implemented/supported
+
+M - mandatory
+O - optional
+
+ Version
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_DID_0_1 False Device ID 1.2 (C.1)
+TSPC_DID_0_2 True Device ID 1.3 (C.1)
+-------------------------------------------------------------------------------
+C.1: It is mandatory to support one of the profile versions.
+-------------------------------------------------------------------------------
+
+
+ SDP Requirements
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_DID_1_1 True Specification ID (M)
+TSPC_DID_1_2 True Vendor ID (M)
+TSPC_DID_1_3 True Product ID (M)
+TSPC_DID_1_4 True Version (M)
+TSPC_DID_1_5 True Primary Record (M)
+TSPC_DID_1_6 True Vendor ID Source (M)
+TSPC_ALL False Turns on all the test cases
+-------------------------------------------------------------------------------
--
1.8.4.1
^ permalink raw reply related
* [PATCH 2/4] android/build: Add PAN PICS file to EXTRA_DIST
From: Jakub Tyszkowski @ 2013-11-22 10:47 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385117261-25270-1-git-send-email-jakub.tyszkowski@tieto.com>
---
android/Makefile.am | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/android/Makefile.am b/android/Makefile.am
index c4544ea..eeff912 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -84,4 +84,5 @@ android_haltest_LDFLAGS = -pthread
endif
EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
- android/pics-gap.txt android/pics-hid.txt
+ android/pics-gap.txt android/pics-hid.txt \
+ android/pics-pan.txt
--
1.8.4.1
^ permalink raw reply related
* [PATCH 1/4] android/pics: Add PTS PICS for PAN
From: Jakub Tyszkowski @ 2013-11-22 10:47 UTC (permalink / raw)
To: linux-bluetooth
PTS PICS for PAN, targeting Android 4.4.
---
android/pics-pan.txt | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 146 insertions(+)
create mode 100644 android/pics-pan.txt
diff --git a/android/pics-pan.txt b/android/pics-pan.txt
new file mode 100644
index 0000000..7576d2d
--- /dev/null
+++ b/android/pics-pan.txt
@@ -0,0 +1,146 @@
+PAN PICS for the PTS tool.
+
+* - different than PTS defaults
+# - not yet implemented/supported
+
+M - mandatory
+O - optional
+
+ Roles
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_PAN_1_1 True (*#) Role: Network Access Point (O.1)
+TSPC_PAN_1_2 False Role: Group Ad-hoc Network (O.1)
+TSPC_PAN_1_3 True (*#) Role: PAN User (O.1)
+TSPC_PAN_1a_1 True (#) BNEP: BNEP Connection Setup (M)
+TSPC_PAN_1a_2 True (#) BNEP: BNEP Data Packet Reception (M)
+TSPC_PAN_1a_3 True (#) BNEP: BNEP Data Packet Transmission (M)
+TSPC_PAN_1a_4 True (#) BNEP: BNEP Control Message Processing (M)
+TSPC_PAN_1a_5 True (#) BNEP: BNEP Extension Header Processing (M)
+TSPC_PAN_1a_6 False BNEP: Network Protocol Filter Message
+ Transmission (O)
+TSPC_PAN_1a_7 False BNEP: Multicast Address Filter Message
+ Transmission (O)
+-------------------------------------------------------------------------------
+O.1: It is mandatory to support at least one of the defined roles.
+-------------------------------------------------------------------------------
+
+
+ Network Access Point Application Features
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_PAN_2_1 True (#) NAP: Support BNEP (M)
+TSPC_PAN_2_2 True (#) NAP: Support BNEP Forwarding (M)
+TSPC_PAN_2_3 False NAP: Support Layer 2-Bridging between PAN and
+ External Network (C.1)
+TSPC_PAN_2_4 True (*#) NAP: Support IP forwarding between PAN and
+ External Network (C.1)
+TSPC_PAN_2_5 False NAP: Support BNEP Packet Filtering (O)
+TSPC_PAN_2_6 True (*#) NAP: Support IPv4 (C.2)
+TSPC_PAN_2_6a True (*#) NAP: Supports operable routable IPv4 address (O)
+TSPC_PAN_2_6b False NAP: Support link-local address configuration
+ for IPv4 (C.4)
+TSPC_PAN_2_7 False NAP: Support ping client for IPv4 (O)
+TSPC_PAN_2_8 False NAP: Support DHCP Client for IPv4 (O)
+TSPC_PAN_2_9 False NAP: Support DNS/LLMNR Resolver for IPv4 (O)
+TSPC_PAN_2_9a True (#) NAP: Support LLMNR Sender for IPv4 (C.5)
+TSPC_PAN_2_9b False NAP: Support LLMNR Responder for IPv4 (O)
+TSPC_PAN_2_10 False NAP: Support HTTP Client for IPv4 (O)
+TSPC_PAN_2_11 False NAP: Support WAP Client for IPv4 (O)
+TSPC_PAN_2_12 False NAP: Support IPv6 (C.3)
+TSPC_PAN_2_13 False NAP: Support ping client for IPv6 (O)
+TSPC_PAN_2_14 False NAP: Support DNS/LLMNR Resolver for IPv6 (O)
+TSPC_PAN_2_14a False (*) NAP: Support LLMNR Sender for IPv6 (C.6)
+TSPC_PAN_2_14b False NAP: Support LLMNR Responder for IPv6 (O)
+TSPC_PAN_2_15 False NAP: Support HTTP Client for IPv6 (O)
+TSPC_PAN_2_16 False NAP: Support WAP Client for IPv6 (O)
+TSPC_PAN_2_17 True (#) NAP: Supports Connectable Mode (M)
+TSPC_PAN_2_18 True (#) NAP: NAP Service Record (M)
+TSPC_PAN_2_19 False NAP: Support at least three PANUs (O)
+TSPC_PAN_2_20 False NAP: Support at least two PANUs (O)
+-------------------------------------------------------------------------------
+Note that support for IP-related features only applies to the PAN interface of
+ the NAP (i.e. If the IP stack is accessible by PANUs).
+C.1: Network Access Point devices MUST support either (TSPC_PAN_2_3)
+ OR (TSPC_PAN_2_4).
+C.2: Mandatory to support IF any IPv4-based transport protocol OR
+ (TSPC_PAN_2_7-11) is supported, ELSE Optional.
+C.3: Mandatory to support IF any IPv6-based transport protocol OR
+ (TSPC_PAN_2_13-16) is supported, ELSE Optional.
+C.4: Mandatory if TSPC_PAN_2_6 is supported and TSPC_PAN_2_6a is not supported,
+ otherwise optional.
+C.5: Mandatory if item (TSPC_PAN_2_6) or item supported.
+C.6: Mandatory if item (TSPC_PAN_2_12) supported
+-------------------------------------------------------------------------------
+
+
+ Group Ad-hoc Network Application Features
+ (GN Application Features)
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_PAN_3_1 False (*) GN: Support BNEP (M)
+TSPC_PAN_3_2 False (*) GN: Support BNEP Forwarding (M)
+TSPC_PAN_3_3 False GN: Support BNEP Packet Filtering (O)
+TSPC_PAN_3_4 False GN: Support IPv4 (C.1)
+TSPC_PAN_3_5 False GN: Support ping client for IPv4 (O)
+TSPC_PAN_3_6 False GN: Support DHCP Client for IPv4 (O)
+TSPC_PAN_3_7 False GN: Support DNS/LLMNR Resolver for IPv4 (O)
+TSPC_PAN_3_7a False (*) GN: Support LLMNR Sender for IPv4 (C.3)
+TSPC_PAN_3_7b False GN: Support LLMNR Responder for IPv4 (O)
+TSPC_PAN_3_8 False GN: Support HTTP Client for IPv4 (O)
+TSPC_PAN_3_9 False GN: Support WAP Client for IPv4 (O)
+TSPC_PAN_3_10 False GN: Support IPv6 (C.2)
+TSPC_PAN_3_11 False GN: Support ping client for IPv6 (O)
+TSPC_PAN_3_12 False GN: Support DNS/LLMNR Resolver for IPv6 (O)
+TSPC_PAN_3_12a False (*) GN: Support LLMNR Sender for IPv6 (C.4)
+TSPC_PAN_3_12b False GN: Support LLMNR Responder for IPv6 (O)
+TSPC_PAN_3_13 False GN: Support HTTP Client for IPv6 (O)
+TSPC_PAN_3_14 False GN: Support WAP Client for IPv6 (O)
+TSPC_PAN_3_15 False (*) GN: Supports Connectable Mode (M)
+TSPC_PAN_3_16 False (*) GN: GN Service Record (M)
+TSPC_PAN_3_17 False GN: Support at least three PANUs (O)
+TSPC_PAN_3_18 False GN: Support at least two PANUs (O)
+-------------------------------------------------------------------------------
+C.1: Mandatory to support IF any IPv4-based transport protocol OR
+ (TSPC_PAN_3_5-9) is supported, ELSE Optional.
+C.2: Mandatory to support IF any IPv6-based transport protocol OR
+ (TSPC_PAN_3_11-14) is supported, ELSE Optional.
+C.3: Mandatory to support IF (TSPC_PAN_3_4) is supported.
+C.4: Mandatory to support if (TSPC_PAN_3_10) is supported.
+-------------------------------------------------------------------------------
+
+
+ PAN User Application Features
+-------------------------------------------------------------------------------
+Parameter Name Selected Description
+-------------------------------------------------------------------------------
+TSPC_PAN_4_1 True (#) PANU: Support BNEP (M)
+TSPC_PAN_4_2 True (*#) PANU: Support IPv4 (C.1)
+TSPC_PAN_4_3 True (*#) PANU: Support ping client for IPv4 (O)
+TSPC_PAN_4_4 True (*#) PANU: Support DHCP client for IPv4 (O)
+TSPC_PAN_4_5 False PANU: Support DNS/LLMNR Resolver for IPv4 (O)
+TSPC_PAN_4_5a True (#) PANU: Support LLMNR Sender for IPv4 (C.2)
+TSPC_PAN_4_5b False PANU: Support LLMNR Responder for IPv4 (O)
+TSPC_PAN_4_6 False PANU: Support HTTP Client for IPv4 (O)
+TSPC_PAN_4_7 False PANU: Support WAP Client for IPv4 (O)
+TSPC_PAN_4_8 False PANU: Support IPv6 (C.1)
+TSPC_PAN_4_9 False PANU: Support ping client for IPv6 (O)
+TSPC_PAN_4_10 False PANU: Support DNS/LLMNR Resolver for IPv6 (O)
+TSPC_PAN_4_10a False (*) PANU: Support LLMNR Sender for IPv6 (C.3)
+TSPC_PAN_4_10b False PANU: Support LLMNR Responder for IPv6 (O)
+TSPC_PAN_4_11 False PANU: Support HTTP Client for IPv6 (O)
+TSPC_PAN_4_12 False PANU: Support WAP Client for IPv6 (O)
+TSPC_PAN_4_13 False PANU: Support connections to multi-user
+ NAPs/GNs (O)
+TSPC_PAN_4_14 False PANU: Supports Connectable Mode (O)
+TSPC_PAN_4_15 False PANU: PANU Service Record (O)
+TSPC_ALL False Turns on all the test cases
+-------------------------------------------------------------------------------
+C.1: PAN User devices must support at least One of items (TSPC_PAN_4_2) or
+ (TSPC_PAN_4_8).
+C.2: Mandatory to support if (TSPC_PAN_4_2) is supported.
+C.3: Mandatory to support if (TSPC_PAN_4_8) is supported.
+-------------------------------------------------------------------------------
--
1.8.4.1
^ permalink raw reply related
* [PATCHv7 14/14] android/socket: Refactor socket send_fd function
From: Andrei Emeltchenko @ 2013-11-22 8:34 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385109295-11445-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Make code cleaner and initialize local cmsg buffer to zeroes.
---
android/socket.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/android/socket.c b/android/socket.c
index dbd2012..daf4370 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -379,7 +379,7 @@ static int bt_sock_send_fd(int sock_fd, const void *buf, int len, int send_fd)
struct msghdr msg;
struct cmsghdr *cmsg;
struct iovec iv;
- char msgbuf[CMSG_SPACE(1)];
+ char cmsgbuf[CMSG_SPACE(sizeof(int))];
DBG("len %d sock_fd %d send_fd %d", len, sock_fd, send_fd);
@@ -387,13 +387,16 @@ static int bt_sock_send_fd(int sock_fd, const void *buf, int len, int send_fd)
return -1;
memset(&msg, 0, sizeof(msg));
+ memset(cmsgbuf, 0, sizeof(cmsgbuf));
+
+ msg.msg_control = cmsgbuf;
+ msg.msg_controllen = sizeof(cmsgbuf);
- msg.msg_control = msgbuf;
- msg.msg_controllen = sizeof(msgbuf);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = CMSG_LEN(sizeof(send_fd));
+
memcpy(CMSG_DATA(cmsg), &send_fd, sizeof(send_fd));
iv.iov_base = (unsigned char *) buf;
--
1.8.3.2
^ permalink raw reply related
* [PATCHv7 13/14] android/hal-sock: Print bdaddr on connect
From: Andrei Emeltchenko @ 2013-11-22 8:34 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385109295-11445-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/hal-sock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/android/hal-sock.c b/android/hal-sock.c
index bd88ad8..e02a49a 100644
--- a/android/hal-sock.c
+++ b/android/hal-sock.c
@@ -82,8 +82,8 @@ static bt_status_t sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
return BT_STATUS_PARM_INVALID;
}
- DBG("uuid %s chan %d sock %p type %d flags 0x%02x",
- btuuid2str(uuid), chan, sock, type, flags);
+ DBG("bdaddr %s uuid %s chan %d sock %p type %d flags 0x%02x",
+ bdaddr2str(bdaddr), btuuid2str(uuid), chan, sock, type, flags);
if (type != BTSOCK_RFCOMM) {
error("Socket type %u not supported", type);
--
1.8.3.2
^ permalink raw reply related
* [PATCHv7 12/14] android/socket: Support listen() with supplied chan number
From: Andrei Emeltchenko @ 2013-11-22 8:34 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385109295-11445-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
No profile is assigned in this case. There is a possibility to use
Serial Port Profile.
---
android/socket.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/android/socket.c b/android/socket.c
index 80afba5..dbd2012 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -629,10 +629,13 @@ static int handle_listen(void *buf)
DBG("");
profile = get_profile_by_uuid(cmd->uuid);
- if (!profile)
- return -1;
-
- chan = profile->channel;
+ if (!profile) {
+ if (!cmd->channel)
+ return -1;
+ else
+ chan = cmd->channel;
+ } else
+ chan = profile->channel;
DBG("rfcomm channel %d svc_name %s", chan, cmd->name);
@@ -667,7 +670,9 @@ static int handle_listen(void *buf)
return -1;
}
- rfsock->service_handle = sdp_service_register(profile, cmd->name);
+ if (profile)
+ rfsock->service_handle = sdp_service_register(profile,
+ cmd->name);
return hal_fd;
}
--
1.8.3.2
^ permalink raw reply related
* [PATCHv7 11/14] android/socket: Add SPP SDP record
From: Andrei Emeltchenko @ 2013-11-22 8:34 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385109295-11445-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/socket.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 67 insertions(+), 1 deletion(-)
diff --git a/android/socket.c b/android/socket.c
index 5af0bf6..80afba5 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -251,6 +251,70 @@ static sdp_record_t *create_pbap_record(uint8_t chan, const char *svc_name)
return record;
}
+static sdp_record_t *create_spp_record(uint8_t chan, const char *svc_name)
+{
+ const char *service_name = "Serial Port";
+ sdp_list_t *svclass_id, *apseq, *profiles, *root;
+ uuid_t root_uuid, sp_uuid, rfcomm;
+ sdp_profile_desc_t profile;
+ sdp_list_t *aproto, *proto[1];
+ sdp_data_t *channel;
+ sdp_record_t *record;
+
+ record = sdp_record_alloc();
+ if (!record)
+ return NULL;
+
+ record->handle = sdp_next_handle();
+
+ sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
+ root = sdp_list_append(NULL, &root_uuid);
+ sdp_set_browse_groups(record, root);
+
+ sdp_uuid16_create(&sp_uuid, SERIAL_PORT_SVCLASS_ID);
+ svclass_id = sdp_list_append(NULL, &sp_uuid);
+ sdp_set_service_classes(record, svclass_id);
+
+ sdp_uuid16_create(&profile.uuid, SERIAL_PORT_PROFILE_ID);
+ profile.version = 0x0100;
+ profiles = sdp_list_append(NULL, &profile);
+ sdp_set_profile_descs(record, profiles);
+
+ sdp_uuid16_create(&rfcomm, RFCOMM_UUID);
+ proto[0] = sdp_list_append(NULL, &rfcomm);
+ channel = sdp_data_alloc(SDP_UINT8, &chan);
+ proto[0] = sdp_list_append(proto[0], channel);
+ apseq = sdp_list_append(NULL, proto[0]);
+
+ aproto = sdp_list_append(NULL, apseq);
+ sdp_set_access_protos(record, aproto);
+
+ sdp_add_lang_attr(record);
+
+ if (svc_name)
+ service_name = svc_name;
+
+ sdp_set_info_attr(record, service_name, "BlueZ", "COM Port");
+
+ sdp_set_url_attr(record, "http://www.bluez.org/",
+ "http://www.bluez.org/", "http://www.bluez.org/");
+
+ sdp_set_service_id(record, sp_uuid);
+ sdp_set_service_ttl(record, 0xffff);
+ sdp_set_service_avail(record, 0xff);
+ sdp_set_record_state(record, 0x00001234);
+
+ sdp_data_free(channel);
+ sdp_list_free(proto[0], NULL);
+ sdp_list_free(apseq, NULL);
+ sdp_list_free(aproto, NULL);
+ sdp_list_free(root, NULL);
+ sdp_list_free(svclass_id, NULL);
+ sdp_list_free(profiles, NULL);
+
+ return record;
+}
+
static struct profile_info {
uint8_t uuid[16];
uint8_t channel;
@@ -285,7 +349,9 @@ static struct profile_info {
0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
},
- .channel = SPP_DEFAULT_CHANNEL
+ .channel = SPP_DEFAULT_CHANNEL,
+ .svc_hint = 0,
+ .create_record = create_spp_record
},
};
--
1.8.3.2
^ permalink raw reply related
* [PATCHv7 10/14] android/socket: Add PBAP SDP record
From: Andrei Emeltchenko @ 2013-11-22 8:34 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385109295-11445-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This adds SDP service record like shown below:
Service Name: OBEX Phonebook Access Server
Service RecHandle: 0x10002
Service Class ID List:
"Phonebook Access - PSE" (0x112f)
Protocol Descriptor List:
"RFCOMM" (0x0003)
Channel: 15
"OBEX" (0x0008)
Profile Descriptor List:
"Phonebook Access" (0x1130)
Version: 0x0100
---
android/socket.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 68 insertions(+), 1 deletion(-)
diff --git a/android/socket.c b/android/socket.c
index 36f2f2e..5af0bf6 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -186,6 +186,71 @@ static sdp_record_t *create_opp_record(uint8_t chan, const char *svc_name)
return record;
}
+static sdp_record_t *create_pbap_record(uint8_t chan, const char *svc_name)
+{
+ const char *service_name = "OBEX Phonebook Access Server";
+ sdp_list_t *svclass_id, *pfseq, *apseq, *root;
+ uuid_t root_uuid, pbap_uuid, rfcomm_uuid, obex_uuid;
+ sdp_profile_desc_t profile[1];
+ sdp_list_t *aproto, *proto[2];
+ sdp_data_t *channel;
+ uint8_t formats[] = { 0x01 };
+ uint8_t dtd = SDP_UINT8;
+ sdp_data_t *sflist;
+ sdp_record_t *record;
+
+ record = sdp_record_alloc();
+ if (!record)
+ return NULL;
+
+ record->handle = sdp_next_handle();
+
+ sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
+ root = sdp_list_append(NULL, &root_uuid);
+ sdp_set_browse_groups(record, root);
+
+ sdp_uuid16_create(&pbap_uuid, PBAP_PSE_SVCLASS_ID);
+ svclass_id = sdp_list_append(NULL, &pbap_uuid);
+ sdp_set_service_classes(record, svclass_id);
+
+ sdp_uuid16_create(&profile[0].uuid, PBAP_PROFILE_ID);
+ profile[0].version = 0x0100;
+ pfseq = sdp_list_append(NULL, profile);
+ sdp_set_profile_descs(record, pfseq);
+
+ sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
+ proto[0] = sdp_list_append(NULL, &rfcomm_uuid);
+ channel = sdp_data_alloc(SDP_UINT8, &chan);
+ proto[0] = sdp_list_append(proto[0], channel);
+ apseq = sdp_list_append(NULL, proto[0]);
+
+ sdp_uuid16_create(&obex_uuid, OBEX_UUID);
+ proto[1] = sdp_list_append(NULL, &obex_uuid);
+ apseq = sdp_list_append(apseq, proto[1]);
+
+ aproto = sdp_list_append(NULL, apseq);
+ sdp_set_access_protos(record, aproto);
+
+ sflist = sdp_data_alloc(dtd, formats);
+ sdp_attr_add(record, SDP_ATTR_SUPPORTED_REPOSITORIES, sflist);
+
+ if (svc_name)
+ service_name = svc_name;
+
+ sdp_set_info_attr(record, service_name, NULL, NULL);
+
+ sdp_data_free(channel);
+ sdp_list_free(proto[0], NULL);
+ sdp_list_free(proto[1], NULL);
+ sdp_list_free(apseq, NULL);
+ sdp_list_free(pfseq, NULL);
+ sdp_list_free(aproto, NULL);
+ sdp_list_free(root, NULL);
+ sdp_list_free(svclass_id, NULL);
+
+ return record;
+}
+
static struct profile_info {
uint8_t uuid[16];
uint8_t channel;
@@ -198,7 +263,9 @@ static struct profile_info {
0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
},
- .channel = PBAP_DEFAULT_CHANNEL
+ .channel = PBAP_DEFAULT_CHANNEL,
+ .svc_hint = SVC_HINT_OBEX,
+ .create_record = create_pbap_record
}, {
.uuid = {
0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00,
--
1.8.3.2
^ permalink raw reply related
* [PATCHv7 09/14] android/socket: Add SPP uuid to profile table
From: Andrei Emeltchenko @ 2013-11-22 8:34 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385109295-11445-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/socket.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/android/socket.c b/android/socket.c
index fa1aa3c..36f2f2e 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -45,6 +45,7 @@
#include "utils.h"
#include "socket.h"
+#define SPP_DEFAULT_CHANNEL 3
#define OPP_DEFAULT_CHANNEL 9
#define PBAP_DEFAULT_CHANNEL 15
#define MAS_DEFAULT_CHANNEL 16
@@ -212,7 +213,13 @@ static struct profile_info {
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
},
.channel = MAS_DEFAULT_CHANNEL
- }
+ }, {
+ .uuid = {
+ 0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x10, 0x00,
+ 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
+ },
+ .channel = SPP_DEFAULT_CHANNEL
+ },
};
static uint32_t sdp_service_register(struct profile_info *profile,
--
1.8.3.2
^ permalink raw reply related
* [PATCHv7 08/14] android/socket: Add MAS uuid to profile table
From: Andrei Emeltchenko @ 2013-11-22 8:34 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385109295-11445-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/socket.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index a652a11..fa1aa3c 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -47,6 +47,7 @@
#define OPP_DEFAULT_CHANNEL 9
#define PBAP_DEFAULT_CHANNEL 15
+#define MAS_DEFAULT_CHANNEL 16
#define SVC_HINT_OBEX 0x10
@@ -205,6 +206,12 @@ static struct profile_info {
.channel = OPP_DEFAULT_CHANNEL,
.svc_hint = SVC_HINT_OBEX,
.create_record = create_opp_record
+ }, {
+ .uuid = {
+ 0x00, 0x00, 0x11, 0x32, 0x00, 0x00, 0x10, 0x00,
+ 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
+ },
+ .channel = MAS_DEFAULT_CHANNEL
}
};
--
1.8.3.2
^ permalink raw reply related
* [PATCHv7 07/14] android/socket: Add OPP SDP record
From: Andrei Emeltchenko @ 2013-11-22 8:34 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385109295-11445-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This adds SDP record for OPP shown below:
Service Name: OBEX Object Push
Service RecHandle: 0x10002
Service Class ID List:
"OBEX Object Push" (0x1105)
Protocol Descriptor List:
"RFCOMM" (0x0003)
Channel: 9
"OBEX" (0x0008)
Profile Descriptor List:
"OBEX Object Push" (0x1105)
Version: 0x0100
---
android/socket.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 76 insertions(+), 1 deletion(-)
diff --git a/android/socket.c b/android/socket.c
index 0c3964f..a652a11 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -48,6 +48,8 @@
#define OPP_DEFAULT_CHANNEL 9
#define PBAP_DEFAULT_CHANNEL 15
+#define SVC_HINT_OBEX 0x10
+
static bdaddr_t adapter_addr;
/* Simple list of RFCOMM server sockets */
@@ -111,6 +113,77 @@ static void cleanup_rfsock(struct rfcomm_sock *rfsock)
g_free(rfsock);
}
+static sdp_record_t *create_opp_record(uint8_t chan, const char *svc_name)
+{
+ const char *service_name = "OBEX Object Push";
+ sdp_list_t *svclass_id, *pfseq, *apseq, *root;
+ uuid_t root_uuid, opush_uuid, rfcomm_uuid, obex_uuid;
+ sdp_profile_desc_t profile[1];
+ sdp_list_t *aproto, *proto[2];
+ uint8_t formats[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0xff };
+ void *dtds[sizeof(formats)], *values[sizeof(formats)];
+ unsigned int i;
+ uint8_t dtd = SDP_UINT8;
+ sdp_data_t *sflist;
+ sdp_data_t *channel;
+ sdp_record_t *record;
+
+ record = sdp_record_alloc();
+ if (!record)
+ return NULL;
+
+ record->handle = sdp_next_handle();
+
+ sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
+ root = sdp_list_append(NULL, &root_uuid);
+ sdp_set_browse_groups(record, root);
+
+ sdp_uuid16_create(&opush_uuid, OBEX_OBJPUSH_SVCLASS_ID);
+ svclass_id = sdp_list_append(NULL, &opush_uuid);
+ sdp_set_service_classes(record, svclass_id);
+
+ sdp_uuid16_create(&profile[0].uuid, OBEX_OBJPUSH_PROFILE_ID);
+ profile[0].version = 0x0100;
+ pfseq = sdp_list_append(NULL, profile);
+ sdp_set_profile_descs(record, pfseq);
+
+ sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
+ proto[0] = sdp_list_append(NULL, &rfcomm_uuid);
+ channel = sdp_data_alloc(SDP_UINT8, &chan);
+ proto[0] = sdp_list_append(proto[0], channel);
+ apseq = sdp_list_append(NULL, proto[0]);
+
+ sdp_uuid16_create(&obex_uuid, OBEX_UUID);
+ proto[1] = sdp_list_append(NULL, &obex_uuid);
+ apseq = sdp_list_append(apseq, proto[1]);
+
+ aproto = sdp_list_append(NULL, apseq);
+ sdp_set_access_protos(record, aproto);
+
+ for (i = 0; i < sizeof(formats); i++) {
+ dtds[i] = &dtd;
+ values[i] = &formats[i];
+ }
+ sflist = sdp_seq_alloc(dtds, values, sizeof(formats));
+ sdp_attr_add(record, SDP_ATTR_SUPPORTED_FORMATS_LIST, sflist);
+
+ if (svc_name)
+ service_name = svc_name;
+
+ sdp_set_info_attr(record, service_name, NULL, NULL);
+
+ sdp_data_free(channel);
+ sdp_list_free(proto[0], NULL);
+ sdp_list_free(proto[1], NULL);
+ sdp_list_free(apseq, NULL);
+ sdp_list_free(pfseq, NULL);
+ sdp_list_free(aproto, NULL);
+ sdp_list_free(root, NULL);
+ sdp_list_free(svclass_id, NULL);
+
+ return record;
+}
+
static struct profile_info {
uint8_t uuid[16];
uint8_t channel;
@@ -129,7 +202,9 @@ static struct profile_info {
0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
},
- .channel = OPP_DEFAULT_CHANNEL
+ .channel = OPP_DEFAULT_CHANNEL,
+ .svc_hint = SVC_HINT_OBEX,
+ .create_record = create_opp_record
}
};
--
1.8.3.2
^ permalink raw reply related
* [PATCHv7 06/14] android/socket: Add general service create/remove function
From: Andrei Emeltchenko @ 2013-11-22 8:34 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385109295-11445-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
create_record function from profile is used to create SDP service record.
The record is removed from rfsock cleanup function.
---
android/socket.c | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/android/socket.c b/android/socket.c
index 156a424..0c3964f 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -35,7 +35,9 @@
#include "lib/sdp.h"
#include "lib/sdp_lib.h"
#include "src/sdp-client.h"
+#include "src/sdpd.h"
+#include "bluetooth.h"
#include "log.h"
#include "hal-msg.h"
#include "hal-ipc.h"
@@ -63,6 +65,7 @@ struct rfcomm_sock {
guint stack_watch;
bdaddr_t dst;
+ uint32_t service_handle;
};
static struct rfcomm_sock *create_rfsock(int sock, int *hal_fd)
@@ -102,6 +105,9 @@ static void cleanup_rfsock(struct rfcomm_sock *rfsock)
if (!g_source_remove(rfsock->stack_watch))
error("stack_watch source was not found");
+ if (rfsock->service_handle)
+ bt_adapter_remove_record(rfsock->service_handle);
+
g_free(rfsock);
}
@@ -110,7 +116,7 @@ static struct profile_info {
uint8_t channel;
uint8_t svc_hint;
BtIOSecLevel sec_level;
- sdp_record_t * (*create_record)(uint8_t chan);
+ sdp_record_t * (*create_record)(uint8_t chan, const char *svc_name);
} profiles[] = {
{
.uuid = {
@@ -127,6 +133,24 @@ static struct profile_info {
}
};
+static uint32_t sdp_service_register(struct profile_info *profile,
+ const void *svc_name)
+{
+ sdp_record_t *record;
+
+ record = profile->create_record(profile->channel, svc_name);
+ if (!record)
+ return 0;
+
+ if (bt_adapter_add_record(record, profile->svc_hint) < 0) {
+ error("Failed to register on SDP record");
+ sdp_record_free(record);
+ return 0;
+ }
+
+ return record->handle;
+}
+
static int bt_sock_send_fd(int sock_fd, const void *buf, int len, int send_fd)
{
ssize_t ret;
@@ -388,7 +412,7 @@ static int handle_listen(void *buf)
chan = profile->channel;
- DBG("rfcomm channel %d", chan);
+ DBG("rfcomm channel %d svc_name %s", chan, cmd->name);
rfsock = create_rfsock(-1, &hal_fd);
if (!rfsock)
@@ -421,6 +445,8 @@ static int handle_listen(void *buf)
return -1;
}
+ rfsock->service_handle = sdp_service_register(profile, cmd->name);
+
return hal_fd;
}
--
1.8.3.2
^ permalink raw reply related
* [PATCHv7 05/14] android/socket: Close file descriptor after sending
From: Andrei Emeltchenko @ 2013-11-22 8:34 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385109295-11445-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/socket.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index 1691749..156a424 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -604,6 +604,7 @@ void bt_sock_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len)
break;
ipc_send(sk, HAL_SERVICE_ID_SOCK, opcode, 0, NULL, fd);
+ close(fd);
return;
case HAL_OP_SOCK_CONNECT:
fd = handle_connect(buf);
@@ -611,6 +612,7 @@ void bt_sock_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len)
break;
ipc_send(sk, HAL_SERVICE_ID_SOCK, opcode, 0, NULL, fd);
+ close(fd);
return;
default:
DBG("Unhandled command, opcode 0x%x", opcode);
--
1.8.3.2
^ permalink raw reply related
* [PATCHv7 04/14] android/socket: Send connect signal to Android framework
From: Andrei Emeltchenko @ 2013-11-22 8:34 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385109295-11445-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Android framework expects connect signal to be sent when
remote device is connected.
---
android/socket.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index ab8d78b..1691749 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -424,6 +424,33 @@ static int handle_listen(void *buf)
return hal_fd;
}
+static bool sock_send_connect(struct rfcomm_sock *rfsock, bdaddr_t *bdaddr)
+{
+ struct hal_sock_connect_signal cmd;
+ int len;
+
+ DBG("");
+
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.size = sizeof(cmd);
+ bdaddr2android(bdaddr, cmd.bdaddr);
+ cmd.channel = rfsock->channel;
+ cmd.status = 0;
+
+ len = write(rfsock->fd, &cmd, sizeof(cmd));
+ if (len < 0) {
+ error("%s", strerror(errno));
+ return false;
+ }
+
+ if (len != sizeof(cmd)) {
+ error("Error sending connect signal");
+ return false;
+ }
+
+ return true;
+}
+
static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
{
struct rfcomm_sock *rfsock = user_data;
@@ -445,6 +472,9 @@ static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
rfsock->fd, rfsock->real_sock, rfsock->channel,
g_io_channel_unix_get_fd(io));
+ if (!sock_send_connect(rfsock, dst))
+ goto fail;
+
/* Handle events from Android */
cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
io_stack = g_io_channel_unix_new(rfsock->fd);
--
1.8.3.2
^ permalink raw reply related
* [PATCHv7 03/14] android/socket: Send RFCOMM channel to framework
From: Andrei Emeltchenko @ 2013-11-22 8:34 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385109295-11445-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Framework expects channel to be send.
---
android/socket.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index 37864e5..ab8d78b 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -519,6 +519,11 @@ static void sdp_search_cb(sdp_list_t *recs, int err, gpointer data)
goto fail;
}
+ if (write(rfsock->fd, &chan, sizeof(chan)) != sizeof(chan)) {
+ error("Error sending RFCOMM channel");
+ goto fail;
+ }
+
rfsock->real_sock = g_io_channel_unix_get_fd(io);
rfsock->channel = chan;
connections = g_list_append(connections, rfsock);
--
1.8.3.2
^ permalink raw reply related
* [PATCHv7 02/14] android/socket: Implement HAL connect call
From: Andrei Emeltchenko @ 2013-11-22 8:34 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385109295-11445-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
HAL connect uses similar event handlers like listen call.
---
android/socket.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index 59cba67..37864e5 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -426,6 +426,42 @@ static int handle_listen(void *buf)
static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
{
+ struct rfcomm_sock *rfsock = user_data;
+ bdaddr_t *dst = &rfsock->dst;
+ GIOChannel *io_stack;
+ char address[18];
+ guint id;
+ GIOCondition cond;
+
+ if (err) {
+ error("%s", err->message);
+ goto fail;
+ }
+
+ ba2str(dst, address);
+ DBG("Connected to %s", address);
+
+ DBG("rfsock: fd %d real_sock %d chan %u sock %d",
+ rfsock->fd, rfsock->real_sock, rfsock->channel,
+ g_io_channel_unix_get_fd(io));
+
+ /* Handle events from Android */
+ cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
+ io_stack = g_io_channel_unix_new(rfsock->fd);
+ id = g_io_add_watch(io_stack, cond, sock_stack_event_cb, rfsock);
+ g_io_channel_unref(io_stack);
+
+ rfsock->stack_watch = id;
+
+ /* Handle rfcomm events */
+ cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
+ id = g_io_add_watch(io, cond, sock_rfcomm_event_cb, rfsock);
+
+ rfsock->rfcomm_watch = id;
+
+ return;
+fail:
+ cleanup_rfsock(rfsock);
}
static void sdp_search_cb(sdp_list_t *recs, int err, gpointer data)
--
1.8.3.2
^ permalink raw reply related
* [PATCHv7 01/14] android/socket: Parse SDP response and connect
From: Andrei Emeltchenko @ 2013-11-22 8:34 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385109295-11445-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Parse SDP response, find RFCOMM channel and connect.
---
android/socket.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/android/socket.c b/android/socket.c
index 1815367..59cba67 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -424,9 +424,74 @@ static int handle_listen(void *buf)
return hal_fd;
}
+static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
+{
+}
+
static void sdp_search_cb(sdp_list_t *recs, int err, gpointer data)
{
+ struct rfcomm_sock *rfsock = data;
+ GError *gerr = NULL;
+ sdp_list_t *list;
+ GIOChannel *io;
+ int chan;
+
DBG("");
+
+ if (err < 0) {
+ error("Unable to get SDP record: %s", strerror(-err));
+ goto fail;
+ }
+
+ if (!recs || !recs->data) {
+ error("No SDP records found");
+ goto fail;
+ }
+
+ for (list = recs; list != NULL; list = list->next) {
+ sdp_record_t *rec = list->data;
+ sdp_list_t *protos;
+
+ if (sdp_get_access_protos(rec, &protos) < 0) {
+ error("Unable to get proto list");
+ goto fail;
+ }
+
+ chan = sdp_get_proto_port(protos, RFCOMM_UUID);
+
+ sdp_list_foreach(protos, (sdp_list_func_t) sdp_list_free,
+ NULL);
+ sdp_list_free(protos, NULL);
+ }
+
+ if (chan <= 0) {
+ error("Could not get RFCOMM channel %d", chan);
+ goto fail;
+ }
+
+ DBG("Got RFCOMM channel %d", chan);
+
+ io = bt_io_connect(connect_cb, rfsock, NULL, &gerr,
+ BT_IO_OPT_SOURCE_BDADDR, &adapter_addr,
+ BT_IO_OPT_DEST_BDADDR, &rfsock->dst,
+ BT_IO_OPT_CHANNEL, chan,
+ BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
+ BT_IO_OPT_INVALID);
+ if (!io) {
+ error("Failed connect: %s", gerr->message);
+ g_error_free(gerr);
+ goto fail;
+ }
+
+ rfsock->real_sock = g_io_channel_unix_get_fd(io);
+ rfsock->channel = chan;
+ connections = g_list_append(connections, rfsock);
+
+ g_io_channel_unref(io);
+
+ return;
+fail:
+ cleanup_rfsock(rfsock);
}
static int handle_connect(void *buf)
--
1.8.3.2
^ permalink raw reply related
* [PATCHv7 00/14] Socket HAL
From: Andrei Emeltchenko @ 2013-11-22 8:34 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This is initial code implementing socket HAL. OPP currently works with send/receive files. Probaly
other profiles works as well, not tested yet.
Changes:
* v7: Rebase and fixing missing unref. All needed SDP records for supported profiles are created.
Support listen() with specified channel like in bluedroid.
* v6: Use watch_id to remove source and general cleanup
* v5: Changed uuid_to_chan table to profile table keeping information about profile like: channel, create_record,
svc_hint and sec_level.
* v4: Changed name rfslot -> rfsock following Johan's comment and other cosmetic changes, fixed one bug in SDP
record, use NULL instead of 0 for sdp functions.
* v3: Fixed coding style with write/send between file descriptors.
* v2: Following Marcel comments changed way copying between file descriptors works, added SDP record
for OPP and now it is possible to send files through GUI. Merged one patch with structures with actual user.
* v1: Rebased and use static src address, hal_fd removed from structure and closed after sent to framework,
added connect calls and SDP parsing, added cleanup_rfcomm function, minor fixes.
* RFC Initial
TODO:
* Use sec_level / check what to do with Android supplied security flags.
* Use splice() (requires bionic change first)
For tracking rfcomm sockets I use structure rfslot which has following
fields:
- real_sock - real RFCOMM socket
- fd - fd to communicate with Android framework
create_rfslot sets hal_fd which is fd passed to Android framework with CMSG
Andrei Emeltchenko (14):
android/socket: Parse SDP response and connect
android/socket: Implement HAL connect call
android/socket: Send RFCOMM channel to framework
android/socket: Send connect signal to Android framework
android/socket: Close file descriptor after sending
android/socket: Add general service create/remove function
android/socket: Add OPP SDP record
android/socket: Add MAS uuid to profile table
android/socket: Add SPP uuid to profile table
android/socket: Add PBAP SDP record
android/socket: Add SPP SDP record
android/socket: Support listen() with supplied chan number
android/hal-sock: Print bdaddr on connect
android/socket: Refactor socket send_fd function
android/hal-sock.c | 4 +-
android/socket.c | 418 +++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 408 insertions(+), 14 deletions(-)
--
1.8.3.2
^ permalink raw reply
* Re: [PATCH 1/2] android/ipc: Zero initialize cmsg buffer
From: Johan Hedberg @ 2013-11-21 14:44 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1385043811-21842-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Thu, Nov 21, 2013, Andrei Emeltchenko wrote:
> This fixes valgrind warnings:
> ...
> Syscall param sendmsg(msg.msg_control) points to uninitialised byte(s)
> ...
> ---
> android/ipc.c | 1 +
> 1 file changed, 1 insertion(+)
Both patches have been applied. Thanks.
Johan
^ permalink raw reply
* Re: Bluetooth: oops in rfcomm_sock_getsockopt_old
From: Jiri Kosina @ 2013-11-21 14:29 UTC (permalink / raw)
To: Johan Hedberg; +Cc: Marcel Holtmann, Gustavo Padovan, netdev, linux-bluetooth
In-Reply-To: <20131120150214.GA2364@x220.p-661hnu-f1>
On Wed, 20 Nov 2013, Johan Hedberg wrote:
> > BUG: unable to handle kernel paging request at 000000234df5351a
> > IP: [<ffffffffa05e95b9>] rfcomm_sock_getsockopt_old+0x39/0x190 [rfcomm]
> > PGD 0
> > Oops: 0000 [#1] SMP
> > Modules linked in: rfcomm bnep cpufreq_conservative cpufreq_userspace cpufreq_powersa
> > CO_vendor_support kvm_intel snd_hda_codec_conexant kvm iwldvm mac80211 btusb bluetooth
> > d_hda_intel snd_hda_codec snd_hwdep cfg80211 thinkpad_acpi snd_seq pcspkr snd_pcm i2c_i801 lpc_ich mfd_core rfkill e1000e ehci_pci snd_timer snd_page_alloc snd_seq_device ptp pps_core wmi snd tpm_tis soundcore battery ac tpm tpm_bios acpi_cpufreq autofs4 uhci_hcd ehci_hcd i915 usbcore usb_common drm_kms_helper drm i2c_algo_bit button video edd fan processor ata_generic thermal thermal_sys
> > CPU: 0 PID: 1024 Comm: bluetoothd Not tainted 3.11.0-07976-g8d6083f #1
> > Hardware name: LENOVO 7470BN2/7470BN2, BIOS 6DET38WW (2.02 ) 12/19/2008
> > task: ffff880076c0e000 ti: ffff880036f94000 task.ti: ffff880036f94000
> > RIP: 0010:[<ffffffffa05e95b9>] [<ffffffffa05e95b9>] rfcomm_sock_getsockopt_old+0x39/0x190 [rfcomm]
> > RSP: 0018:ffff880036f95e78 EFLAGS: 00010246
> > RAX: 000000234df53512 RBX: 00007fff5ebe9e9c RCX: 00007fff5ebe9e9c
> > RDX: 00007fff5ebe9e98 RSI: 0000000000000003 RDI: ffff8800784eb480
> > RBP: ffff880036f95ec8 R08: ffff880076c1e000 R09: 00007fff5ebea148
> > R10: 00007fff5ebe9e98 R11: 0000000000000202 R12: ffff880076c1e000
> > R13: 0000000000000003 R14: 00007fff5ebe9e9c R15: 00007fff5ebe9e98
> > FS: 00007fd5d7655700(0000) GS:ffff88007c200000(0000) knlGS:0000000000000000
> > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> > CR2: 000000234df5351a CR3: 0000000037b06000 CR4: 00000000000007f0
> > Stack:
> > 0000000000000004 00007fff5ebe9e98 ffff880036f95ea8 ffffffff81582e8f
> > ffffffff8148e61b ffff8800784eb480 0000000000000012 0000000000000003
> > 00007fff5ebe9e9c 00007fff5ebe9e98 ffff880036f95f28 ffffffffa05e9763
> > Call Trace:
> > [<ffffffff81582e8f>] ? _raw_spin_unlock_bh+0x3f/0x50
> > [<ffffffff8148e61b>] ? release_sock+0x2b/0xa0
> > [<ffffffffa05e9763>] rfcomm_sock_getsockopt+0x53/0x190 [rfcomm]
> > [<ffffffff8158b737>] ? sysret_check+0x1b/0x56
> > [<ffffffff81486933>] SyS_getsockopt+0x73/0xe0
> > [<ffffffff8158b712>] system_call_fastpath+0x16/0x1b
> > Code: 04 48 89 5d d8 4c 89 6d e8 48 89 cb 4c 89 65 e0 4c 89 75 f0 41 89 f5 4c 89 7d f8 48 89 55 b8 4c 8b 67 20 49 8b 84 24 50 04 00 00 <4c> 8b 78 08 0f 85 27 01 00 00 e8 e8 83 b6 e0 48 89 d8 e8 60 40
> > RIP [<ffffffffa05e95b9>] rfcomm_sock_getsockopt_old+0x39/0x190 [rfcomm]
> > RSP <ffff880036f95e78>
> > CR2: 000000234df5351a
> > ---[ end trace d84df5c733bb1019 ]---
> >
> >
> > I have bisected this to 94a86df01. I don't immediately see how this could
> > be causing the issue directly, hence sending out this as a heads-up, and
> > will continue looking into this eventually.
> >
> > It seems to be very reliably reproducible, so I expect the bisection to be
> > correct (to be verified still).
>
> The issue is already fixed in the bluetooth and wireless trees but
> the patch hasn't yet made it to the net or Linus' tree.
Tested-by: Jiri Kosina <jkosina@suse.cz>
Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply
* [PATCH 2/2] android/haltest: Zero initialize cmsg buffer
From: Andrei Emeltchenko @ 2013-11-21 14:23 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385043811-21842-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/client/if-sock.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/android/client/if-sock.c b/android/client/if-sock.c
index 2cd06e8..eef9a76 100644
--- a/android/client/if-sock.c
+++ b/android/client/if-sock.c
@@ -130,6 +130,7 @@ static void read_accepted(int fd)
memset(&msg, 0, sizeof(msg));
memset(&iv, 0, sizeof(iv));
+ memset(cmsgbuf, 0, sizeof(cmsgbuf));
iv.iov_base = &cs;
iv.iov_len = sizeof(cs);
--
1.8.3.2
^ permalink raw reply related
* [PATCH 1/2] android/ipc: Zero initialize cmsg buffer
From: Andrei Emeltchenko @ 2013-11-21 14:23 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This fixes valgrind warnings:
...
Syscall param sendmsg(msg.msg_control) points to uninitialised byte(s)
...
---
android/ipc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/android/ipc.c b/android/ipc.c
index 2fa90bd..4044d4d 100644
--- a/android/ipc.c
+++ b/android/ipc.c
@@ -47,6 +47,7 @@ void ipc_send(int sk, uint8_t service_id, uint8_t opcode, uint16_t len,
memset(&msg, 0, sizeof(msg));
memset(&m, 0, sizeof(m));
+ memset(cmsgbuf, 0, sizeof(cmsgbuf));
m.service_id = service_id;
m.opcode = opcode;
--
1.8.3.2
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox