linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC v4 0/8]  DBus OutOfBand API update
@ 2012-08-13 10:46 Szymon Janc
  2012-08-13 10:46 ` [RFC v4 1/8] dbusoob: Update API Szymon Janc
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Szymon Janc @ 2012-08-13 10:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Hi,

changes since V3:
- remove of DeviceFound signal (rationale below)
- remove of UUIDs from AddRemoteData dictionary
- AlreadyPaired -> AlreadyExist error change
- proposed implementation


After some more thinking about OOB API I've decided that emitting
DeviceFound signal when OOB data are provided is not the best thing to do.

Typical usecase with dbusoob plugin is to provide oob data and either start
pairing with CreatePairedDevice or wait for incoming pairing request. No need
to emit DeviceFound as OOB provider is already aware of device address and can
start pairing. If it doesn't provide pairing agent for device there will be
fallback to adapter agent (which doesn't need to know anything about OOB
channel).


For UUIDs removal is similar - OOB provider already knows which UUIDs are
supported by remote device and based on that can choose to pair or not. No
need to provide that to bluetoothd as it would be only used in DeviceFound
signal anyway.

Comments are welcome.

-- 
BR
Szymon Janc

Szymon Janc (8):
  dbusoob: Update API
  dbusoob: Simplify remove_remote_data
  dbusoob: Change ReadLocalData to match new API
  dbusoob: Change AddRemoteData to match new API
  dbusoob: Add support for Class in AddRemoteData
  dbusoob: Add support for Name in AddRemoteData
  dbusoob: Reply with error if SSP is not supported
  Update test/test-oob to match new DBus OOB API

 doc/oob-api.txt   |   59 ++++++++++++++--
 plugins/dbusoob.c |  193 +++++++++++++++++++++++++++++++++++++++++++++--------
 src/adapter.c     |    5 ++
 src/adapter.h     |    2 +
 src/mgmt.c        |    7 ++
 src/mgmt.h        |    2 +
 test/test-oob     |    4 +-
 7 files changed, 235 insertions(+), 37 deletions(-)

-- 
1.7.9.5


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

* [RFC v4 1/8] dbusoob: Update API
  2012-08-13 10:46 [RFC v4 0/8] DBus OutOfBand API update Szymon Janc
@ 2012-08-13 10:46 ` Szymon Janc
  2012-08-13 10:46 ` [RFC v4 2/8] dbusoob: Simplify remove_remote_data Szymon Janc
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Szymon Janc @ 2012-08-13 10:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Update DBus API so that it better matches inquiry result. It can now
also be used only for OOB discovery (hash and randomizer are optional).

Converting to dictionaries make it also easily extendible e.g. to add
support for BLE when proper whitepaper becomes available.

---
 doc/oob-api.txt |   59 +++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 53 insertions(+), 6 deletions(-)

diff --git a/doc/oob-api.txt b/doc/oob-api.txt
index d838712..c3978fc 100644
--- a/doc/oob-api.txt
+++ b/doc/oob-api.txt
@@ -2,31 +2,77 @@ BlueZ D-Bus Out Of Band Pairing API description
 ===============================================
 
 Copyright (C) 2011  Szymon Janc <szymon.janc@tieto.com> for ST-Ericsson
+Copyright (C) 2012  Tieto Poland
+
+Currently only Secure Simple Pairing is supported. This might change when white
+paper describing OOB pairing for Bluetooth Low Energy will become available.
+
+Out Of Band hierarchy
+=====================
 
 Service		org.bluez
 Interface	org.bluez.OutOfBand
 Object path	[variable prefix]/{hci0,hci1,...}
 
-Methods		array{byte} hash, array{byte} randomizer ReadLocalData()
+Methods		dict ReadLocalData()
 
 			This method reads local OOB data from adapter. Return
-			value is pair of arrays 16 bytes each.
+			value is a dictionary. Following keys are possible:
+
+			array{byte} Hash:
+
+					16 bytes hash blob.
+
+			array{byte} Randomizer:
 
-			Note: This method will generate and return new local
-			OOB data.
+					16 bytes randomizer blob.
+
+			Other data that can be transmitted via OOB mechanism
+			can be obtained from org.bluez.Adapter interface.
+
+			Note: This method will generate and return new data
+			every time it is called. Data received in previous
+			calls is invalidated and cannot be used for pairing.
 
 			Possible errors: org.bluez.Error.Failed
 					 org.bluez.Error.InProgress
+					 org.bluez.Error.NotSupported
 
-		void AddRemoteData(string address, array{byte} hash,
-							array{byte} randomizer)
+		void AddRemoteData(string address, dict data)
 
 			This method adds new Out Of Band data for
 			specified address. If data for specified address
 			already exists it will be overwritten with new one.
 
+			All data is optional.
+
+			possible keys:
+
+				array{byte} Hash:
+
+					16 bytes hash blob, it is used as is
+					so the size and byte order must match.
+
+				array{byte} Randomizer:
+
+					16 bytes randomizer blob, it is used as
+					is so the size and byte order must
+					match. If Randomizer is provided Hash
+					also needs to be provided.
+
+				uint32 Class:
+
+					The Bluetooth class of device of the
+					remote device.
+
+				string Name:
+
+					Remote device name.
+
 			Possible errors: org.bluez.Error.Failed
 					 org.bluez.Error.InvalidArguments
+					 org.bluez.Error.AlreadyExists
+					 org.bluez.Error.NotSupported
 
 		void RemoveRemoteData(string address)
 
@@ -36,3 +82,4 @@ Methods		array{byte} hash, array{byte} randomizer ReadLocalData()
 
 			Possible errors: org.bluez.Error.Failed
 					 org.bluez.Error.InvalidArguments
+					 org.bluez.Error.NotSupported
-- 
1.7.9.5


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

* [RFC v4 2/8] dbusoob: Simplify remove_remote_data
  2012-08-13 10:46 [RFC v4 0/8] DBus OutOfBand API update Szymon Janc
  2012-08-13 10:46 ` [RFC v4 1/8] dbusoob: Update API Szymon Janc
@ 2012-08-13 10:46 ` Szymon Janc
  2012-08-13 10:46 ` [RFC v4 3/8] dbusoob: Change ReadLocalData to match new API Szymon Janc
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Szymon Janc @ 2012-08-13 10:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

str2ba already checks if address is valid before converting and returns
-1 in case of failure.

---
 plugins/dbusoob.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
index 1791342..d259159 100644
--- a/plugins/dbusoob.c
+++ b/plugins/dbusoob.c
@@ -164,11 +164,9 @@ static DBusMessage *remove_remote_data(DBusConnection *conn, DBusMessage *msg,
 			DBUS_TYPE_INVALID))
 		return btd_error_invalid_args(msg);
 
-	if (bachk(addr))
+	if (str2ba(addr, &bdaddr) < 0)
 		return btd_error_invalid_args(msg);
 
-	str2ba(addr, &bdaddr);
-
 	if (btd_adapter_remove_remote_oob_data(adapter, &bdaddr))
 		return btd_error_failed(msg, "Request failed");
 
-- 
1.7.9.5


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

* [RFC v4 3/8] dbusoob: Change ReadLocalData to match new API
  2012-08-13 10:46 [RFC v4 0/8] DBus OutOfBand API update Szymon Janc
  2012-08-13 10:46 ` [RFC v4 1/8] dbusoob: Update API Szymon Janc
  2012-08-13 10:46 ` [RFC v4 2/8] dbusoob: Simplify remove_remote_data Szymon Janc
@ 2012-08-13 10:46 ` Szymon Janc
  2012-08-13 10:46 ` [RFC v4 4/8] dbusoob: Change AddRemoteData " Szymon Janc
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Szymon Janc @ 2012-08-13 10:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

ReadLocalData now returns dictionary instead of hardcoded pair of
arrays.

---
 plugins/dbusoob.c |   31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
index d259159..92c4df1 100644
--- a/plugins/dbusoob.c
+++ b/plugins/dbusoob.c
@@ -79,20 +79,36 @@ static void read_local_data_complete(struct btd_adapter *adapter, uint8_t *hash,
 {
 	struct DBusMessage *reply;
 	struct oob_request *oob_request;
+	DBusMessageIter iter;
+	DBusMessageIter dict;
 
 	oob_request = find_oob_request(adapter);
 	if (!oob_request)
 		return;
 
-	if (hash && randomizer)
-		reply = g_dbus_create_reply(oob_request->msg,
-			DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &hash, 16,
-			DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &randomizer, 16,
-			DBUS_TYPE_INVALID);
-	else
+	if (!hash || !randomizer) {
 		reply = btd_error_failed(oob_request->msg,
 					"Failed to read local OOB data.");
+		goto done;
+	}
+
+	reply = dbus_message_new_method_return(oob_request->msg);
+	if (!reply)
+		goto done;
+
+	dbus_message_iter_init_append(reply, &iter);
+
+	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+			DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+			DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
+			DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
+
+	dict_append_array(&dict, "Hash", DBUS_TYPE_BYTE, &hash, 16);
+	dict_append_array(&dict, "Randomizer", DBUS_TYPE_BYTE, &randomizer, 16);
+
+	dbus_message_iter_close_container(&iter, &dict);
 
+done:
 	oob_requests = g_slist_remove(oob_requests, oob_request);
 	dbus_message_unref(oob_request->msg);
 	g_free(oob_request);
@@ -182,8 +198,7 @@ static const GDBusMethodTable oob_methods[] = {
 			GDBUS_ARGS({ "address", "s" }), NULL,
 			remove_remote_data) },
 	{ GDBUS_ASYNC_METHOD("ReadLocalData",
-			NULL, GDBUS_ARGS({ "hash", "ay" },
-						{ "randomizer", "ay" }),
+			NULL, GDBUS_ARGS({ "data", "a{sv}" }),
 			read_local_data) },
 	{ }
 };
-- 
1.7.9.5


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

* [RFC v4 4/8] dbusoob: Change AddRemoteData to match new API
  2012-08-13 10:46 [RFC v4 0/8] DBus OutOfBand API update Szymon Janc
                   ` (2 preceding siblings ...)
  2012-08-13 10:46 ` [RFC v4 3/8] dbusoob: Change ReadLocalData to match new API Szymon Janc
@ 2012-08-13 10:46 ` Szymon Janc
  2012-08-13 10:46 ` [RFC v4 5/8] dbusoob: Add support for Class in AddRemoteData Szymon Janc
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Szymon Janc @ 2012-08-13 10:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

AddRemoteData now expect dictionary for data instead of hardcoded pair
of arrays.

---
 plugins/dbusoob.c |  126 +++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 108 insertions(+), 18 deletions(-)

diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
index 92c4df1..2ae80fa 100644
--- a/plugins/dbusoob.c
+++ b/plugins/dbusoob.c
@@ -51,6 +51,12 @@ struct oob_request {
 	DBusMessage *msg;
 };
 
+struct oob_data {
+	char *addr;
+	uint8_t *hash;
+	uint8_t *randomizer;
+};
+
 static GSList *oob_requests = NULL;
 static DBusConnection *connection = NULL;
 
@@ -142,28 +148,113 @@ static DBusMessage *read_local_data(DBusConnection *conn, DBusMessage *msg,
 	return NULL;
 }
 
-static DBusMessage *add_remote_data(DBusConnection *conn, DBusMessage *msg,
-								void *data)
+static gboolean parse_data(DBusMessageIter *data, struct oob_data *remote_data)
+{
+	while (dbus_message_iter_get_arg_type(data) == DBUS_TYPE_DICT_ENTRY) {
+		const char *key;
+		DBusMessageIter value, entry;
+		int var;
+
+		dbus_message_iter_recurse(data, &entry);
+		dbus_message_iter_get_basic(&entry, &key);
+
+		dbus_message_iter_next(&entry);
+		dbus_message_iter_recurse(&entry, &value);
+
+		var = dbus_message_iter_get_arg_type(&value);
+		if (strcasecmp(key, "Hash") == 0) {
+			DBusMessageIter array;
+			int size;
+
+			if (var != DBUS_TYPE_ARRAY)
+				return FALSE;
+
+			dbus_message_iter_recurse(&value, &array);
+			dbus_message_iter_get_fixed_array(&array,
+						&remote_data->hash, &size);
+
+			if (size != 16)
+				return FALSE;
+		} else if (strcasecmp(key, "Randomizer") == 0) {
+			DBusMessageIter array;
+			int size;
+
+			if (var != DBUS_TYPE_ARRAY)
+				return FALSE;
+
+			dbus_message_iter_recurse(&value, &array);
+			dbus_message_iter_get_fixed_array(&array,
+						&remote_data->randomizer,
+						&size);
+
+			if (size != 16)
+				return FALSE;
+		}
+
+		dbus_message_iter_next(data);
+	}
+
+	if (dbus_message_iter_get_arg_type(data) != DBUS_TYPE_INVALID)
+		return FALSE;
+
+	/* If randomizer is provided, hash also needs to be provided. */
+	if (remote_data->randomizer && !remote_data->hash)
+		return FALSE;
+
+	return TRUE;
+}
+
+static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
 {
-	struct btd_adapter *adapter = data;
-	uint8_t *hash, *randomizer;
-	int32_t hlen, rlen;
-	const char *addr;
 	bdaddr_t bdaddr;
 
-	if (!dbus_message_get_args(msg, NULL,
-			DBUS_TYPE_STRING, &addr,
-			DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &hash, &hlen,
-			DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &randomizer, &rlen,
-			DBUS_TYPE_INVALID))
-		return btd_error_invalid_args(msg);
+	str2ba(data->addr, &bdaddr);
+
+	if (data->hash) {
+		uint8_t empty_randomizer[16];
 
-	if (hlen != 16 || rlen != 16 || bachk(addr))
+		if (!data->randomizer) {
+			memset(empty_randomizer, 0, sizeof(empty_randomizer));
+			data->randomizer = empty_randomizer;
+		}
+
+		if (btd_adapter_add_remote_oob_data(adapter, &bdaddr,
+					data->hash, data->randomizer) < 0)
+			return FALSE;
+	}
+
+	return TRUE;
+}
+
+static DBusMessage *add_remote_data(DBusConnection *conn, DBusMessage *msg,
+							void *user_data)
+{
+	struct btd_adapter *adapter = user_data;
+	DBusMessageIter args;
+	DBusMessageIter data;
+	struct oob_data remote_data;
+	struct btd_device *device;
+
+	memset(&remote_data, 0, sizeof(remote_data));
+
+	dbus_message_iter_init(msg, &args);
+
+	dbus_message_iter_get_basic(&args, &remote_data.addr);
+	dbus_message_iter_next(&args);
+
+	if (bachk(remote_data.addr) < 0)
 		return btd_error_invalid_args(msg);
 
-	str2ba(addr, &bdaddr);
+	device = adapter_find_device(adapter, remote_data.addr);
+	if (device && device_is_paired(device))
+		return btd_error_already_exists(msg);
+
+	dbus_message_iter_recurse(&args, &data);
+
+	if (!parse_data(&data, &remote_data))
+		return btd_error_invalid_args(msg);
 
-	if (btd_adapter_add_remote_oob_data(adapter, &bdaddr, hash, randomizer))
+	if (!store_data(adapter, &remote_data))
 		return btd_error_failed(msg, "Request failed");
 
 	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
@@ -191,9 +282,8 @@ static DBusMessage *remove_remote_data(DBusConnection *conn, DBusMessage *msg,
 
 static const GDBusMethodTable oob_methods[] = {
 	{ GDBUS_METHOD("AddRemoteData",
-			GDBUS_ARGS({ "address", "s" }, { "hash", "ay" },
-					{ "randomizer", "ay" }), NULL,
-			add_remote_data) },
+			GDBUS_ARGS({ "address", "s" }, { "data", "a{sv}"}),
+			NULL, add_remote_data) },
 	{ GDBUS_METHOD("RemoveRemoteData",
 			GDBUS_ARGS({ "address", "s" }), NULL,
 			remove_remote_data) },
-- 
1.7.9.5


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

* [RFC v4 5/8] dbusoob: Add support for Class in AddRemoteData
  2012-08-13 10:46 [RFC v4 0/8] DBus OutOfBand API update Szymon Janc
                   ` (3 preceding siblings ...)
  2012-08-13 10:46 ` [RFC v4 4/8] dbusoob: Change AddRemoteData " Szymon Janc
@ 2012-08-13 10:46 ` Szymon Janc
  2012-08-13 10:46 ` [RFC v4 6/8] dbusoob: Add support for Name " Szymon Janc
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Szymon Janc @ 2012-08-13 10:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Class received in AddRemoteData is stored for future use when device
object is created.

---
 plugins/dbusoob.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
index 2ae80fa..97de9c0 100644
--- a/plugins/dbusoob.c
+++ b/plugins/dbusoob.c
@@ -43,6 +43,7 @@
 #include "event.h"
 #include "error.h"
 #include "oob.h"
+#include "storage.h"
 
 #define OOB_INTERFACE	"org.bluez.OutOfBand"
 
@@ -55,6 +56,7 @@ struct oob_data {
 	char *addr;
 	uint8_t *hash;
 	uint8_t *randomizer;
+	uint32_t class;
 };
 
 static GSList *oob_requests = NULL;
@@ -189,6 +191,12 @@ static gboolean parse_data(DBusMessageIter *data, struct oob_data *remote_data)
 
 			if (size != 16)
 				return FALSE;
+		} else if (strcasecmp(key, "Class") == 0) {
+			if (var != DBUS_TYPE_UINT32)
+				return FALSE;
+
+			dbus_message_iter_get_basic(&value,
+							&remote_data->class);
 		}
 
 		dbus_message_iter_next(data);
@@ -223,6 +231,13 @@ static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
 			return FALSE;
 	}
 
+	if (data->class) {
+		bdaddr_t local;
+		adapter_get_address(adapter, &local);
+
+		write_remote_class(&local, &bdaddr, data->class);
+	}
+
 	return TRUE;
 }
 
-- 
1.7.9.5


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

* [RFC v4 6/8] dbusoob: Add support for Name in AddRemoteData
  2012-08-13 10:46 [RFC v4 0/8] DBus OutOfBand API update Szymon Janc
                   ` (4 preceding siblings ...)
  2012-08-13 10:46 ` [RFC v4 5/8] dbusoob: Add support for Class in AddRemoteData Szymon Janc
@ 2012-08-13 10:46 ` Szymon Janc
  2012-08-13 10:46 ` [RFC v4 7/8] dbusoob: Reply with error if SSP is not supported Szymon Janc
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Szymon Janc @ 2012-08-13 10:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Name received in AddRemoteData is stored for future use when device
object is created.

---
 plugins/dbusoob.c |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
index 97de9c0..0e0eeca 100644
--- a/plugins/dbusoob.c
+++ b/plugins/dbusoob.c
@@ -57,6 +57,7 @@ struct oob_data {
 	uint8_t *hash;
 	uint8_t *randomizer;
 	uint32_t class;
+	char *name;
 };
 
 static GSList *oob_requests = NULL;
@@ -197,6 +198,12 @@ static gboolean parse_data(DBusMessageIter *data, struct oob_data *remote_data)
 
 			dbus_message_iter_get_basic(&value,
 							&remote_data->class);
+		} else if (strcasecmp(key, "Name") == 0) {
+			if (var != DBUS_TYPE_STRING)
+				return FALSE;
+
+			dbus_message_iter_get_basic(&value,
+							&remote_data->name);
 		}
 
 		dbus_message_iter_next(data);
@@ -215,8 +222,10 @@ static gboolean parse_data(DBusMessageIter *data, struct oob_data *remote_data)
 static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
 {
 	bdaddr_t bdaddr;
+	bdaddr_t local;
 
 	str2ba(data->addr, &bdaddr);
+	adapter_get_address(adapter, &local);
 
 	if (data->hash) {
 		uint8_t empty_randomizer[16];
@@ -231,12 +240,11 @@ static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
 			return FALSE;
 	}
 
-	if (data->class) {
-		bdaddr_t local;
-		adapter_get_address(adapter, &local);
-
+	if (data->class)
 		write_remote_class(&local, &bdaddr, data->class);
-	}
+
+	if (data->name)
+		write_device_name(&local, &bdaddr, 0, data->name);
 
 	return TRUE;
 }
-- 
1.7.9.5


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

* [RFC v4 7/8] dbusoob: Reply with error if SSP is not supported
  2012-08-13 10:46 [RFC v4 0/8] DBus OutOfBand API update Szymon Janc
                   ` (5 preceding siblings ...)
  2012-08-13 10:46 ` [RFC v4 6/8] dbusoob: Add support for Name " Szymon Janc
@ 2012-08-13 10:46 ` Szymon Janc
  2012-08-13 10:46 ` [RFC v4 8/8] Update test/test-oob to match new DBus OOB API Szymon Janc
  2012-08-14  9:30 ` [RFC v4 0/8] DBus OutOfBand API update Johan Hedberg
  8 siblings, 0 replies; 10+ messages in thread
From: Szymon Janc @ 2012-08-13 10:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Reply with org.bluez.Error.NotSupported if methods were called on
adapter without SSP enabled.

---
 plugins/dbusoob.c |    9 +++++++++
 src/adapter.c     |    5 +++++
 src/adapter.h     |    2 ++
 src/mgmt.c        |    7 +++++++
 src/mgmt.h        |    2 ++
 5 files changed, 25 insertions(+)

diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
index 0e0eeca..885f247 100644
--- a/plugins/dbusoob.c
+++ b/plugins/dbusoob.c
@@ -137,6 +137,9 @@ static DBusMessage *read_local_data(DBusConnection *conn, DBusMessage *msg,
 	struct btd_adapter *adapter = data;
 	struct oob_request *oob_request;
 
+	if (!btd_adapter_ssp_enabled(adapter))
+		return btd_error_not_supported(msg);
+
 	if (find_oob_request(adapter))
 		return btd_error_in_progress(msg);
 
@@ -258,6 +261,9 @@ static DBusMessage *add_remote_data(DBusConnection *conn, DBusMessage *msg,
 	struct oob_data remote_data;
 	struct btd_device *device;
 
+	if (!btd_adapter_ssp_enabled(adapter))
+		return btd_error_not_supported(msg);
+
 	memset(&remote_data, 0, sizeof(remote_data));
 
 	dbus_message_iter_init(msg, &args);
@@ -290,6 +296,9 @@ static DBusMessage *remove_remote_data(DBusConnection *conn, DBusMessage *msg,
 	const char *addr;
 	bdaddr_t bdaddr;
 
+	if (!btd_adapter_ssp_enabled(adapter))
+		return btd_error_not_supported(msg);
+
 	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &addr,
 			DBUS_TYPE_INVALID))
 		return btd_error_invalid_args(msg);
diff --git a/src/adapter.c b/src/adapter.c
index b7691d0..e6b5559 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3498,3 +3498,8 @@ int btd_adapter_remove_remote_oob_data(struct btd_adapter *adapter,
 {
 	return mgmt_remove_remote_oob_data(adapter->dev_id, bdaddr);
 }
+
+int btd_adapter_ssp_enabled(struct btd_adapter *adapter)
+{
+	return mgmt_ssp_enabled(adapter->dev_id);
+}
diff --git a/src/adapter.h b/src/adapter.h
index d8a1bb1..5a0247e 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -230,3 +230,5 @@ int btd_adapter_remove_remote_oob_data(struct btd_adapter *adapter,
 
 int btd_adapter_gatt_server_start(struct btd_adapter *adapter);
 void btd_adapter_gatt_server_stop(struct btd_adapter *adapter);
+
+int btd_adapter_ssp_enabled(struct btd_adapter *adapter);
diff --git a/src/mgmt.c b/src/mgmt.c
index c893972..b3ae776 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -2474,3 +2474,10 @@ int mgmt_load_ltks(int index, GSList *keys)
 
 	return err;
 }
+
+int mgmt_ssp_enabled(int index)
+{
+	struct controller_info *info = &controllers[index];
+
+	return mgmt_ssp(info->current_settings);
+}
diff --git a/src/mgmt.h b/src/mgmt.h
index 0658198..95245d2 100644
--- a/src/mgmt.h
+++ b/src/mgmt.h
@@ -78,3 +78,5 @@ int mgmt_remove_remote_oob_data(int index, bdaddr_t *bdaddr);
 
 int mgmt_confirm_name(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type,
 							gboolean name_known);
+
+int mgmt_ssp_enabled(int index);
-- 
1.7.9.5


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

* [RFC v4 8/8] Update test/test-oob to match new DBus OOB API
  2012-08-13 10:46 [RFC v4 0/8] DBus OutOfBand API update Szymon Janc
                   ` (6 preceding siblings ...)
  2012-08-13 10:46 ` [RFC v4 7/8] dbusoob: Reply with error if SSP is not supported Szymon Janc
@ 2012-08-13 10:46 ` Szymon Janc
  2012-08-14  9:30 ` [RFC v4 0/8] DBus OutOfBand API update Johan Hedberg
  8 siblings, 0 replies; 10+ messages in thread
From: Szymon Janc @ 2012-08-13 10:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

---
 test/test-oob |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/test-oob b/test/test-oob
index bec9de5..d44215f 100755
--- a/test/test-oob
+++ b/test/test-oob
@@ -68,8 +68,8 @@ if __name__ == '__main__':
 	print()
 	print("Exchanging Out of Band data...")
 
-	oob_adapter0.AddRemoteData(adapter1_address, oob1[0], oob1[1])
-	oob_adapter1.AddRemoteData(adapter0_address, oob0[0], oob0[1])
+	oob_adapter0.AddRemoteData(adapter1_address, oob1)
+	oob_adapter1.AddRemoteData(adapter0_address, oob0)
 
 	print("Done.")
 	print()
-- 
1.7.9.5


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

* Re: [RFC v4 0/8]  DBus OutOfBand API update
  2012-08-13 10:46 [RFC v4 0/8] DBus OutOfBand API update Szymon Janc
                   ` (7 preceding siblings ...)
  2012-08-13 10:46 ` [RFC v4 8/8] Update test/test-oob to match new DBus OOB API Szymon Janc
@ 2012-08-14  9:30 ` Johan Hedberg
  8 siblings, 0 replies; 10+ messages in thread
From: Johan Hedberg @ 2012-08-14  9:30 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth

Hi Szymon,

On Mon, Aug 13, 2012, Szymon Janc wrote:
> changes since V3:
> - remove of DeviceFound signal (rationale below)
> - remove of UUIDs from AddRemoteData dictionary
> - AlreadyPaired -> AlreadyExist error change
> - proposed implementation
> 
> 
> After some more thinking about OOB API I've decided that emitting
> DeviceFound signal when OOB data are provided is not the best thing to do.
> 
> Typical usecase with dbusoob plugin is to provide oob data and either start
> pairing with CreatePairedDevice or wait for incoming pairing request. No need
> to emit DeviceFound as OOB provider is already aware of device address and can
> start pairing. If it doesn't provide pairing agent for device there will be
> fallback to adapter agent (which doesn't need to know anything about OOB
> channel).
> 
> 
> For UUIDs removal is similar - OOB provider already knows which UUIDs are
> supported by remote device and based on that can choose to pair or not. No
> need to provide that to bluetoothd as it would be only used in DeviceFound
> signal anyway.
> 
> Comments are welcome.
> 
> -- 
> BR
> Szymon Janc
> 
> Szymon Janc (8):
>   dbusoob: Update API
>   dbusoob: Simplify remove_remote_data
>   dbusoob: Change ReadLocalData to match new API
>   dbusoob: Change AddRemoteData to match new API
>   dbusoob: Add support for Class in AddRemoteData
>   dbusoob: Add support for Name in AddRemoteData
>   dbusoob: Reply with error if SSP is not supported
>   Update test/test-oob to match new DBus OOB API
> 
>  doc/oob-api.txt   |   59 ++++++++++++++--
>  plugins/dbusoob.c |  193 +++++++++++++++++++++++++++++++++++++++++++++--------
>  src/adapter.c     |    5 ++
>  src/adapter.h     |    2 +
>  src/mgmt.c        |    7 ++
>  src/mgmt.h        |    2 +
>  test/test-oob     |    4 +-
>  7 files changed, 235 insertions(+), 37 deletions(-)

The patches look good to me and have now been applied upstream. Thanks.

Johan

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

end of thread, other threads:[~2012-08-14  9:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-13 10:46 [RFC v4 0/8] DBus OutOfBand API update Szymon Janc
2012-08-13 10:46 ` [RFC v4 1/8] dbusoob: Update API Szymon Janc
2012-08-13 10:46 ` [RFC v4 2/8] dbusoob: Simplify remove_remote_data Szymon Janc
2012-08-13 10:46 ` [RFC v4 3/8] dbusoob: Change ReadLocalData to match new API Szymon Janc
2012-08-13 10:46 ` [RFC v4 4/8] dbusoob: Change AddRemoteData " Szymon Janc
2012-08-13 10:46 ` [RFC v4 5/8] dbusoob: Add support for Class in AddRemoteData Szymon Janc
2012-08-13 10:46 ` [RFC v4 6/8] dbusoob: Add support for Name " Szymon Janc
2012-08-13 10:46 ` [RFC v4 7/8] dbusoob: Reply with error if SSP is not supported Szymon Janc
2012-08-13 10:46 ` [RFC v4 8/8] Update test/test-oob to match new DBus OOB API Szymon Janc
2012-08-14  9:30 ` [RFC v4 0/8] DBus OutOfBand API update Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).