Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [PATCH 1/4] android: Add CAP_NET_RAW capability
From: Johan Hedberg @ 2013-11-25 14:01 UTC (permalink / raw)
  To: Ravi kumar Veeramally; +Cc: linux-bluetooth
In-Reply-To: <1385387369-3015-2-git-send-email-ravikumar.veeramally@linux.intel.com>

Hi Ravi,

On Mon, Nov 25, 2013, Ravi kumar Veeramally wrote:
> CAP_NET_RAW capability is required to up the bnep interfaces
> in android environment.
> ---
>  android/main.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/android/main.c b/android/main.c
> index c9733f3..bfd2a87 100644
> --- a/android/main.c
> +++ b/android/main.c
> @@ -506,6 +506,7 @@ static bool set_capabilities(void)
>  	header.pid = 0;
>  
>  	cap.effective = cap.permitted =
> +		CAP_TO_MASK(CAP_NET_RAW) |
>  		CAP_TO_MASK(CAP_NET_ADMIN) |
>  		CAP_TO_MASK(CAP_NET_BIND_SERVICE);
>  	cap.inheritable = 0;

Would you then say that commit 9bda7e8c2130de9a3340ebd0e6cc1dedc2eae338
is incorrect? A quick grep doesn't show any instances of checking this
capability in the BNEP code of the kernel. Exactly which system call is
it that needs it?

If you answered positively to my first question, please send a patch for
that as well.

Johan

^ permalink raw reply

* [PATCH 4/4] android/pan: Implement the get local role method in daemon
From: Ravi kumar Veeramally @ 2013-11-25 13:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1385387369-3015-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Returns local role of the device (NONE, PANU or NAP).
---
 android/pan.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/android/pan.c b/android/pan.c
index 74c27c0..b443b3e 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -364,11 +364,17 @@ static uint8_t bt_pan_enable(struct hal_cmd_pan_enable *cmd, uint16_t len)
 	return HAL_STATUS_FAILED;
 }
 
-static uint8_t bt_pan_get_role(void *cmd, uint16_t len)
+static uint8_t bt_pan_get_role(int sk, void *cmd, uint16_t len)
 {
-	DBG("Not Implemented");
+	struct hal_rsp_pan_get_role rsp;
 
-	return HAL_STATUS_FAILED;
+	DBG("");
+
+	rsp.local_role = local_role;
+	ipc_send(sk, HAL_SERVICE_ID_PAN, HAL_OP_PAN_GET_ROLE, sizeof(rsp),
+								&rsp, -1);
+
+	return HAL_STATUS_SUCCESS;
 }
 
 void bt_pan_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len)
@@ -380,7 +386,7 @@ void bt_pan_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len)
 		status = bt_pan_enable(buf, len);
 		break;
 	case HAL_OP_PAN_GET_ROLE:
-		status = bt_pan_get_role(buf, len);
+		status = bt_pan_get_role(sk, buf, len);
 		break;
 	case HAL_OP_PAN_CONNECT:
 		status = bt_pan_connect(buf, len);
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 3/4] android/pan: Implement pan disconnect method in daemon
From: Ravi kumar Veeramally @ 2013-11-25 13:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1385387369-3015-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Disconnect ongoing PANU role connection betweek devices, free
the device and notify the connection state.
---
 android/pan.c | 59 +++++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 45 insertions(+), 14 deletions(-)

diff --git a/android/pan.c b/android/pan.c
index b1d0e15..74c27c0 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -270,20 +270,6 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer data)
 							bnep_setup_cb, np);
 }
 
-static uint8_t bt_pan_enable(struct hal_cmd_pan_enable *cmd, uint16_t len)
-{
-	DBG("Not Implemented");
-
-	return HAL_STATUS_FAILED;
-}
-
-static uint8_t bt_pan_get_role(void *cmd, uint16_t len)
-{
-	DBG("Not Implemented");
-
-	return HAL_STATUS_FAILED;
-}
-
 static uint8_t bt_pan_connect(struct hal_cmd_pan_connect *cmd, uint16_t len)
 {
 	struct network_peer *np;
@@ -335,6 +321,51 @@ static uint8_t bt_pan_connect(struct hal_cmd_pan_connect *cmd, uint16_t len)
 static uint8_t bt_pan_disconnect(struct hal_cmd_pan_disconnect *cmd,
 								uint16_t len)
 {
+	struct network_peer *np;
+	GSList *l;
+	bdaddr_t dst;
+
+	DBG("");
+
+	if (len < sizeof(*cmd))
+		return HAL_STATUS_INVALID;
+
+	android2bdaddr(&cmd->bdaddr, &dst);
+
+	l = g_slist_find_custom(peers, &dst, peer_cmp);
+	if (!l)
+		return HAL_STATUS_FAILED;
+
+	np = l->data;
+
+	if (np->conn_state == HAL_PAN_STATE_CONNECTED) {
+		if (np->watch) {
+			g_source_remove(np->watch);
+			np->watch = 0;
+		}
+
+		bnep_if_down(np->dev);
+		bnep_kill_connection(&dst);
+		bt_pan_notify_conn_state(np, HAL_PAN_STATE_DISCONNECTED);
+		network_peer_free(np);
+
+	} else if (np->io) {
+		bt_pan_notify_conn_state(np, HAL_PAN_STATE_DISCONNECTING);
+		g_io_channel_shutdown(np->io, TRUE, NULL);
+	}
+
+	return HAL_STATUS_SUCCESS;
+}
+
+static uint8_t bt_pan_enable(struct hal_cmd_pan_enable *cmd, uint16_t len)
+{
+	DBG("Not Implemented");
+
+	return HAL_STATUS_FAILED;
+}
+
+static uint8_t bt_pan_get_role(void *cmd, uint16_t len)
+{
 	DBG("Not Implemented");
 
 	return HAL_STATUS_FAILED;
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 2/4] android/pan: Implement pan connect method in daemon
From: Ravi kumar Veeramally @ 2013-11-25 13:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1385387369-3015-1-git-send-email-ravikumar.veeramally@linux.intel.com>

Implements the PAN connect method in android daemon with PANU role
only. Setting up the bnep environment, adds connection and makes
bnep interface up. Notifies bnep interface on control state call back
and connection status on connection state call back.
---
 android/Android.mk  |   2 +
 android/Makefile.am |   3 +-
 android/pan.c       | 289 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 291 insertions(+), 3 deletions(-)

diff --git a/android/Android.mk b/android/Android.mk
index 616a338..4555284 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -41,6 +41,7 @@ LOCAL_SRC_FILES := \
 	../lib/hci.c \
 	../btio/btio.c \
 	../src/sdp-client.c \
+	../profiles/network/common.c \
 
 LOCAL_C_INCLUDES := \
 	$(call include-path-for, glib) \
@@ -65,6 +66,7 @@ lib_headers := \
 	sdp.h \
 	rfcomm.h \
 	sco.h \
+	bnep.h \
 
 $(shell mkdir -p $(LOCAL_PATH)/../lib/bluetooth)
 
diff --git a/android/Makefile.am b/android/Makefile.am
index 5f6b1a3..5d13434 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -23,7 +23,8 @@ android_bluetoothd_SOURCES = android/main.c \
 				android/socket.h android/socket.c \
 				android/pan.h android/pan.c \
 				btio/btio.h btio/btio.c \
-				src/sdp-client.h src/sdp-client.c
+				src/sdp-client.h src/sdp-client.c \
+				profiles/network/common.c profiles/network/common.h
 
 android_bluetoothd_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
 
diff --git a/android/pan.c b/android/pan.c
index ada458a..b1d0e15 100644
--- a/android/pan.c
+++ b/android/pan.c
@@ -29,13 +29,246 @@
 #include <fcntl.h>
 #include <glib.h>
 
+#include "btio/btio.h"
 #include "lib/bluetooth.h"
+#include "lib/bnep.h"
+#include "lib/sdp.h"
+#include "lib/sdp_lib.h"
+#include "src/glib-helper.h"
+#include "profiles/network/common.h"
+
 #include "log.h"
 #include "pan.h"
 #include "hal-msg.h"
 #include "ipc.h"
+#include "utils.h"
+#include "bluetooth.h"
 
+static bdaddr_t adapter_addr;
 static int notification_sk = -1;
+GSList *peers = NULL;
+uint8_t local_role = HAL_PAN_ROLE_NONE;
+
+struct network_peer {
+	char		dev[16];
+	bdaddr_t	dst;
+	uint8_t		conn_state;
+	uint8_t		role;
+	GIOChannel	*io;
+	guint		watch;
+};
+
+struct __service_16 {
+	 uint16_t dst;
+	uint16_t src;
+} __attribute__ ((packed));
+
+static int peer_cmp(gconstpointer s, gconstpointer user_data)
+{
+	const struct network_peer *np = s;
+	const bdaddr_t *dst = user_data;
+
+	return bacmp(&np->dst, dst);
+}
+
+static void network_peer_free(struct network_peer *np)
+{
+	local_role = HAL_PAN_ROLE_NONE;
+
+	if (np->watch > 0) {
+		g_source_remove(np->watch);
+		np->watch = 0;
+	}
+
+	if (np->io) {
+		g_io_channel_unref(np->io);
+		np->io = NULL;
+	}
+
+	peers = g_slist_remove(peers, np);
+	g_free(np);
+}
+
+static void bt_pan_notify_conn_state(struct network_peer *np, uint8_t state)
+{
+	struct hal_ev_pan_conn_state ev;
+	char addr[18];
+
+	if (np->conn_state == state)
+		return;
+
+	np->conn_state = state;
+	ba2str(&np->dst, addr);
+	DBG("device %s state %u", addr, state);
+
+	bdaddr2android(&np->dst, ev.bdaddr);
+	ev.state = state;
+	ev.local_role = local_role;
+	ev.remote_role = np->role;
+	ev.status = HAL_STATUS_SUCCESS;
+
+	ipc_send(notification_sk, HAL_SERVICE_ID_PAN, HAL_EV_PAN_CONN_STATE,
+							sizeof(ev), &ev, -1);
+}
+
+static void bt_pan_notify_ctrl_state(struct network_peer *np, uint8_t state)
+{
+	struct hal_ev_pan_ctrl_state ev;
+
+	DBG("");
+
+	ev.state = state;
+	ev.local_role = local_role;
+	ev.status = HAL_STATUS_SUCCESS;
+	memcpy(ev.name, np->dev, sizeof(np->dev));
+
+	ipc_send(notification_sk, HAL_SERVICE_ID_PAN, HAL_EV_PAN_CTRL_STATE,
+							sizeof(ev), &ev, -1);
+}
+
+static gboolean bnep_watchdog_cb(GIOChannel *chan, GIOCondition cond,
+								gpointer data)
+{
+	struct network_peer *np = data;
+
+	DBG("%s disconnected", np->dev);
+
+	bnep_if_down(np->dev);
+	bt_pan_notify_conn_state(np, HAL_PAN_STATE_DISCONNECTED);
+	network_peer_free(np);
+
+	return FALSE;
+}
+
+static gboolean bnep_setup_cb(GIOChannel *chan, GIOCondition cond,
+								gpointer data)
+{
+	struct network_peer *np = data;
+	struct bnep_control_rsp *rsp;
+	struct timeval timeo;
+	char pkt[BNEP_MTU];
+	uint16_t bnep_role;
+	ssize_t r;
+	int sk;
+
+	DBG("cond %u", cond);
+
+	if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) {
+		error("Hangup or error ir invalid on l2cap server socket");
+		goto failed;
+	}
+
+	sk = g_io_channel_unix_get_fd(chan);
+	memset(pkt, 0, BNEP_MTU);
+
+	r = read(sk, pkt, sizeof(pkt) - 1);
+	if (r < 0) {
+		error("IO Channel read error");
+		goto failed;
+	}
+
+	if (r == 0) {
+		error("No packet received on l2cap socket");
+		goto failed;
+	}
+
+	errno = EPROTO;
+
+	if ((size_t) r < sizeof(*rsp)) {
+		error("Packet received is not bnep type");
+		goto failed;
+	}
+
+	rsp = (void *) pkt;
+	if (rsp->type != BNEP_CONTROL) {
+		error("Packet received is not bnep type");
+		goto failed;
+	}
+
+	if (rsp->ctrl != BNEP_SETUP_CONN_RSP) {
+		DBG("rsp->ctrl != BNEP_SETUP_CONN_RSP");
+		return TRUE;
+	}
+
+	r = ntohs(rsp->resp);
+
+	if (r != BNEP_SUCCESS) {
+		error("bnep failed");
+		goto failed;
+	}
+
+	memset(&timeo, 0, sizeof(timeo));
+	timeo.tv_sec = 0;
+
+	setsockopt(sk, SOL_SOCKET, SO_RCVTIMEO, &timeo, sizeof(timeo));
+	bnep_role = (local_role == HAL_PAN_ROLE_PANU) ? BNEP_SVC_PANU :
+								BNEP_SVC_NAP;
+
+	if (bnep_connadd(sk, bnep_role, np->dev))
+		goto failed;
+
+	if (bnep_if_up(np->dev)) {
+		bnep_kill_connection(&np->dst);
+		goto failed;
+	}
+
+	bt_pan_notify_ctrl_state(np, HAL_PAN_CTRL_ENABLED);
+	bt_pan_notify_conn_state(np, HAL_PAN_STATE_CONNECTED);
+
+	DBG("%s connected", np->dev);
+
+	/* Start watchdog */
+	np->watch = g_io_add_watch(chan, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+						(GIOFunc) bnep_watchdog_cb, np);
+	g_io_channel_unref(np->io);
+	np->io = NULL;
+
+	return FALSE;
+
+failed:
+	bt_pan_notify_conn_state(np, HAL_PAN_STATE_DISCONNECTED);
+	network_peer_free(np);
+	return FALSE;
+}
+
+static void connect_cb(GIOChannel *chan, GError *err, gpointer data)
+{
+	struct network_peer *np = data;
+	struct bnep_setup_conn_req *req;
+	struct __service_16 *s;
+	unsigned char pkt[BNEP_MTU];
+	int fd;
+
+	DBG("");
+
+	if (err) {
+		error("%s", err->message);
+		bt_pan_notify_conn_state(np, HAL_PAN_STATE_DISCONNECTED);
+		network_peer_free(np);
+	}
+
+	/* Send request */
+	req = (void *) pkt;
+	req->type = BNEP_CONTROL;
+	req->ctrl = BNEP_SETUP_CONN_REQ;
+	req->uuid_size = 2;     /* 16bit UUID */
+	s = (void *) req->service;
+	s->dst = (np->role == HAL_PAN_ROLE_NAP) ? htons(BNEP_SVC_NAP) :
+							htons(BNEP_SVC_PANU);
+	s->src = (local_role == HAL_PAN_ROLE_NAP) ? htons(BNEP_SVC_NAP) :
+							htons(BNEP_SVC_PANU);
+
+	fd = g_io_channel_unix_get_fd(np->io);
+	if (write(fd, pkt, sizeof(*req) + sizeof(*s)) < 0) {
+		error("bnep connection req send failed: %s", strerror(errno));
+		bt_pan_notify_conn_state(np, HAL_PAN_STATE_DISCONNECTED);
+		network_peer_free(np);
+		return;
+	}
+
+	g_io_add_watch(np->io, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+							bnep_setup_cb, np);
+}
 
 static uint8_t bt_pan_enable(struct hal_cmd_pan_enable *cmd, uint16_t len)
 {
@@ -53,9 +286,50 @@ static uint8_t bt_pan_get_role(void *cmd, uint16_t len)
 
 static uint8_t bt_pan_connect(struct hal_cmd_pan_connect *cmd, uint16_t len)
 {
-	DBG("Not Implemented");
+	struct network_peer *np;
+	bdaddr_t dst;
+	char addr[18];
+	GSList *l;
+	GError *gerr = NULL;
 
-	return HAL_STATUS_FAILED;
+	DBG("");
+
+	if (len < sizeof(*cmd))
+		return HAL_STATUS_INVALID;
+
+	android2bdaddr(&cmd->bdaddr, &dst);
+
+	l = g_slist_find_custom(peers, &dst, peer_cmp);
+	if (l)
+		return HAL_STATUS_FAILED;
+
+	np = g_new0(struct network_peer, 1);
+	bacpy(&np->dst, &dst);
+	local_role = cmd->local_role;
+	np->role = cmd->remote_role;
+
+	ba2str(&np->dst, addr);
+	DBG("connecting to %s", addr);
+
+	np->io = bt_io_connect(connect_cb, np, NULL, &gerr,
+					BT_IO_OPT_SOURCE_BDADDR, &adapter_addr,
+					BT_IO_OPT_DEST_BDADDR, &np->dst,
+					BT_IO_OPT_PSM, BNEP_PSM,
+					BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
+					BT_IO_OPT_OMTU, BNEP_MTU,
+					BT_IO_OPT_IMTU, BNEP_MTU,
+					BT_IO_OPT_INVALID);
+	if (!np->io) {
+		error("%s", gerr->message);
+		g_error_free(gerr);
+		g_free(np);
+		return HAL_STATUS_FAILED;
+	}
+
+	peers = g_slist_append(peers, np);
+	bt_pan_notify_conn_state(np, HAL_PAN_STATE_CONNECTING);
+
+	return HAL_STATUS_SUCCESS;
 }
 
 static uint8_t bt_pan_disconnect(struct hal_cmd_pan_disconnect *cmd,
@@ -93,11 +367,21 @@ void bt_pan_handle_cmd(int sk, uint8_t opcode, void *buf, uint16_t len)
 
 bool bt_pan_register(int sk, const bdaddr_t *addr)
 {
+	int err;
+
 	DBG("");
 
 	if (notification_sk >= 0)
 		return false;
 
+	bacpy(&adapter_addr, addr);
+
+	err = bnep_init();
+	if (err) {
+		error("bnep init failed");
+		return false;
+	}
+
 	notification_sk = sk;
 
 	return true;
@@ -111,4 +395,5 @@ void bt_pan_unregister(void)
 		return;
 
 	notification_sk = -1;
+	bnep_cleanup();
 }
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 1/4] android: Add CAP_NET_RAW capability
From: Ravi kumar Veeramally @ 2013-11-25 13:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally
In-Reply-To: <1385387369-3015-1-git-send-email-ravikumar.veeramally@linux.intel.com>

CAP_NET_RAW capability is required to up the bnep interfaces
in android environment.
---
 android/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/android/main.c b/android/main.c
index c9733f3..bfd2a87 100644
--- a/android/main.c
+++ b/android/main.c
@@ -506,6 +506,7 @@ static bool set_capabilities(void)
 	header.pid = 0;
 
 	cap.effective = cap.permitted =
+		CAP_TO_MASK(CAP_NET_RAW) |
 		CAP_TO_MASK(CAP_NET_ADMIN) |
 		CAP_TO_MASK(CAP_NET_BIND_SERVICE);
 	cap.inheritable = 0;
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 0/4] Adds pan connect disconnect and get role methods
From: Ravi kumar Veeramally @ 2013-11-25 13:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Ravi kumar Veeramally

This patch set supports PANU role with a minor fix in android. Added
CAP_NET_RAW capability for bnep services. Creates bnep connection and
up the inreface on connect call and free the device on disconnect call.
Interface name(bnepX) will be notified on control state cb. Android
environment will create IP address with dhcp calls.

Ravi kumar Veeramally (4):
  android: Add CAP_NET_RAW capability
  android/pan: Implement pan connect method in daemon
  android/pan: Implement pan disconnect method in daemon
  android/pan: Implement the get local role method in daemon

 android/Android.mk  |   2 +
 android/Makefile.am |   3 +-
 android/main.c      |   1 +
 android/pan.c       | 340 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 4 files changed, 336 insertions(+), 10 deletions(-)

-- 
1.8.3.2


^ permalink raw reply

* Re: [PATCH 1/3] sdptool: Fix memory leaks creating OPP record
From: Johan Hedberg @ 2013-11-25 13:42 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1385385285-30592-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Mon, Nov 25, 2013, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> ---
>  tools/sdptool.c | 3 +++
>  1 file changed, 3 insertions(+)

All three patches have been applied, however don't hesitate to also send
patches to fix using 0 instead of NULL for pointers.

Johan

^ permalink raw reply

* Re: [PATCHv9 18/21] android/socket: Use security level for connect
From: Johan Hedberg @ 2013-11-25 13:40 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1385384937-29858-19-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Mon, Nov 25, 2013, Andrei Emeltchenko wrote:
> Use low security level for connections without profile and default
> sec_level for others. rfsock now has pointer to profile info for
> outcoming connections.
> ---
>  android/socket.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)

Patches 1-17 have been applied, but I can't apply from this one onwards
since the default security level should be MEDIUM and not LOW. OPP is
the only exception that should have LOW and SAP the only exception that
should have HIGH.

Johan

^ permalink raw reply

* Re: [PATCH] Adding paired-devices cmd to the bluetoothctl
From: Johan Hedberg @ 2013-11-25 13:24 UTC (permalink / raw)
  To: Szymon Janc; +Cc: Sebastian, linux-bluetooth, Sebastian Chlad
In-Reply-To: <7144304.2MX7gdvi4Y@uw000953>

Hi Szymon,

On Mon, Nov 25, 2013, Szymon Janc wrote:
> > Paired-devices command lists only paired devices
> > ---
> >  client/main.c | 22 ++++++++++++++++++++++
> >  1 file changed, 22 insertions(+)
> > 
> > diff --git a/client/main.c b/client/main.c
> > index 0dd1510..c39ebf8 100644
> > --- a/client/main.c
> > +++ b/client/main.c
> > @@ -538,6 +538,26 @@ static void cmd_devices(const char *arg)
> >  	}
> >  }
> >  
> > +static void cmd_devices_paired(const char *arg)
> > +{
> > +	GList *list;
> > +
> > +	for (list = g_list_first(dev_list); list; list = g_list_next(list)) {
> > +		DBusMessageIter iter;
> > +		GDBusProxy *proxy = list->data;
> > +		dbus_bool_t paired;
> > +
> > +		if (g_dbus_proxy_get_property(proxy, "Paired", &iter) == FALSE)
> > +			return;
> > +		dbus_message_iter_get_basic(&iter, &paired);
> > +
> > +		if (!paired)
> > +			break;
> 
> Shouldn't this be
>   if (!paired)
>       continue;
> 
> ? Or paired devices are guaranteed to be first on list?

They're not, and the same goes the for return statement in case
g_dbus_proxy_get_property fails. Since this was the last patch pushed I
did a git commit --amend + git push --force to avoid a fixup patch.

Johan

^ permalink raw reply

* [PATCH 3/3] sdptool: Make code consistent for SPP record add
From: Andrei Emeltchenko @ 2013-11-25 13:14 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385385285-30592-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Move freeing to the end of the function like it is done for other
records.
---
 tools/sdptool.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/sdptool.c b/tools/sdptool.c
index 6682612..b4b65ec 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -1174,18 +1174,15 @@ static int add_sp(sdp_session_t *session, svc_info_t *si)
 	sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
 	root = sdp_list_append(0, &root_uuid);
 	sdp_set_browse_groups(&record, root);
-	sdp_list_free(root, 0);
 
 	sdp_uuid16_create(&sp_uuid, SERIAL_PORT_SVCLASS_ID);
 	svclass_id = sdp_list_append(0, &sp_uuid);
 	sdp_set_service_classes(&record, svclass_id);
-	sdp_list_free(svclass_id, 0);
 
 	sdp_uuid16_create(&profile.uuid, SERIAL_PORT_PROFILE_ID);
 	profile.version = 0x0100;
 	profiles = sdp_list_append(0, &profile);
 	sdp_set_profile_descs(&record, profiles);
-	sdp_list_free(profiles, 0);
 
 	sdp_uuid16_create(&l2cap, L2CAP_UUID);
 	proto[0] = sdp_list_append(0, &l2cap);
@@ -1226,6 +1223,9 @@ end:
 	sdp_list_free(proto[1], 0);
 	sdp_list_free(apseq, 0);
 	sdp_list_free(aproto, 0);
+	sdp_list_free(root, 0);
+	sdp_list_free(svclass_id, 0);
+	sdp_list_free(profiles, 0);
 
 	return ret;
 }
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 2/3] sdptool: Fix memory leaks creating PBAP record
From: Andrei Emeltchenko @ 2013-11-25 13:14 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385385285-30592-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 tools/sdptool.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/sdptool.c b/tools/sdptool.c
index 78dc281..6682612 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -1888,7 +1888,10 @@ end:
 	sdp_list_free(proto[1], 0);
 	sdp_list_free(proto[2], 0);
 	sdp_list_free(apseq, 0);
+	sdp_list_free(pfseq, 0);
 	sdp_list_free(aproto, 0);
+	sdp_list_free(root, 0);
+	sdp_list_free(svclass_id, 0);
 
 	return ret;
 }
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH 1/3] sdptool: Fix memory leaks creating OPP record
From: Andrei Emeltchenko @ 2013-11-25 13:14 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

---
 tools/sdptool.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/sdptool.c b/tools/sdptool.c
index f985b1e..78dc281 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -1813,7 +1813,10 @@ end:
 	sdp_list_free(proto[1], 0);
 	sdp_list_free(proto[2], 0);
 	sdp_list_free(apseq, 0);
+	sdp_list_free(pfseq, 0);
 	sdp_list_free(aproto, 0);
+	sdp_list_free(root, 0);
+	sdp_list_free(svclass_id, NULL);
 
 	return ret;
 }
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH BlueZ 19/19] unit/AVDTP: Add /TP/SIG/SMG/BV-24-C test
From: Luiz Augusto von Dentz @ 2013-11-25 13:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385385070-21010-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 BlueZ 18/19] unit/AVDTP: Add /TP/SIG/SMG/BV-23-C test
From: Luiz Augusto von Dentz @ 2013-11-25 13:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385385070-21010-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 BlueZ 17/19] unit/AVDTP: Add /TP/SIG/SMG/BV-22-C test
From: Luiz Augusto von Dentz @ 2013-11-25 13:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385385070-21010-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 BlueZ 16/19] unit/AVDTP: Add /TP/SIG/SMG/BV-21-C test
From: Luiz Augusto von Dentz @ 2013-11-25 13:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385385070-21010-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 BlueZ 15/19] unit/AVDTP: Add /TP/SIG/SMG/BV-20-C test
From: Luiz Augusto von Dentz @ 2013-11-25 13:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385385070-21010-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 BlueZ 14/19] unit/AVDTP: Add /TP/SIG/SMG/BV-19-C test
From: Luiz Augusto von Dentz @ 2013-11-25 13:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385385070-21010-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 BlueZ 13/19] unit/AVDTP: Add /TP/SIG/SMG/BV-18-C test
From: Luiz Augusto von Dentz @ 2013-11-25 13:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385385070-21010-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 BlueZ 12/19] unit/AVDTP: Add /TP/SIG/SMG/BV-17-C test
From: Luiz Augusto von Dentz @ 2013-11-25 13:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385385070-21010-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 BlueZ 11/19] unit/AVDTP: Add /TP/SIG/SMG/BV-16-C test
From: Luiz Augusto von Dentz @ 2013-11-25 13:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385385070-21010-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 BlueZ 10/19] unit/AVDTP: Add /TP/SIG/SMG/BV-15-C test
From: Luiz Augusto von Dentz @ 2013-11-25 13:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385385070-21010-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

* [PATCH BlueZ 09/19] unit/AVDTP: Add /TP/SIG/SMG/BV-12-C test
From: Luiz Augusto von Dentz @ 2013-11-25 13:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385385070-21010-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 a valid get
configuration command for remote SEP and replies the returned
configuration.
---
 unit/test-avdtp.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index 1f43c08..a266819 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -368,7 +368,8 @@ static void test_get_configuration(gconstpointer data)
 	context->pdu_list = test->pdu_list;
 
 	sep = avdtp_register_sep(AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
-					0x00, FALSE, &sep_ind, &sep_cfm, NULL);
+					0x00, FALSE, NULL, &sep_cfm,
+					context);
 	context->sep = sep;
 
 	avdtp_discover(context->session, discover_cb, context);
@@ -435,6 +436,18 @@ int main(int argc, char *argv[])
 				0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
 			raw_pdu(0x82, 0x03),
 			raw_pdu(0x90, 0x04, 0x04));
+	define_test("/TP/SIG/SMG/BV-12-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, 0x04, 0x04),
+			raw_pdu(0x32, 0x04, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
+				0x21, 0x02, 0x02, 0x20));
 
 	return g_test_run();
 }
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH BlueZ 08/19] unit/AVDTP: Add /TP/SIG/SMG/BV-11-C test
From: Luiz Augusto von Dentz @ 2013-11-25 13:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385385070-21010-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 issue a valid get configuration
command for remote SEP and report the replied configuration.
---
 unit/test-avdtp.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index e39ed24..1f43c08 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -230,6 +230,22 @@ static struct avdtp_sep_ind sep_ind = {
 	.get_capability		= sep_getcap_ind,
 };
 
+static void sep_setconf_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_get_configuration(session, stream);
+	g_assert_cmpint(ret, ==, 0);
+}
+
+static struct avdtp_sep_cfm sep_cfm = {
+	.set_configuration	= sep_setconf_cfm,
+};
+
 static void test_server(gconstpointer data)
 {
 	const struct test_data *test = data;
@@ -343,6 +359,27 @@ static void test_set_configuration(gconstpointer data)
 	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 avdtp_local_sep *sep;
+
+	context->pdu_list = test->pdu_list;
+
+	sep = avdtp_register_sep(AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
+					0x00, FALSE, &sep_ind, &sep_cfm, NULL);
+	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);
@@ -388,6 +425,16 @@ 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,
+			raw_pdu(0x60, 0x01),
+			raw_pdu(0x62, 0x01, 0x04, 0x00),
+			raw_pdu(0x70, 0x02, 0x04),
+			raw_pdu(0x72, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00, 0x00,
+				0xff, 0xff, 0x02, 0x40),
+			raw_pdu(0x80, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
+				0x00, 0x00, 0x21, 0x02, 0x02, 0x20),
+			raw_pdu(0x82, 0x03),
+			raw_pdu(0x90, 0x04, 0x04));
 
 	return g_test_run();
 }
-- 
1.8.3.1


^ permalink raw reply related

* [PATCH BlueZ 07/19] unit/AVDTP: Add /TP/SIG/SMG/BV-10-C test
From: Luiz Augusto von Dentz @ 2013-11-25 13:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1385385070-21010-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 a valid set
configuration command for remote SEP, and configures the SEP as
requested and replies the returned confirmation.
---
 unit/test-avdtp.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index b0991d9..e39ed24 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -379,6 +379,15 @@ int main(int argc, char *argv[])
 				0xff, 0xff, 0x02, 0x40),
 			raw_pdu(0x50, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07, 0x06,
 				0x00, 0x00, 0x21, 0x02, 0x02, 0x20));
+	define_test("/TP/SIG/SMG/BV-10-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));
 
 	return g_test_run();
 }
-- 
1.8.3.1


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox