Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request
@ 2011-11-11 14:28 Luiz Augusto von Dentz
  2011-11-11 14:28 ` [PATCH obexd 02/12 v3] gobex: add unit test for CONNECT response Luiz Augusto von Dentz
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-11 14:28 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 unit/test-gobex-transfer.c |   57 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index a246418..25c5383 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -65,6 +65,13 @@ static guint8 get_rsp_first[] = { G_OBEX_RSP_CONTINUE | FINAL_BIT, 0x00, 0x10,
 static guint8 get_rsp_last[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x06,
 					G_OBEX_HDR_BODY_END, 0x00, 0x03 };
 
+static guint8 conn_req[] = { G_OBEX_OP_CONNECT | FINAL_BIT, 0x00, 0x07,
+					0x10, 0x00, 0x10, 0x00 };
+static guint8 conn_rsp[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x0c,
+					0x10, 0x00, 0x10, 0x00,
+					G_OBEX_HDR_CONNECTION, 0x00, 0x00,
+					0x00, 0x01 };
+
 static guint8 hdr_type[] = "foo/bar";
 static guint8 body_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
 
@@ -614,10 +621,60 @@ static void test_get_rsp_eagain(void)
 	g_assert_no_error(d.err);
 }
 
+static void conn_complete(GObex *obex, GError *err, GObexPacket *rsp,
+							gpointer user_data)
+{
+	struct test_data *d = user_data;
+
+	if (err != NULL)
+		d->err = g_error_copy(err);
+
+	g_main_loop_quit(d->mainloop);
+}
+
+static void test_conn_req(void)
+{
+	GIOChannel *io;
+	GIOCondition cond;
+	guint io_id, timer_id;
+	GObex *obex;
+	struct test_data d = { 0, NULL, {
+				{ conn_req, sizeof(conn_req) } }, {
+				{ conn_rsp, sizeof(conn_rsp) } } };
+
+	create_endpoints(&obex, &io, SOCK_STREAM);
+	d.obex = obex;
+
+	cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
+	io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+
+	d.mainloop = g_main_loop_new(NULL, FALSE);
+
+	timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+
+	g_obex_connect(obex, conn_complete, &d, &d.err, G_OBEX_HDR_INVALID);
+	g_assert_no_error(d.err);
+
+	g_main_loop_run(d.mainloop);
+
+	g_assert_cmpuint(d.count, ==, 1);
+
+	g_main_loop_unref(d.mainloop);
+
+	g_source_remove(timer_id);
+	g_io_channel_unref(io);
+	g_source_remove(io_id);
+	g_obex_unref(obex);
+
+	g_assert_no_error(d.err);
+}
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
 
+	g_test_add_func("/gobex/test_conn_req", test_conn_req);
+
 	g_test_add_func("/gobex/test_put_req", test_put_req);
 	g_test_add_func("/gobex/test_put_rsp", test_put_rsp);
 
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH obexd 02/12 v3] gobex: add unit test for CONNECT response
  2011-11-11 14:28 [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Luiz Augusto von Dentz
@ 2011-11-11 14:28 ` Luiz Augusto von Dentz
  2011-11-11 14:28 ` [PATCH obexd 03/12 v3] gobex: add unit test for CONNECT followed by GET request Luiz Augusto von Dentz
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-11 14:28 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 unit/test-gobex-transfer.c |   60 ++++++++++++++++++++++++++++++++++++++++++++
 unit/util.c                |    3 ++
 2 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index 25c5383..c711876 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -669,11 +669,71 @@ static void test_conn_req(void)
 	g_assert_no_error(d.err);
 }
 
+static void handle_conn_rsp(GObex *obex, GObexPacket *req,
+						gpointer user_data)
+{
+	struct test_data *d = user_data;
+	guint8 op = g_obex_packet_get_operation(req, NULL);
+	GObexPacket *rsp;
+
+	if (op != G_OBEX_OP_CONNECT) {
+		d->err = g_error_new(TEST_ERROR, TEST_ERROR_UNEXPECTED,
+					"Unexpected opcode 0x%02x", op);
+		g_main_loop_quit(d->mainloop);
+		return;
+	}
+
+	rsp = g_obex_packet_new(G_OBEX_RSP_SUCCESS, TRUE, G_OBEX_HDR_INVALID);
+	g_obex_send(obex, rsp, &d->err);
+}
+
+static void test_conn_rsp(void)
+{
+	GIOChannel *io;
+	GIOCondition cond;
+	guint io_id, timer_id;
+	GObex *obex;
+	struct test_data d = { 0, NULL, {
+			{ conn_rsp, sizeof(conn_rsp) } }, {
+			{ NULL, 0 } } };
+
+	create_endpoints(&obex, &io, SOCK_STREAM);
+	d.obex = obex;
+
+	cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
+	io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+
+	d.mainloop = g_main_loop_new(NULL, FALSE);
+
+	timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+
+	g_obex_add_request_function(obex, G_OBEX_OP_CONNECT,
+						handle_conn_rsp, &d);
+
+	g_io_channel_write_chars(io, (char *) conn_req, sizeof(conn_req),
+								NULL, &d.err);
+	g_assert_no_error(d.err);
+
+	g_main_loop_run(d.mainloop);
+
+	g_assert_cmpuint(d.count, ==, 1);
+
+	g_main_loop_unref(d.mainloop);
+
+	g_source_remove(timer_id);
+	g_io_channel_unref(io);
+	g_source_remove(io_id);
+	g_obex_unref(obex);
+
+	g_assert_no_error(d.err);
+}
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
 
 	g_test_add_func("/gobex/test_conn_req", test_conn_req);
+	g_test_add_func("/gobex/test_conn_rsp", test_conn_rsp);
 
 	g_test_add_func("/gobex/test_put_req", test_put_req);
 	g_test_add_func("/gobex/test_put_rsp", test_put_rsp);
diff --git a/unit/util.c b/unit/util.c
index 630a70e..5788654 100644
--- a/unit/util.c
+++ b/unit/util.c
@@ -166,6 +166,9 @@ gboolean test_io_cb(GIOChannel *io, GIOCondition cond, gpointer user_data)
 		goto failed;
 	}
 
+	if (send_buf_len == 0)
+		goto failed;
+
 	g_io_channel_write_chars(io, send_buf, send_buf_len, &bytes_written,
 									NULL);
 	if (bytes_written != send_buf_len) {
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH obexd 03/12 v3] gobex: add unit test for CONNECT followed by GET request
  2011-11-11 14:28 [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Luiz Augusto von Dentz
  2011-11-11 14:28 ` [PATCH obexd 02/12 v3] gobex: add unit test for CONNECT response Luiz Augusto von Dentz
@ 2011-11-11 14:28 ` Luiz Augusto von Dentz
  2011-11-11 14:28 ` [PATCH obexd 04/12 v3] gobex: add unit test for CONNECT followed by GET response Luiz Augusto von Dentz
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-11 14:28 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 unit/test-gobex-transfer.c |   67 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index c711876..8831d2d 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -72,6 +72,13 @@ static guint8 conn_rsp[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x0c,
 					G_OBEX_HDR_CONNECTION, 0x00, 0x00,
 					0x00, 0x01 };
 
+static guint8 conn_get_req_first[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x28,
+	G_OBEX_HDR_CONNECTION, 0x00, 0x00, 0x00, 0x01,
+	G_OBEX_HDR_TYPE, 0x00, 0x0b,
+	'f', 'o', 'o', '/', 'b', 'a', 'r', '\0',
+	G_OBEX_HDR_NAME, 0x00, 0x15,
+	0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0 };
+
 static guint8 hdr_type[] = "foo/bar";
 static guint8 body_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
 
@@ -728,6 +735,64 @@ static void test_conn_rsp(void)
 	g_assert_no_error(d.err);
 }
 
+static void conn_complete_get_req(GObex *obex, GError *err, GObexPacket *rsp,
+							gpointer user_data)
+{
+	struct test_data *d = user_data;
+
+	if (err != NULL) {
+		d->err = g_error_copy(err);
+		g_main_loop_quit(d->mainloop);
+	}
+
+	g_obex_get_req(obex, rcv_data, transfer_complete, d, &d->err,
+				G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
+				G_OBEX_HDR_NAME, "file.txt",
+				G_OBEX_HDR_INVALID);
+}
+
+static void test_conn_get_req(void)
+{
+	GIOChannel *io;
+	GIOCondition cond;
+	guint io_id, timer_id;
+	GObex *obex;
+	struct test_data d = { 0, NULL, {
+			{ conn_req, sizeof(conn_req) },
+			{ conn_get_req_first, sizeof(conn_get_req_first) },
+			{ get_req_last, sizeof(get_req_last) }}, {
+			{ conn_rsp, sizeof(conn_rsp) } ,
+			{ get_rsp_first, sizeof(get_rsp_first) },
+			{ get_rsp_last, sizeof(get_rsp_last) } } };
+
+	create_endpoints(&obex, &io, SOCK_STREAM);
+	d.obex = obex;
+
+	cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
+	io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+
+	d.mainloop = g_main_loop_new(NULL, FALSE);
+
+	timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+
+	g_obex_connect(obex, conn_complete_get_req, &d, &d.err,
+							G_OBEX_HDR_INVALID);
+	g_assert_no_error(d.err);
+
+	g_main_loop_run(d.mainloop);
+
+	g_assert_cmpuint(d.count, ==, 3);
+
+	g_main_loop_unref(d.mainloop);
+
+	g_source_remove(timer_id);
+	g_io_channel_unref(io);
+	g_source_remove(io_id);
+	g_obex_unref(obex);
+
+	g_assert_no_error(d.err);
+}
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -749,6 +814,8 @@ int main(int argc, char *argv[])
 
 	g_test_add_func("/gobex/test_put_req_random", test_put_req_random);
 
+	g_test_add_func("/gobex/test_conn_get_req", test_conn_get_req);
+
 	g_test_run();
 
 	return 0;
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH obexd 04/12 v3] gobex: add unit test for CONNECT followed by GET response
  2011-11-11 14:28 [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Luiz Augusto von Dentz
  2011-11-11 14:28 ` [PATCH obexd 02/12 v3] gobex: add unit test for CONNECT response Luiz Augusto von Dentz
  2011-11-11 14:28 ` [PATCH obexd 03/12 v3] gobex: add unit test for CONNECT followed by GET request Luiz Augusto von Dentz
@ 2011-11-11 14:28 ` Luiz Augusto von Dentz
  2011-11-11 14:28 ` [PATCH obexd 05/12 v3] gobex: add unit test for CONNECT followed by PUT request Luiz Augusto von Dentz
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-11 14:28 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 unit/test-gobex-transfer.c |   59 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index 8831d2d..75e9592 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -71,6 +71,10 @@ static guint8 conn_rsp[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x0c,
 					0x10, 0x00, 0x10, 0x00,
 					G_OBEX_HDR_CONNECTION, 0x00, 0x00,
 					0x00, 0x01 };
+static guint8 conn_rsp_2[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x0c,
+					0x10, 0x00, 0x10, 0x00,
+					G_OBEX_HDR_CONNECTION, 0x00, 0x00,
+					0x00, 0x02 };
 
 static guint8 conn_get_req_first[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x28,
 	G_OBEX_HDR_CONNECTION, 0x00, 0x00, 0x00, 0x01,
@@ -78,6 +82,12 @@ static guint8 conn_get_req_first[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x28,
 	'f', 'o', 'o', '/', 'b', 'a', 'r', '\0',
 	G_OBEX_HDR_NAME, 0x00, 0x15,
 	0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0 };
+static guint8 conn_get_req_first_2[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x28,
+	G_OBEX_HDR_CONNECTION, 0x00, 0x00, 0x00, 0x02,
+	G_OBEX_HDR_TYPE, 0x00, 0x0b,
+	'f', 'o', 'o', '/', 'b', 'a', 'r', '\0',
+	G_OBEX_HDR_NAME, 0x00, 0x15,
+	0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0 };
 
 static guint8 hdr_type[] = "foo/bar";
 static guint8 body_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
@@ -793,6 +803,54 @@ static void test_conn_get_req(void)
 	g_assert_no_error(d.err);
 }
 
+static void test_conn_get_rsp(void)
+{
+	GIOChannel *io;
+	GIOCondition cond;
+	guint io_id, timer_id;
+	GObex *obex;
+	struct test_data d = { 0, NULL, {
+			{ conn_rsp_2, sizeof(conn_rsp_2) },
+			{ get_rsp_first, sizeof(get_rsp_first) },
+			{ get_rsp_last, sizeof(get_rsp_last) } }, {
+			{ conn_get_req_first_2, sizeof(conn_get_req_first_2) },
+			{ get_req_last, sizeof(get_req_last) },
+			{ NULL, 0 } } };
+
+	create_endpoints(&obex, &io, SOCK_STREAM);
+	d.obex = obex;
+
+	cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
+	io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+
+	d.mainloop = g_main_loop_new(NULL, FALSE);
+
+	timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+
+	g_obex_add_request_function(obex, G_OBEX_OP_CONNECT,
+						handle_conn_rsp, &d);
+
+	g_obex_add_request_function(obex, G_OBEX_OP_GET,
+						handle_get, &d);
+
+	g_io_channel_write_chars(io, (char *) conn_req, sizeof(conn_req),
+								NULL, &d.err);
+	g_assert_no_error(d.err);
+
+	g_main_loop_run(d.mainloop);
+
+	g_assert_cmpuint(d.count, ==, 2);
+
+	g_main_loop_unref(d.mainloop);
+
+	g_source_remove(timer_id);
+	g_io_channel_unref(io);
+	g_source_remove(io_id);
+	g_obex_unref(obex);
+
+	g_assert_no_error(d.err);
+}
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -815,6 +873,7 @@ int main(int argc, char *argv[])
 	g_test_add_func("/gobex/test_put_req_random", test_put_req_random);
 
 	g_test_add_func("/gobex/test_conn_get_req", test_conn_get_req);
+	g_test_add_func("/gobex/test_conn_get_rsp", test_conn_get_rsp);
 
 	g_test_run();
 
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH obexd 05/12 v3] gobex: add unit test for CONNECT followed by PUT request
  2011-11-11 14:28 [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Luiz Augusto von Dentz
                   ` (2 preceding siblings ...)
  2011-11-11 14:28 ` [PATCH obexd 04/12 v3] gobex: add unit test for CONNECT followed by GET response Luiz Augusto von Dentz
@ 2011-11-11 14:28 ` Luiz Augusto von Dentz
  2011-11-11 14:29 ` [PATCH obexd 06/12 v3] gobex: add unit test for CONNECT followed by PUT response Luiz Augusto von Dentz
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-11 14:28 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 unit/test-gobex-transfer.c |   76 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 75 insertions(+), 1 deletions(-)

diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index 75e9592..466e1d0 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -89,6 +89,15 @@ static guint8 conn_get_req_first_2[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x28,
 	G_OBEX_HDR_NAME, 0x00, 0x15,
 	0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0 };
 
+static guint8 conn_put_req_first[] = { G_OBEX_OP_PUT, 0x00, 0x35,
+	G_OBEX_HDR_CONNECTION, 0x00, 0x00, 0x00, 0x01,
+	G_OBEX_HDR_TYPE, 0x00, 0x0b,
+	'f', 'o', 'o', '/', 'b', 'a', 'r', '\0',
+	G_OBEX_HDR_NAME, 0x00, 0x15,
+	0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0,
+	G_OBEX_HDR_BODY, 0x00, 0x0d,
+	0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+
 static guint8 hdr_type[] = "foo/bar";
 static guint8 body_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
 
@@ -158,9 +167,12 @@ static gssize provide_eagain(void *buf, gsize len, gpointer user_data)
 static gssize provide_data(void *buf, gsize len, gpointer user_data)
 {
 	struct test_data *d = user_data;
+	static int count = 0;
 
-	if (d->count > 0)
+	if (count > 0) {
+		count = 0;
 		return 0;
+	}
 
 	if (len < sizeof(body_data)) {
 		g_set_error(&d->err, TEST_ERROR, TEST_ERROR_UNEXPECTED,
@@ -176,6 +188,8 @@ static gssize provide_data(void *buf, gsize len, gpointer user_data)
 		g_timeout_add(d->provide_delay, resume_obex, d->obex);
 	}
 
+	count++;
+
 	return sizeof(body_data);
 }
 
@@ -851,6 +865,64 @@ static void test_conn_get_rsp(void)
 	g_assert_no_error(d.err);
 }
 
+static void conn_complete_put_req(GObex *obex, GError *err, GObexPacket *rsp,
+							gpointer user_data)
+{
+	struct test_data *d = user_data;
+
+	if (err != NULL) {
+		d->err = g_error_copy(err);
+		g_main_loop_quit(d->mainloop);
+	}
+
+	g_obex_put_req(obex, provide_data, transfer_complete, d, &d->err,
+				G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
+				G_OBEX_HDR_NAME, "file.txt",
+				G_OBEX_HDR_INVALID);
+}
+
+static void test_conn_put_req(void)
+{
+	GIOChannel *io;
+	GIOCondition cond;
+	guint io_id, timer_id;
+	GObex *obex;
+	struct test_data d = { 0, NULL, {
+			{ conn_req, sizeof(conn_req) },
+			{ conn_put_req_first, sizeof(conn_put_req_first) },
+			{ put_req_last, sizeof(put_req_last) }}, {
+			{ conn_rsp, sizeof(conn_rsp) } ,
+			{ put_rsp_first, sizeof(put_rsp_first) },
+			{ put_rsp_last, sizeof(put_rsp_last) } } };
+
+	create_endpoints(&obex, &io, SOCK_STREAM);
+	d.obex = obex;
+
+	cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
+	io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+
+	d.mainloop = g_main_loop_new(NULL, FALSE);
+
+	timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+
+	g_obex_connect(obex, conn_complete_put_req, &d, &d.err,
+							G_OBEX_HDR_INVALID);
+	g_assert_no_error(d.err);
+
+	g_main_loop_run(d.mainloop);
+
+	g_assert_cmpuint(d.count, ==, 3);
+
+	g_main_loop_unref(d.mainloop);
+
+	g_source_remove(timer_id);
+	g_io_channel_unref(io);
+	g_source_remove(io_id);
+	g_obex_unref(obex);
+
+	g_assert_no_error(d.err);
+}
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -875,6 +947,8 @@ int main(int argc, char *argv[])
 	g_test_add_func("/gobex/test_conn_get_req", test_conn_get_req);
 	g_test_add_func("/gobex/test_conn_get_rsp", test_conn_get_rsp);
 
+	g_test_add_func("/gobex/test_conn_put_req", test_conn_put_req);
+
 	g_test_run();
 
 	return 0;
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH obexd 06/12 v3] gobex: add unit test for CONNECT followed by PUT response
  2011-11-11 14:28 [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Luiz Augusto von Dentz
                   ` (3 preceding siblings ...)
  2011-11-11 14:28 ` [PATCH obexd 05/12 v3] gobex: add unit test for CONNECT followed by PUT request Luiz Augusto von Dentz
@ 2011-11-11 14:29 ` Luiz Augusto von Dentz
  2011-11-11 14:29 ` [PATCH obexd 07/12 v3] gobex: add unit test for CONNECT followed by GET wrong response Luiz Augusto von Dentz
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-11 14:29 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 unit/test-gobex-transfer.c |   61 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index 466e1d0..c09abf8 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -75,6 +75,10 @@ static guint8 conn_rsp_2[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x0c,
 					0x10, 0x00, 0x10, 0x00,
 					G_OBEX_HDR_CONNECTION, 0x00, 0x00,
 					0x00, 0x02 };
+static guint8 conn_rsp_3[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x0c,
+					0x10, 0x00, 0x10, 0x00,
+					G_OBEX_HDR_CONNECTION, 0x00, 0x00,
+					0x00, 0x03 };
 
 static guint8 conn_get_req_first[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x28,
 	G_OBEX_HDR_CONNECTION, 0x00, 0x00, 0x00, 0x01,
@@ -97,6 +101,14 @@ static guint8 conn_put_req_first[] = { G_OBEX_OP_PUT, 0x00, 0x35,
 	0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0,
 	G_OBEX_HDR_BODY, 0x00, 0x0d,
 	0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+static guint8 conn_put_req_first_3[] = { G_OBEX_OP_PUT, 0x00, 0x35,
+	G_OBEX_HDR_CONNECTION, 0x00, 0x00, 0x00, 0x03,
+	G_OBEX_HDR_TYPE, 0x00, 0x0b,
+	'f', 'o', 'o', '/', 'b', 'a', 'r', '\0',
+	G_OBEX_HDR_NAME, 0x00, 0x15,
+	0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0,
+	G_OBEX_HDR_BODY, 0x00, 0x0d,
+	0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
 
 static guint8 hdr_type[] = "foo/bar";
 static guint8 body_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
@@ -923,6 +935,54 @@ static void test_conn_put_req(void)
 	g_assert_no_error(d.err);
 }
 
+static void test_conn_put_rsp(void)
+{
+	GIOChannel *io;
+	GIOCondition cond;
+	guint io_id, timer_id;
+	GObex *obex;
+	struct test_data d = { 0, NULL, {
+			{ conn_rsp_3, sizeof(conn_rsp_3) },
+			{ put_rsp_first, sizeof(put_rsp_first) },
+			{ put_rsp_last, sizeof(put_rsp_last) } }, {
+			{ conn_put_req_first_3, sizeof(conn_put_req_first_3) },
+			{ put_req_last, sizeof(put_req_last) },
+			{ NULL, 0 } } };
+
+	create_endpoints(&obex, &io, SOCK_STREAM);
+	d.obex = obex;
+
+	cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
+	io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+
+	d.mainloop = g_main_loop_new(NULL, FALSE);
+
+	timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+
+	g_obex_add_request_function(obex, G_OBEX_OP_CONNECT,
+						handle_conn_rsp, &d);
+
+	g_obex_add_request_function(obex, G_OBEX_OP_PUT,
+						handle_put, &d);
+
+	g_io_channel_write_chars(io, (char *) conn_req, sizeof(conn_req),
+								NULL, &d.err);
+	g_assert_no_error(d.err);
+
+	g_main_loop_run(d.mainloop);
+
+	g_assert_cmpuint(d.count, ==, 2);
+
+	g_main_loop_unref(d.mainloop);
+
+	g_source_remove(timer_id);
+	g_io_channel_unref(io);
+	g_source_remove(io_id);
+	g_obex_unref(obex);
+
+	g_assert_no_error(d.err);
+}
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -948,6 +1008,7 @@ int main(int argc, char *argv[])
 	g_test_add_func("/gobex/test_conn_get_rsp", test_conn_get_rsp);
 
 	g_test_add_func("/gobex/test_conn_put_req", test_conn_put_req);
+	g_test_add_func("/gobex/test_conn_put_rsp", test_conn_put_rsp);
 
 	g_test_run();
 
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH obexd 07/12 v3] gobex: add unit test for CONNECT followed by GET wrong response
  2011-11-11 14:28 [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Luiz Augusto von Dentz
                   ` (4 preceding siblings ...)
  2011-11-11 14:29 ` [PATCH obexd 06/12 v3] gobex: add unit test for CONNECT followed by PUT response Luiz Augusto von Dentz
@ 2011-11-11 14:29 ` Luiz Augusto von Dentz
  2011-11-11 14:29 ` [PATCH obexd 08/12 v3] gobex: add unit test for CONNECT followed by PUT request with random data Luiz Augusto von Dentz
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-11 14:29 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 unit/test-gobex-transfer.c |   52 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index c09abf8..b4c62c1 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -79,6 +79,13 @@ static guint8 conn_rsp_3[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x0c,
 					0x10, 0x00, 0x10, 0x00,
 					G_OBEX_HDR_CONNECTION, 0x00, 0x00,
 					0x00, 0x03 };
+static guint8 conn_rsp_4[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x0c,
+					0x10, 0x00, 0x10, 0x00,
+					G_OBEX_HDR_CONNECTION, 0x00, 0x00,
+					0x00, 0x04 };
+
+static guint8 unavailable_rsp[] = { G_OBEX_RSP_SERVICE_UNAVAILABLE | FINAL_BIT,
+					0x00, 0x03 };
 
 static guint8 conn_get_req_first[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x28,
 	G_OBEX_HDR_CONNECTION, 0x00, 0x00, 0x00, 0x01,
@@ -983,6 +990,49 @@ static void test_conn_put_rsp(void)
 	g_assert_no_error(d.err);
 }
 
+static void test_conn_get_wrg_rsp(void)
+{
+	GIOChannel *io;
+	GIOCondition cond;
+	guint io_id, timer_id;
+	GObex *obex;
+	struct test_data d = { 0, NULL, {
+			{ conn_rsp_4, sizeof(conn_rsp_4) },
+			{ unavailable_rsp, sizeof(unavailable_rsp) } }, {
+			{ conn_get_req_first, sizeof(conn_get_req_first) },
+			{ NULL, 0 } } };
+
+	create_endpoints(&obex, &io, SOCK_STREAM);
+	d.obex = obex;
+
+	cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
+	io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+
+	d.mainloop = g_main_loop_new(NULL, FALSE);
+
+	timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+
+	g_obex_add_request_function(obex, G_OBEX_OP_CONNECT,
+						handle_conn_rsp, &d);
+
+	g_io_channel_write_chars(io, (char *) conn_req, sizeof(conn_req),
+								NULL, &d.err);
+	g_assert_no_error(d.err);
+
+	g_main_loop_run(d.mainloop);
+
+	g_assert_cmpuint(d.count, ==, 2);
+
+	g_main_loop_unref(d.mainloop);
+
+	g_source_remove(timer_id);
+	g_io_channel_unref(io);
+	g_source_remove(io_id);
+	g_obex_unref(obex);
+
+	g_assert_no_error(d.err);
+}
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -1010,6 +1060,8 @@ int main(int argc, char *argv[])
 	g_test_add_func("/gobex/test_conn_put_req", test_conn_put_req);
 	g_test_add_func("/gobex/test_conn_put_rsp", test_conn_put_rsp);
 
+	g_test_add_func("/gobex/test_conn_get_wrg_rsp", test_conn_get_wrg_rsp);
+
 	g_test_run();
 
 	return 0;
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH obexd 08/12 v3] gobex: add unit test for CONNECT followed by PUT request with random data
  2011-11-11 14:28 [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Luiz Augusto von Dentz
                   ` (5 preceding siblings ...)
  2011-11-11 14:29 ` [PATCH obexd 07/12 v3] gobex: add unit test for CONNECT followed by GET wrong response Luiz Augusto von Dentz
@ 2011-11-11 14:29 ` Luiz Augusto von Dentz
  2011-11-11 14:29 ` [PATCH obexd 09/12 v3] gobex: fix checking connection id for ABORT Luiz Augusto von Dentz
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-11 14:29 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Note that in order to work the buffer had to be increased to OBEX maximum
MTU otherwise test_io_cb would be sending responses for each fragment it
has read which may not constitute a full packet.
---
 unit/test-gobex-transfer.c |   63 ++++++++++++++++++++++++++++++++++++++++++++
 unit/util.c                |    2 +-
 2 files changed, 64 insertions(+), 1 deletions(-)

diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index b4c62c1..306a6f0 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -1033,6 +1033,66 @@ static void test_conn_get_wrg_rsp(void)
 	g_assert_no_error(d.err);
 }
 
+static void conn_complete_put_req_random(GObex *obex, GError *err,
+					GObexPacket *rsp, gpointer user_data)
+{
+	struct test_data *d = user_data;
+
+	if (err != NULL) {
+		d->err = g_error_copy(err);
+		g_main_loop_quit(d->mainloop);
+	}
+
+	g_obex_put_req(obex, provide_random, transfer_complete, d, &d->err,
+					G_OBEX_HDR_TYPE, hdr_type, sizeof(hdr_type),
+					G_OBEX_HDR_NAME, "random.bin",
+					G_OBEX_HDR_INVALID);
+}
+
+static void test_conn_put_req_random(void)
+{
+	GIOChannel *io;
+	GIOCondition cond;
+	guint io_id, timer_id;
+	GObex *obex;
+	struct test_data d = { 0, NULL, {
+				{ conn_req, sizeof(conn_req) } ,
+				{ NULL, 0 },
+				{ NULL, 0 },
+				{ put_req_last, sizeof(put_req_last) } }, {
+				{ conn_rsp, sizeof(conn_rsp) } ,
+				{ put_rsp_first, sizeof(put_rsp_first) },
+				{ put_rsp_first, sizeof(put_rsp_first) },
+				{ put_rsp_last, sizeof(put_rsp_last) } } };
+
+	create_endpoints(&obex, &io, SOCK_STREAM);
+	d.obex = obex;
+
+	cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
+	io_id = g_io_add_watch(io, cond, test_io_cb, &d);
+
+	d.mainloop = g_main_loop_new(NULL, FALSE);
+
+	timer_id = g_timeout_add_seconds(1, test_timeout, &d);
+
+	g_obex_connect(obex, conn_complete_put_req_random, &d, &d.err,
+							G_OBEX_HDR_INVALID);
+	g_assert_no_error(d.err);
+
+	g_main_loop_run(d.mainloop);
+
+	g_assert_cmpuint(d.count, ==, RANDOM_PACKETS);
+
+	g_main_loop_unref(d.mainloop);
+
+	g_source_remove(timer_id);
+	g_io_channel_unref(io);
+	g_source_remove(io_id);
+	g_obex_unref(obex);
+
+	g_assert_no_error(d.err);
+}
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -1062,6 +1122,9 @@ int main(int argc, char *argv[])
 
 	g_test_add_func("/gobex/test_conn_get_wrg_rsp", test_conn_get_wrg_rsp);
 
+	g_test_add_func("/gobex/test_conn_put_req_random",
+						test_conn_put_req_random);
+
 	g_test_run();
 
 	return 0;
diff --git a/unit/util.c b/unit/util.c
index 5788654..e8f2024 100644
--- a/unit/util.c
+++ b/unit/util.c
@@ -132,7 +132,7 @@ gboolean test_io_cb(GIOChannel *io, GIOCondition cond, gpointer user_data)
 	struct test_data *d = user_data;
 	GIOStatus status;
 	gsize bytes_written, rbytes, send_buf_len, expect_len;
-	char buf[255];
+	char buf[65535];
 	const char *send_buf, *expect;
 
 	expect = d->recv[d->count].data;
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH obexd 09/12 v3] gobex: fix checking connection id for ABORT
  2011-11-11 14:28 [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Luiz Augusto von Dentz
                   ` (6 preceding siblings ...)
  2011-11-11 14:29 ` [PATCH obexd 08/12 v3] gobex: add unit test for CONNECT followed by PUT request with random data Luiz Augusto von Dentz
@ 2011-11-11 14:29 ` Luiz Augusto von Dentz
  2011-11-11 14:29 ` [PATCH obexd 10/12 v3] gobex: fix not tracking received responses Luiz Augusto von Dentz
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-11 14:29 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

OBEX spec state that it is optional to send a Connection Id header in an
OBEX ABORT operation.

Reported by Hendrik Sattler <post@hendrik-sattler.de>
---
 gobex/gobex.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/gobex/gobex.c b/gobex/gobex.c
index 86e1c4a..b0f3716 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -705,9 +705,16 @@ static void handle_request(GObex *obex, GObexPacket *req)
 
 	op = g_obex_packet_get_operation(req, NULL);
 
-	if (op == G_OBEX_OP_CONNECT)
+	switch (op) {
+	case G_OBEX_OP_CONNECT:
 		parse_connect_data(obex, req);
-	else if (check_connid(obex, req) == FALSE) {
+		break;
+	case G_OBEX_OP_ABORT:
+		break;
+	default:
+		if (check_connid(obex, req))
+			break;
+
 		g_obex_debug(G_OBEX_DEBUG_ERROR, "Invalid Connection ID");
 		g_obex_send_rsp(obex, G_OBEX_RSP_SERVICE_UNAVAILABLE, NULL,
 							G_OBEX_HDR_INVALID);
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH obexd 10/12 v3] gobex: fix not tracking received responses
  2011-11-11 14:28 [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Luiz Augusto von Dentz
                   ` (7 preceding siblings ...)
  2011-11-11 14:29 ` [PATCH obexd 09/12 v3] gobex: fix checking connection id for ABORT Luiz Augusto von Dentz
@ 2011-11-11 14:29 ` Luiz Augusto von Dentz
  2011-11-11 14:29 ` [PATCH obexd 11/12 v3] gobex: fix sending Connection ID header in all requests Luiz Augusto von Dentz
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-11 14:29 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

obex->rx_last_op is only updated if there is no pending request which
means it only store last received request.
---
 gobex/gobex.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gobex/gobex.c b/gobex/gobex.c
index b0f3716..e2d9c6c 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -860,19 +860,20 @@ static gboolean incoming_data(GIOChannel *io, GIOCondition cond,
 	if (obex->rx_data < 3 || obex->rx_data < obex->rx_pkt_len)
 		return TRUE;
 
+	obex->rx_last_op = obex->rx_buf[0] & ~FINAL_BIT;
+
 	if (obex->pending_req) {
 		struct pending_pkt *p = obex->pending_req;
 		opcode = g_obex_packet_get_operation(p->pkt, NULL);
 		header_offset = rsp_header_offset(opcode);
 	} else {
-		opcode = obex->rx_buf[0] & ~FINAL_BIT;
+		opcode = obex->rx_last_op;
 		/* Unexpected response -- fail silently */
 		if (opcode > 0x1f && opcode < 0xff) {
 			obex->rx_data = 0;
 			return TRUE;
 		}
 		header_offset = req_header_offset(opcode);
-		obex->rx_last_op = opcode;
 	}
 
 	if (header_offset < 0) {
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH obexd 11/12 v3] gobex: fix sending Connection ID header in all requests
  2011-11-11 14:28 [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Luiz Augusto von Dentz
                   ` (8 preceding siblings ...)
  2011-11-11 14:29 ` [PATCH obexd 10/12 v3] gobex: fix not tracking received responses Luiz Augusto von Dentz
@ 2011-11-11 14:29 ` Luiz Augusto von Dentz
  2011-11-11 14:29 ` [PATCH obexd 12/12 v3] gobex: make connection id check less strict Luiz Augusto von Dentz
  2011-11-12 18:23 ` [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Johan Hedberg
  11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-11 14:29 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

According to both OBEX and GOEP specs Connection ID should only be
included in the first packet of a request.
---
 client/transfer.c |    1 -
 gobex/gobex.c     |    3 +++
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/client/transfer.c b/client/transfer.c
index b6994d1..7db20f6 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -377,7 +377,6 @@ static void get_buf_xfer_progress(GObex *obex, GError *err, GObexPacket *rsp,
 
 	transfer->xfer = g_obex_send_req(obex, req, -1, get_buf_xfer_progress,
 							transfer, &err);
-
 	if (callback)
 		callback->func(transfer, transfer->transferred, err,
 							callback->data);
diff --git a/gobex/gobex.c b/gobex/gobex.c
index e2d9c6c..8a23485 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -410,6 +410,9 @@ guint g_obex_send_req(GObex *obex, GObexPacket *req, gint timeout,
 	if (obex->conn_id == CONNID_INVALID)
 		goto create_pending;
 
+	if (obex->rx_last_op == G_OBEX_RSP_CONTINUE)
+		goto create_pending;
+
 	connid = g_obex_packet_get_header(req, G_OBEX_HDR_CONNECTION);
 	if (connid != NULL)
 		goto create_pending;
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH obexd 12/12 v3] gobex: make connection id check less strict
  2011-11-11 14:28 [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Luiz Augusto von Dentz
                   ` (9 preceding siblings ...)
  2011-11-11 14:29 ` [PATCH obexd 11/12 v3] gobex: fix sending Connection ID header in all requests Luiz Augusto von Dentz
@ 2011-11-11 14:29 ` Luiz Augusto von Dentz
  2011-11-12 18:23 ` [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Johan Hedberg
  11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-11 14:29 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

OBEX spec says:

  Only the first packet in the request needs to contain the Connection
  Id header...

  If a Connection Id header is received with an invalid connection
  identifier, it is recommended that the operation be rejected with the
  response code (0xD3) “Service Unavailable”.

Since not all requests packets need to contain Connection Id header we
should only try to validate it in case a header is received.

Reported by Hendrik Sattler <post@hendrik-sattler.de>
---
 gobex/gobex.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gobex/gobex.c b/gobex/gobex.c
index 8a23485..7840304 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -694,7 +694,7 @@ static gboolean check_connid(GObex *obex, GObexPacket *pkt)
 
 	hdr = g_obex_packet_get_header(pkt, G_OBEX_HDR_CONNECTION);
 	if (hdr == NULL)
-		return FALSE;
+		return TRUE;
 
 	g_obex_header_get_uint32(hdr, &id);
 
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request
  2011-11-11 14:28 [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Luiz Augusto von Dentz
                   ` (10 preceding siblings ...)
  2011-11-11 14:29 ` [PATCH obexd 12/12 v3] gobex: make connection id check less strict Luiz Augusto von Dentz
@ 2011-11-12 18:23 ` Johan Hedberg
  11 siblings, 0 replies; 13+ messages in thread
From: Johan Hedberg @ 2011-11-12 18:23 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Fri, Nov 11, 2011, Luiz Augusto von Dentz wrote:
> ---
>  unit/test-gobex-transfer.c |   57 ++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 57 insertions(+), 0 deletions(-)

All twelve patches have been applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-11-12 18:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-11 14:28 [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Luiz Augusto von Dentz
2011-11-11 14:28 ` [PATCH obexd 02/12 v3] gobex: add unit test for CONNECT response Luiz Augusto von Dentz
2011-11-11 14:28 ` [PATCH obexd 03/12 v3] gobex: add unit test for CONNECT followed by GET request Luiz Augusto von Dentz
2011-11-11 14:28 ` [PATCH obexd 04/12 v3] gobex: add unit test for CONNECT followed by GET response Luiz Augusto von Dentz
2011-11-11 14:28 ` [PATCH obexd 05/12 v3] gobex: add unit test for CONNECT followed by PUT request Luiz Augusto von Dentz
2011-11-11 14:29 ` [PATCH obexd 06/12 v3] gobex: add unit test for CONNECT followed by PUT response Luiz Augusto von Dentz
2011-11-11 14:29 ` [PATCH obexd 07/12 v3] gobex: add unit test for CONNECT followed by GET wrong response Luiz Augusto von Dentz
2011-11-11 14:29 ` [PATCH obexd 08/12 v3] gobex: add unit test for CONNECT followed by PUT request with random data Luiz Augusto von Dentz
2011-11-11 14:29 ` [PATCH obexd 09/12 v3] gobex: fix checking connection id for ABORT Luiz Augusto von Dentz
2011-11-11 14:29 ` [PATCH obexd 10/12 v3] gobex: fix not tracking received responses Luiz Augusto von Dentz
2011-11-11 14:29 ` [PATCH obexd 11/12 v3] gobex: fix sending Connection ID header in all requests Luiz Augusto von Dentz
2011-11-11 14:29 ` [PATCH obexd 12/12 v3] gobex: make connection id check less strict Luiz Augusto von Dentz
2011-11-12 18:23 ` [PATCH obexd 01/12 v3] gobex: add unit test for CONNECT request Johan Hedberg

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