* [PATCH v4 4/7] android/tester: Add stack initialization of stack in setup
From: Marcin Kraglak @ 2013-12-11 10:46 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1386758797-1809-1-git-send-email-marcin.kraglak@tieto.com>
This add stack initialization and cleanup in setup/teardown.
---
android/Makefile.am | 10 +++++++--
android/android-tester.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/android/Makefile.am b/android/Makefile.am
index 5364c2e..f3e77c3 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -91,9 +91,15 @@ android_android_tester_SOURCES = emulator/btdev.h emulator/btdev.c \
src/shared/mgmt.h src/shared/mgmt.c \
src/shared/hciemu.h src/shared/hciemu.c \
src/shared/tester.h src/shared/tester.c \
- android/android-tester.c
+ android/hal-utils.h android/hal-utils.c \
+ android/client/hwmodule.c android/android-tester.c
-android_android_tester_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
+android_android_tester_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android
+
+android_android_tester_LDADD = lib/libbluetooth-internal.la \
+ android/libhal-internal.la @GLIB_LIBS@
+
+android_android_tester_LDFLAGS = -pthread
endif
diff --git a/android/android-tester.c b/android/android-tester.c
index ad7aa39..15f8c61 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -32,6 +32,9 @@
#include "src/shared/mgmt.h"
#include "src/shared/hciemu.h"
+#include <hardware/hardware.h>
+#include <hardware/bluetooth.h>
+
struct generic_data {
};
@@ -45,6 +48,7 @@ struct test_data {
enum hciemu_type hciemu_type;
const struct generic_data *test_data;
pid_t bluetoothd_pid;
+ const bt_interface_t *if_bluetooth;
};
static char exec_dir[PATH_MAX + 1];
@@ -243,12 +247,32 @@ failed:
close(fd);
}
+static bt_callbacks_t bt_callbacks = {
+ .size = sizeof(bt_callbacks),
+ .adapter_state_changed_cb = NULL,
+ .adapter_properties_cb = NULL,
+ .remote_device_properties_cb = NULL,
+ .device_found_cb = NULL,
+ .discovery_state_changed_cb = NULL,
+ .pin_request_cb = NULL,
+ .ssp_request_cb = NULL,
+ .bond_state_changed_cb = NULL,
+ .acl_state_changed_cb = NULL,
+ .thread_evt_cb = NULL,
+ .dut_mode_recv_cb = NULL,
+ .le_test_mode_cb = NULL
+};
+
static void setup(struct test_data *data)
{
+ const hw_module_t *module;
+ hw_device_t *device;
+ bt_status_t status;
int signal_fd[2];
char buf[1024];
pid_t pid;
int len;
+ int err;
if (pipe(signal_fd)) {
tester_setup_failed();
@@ -282,6 +306,33 @@ static void setup(struct test_data *data)
tester_setup_failed();
return;
}
+
+ close(signal_fd[0]);
+
+ err = hw_get_module(BT_HARDWARE_MODULE_ID, &module);
+ if (err) {
+ tester_setup_failed();
+ return;
+ }
+
+ err = module->methods->open(module, BT_HARDWARE_MODULE_ID, &device);
+ if (err) {
+ tester_setup_failed();
+ return;
+ }
+
+ data->if_bluetooth = ((bluetooth_device_t *)
+ device)->get_bluetooth_interface();
+ if (!data->if_bluetooth) {
+ tester_setup_failed();
+ return;
+ }
+
+ status = data->if_bluetooth->init(&bt_callbacks);
+ if (status != BT_STATUS_SUCCESS) {
+ data->if_bluetooth = NULL;
+ tester_setup_failed();
+ }
}
static void setup_base(const void *test_data)
@@ -297,6 +348,11 @@ static void teardown(const void *test_data)
{
struct test_data *data = tester_get_data();
+ if (data->if_bluetooth) {
+ data->if_bluetooth->cleanup();
+ data->if_bluetooth = NULL;
+ }
+
if (data->bluetoothd_pid)
waitpid(data->bluetoothd_pid, NULL, 0);
@@ -305,6 +361,7 @@ static void teardown(const void *test_data)
static void controller_setup(const void *test_data)
{
+ tester_test_passed();
}
#define test_bredrle(name, data, test_setup, test, test_teardown) \
--
1.8.3.1
^ permalink raw reply related
* [PATCH v4 3/7] android/tester: Start emulator in new process
From: Marcin Kraglak @ 2013-12-11 10:46 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1386758797-1809-1-git-send-email-marcin.kraglak@tieto.com>
This is needed because bluetooth->init call is blocking,
and we have to emulate normal behaviour of android environment.
That process will exit if it won't receive any message in 2 sec
or when bluetoothd will exit. Main tester thread will wait for
this process in teardown method.
---
android/android-tester.c | 132 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 131 insertions(+), 1 deletion(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 498da22..ad7aa39 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -15,9 +15,15 @@
*
*/
+#include <stdlib.h>
#include <unistd.h>
#include <glib.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/un.h>
+#include <libgen.h>
#include "lib/bluetooth.h"
#include "lib/mgmt.h"
@@ -29,14 +35,20 @@
struct generic_data {
};
+#define WAIT_FOR_SIGNAL_TIME 2 /* in seconds */
+#define EMULATOR_SIGNAL "emulator_started"
+
struct test_data {
struct mgmt *mgmt;
uint16_t mgmt_index;
struct hciemu *hciemu;
enum hciemu_type hciemu_type;
const struct generic_data *test_data;
+ pid_t bluetoothd_pid;
};
+static char exec_dir[PATH_MAX + 1];
+
static void read_info_callback(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
@@ -165,13 +177,129 @@ static void test_post_teardown(const void *test_data)
data->hciemu = NULL;
}
+static void bluetoothd_start(int hci_index)
+{
+ char prg_name[PATH_MAX + 1];
+ char index[8];
+ char *prg_argv[4];
+
+ snprintf(prg_name, sizeof(prg_name), "%s/%s", exec_dir, "bluetoothd");
+ snprintf(index, sizeof(index), "%d", hci_index);
+
+ prg_argv[0] = prg_name;
+ prg_argv[1] = "-i";
+ prg_argv[2] = index;
+ prg_argv[3] = NULL;
+
+ if (!tester_use_debug())
+ fclose(stderr);
+
+ execve(prg_argv[0], prg_argv, NULL);
+}
+
+static void emulator(int pipe, int hci_index)
+{
+ static const char SYSTEM_SOCKET_PATH[] = "\0android_system";
+ char buf[1024];
+ struct sockaddr_un addr;
+ struct timeval tv;
+ int fd;
+ ssize_t len;
+
+ fd = socket(PF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+ if (fd < 0)
+ goto failed;
+
+ tv.tv_sec = WAIT_FOR_SIGNAL_TIME;
+ tv.tv_usec = 0;
+ setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv));
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sun_family = AF_UNIX;
+ memcpy(addr.sun_path, SYSTEM_SOCKET_PATH, sizeof(SYSTEM_SOCKET_PATH));
+
+ if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+ perror("Failed to bind system socket");
+ goto failed;
+ }
+
+ len = write(pipe, EMULATOR_SIGNAL, sizeof(EMULATOR_SIGNAL));
+
+ if (len != sizeof(EMULATOR_SIGNAL))
+ goto failed;
+
+ memset(buf, 0, sizeof(buf));
+
+ len = read(fd, buf, sizeof(buf));
+ if (len <= 0 || (strcmp(buf, "ctl.start=bluetoothd")))
+ goto failed;
+
+ close(pipe);
+ close(fd);
+ bluetoothd_start(hci_index);
+
+failed:
+ close(pipe);
+ close(fd);
+}
+
+static void setup(struct test_data *data)
+{
+ int signal_fd[2];
+ char buf[1024];
+ pid_t pid;
+ int len;
+
+ if (pipe(signal_fd)) {
+ tester_setup_failed();
+ return;
+ }
+
+ pid = fork();
+
+ if (pid < 0) {
+ close(signal_fd[0]);
+ close(signal_fd[1]);
+ tester_setup_failed();
+ return;
+ }
+
+ if (pid == 0) {
+ if (!tester_use_debug())
+ fclose(stderr);
+
+ close(signal_fd[0]);
+ emulator(signal_fd[1], data->mgmt_index);
+ exit(0);
+ }
+
+ close(signal_fd[1]);
+ data->bluetoothd_pid = pid;
+
+ len = read(signal_fd[0], buf, sizeof(buf));
+ if (len <= 0 || (strcmp(buf, EMULATOR_SIGNAL))) {
+ close(signal_fd[0]);
+ tester_setup_failed();
+ return;
+ }
+}
+
static void setup_base(const void *test_data)
{
- tester_setup_failed();
+ struct test_data *data = tester_get_data();
+
+ setup(data);
+
+ tester_setup_complete();
}
static void teardown(const void *test_data)
{
+ struct test_data *data = tester_get_data();
+
+ if (data->bluetoothd_pid)
+ waitpid(data->bluetoothd_pid, NULL, 0);
+
tester_teardown_complete();
}
@@ -194,6 +322,8 @@ static void controller_setup(const void *test_data)
int main(int argc, char *argv[])
{
+ snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
+
tester_init(&argc, &argv);
test_bredrle("Test Init", NULL, setup_base, controller_setup, teardown);
--
1.8.3.1
^ permalink raw reply related
* [PATCH v4 2/7] android/tester: Add pre-setup and post-teardown routines
From: Marcin Kraglak @ 2013-12-11 10:46 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1386758797-1809-1-git-send-email-marcin.kraglak@tieto.com>
This will add hciemu initialization and cleanup. These functions
will be called to create hci emulator and cleanup it.
---
android/Makefile.am | 10 ++-
android/android-tester.c | 183 ++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 191 insertions(+), 2 deletions(-)
diff --git a/android/Makefile.am b/android/Makefile.am
index 0768985..5364c2e 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -85,7 +85,15 @@ android_haltest_LDFLAGS = -pthread
noinst_PROGRAMS += android/android-tester
-android_android_tester_SOURCES = android/android-tester.c
+android_android_tester_SOURCES = emulator/btdev.h emulator/btdev.c \
+ emulator/bthost.h emulator/bthost.c \
+ src/shared/util.h src/shared/util.c \
+ src/shared/mgmt.h src/shared/mgmt.c \
+ src/shared/hciemu.h src/shared/hciemu.c \
+ src/shared/tester.h src/shared/tester.c \
+ android/android-tester.c
+
+android_android_tester_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
endif
diff --git a/android/android-tester.c b/android/android-tester.c
index f5c42b0..498da22 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -15,7 +15,188 @@
*
*/
+#include <unistd.h>
+
+#include <glib.h>
+
+#include "lib/bluetooth.h"
+#include "lib/mgmt.h"
+
+#include "src/shared/tester.h"
+#include "src/shared/mgmt.h"
+#include "src/shared/hciemu.h"
+
+struct generic_data {
+};
+
+struct test_data {
+ struct mgmt *mgmt;
+ uint16_t mgmt_index;
+ struct hciemu *hciemu;
+ enum hciemu_type hciemu_type;
+ const struct generic_data *test_data;
+};
+
+static void read_info_callback(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct mgmt_rp_read_info *rp = param;
+ char addr[18];
+ uint16_t manufacturer;
+ uint32_t supported_settings, current_settings;
+
+ tester_print("Read Info callback");
+ tester_print(" Status: 0x%02x", status);
+
+ if (status || !param) {
+ tester_pre_setup_failed();
+ return;
+ }
+
+ ba2str(&rp->bdaddr, addr);
+ manufacturer = btohs(rp->manufacturer);
+ supported_settings = btohl(rp->supported_settings);
+ current_settings = btohl(rp->current_settings);
+
+ tester_print(" Address: %s", addr);
+ tester_print(" Version: 0x%02x", rp->version);
+ tester_print(" Manufacturer: 0x%04x", manufacturer);
+ tester_print(" Supported settings: 0x%08x", supported_settings);
+ tester_print(" Current settings: 0x%08x", current_settings);
+ tester_print(" Class: 0x%02x%02x%02x",
+ rp->dev_class[2], rp->dev_class[1], rp->dev_class[0]);
+ tester_print(" Name: %s", rp->name);
+ tester_print(" Short name: %s", rp->short_name);
+
+ if (strcmp(hciemu_get_address(data->hciemu), addr)) {
+ tester_pre_setup_failed();
+ return;
+ }
+
+ tester_pre_setup_complete();
+}
+
+static void index_added_callback(uint16_t index, uint16_t length,
+ const void *param, void *user_data)
+{
+ struct test_data *data = tester_get_data();
+
+ tester_print("Index Added callback");
+ tester_print(" Index: 0x%04x", index);
+
+ data->mgmt_index = index;
+
+ mgmt_send(data->mgmt, MGMT_OP_READ_INFO, data->mgmt_index, 0, NULL,
+ read_info_callback, NULL, NULL);
+}
+
+static void index_removed_callback(uint16_t index, uint16_t length,
+ const void *param, void *user_data)
+{
+ struct test_data *data = tester_get_data();
+
+ tester_print("Index Removed callback");
+ tester_print(" Index: 0x%04x", index);
+
+ if (index != data->mgmt_index)
+ return;
+
+ mgmt_unregister_index(data->mgmt, data->mgmt_index);
+
+ mgmt_unref(data->mgmt);
+ data->mgmt = NULL;
+
+ tester_post_teardown_complete();
+}
+
+static void read_index_list_callback(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ struct test_data *data = tester_get_data();
+
+ tester_print("Read Index List callback");
+ tester_print(" Status: 0x%02x", status);
+
+ if (status || !param) {
+ tester_pre_setup_failed();
+ return;
+ }
+
+ mgmt_register(data->mgmt, MGMT_EV_INDEX_ADDED, MGMT_INDEX_NONE,
+ index_added_callback, NULL, NULL);
+
+ mgmt_register(data->mgmt, MGMT_EV_INDEX_REMOVED, MGMT_INDEX_NONE,
+ index_removed_callback, NULL, NULL);
+
+ data->hciemu = hciemu_new(data->hciemu_type);
+ if (!data->hciemu) {
+ tester_warn("Failed to setup HCI emulation");
+ tester_pre_setup_failed();
+ return;
+ }
+
+ tester_print("New hciemu instance created");
+}
+
+static void test_pre_setup(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+
+ if (!tester_use_debug())
+ fclose(stderr);
+
+ data->mgmt = mgmt_new_default();
+ if (!data->mgmt) {
+ tester_warn("Failed to setup management interface");
+ tester_pre_setup_failed();
+ return;
+ }
+
+ mgmt_send(data->mgmt, MGMT_OP_READ_INDEX_LIST, MGMT_INDEX_NONE, 0,
+ NULL, read_index_list_callback, NULL, NULL);
+}
+
+static void test_post_teardown(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+
+ hciemu_unref(data->hciemu);
+ data->hciemu = NULL;
+}
+
+static void setup_base(const void *test_data)
+{
+ tester_setup_failed();
+}
+
+static void teardown(const void *test_data)
+{
+ tester_teardown_complete();
+}
+
+static void controller_setup(const void *test_data)
+{
+}
+
+#define test_bredrle(name, data, test_setup, test, test_teardown) \
+ do { \
+ struct test_data *user; \
+ user = g_malloc0(sizeof(struct test_data)); \
+ if (!user) \
+ break; \
+ user->hciemu_type = HCIEMU_TYPE_BREDRLE; \
+ user->test_data = data; \
+ tester_add_full(name, data, test_pre_setup, test_setup, \
+ test, test_teardown, test_post_teardown, \
+ 3, user, g_free); \
+ } while (0)
+
int main(int argc, char *argv[])
{
- return 0;
+ tester_init(&argc, &argv);
+
+ test_bredrle("Test Init", NULL, setup_base, controller_setup, teardown);
+
+ return tester_run();
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH v4 1/7] android/tester: Add android-tester
From: Marcin Kraglak @ 2013-12-11 10:46 UTC (permalink / raw)
To: linux-bluetooth
This commit add android-tester.c to tree and Makefile.am.
This will contain set of unit tests for testing android daemon.
---
.gitignore | 1 +
android/Makefile.am | 4 ++++
android/android-tester.c | 21 +++++++++++++++++++++
3 files changed, 26 insertions(+)
create mode 100644 android/android-tester.c
diff --git a/.gitignore b/.gitignore
index 2d3435a..c570728 100644
--- a/.gitignore
+++ b/.gitignore
@@ -107,3 +107,4 @@ unit/test-*.trs
android/system-emulator
android/bluetoothd
android/haltest
+android/android-tester
diff --git a/android/Makefile.am b/android/Makefile.am
index df04762..0768985 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -83,6 +83,10 @@ android_haltest_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android \
android_haltest_LDFLAGS = -pthread
+noinst_PROGRAMS += android/android-tester
+
+android_android_tester_SOURCES = android/android-tester.c
+
endif
EXTRA_DIST += android/Android.mk android/hal-ipc-api.txt android/README \
diff --git a/android/android-tester.c b/android/android-tester.c
new file mode 100644
index 0000000..f5c42b0
--- /dev/null
+++ b/android/android-tester.c
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+int main(int argc, char *argv[])
+{
+ return 0;
+}
--
1.8.3.1
^ permalink raw reply related
* [PATCH 9/9] android/bluetooth: Code style and whitespace cleanup
From: Szymon Janc @ 2013-12-11 10:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1386757887-29018-1-git-send-email-szymon.janc@tieto.com>
This fix some random style or whitespace damages. Also moves statics
after last type definition.
---
android/bluetooth.c | 63 ++++++++++++++++++++++++++++-------------------------
1 file changed, 33 insertions(+), 30 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index b139ff7..4bb2c92 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -52,20 +52,37 @@
/* Default to DisplayYesNo */
#define DEFAULT_IO_CAPABILITY 0x01
+
/* Default discoverable timeout 120sec as in Android */
#define DEFAULT_DISCOVERABLE_TIMEOUT 120
#define BASELEN_PROP_CHANGED (sizeof(struct hal_ev_adapter_props_changed) \
- + (sizeof(struct hal_property)))
+ + (sizeof(struct hal_property)))
static uint16_t option_index = MGMT_INDEX_NONE;
#define BASELEN_REMOTE_DEV_PROP (sizeof(struct hal_ev_remote_device_props) \
+ sizeof(struct hal_property))
-/* This list contains addresses which are asked for records */
-static GSList *browse_reqs;
-static struct mgmt *mgmt_if = NULL;
+struct device {
+ bdaddr_t bdaddr;
+ uint8_t bdaddr_type;
+
+ int bond_state;
+
+ char *name;
+ char *friendly_name;
+
+ uint32_t class;
+ int32_t rssi;
+};
+
+struct browse_req {
+ bdaddr_t bdaddr;
+ GSList *uuids;
+ int search_uuid;
+ int reconnect_attempt;
+};
static struct {
uint16_t index;
@@ -91,23 +108,6 @@ static struct {
.uuids = NULL,
};
-struct device {
- bdaddr_t bdaddr;
- uint8_t bdaddr_type;
- int bond_state;
- char *name;
- char *friendly_name;
- uint32_t class;
- int32_t rssi;
-};
-
-struct browse_req {
- bdaddr_t bdaddr;
- GSList *uuids;
- int search_uuid;
- int reconnect_attempt;
-};
-
static const uint16_t uuid_list[] = {
L2CAP_UUID,
PNP_INFO_SVCLASS_ID,
@@ -115,8 +115,12 @@ static const uint16_t uuid_list[] = {
0
};
+static struct mgmt *mgmt_if = NULL;
static GSList *devices = NULL;
+/* This list contains addresses which are asked for records */
+static GSList *browse_reqs;
+
static int bdaddr_cmp(gconstpointer a, gconstpointer b)
{
const bdaddr_t *bda = a;
@@ -349,7 +353,6 @@ static void store_link_key(const bdaddr_t *dst, const uint8_t *key,
uint8_t type, uint8_t pin_length)
{
/* TODO store link key */
-
}
static void send_bond_state_change(const bdaddr_t *addr, uint8_t status,
@@ -368,7 +371,6 @@ static void send_bond_state_change(const bdaddr_t *addr, uint8_t status,
static void set_device_bond_state(const bdaddr_t *addr, uint8_t status,
int state)
{
-
struct device *dev;
dev = find_device(addr);
@@ -570,6 +572,7 @@ static void new_link_key_callback(uint16_t index, uint16_t length,
browse_remote_sdp(&addr->bdaddr);
}
+
static void send_device_property(const bdaddr_t *bdaddr, uint8_t type,
uint16_t len, const void *val)
{
@@ -693,7 +696,8 @@ static void user_passkey_request_callback(uint16_t index, uint16_t length,
}
static void user_passkey_notify_callback(uint16_t index, uint16_t length,
- const void *param, void *user_data)
+ const void *param,
+ void *user_data)
{
const struct mgmt_ev_passkey_notify *ev = param;
char dst[18];
@@ -713,8 +717,7 @@ static void user_passkey_notify_callback(uint16_t index, uint16_t length,
set_device_bond_state(&ev->addr.bdaddr, HAL_STATUS_SUCCESS,
HAL_BOND_STATE_BONDING);
- send_ssp_request(&ev->addr.bdaddr, HAL_SSP_VARIANT_NOTIF,
- ev->passkey);
+ send_ssp_request(&ev->addr.bdaddr, HAL_SSP_VARIANT_NOTIF, ev->passkey);
}
static void mgmt_discovering_event(uint16_t index, uint16_t length,
@@ -760,7 +763,6 @@ static void confirm_device_name(const bdaddr_t *addr, uint8_t addr_type)
error("Failed to send confirm name request");
}
-
static int fill_hal_prop(void *buf, uint8_t type, uint16_t len,
const void *val)
{
@@ -813,7 +815,8 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
bdaddr2android(bdaddr, &android_bdaddr);
size += fill_hal_prop(buf + size, HAL_PROP_DEVICE_ADDR,
- sizeof(android_bdaddr), &android_bdaddr);
+ sizeof(android_bdaddr),
+ &android_bdaddr);
(*num_prop)++;
android_type = bdaddr_type2android(dev->bdaddr_type);
@@ -932,7 +935,8 @@ static void mgmt_device_connected_event(uint16_t index, uint16_t length,
}
static void mgmt_device_disconnected_event(uint16_t index, uint16_t length,
- const void *param, void *user_data)
+ const void *param,
+ void *user_data)
{
const struct mgmt_ev_device_disconnected *ev = param;
struct hal_ev_acl_state_changed hal_ev;
@@ -1699,7 +1703,6 @@ static uint8_t get_adapter_name(void)
return HAL_STATUS_SUCCESS;
}
-
static uint8_t get_adapter_class(void)
{
DBG("");
--
1.8.3.2
^ permalink raw reply related
* [PATCH 8/9] android/bluetooth: Add support for remote device type property
From: Szymon Janc @ 2013-12-11 10:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1386757887-29018-1-git-send-email-szymon.janc@tieto.com>
This makes daemon store remote device address type to be able to handle
remote device type property.
---
android/bluetooth.c | 37 ++++++++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 9 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index ffe1120..b139ff7 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -93,6 +93,7 @@ static struct {
struct device {
bdaddr_t bdaddr;
+ uint8_t bdaddr_type;
int bond_state;
char *name;
char *friendly_name;
@@ -135,7 +136,7 @@ static struct device *find_device(const bdaddr_t *bdaddr)
return NULL;
}
-static struct device *create_device(const bdaddr_t *bdaddr)
+static struct device *create_device(const bdaddr_t *bdaddr, uint8_t type)
{
struct device *dev;
char addr[18];
@@ -146,6 +147,7 @@ static struct device *create_device(const bdaddr_t *bdaddr)
dev = g_new0(struct device, 1);
bacpy(&dev->bdaddr, bdaddr);
+ dev->bdaddr_type = type;
dev->bond_state = HAL_BOND_STATE_NONE;
/* use address for name, will be change if one is present
@@ -163,7 +165,7 @@ static void free_device(struct device *dev)
g_free(dev);
}
-static struct device *get_device(const bdaddr_t *bdaddr)
+static struct device *get_device(const bdaddr_t *bdaddr, uint8_t type)
{
struct device *dev;
@@ -171,7 +173,7 @@ static struct device *get_device(const bdaddr_t *bdaddr)
if (dev)
return dev;
- return create_device(bdaddr);
+ return create_device(bdaddr, type);
}
static void send_adapter_property(uint8_t type, uint16_t len, const void *val)
@@ -369,7 +371,9 @@ static void set_device_bond_state(const bdaddr_t *addr, uint8_t status,
struct device *dev;
- dev = get_device(addr);
+ dev = find_device(addr);
+ if (!dev)
+ return;
if (dev->bond_state != state) {
dev->bond_state = state;
@@ -606,7 +610,7 @@ static void pin_code_request_callback(uint16_t index, uint16_t length,
ba2str(&ev->addr.bdaddr, dst);
- dev = get_device(&ev->addr.bdaddr);
+ dev = get_device(&ev->addr.bdaddr, BDADDR_BREDR);
/* Workaround for Android Bluetooth.apk issue: send remote
* device property */
@@ -769,6 +773,14 @@ static int fill_hal_prop(void *buf, uint8_t type, uint16_t len,
return sizeof(*prop) + len;
}
+static uint8_t bdaddr_type2android(uint8_t type)
+{
+ if (type == BDADDR_BREDR)
+ return HAL_TYPE_BREDR;
+
+ return HAL_TYPE_LE;
+}
+
static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
int8_t rssi, bool confirm,
const uint8_t *data, uint8_t data_len)
@@ -789,8 +801,9 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
if (!dev) {
struct hal_ev_device_found *ev = (void *) buf;
bdaddr_t android_bdaddr;
+ uint8_t android_type;
- dev = create_device(bdaddr);
+ dev = create_device(bdaddr, bdaddr_type);
size += sizeof(*ev);
@@ -802,6 +815,11 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
size += fill_hal_prop(buf + size, HAL_PROP_DEVICE_ADDR,
sizeof(android_bdaddr), &android_bdaddr);
(*num_prop)++;
+
+ android_type = bdaddr_type2android(dev->bdaddr_type);
+ size += fill_hal_prop(buf + size, HAL_PROP_DEVICE_TYPE,
+ sizeof(android_type), &android_type);
+ (*num_prop)++;
} else {
struct hal_ev_remote_device_props *ev = (void *) buf;
@@ -2280,11 +2298,12 @@ static uint8_t get_device_class(struct device *dev)
static uint8_t get_device_type(struct device *dev)
{
- DBG("Not implemented");
+ uint8_t type = bdaddr_type2android(dev->bdaddr_type);
- /* TODO */
+ send_device_property(&dev->bdaddr, HAL_PROP_DEVICE_TYPE,
+ sizeof(type), &type);
- return HAL_STATUS_FAILED;
+ return HAL_STATUS_SUCCESS;
}
static uint8_t get_device_service_rec(struct device *dev)
--
1.8.3.2
^ permalink raw reply related
* [PATCH 7/9] android/bluetooth: Add support for get remote device properties command
From: Szymon Janc @ 2013-12-11 10:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1386757887-29018-1-git-send-email-szymon.janc@tieto.com>
This allows to get all properties of specified remote device.
---
android/bluetooth.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 254ccb4..ffe1120 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -2338,10 +2338,34 @@ static uint8_t get_device_timestamp(struct device *dev)
static void handle_get_remote_device_props_cmd(const void *buf, uint16_t len)
{
- /* TODO */
+ const struct hal_cmd_get_remote_device_props *cmd = buf;
+ uint8_t status;
+ bdaddr_t addr;
+ GSList *l;
+
+ android2bdaddr(cmd->bdaddr, &addr);
+
+ l = g_slist_find_custom(devices, &addr, bdaddr_cmp);
+ if (!l) {
+ status = HAL_STATUS_INVALID;
+ goto failed;
+ }
+ get_device_name(l->data);
+ get_device_uuids(l->data);
+ get_device_class(l->data);
+ get_device_type(l->data);
+ get_device_service_rec(l->data);
+ get_device_friendly_name(l->data);
+ get_device_rssi(l->data);
+ get_device_version_info(l->data);
+ get_device_timestamp(l->data);
+
+ status = HAL_STATUS_SUCCESS;
+
+failed:
ipc_send_rsp(HAL_SERVICE_ID_BLUETOOTH, HAL_OP_GET_REMOTE_DEVICE_PROPS,
- HAL_STATUS_FAILED);
+ status);
}
static void handle_get_remote_device_prop_cmd(const void *buf, uint16_t len)
--
1.8.3.2
^ permalink raw reply related
* [PATCH 6/9] android/bluetooth: Add support for remote device RSSI
From: Szymon Janc @ 2013-12-11 10:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1386757887-29018-1-git-send-email-szymon.janc@tieto.com>
This allows to cache remote device RSSI and get it with get property
command.
---
android/bluetooth.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 0515468..254ccb4 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -97,6 +97,7 @@ struct device {
char *name;
char *friendly_name;
uint32_t class;
+ int32_t rssi;
};
struct browse_req {
@@ -822,6 +823,8 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
}
if (rssi) {
+ dev->rssi = rssi;
+
size += fill_hal_prop(buf + size, HAL_PROP_DEVICE_RSSI,
sizeof(rssi), &rssi);
(*num_prop)++;
@@ -2306,11 +2309,13 @@ static uint8_t get_device_friendly_name(struct device *dev)
static uint8_t get_device_rssi(struct device *dev)
{
- DBG("Not implemented");
+ if (!dev->rssi)
+ return HAL_STATUS_FAILED;
- /* TODO */
+ send_device_property(&dev->bdaddr, HAL_PROP_DEVICE_RSSI,
+ sizeof(dev->rssi), &dev->rssi);
- return HAL_STATUS_FAILED;
+ return HAL_STATUS_SUCCESS;
}
static uint8_t get_device_version_info(struct device *dev)
--
1.8.3.2
^ permalink raw reply related
* [PATCH 5/9] android/bluetooth: Add support for remote device class
From: Szymon Janc @ 2013-12-11 10:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1386757887-29018-1-git-send-email-szymon.janc@tieto.com>
This allows to cache remote device CoD and get it with get property
command.
---
android/bluetooth.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index d6cefb7..0515468 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -96,6 +96,7 @@ struct device {
int bond_state;
char *name;
char *friendly_name;
+ uint32_t class;
};
struct browse_req {
@@ -594,6 +595,7 @@ static void pin_code_request_callback(uint16_t index, uint16_t length,
{
const struct mgmt_ev_pin_code_request *ev = param;
struct hal_ev_pin_request hal_ev;
+ struct device *dev;
char dst[18];
if (length < sizeof(*ev)) {
@@ -603,19 +605,21 @@ static void pin_code_request_callback(uint16_t index, uint16_t length,
ba2str(&ev->addr.bdaddr, dst);
+ dev = get_device(&ev->addr.bdaddr);
+
/* Workaround for Android Bluetooth.apk issue: send remote
* device property */
- get_device_name(get_device(&ev->addr.bdaddr));
+ get_device_name(dev);
set_device_bond_state(&ev->addr.bdaddr, HAL_STATUS_SUCCESS,
HAL_BOND_STATE_BONDING);
DBG("%s type %u secure %u", dst, ev->addr.type, ev->secure);
- /* TODO CoD of remote devices should probably be cached
- * Name we already send in remote device prop */
+ /* Name already sent in remote device prop */
memset(&hal_ev, 0, sizeof(hal_ev));
bdaddr2android(&ev->addr.bdaddr, hal_ev.bdaddr);
+ hal_ev.class_of_dev = dev->class;
ipc_send_notif(HAL_SERVICE_ID_BLUETOOTH, HAL_EV_PIN_REQUEST,
sizeof(hal_ev), &hal_ev);
@@ -810,6 +814,8 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
}
if (eir.class) {
+ dev->class = eir.class;
+
size += fill_hal_prop(buf + size, HAL_PROP_DEVICE_CLASS,
sizeof(eir.class), &eir.class);
(*num_prop)++;
@@ -2263,11 +2269,10 @@ static uint8_t get_device_uuids(struct device *dev)
static uint8_t get_device_class(struct device *dev)
{
- DBG("Not implemented");
+ send_device_property(&dev->bdaddr, HAL_PROP_DEVICE_CLASS,
+ sizeof(dev->class), &dev->class);
- /* TODO */
-
- return HAL_STATUS_FAILED;
+ return HAL_STATUS_SUCCESS;
}
static uint8_t get_device_type(struct device *dev)
--
1.8.3.2
^ permalink raw reply related
* [PATCH 4/9] android/bluetooth: Free devices on service unregister
From: Szymon Janc @ 2013-12-11 10:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1386757887-29018-1-git-send-email-szymon.janc@tieto.com>
There is no need to keep devices list in memory if service was
unregistered.
---
android/bluetooth.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index e32ddd6..d6cefb7 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -154,6 +154,13 @@ static struct device *create_device(const bdaddr_t *bdaddr)
return dev;
}
+static void free_device(struct device *dev)
+{
+ g_free(dev->name);
+ g_free(dev->friendly_name);
+ g_free(dev);
+}
+
static struct device *get_device(const bdaddr_t *bdaddr)
{
struct device *dev;
@@ -2557,5 +2564,8 @@ void bt_bluetooth_unregister(void)
{
DBG("");
+ g_slist_free_full(devices, (GDestroyNotify) free_device);
+ devices = NULL;
+
ipc_unregister(HAL_SERVICE_ID_CORE);
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH 3/9] android/bluetooth: Add support for remote device friendly name
From: Szymon Janc @ 2013-12-11 10:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1386757887-29018-1-git-send-email-szymon.janc@tieto.com>
This allows to get and set remote device property with friendly name.
Storage support is still missing.
---
android/bluetooth.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index b6ef3e6..e32ddd6 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -95,6 +95,7 @@ struct device {
bdaddr_t bdaddr;
int bond_state;
char *name;
+ char *friendly_name;
};
struct browse_req {
@@ -2282,11 +2283,13 @@ static uint8_t get_device_service_rec(struct device *dev)
static uint8_t get_device_friendly_name(struct device *dev)
{
- DBG("Not implemented");
+ if (!dev->friendly_name)
+ return HAL_STATUS_FAILED;
- /* TODO */
+ send_device_property(&dev->bdaddr, HAL_PROP_DEVICE_FRIENDLY_NAME,
+ strlen(dev->friendly_name), dev->friendly_name);
- return HAL_STATUS_FAILED;
+ return HAL_STATUS_SUCCESS;
}
static uint8_t get_device_rssi(struct device *dev)
@@ -2377,13 +2380,20 @@ failed:
status);
}
-static uint8_t set_device_friendly_name(struct device *dev)
+static uint8_t set_device_friendly_name(struct device *dev, const uint8_t *val,
+ uint16_t len)
{
- DBG("Not implemented");
+ DBG("");
- /* TODO */
+ g_free(dev->friendly_name);
+ dev->friendly_name = g_strndup((const char *) val, len);
- return HAL_STATUS_FAILED;
+ /* TODO store friendly name */
+
+ send_device_property(&dev->bdaddr, HAL_PROP_DEVICE_FRIENDLY_NAME,
+ strlen(dev->friendly_name), dev->friendly_name);
+
+ return HAL_STATUS_SUCCESS;
}
static uint8_t set_device_version_info(struct device *dev)
@@ -2419,7 +2429,7 @@ static void handle_set_remote_device_prop_cmd(const void *buf, uint16_t len)
switch (cmd->type) {
case HAL_PROP_DEVICE_FRIENDLY_NAME:
- status = set_device_friendly_name(l->data);
+ status = set_device_friendly_name(l->data, cmd->val, cmd->len);
break;
case HAL_PROP_DEVICE_VERSION_INFO:
status = set_device_version_info(l->data);
--
1.8.3.2
^ permalink raw reply related
* [PATCH 2/9] android/bluetooth: Add support for adapter bonded devices property
From: Szymon Janc @ 2013-12-11 10:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1386757887-29018-1-git-send-email-szymon.janc@tieto.com>
This allows to get property with list of bonded devices.
---
android/bluetooth.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index 82003fd..b6ef3e6 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1729,11 +1729,26 @@ static uint8_t get_adapter_scan_mode(void)
static uint8_t get_adapter_bonded_devices(void)
{
- DBG("Not implemented");
+ uint8_t buf[sizeof(bdaddr_t) * g_slist_length(devices)];
+ int i = 0;
+ GSList *l;
- /* TODO: Add implementation */
+ DBG("");
- return HAL_STATUS_FAILED;
+ for (l = devices; l; l = g_slist_next(l)) {
+ struct device *dev = l->data;
+
+ if (dev->bond_state != HAL_BOND_STATE_BONDED)
+ continue;
+
+ bdaddr2android(&dev->bdaddr, buf + (i * sizeof(bdaddr_t)));
+ i++;
+ }
+
+ send_adapter_property(HAL_PROP_ADAPTER_BONDED_DEVICES,
+ i * sizeof(bdaddr_t), buf);
+
+ return HAL_STATUS_SUCCESS;
}
static uint8_t get_adapter_discoverable_timeout(void)
--
1.8.3.2
^ permalink raw reply related
* [PATCH 1/9] android/bluetooth: Add support for reporting adapter type property
From: Szymon Janc @ 2013-12-11 10:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This allows to get property with adapter type.
---
android/bluetooth.c | 32 +++++++++++++++++++++++++++++---
android/hal-msg.h | 4 ++++
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index e456f3c..82003fd 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1674,13 +1674,39 @@ static uint8_t get_adapter_class(void)
return HAL_STATUS_SUCCESS;
}
+static uint8_t settings2type(void)
+{
+ bool bredr, le;
+
+ bredr = adapter.current_settings & MGMT_SETTING_BREDR;
+ le = adapter.current_settings & MGMT_SETTING_LE;
+
+ if (bredr && le)
+ return HAL_TYPE_DUAL;
+
+ if (bredr && !le)
+ return HAL_TYPE_BREDR;
+
+ if (!bredr && le)
+ return HAL_TYPE_LE;
+
+ return 0;
+}
+
static uint8_t get_adapter_type(void)
{
- DBG("Not implemented");
+ uint8_t type;
- /* TODO: Add implementation */
+ DBG("");
- return HAL_STATUS_FAILED;
+ type = settings2type();
+
+ if (!type)
+ return HAL_STATUS_FAILED;
+
+ send_adapter_property(HAL_PROP_ADAPTER_TYPE, sizeof(type), &type);
+
+ return HAL_STATUS_SUCCESS;
}
static uint8_t get_adapter_service_rec(void)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 80c4a25..3be91aa 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -116,6 +116,10 @@ struct hal_cmd_get_adapter_prop {
#define HAL_ADAPTER_SCAN_MODE_CONN 0x01
#define HAL_ADAPTER_SCAN_MODE_CONN_DISC 0x02
+#define HAL_TYPE_BREDR 0x01
+#define HAL_TYPE_LE 0x02
+#define HAL_TYPE_DUAL 0x03
+
#define HAL_OP_SET_ADAPTER_PROP 0x05
struct hal_cmd_set_adapter_prop {
uint8_t type;
--
1.8.3.2
^ permalink raw reply related
* [PATCH 10/10] android/pan: Add PAN NAP sdp record fo server role
From: Ravi kumar Veeramally @ 2013-12-11 10:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1386756825-934-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Adding PAN profile NAP SDP record on profile register call and
remove on unregister call.
---
android/pan.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/android/pan.c b/android/pan.c
index 29b0a54..a6a8e27 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -44,9 +44,12 @@
#include "utils.h"
#include "bluetooth.h"
+#define SVC_HINT_CAPTURING 0x08
+
static bdaddr_t adapter_addr;
GSList *devices = NULL;
uint8_t local_role = HAL_PAN_ROLE_NONE;
+static uint32_t record_id = 0;
struct pan_device {
char iface[16];
@@ -343,6 +346,7 @@ static const struct ipc_handler cmd_handlers[] = {
bool bt_pan_register(const bdaddr_t *addr)
{
+ sdp_record_t *rec = NULL;
int err;
DBG("");
@@ -355,6 +359,21 @@ bool bt_pan_register(const bdaddr_t *addr)
return false;
}
+ rec = pan_record("bnepnap", BNEP_SVC_NAP, TRUE);
+ if (!rec) {
+ bnep_cleanup();
+ return false;
+ }
+
+ if (bt_adapter_add_record(rec, SVC_HINT_CAPTURING) < 0) {
+ error("Failed to register on PAN record");
+ sdp_record_free(rec);
+ bnep_cleanup();
+ return false;
+ }
+
+ record_id = rec->handle;
+
ipc_register(HAL_SERVICE_ID_PAN, cmd_handlers,
G_N_ELEMENTS(cmd_handlers));
@@ -373,6 +392,8 @@ void bt_pan_unregister(void)
{
DBG("");
+ bt_adapter_remove_record(record_id);
+
g_slist_foreach(devices, free_pan_devices, NULL);
devices = NULL;
bnep_cleanup();
--
1.8.3.2
^ permalink raw reply related
* [PATCH 09/10] android/pan: Free connected pan devices on profile unregister call
From: Ravi kumar Veeramally @ 2013-12-11 10:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1386756825-934-1-git-send-email-ravikumar.veeramally@linux.intel.com>
---
android/pan.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/android/pan.c b/android/pan.c
index 0783357..29b0a54 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -361,10 +361,20 @@ bool bt_pan_register(const bdaddr_t *addr)
return true;
}
+static void free_pan_devices(gpointer data, gpointer user_data)
+{
+ struct pan_device *dev = data;
+
+ bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
+ pan_device_free(dev);
+}
+
void bt_pan_unregister(void)
{
DBG("");
+ g_slist_foreach(devices, free_pan_devices, NULL);
+ devices = NULL;
bnep_cleanup();
ipc_unregister(HAL_SERVICE_ID_PAN);
--
1.8.3.2
^ permalink raw reply related
* [PATCH 08/10] android/pan: Fix minor white space
From: Ravi kumar Veeramally @ 2013-12-11 10:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1386756825-934-1-git-send-email-ravikumar.veeramally@linux.intel.com>
---
android/pan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/pan.c b/android/pan.c
index 1ed7b04..0783357 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -257,7 +257,7 @@ static void bt_pan_connect(const void *buf, uint16_t len)
devices = g_slist_append(devices, dev);
bt_pan_notify_conn_state(dev, HAL_PAN_STATE_CONNECTING);
- status = HAL_STATUS_SUCCESS;
+ status = HAL_STATUS_SUCCESS;
failed:
ipc_send_rsp(HAL_SERVICE_ID_PAN, HAL_OP_PAN_CONNECT, status);
--
1.8.3.2
^ permalink raw reply related
* [PATCH 07/10] android/pan: Fix missing cleanup calls
From: Ravi kumar Veeramally @ 2013-12-11 10:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1386756825-934-1-git-send-email-ravikumar.veeramally@linux.intel.com>
---
android/pan.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/android/pan.c b/android/pan.c
index a9557a0..1ed7b04 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -128,6 +128,8 @@ static gboolean bnep_watchdog_cb(GIOChannel *chan, GIOCondition cond,
DBG("%s disconnected", dev->iface);
+ bnep_if_down(dev->iface);
+ bnep_conndel(&dev->dst);
bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
pan_device_free(dev);
@@ -142,6 +144,7 @@ static void bnep_conn_cb(GIOChannel *chan, char *iface, int err, void *data)
if (err < 0) {
error("bnep connect req failed: %s", strerror(-err));
+ bnep_conndel(&dev->dst);
bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
pan_device_free(dev);
return;
--
1.8.3.2
^ permalink raw reply related
* [PATCH 06/10] android/pan: Remove channel unref which causing disconnection
From: Ravi kumar Veeramally @ 2013-12-11 10:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1386756825-934-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Channel unreferencing here causing calling watchdog_cb and eventually
connection is dismissed immediately. Channel is already freed
in bnep.c:free_bnep_connect().
---
android/pan.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/android/pan.c b/android/pan.c
index f74f1a7..a9557a0 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -156,8 +156,6 @@ static void bnep_conn_cb(GIOChannel *chan, char *iface, int err, void *data)
dev->watch = g_io_add_watch(chan, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
bnep_watchdog_cb, dev);
- g_io_channel_unref(dev->io);
- dev->io = NULL;
}
static void connect_cb(GIOChannel *chan, GError *err, gpointer data)
--
1.8.3.2
^ permalink raw reply related
* [PATCH 05/10] profiles/network: Move pan sdp record function bnep and make it global
From: Ravi kumar Veeramally @ 2013-12-11 10:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1386756825-934-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Moving pan sdp record function bnep, it is required in android/pan.
Even though it is not exactly related to bnep, but bnep.h|c is dbus
free files and shared with android/*.
---
profiles/network/bnep.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++
profiles/network/bnep.h | 2 +
profiles/network/server.c | 128 +--------------------------------------------
3 files changed, 132 insertions(+), 127 deletions(-)
diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
index 08037e6..bbccd87 100644
--- a/profiles/network/bnep.c
+++ b/profiles/network/bnep.c
@@ -39,6 +39,8 @@
#include <bluetooth/bluetooth.h>
#include <bluetooth/l2cap.h>
#include <bluetooth/bnep.h>
+#include <bluetooth/sdp.h>
+#include <bluetooth/sdp_lib.h>
#include <glib.h>
@@ -542,3 +544,130 @@ uint16_t bnep_setup_decode(struct bnep_setup_conn_req *req, uint16_t *dst,
return BNEP_SUCCESS;
}
+
+sdp_record_t *pan_record(const char *name, uint16_t id, gboolean security)
+{
+ sdp_list_t *svclass, *pfseq, *apseq, *root, *aproto;
+ uuid_t root_uuid, pan, l2cap, bnep;
+ sdp_profile_desc_t profile[1];
+ sdp_list_t *proto[2];
+ sdp_data_t *v, *p;
+ uint16_t psm = BNEP_PSM, version = 0x0100;
+ uint16_t security_desc = (security ? 0x0001 : 0x0000);
+ uint16_t net_access_type = 0xfffe;
+ uint32_t max_net_access_rate = 0;
+ const char *desc = "Network service";
+ sdp_record_t *record;
+
+ record = sdp_record_alloc();
+ if (!record)
+ return NULL;
+
+ record->attrlist = NULL;
+ record->pattern = NULL;
+
+ switch (id) {
+ case BNEP_SVC_NAP:
+ sdp_uuid16_create(&pan, NAP_SVCLASS_ID);
+ svclass = sdp_list_append(NULL, &pan);
+ sdp_set_service_classes(record, svclass);
+
+ sdp_uuid16_create(&profile[0].uuid, NAP_PROFILE_ID);
+ profile[0].version = 0x0100;
+ pfseq = sdp_list_append(NULL, &profile[0]);
+ sdp_set_profile_descs(record, pfseq);
+
+ sdp_set_info_attr(record, name, NULL, desc);
+
+ sdp_attr_add_new(record, SDP_ATTR_NET_ACCESS_TYPE,
+ SDP_UINT16, &net_access_type);
+ sdp_attr_add_new(record, SDP_ATTR_MAX_NET_ACCESSRATE,
+ SDP_UINT32, &max_net_access_rate);
+ break;
+ case BNEP_SVC_GN:
+ sdp_uuid16_create(&pan, GN_SVCLASS_ID);
+ svclass = sdp_list_append(NULL, &pan);
+ sdp_set_service_classes(record, svclass);
+
+ sdp_uuid16_create(&profile[0].uuid, GN_PROFILE_ID);
+ profile[0].version = 0x0100;
+ pfseq = sdp_list_append(NULL, &profile[0]);
+ sdp_set_profile_descs(record, pfseq);
+
+ sdp_set_info_attr(record, name, NULL, desc);
+ break;
+ case BNEP_SVC_PANU:
+ sdp_uuid16_create(&pan, PANU_SVCLASS_ID);
+ svclass = sdp_list_append(NULL, &pan);
+ sdp_set_service_classes(record, svclass);
+
+ sdp_uuid16_create(&profile[0].uuid, PANU_PROFILE_ID);
+ profile[0].version = 0x0100;
+ pfseq = sdp_list_append(NULL, &profile[0]);
+ sdp_set_profile_descs(record, pfseq);
+
+ sdp_set_info_attr(record, name, NULL, desc);
+ break;
+ default:
+ sdp_record_free(record);
+ return NULL;
+ }
+
+ sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
+ root = sdp_list_append(NULL, &root_uuid);
+ sdp_set_browse_groups(record, root);
+
+ sdp_uuid16_create(&l2cap, L2CAP_UUID);
+ proto[0] = sdp_list_append(NULL, &l2cap);
+ p = sdp_data_alloc(SDP_UINT16, &psm);
+ proto[0] = sdp_list_append(proto[0], p);
+ apseq = sdp_list_append(NULL, proto[0]);
+
+ sdp_uuid16_create(&bnep, BNEP_UUID);
+ proto[1] = sdp_list_append(NULL, &bnep);
+ v = sdp_data_alloc(SDP_UINT16, &version);
+ proto[1] = sdp_list_append(proto[1], v);
+
+ /* Supported protocols */
+ {
+ uint16_t ptype[] = {
+ 0x0800, /* IPv4 */
+ 0x0806, /* ARP */
+ };
+ sdp_data_t *head, *pseq;
+ int p;
+
+ for (p = 0, head = NULL; p < 2; p++) {
+ sdp_data_t *data = sdp_data_alloc(SDP_UINT16,
+ &ptype[p]);
+ if (head)
+ sdp_seq_append(head, data);
+ else
+ head = data;
+ }
+ pseq = sdp_data_alloc(SDP_SEQ16, head);
+ proto[1] = sdp_list_append(proto[1], pseq);
+ }
+
+ apseq = sdp_list_append(apseq, proto[1]);
+
+ aproto = sdp_list_append(NULL, apseq);
+ sdp_set_access_protos(record, aproto);
+
+ sdp_add_lang_attr(record);
+
+ sdp_attr_add_new(record, SDP_ATTR_SECURITY_DESC,
+ SDP_UINT16, &security_desc);
+
+ sdp_data_free(p);
+ sdp_data_free(v);
+ sdp_list_free(apseq, NULL);
+ sdp_list_free(root, NULL);
+ sdp_list_free(aproto, NULL);
+ sdp_list_free(proto[0], NULL);
+ sdp_list_free(proto[1], NULL);
+ sdp_list_free(svclass, NULL);
+ sdp_list_free(pfseq, NULL);
+
+ return record;
+}
diff --git a/profiles/network/bnep.h b/profiles/network/bnep.h
index dd22c40..4f1f812 100644
--- a/profiles/network/bnep.h
+++ b/profiles/network/bnep.h
@@ -44,3 +44,5 @@ ssize_t bnep_send_ctrl_rsp(int sk, uint8_t type, uint8_t ctrl, uint16_t resp);
uint16_t bnep_setup_chk(uint16_t dst_role, uint16_t src_role);
uint16_t bnep_setup_decode(struct bnep_setup_conn_req *req, uint16_t *dst,
uint16_t *src);
+
+sdp_record_t *pan_record(const char *name, uint16_t id, gboolean security);
diff --git a/profiles/network/server.c b/profiles/network/server.c
index 73741ec..95564c6 100644
--- a/profiles/network/server.c
+++ b/profiles/network/server.c
@@ -125,132 +125,6 @@ static struct network_server *find_server_by_uuid(GSList *list,
return NULL;
}
-static sdp_record_t *server_record_new(const char *name, uint16_t id)
-{
- sdp_list_t *svclass, *pfseq, *apseq, *root, *aproto;
- uuid_t root_uuid, pan, l2cap, bnep;
- sdp_profile_desc_t profile[1];
- sdp_list_t *proto[2];
- sdp_data_t *v, *p;
- uint16_t psm = BNEP_PSM, version = 0x0100;
- uint16_t security_desc = (security ? 0x0001 : 0x0000);
- uint16_t net_access_type = 0xfffe;
- uint32_t max_net_access_rate = 0;
- const char *desc = "Network service";
- sdp_record_t *record;
-
- record = sdp_record_alloc();
- if (!record)
- return NULL;
-
- record->attrlist = NULL;
- record->pattern = NULL;
-
- switch (id) {
- case BNEP_SVC_NAP:
- sdp_uuid16_create(&pan, NAP_SVCLASS_ID);
- svclass = sdp_list_append(NULL, &pan);
- sdp_set_service_classes(record, svclass);
-
- sdp_uuid16_create(&profile[0].uuid, NAP_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(NULL, &profile[0]);
- sdp_set_profile_descs(record, pfseq);
-
- sdp_set_info_attr(record, name, NULL, desc);
-
- sdp_attr_add_new(record, SDP_ATTR_NET_ACCESS_TYPE,
- SDP_UINT16, &net_access_type);
- sdp_attr_add_new(record, SDP_ATTR_MAX_NET_ACCESSRATE,
- SDP_UINT32, &max_net_access_rate);
- break;
- case BNEP_SVC_GN:
- sdp_uuid16_create(&pan, GN_SVCLASS_ID);
- svclass = sdp_list_append(NULL, &pan);
- sdp_set_service_classes(record, svclass);
-
- sdp_uuid16_create(&profile[0].uuid, GN_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(NULL, &profile[0]);
- sdp_set_profile_descs(record, pfseq);
-
- sdp_set_info_attr(record, name, NULL, desc);
- break;
- case BNEP_SVC_PANU:
- sdp_uuid16_create(&pan, PANU_SVCLASS_ID);
- svclass = sdp_list_append(NULL, &pan);
- sdp_set_service_classes(record, svclass);
-
- sdp_uuid16_create(&profile[0].uuid, PANU_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(NULL, &profile[0]);
- sdp_set_profile_descs(record, pfseq);
-
- sdp_set_info_attr(record, name, NULL, desc);
- break;
- default:
- sdp_record_free(record);
- return NULL;
- }
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(record, root);
-
- sdp_uuid16_create(&l2cap, L2CAP_UUID);
- proto[0] = sdp_list_append(NULL, &l2cap);
- p = sdp_data_alloc(SDP_UINT16, &psm);
- proto[0] = sdp_list_append(proto[0], p);
- apseq = sdp_list_append(NULL, proto[0]);
-
- sdp_uuid16_create(&bnep, BNEP_UUID);
- proto[1] = sdp_list_append(NULL, &bnep);
- v = sdp_data_alloc(SDP_UINT16, &version);
- proto[1] = sdp_list_append(proto[1], v);
-
- /* Supported protocols */
- {
- uint16_t ptype[] = {
- 0x0800, /* IPv4 */
- 0x0806, /* ARP */
- };
- sdp_data_t *head, *pseq;
- int p;
-
- for (p = 0, head = NULL; p < 2; p++) {
- sdp_data_t *data = sdp_data_alloc(SDP_UINT16, &ptype[p]);
- if (head)
- sdp_seq_append(head, data);
- else
- head = data;
- }
- pseq = sdp_data_alloc(SDP_SEQ16, head);
- proto[1] = sdp_list_append(proto[1], pseq);
- }
-
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(NULL, apseq);
- sdp_set_access_protos(record, aproto);
-
- sdp_add_lang_attr(record);
-
- sdp_attr_add_new(record, SDP_ATTR_SECURITY_DESC,
- SDP_UINT16, &security_desc);
-
- sdp_data_free(p);
- sdp_data_free(v);
- sdp_list_free(apseq, NULL);
- sdp_list_free(root, NULL);
- sdp_list_free(aproto, NULL);
- sdp_list_free(proto[0], NULL);
- sdp_list_free(proto[1], NULL);
- sdp_list_free(svclass, NULL);
- sdp_list_free(pfseq, NULL);
-
- return record;
-}
-
static int server_connadd(struct network_server *ns,
struct network_session *session,
uint16_t dst_role)
@@ -497,7 +371,7 @@ static uint32_t register_server_record(struct network_server *ns)
{
sdp_record_t *record;
- record = server_record_new(ns->name, ns->id);
+ record = pan_record(ns->name, ns->id, security);
if (!record) {
error("Unable to allocate new service record");
return 0;
--
1.8.3.2
^ permalink raw reply related
* [PATCH 04/10] profiles/network/server: Delete function which does nothing
From: Ravi kumar Veeramally @ 2013-12-11 10:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1386756825-934-1-git-send-email-ravikumar.veeramally@linux.intel.com>
---
profiles/network/manager.c | 2 --
profiles/network/server.c | 4 ----
profiles/network/server.h | 1 -
3 files changed, 7 deletions(-)
diff --git a/profiles/network/manager.c b/profiles/network/manager.c
index 8ac2dec..47aebcb 100644
--- a/profiles/network/manager.c
+++ b/profiles/network/manager.c
@@ -200,8 +200,6 @@ static int network_init(void)
static void network_exit(void)
{
- server_exit();
-
btd_profile_unregister(&panu_profile);
btd_profile_unregister(&gn_profile);
btd_profile_unregister(&nap_profile);
diff --git a/profiles/network/server.c b/profiles/network/server.c
index cf34932..73741ec 100644
--- a/profiles/network/server.c
+++ b/profiles/network/server.c
@@ -493,10 +493,6 @@ int server_init(gboolean secure)
return 0;
}
-void server_exit(void)
-{
-}
-
static uint32_t register_server_record(struct network_server *ns)
{
sdp_record_t *record;
diff --git a/profiles/network/server.h b/profiles/network/server.h
index 2edd342..a76e6f7 100644
--- a/profiles/network/server.h
+++ b/profiles/network/server.h
@@ -22,6 +22,5 @@
*/
int server_init(gboolean secure);
-void server_exit(void);
int server_register(struct btd_adapter *adapter, uint16_t id);
int server_unregister(struct btd_adapter *adapter, uint16_t id);
--
1.8.3.2
^ permalink raw reply related
* [PATCH 03/10] bnep: Move bnep related calls to bnep.h|c
From: Ravi kumar Veeramally @ 2013-12-11 10:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1386756825-934-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Moving bnep related calls to bnep.h|c to reduce redundancy
while using same in android/*.
---
profiles/network/bnep.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++
profiles/network/bnep.h | 5 +++-
profiles/network/server.c | 66 ----------------------------------------------
3 files changed, 71 insertions(+), 67 deletions(-)
diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
index 57dfbf9..08037e6 100644
--- a/profiles/network/bnep.c
+++ b/profiles/network/bnep.c
@@ -475,3 +475,70 @@ ssize_t bnep_send_ctrl_rsp(int sk, uint8_t type, uint8_t ctrl, uint16_t resp)
return send(sk, &rsp, sizeof(rsp), 0);
}
+
+uint16_t bnep_setup_chk(uint16_t dst, uint16_t src)
+{
+ /* Allowed PAN Profile scenarios */
+ switch (dst) {
+ case BNEP_SVC_NAP:
+ case BNEP_SVC_GN:
+ if (src == BNEP_SVC_PANU)
+ return 0;
+ return BNEP_CONN_INVALID_SRC;
+ case BNEP_SVC_PANU:
+ if (src == BNEP_SVC_PANU || src == BNEP_SVC_GN ||
+ src == BNEP_SVC_NAP)
+ return 0;
+
+ return BNEP_CONN_INVALID_SRC;
+ }
+
+ return BNEP_CONN_INVALID_DST;
+}
+
+uint16_t bnep_setup_decode(struct bnep_setup_conn_req *req, uint16_t *dst,
+ uint16_t *src)
+{
+ const uint8_t bt_base[] = { 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
+ 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB };
+ uint8_t *dest, *source;
+ uint32_t val;
+
+ dest = req->service;
+ source = req->service + req->uuid_size;
+
+ switch (req->uuid_size) {
+ case 2: /* UUID16 */
+ *dst = bt_get_be16(dest);
+ *src = bt_get_be16(source);
+ break;
+ case 16: /* UUID128 */
+ /* Check that the bytes in the UUID, except the service ID
+ * itself, are correct. The service ID is checked in
+ * bnep_setup_chk(). */
+ if (memcmp(&dest[4], bt_base, sizeof(bt_base)) != 0)
+ return BNEP_CONN_INVALID_DST;
+ if (memcmp(&source[4], bt_base, sizeof(bt_base)) != 0)
+ return BNEP_CONN_INVALID_SRC;
+
+ /* Intentional no-break */
+
+ case 4: /* UUID32 */
+ val = bt_get_be32(dest);
+ if (val > 0xffff)
+ return BNEP_CONN_INVALID_DST;
+
+ *dst = val;
+
+ val = bt_get_be32(source);
+ if (val > 0xffff)
+ return BNEP_CONN_INVALID_SRC;
+
+ *src = val;
+ break;
+ default:
+ return BNEP_CONN_INVALID_SVC;
+ }
+
+ return BNEP_SUCCESS;
+}
diff --git a/profiles/network/bnep.h b/profiles/network/bnep.h
index dea0319..dd22c40 100644
--- a/profiles/network/bnep.h
+++ b/profiles/network/bnep.h
@@ -40,4 +40,7 @@ typedef void (*bnep_connect_cb) (GIOChannel *chan, char *iface, int err,
int bnep_connect(int sk, uint16_t src, uint16_t dst, bnep_connect_cb conn_cb,
void *data);
-ssize_t bnep_send_ctrl_rsp(int sk, uint8_t type, uint8_t ctrl, uint16_t resp);
\ No newline at end of file
+ssize_t bnep_send_ctrl_rsp(int sk, uint8_t type, uint8_t ctrl, uint16_t resp);
+uint16_t bnep_setup_chk(uint16_t dst_role, uint16_t src_role);
+uint16_t bnep_setup_decode(struct bnep_setup_conn_req *req, uint16_t *dst,
+ uint16_t *src);
diff --git a/profiles/network/server.c b/profiles/network/server.c
index 296ddd8..cf34932 100644
--- a/profiles/network/server.c
+++ b/profiles/network/server.c
@@ -280,72 +280,6 @@ static int server_connadd(struct network_server *ns,
return 0;
}
-static uint16_t bnep_setup_chk(uint16_t dst_role, uint16_t src_role)
-{
- /* Allowed PAN Profile scenarios */
- switch (dst_role) {
- case BNEP_SVC_NAP:
- case BNEP_SVC_GN:
- if (src_role == BNEP_SVC_PANU)
- return 0;
- return BNEP_CONN_INVALID_SRC;
- case BNEP_SVC_PANU:
- if (src_role == BNEP_SVC_PANU ||
- src_role == BNEP_SVC_GN ||
- src_role == BNEP_SVC_NAP)
- return 0;
-
- return BNEP_CONN_INVALID_SRC;
- }
-
- return BNEP_CONN_INVALID_DST;
-}
-
-static uint16_t bnep_setup_decode(struct bnep_setup_conn_req *req,
- uint16_t *dst_role, uint16_t *src_role)
-{
- const uint8_t bt_base[] = { 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
- 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB };
- uint8_t *dest, *source;
- uint32_t val;
-
- dest = req->service;
- source = req->service + req->uuid_size;
-
- switch (req->uuid_size) {
- case 2: /* UUID16 */
- *dst_role = bt_get_be16(dest);
- *src_role = bt_get_be16(source);
- break;
- case 16: /* UUID128 */
- /* Check that the bytes in the UUID, except the service ID
- * itself, are correct. The service ID is checked in
- * bnep_setup_chk(). */
- if (memcmp(&dest[4], bt_base, sizeof(bt_base)) != 0)
- return BNEP_CONN_INVALID_DST;
- if (memcmp(&source[4], bt_base, sizeof(bt_base)) != 0)
- return BNEP_CONN_INVALID_SRC;
-
- /* Intentional no-break */
-
- case 4: /* UUID32 */
- val = bt_get_be32(dest);
- if (val > 0xffff)
- return BNEP_CONN_INVALID_DST;
- *dst_role = val;
-
- val = bt_get_be32(source);
- if (val > 0xffff)
- return BNEP_CONN_INVALID_SRC;
- *src_role = val;
- break;
- default:
- return BNEP_CONN_INVALID_SVC;
- }
-
- return BNEP_SUCCESS;
-}
-
static void session_free(void *data)
{
struct network_session *session = data;
--
1.8.3.2
^ permalink raw reply related
* [PATCH 02/10] bnep: Rename send ctrl_rsp and make it global
From: Ravi kumar Veeramally @ 2013-12-11 10:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1386756825-934-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Renaming send_bnep_ctrl_rsp to bnep_send_ctrl_rsp and moving
to bnep.h. It is required in android/*.
---
profiles/network/bnep.c | 11 +++++++++++
profiles/network/bnep.h | 2 ++
profiles/network/server.c | 13 +------------
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
index aa980a2..57dfbf9 100644
--- a/profiles/network/bnep.c
+++ b/profiles/network/bnep.c
@@ -464,3 +464,14 @@ int bnep_del_from_bridge(const char *devname, const char *bridge)
return 0;
}
+
+ssize_t bnep_send_ctrl_rsp(int sk, uint8_t type, uint8_t ctrl, uint16_t resp)
+{
+ struct bnep_control_rsp rsp;
+
+ rsp.type = type;
+ rsp.ctrl = ctrl;
+ rsp.resp = htons(resp);
+
+ return send(sk, &rsp, sizeof(rsp), 0);
+}
diff --git a/profiles/network/bnep.h b/profiles/network/bnep.h
index 1905a98..dea0319 100644
--- a/profiles/network/bnep.h
+++ b/profiles/network/bnep.h
@@ -39,3 +39,5 @@ typedef void (*bnep_connect_cb) (GIOChannel *chan, char *iface, int err,
void *data);
int bnep_connect(int sk, uint16_t src, uint16_t dst, bnep_connect_cb conn_cb,
void *data);
+
+ssize_t bnep_send_ctrl_rsp(int sk, uint8_t type, uint8_t ctrl, uint16_t resp);
\ No newline at end of file
diff --git a/profiles/network/server.c b/profiles/network/server.c
index c777cc1..296ddd8 100644
--- a/profiles/network/server.c
+++ b/profiles/network/server.c
@@ -251,17 +251,6 @@ static sdp_record_t *server_record_new(const char *name, uint16_t id)
return record;
}
-static ssize_t send_bnep_ctrl_rsp(int sk, uint16_t val)
-{
- struct bnep_control_rsp rsp;
-
- rsp.type = BNEP_CONTROL;
- rsp.ctrl = BNEP_SETUP_CONN_RSP;
- rsp.resp = htons(val);
-
- return send(sk, &rsp, sizeof(rsp), 0);
-}
-
static int server_connadd(struct network_server *ns,
struct network_session *session,
uint16_t dst_role)
@@ -462,7 +451,7 @@ static gboolean bnep_setup(GIOChannel *chan,
rsp = BNEP_SUCCESS;
reply:
- send_bnep_ctrl_rsp(sk, rsp);
+ bnep_send_ctrl_rsp(sk, BNEP_CONTROL, BNEP_SETUP_CONN_RSP, rsp);
return FALSE;
}
--
1.8.3.2
^ permalink raw reply related
* [PATCH 01/10] bnep: Rename bnep_kill_connection to bnep_conndel
From: Ravi kumar Veeramally @ 2013-12-11 10:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1386756825-934-1-git-send-email-ravikumar.veeramally@linux.intel.com>
Renaming bnep_kill_connection to bnep_conndel to maintain
consistency with bnep_connadd function name.
---
android/pan.c | 2 +-
profiles/network/bnep.c | 2 +-
profiles/network/bnep.h | 3 +--
profiles/network/connection.c | 2 +-
profiles/network/server.c | 2 +-
5 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/android/pan.c b/android/pan.c
index 6b098b2..f74f1a7 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -288,7 +288,7 @@ static void bt_pan_disconnect(const void *buf, uint16_t len)
}
bnep_if_down(dev->iface);
- bnep_kill_connection(&dst);
+ bnep_conndel(&dst);
bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
pan_device_free(dev);
diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
index 912c0c2..aa980a2 100644
--- a/profiles/network/bnep.c
+++ b/profiles/network/bnep.c
@@ -160,7 +160,7 @@ int bnep_cleanup(void)
return 0;
}
-int bnep_kill_connection(const bdaddr_t *dst)
+int bnep_conndel(const bdaddr_t *dst)
{
struct bnep_conndel_req req;
diff --git a/profiles/network/bnep.h b/profiles/network/bnep.h
index 9043e46..1905a98 100644
--- a/profiles/network/bnep.h
+++ b/profiles/network/bnep.h
@@ -28,9 +28,8 @@ uint16_t bnep_service_id(const char *svc);
const char *bnep_uuid(uint16_t id);
const char *bnep_name(uint16_t id);
-int bnep_kill_connection(const bdaddr_t *dst);
-
int bnep_connadd(int sk, uint16_t role, char *dev);
+int bnep_conndel(const bdaddr_t *dst);
int bnep_if_up(const char *devname);
int bnep_if_down(const char *devname);
int bnep_add_to_bridge(const char *devname, const char *bridge);
diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index 9aff319..fb3e1ce 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
@@ -171,7 +171,7 @@ static void connection_destroy(DBusConnection *conn, void *user_data)
if (nc->state == CONNECTED) {
bnep_if_down(nc->dev);
- bnep_kill_connection(device_get_address(nc->peer->device));
+ bnep_conndel(device_get_address(nc->peer->device));
} else if (nc->io)
cancel_connection(nc, -EIO);
}
diff --git a/profiles/network/server.c b/profiles/network/server.c
index b3aab11..c777cc1 100644
--- a/profiles/network/server.c
+++ b/profiles/network/server.c
@@ -608,7 +608,7 @@ static void server_remove_sessions(struct network_server *ns)
bnep_del_from_bridge(session->dev, ns->bridge);
bnep_if_down(session->dev);
- bnep_kill_connection(&session->dst);
+ bnep_conndel(&session->dst);
}
g_slist_free_full(ns->sessions, session_free);
--
1.8.3.2
^ permalink raw reply related
* [PATCH 00/10] Refactoring bnep code to reduce redundancy
From: Ravi kumar Veeramally @ 2013-12-11 10:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ravi kumar Veeramally
This patch set contains refactoring of bnep functionality, minor
fixes in android/pan and adding PAN profile NAP sdp record to
android.
Ravi kumar Veeramally (10):
bnep: Rename bnep_kill_connection to bnep_conndel
bnep: Rename send ctrl_rsp and make it global
bnep: Move bnep related calls to bnep.h|c
profiles/network/server: Delete function which does nothing
profiles/network: Move pan sdp record function bnep and make it global
android/pan: Remove channel unref which causing disconnection
android/pan: Fix missing cleanup calls
android/pan: Fix minor white space
android/pan: Free connected pan devices on profile unregister call
android/pan: Add PAN NAP sdp record fo server role
android/pan.c | 40 +++++++-
profiles/network/bnep.c | 209 ++++++++++++++++++++++++++++++++++++++++-
profiles/network/bnep.h | 10 +-
profiles/network/connection.c | 2 +-
profiles/network/manager.c | 2 -
profiles/network/server.c | 213 +-----------------------------------------
profiles/network/server.h | 1 -
7 files changed, 256 insertions(+), 221 deletions(-)
--
1.8.3.2
^ permalink raw reply
* [PATCH] hciemu: Print error in case hci_vhci is not loaded
From: Andrei Emeltchenko @ 2013-12-11 9:36 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Error message should indicate that module is not loaded:
Opening /dev/vhci failed: No such file or directory
---
src/shared/hciemu.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/shared/hciemu.c b/src/shared/hciemu.c
index c2b4748..9f4bfaf 100644
--- a/src/shared/hciemu.c
+++ b/src/shared/hciemu.c
@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
+#include <errno.h>
#include <sys/socket.h>
#include <glib.h>
@@ -216,6 +217,7 @@ static bool create_vhci(struct hciemu *hciemu)
fd = open("/dev/vhci", O_RDWR | O_NONBLOCK | O_CLOEXEC);
if (fd < 0) {
+ perror("Opening /dev/vhci failed");
btdev_destroy(btdev);
return false;
}
--
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