linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] Bluetooth: Add 'dst_type' field to struct hci_conn
@ 2011-05-31 17:20 Andre Guedes
  2011-05-31 17:20 ` [PATCH 2/4] Bluetooth: Remove useless check in hci_connect() Andre Guedes
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andre Guedes @ 2011-05-31 17:20 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andre Guedes

This patch adds a new field (dst_type) to the struct hci_conn which
holds the type of the destination address (bdaddr_t dst). This
approach is needed in order to use the struct hci_conn as an
abstraction of LE connections in HCI Layer. For non-LE this field
is ignored.

This patch also set properly the 'dst_type' field after initializing
LE hci_conn structures.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
 include/net/bluetooth/hci_core.h |    1 +
 net/bluetooth/hci_event.c        |    8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index af4b0ed..539eb85 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -224,6 +224,7 @@ struct hci_conn {
 	spinlock_t	lock;
 
 	bdaddr_t	dst;
+	__u8            dst_type;
 	__u16		handle;
 	__u16		state;
 	__u8		mode;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index c456f9c..6cb73dd 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1236,10 +1236,12 @@ static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status)
 	} else {
 		if (!conn) {
 			conn = hci_conn_add(hdev, LE_LINK, &cp->peer_addr);
-			if (conn)
+			if (conn) {
+				conn->dst_type = cp->peer_addr_type;
 				conn->out = 1;
-			else
+			} else {
 				BT_ERR("No memory for new connection");
+			}
 		}
 	}
 
@@ -2689,6 +2691,8 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff
 			hci_dev_unlock(hdev);
 			return;
 		}
+
+		conn->dst_type = ev->bdaddr_type;
 	}
 
 	if (ev->status) {
-- 
1.7.4.1


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

* [PATCH 2/4] Bluetooth: Remove useless check in hci_connect()
  2011-05-31 17:20 [PATCH 1/4] Bluetooth: Add 'dst_type' field to struct hci_conn Andre Guedes
@ 2011-05-31 17:20 ` Andre Guedes
  2011-05-31 17:20 ` [PATCH 3/4] Bluetooth: Check advertising cache " Andre Guedes
  2011-05-31 17:20 ` [PATCH 4/4] Bluetooth: Set 'peer_addr_type' in hci_le_connect() Andre Guedes
  2 siblings, 0 replies; 5+ messages in thread
From: Andre Guedes @ 2011-05-31 17:20 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andre Guedes

There is no need to check the connection's state since hci_conn_add()
has just created a new connection and its state has been set properly.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Ville Tervo <ville.tervo@nokia.com>
---
 net/bluetooth/hci_conn.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 3163330..5f352d2 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -453,8 +453,8 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
 		le = hci_conn_add(hdev, LE_LINK, dst);
 		if (!le)
 			return ERR_PTR(-ENOMEM);
-		if (le->state == BT_OPEN)
-			hci_le_connect(le);
+
+		hci_le_connect(le);
 
 		hci_conn_hold(le);
 
-- 
1.7.4.1


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

* [PATCH 3/4] Bluetooth: Check advertising cache in hci_connect()
  2011-05-31 17:20 [PATCH 1/4] Bluetooth: Add 'dst_type' field to struct hci_conn Andre Guedes
  2011-05-31 17:20 ` [PATCH 2/4] Bluetooth: Remove useless check in hci_connect() Andre Guedes
@ 2011-05-31 17:20 ` Andre Guedes
  2011-05-31 17:20 ` [PATCH 4/4] Bluetooth: Set 'peer_addr_type' in hci_le_connect() Andre Guedes
  2 siblings, 0 replies; 5+ messages in thread
From: Andre Guedes @ 2011-05-31 17:20 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andre Guedes

When connecting to a LE device, we need to check the advertising
cache in order to know the address type of that device.

If its advertising entry is not found, the connection is not
established and hci_connect() returns error.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Ville Tervo <ville.tervo@nokia.com>
---
 net/bluetooth/hci_conn.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 5f352d2..f6729a6 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -447,13 +447,22 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
 	BT_DBG("%s dst %s", hdev->name, batostr(dst));
 
 	if (type == LE_LINK) {
+		struct adv_entry *entry;
+
 		le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
 		if (le)
 			return ERR_PTR(-EBUSY);
+
+		entry = hci_find_adv_entry(hdev, dst);
+		if (!entry)
+			return ERR_PTR(-EHOSTUNREACH);
+
 		le = hci_conn_add(hdev, LE_LINK, dst);
 		if (!le)
 			return ERR_PTR(-ENOMEM);
 
+		le->dst_type = entry->bdaddr_type;
+
 		hci_le_connect(le);
 
 		hci_conn_hold(le);
-- 
1.7.4.1


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

* [PATCH 4/4] Bluetooth: Set 'peer_addr_type' in hci_le_connect()
  2011-05-31 17:20 [PATCH 1/4] Bluetooth: Add 'dst_type' field to struct hci_conn Andre Guedes
  2011-05-31 17:20 ` [PATCH 2/4] Bluetooth: Remove useless check in hci_connect() Andre Guedes
  2011-05-31 17:20 ` [PATCH 3/4] Bluetooth: Check advertising cache " Andre Guedes
@ 2011-05-31 17:20 ` Andre Guedes
  2011-06-01 19:38   ` Gustavo F. Padovan
  2 siblings, 1 reply; 5+ messages in thread
From: Andre Guedes @ 2011-05-31 17:20 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andre Guedes

Set the 'peer_addr_type' field of the LE Create Connection command
sent in hci_le_connect().

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Ville Tervo <ville.tervo@nokia.com>
---
 net/bluetooth/hci_conn.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index f6729a6..664d77c 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -58,6 +58,7 @@ static void hci_le_connect(struct hci_conn *conn)
 	cp.scan_interval = cpu_to_le16(0x0004);
 	cp.scan_window = cpu_to_le16(0x0004);
 	bacpy(&cp.peer_addr, &conn->dst);
+	cp.peer_addr_type = conn->dst_type;
 	cp.conn_interval_min = cpu_to_le16(0x0008);
 	cp.conn_interval_max = cpu_to_le16(0x0100);
 	cp.supervision_timeout = cpu_to_le16(0x0064);
-- 
1.7.4.1


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

* Re: [PATCH 4/4] Bluetooth: Set 'peer_addr_type' in hci_le_connect()
  2011-05-31 17:20 ` [PATCH 4/4] Bluetooth: Set 'peer_addr_type' in hci_le_connect() Andre Guedes
@ 2011-06-01 19:38   ` Gustavo F. Padovan
  0 siblings, 0 replies; 5+ messages in thread
From: Gustavo F. Padovan @ 2011-06-01 19:38 UTC (permalink / raw)
  To: Andre Guedes; +Cc: linux-bluetooth

Hi Andre,

* Andre Guedes <andre.guedes@openbossa.org> [2011-05-31 14:20:57 -0300]:

> Set the 'peer_addr_type' field of the LE Create Connection command
> sent in hci_le_connect().
> 
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> Acked-by: Ville Tervo <ville.tervo@nokia.com>
> ---
>  net/bluetooth/hci_conn.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)

All four patches applied. Thanks.

-- 
Gustavo F. Padovan
http://profusion.mobi

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

end of thread, other threads:[~2011-06-01 19:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-31 17:20 [PATCH 1/4] Bluetooth: Add 'dst_type' field to struct hci_conn Andre Guedes
2011-05-31 17:20 ` [PATCH 2/4] Bluetooth: Remove useless check in hci_connect() Andre Guedes
2011-05-31 17:20 ` [PATCH 3/4] Bluetooth: Check advertising cache " Andre Guedes
2011-05-31 17:20 ` [PATCH 4/4] Bluetooth: Set 'peer_addr_type' in hci_le_connect() Andre Guedes
2011-06-01 19:38   ` Gustavo F. Padovan

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).