* [PATCH 09/13] plugins: Add initial code for sixaxis plugin
From: Szymon Janc @ 2013-11-25 22:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1385417752-25664-1-git-send-email-szymon.janc@gmail.com>
This plugin will be used to associate PS3 controllers.
---
Makefile.plugins | 8 ++++++++
bootstrap-configure | 1 +
configure.ac | 5 +++++
plugins/sixaxis.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 60 insertions(+)
create mode 100644 plugins/sixaxis.c
diff --git a/Makefile.plugins b/Makefile.plugins
index 7c5f71d..f5025e9 100644
--- a/Makefile.plugins
+++ b/Makefile.plugins
@@ -110,3 +110,11 @@ builtin_sources += profiles/heartrate/heartrate.c
builtin_modules += cyclingspeed
builtin_sources += profiles/cyclingspeed/cyclingspeed.c
endif
+
+if SIXAXIS
+plugin_LTLIBRARIES += plugins/sixaxis.la
+plugins_sixaxis_la_SOURCES = plugins/sixaxis.c
+plugins_sixaxis_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version \
+ -no-undefined @UDEV_LIBS@
+plugins_sixaxis_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden @UDEV_CFLAGS@
+endif
diff --git a/bootstrap-configure b/bootstrap-configure
index dc36311..c7f08ed 100755
--- a/bootstrap-configure
+++ b/bootstrap-configure
@@ -13,4 +13,5 @@ fi
--localstatedir=/var \
--enable-experimental \
--enable-android \
+ --enable-sixaxis \
--disable-datafiles $*
diff --git a/configure.ac b/configure.ac
index 949846e..ca226bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -216,6 +216,11 @@ AC_ARG_ENABLE(experimental, AC_HELP_STRING([--enable-experimental],
[enable_experimental=${enableval}])
AM_CONDITIONAL(EXPERIMENTAL, test "${enable_experimental}" = "yes")
+AC_ARG_ENABLE(sixaxis, AC_HELP_STRING([--enable-sixaxis],
+ [enable sixaxis plugin]), [enable_sixaxis=${enableval}])
+AM_CONDITIONAL(SIXAXIS, test "${enable_sixaxis}" = "yes" &&
+ test "${enable_udev}" != "no")
+
if (test "${prefix}" = "NONE"); then
dnl no prefix and no localstatedir, so default to /var
if (test "$localstatedir" = '${prefix}/var'); then
diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
new file mode 100644
index 0000000..bf66bef
--- /dev/null
+++ b/plugins/sixaxis.c
@@ -0,0 +1,46 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2009 Bastien Nocera <hadess@hadess.net>
+ * Copyright (C) 2011 Antonio Ospite <ospite@studenti.unina.it>
+ * Copyright (C) 2013 Szymon Janc <szymon.janc@gmail.com>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "plugin.h"
+#include "log.h"
+
+static int sixaxis_init(void)
+{
+ DBG("");
+
+ return 0;
+}
+
+static void sixaxis_exit(void)
+{
+ DBG("");
+}
+
+BLUETOOTH_PLUGIN_DEFINE(sixaxis, VERSION, BLUETOOTH_PLUGIN_PRIORITY_LOW,
+ sixaxis_init, sixaxis_exit)
--
1.8.4.4
^ permalink raw reply related
* [PATCH 08/13] Rename adapter_find_device to btd_adapter_find_device
From: Szymon Janc @ 2013-11-25 22:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1385417752-25664-1-git-send-email-szymon.janc@gmail.com>
Allow this symbol to be exported and usable from external plugins.
---
profiles/audio/avctp.c | 2 +-
profiles/audio/avdtp.c | 2 +-
profiles/input/device.c | 2 +-
src/adapter.c | 22 +++++++++++-----------
src/adapter.h | 2 +-
src/attrib-server.c | 2 +-
src/profile.c | 2 +-
7 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 29fe763..4de981c 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -1371,7 +1371,7 @@ static void avctp_confirm_cb(GIOChannel *chan, gpointer data)
DBG("AVCTP: incoming connect from %s", address);
- device = adapter_find_device(adapter_find(&src), &dst);
+ device = btd_adapter_find_device(adapter_find(&src), &dst);
if (!device)
return;
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 9386c44..f866b39 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -2467,7 +2467,7 @@ static void avdtp_confirm_cb(GIOChannel *chan, gpointer data)
DBG("AVDTP: incoming connect from %s", address);
- device = adapter_find_device(adapter_find(&src), &dst);
+ device = btd_adapter_find_device(adapter_find(&src), &dst);
if (!device)
goto drop;
diff --git a/profiles/input/device.c b/profiles/input/device.c
index 71fe04a..0c2089b 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -880,7 +880,7 @@ static struct input_device *find_device(const bdaddr_t *src,
struct btd_device *device;
struct btd_service *service;
- device = adapter_find_device(adapter_find(src), dst);
+ device = btd_adapter_find_device(adapter_find(src), dst);
if (device == NULL)
return NULL;
diff --git a/src/adapter.c b/src/adapter.c
index a5a9ada..ea94753 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -690,7 +690,7 @@ int adapter_set_name(struct btd_adapter *adapter, const char *name)
return set_name(adapter, name);
}
-struct btd_device *adapter_find_device(struct btd_adapter *adapter,
+struct btd_device *btd_adapter_find_device(struct btd_adapter *adapter,
const bdaddr_t *dst)
{
struct btd_device *device;
@@ -1081,7 +1081,7 @@ struct btd_device *btd_adapter_get_device(struct btd_adapter *adapter,
if (!adapter)
return NULL;
- device = adapter_find_device(adapter, addr);
+ device = btd_adapter_find_device(adapter, addr);
if (device)
return device;
@@ -4424,7 +4424,7 @@ static int adapter_authorize(struct btd_adapter *adapter, const bdaddr_t *dst,
struct btd_device *device;
static guint id = 0;
- device = adapter_find_device(adapter, dst);
+ device = btd_adapter_find_device(adapter, dst);
if (!device)
return 0;
@@ -4630,7 +4630,7 @@ int btd_adapter_pincode_reply(struct btd_adapter *adapter,
/* Since a pincode was requested, update the starting time to
* the point where the pincode is provided. */
- device = adapter_find_device(adapter, bdaddr);
+ device = btd_adapter_find_device(adapter, bdaddr);
device_bonding_restart_timer(device);
id = mgmt_reply(adapter->mgmt, MGMT_OP_PIN_CODE_REPLY,
@@ -4964,7 +4964,7 @@ static void bonding_complete(struct btd_adapter *adapter,
if (status == 0)
device = btd_adapter_get_device(adapter, bdaddr, addr_type);
else
- device = adapter_find_device(adapter, bdaddr);
+ device = btd_adapter_find_device(adapter, bdaddr);
if (device != NULL)
device_bonding_complete(device, status);
@@ -4991,7 +4991,7 @@ static void bonding_attempt_complete(struct btd_adapter *adapter,
if (status == 0)
device = btd_adapter_get_device(adapter, bdaddr, addr_type);
else
- device = adapter_find_device(adapter, bdaddr);
+ device = btd_adapter_find_device(adapter, bdaddr);
if (status == MGMT_STATUS_AUTH_FAILED && adapter->pincode_requested) {
/* On faliure, issue a bonding_retry if possible. */
@@ -5150,7 +5150,7 @@ static void dev_disconnected(struct btd_adapter *adapter,
DBG("Device %s disconnected, reason %u", dst, reason);
- device = adapter_find_device(adapter, &addr->bdaddr);
+ device = btd_adapter_find_device(adapter, &addr->bdaddr);
if (device)
adapter_remove_connection(adapter, device);
@@ -5765,7 +5765,7 @@ static void device_blocked_callback(uint16_t index, uint16_t length,
ba2str(&ev->addr.bdaddr, addr);
DBG("hci%u %s blocked", index, addr);
- device = adapter_find_device(adapter, &ev->addr.bdaddr);
+ device = btd_adapter_find_device(adapter, &ev->addr.bdaddr);
if (device)
device_block(device, TRUE);
}
@@ -5786,7 +5786,7 @@ static void device_unblocked_callback(uint16_t index, uint16_t length,
ba2str(&ev->addr.bdaddr, addr);
DBG("hci%u %s unblocked", index, addr);
- device = adapter_find_device(adapter, &ev->addr.bdaddr);
+ device = btd_adapter_find_device(adapter, &ev->addr.bdaddr);
if (device)
device_unblock(device, FALSE, TRUE);
}
@@ -5808,7 +5808,7 @@ static void connect_failed_callback(uint16_t index, uint16_t length,
DBG("hci%u %s status %u", index, addr, ev->status);
- device = adapter_find_device(adapter, &ev->addr.bdaddr);
+ device = btd_adapter_find_device(adapter, &ev->addr.bdaddr);
if (device) {
/* If the device is in a bonding process cancel any auth request
* sent to the agent before proceeding, but keep the bonding
@@ -5854,7 +5854,7 @@ static void unpaired_callback(uint16_t index, uint16_t length,
DBG("hci%u addr %s", index, addr);
- device = adapter_find_device(adapter, &ev->addr.bdaddr);
+ device = btd_adapter_find_device(adapter, &ev->addr.bdaddr);
if (!device) {
warn("No device object for unpaired device %s", addr);
return;
diff --git a/src/adapter.h b/src/adapter.h
index e982243..de5b07d 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -95,7 +95,7 @@ struct btd_device *btd_adapter_get_device(struct btd_adapter *adapter,
uint8_t addr_type);
sdp_list_t *btd_adapter_get_services(struct btd_adapter *adapter);
-struct btd_device *adapter_find_device(struct btd_adapter *adapter,
+struct btd_device *btd_adapter_find_device(struct btd_adapter *adapter,
const bdaddr_t *dst);
const char *adapter_get_path(struct btd_adapter *adapter);
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 9231b5b..a6f1066 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -1137,7 +1137,7 @@ guint attrib_channel_attach(GAttrib *attrib)
channel->server = server;
- device = adapter_find_device(server->adapter, &channel->dst);
+ device = btd_adapter_find_device(server->adapter, &channel->dst);
if (device == NULL) {
error("Device object not found for attrib server");
g_free(channel);
diff --git a/src/profile.c b/src/profile.c
index 97cb1bc..3c0d27c 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -1047,7 +1047,7 @@ static struct ext_io *create_conn(struct ext_io *server, GIOChannel *io,
GIOCondition cond;
char addr[18];
- device = adapter_find_device(server->adapter, dst);
+ device = btd_adapter_find_device(server->adapter, dst);
if (device == NULL) {
ba2str(dst, addr);
error("%s device %s not found", server->ext->name, addr);
--
1.8.4.4
^ permalink raw reply related
* [PATCH 07/13] Rename adapter_get_address to btd_adapter_get_address
From: Szymon Janc @ 2013-11-25 22:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1385417752-25664-1-git-send-email-szymon.janc@gmail.com>
Allow this symbol to be exported and usable from external plugins.
---
plugins/neard.c | 2 +-
plugins/wiimote.c | 2 +-
profiles/audio/avctp.c | 16 ++++++++++------
profiles/audio/avdtp.c | 9 ++++++---
profiles/health/hdp.c | 6 ++++--
profiles/health/hdp_util.c | 6 +++---
profiles/input/device.c | 2 +-
profiles/input/manager.c | 4 ++--
profiles/network/connection.c | 2 +-
profiles/network/server.c | 4 ++--
profiles/sap/server.c | 3 ++-
src/adapter.c | 6 +++---
src/adapter.h | 2 +-
src/attrib-server.c | 4 ++--
src/device.c | 31 ++++++++++++++++---------------
src/profile.c | 12 ++++++------
16 files changed, 61 insertions(+), 50 deletions(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index 58689e6..35fdaeb 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -227,7 +227,7 @@ static DBusMessage *create_request_oob_reply(struct btd_adapter *adapter,
uint8_t *peir = eir;
int len;
- len = eir_create_oob(adapter_get_address(adapter),
+ len = eir_create_oob(btd_adapter_get_address(adapter),
btd_adapter_get_name(adapter),
btd_adapter_get_class(adapter), hash,
randomizer, main_opts.did_vendor,
diff --git a/plugins/wiimote.c b/plugins/wiimote.c
index 6cc21ee..96a6569 100644
--- a/plugins/wiimote.c
+++ b/plugins/wiimote.c
@@ -106,7 +106,7 @@ static ssize_t wii_pincb(struct btd_adapter *adapter, struct btd_device *device,
found:
DBG("Forcing fixed pin on detected wiimote %s", addr);
- memcpy(pinbuf, adapter_get_address(adapter), 6);
+ memcpy(pinbuf, btd_adapter_get_address(adapter), 6);
return 6;
}
diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 476f61a..29fe763 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -1307,7 +1307,7 @@ static void avctp_control_confirm(struct avctp *session, GIOChannel *chan,
avctp_set_state(session, AVCTP_STATE_CONNECTING);
session->control = avctp_channel_create(session, chan, NULL);
- src = adapter_get_address(device_get_adapter(dev));
+ src = btd_adapter_get_address(device_get_adapter(dev));
dst = device_get_address(dev);
session->auth_id = btd_request_authorization(src, dst,
@@ -1422,7 +1422,7 @@ static GIOChannel *avctp_server_socket(const bdaddr_t *src, gboolean master,
int avctp_register(struct btd_adapter *adapter, gboolean master)
{
struct avctp_server *server;
- const bdaddr_t *src = adapter_get_address(adapter);
+ const bdaddr_t *src = btd_adapter_get_address(adapter);
server = g_new0(struct avctp_server, 1);
@@ -1937,6 +1937,7 @@ struct avctp *avctp_connect(struct btd_device *device)
struct avctp *session;
GError *err = NULL;
GIOChannel *io;
+ const bdaddr_t *src;
session = avctp_get_internal(device);
if (!session)
@@ -1947,9 +1948,10 @@ struct avctp *avctp_connect(struct btd_device *device)
avctp_set_state(session, AVCTP_STATE_CONNECTING);
+ src = btd_adapter_get_address(session->server->adapter);
+
io = bt_io_connect(avctp_connect_cb, session, NULL, &err,
- BT_IO_OPT_SOURCE_BDADDR,
- adapter_get_address(session->server->adapter),
+ BT_IO_OPT_SOURCE_BDADDR, src,
BT_IO_OPT_DEST_BDADDR,
device_get_address(session->device),
BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
@@ -1971,6 +1973,7 @@ struct avctp *avctp_connect(struct btd_device *device)
int avctp_connect_browsing(struct avctp *session)
{
+ const bdaddr_t *src;
GError *err = NULL;
GIOChannel *io;
@@ -1982,9 +1985,10 @@ int avctp_connect_browsing(struct avctp *session)
avctp_set_state(session, AVCTP_STATE_BROWSING_CONNECTING);
+ src = btd_adapter_get_address(session->server->adapter);
+
io = bt_io_connect(avctp_connect_browsing_cb, session, NULL, &err,
- BT_IO_OPT_SOURCE_BDADDR,
- adapter_get_address(session->server->adapter),
+ BT_IO_OPT_SOURCE_BDADDR, src,
BT_IO_OPT_DEST_BDADDR,
device_get_address(session->device),
BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index b7a7d9c..9386c44 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -2523,11 +2523,13 @@ static GIOChannel *l2cap_connect(struct avdtp *session)
{
GError *err = NULL;
GIOChannel *io;
+ const bdaddr_t *src;
+
+ src = btd_adapter_get_address(session->server->adapter);
io = bt_io_connect(avdtp_connect_cb, session,
NULL, &err,
- BT_IO_OPT_SOURCE_BDADDR,
- adapter_get_address(session->server->adapter),
+ BT_IO_OPT_SOURCE_BDADDR, src,
BT_IO_OPT_DEST_BDADDR,
device_get_address(session->device),
BT_IO_OPT_PSM, AVDTP_PSM,
@@ -3675,7 +3677,8 @@ static struct avdtp_server *avdtp_server_init(struct btd_adapter *adapter)
server = g_new0(struct avdtp_server, 1);
- server->io = avdtp_server_socket(adapter_get_address(adapter), TRUE);
+ server->io = avdtp_server_socket(btd_adapter_get_address(adapter),
+ TRUE);
if (!server->io) {
g_free(server);
return NULL;
diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c
index 86cebe6..6203fa8 100644
--- a/profiles/health/hdp.c
+++ b/profiles/health/hdp.c
@@ -1322,6 +1322,7 @@ static void release_adapter_instance(struct hdp_adapter *hdp_adapter)
static gboolean update_adapter(struct hdp_adapter *hdp_adapter)
{
GError *err = NULL;
+ const bdaddr_t *src;
if (applications == NULL) {
release_adapter_instance(hdp_adapter);
@@ -1331,8 +1332,9 @@ static gboolean update_adapter(struct hdp_adapter *hdp_adapter)
if (hdp_adapter->mi != NULL)
goto update;
- hdp_adapter->mi = mcap_create_instance(
- adapter_get_address(hdp_adapter->btd_adapter),
+ src = btd_adapter_get_address(hdp_adapter->btd_adapter);
+
+ hdp_adapter->mi = mcap_create_instance(src,
BT_IO_SEC_MEDIUM, 0, 0,
mcl_connected, mcl_reconnected,
mcl_disconnected, mcl_uncached,
diff --git a/profiles/health/hdp_util.c b/profiles/health/hdp_util.c
index 34e4671..7de87a8 100644
--- a/profiles/health/hdp_util.c
+++ b/profiles/health/hdp_util.c
@@ -853,7 +853,7 @@ gboolean hdp_get_mdep(struct hdp_device *device, struct hdp_application *app,
const bdaddr_t *dst;
uuid_t uuid;
- src = adapter_get_address(device_get_adapter(device->dev));
+ src = btd_adapter_get_address(device_get_adapter(device->dev));
dst = device_get_address(device->dev);
mdep_data = g_new0(struct get_mdep_data, 1);
@@ -1080,7 +1080,7 @@ gboolean hdp_establish_mcl(struct hdp_device *device,
const bdaddr_t *dst;
uuid_t uuid;
- src = adapter_get_address(device_get_adapter(device->dev));
+ src = btd_adapter_get_address(device_get_adapter(device->dev));
dst = device_get_address(device->dev);
conn_data = g_new0(struct conn_mcl_data, 1);
@@ -1151,7 +1151,7 @@ gboolean hdp_get_dcpsm(struct hdp_device *device, hdp_continue_dcpsm_f func,
const bdaddr_t *dst;
uuid_t uuid;
- src = adapter_get_address(device_get_adapter(device->dev));
+ src = btd_adapter_get_address(device_get_adapter(device->dev));
dst = device_get_address(device->dev);
dcpsm_data = g_new0(struct get_dcpsm_data, 1);
diff --git a/profiles/input/device.c b/profiles/input/device.c
index 6523161..71fe04a 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -812,7 +812,7 @@ static struct input_device *input_device_new(struct btd_service *service)
char name[HCI_MAX_NAME_LENGTH + 1];
idev = g_new0(struct input_device, 1);
- bacpy(&idev->src, adapter_get_address(adapter));
+ bacpy(&idev->src, btd_adapter_get_address(adapter));
bacpy(&idev->dst, device_get_address(device));
idev->service = btd_service_ref(service);
idev->device = btd_device_ref(device);
diff --git a/profiles/input/manager.c b/profiles/input/manager.c
index 689ccdd..660043e 100644
--- a/profiles/input/manager.c
+++ b/profiles/input/manager.c
@@ -46,13 +46,13 @@
static int hid_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
{
- return server_start(adapter_get_address(adapter));
+ return server_start(btd_adapter_get_address(adapter));
}
static void hid_server_remove(struct btd_profile *p,
struct btd_adapter *adapter)
{
- server_stop(adapter_get_address(adapter));
+ server_stop(btd_adapter_get_address(adapter));
}
static struct btd_profile input_profile = {
diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index 960a1fe..5966268 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
@@ -452,7 +452,7 @@ int connection_connect(struct btd_service *service)
if (nc->state != DISCONNECTED)
return -EALREADY;
- src = adapter_get_address(device_get_adapter(peer->device));
+ src = btd_adapter_get_address(device_get_adapter(peer->device));
dst = device_get_address(peer->device);
nc->io = bt_io_connect(connect_cb, nc,
diff --git a/profiles/network/server.c b/profiles/network/server.c
index 7b784e5..0050b30 100644
--- a/profiles/network/server.c
+++ b/profiles/network/server.c
@@ -765,7 +765,7 @@ static struct network_adapter *create_adapter(struct btd_adapter *adapter)
na->io = bt_io_listen(NULL, confirm_event, na,
NULL, &err,
BT_IO_OPT_SOURCE_BDADDR,
- adapter_get_address(adapter),
+ btd_adapter_get_address(adapter),
BT_IO_OPT_PSM, BNEP_PSM,
BT_IO_OPT_OMTU, BNEP_MTU,
BT_IO_OPT_IMTU, BNEP_MTU,
@@ -823,7 +823,7 @@ int server_register(struct btd_adapter *adapter, uint16_t id)
path);
done:
- bacpy(&ns->src, adapter_get_address(adapter));
+ bacpy(&ns->src, btd_adapter_get_address(adapter));
ns->id = id;
ns->na = na;
ns->record_id = 0;
diff --git a/profiles/sap/server.c b/profiles/sap/server.c
index 63314a7..119862d 100644
--- a/profiles/sap/server.c
+++ b/profiles/sap/server.c
@@ -1372,7 +1372,8 @@ int sap_server_register(struct btd_adapter *adapter)
io = bt_io_listen(NULL, connect_confirm_cb, server,
NULL, &gerr,
- BT_IO_OPT_SOURCE_BDADDR, adapter_get_address(adapter),
+ BT_IO_OPT_SOURCE_BDADDR,
+ btd_adapter_get_address(adapter),
BT_IO_OPT_CHANNEL, SAP_SERVER_CHANNEL,
BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_HIGH,
BT_IO_OPT_MASTER, TRUE,
diff --git a/src/adapter.c b/src/adapter.c
index ec15715..a5a9ada 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3991,7 +3991,7 @@ const char *adapter_get_path(struct btd_adapter *adapter)
return adapter->path;
}
-const bdaddr_t *adapter_get_address(struct btd_adapter *adapter)
+const bdaddr_t *btd_adapter_get_address(struct btd_adapter *adapter)
{
return &adapter->bdaddr;
}
@@ -5225,7 +5225,7 @@ static void store_link_key(struct btd_adapter *adapter,
char *str;
int i;
- ba2str(adapter_get_address(adapter), adapter_addr);
+ ba2str(btd_adapter_get_address(adapter), adapter_addr);
ba2str(device_get_address(device), device_addr);
snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info", adapter_addr,
@@ -5382,7 +5382,7 @@ static void new_long_term_key_callback(uint16_t index, uint16_t length,
if (ev->store_hint) {
const struct mgmt_ltk_info *key = &ev->key;
- const bdaddr_t *bdaddr = adapter_get_address(adapter);
+ const bdaddr_t *bdaddr = btd_adapter_get_address(adapter);
store_longtermkey(bdaddr, &key->addr.bdaddr,
key->addr.type, key->val, key->master,
diff --git a/src/adapter.h b/src/adapter.h
index 8a2ddae..e982243 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -99,7 +99,7 @@ struct btd_device *adapter_find_device(struct btd_adapter *adapter,
const bdaddr_t *dst);
const char *adapter_get_path(struct btd_adapter *adapter);
-const bdaddr_t *adapter_get_address(struct btd_adapter *adapter);
+const bdaddr_t *btd_adapter_get_address(struct btd_adapter *adapter);
int adapter_set_name(struct btd_adapter *adapter, const char *name);
int adapter_service_add(struct btd_adapter *adapter, sdp_record_t *rec);
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 2861a00..9231b5b 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -156,7 +156,7 @@ static int adapter_cmp_addr(gconstpointer a, gconstpointer b)
const struct gatt_server *server = a;
const bdaddr_t *bdaddr = b;
- return bacmp(adapter_get_address(server->adapter), bdaddr);
+ return bacmp(btd_adapter_get_address(server->adapter), bdaddr);
}
static int adapter_cmp(gconstpointer a, gconstpointer b)
@@ -1310,7 +1310,7 @@ int btd_adapter_gatt_server_start(struct btd_adapter *adapter)
server = g_new0(struct gatt_server, 1);
server->adapter = btd_adapter_ref(adapter);
- addr = adapter_get_address(server->adapter);
+ addr = btd_adapter_get_address(server->adapter);
/* BR/EDR socket */
server->l2cap_io = bt_io_listen(connect_event, NULL, NULL, NULL, &gerr,
diff --git a/src/device.c b/src/device.c
index 4ff8a14..4e952c5 100644
--- a/src/device.c
+++ b/src/device.c
@@ -263,7 +263,7 @@ static gboolean store_device_info_cb(gpointer user_data)
device->store_id = 0;
- ba2str(adapter_get_address(device->adapter), adapter_addr);
+ ba2str(btd_adapter_get_address(device->adapter), adapter_addr);
ba2str(&device->bdaddr, device_addr);
snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info", adapter_addr,
device_addr);
@@ -409,7 +409,7 @@ void device_store_cached_name(struct btd_device *dev, const char *name)
return;
}
- ba2str(adapter_get_address(dev->adapter), s_addr);
+ ba2str(btd_adapter_get_address(dev->adapter), s_addr);
ba2str(&dev->bdaddr, d_addr);
snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s", s_addr, d_addr);
filename[PATH_MAX] = '\0';
@@ -470,7 +470,7 @@ static void browse_request_cancel(struct browse_req *req)
struct btd_device *device = req->device;
struct btd_adapter *adapter = device->adapter;
- bt_cancel_discovery(adapter_get_address(adapter), &device->bdaddr);
+ bt_cancel_discovery(btd_adapter_get_address(adapter), &device->bdaddr);
attio_cleanup(device);
@@ -2183,7 +2183,7 @@ struct btd_device *device_create_from_storage(struct btd_adapter *adapter,
if (device == NULL)
return NULL;
- src = adapter_get_address(adapter);
+ src = btd_adapter_get_address(adapter);
ba2str(src, srcaddr);
load_info(device, srcaddr, address, key_file);
@@ -2208,7 +2208,7 @@ struct btd_device *device_create(struct btd_adapter *adapter,
return NULL;
device->bdaddr_type = bdaddr_type;
- sba = adapter_get_address(adapter);
+ sba = btd_adapter_get_address(adapter);
ba2str(sba, src);
str = load_cached_name(device, src, dst);
@@ -2231,7 +2231,7 @@ char *btd_device_get_storage_path(struct btd_device *device,
return NULL;
}
- ba2str(adapter_get_address(device->adapter), srcaddr);
+ ba2str(btd_adapter_get_address(device->adapter), srcaddr);
ba2str(&device->bdaddr, dstaddr);
if (!filename)
@@ -2342,7 +2342,7 @@ static void delete_folder_tree(const char *dirname)
static void device_remove_stored(struct btd_device *device)
{
- const bdaddr_t *src = adapter_get_address(device->adapter);
+ const bdaddr_t *src = btd_adapter_get_address(device->adapter);
uint8_t dst_type = device->bdaddr_type;
char adapter_addr[18];
char device_addr[18];
@@ -2717,7 +2717,7 @@ static void update_bredr_services(struct browse_req *req, sdp_list_t *recs)
char *data;
gsize length = 0;
- ba2str(adapter_get_address(device->adapter), srcaddr);
+ ba2str(btd_adapter_get_address(device->adapter), srcaddr);
ba2str(&device->bdaddr, dstaddr);
if (!device->temporary) {
@@ -2961,7 +2961,7 @@ static void browse_cb(sdp_list_t *recs, int err, gpointer user_data)
/* Search for mandatory uuids */
if (uuid_list[req->search_uuid]) {
sdp_uuid16_create(&uuid, uuid_list[req->search_uuid++]);
- bt_search_service(adapter_get_address(adapter),
+ bt_search_service(btd_adapter_get_address(adapter),
&device->bdaddr, &uuid,
browse_cb, user_data, NULL);
return;
@@ -2994,7 +2994,7 @@ static void store_services(struct btd_device *device)
if (prim_uuid == NULL)
return;
- ba2str(adapter_get_address(adapter), src_addr);
+ ba2str(btd_adapter_get_address(adapter), src_addr);
ba2str(&device->bdaddr, dst_addr);
snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/attributes", src_addr,
@@ -3370,7 +3370,8 @@ int device_connect_le(struct btd_device *dev)
* pairing finishes
*/
io = bt_io_connect(att_connect_cb, attcb, NULL, &gerr,
- BT_IO_OPT_SOURCE_BDADDR, adapter_get_address(adapter),
+ BT_IO_OPT_SOURCE_BDADDR,
+ btd_adapter_get_address(adapter),
BT_IO_OPT_SOURCE_TYPE, BDADDR_LE_PUBLIC,
BT_IO_OPT_DEST_BDADDR, &dev->bdaddr,
BT_IO_OPT_DEST_TYPE, dev->bdaddr_type,
@@ -3453,7 +3454,7 @@ static int device_browse_primary(struct btd_device *device, DBusMessage *msg)
device->att_io = bt_io_connect(att_connect_cb,
attcb, NULL, NULL,
BT_IO_OPT_SOURCE_BDADDR,
- adapter_get_address(adapter),
+ btd_adapter_get_address(adapter),
BT_IO_OPT_SOURCE_TYPE, BDADDR_LE_PUBLIC,
BT_IO_OPT_DEST_BDADDR, &device->bdaddr,
BT_IO_OPT_DEST_TYPE, device->bdaddr_type,
@@ -3499,8 +3500,8 @@ static int device_browse_sdp(struct btd_device *device, DBusMessage *msg)
req->device = device;
sdp_uuid16_create(&uuid, uuid_list[req->search_uuid++]);
- err = bt_search_service(adapter_get_address(adapter), &device->bdaddr,
- &uuid, browse_cb, req, NULL);
+ err = bt_search_service(btd_adapter_get_address(adapter),
+ &device->bdaddr, &uuid, browse_cb, req, NULL);
if (err < 0) {
browse_request_free(req);
return err;
@@ -4280,7 +4281,7 @@ static sdp_list_t *read_device_records(struct btd_device *device)
sdp_list_t *recs = NULL;
sdp_record_t *rec;
- ba2str(adapter_get_address(device->adapter), local);
+ ba2str(btd_adapter_get_address(device->adapter), local);
ba2str(&device->bdaddr, peer);
snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s", local, peer);
diff --git a/src/profile.c b/src/profile.c
index baadd99..97cb1bc 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -718,7 +718,7 @@ static void ext_io_destroy(gpointer p)
}
if (ext_io->resolving)
- bt_cancel_discovery(adapter_get_address(ext_io->adapter),
+ bt_cancel_discovery(btd_adapter_get_address(ext_io->adapter),
device_get_address(ext_io->device));
if (ext_io->adapter)
@@ -1257,7 +1257,7 @@ static uint32_t ext_start_servers(struct ext_profile *ext,
io = bt_io_listen(connect, confirm, l2cap, NULL, &err,
BT_IO_OPT_SOURCE_BDADDR,
- adapter_get_address(adapter),
+ btd_adapter_get_address(adapter),
BT_IO_OPT_MODE, ext->mode,
BT_IO_OPT_PSM, psm,
BT_IO_OPT_SEC_LEVEL, ext->sec_level,
@@ -1295,7 +1295,7 @@ static uint32_t ext_start_servers(struct ext_profile *ext,
io = bt_io_listen(connect, confirm, rfcomm, NULL, &err,
BT_IO_OPT_SOURCE_BDADDR,
- adapter_get_address(adapter),
+ btd_adapter_get_address(adapter),
BT_IO_OPT_CHANNEL, chan,
BT_IO_OPT_SEC_LEVEL, ext->sec_level,
BT_IO_OPT_INVALID);
@@ -1580,7 +1580,7 @@ static void record_cb(sdp_list_t *recs, int err, gpointer user_data)
goto failed;
}
- err = connect_io(conn, adapter_get_address(conn->adapter),
+ err = connect_io(conn, btd_adapter_get_address(conn->adapter),
device_get_address(conn->device));
if (err < 0) {
error("Connecting %s failed: %s", ext->name, strerror(-err));
@@ -1637,10 +1637,10 @@ static int ext_connect_dev(struct btd_service *service)
if (ext->remote_psm || ext->remote_chan) {
conn->psm = ext->remote_psm;
conn->chan = ext->remote_chan;
- err = connect_io(conn, adapter_get_address(adapter),
+ err = connect_io(conn, btd_adapter_get_address(adapter),
device_get_address(dev));
} else {
- err = resolve_service(conn, adapter_get_address(adapter),
+ err = resolve_service(conn, btd_adapter_get_address(adapter),
device_get_address(dev));
}
--
1.8.4.4
^ permalink raw reply related
* [PATCH 06/13] Rename device_get_uuids to btd_device_get_uuids
From: Szymon Janc @ 2013-11-25 22:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1385417752-25664-1-git-send-email-szymon.janc@gmail.com>
Allow this symbol to be exported and usable from external plugins.
---
src/adapter.c | 2 +-
src/device.c | 2 +-
src/device.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 9600803..ec15715 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2537,7 +2537,7 @@ static void load_devices(struct btd_adapter *adapter)
/* TODO: register services from pre-loaded list of primaries */
- list = device_get_uuids(device);
+ list = btd_device_get_uuids(device);
if (list)
device_probe_profiles(device, list);
diff --git a/src/device.c b/src/device.c
index 58f24bf..4ff8a14 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2474,7 +2474,7 @@ static gboolean record_has_uuid(const sdp_record_t *rec,
return FALSE;
}
-GSList *device_get_uuids(struct btd_device *device)
+GSList *btd_device_get_uuids(struct btd_device *device)
{
return device->uuids;
}
diff --git a/src/device.h b/src/device.h
index 44bee3e..a0d25fe 100644
--- a/src/device.h
+++ b/src/device.h
@@ -46,7 +46,7 @@ uint16_t btd_device_get_version(struct btd_device *device);
void device_remove(struct btd_device *device, gboolean remove_stored);
int device_address_cmp(gconstpointer a, gconstpointer b);
int device_bdaddr_cmp(gconstpointer a, gconstpointer b);
-GSList *device_get_uuids(struct btd_device *device);
+GSList *btd_device_get_uuids(struct btd_device *device);
void device_probe_profiles(struct btd_device *device, GSList *profiles);
const sdp_record_t *btd_device_get_record(struct btd_device *device,
const char *uuid);
--
1.8.4.4
^ permalink raw reply related
* [PATCH 05/13] Rename device_device_set_name to btd_device_device_set_name
From: Szymon Janc @ 2013-11-25 22:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1385417752-25664-1-git-send-email-szymon.janc@gmail.com>
Allow this symbol to be exported and usable from external plugins.
---
plugins/neard.c | 2 +-
src/adapter.c | 4 ++--
src/device.c | 2 +-
src/device.h | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index 073abec..58689e6 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -640,7 +640,7 @@ static void store_params(struct btd_adapter *adapter, struct btd_device *device,
if (params->name) {
device_store_cached_name(device, params->name);
- device_set_name(device, params->name);
+ btd_device_device_set_name(device, params->name);
}
/* TODO handle UUIDs? */
diff --git a/src/adapter.c b/src/adapter.c
index ccd3c43..9600803 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -4152,7 +4152,7 @@ static void update_found_devices(struct btd_adapter *adapter,
name_known = device_name_known(dev);
if (eir_data.name && (eir_data.name_complete || !name_known))
- device_set_name(dev, eir_data.name);
+ btd_device_device_set_name(dev, eir_data.name);
if (eir_data.class != 0)
device_set_class(dev, eir_data.class);
@@ -5743,7 +5743,7 @@ static void connected_callback(uint16_t index, uint16_t length,
if (eir_data.name != NULL) {
device_store_cached_name(device, eir_data.name);
- device_set_name(device, eir_data.name);
+ btd_device_device_set_name(device, eir_data.name);
}
eir_data_free(&eir_data);
diff --git a/src/device.c b/src/device.c
index e652329..58f24bf 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2241,7 +2241,7 @@ char *btd_device_get_storage_path(struct btd_device *device,
filename);
}
-void device_set_name(struct btd_device *device, const char *name)
+void btd_device_device_set_name(struct btd_device *device, const char *name)
{
if (strncmp(name, device->name, MAX_NAME_LENGTH) == 0)
return;
diff --git a/src/device.h b/src/device.h
index f7e7bdc..44bee3e 100644
--- a/src/device.h
+++ b/src/device.h
@@ -33,7 +33,7 @@ struct btd_device *device_create_from_storage(struct btd_adapter *adapter,
char *btd_device_get_storage_path(struct btd_device *device,
const char *filename);
-void device_set_name(struct btd_device *device, const char *name);
+void btd_device_device_set_name(struct btd_device *device, const char *name);
void device_store_cached_name(struct btd_device *dev, const char *name);
void device_get_name(struct btd_device *device, char *name, size_t len);
bool device_name_known(struct btd_device *device);
--
1.8.4.4
^ permalink raw reply related
* [PATCH 04/13] Rename device_set_trusted to btd_device_set_trusted
From: Szymon Janc @ 2013-11-25 22:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1385417752-25664-1-git-send-email-szymon.janc@gmail.com>
Allow this symbol to be exported and usable from external plugins.
---
src/device.c | 4 ++--
src/device.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/device.c b/src/device.c
index 59e65b9..e652329 100644
--- a/src/device.c
+++ b/src/device.c
@@ -809,7 +809,7 @@ static void set_trust(GDBusPendingPropertySet id, gboolean value, void *data)
{
struct btd_device *device = data;
- device_set_trusted(device, value);
+ btd_device_set_trusted(device, value);
g_dbus_pending_property_success(id);
}
@@ -3565,7 +3565,7 @@ void btd_device_set_temporary(struct btd_device *device, gboolean temporary)
device->temporary = temporary;
}
-void device_set_trusted(struct btd_device *device, gboolean trusted)
+void btd_device_set_trusted(struct btd_device *device, gboolean trusted)
{
if (!device)
return;
diff --git a/src/device.h b/src/device.h
index 35d2a75..f7e7bdc 100644
--- a/src/device.h
+++ b/src/device.h
@@ -70,7 +70,7 @@ gboolean device_is_bonded(struct btd_device *device);
gboolean device_is_trusted(struct btd_device *device);
void device_set_paired(struct btd_device *device, gboolean paired);
void btd_device_set_temporary(struct btd_device *device, gboolean temporary);
-void device_set_trusted(struct btd_device *device, gboolean trusted);
+void btd_device_set_trusted(struct btd_device *device, gboolean trusted);
void device_set_bonded(struct btd_device *device, gboolean bonded);
void device_set_legacy(struct btd_device *device, bool legacy);
void device_set_rssi(struct btd_device *device, int8_t rssi);
--
1.8.4.4
^ permalink raw reply related
* [PATCH 03/13] Rename device_set_temporary to btd_device_set_temporary
From: Szymon Janc @ 2013-11-25 22:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1385417752-25664-1-git-send-email-szymon.janc@gmail.com>
Allow this symbol to be exported and usable from external plugins.
---
src/adapter.c | 12 ++++++------
src/device.c | 14 +++++++-------
src/device.h | 2 +-
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 8a6dadf..ccd3c43 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1012,7 +1012,7 @@ static struct btd_device *adapter_create_device(struct btd_adapter *adapter,
if (!device)
return NULL;
- device_set_temporary(device, TRUE);
+ btd_device_set_temporary(device, TRUE);
adapter->devices = g_slist_append(adapter->devices, device);
@@ -2156,7 +2156,7 @@ static DBusMessage *remove_device(DBusConnection *conn,
device = list->data;
- device_set_temporary(device, TRUE);
+ btd_device_set_temporary(device, TRUE);
if (!device_is_connected(device)) {
adapter_remove_device(adapter, device);
@@ -2532,7 +2532,7 @@ static void load_devices(struct btd_adapter *adapter)
if (!device)
goto free;
- device_set_temporary(device, FALSE);
+ btd_device_set_temporary(device, FALSE);
adapter->devices = g_slist_append(adapter->devices, device);
/* TODO: register services from pre-loaded list of primaries */
@@ -5294,7 +5294,7 @@ static void new_link_key_callback(uint16_t index, uint16_t length,
device_set_bonded(device, TRUE);
if (device_is_temporary(device))
- device_set_temporary(device, FALSE);
+ btd_device_set_temporary(device, FALSE);
}
bonding_complete(adapter, &addr->bdaddr, addr->type, 0);
@@ -5392,7 +5392,7 @@ static void new_long_term_key_callback(uint16_t index, uint16_t length,
device_set_bonded(device, TRUE);
if (device_is_temporary(device))
- device_set_temporary(device, FALSE);
+ btd_device_set_temporary(device, FALSE);
}
if (ev->key.master)
@@ -5860,7 +5860,7 @@ static void unpaired_callback(uint16_t index, uint16_t length,
return;
}
- device_set_temporary(device, TRUE);
+ btd_device_set_temporary(device, TRUE);
if (device_is_connected(device))
device_request_disconnect(device, NULL);
diff --git a/src/device.c b/src/device.c
index c0e317d..59e65b9 100644
--- a/src/device.c
+++ b/src/device.c
@@ -997,7 +997,7 @@ int device_block(struct btd_device *device, gboolean update_only)
store_device_info(device);
- device_set_temporary(device, FALSE);
+ btd_device_set_temporary(device, FALSE);
g_dbus_emit_property_changed(dbus_conn, device->path,
DEVICE_INTERFACE, "Blocked");
@@ -1152,7 +1152,7 @@ static void device_profile_connected(struct btd_device *dev,
DBG("%s %s (%d)", profile->name, strerror(-err), -err);
if (!err)
- device_set_temporary(dev, FALSE);
+ btd_device_set_temporary(dev, FALSE);
if (dev->pending == NULL)
return;
@@ -1308,7 +1308,7 @@ static DBusMessage *connect_profiles(struct btd_device *dev, DBusMessage *msg,
if (!btd_adapter_get_powered(dev->adapter))
return btd_error_not_ready(msg);
- device_set_temporary(dev, FALSE);
+ btd_device_set_temporary(dev, FALSE);
if (!dev->svc_resolved)
goto resolve_services;
@@ -1358,7 +1358,7 @@ static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg,
if (device_is_connected(dev))
return dbus_message_new_method_return(msg);
- device_set_temporary(dev, FALSE);
+ btd_device_set_temporary(dev, FALSE);
dev->disable_auto_connect = FALSE;
@@ -1609,7 +1609,7 @@ static DBusMessage *pair_device(DBusConnection *conn, DBusMessage *msg,
uint8_t io_cap;
int err;
- device_set_temporary(device, FALSE);
+ btd_device_set_temporary(device, FALSE);
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_INVALID))
return btd_error_invalid_args(msg);
@@ -3112,7 +3112,7 @@ static void register_all_services(struct browse_req *req, GSList *services)
{
struct btd_device *device = req->device;
- device_set_temporary(device, FALSE);
+ btd_device_set_temporary(device, FALSE);
update_gatt_services(req, device->primaries, services);
g_slist_free_full(device->primaries, g_free);
@@ -3549,7 +3549,7 @@ gboolean device_is_temporary(struct btd_device *device)
return device->temporary;
}
-void device_set_temporary(struct btd_device *device, gboolean temporary)
+void btd_device_set_temporary(struct btd_device *device, gboolean temporary)
{
if (!device)
return;
diff --git a/src/device.h b/src/device.h
index deec8d0..35d2a75 100644
--- a/src/device.h
+++ b/src/device.h
@@ -69,7 +69,7 @@ gboolean device_is_paired(struct btd_device *device);
gboolean device_is_bonded(struct btd_device *device);
gboolean device_is_trusted(struct btd_device *device);
void device_set_paired(struct btd_device *device, gboolean paired);
-void device_set_temporary(struct btd_device *device, gboolean temporary);
+void btd_device_set_temporary(struct btd_device *device, gboolean temporary);
void device_set_trusted(struct btd_device *device, gboolean trusted);
void device_set_bonded(struct btd_device *device, gboolean bonded);
void device_set_legacy(struct btd_device *device, bool legacy);
--
1.8.4.4
^ permalink raw reply related
* [PATCH 02/13] Rename adapter_get_device to btd_adapter_get_device
From: Szymon Janc @ 2013-11-25 22:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1385417752-25664-1-git-send-email-szymon.janc@gmail.com>
Allow this symbol to be exported and usable from external plugins.
---
plugins/neard.c | 6 ++++--
profiles/health/hdp.c | 4 ++--
src/adapter.c | 28 +++++++++++++++++-----------
src/adapter.h | 2 +-
4 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index ea91c4d..073abec 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -701,7 +701,8 @@ static DBusMessage *push_oob(DBusConnection *conn, DBusMessage *msg, void *data)
return error_reply(msg, EINVAL);
}
- device = adapter_get_device(adapter, &remote.address, BDADDR_BREDR);
+ device = btd_adapter_get_device(adapter, &remote.address,
+ BDADDR_BREDR);
err = check_device(device);
if (err < 0) {
@@ -769,7 +770,8 @@ static DBusMessage *request_oob(DBusConnection *conn, DBusMessage *msg,
if (bacmp(&remote.address, BDADDR_ANY) == 0)
goto read_local;
- device = adapter_get_device(adapter, &remote.address, BDADDR_BREDR);
+ device = btd_adapter_get_device(adapter, &remote.address,
+ BDADDR_BREDR);
err = check_device(device);
if (err < 0) {
diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c
index 7b4e799..86cebe6 100644
--- a/profiles/health/hdp.c
+++ b/profiles/health/hdp.c
@@ -1205,8 +1205,8 @@ static void mcl_connected(struct mcap_mcl *mcl, gpointer data)
struct hdp_adapter *hdp_adapter = data;
struct btd_device *device;
- device = adapter_get_device(hdp_adapter->btd_adapter, &addr,
- BDADDR_BREDR);
+ device = btd_adapter_get_device(hdp_adapter->btd_adapter,
+ &addr, BDADDR_BREDR);
if (!device)
return;
hdp_device = create_health_device(device);
diff --git a/src/adapter.c b/src/adapter.c
index d904a56..8a6dadf 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1072,7 +1072,7 @@ static void adapter_remove_device(struct btd_adapter *adapter,
device_remove(dev, TRUE);
}
-struct btd_device *adapter_get_device(struct btd_adapter *adapter,
+struct btd_device *btd_adapter_get_device(struct btd_adapter *adapter,
const bdaddr_t *addr,
uint8_t addr_type)
{
@@ -2726,7 +2726,8 @@ static void get_connections_complete(uint8_t status, uint16_t length,
ba2str(&addr->bdaddr, address);
DBG("Adding existing connection to %s", address);
- device = adapter_get_device(adapter, &addr->bdaddr, addr->type);
+ device = btd_adapter_get_device(adapter, &addr->bdaddr,
+ addr->type);
if (device)
adapter_add_connection(adapter, device);
}
@@ -4687,7 +4688,8 @@ static void user_confirm_request_callback(uint16_t index, uint16_t length,
ba2str(&ev->addr.bdaddr, addr);
DBG("hci%u %s confirm_hint %u", adapter->dev_id, addr,
ev->confirm_hint);
- device = adapter_get_device(adapter, &ev->addr.bdaddr, ev->addr.type);
+ device = btd_adapter_get_device(adapter, &ev->addr.bdaddr,
+ ev->addr.type);
if (!device) {
error("Unable to get device object for %s", addr);
return;
@@ -4758,7 +4760,8 @@ static void user_passkey_request_callback(uint16_t index, uint16_t length,
ba2str(&ev->addr.bdaddr, addr);
DBG("hci%u %s", index, addr);
- device = adapter_get_device(adapter, &ev->addr.bdaddr, ev->addr.type);
+ device = btd_adapter_get_device(adapter, &ev->addr.bdaddr,
+ ev->addr.type);
if (!device) {
error("Unable to get device object for %s", addr);
return;
@@ -4790,7 +4793,8 @@ static void user_passkey_notify_callback(uint16_t index, uint16_t length,
ba2str(&ev->addr.bdaddr, addr);
DBG("hci%u %s", index, addr);
- device = adapter_get_device(adapter, &ev->addr.bdaddr, ev->addr.type);
+ device = btd_adapter_get_device(adapter, &ev->addr.bdaddr,
+ ev->addr.type);
if (!device) {
error("Unable to get device object for %s", addr);
return;
@@ -4872,7 +4876,8 @@ static void pin_code_request_callback(uint16_t index, uint16_t length,
DBG("hci%u %s", adapter->dev_id, addr);
- device = adapter_get_device(adapter, &ev->addr.bdaddr, ev->addr.type);
+ device = btd_adapter_get_device(adapter, &ev->addr.bdaddr,
+ ev->addr.type);
if (!device) {
error("Unable to get device object for %s", addr);
return;
@@ -4957,7 +4962,7 @@ static void bonding_complete(struct btd_adapter *adapter,
struct btd_device *device;
if (status == 0)
- device = adapter_get_device(adapter, bdaddr, addr_type);
+ device = btd_adapter_get_device(adapter, bdaddr, addr_type);
else
device = adapter_find_device(adapter, bdaddr);
@@ -4984,7 +4989,7 @@ static void bonding_attempt_complete(struct btd_adapter *adapter,
addr_type, status);
if (status == 0)
- device = adapter_get_device(adapter, bdaddr, addr_type);
+ device = btd_adapter_get_device(adapter, bdaddr, addr_type);
else
device = adapter_find_device(adapter, bdaddr);
@@ -5274,7 +5279,7 @@ static void new_link_key_callback(uint16_t index, uint16_t length,
return;
}
- device = adapter_get_device(adapter, &addr->bdaddr, addr->type);
+ device = btd_adapter_get_device(adapter, &addr->bdaddr, addr->type);
if (!device) {
error("Unable to get device object for %s", dst);
return;
@@ -5369,7 +5374,7 @@ static void new_long_term_key_callback(uint16_t index, uint16_t length,
DBG("hci%u new LTK for %s authenticated %u enc_size %u",
adapter->dev_id, dst, ev->key.authenticated, ev->key.enc_size);
- device = adapter_get_device(adapter, &addr->bdaddr, addr->type);
+ device = btd_adapter_get_device(adapter, &addr->bdaddr, addr->type);
if (!device) {
error("Unable to get device object for %s", dst);
return;
@@ -5720,7 +5725,8 @@ static void connected_callback(uint16_t index, uint16_t length,
DBG("hci%u device %s connected eir_len %u", index, addr, eir_len);
- device = adapter_get_device(adapter, &ev->addr.bdaddr, ev->addr.type);
+ device = btd_adapter_get_device(adapter, &ev->addr.bdaddr,
+ ev->addr.type);
if (!device) {
error("Unable to get device object for %s", addr);
return;
diff --git a/src/adapter.h b/src/adapter.h
index 80c5f77..8a2ddae 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -90,7 +90,7 @@ bool btd_adapter_get_connectable(struct btd_adapter *adapter);
uint32_t btd_adapter_get_class(struct btd_adapter *adapter);
const char *btd_adapter_get_name(struct btd_adapter *adapter);
-struct btd_device *adapter_get_device(struct btd_adapter *adapter,
+struct btd_device *btd_adapter_get_device(struct btd_adapter *adapter,
const bdaddr_t *addr,
uint8_t addr_type);
sdp_list_t *btd_adapter_get_services(struct btd_adapter *adapter);
--
1.8.4.4
^ permalink raw reply related
* [PATCH 01/13] core: Export some symbols from libbluetooth
From: Szymon Janc @ 2013-11-25 22:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1385417752-25664-1-git-send-email-szymon.janc@gmail.com>
Those are commonly used and should be available for external plugins.
---
src/bluetooth.ver | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/bluetooth.ver b/src/bluetooth.ver
index b71c70d..214fa8a 100644
--- a/src/bluetooth.ver
+++ b/src/bluetooth.ver
@@ -5,6 +5,8 @@
info;
error;
debug;
+ baswap;
+ ba2str;
local:
*;
};
--
1.8.4.4
^ permalink raw reply related
* [PATCH 00/13] sixaxis support
From: Szymon Janc @ 2013-11-25 22:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
Hi All,
This is yet another attempt to get PS3 controller support into BlueZ upstream.
I based my work on Fedora out-of-tree patch (hence copyright info) and tried
to take into consideration comments from previous upstreaming attempt.
I find sixaxis name short and neat so I sticked with it.
I didn't really like the idea of hardcoding SDP records so I took different
approach of doing reverse SDP search while cable associated device first
connects. This is done before authorizing incoming HID connection.
Some functions unavailable to exteral plugins were renamed with btd_ prefix
(or explicitly marked in bletooth.ver) to export them (patch 1-8).
Patch 9-10 add sixaxis external plugin that depends on udev. This plugin is
responsible for preparing newly USB connected PS3 sixaxis device and creating
btd_device with proper PNP information.
Patch 12 adds support for handling first connection of sixaxis device in input
plugin itself. This is something I would like to get comments and suggestions.
Currently this is rather sixaxis oriented, but could be made more generic (some
hooks registration) if desired.
This serie is not implemententing any LED (or other features) setting support.
I have an impression that those should not be handled by BlueZ but some other
entity (util tools or driver itself perhabs?) as this is not related to
transport itself and should be set/used on USB connection as well.
This was tested with Dualshock3 and seems to be working nicely here.
Comments are welcome.
--
BR
Szymon Janc
Szymon Janc (13):
core: Export some symbols from libbluetooth
Rename adapter_get_device to btd_adapter_get_device
Rename device_set_temporary to btd_device_set_temporary
Rename device_set_trusted to btd_device_set_trusted
Rename device_device_set_name to btd_device_device_set_name
Rename device_get_uuids to btd_device_get_uuids
Rename adapter_get_address to btd_adapter_get_address
Rename adapter_find_device to btd_adapter_find_device
plugins: Add initial code for sixaxis plugin
plugins/sixaxis: Add initial code for udev handling
plugins/sixaxis: Add support for configuring new controllers
device: Add device_discover_services function
input: Add support for handling sixaxis devices
Makefile.plugins | 8 ++
bootstrap-configure | 1 +
configure.ac | 5 +
plugins/neard.c | 10 +-
plugins/sixaxis.c | 286 ++++++++++++++++++++++++++++++++++++++++++
plugins/wiimote.c | 2 +-
profiles/audio/avctp.c | 18 +--
profiles/audio/avdtp.c | 11 +-
profiles/health/hdp.c | 10 +-
profiles/health/hdp_util.c | 6 +-
profiles/input/device.c | 4 +-
profiles/input/manager.c | 4 +-
profiles/input/server.c | 104 ++++++++++++++-
profiles/network/connection.c | 2 +-
profiles/network/server.c | 4 +-
profiles/sap/server.c | 3 +-
src/adapter.c | 74 ++++++-----
src/adapter.h | 6 +-
src/attrib-server.c | 6 +-
src/bluetooth.ver | 2 +
src/device.c | 70 +++++++----
src/device.h | 10 +-
src/profile.c | 14 +--
23 files changed, 551 insertions(+), 109 deletions(-)
create mode 100644 plugins/sixaxis.c
--
1.8.4.4
^ permalink raw reply
* Re: [PATCH 00/13] sixaxis support
From: Antonio Ospite @ 2013-11-25 22:12 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
In-Reply-To: <1385417752-25664-1-git-send-email-szymon.janc@gmail.com>
On Mon, 25 Nov 2013 22:15:39 +0000
Szymon Janc <szymon.janc@gmail.com> wrote:
> Hi All,
>
> This is yet another attempt to get PS3 controller support into BlueZ upstream.
>
> I based my work on Fedora out-of-tree patch (hence copyright info) and tried
> to take into consideration comments from previous upstreaming attempt.
>
Hi Szymon, JFYI the latest patch for my playstation-peripheral plugin
is here:
http://ao2.it/tmp/playstation-peripheral-pugin-v5.x-2013-11-13.patch
Only two patches to BlueZ should be needed with this code.
Basically the only show-stopper was a way to add a device to the
database before it ever connects, I went for this
"btd_create_stored_device(everything_we_know)" but BlueZ devs didn't
like this "kitchen sink" function.
>From my POV the problem here was:
"Add a known device to the device database before it ever connects"
However it looks like I didn't get to solve it in an acceptable way.
> I find sixaxis name short and neat so I sticked with it.
>
I was using playstation-peripheral thinking to the PS Move and
possibly other devices which may work slightly different.
> I didn't really like the idea of hardcoding SDP records so I took different
> approach of doing reverse SDP search while cable associated device first
> connects. This is done before authorizing incoming HID connection.
>
I think ideally we should avoid making BlueZ aware of sixaxis in
input.c.
> Some functions unavailable to exteral plugins were renamed with btd_ prefix
> (or explicitly marked in bletooth.ver) to export them (patch 1-8).
>
> Patch 9-10 add sixaxis external plugin that depends on udev. This plugin is
> responsible for preparing newly USB connected PS3 sixaxis device and creating
> btd_device with proper PNP information.
>
> Patch 12 adds support for handling first connection of sixaxis device in input
> plugin itself. This is something I would like to get comments and suggestions.
> Currently this is rather sixaxis oriented, but could be made more generic (some
> hooks registration) if desired.
>
> This serie is not implemententing any LED (or other features) setting support.
> I have an impression that those should not be handled by BlueZ but some other
> entity (util tools or driver itself perhabs?) as this is not related to
> transport itself and should be set/used on USB connection as well.
>
Setting LEDs will need to be done by some code using udev anyway, as we
want the LED to match the X in the created /dev/input/jsX, so I thought
it may just go in the bluez plugin which is using udev already.
The kernel driver is at HID/input level in linux which is not aware of
the joystick layer, so it cannot know the joystick number, and
besides kernel driver should not be too smart anyway.
We cannot just count devices in the sixaxis kernel driver either,
consider this scenario:
- Connect a PS3 controller (js0, LED1)
- Connect some other joystick (js1)
- Connect another PS3 controller (js2, LED3)
> This was tested with Dualshock3 and seems to be working nicely here.
>
> Comments are welcome.
>
See above, but I don't think I am qualified to comment on your patches
12 and 13.
BTW considering that up to now I failed to have this merged I am not
going be picky, if BlueZ devs are happy with your approach, let's go
for it :)
Thanks,
Antonio
--
Antonio Ospite
http://ao2.it
A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
^ permalink raw reply
* Re: autopair corner cases
From: Scott James Remnant @ 2013-11-25 21:41 UTC (permalink / raw)
To: Bastien Nocera
Cc: linux-bluetooth@vger.kernel.org, Alex Deymo, Scott James Remnant
In-Reply-To: <1384867785.2027.36.camel@nuvo>
On Tue, Nov 19, 2013 at 5:29 AM, Bastien Nocera <hadess@hadess.net> wrote:
> 6) I have a "TomTom Remote" that shows up as a keyboard and uses "0000"
> as its PIN. The problem is that, as per the code in autopair.c we'll
> first show a random pincode then quickly fall back to using "0000":
>> /* For keyboards rejecting the first random code
>> * in less than 500ms, try a fixed code. */
>
> How does ChromeOS present this? Does it wait half a second before
> showing the pincode to enter? Because flashing an unusable pincode on
> the screen before succeeding pairing is pretty rubbish in my opinion...
>
This is at least slightly better than OS X, which would display the
random PIN, and then fail pairing - require you to try again, find the
"Advanced" button, set it to one of three or four user-nonsensical
options, and then enter 0000
I'm not saying we can't do better, of course, I'm just saying that we
can do worse :p
A half-second flash of a 6-digit PIN before falling back to a
four-digit one at least works in all of the corner cases - including
this one.
We actually collect logs via metrics of the devices this happens for,
right now we only know of one keyboard that this gets triggered for (a
Motorola Android Keyboard that's no longer on sale) - the TomTom
Remote makes two - I guess nobody's paired a Chromebook with one yet.
I'm way open to ideas for improving the experience here, just as long
as we keep the "works in the common and corner cases" part ;-)
Scott
--
Scott James Remnant | Chrome OS Systems | keybuk@google.com | Google
^ permalink raw reply
* Re: autopair corner cases
From: Scott James Remnant @ 2013-11-25 21:37 UTC (permalink / raw)
To: Bastien Nocera; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1384864264.2027.22.camel@nuvo>
On Tue, Nov 19, 2013 at 4:31 AM, Bastien Nocera <hadess@hadess.net> wrote:
> 1) First is the case of the PS3 BD Remote that will reject
> authentication when you try to pair to it. gnome-bluetooth knows not to
> pair with it.
>
>> <!-- Sony PlayStation 3 Remote Control -->
>> <device oui="00:19:C1:" name="BD Remote Control" pin="NULL"/>
>> <device oui="00:1E:3D:" name="BD Remote Control" pin="NULL"/>
>> <device oui="00:06:F5:" name="BD Remote Control" pin="NULL"/>
>
> Is there a way to say "we can't actually pair" when the client requested
> pairing already? Or is that considered a security problem?
>
It's perfectly valid for Bluetooth devices to not support pairing, and
return a "Pairing Not Supported" or "Authentication Not Supported"
error when attempted. When I tested a PS3 controller here, it seemed
to do that according to spec.
This is especially true for LE devices, the majority I have don't
support pairing.
While it's a "nice to have" for a UI to know in advance, maintaining
that list of devices would be quite an undertaking, it didn't seem
worth special casing the PS3 Controller. Also that should take the
form of a device property the UI can examine to decide whether or not
to offer pairing. Having the plugin fail pairing with the same error
the device would give anyway didn't seem like a "fix".
> 2) The second case is pairing this "funny" keyboard that's the iCade
> controller. In gnome-bluetooth, we had special code to generate only
> joystick movements for the pairing, rather than hard to determine
> buttons, so we'd end up with a 6-digit pin using only 1 through 4.
>
>> <!-- ION iCade Game Controller -->
>> <device name="iCade" type="keyboard" pin="ICADE"/>
>
Having a BlueZ-UI API just for this one device seems like overkill?
This can be just blacklisted in the autopair plugin, or handled by a
higher priority plugin, so the UI can use its special code, no?
> 3) We have a whole list of GPS that don't use present themselves as
> anything special apart from the name. Most use "0000", but some use
> things like "NAVMAN" or "12345678"
>
>> <!-- http://bugzilla.gnome.org/show_bug.cgi?id=560315#c20 -->
>> <device oui="00:02:5B:" name="Pharos iGPS-BT" pin="12345678"/>
>>
>> <!-- https://bugzilla.gnome.org/show_bug.cgi?id=613698 -->
>> <device oui="00:0C:A5:" name="NAVMAN GPS ONE" pin="NAVMAN"/>
>
These could be handled by extending the plugin, or a higher priority
plugin, - right now I don't think the plugin would deal with them at
all?
> 4) Audio devices will mostly already be supported by the autopair code
> (yay!), though we have a few stragglers, most notably this speaker that
> can use random pincode, as long as they're only 4 digits in length:
>
>> <!-- http://bugzilla.gnome.org/show_bug.cgi?id=583651 -->
>> <device type="audio" oui="00:1A:80:" name="CMT-DH5BT" pin="max:4"/>
>
I'm confused by this one - the device accepts any four-digit PIN?
wouldn't 0000 work? :)
> 5) Printers are missing from the list, that should be an easy fix.
>
Unsurprising, since Chromium OS doesn't support printers ;-)
Scott
--
Scott James Remnant | Chrome OS Systems | keybuk@google.com | Google
^ permalink raw reply
* SM: is BlueZ the Master/Initiator or Slave/Responder?
From: Scott James Remnant @ 2013-11-25 21:17 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org, Holtmann, Marcel, Johan Hedberg,
Brian Gix
We are able to pass all qualification tests with BlueZ as the Master except one:
TP/KDU/BV-06-C - Master Key Distribution - Encryption Key bit
This test requires that BlueZ initiates pairing with the
SMP_DIST_ENC_KEY bit set in the init_key_dist member of struct
smp_cmd_pairing - however this member is always initialized to zero
and never changed.
This seems to have changed at some point in the past, 2b64d153 added
MITM mechanism and changed the init_key_dist member initialization
from dist_keys to 0
So two questions:
1) should BlueZ be able to behave as Master? It passes the majority
of the tests except this one.
2) given the above, is this a bug that init_key_dist is 0 or is it a
test plan error that it requires this?
Scott
--
Scott James Remnant | Chrome OS Systems | keybuk@google.com | Google
^ permalink raw reply
* Crasher during remote initiated pairing
From: Bastien Nocera @ 2013-11-25 16:53 UTC (permalink / raw)
To: linux-bluetooth
Heya,
I have a particularly stubborn device, the TomTom Go Remote that tries
to connect to my computer as soon as it's turned on, even when I've
removed the pairing on the computer side.
With GNOME's Bluetooth wizard open, I receive an out of the blue request
for pairing, I pass it the expected PIN code (0000), I then find that
the wizard doesn't work as I expected and turn it off. bluetoothd
promptly crashes:
Program received signal SIGSEGV, Segmentation fault.
0x00007f0cf9ffde24 in agent_auth_cb (agent=<optimized out>, derr=0x7fffab655920, user_data=0x7f0cfb2e0020) at src/adapter.c:4370
4370 struct service_auth *auth = adapter->auths->head->data;
(gdb) p adapter
$1 = (struct btd_adapter *) 0x7f0cfb2e0020
(gdb) p adapter->auths
$2 = (GQueue *) 0x7f0cfb2d1240
(gdb) p adapter->auths->head
$3 = 0x0
Some missing NULL checks?
I imagine that this should be reproduceable using simple-agent and
making it exit after replying to RequestPinCode.
This happens with 5.10 and 5.11:
https://retrace.fedoraproject.org/faf/problems/1353319/
Cheers
^ permalink raw reply
* [PATCH v2 20/20] unit/AVDTP: Add /TP/SIG/SMG/BV-24-C test
From: Luiz Augusto von Dentz @ 2013-11-25 14:54 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385391283-10962-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Verify that the IUT (ACP) is able to accept a command to abort a stream.
---
unit/test-avdtp.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index 949d998..065dc07 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -596,6 +596,17 @@ int main(int argc, char *argv[])
0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
raw_pdu(0x12, 0x03),
raw_pdu(0x20, 0x0a, 0x04));
+ define_test("/TP/SIG/SMG/BV-24-C", test_server,
+ raw_pdu(0x00, 0x01),
+ raw_pdu(0x02, 0x01, 0x04, 0x00),
+ raw_pdu(0x10, 0x02, 0x04),
+ raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
+ 0xff, 0xff, 0x02, 0x40),
+ raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
+ 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
+ raw_pdu(0x22, 0x03),
+ raw_pdu(0x30, 0x0a, 0x04),
+ raw_pdu(0x32, 0x0a));
return g_test_run();
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH v2 19/20] unit/AVDTP: Add /TP/SIG/SMG/BV-23-C test
From: Luiz Augusto von Dentz @ 2013-11-25 14:54 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385391283-10962-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Verify that the IUT (INT) is able to abort a stream by issuing the
AVDTP_ABORT and reporting the replied confirmation.
---
unit/test-avdtp.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index 88c2b01..949d998 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -293,6 +293,8 @@ static void sep_setconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-11-C"))
ret = avdtp_get_configuration(session, stream);
+ if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-23-C"))
+ ret = avdtp_abort(session, stream);
else
ret = avdtp_open(session, stream);
@@ -584,6 +586,16 @@ int main(int argc, char *argv[])
raw_pdu(0x42, 0x07),
raw_pdu(0x50, 0x09, 0x04),
raw_pdu(0x52, 0x09));
+ define_test("/TP/SIG/SMG/BV-23-C", test_client,
+ raw_pdu(0xf0, 0x01),
+ raw_pdu(0xf2, 0x01, 0x04, 0x00),
+ raw_pdu(0x00, 0x02, 0x04),
+ raw_pdu(0x02, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
+ 0xff, 0xff, 0x02, 0x40),
+ raw_pdu(0x10, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
+ 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
+ raw_pdu(0x12, 0x03),
+ raw_pdu(0x20, 0x0a, 0x04));
return g_test_run();
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH v2 18/20] unit/AVDTP: Add /TP/SIG/SMG/BV-22-C test
From: Luiz Augusto von Dentz @ 2013-11-25 14:54 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385391283-10962-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Verify that the IUT (ACP) is able to accept an AVDTP_SUSPEND_CMD, after
the streaming procedure has been started, by reporting the suspension
and replying the returned confirmation.
---
unit/test-avdtp.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index 804fdf5..88c2b01 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -569,6 +569,21 @@ int main(int argc, char *argv[])
raw_pdu(0xd0, 0x07, 0x04),
raw_pdu(0xd2, 0x07),
raw_pdu(0xe0, 0x09, 0x04));
+ define_test("/TP/SIG/SMG/BV-22-C", test_server,
+ raw_pdu(0x00, 0x01),
+ raw_pdu(0x02, 0x01, 0x04, 0x00),
+ raw_pdu(0x10, 0x02, 0x04),
+ raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
+ 0xff, 0xff, 0x02, 0x40),
+ raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
+ 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
+ raw_pdu(0x22, 0x03),
+ raw_pdu(0x30, 0x06, 0x04),
+ raw_pdu(0x32, 0x06),
+ raw_pdu(0x40, 0x07, 0x04),
+ raw_pdu(0x42, 0x07),
+ raw_pdu(0x50, 0x09, 0x04),
+ raw_pdu(0x52, 0x09));
return g_test_run();
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH v2 17/20] unit/AVDTP: Add /TP/SIG/SMG/BV-21-C test
From: Luiz Augusto von Dentz @ 2013-11-25 14:54 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385391283-10962-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Verify that the IUT (INT) is able to initiate the suspension of a
streaming procedure, after the streaming procedure has been started, by
issuing the AVDTP_SUSPEND_CMD.
---
unit/test-avdtp.c | 124 +++++++++++++-----------------------------------------
1 file changed, 29 insertions(+), 95 deletions(-)
diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index 4677e22..804fdf5 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -317,11 +317,15 @@ static void sep_start_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
struct avdtp_stream *stream, struct avdtp_error *err,
void *user_data)
{
+ struct context *context = user_data;
int ret;
g_assert(err == NULL);
- ret = avdtp_close(session, stream, FALSE);
+ if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-19-C"))
+ ret = avdtp_close(session, stream, FALSE);
+ else
+ ret = avdtp_suspend(session, stream);
g_assert_cmpint(ret, ==, 0);
}
@@ -359,7 +363,8 @@ static void discover_cb(struct avdtp *session, GSList *seps,
uint8_t data[4] = { 0x21, 0x02, 2, 32 };
int ret;
- if (!context)
+ if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-05-C") ||
+ g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-07-C"))
return;
g_assert(err == NULL);
@@ -391,92 +396,7 @@ static void discover_cb(struct avdtp *session, GSList *seps,
g_slist_free_full(caps, g_free);
}
-static void test_discover(gconstpointer data)
-{
- struct context *context = create_context(0x0100, data);
-
- avdtp_discover(context->session, discover_cb, NULL);
-
- execute_context(context);
-}
-
-static void test_get_capabilities(gconstpointer data)
-{
- struct context *context = create_context(0x0100, data);
-
- avdtp_discover(context->session, discover_cb, NULL);
-
- execute_context(context);
-}
-
-static void test_set_configuration(gconstpointer data)
-{
- struct context *context = create_context(0x0100, data);
- struct avdtp_local_sep *sep;
-
- sep = avdtp_register_sep(AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
- 0x00, FALSE, NULL, NULL, NULL);
- context->sep = sep;
-
- avdtp_discover(context->session, discover_cb, context);
-
- execute_context(context);
-
- avdtp_unregister_sep(sep);
-}
-
-static void test_get_configuration(gconstpointer data)
-{
- struct context *context = create_context(0x0100, data);
- struct avdtp_local_sep *sep;
-
- sep = avdtp_register_sep(AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
- 0x00, FALSE, NULL, &sep_cfm,
- context);
- context->sep = sep;
-
- avdtp_discover(context->session, discover_cb, context);
-
- execute_context(context);
-
- avdtp_unregister_sep(sep);
-}
-
-static void test_open(gconstpointer data)
-{
- struct context *context = create_context(0x0100, data);
- struct avdtp_local_sep *sep;
-
- sep = avdtp_register_sep(AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
- 0x00, FALSE, NULL, &sep_cfm,
- context);
- context->sep = sep;
-
- avdtp_discover(context->session, discover_cb, context);
-
- execute_context(context);
-
- avdtp_unregister_sep(sep);
-}
-
-static void test_start(gconstpointer data)
-{
- struct context *context = create_context(0x0100, data);
- struct avdtp_local_sep *sep;
-
- sep = avdtp_register_sep(AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
- 0x00, FALSE, NULL, &sep_cfm,
- context);
- context->sep = sep;
-
- avdtp_discover(context->session, discover_cb, context);
-
- execute_context(context);
-
- avdtp_unregister_sep(sep);
-}
-
-static void test_close(gconstpointer data)
+static void test_client(gconstpointer data)
{
struct context *context = create_context(0x0100, data);
struct avdtp_local_sep *sep;
@@ -506,12 +426,12 @@ int main(int argc, char *argv[])
* To verify that the following procedures are implemented according to
* their specification in AVDTP.
*/
- define_test("/TP/SIG/SMG/BV-05-C", test_discover,
+ define_test("/TP/SIG/SMG/BV-05-C", test_client,
raw_pdu(0x00, 0x01));
define_test("/TP/SIG/SMG/BV-06-C", test_server,
raw_pdu(0x00, 0x01),
raw_pdu(0x02, 0x01, 0x04, 0x00));
- define_test("/TP/SIG/SMG/BV-07-C", test_get_capabilities,
+ define_test("/TP/SIG/SMG/BV-07-C", test_client,
raw_pdu(0x10, 0x01),
raw_pdu(0x12, 0x01, 0x04, 0x00),
raw_pdu(0x20, 0x02, 0x04));
@@ -521,7 +441,7 @@ int main(int argc, char *argv[])
raw_pdu(0x10, 0x02, 0x04),
raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
0xff, 0xff, 0x02, 0x40));
- define_test("/TP/SIG/SMG/BV-09-C", test_set_configuration,
+ define_test("/TP/SIG/SMG/BV-09-C", test_client,
raw_pdu(0x30, 0x01),
raw_pdu(0x32, 0x01, 0x04, 0x00),
raw_pdu(0x40, 0x02, 0x04),
@@ -538,7 +458,7 @@ int main(int argc, char *argv[])
raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
raw_pdu(0x22, 0x03));
- define_test("/TP/SIG/SMG/BV-11-C", test_get_configuration,
+ define_test("/TP/SIG/SMG/BV-11-C", test_client,
raw_pdu(0x60, 0x01),
raw_pdu(0x62, 0x01, 0x04, 0x00),
raw_pdu(0x70, 0x02, 0x04),
@@ -560,7 +480,7 @@ int main(int argc, char *argv[])
raw_pdu(0x30, 0x04, 0x04),
raw_pdu(0x32, 0x04, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
0x21, 0x02, 0x02, 0x20));
- define_test("/TP/SIG/SMG/BV-15-C", test_open,
+ define_test("/TP/SIG/SMG/BV-15-C", test_client,
raw_pdu(0xa0, 0x01),
raw_pdu(0xa2, 0x01, 0x04, 0x00),
raw_pdu(0xb0, 0x02, 0x04),
@@ -581,7 +501,7 @@ int main(int argc, char *argv[])
raw_pdu(0x22, 0x03),
raw_pdu(0x30, 0x06, 0x04),
raw_pdu(0x32, 0x06));
- define_test("/TP/SIG/SMG/BV-17-C", test_start,
+ define_test("/TP/SIG/SMG/BV-17-C", test_client,
raw_pdu(0xe0, 0x01),
raw_pdu(0xe2, 0x01, 0x04, 0x00),
raw_pdu(0xf0, 0x02, 0x04),
@@ -606,7 +526,7 @@ int main(int argc, char *argv[])
raw_pdu(0x32, 0x06),
raw_pdu(0x40, 0x07, 0x04),
raw_pdu(0x42, 0x07));
- define_test("/TP/SIG/SMG/BV-19-C", test_close,
+ define_test("/TP/SIG/SMG/BV-19-C", test_client,
raw_pdu(0x30, 0x01),
raw_pdu(0x32, 0x01, 0x04, 0x00),
raw_pdu(0x40, 0x02, 0x04),
@@ -635,6 +555,20 @@ int main(int argc, char *argv[])
raw_pdu(0x42, 0x07),
raw_pdu(0x50, 0x08, 0x04),
raw_pdu(0x52, 0x08));
+ define_test("/TP/SIG/SMG/BV-21-C", test_client,
+ raw_pdu(0x90, 0x01),
+ raw_pdu(0x92, 0x01, 0x04, 0x00),
+ raw_pdu(0xa0, 0x02, 0x04),
+ raw_pdu(0xa2, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
+ 0xff, 0xff, 0x02, 0x40),
+ raw_pdu(0xb0, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
+ 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
+ raw_pdu(0xb2, 0x03),
+ raw_pdu(0xc0, 0x06, 0x04),
+ raw_pdu(0xc2, 0x06),
+ raw_pdu(0xd0, 0x07, 0x04),
+ raw_pdu(0xd2, 0x07),
+ raw_pdu(0xe0, 0x09, 0x04));
return g_test_run();
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH v2 16/20] unit/AVDTP: Add /TP/SIG/SMG/BV-20-C test
From: Luiz Augusto von Dentz @ 2013-11-25 14:54 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385391283-10962-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Verify that the IUT (ACP) is able to accept an AVDTP_CLOSE_CMD after the
streaming procedure has been started, by releasing all the resources
associated to the SEP, reporting of the closing and replying the
returned confirmation.
---
unit/test-avdtp.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index c01e5fb..4677e22 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -620,6 +620,21 @@ int main(int argc, char *argv[])
raw_pdu(0x70, 0x07, 0x04),
raw_pdu(0x72, 0x07),
raw_pdu(0x80, 0x08, 0x04));
+ define_test("/TP/SIG/SMG/BV-20-C", test_server,
+ raw_pdu(0x00, 0x01),
+ raw_pdu(0x02, 0x01, 0x04, 0x00),
+ raw_pdu(0x10, 0x02, 0x04),
+ raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
+ 0xff, 0xff, 0x02, 0x40),
+ raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
+ 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
+ raw_pdu(0x22, 0x03),
+ raw_pdu(0x30, 0x06, 0x04),
+ raw_pdu(0x32, 0x06),
+ raw_pdu(0x40, 0x07, 0x04),
+ raw_pdu(0x42, 0x07),
+ raw_pdu(0x50, 0x08, 0x04),
+ raw_pdu(0x52, 0x08));
return g_test_run();
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH v2 15/20] unit/AVDTP: Add /TP/SIG/SMG/BV-19-C test
From: Luiz Augusto von Dentz @ 2013-11-25 14:54 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385391283-10962-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Verify that the IUT (INT) is able to initiate the release of a streaming
procedure after the streaming procedure has been started, by issuing the
AVDTP_CLOSE_CMD, releasing all the resources associated to the SEP after
reception of the replied confirmation and reporting the closing.
---
unit/test-avdtp.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 46 insertions(+), 5 deletions(-)
diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index 615df00..c01e5fb 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -293,12 +293,8 @@ static void sep_setconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-11-C"))
ret = avdtp_get_configuration(session, stream);
- else if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-15-C"))
- ret = avdtp_open(session, stream);
- else if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-17-C"))
- ret = avdtp_open(session, stream);
else
- g_assert_not_reached();
+ ret = avdtp_open(session, stream);
g_assert_cmpint(ret, ==, 0);
}
@@ -317,9 +313,23 @@ static void sep_open_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
g_assert_cmpint(ret, ==, 0);
}
+static void sep_start_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
+ struct avdtp_stream *stream, struct avdtp_error *err,
+ void *user_data)
+{
+ int ret;
+
+ g_assert(err == NULL);
+
+ ret = avdtp_close(session, stream, FALSE);
+
+ g_assert_cmpint(ret, ==, 0);
+}
+
static struct avdtp_sep_cfm sep_cfm = {
.set_configuration = sep_setconf_cfm,
.open = sep_open_cfm,
+ .start = sep_start_cfm,
};
static void test_server(gconstpointer data)
@@ -466,6 +476,23 @@ static void test_start(gconstpointer data)
avdtp_unregister_sep(sep);
}
+static void test_close(gconstpointer data)
+{
+ struct context *context = create_context(0x0100, data);
+ struct avdtp_local_sep *sep;
+
+ sep = avdtp_register_sep(AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
+ 0x00, FALSE, NULL, &sep_cfm,
+ context);
+ context->sep = sep;
+
+ avdtp_discover(context->session, discover_cb, context);
+
+ execute_context(context);
+
+ avdtp_unregister_sep(sep);
+}
+
int main(int argc, char *argv[])
{
g_test_init(&argc, &argv, NULL);
@@ -579,6 +606,20 @@ int main(int argc, char *argv[])
raw_pdu(0x32, 0x06),
raw_pdu(0x40, 0x07, 0x04),
raw_pdu(0x42, 0x07));
+ define_test("/TP/SIG/SMG/BV-19-C", test_close,
+ raw_pdu(0x30, 0x01),
+ raw_pdu(0x32, 0x01, 0x04, 0x00),
+ raw_pdu(0x40, 0x02, 0x04),
+ raw_pdu(0x42, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
+ 0xff, 0xff, 0x02, 0x40),
+ raw_pdu(0x50, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
+ 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
+ raw_pdu(0x52, 0x03),
+ raw_pdu(0x60, 0x06, 0x04),
+ raw_pdu(0x62, 0x06),
+ raw_pdu(0x70, 0x07, 0x04),
+ raw_pdu(0x72, 0x07),
+ raw_pdu(0x80, 0x08, 0x04));
return g_test_run();
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH v2 14/20] unit/AVDTP: Add /TP/SIG/SMG/BV-18-C test
From: Luiz Augusto von Dentz @ 2013-11-25 14:54 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385391283-10962-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
To verify that the IUT (ACP) reports the reception of valid
AVDTP_START_CMD and replies the returned confirmation.
---
unit/test-avdtp.c | 138 ++++++++++++++++++++++++++++++------------------------
1 file changed, 76 insertions(+), 62 deletions(-)
diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index 7d2c7bc..615df00 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -46,6 +46,7 @@ struct test_pdu {
};
struct test_data {
+ char *test_name;
struct test_pdu *pdu_list;
};
@@ -64,20 +65,23 @@ struct test_data {
args, { }, { } \
}; \
static struct test_data data; \
+ data.test_name = g_strdup(name); \
data.pdu_list = g_malloc(sizeof(pdus)); \
memcpy(data.pdu_list, pdus, sizeof(pdus)); \
- g_test_add_data_func(name, &data, function); \
+ g_test_add_data_func_full(name, &data, function, test_free); \
} while (0)
struct context {
GMainLoop *main_loop;
struct avdtp *session;
struct avdtp_local_sep *sep;
+ struct avdtp_stream *stream;
guint source;
int fd;
int mtu;
+ gboolean pending_open;
unsigned int pdu_offset;
- const struct test_pdu *pdu_list;
+ const struct test_data *data;
};
static void test_debug(const char *str, void *user_data)
@@ -87,6 +91,14 @@ static void test_debug(const char *str, void *user_data)
g_print("%s%s\n", prefix, str);
}
+static void test_free(void *user_data)
+{
+ struct test_data *data = user_data;
+
+ g_free(data->test_name);
+ g_free(data->pdu_list);
+}
+
static void context_quit(struct context *context)
{
g_main_loop_quit(context->main_loop);
@@ -98,7 +110,7 @@ static gboolean send_pdu(gpointer user_data)
const struct test_pdu *pdu;
ssize_t len;
- pdu = &context->pdu_list[context->pdu_offset++];
+ pdu = &context->data->pdu_list[context->pdu_offset++];
len = write(context->fd, pdu->data, pdu->size);
@@ -112,7 +124,7 @@ static gboolean send_pdu(gpointer user_data)
static void context_process(struct context *context)
{
- if (!context->pdu_list[context->pdu_offset].valid) {
+ if (!context->data->pdu_list[context->pdu_offset].valid) {
context_quit(context);
return;
}
@@ -120,6 +132,17 @@ static void context_process(struct context *context)
g_idle_add(send_pdu, context);
}
+static gboolean transport_open(struct avdtp_stream *stream)
+{
+ int fd;
+
+ fd = open("/dev/null", O_RDWR, 0);
+ if (fd < 0)
+ g_assert_not_reached();
+
+ return avdtp_stream_set_transport(stream, fd, 672, 672);
+}
+
static gboolean test_handler(GIOChannel *channel, GIOCondition cond,
gpointer user_data)
{
@@ -129,7 +152,7 @@ static gboolean test_handler(GIOChannel *channel, GIOCondition cond,
ssize_t len;
int fd;
- pdu = &context->pdu_list[context->pdu_offset++];
+ pdu = &context->data->pdu_list[context->pdu_offset++];
if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
return FALSE;
@@ -147,12 +170,17 @@ static gboolean test_handler(GIOChannel *channel, GIOCondition cond,
g_assert(memcmp(buf, pdu->data, pdu->size) == 0);
+ if (context->pending_open) {
+ context->pending_open = FALSE;
+ g_assert(transport_open(context->stream));
+ }
+
context_process(context);
return TRUE;
}
-static struct context *create_context(uint16_t version)
+static struct context *create_context(uint16_t version, gconstpointer data)
{
struct context *context = g_new0(struct context, 1);
GIOChannel *channel;
@@ -181,6 +209,7 @@ static struct context *create_context(uint16_t version)
g_io_channel_unref(channel);
context->fd = sv[1];
+ context->data = data;
return context;
}
@@ -227,8 +256,21 @@ static gboolean sep_getcap_ind(struct avdtp *session,
return TRUE;
}
+static gboolean sep_open_ind(struct avdtp *session, struct avdtp_local_sep *sep,
+ struct avdtp_stream *stream, uint8_t *err,
+ void *user_data)
+{
+ struct context *context = user_data;
+
+ context->pending_open = TRUE;
+ context->stream = stream;
+
+ return TRUE;
+}
+
static struct avdtp_sep_ind sep_ind = {
.get_capability = sep_getcap_ind,
+ .open = sep_open_ind,
};
static void sep_setconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
@@ -244,21 +286,19 @@ static void sep_setconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
if (!context)
return;
- pdu = &context->pdu_list[context->pdu_offset];
+ pdu = &context->data->pdu_list[context->pdu_offset];
if (pdu->size < 2)
return;
- switch (pdu->data[1]) {
- case 0x04:
+ if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-11-C"))
ret = avdtp_get_configuration(session, stream);
- break;
- case 0x06:
+ else if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-15-C"))
ret = avdtp_open(session, stream);
- break;
- default:
+ else if (g_str_equal(context->data->test_name, "/TP/SIG/SMG/BV-17-C"))
+ ret = avdtp_open(session, stream);
+ else
g_assert_not_reached();
- }
g_assert_cmpint(ret, ==, 0);
}
@@ -271,11 +311,7 @@ static void sep_open_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
g_assert(err == NULL);
- ret = open("/dev/null", O_RDWR, 0);
- if (ret < 0)
- g_assert_not_reached();
-
- avdtp_stream_set_transport(stream, ret, 672, 672);
+ g_assert(transport_open(stream));
ret = avdtp_start(session, stream);
g_assert_cmpint(ret, ==, 0);
@@ -288,22 +324,17 @@ static struct avdtp_sep_cfm sep_cfm = {
static void test_server(gconstpointer data)
{
- const struct test_data *test = data;
- struct context *context = create_context(0x0100);
+ struct context *context = create_context(0x0100, data);
struct avdtp_local_sep *sep;
- context->pdu_list = test->pdu_list;
-
sep = avdtp_register_sep(AVDTP_SEP_TYPE_SOURCE, AVDTP_MEDIA_TYPE_AUDIO,
- 0x00, TRUE, &sep_ind, NULL, NULL);
+ 0x00, TRUE, &sep_ind, NULL, context);
g_idle_add(send_pdu, context);
execute_context(context);
avdtp_unregister_sep(sep);
-
- g_free(test->pdu_list);
}
static void discover_cb(struct avdtp *session, GSList *seps,
@@ -352,40 +383,27 @@ static void discover_cb(struct avdtp *session, GSList *seps,
static void test_discover(gconstpointer data)
{
- const struct test_data *test = data;
- struct context *context = create_context(0x0100);
-
- context->pdu_list = test->pdu_list;
+ struct context *context = create_context(0x0100, data);
avdtp_discover(context->session, discover_cb, NULL);
execute_context(context);
-
- g_free(test->pdu_list);
}
static void test_get_capabilities(gconstpointer data)
{
- const struct test_data *test = data;
- struct context *context = create_context(0x0100);
-
- context->pdu_list = test->pdu_list;
+ struct context *context = create_context(0x0100, data);
avdtp_discover(context->session, discover_cb, NULL);
execute_context(context);
-
- g_free(test->pdu_list);
}
static void test_set_configuration(gconstpointer data)
{
- const struct test_data *test = data;
- struct context *context = create_context(0x0100);
+ struct context *context = create_context(0x0100, data);
struct avdtp_local_sep *sep;
- context->pdu_list = test->pdu_list;
-
sep = avdtp_register_sep(AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
0x00, FALSE, NULL, NULL, NULL);
context->sep = sep;
@@ -395,18 +413,13 @@ static void test_set_configuration(gconstpointer data)
execute_context(context);
avdtp_unregister_sep(sep);
-
- g_free(test->pdu_list);
}
static void test_get_configuration(gconstpointer data)
{
- const struct test_data *test = data;
- struct context *context = create_context(0x0100);
+ struct context *context = create_context(0x0100, data);
struct avdtp_local_sep *sep;
- context->pdu_list = test->pdu_list;
-
sep = avdtp_register_sep(AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
0x00, FALSE, NULL, &sep_cfm,
context);
@@ -417,18 +430,13 @@ static void test_get_configuration(gconstpointer data)
execute_context(context);
avdtp_unregister_sep(sep);
-
- g_free(test->pdu_list);
}
static void test_open(gconstpointer data)
{
- const struct test_data *test = data;
- struct context *context = create_context(0x0100);
+ struct context *context = create_context(0x0100, data);
struct avdtp_local_sep *sep;
- context->pdu_list = test->pdu_list;
-
sep = avdtp_register_sep(AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
0x00, FALSE, NULL, &sep_cfm,
context);
@@ -439,18 +447,13 @@ static void test_open(gconstpointer data)
execute_context(context);
avdtp_unregister_sep(sep);
-
- g_free(test->pdu_list);
}
static void test_start(gconstpointer data)
{
- const struct test_data *test = data;
- struct context *context = create_context(0x0100);
+ struct context *context = create_context(0x0100, data);
struct avdtp_local_sep *sep;
- context->pdu_list = test->pdu_list;
-
sep = avdtp_register_sep(AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
0x00, FALSE, NULL, &sep_cfm,
context);
@@ -461,8 +464,6 @@ static void test_start(gconstpointer data)
execute_context(context);
avdtp_unregister_sep(sep);
-
- g_free(test->pdu_list);
}
int main(int argc, char *argv[])
@@ -565,6 +566,19 @@ int main(int argc, char *argv[])
raw_pdu(0x10, 0x06, 0x04),
raw_pdu(0x12, 0x06),
raw_pdu(0x20, 0x07, 0x04));
+ define_test("/TP/SIG/SMG/BV-18-C", test_server,
+ raw_pdu(0x00, 0x01),
+ raw_pdu(0x02, 0x01, 0x04, 0x00),
+ raw_pdu(0x10, 0x02, 0x04),
+ raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
+ 0xff, 0xff, 0x02, 0x40),
+ raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
+ 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
+ raw_pdu(0x22, 0x03),
+ raw_pdu(0x30, 0x06, 0x04),
+ raw_pdu(0x32, 0x06),
+ raw_pdu(0x40, 0x07, 0x04),
+ raw_pdu(0x42, 0x07));
return g_test_run();
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH v2 13/20] unit/AVDTP: Add /TP/SIG/SMG/BV-17-C test
From: Luiz Augusto von Dentz @ 2013-11-25 14:54 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385391283-10962-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Verify that the IUT (INT) is able to start a streaming procedure after
the stream establishment is complete, by issuing the AVDTP_START_CMD,
reporting the replied confirmation and streaming packets.
---
unit/test-avdtp.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index 2bf782c..7d2c7bc 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -30,6 +30,7 @@
#include <stdbool.h>
#include <inttypes.h>
#include <string.h>
+#include <fcntl.h>
#include <sys/socket.h>
#include <glib.h>
@@ -262,8 +263,27 @@ static void sep_setconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
g_assert_cmpint(ret, ==, 0);
}
+static void sep_open_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
+ struct avdtp_stream *stream, struct avdtp_error *err,
+ void *user_data)
+{
+ int ret;
+
+ g_assert(err == NULL);
+
+ ret = open("/dev/null", O_RDWR, 0);
+ if (ret < 0)
+ g_assert_not_reached();
+
+ avdtp_stream_set_transport(stream, ret, 672, 672);
+
+ ret = avdtp_start(session, stream);
+ g_assert_cmpint(ret, ==, 0);
+}
+
static struct avdtp_sep_cfm sep_cfm = {
.set_configuration = sep_setconf_cfm,
+ .open = sep_open_cfm,
};
static void test_server(gconstpointer data)
@@ -423,6 +443,28 @@ static void test_open(gconstpointer data)
g_free(test->pdu_list);
}
+static void test_start(gconstpointer data)
+{
+ const struct test_data *test = data;
+ struct context *context = create_context(0x0100);
+ struct avdtp_local_sep *sep;
+
+ context->pdu_list = test->pdu_list;
+
+ sep = avdtp_register_sep(AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
+ 0x00, FALSE, NULL, &sep_cfm,
+ context);
+ context->sep = sep;
+
+ avdtp_discover(context->session, discover_cb, context);
+
+ execute_context(context);
+
+ avdtp_unregister_sep(sep);
+
+ g_free(test->pdu_list);
+}
+
int main(int argc, char *argv[])
{
g_test_init(&argc, &argv, NULL);
@@ -511,6 +553,18 @@ int main(int argc, char *argv[])
raw_pdu(0x22, 0x03),
raw_pdu(0x30, 0x06, 0x04),
raw_pdu(0x32, 0x06));
+ define_test("/TP/SIG/SMG/BV-17-C", test_start,
+ raw_pdu(0xe0, 0x01),
+ raw_pdu(0xe2, 0x01, 0x04, 0x00),
+ raw_pdu(0xf0, 0x02, 0x04),
+ raw_pdu(0xf2, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
+ 0xff, 0xff, 0x02, 0x40),
+ raw_pdu(0x00, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
+ 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
+ raw_pdu(0x02, 0x03),
+ raw_pdu(0x10, 0x06, 0x04),
+ raw_pdu(0x12, 0x06),
+ raw_pdu(0x20, 0x07, 0x04));
return g_test_run();
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH v2 12/20] unit/AVDTP: Add /TP/SIG/SMG/BV-16-C test
From: Luiz Augusto von Dentz @ 2013-11-25 14:54 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385391283-10962-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Verify that the IUT (ACP) reports the reception of valid AVDTP_OPEN_CMD
for transport sessions associated to a SEP and replies the returned
confirmation.
---
unit/test-avdtp.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index 4e46987..2bf782c 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -500,6 +500,17 @@ int main(int argc, char *argv[])
0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
raw_pdu(0xc2, 0x03),
raw_pdu(0xd0, 0x06, 0x04));
+ define_test("/TP/SIG/SMG/BV-16-C", test_server,
+ raw_pdu(0x00, 0x01),
+ raw_pdu(0x02, 0x01, 0x04, 0x00),
+ raw_pdu(0x10, 0x02, 0x04),
+ raw_pdu(0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
+ 0xff, 0xff, 0x02, 0x40),
+ raw_pdu(0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
+ 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
+ raw_pdu(0x22, 0x03),
+ raw_pdu(0x30, 0x06, 0x04),
+ raw_pdu(0x32, 0x06));
return g_test_run();
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH v2 11/20] unit/AVDTP: Add /TP/SIG/SMG/BV-15-C test
From: Luiz Augusto von Dentz @ 2013-11-25 14:54 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1385391283-10962-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Verify that the IUT (INT) is able to establish a stream connection to a
previously configured remote SEP by establishing one L2CAP channel
(AVDTP_OPEN_CMD), and reports the related confirmation.
---
unit/test-avdtp.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 54 insertions(+), 2 deletions(-)
diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index a266819..4e46987 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -40,7 +40,7 @@
struct test_pdu {
bool valid;
- const void *data;
+ const uint8_t *data;
size_t size;
};
@@ -234,11 +234,31 @@ static void sep_setconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
struct avdtp_stream *stream,
struct avdtp_error *err, void *user_data)
{
+ struct context *context = user_data;
+ const struct test_pdu *pdu;
int ret;
g_assert(err == NULL);
- ret = avdtp_get_configuration(session, stream);
+ if (!context)
+ return;
+
+ pdu = &context->pdu_list[context->pdu_offset];
+
+ if (pdu->size < 2)
+ return;
+
+ switch (pdu->data[1]) {
+ case 0x04:
+ ret = avdtp_get_configuration(session, stream);
+ break;
+ case 0x06:
+ ret = avdtp_open(session, stream);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+
g_assert_cmpint(ret, ==, 0);
}
@@ -381,6 +401,28 @@ static void test_get_configuration(gconstpointer data)
g_free(test->pdu_list);
}
+static void test_open(gconstpointer data)
+{
+ const struct test_data *test = data;
+ struct context *context = create_context(0x0100);
+ struct avdtp_local_sep *sep;
+
+ context->pdu_list = test->pdu_list;
+
+ sep = avdtp_register_sep(AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
+ 0x00, FALSE, NULL, &sep_cfm,
+ context);
+ context->sep = sep;
+
+ avdtp_discover(context->session, discover_cb, context);
+
+ execute_context(context);
+
+ avdtp_unregister_sep(sep);
+
+ g_free(test->pdu_list);
+}
+
int main(int argc, char *argv[])
{
g_test_init(&argc, &argv, NULL);
@@ -448,6 +490,16 @@ int main(int argc, char *argv[])
raw_pdu(0x30, 0x04, 0x04),
raw_pdu(0x32, 0x04, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
0x21, 0x02, 0x02, 0x20));
+ define_test("/TP/SIG/SMG/BV-15-C", test_open,
+ raw_pdu(0xa0, 0x01),
+ raw_pdu(0xa2, 0x01, 0x04, 0x00),
+ raw_pdu(0xb0, 0x02, 0x04),
+ raw_pdu(0xb2, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
+ 0xff, 0xff, 0x02, 0x40),
+ raw_pdu(0xc0, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
+ 0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
+ raw_pdu(0xc2, 0x03),
+ raw_pdu(0xd0, 0x06, 0x04));
return g_test_run();
}
--
1.8.3.1
^ 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