All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC v3 0/5] LE Connection
@ 2012-04-05 17:17 Andre Guedes
  2012-04-05 17:17 ` [RFC v3 1/5] Bluetooth: Add address type to struct sockaddr_l2 Andre Guedes
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Andre Guedes @ 2012-04-05 17:17 UTC (permalink / raw)
  To: linux-bluetooth

Hi all,

This new version fixes all aligning style issues.

BR,

Andre Guedes


Andre Guedes (5):
  Bluetooth: Add address type to struct sockaddr_l2
  Bluetooth: Move address type macros to bluetooth.h
  Bluetooth: Add dst_type parameter to hci_connect
  Bluetooth: Use address type info from User-space
  Bluetooth: Remove advertising cache

 include/net/bluetooth/bluetooth.h |    5 +++
 include/net/bluetooth/hci_core.h  |   27 ++++---------
 include/net/bluetooth/l2cap.h     |    3 +-
 net/bluetooth/hci_conn.c          |   12 ++----
 net/bluetooth/hci_core.c          |   75 -------------------------------------
 net/bluetooth/hci_event.c         |    7 ----
 net/bluetooth/l2cap_core.c        |   15 ++++----
 net/bluetooth/l2cap_sock.c        |    2 +-
 net/bluetooth/mgmt.c              |   36 +++++++++---------
 net/bluetooth/sco.c               |    3 +-
 10 files changed, 47 insertions(+), 138 deletions(-)

-- 
1.7.9.4


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

* [RFC v3 1/5] Bluetooth: Add address type to struct sockaddr_l2
  2012-04-05 17:17 [RFC v3 0/5] LE Connection Andre Guedes
@ 2012-04-05 17:17 ` Andre Guedes
  2012-04-05 17:49   ` Marcel Holtmann
  2012-04-05 17:17 ` [RFC v3 2/5] Bluetooth: Move address type macros to bluetooth.h Andre Guedes
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Andre Guedes @ 2012-04-05 17:17 UTC (permalink / raw)
  To: linux-bluetooth

This patch adds the address type info to struct sockaddr_l2 so
user-space can inform the remote device address type required
to establish LE connections.

Soon, instead of looking the advertising cache up to discover the
address type, we'll use this address type info to establish LE
connections.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
 include/net/bluetooth/l2cap.h |    1 +
 1 file changed, 1 insertion(+)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index f6f0500..d14967e 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -57,6 +57,7 @@ struct sockaddr_l2 {
 	__le16		l2_psm;
 	bdaddr_t	l2_bdaddr;
 	__le16		l2_cid;
+	__u8		l2_bdaddr_type;
 };
 
 /* L2CAP socket options */
-- 
1.7.9.4


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

* [RFC v3 2/5] Bluetooth: Move address type macros to bluetooth.h
  2012-04-05 17:17 [RFC v3 0/5] LE Connection Andre Guedes
  2012-04-05 17:17 ` [RFC v3 1/5] Bluetooth: Add address type to struct sockaddr_l2 Andre Guedes
@ 2012-04-05 17:17 ` Andre Guedes
  2012-04-05 17:17 ` [RFC v3 3/5] Bluetooth: Add dst_type parameter to hci_connect Andre Guedes
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Andre Guedes @ 2012-04-05 17:17 UTC (permalink / raw)
  To: linux-bluetooth

This patch moves address type macros to bluetooth.h since they will be
used by management interface and Bluetooth socket interface. It also
replaces the macro prefix MGMT_ADDR_ by BDADDR_.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
 include/net/bluetooth/bluetooth.h |    5 +++++
 include/net/bluetooth/hci_core.h  |   16 ++++++----------
 net/bluetooth/mgmt.c              |   28 ++++++++++++++--------------
 3 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index f2c8bdf..3fe927d 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -163,6 +163,11 @@ typedef struct {
 	__u8 b[6];
 } __packed bdaddr_t;
 
+/* BD Address type */
+#define BDADDR_BREDR		0x00
+#define BDADDR_LE_PUBLIC	0x01
+#define BDADDR_LE_RANDOM	0x02
+
 #define BDADDR_ANY   (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
 #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})
 
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index c0b232c..43a97e4 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -964,16 +964,12 @@ void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb);
 void hci_sock_dev_event(struct hci_dev *hdev, int event);
 
 /* Management interface */
-#define MGMT_ADDR_BREDR			0x00
-#define MGMT_ADDR_LE_PUBLIC		0x01
-#define MGMT_ADDR_LE_RANDOM		0x02
-
-#define DISCOV_TYPE_BREDR		(BIT(MGMT_ADDR_BREDR))
-#define DISCOV_TYPE_LE			(BIT(MGMT_ADDR_LE_PUBLIC) | \
-						BIT(MGMT_ADDR_LE_RANDOM))
-#define DISCOV_TYPE_INTERLEAVED		(BIT(MGMT_ADDR_BREDR) | \
-						BIT(MGMT_ADDR_LE_PUBLIC) | \
-						BIT(MGMT_ADDR_LE_RANDOM))
+#define DISCOV_TYPE_BREDR		(BIT(BDADDR_BREDR))
+#define DISCOV_TYPE_LE			(BIT(BDADDR_LE_PUBLIC) | \
+					 BIT(BDADDR_LE_RANDOM))
+#define DISCOV_TYPE_INTERLEAVED		(BIT(BDADDR_BREDR) | \
+					 BIT(BDADDR_LE_PUBLIC) | \
+					 BIT(BDADDR_LE_RANDOM))
 
 int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len);
 int mgmt_index_added(struct hci_dev *hdev);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 4e7a01f..c6e70b6 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1532,7 +1532,7 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data,
 		goto unlock;
 	}
 
-	if (cp->addr.type == MGMT_ADDR_BREDR)
+	if (cp->addr.type == BDADDR_BREDR)
 		err = hci_remove_link_key(hdev, &cp->addr.bdaddr);
 	else
 		err = hci_remove_ltk(hdev, &cp->addr.bdaddr);
@@ -1544,7 +1544,7 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data,
 	}
 
 	if (cp->disconnect) {
-		if (cp->addr.type == MGMT_ADDR_BREDR)
+		if (cp->addr.type == BDADDR_BREDR)
 			conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK,
 							&cp->addr.bdaddr);
 		else
@@ -1604,7 +1604,7 @@ static int disconnect(struct sock *sk, struct hci_dev *hdev, void *data,
 		goto failed;
 	}
 
-	if (cp->addr.type == MGMT_ADDR_BREDR)
+	if (cp->addr.type == BDADDR_BREDR)
 		conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->addr.bdaddr);
 	else
 		conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->addr.bdaddr);
@@ -1639,16 +1639,16 @@ static u8 link_to_mgmt(u8 link_type, u8 addr_type)
 	case LE_LINK:
 		switch (addr_type) {
 		case ADDR_LE_DEV_PUBLIC:
-			return MGMT_ADDR_LE_PUBLIC;
+			return BDADDR_LE_PUBLIC;
 
 		default:
 			/* Fallback to LE Random address type */
-			return MGMT_ADDR_LE_RANDOM;
+			return BDADDR_LE_RANDOM;
 		}
 
 	default:
 		/* Fallback to BR/EDR type */
-		return MGMT_ADDR_BREDR;
+		return BDADDR_BREDR;
 	}
 }
 
@@ -1910,7 +1910,7 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
 	else
 		auth_type = HCI_AT_DEDICATED_BONDING_MITM;
 
-	if (cp->addr.type == MGMT_ADDR_BREDR)
+	if (cp->addr.type == BDADDR_BREDR)
 		conn = hci_connect(hdev, ACL_LINK, &cp->addr.bdaddr, sec_level,
 				   auth_type);
 	else
@@ -1943,7 +1943,7 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
 	}
 
 	/* For LE, just connecting isn't a proof that the pairing finished */
-	if (cp->addr.type == MGMT_ADDR_BREDR)
+	if (cp->addr.type == BDADDR_BREDR)
 		conn->connect_cfm_cb = pairing_complete_cb;
 
 	conn->security_cfm_cb = pairing_complete_cb;
@@ -2020,7 +2020,7 @@ static int user_pairing_resp(struct sock *sk, struct hci_dev *hdev,
 		goto done;
 	}
 
-	if (type == MGMT_ADDR_BREDR)
+	if (type == BDADDR_BREDR)
 		conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, bdaddr);
 	else
 		conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr);
@@ -2031,7 +2031,7 @@ static int user_pairing_resp(struct sock *sk, struct hci_dev *hdev,
 		goto done;
 	}
 
-	if (type == MGMT_ADDR_LE_PUBLIC || type == MGMT_ADDR_LE_RANDOM) {
+	if (type == BDADDR_LE_PUBLIC || type == BDADDR_LE_RANDOM) {
 		/* Continue with pairing via SMP */
 		err = smp_user_confirm_reply(conn, mgmt_op, passkey);
 
@@ -2962,7 +2962,7 @@ int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, u8 persistent)
 
 	ev.store_hint = persistent;
 	bacpy(&ev.key.addr.bdaddr, &key->bdaddr);
-	ev.key.addr.type = MGMT_ADDR_BREDR;
+	ev.key.addr.type = BDADDR_BREDR;
 	ev.key.type = key->type;
 	memcpy(ev.key.val, key->val, 16);
 	ev.key.pin_len = key->pin_len;
@@ -3120,7 +3120,7 @@ int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure)
 	struct mgmt_ev_pin_code_request ev;
 
 	bacpy(&ev.addr.bdaddr, bdaddr);
-	ev.addr.type = MGMT_ADDR_BREDR;
+	ev.addr.type = BDADDR_BREDR;
 	ev.secure = secure;
 
 	return mgmt_event(MGMT_EV_PIN_CODE_REQUEST, hdev, &ev, sizeof(ev),
@@ -3139,7 +3139,7 @@ int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
 		return -ENOENT;
 
 	bacpy(&rp.addr.bdaddr, bdaddr);
-	rp.addr.type = MGMT_ADDR_BREDR;
+	rp.addr.type = BDADDR_BREDR;
 
 	err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_REPLY,
 			   mgmt_status(status), &rp, sizeof(rp));
@@ -3161,7 +3161,7 @@ int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
 		return -ENOENT;
 
 	bacpy(&rp.addr.bdaddr, bdaddr);
-	rp.addr.type = MGMT_ADDR_BREDR;
+	rp.addr.type = BDADDR_BREDR;
 
 	err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_NEG_REPLY,
 			   mgmt_status(status), &rp, sizeof(rp));
-- 
1.7.9.4


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

* [RFC v3 3/5] Bluetooth: Add dst_type parameter to hci_connect
  2012-04-05 17:17 [RFC v3 0/5] LE Connection Andre Guedes
  2012-04-05 17:17 ` [RFC v3 1/5] Bluetooth: Add address type to struct sockaddr_l2 Andre Guedes
  2012-04-05 17:17 ` [RFC v3 2/5] Bluetooth: Move address type macros to bluetooth.h Andre Guedes
@ 2012-04-05 17:17 ` Andre Guedes
  2012-04-05 17:17 ` [RFC v3 4/5] Bluetooth: Use address type info from User-space Andre Guedes
  2012-04-05 17:17 ` [RFC v3 5/5] Bluetooth: Remove advertising cache Andre Guedes
  4 siblings, 0 replies; 10+ messages in thread
From: Andre Guedes @ 2012-04-05 17:17 UTC (permalink / raw)
  To: linux-bluetooth

This patch adds the dst_type parameter to hci_connect function.
Instead of searching the address type in advertising cache, we
use the dst_type parameter to establish LE connections.

The dst_type is ignored for BR/EDR connection establishment.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
 include/net/bluetooth/hci_core.h |    2 +-
 net/bluetooth/hci_conn.c         |   12 ++++--------
 net/bluetooth/l2cap_core.c       |    8 ++++----
 net/bluetooth/mgmt.c             |    8 ++++----
 net/bluetooth/sco.c              |    3 ++-
 5 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 43a97e4..99d2cde 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -574,7 +574,7 @@ int hci_chan_del(struct hci_chan *chan);
 void hci_chan_list_flush(struct hci_conn *conn);
 
 struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
-						__u8 sec_level, __u8 auth_type);
+			     __u8 dst_type, __u8 sec_level, __u8 auth_type);
 int hci_conn_check_link_mode(struct hci_conn *conn);
 int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level);
 int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type);
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 947172b..c02fc5d 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -514,7 +514,8 @@ EXPORT_SYMBOL(hci_get_route);
 
 /* Create SCO, ACL or LE connection.
  * Device _must_ be locked */
-struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type)
+struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
+			     __u8 dst_type, __u8 sec_level, __u8 auth_type)
 {
 	struct hci_conn *acl;
 	struct hci_conn *sco;
@@ -523,21 +524,16 @@ 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;
+		le->dst_type = (dst_type == BDADDR_LE_PUBLIC) ?
+				ADDR_LE_DEV_PUBLIC : ADDR_LE_DEV_RANDOM;
 
 		hci_le_connect(le);
 
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 3caff27..868d0a8 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1216,11 +1216,11 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *d
 	auth_type = l2cap_get_auth_type(chan);
 
 	if (chan->dcid == L2CAP_CID_LE_DATA)
-		hcon = hci_connect(hdev, LE_LINK, dst,
-					chan->sec_level, auth_type);
+		hcon = hci_connect(hdev, LE_LINK, dst, BDADDR_LE_RANDOM,
+				   chan->sec_level, auth_type);
 	else
-		hcon = hci_connect(hdev, ACL_LINK, dst,
-					chan->sec_level, auth_type);
+		hcon = hci_connect(hdev, ACL_LINK, dst, BDADDR_BREDR,
+				   chan->sec_level, auth_type);
 
 	if (IS_ERR(hcon)) {
 		err = PTR_ERR(hcon);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index c6e70b6..accae54 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1911,11 +1911,11 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
 		auth_type = HCI_AT_DEDICATED_BONDING_MITM;
 
 	if (cp->addr.type == BDADDR_BREDR)
-		conn = hci_connect(hdev, ACL_LINK, &cp->addr.bdaddr, sec_level,
-				   auth_type);
+		conn = hci_connect(hdev, ACL_LINK, &cp->addr.bdaddr,
+				   cp->addr.type, sec_level, auth_type);
 	else
-		conn = hci_connect(hdev, LE_LINK, &cp->addr.bdaddr, sec_level,
-				   auth_type);
+		conn = hci_connect(hdev, LE_LINK, &cp->addr.bdaddr,
+				   cp->addr.type, sec_level, auth_type);
 
 	memset(&rp, 0, sizeof(rp));
 	bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr);
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 8bf26d1..638456a 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -196,7 +196,8 @@ static int sco_connect(struct sock *sk)
 	else
 		type = SCO_LINK;
 
-	hcon = hci_connect(hdev, type, dst, BT_SECURITY_LOW, HCI_AT_NO_BONDING);
+	hcon = hci_connect(hdev, type, dst, BDADDR_BREDR, BT_SECURITY_LOW,
+			   HCI_AT_NO_BONDING);
 	if (IS_ERR(hcon)) {
 		err = PTR_ERR(hcon);
 		goto done;
-- 
1.7.9.4


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

* [RFC v3 4/5] Bluetooth: Use address type info from User-space
  2012-04-05 17:17 [RFC v3 0/5] LE Connection Andre Guedes
                   ` (2 preceding siblings ...)
  2012-04-05 17:17 ` [RFC v3 3/5] Bluetooth: Add dst_type parameter to hci_connect Andre Guedes
@ 2012-04-05 17:17 ` Andre Guedes
  2012-04-05 17:17 ` [RFC v3 5/5] Bluetooth: Remove advertising cache Andre Guedes
  4 siblings, 0 replies; 10+ messages in thread
From: Andre Guedes @ 2012-04-05 17:17 UTC (permalink / raw)
  To: linux-bluetooth

In order to establish a LE connection we need the address type
information. User-space already pass this information to kernel
through struct sockaddr_l2.

This patch adds the dst_type parameter to l2cap_chan_connect so we
are able to pass the address type info from user-space down to
hci_conn layer.

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

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index d14967e..3e2a21f 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -911,7 +911,7 @@ struct l2cap_chan *l2cap_chan_create(void);
 void l2cap_chan_close(struct l2cap_chan *chan, int reason);
 void l2cap_chan_destroy(struct l2cap_chan *chan);
 int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
-								bdaddr_t *dst);
+		       bdaddr_t *dst, u8 dst_type);
 int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len,
 								u32 priority);
 void l2cap_chan_busy(struct l2cap_chan *chan, int busy);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 868d0a8..40aaf1b 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1131,7 +1131,8 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm, bdaddr
 	return c1;
 }
 
-int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *dst)
+int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
+		       bdaddr_t *dst, u8 dst_type)
 {
 	struct sock *sk = chan->sk;
 	bdaddr_t *src = &bt_sk(sk)->src;
@@ -1141,8 +1142,8 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *d
 	__u8 auth_type;
 	int err;
 
-	BT_DBG("%s -> %s psm 0x%2.2x", batostr(src), batostr(dst),
-						__le16_to_cpu(chan->psm));
+	BT_DBG("%s -> %s (type %u) psm 0x%2.2x", batostr(src), batostr(dst),
+	       dst_type, __le16_to_cpu(chan->psm));
 
 	hdev = hci_get_route(dst, src);
 	if (!hdev)
@@ -1216,10 +1217,10 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *d
 	auth_type = l2cap_get_auth_type(chan);
 
 	if (chan->dcid == L2CAP_CID_LE_DATA)
-		hcon = hci_connect(hdev, LE_LINK, dst, BDADDR_LE_RANDOM,
+		hcon = hci_connect(hdev, LE_LINK, dst, dst_type,
 				   chan->sec_level, auth_type);
 	else
-		hcon = hci_connect(hdev, ACL_LINK, dst, BDADDR_BREDR,
+		hcon = hci_connect(hdev, ACL_LINK, dst, dst_type,
 				   chan->sec_level, auth_type);
 
 	if (IS_ERR(hcon)) {
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 1d3e9c3..a54fabe 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -124,7 +124,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al
 		return -EINVAL;
 
 	err = l2cap_chan_connect(chan, la.l2_psm, __le16_to_cpu(la.l2_cid),
-				&la.l2_bdaddr);
+				 &la.l2_bdaddr, la.l2_bdaddr_type);
 	if (err)
 		return err;
 
-- 
1.7.9.4


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

* [RFC v3 5/5] Bluetooth: Remove advertising cache
  2012-04-05 17:17 [RFC v3 0/5] LE Connection Andre Guedes
                   ` (3 preceding siblings ...)
  2012-04-05 17:17 ` [RFC v3 4/5] Bluetooth: Use address type info from User-space Andre Guedes
@ 2012-04-05 17:17 ` Andre Guedes
  4 siblings, 0 replies; 10+ messages in thread
From: Andre Guedes @ 2012-04-05 17:17 UTC (permalink / raw)
  To: linux-bluetooth

User-space pass the remote device address type to kernel through
struct sockaddr_l2 what makes the advertising useless. This patch
removes all advertising cache code.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
 include/net/bluetooth/hci_core.h |    9 -----
 net/bluetooth/hci_core.c         |   75 --------------------------------------
 net/bluetooth/hci_event.c        |    7 ----
 3 files changed, 91 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 99d2cde..4653124 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -255,9 +255,6 @@ struct hci_dev {
 
 	struct list_head	remote_oob_data;
 
-	struct list_head	adv_entries;
-	struct delayed_work	adv_work;
-
 	struct hci_dev_stats	stat;
 
 	struct sk_buff_head	driver_init;
@@ -691,12 +688,6 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
 								u8 *randomizer);
 int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);
 
-#define ADV_CLEAR_TIMEOUT (3*60*HZ) /* Three minutes */
-int hci_adv_entries_clear(struct hci_dev *hdev);
-struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr);
-int hci_add_adv_entry(struct hci_dev *hdev,
-					struct hci_ev_le_advertising_info *ev);
-
 void hci_del_off_timer(struct hci_dev *hdev);
 
 void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 9629645..9618fe1 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1546,75 +1546,6 @@ int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)
 	return mgmt_device_unblocked(hdev, bdaddr, type);
 }
 
-static void hci_clear_adv_cache(struct work_struct *work)
-{
-	struct hci_dev *hdev = container_of(work, struct hci_dev,
-					    adv_work.work);
-
-	hci_dev_lock(hdev);
-
-	hci_adv_entries_clear(hdev);
-
-	hci_dev_unlock(hdev);
-}
-
-int hci_adv_entries_clear(struct hci_dev *hdev)
-{
-	struct adv_entry *entry, *tmp;
-
-	list_for_each_entry_safe(entry, tmp, &hdev->adv_entries, list) {
-		list_del(&entry->list);
-		kfree(entry);
-	}
-
-	BT_DBG("%s adv cache cleared", hdev->name);
-
-	return 0;
-}
-
-struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr)
-{
-	struct adv_entry *entry;
-
-	list_for_each_entry(entry, &hdev->adv_entries, list)
-		if (bacmp(bdaddr, &entry->bdaddr) == 0)
-			return entry;
-
-	return NULL;
-}
-
-static inline int is_connectable_adv(u8 evt_type)
-{
-	if (evt_type == ADV_IND || evt_type == ADV_DIRECT_IND)
-		return 1;
-
-	return 0;
-}
-
-int hci_add_adv_entry(struct hci_dev *hdev,
-					struct hci_ev_le_advertising_info *ev) { struct adv_entry *entry; if (!is_connectable_adv(ev->evt_type))
-		return -EINVAL;
-
-	/* Only new entries should be added to adv_entries. So, if
-	 * bdaddr was found, don't add it. */
-	if (hci_find_adv_entry(hdev, &ev->bdaddr))
-		return 0;
-
-	entry = kzalloc(sizeof(*entry), GFP_KERNEL);
-	if (!entry)
-		return -ENOMEM;
-
-	bacpy(&entry->bdaddr, &ev->bdaddr);
-	entry->bdaddr_type = ev->bdaddr_type;
-
-	list_add(&entry->list, &hdev->adv_entries);
-
-	BT_DBG("%s adv entry added: address %s type %u", hdev->name,
-				batostr(&entry->bdaddr), entry->bdaddr_type);
-
-	return 0;
-}
-
 static void le_scan_param_req(struct hci_dev *hdev, unsigned long opt)
 {
 	struct le_scan_params *param =  (struct le_scan_params *) opt;
@@ -1808,9 +1739,6 @@ int hci_register_dev(struct hci_dev *hdev)
 
 	INIT_LIST_HEAD(&hdev->remote_oob_data);
 
-	INIT_LIST_HEAD(&hdev->adv_entries);
-
-	INIT_DELAYED_WORK(&hdev->adv_work, hci_clear_adv_cache);
 	INIT_WORK(&hdev->power_on, hci_power_on);
 	INIT_DELAYED_WORK(&hdev->power_off, hci_power_off);
 
@@ -1904,8 +1832,6 @@ void hci_unregister_dev(struct hci_dev *hdev)
 
 	hci_del_sysfs(hdev);
 
-	cancel_delayed_work_sync(&hdev->adv_work);
-
 	destroy_workqueue(hdev->workqueue);
 
 	hci_dev_lock(hdev);
@@ -1914,7 +1840,6 @@ void hci_unregister_dev(struct hci_dev *hdev)
 	hci_link_keys_clear(hdev);
 	hci_smp_ltks_clear(hdev);
 	hci_remote_oob_data_clear(hdev);
-	hci_adv_entries_clear(hdev);
 	hci_dev_unlock(hdev);
 
 	hci_dev_put(hdev);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 7325300..f78524f 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1101,10 +1101,7 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
 
 		set_bit(HCI_LE_SCAN, &hdev->dev_flags);
 
-		cancel_delayed_work_sync(&hdev->adv_work);
-
 		hci_dev_lock(hdev);
-		hci_adv_entries_clear(hdev);
 		hci_discovery_set_state(hdev, DISCOVERY_FINDING);
 		hci_dev_unlock(hdev);
 		break;
@@ -1119,8 +1116,6 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
 
 		clear_bit(HCI_LE_SCAN, &hdev->dev_flags);
 
-		schedule_delayed_work(&hdev->adv_work, ADV_CLEAR_TIMEOUT);
-
 		if (hdev->discovery.type == DISCOV_TYPE_INTERLEAVED &&
 				hdev->discovery.state == DISCOVERY_FINDING) {
 			mgmt_interleaved_discovery(hdev);
@@ -3349,8 +3344,6 @@ static inline void hci_le_adv_report_evt(struct hci_dev *hdev,
 	while (num_reports--) {
 		struct hci_ev_le_advertising_info *ev = ptr;
 
-		hci_add_adv_entry(hdev, ev);
-
 		rssi = ev->data[ev->length];
 		mgmt_device_found(hdev, &ev->bdaddr, LE_LINK, ev->bdaddr_type,
 				  NULL, rssi, 0, 1, ev->data, ev->length);
-- 
1.7.9.4


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

* Re: [RFC v3 1/5] Bluetooth: Add address type to struct sockaddr_l2
  2012-04-05 17:17 ` [RFC v3 1/5] Bluetooth: Add address type to struct sockaddr_l2 Andre Guedes
@ 2012-04-05 17:49   ` Marcel Holtmann
  2012-04-05 22:18     ` Andre Guedes
  0 siblings, 1 reply; 10+ messages in thread
From: Marcel Holtmann @ 2012-04-05 17:49 UTC (permalink / raw)
  To: Andre Guedes; +Cc: linux-bluetooth

Hi Andre,

> This patch adds the address type info to struct sockaddr_l2 so
> user-space can inform the remote device address type required
> to establish LE connections.
> 
> Soon, instead of looking the advertising cache up to discover the
> address type, we'll use this address type info to establish LE
> connections.
> 
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> ---
>  include/net/bluetooth/l2cap.h |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> index f6f0500..d14967e 100644
> --- a/include/net/bluetooth/l2cap.h
> +++ b/include/net/bluetooth/l2cap.h
> @@ -57,6 +57,7 @@ struct sockaddr_l2 {
>  	__le16		l2_psm;
>  	bdaddr_t	l2_bdaddr;
>  	__le16		l2_cid;
> +	__u8		l2_bdaddr_type;
>  };

so I am trying to come up with a better name for this value. It feels a
little bit too long to me.

I was considering l2_bdtype, but that is not really semantically correct
here. Or would it be fine? We could do l2_bdatype, but that does not
really make it any better either.

Regards

Marcel



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

* Re: [RFC v3 1/5] Bluetooth: Add address type to struct sockaddr_l2
  2012-04-05 17:49   ` Marcel Holtmann
@ 2012-04-05 22:18     ` Andre Guedes
  2012-04-24 16:42       ` Andre Guedes
  0 siblings, 1 reply; 10+ messages in thread
From: Andre Guedes @ 2012-04-05 22:18 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

Hi Marcel,

On Thu, Apr 5, 2012 at 2:49 PM, Marcel Holtmann <marcel@holtmann.org> wrote=
:
> Hi Andre,
>
>> This patch adds the address type info to struct sockaddr_l2 so
>> user-space can inform the remote device address type required
>> to establish LE connections.
>>
>> Soon, instead of looking the advertising cache up to discover the
>> address type, we'll use this address type info to establish LE
>> connections.
>>
>> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
>> ---
>> =A0include/net/bluetooth/l2cap.h | =A0 =A01 +
>> =A01 file changed, 1 insertion(+)
>>
>> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap=
.h
>> index f6f0500..d14967e 100644
>> --- a/include/net/bluetooth/l2cap.h
>> +++ b/include/net/bluetooth/l2cap.h
>> @@ -57,6 +57,7 @@ struct sockaddr_l2 {
>> =A0 =A0 =A0 __le16 =A0 =A0 =A0 =A0 =A0l2_psm;
>> =A0 =A0 =A0 bdaddr_t =A0 =A0 =A0 =A0l2_bdaddr;
>> =A0 =A0 =A0 __le16 =A0 =A0 =A0 =A0 =A0l2_cid;
>> + =A0 =A0 __u8 =A0 =A0 =A0 =A0 =A0 =A0l2_bdaddr_type;
>> =A0};
>
> so I am trying to come up with a better name for this value. It feels a
> little bit too long to me.
>
> I was considering l2_bdtype, but that is not really semantically correct
> here. Or would it be fine? We could do l2_bdatype, but that does not
> really make it any better either.

Yes, it is a little big to me too. But that was the best name I could
find. Other names just don't clearly say what this field means.

BR,

Andre

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

* Re: [RFC v3 1/5] Bluetooth: Add address type to struct sockaddr_l2
  2012-04-05 22:18     ` Andre Guedes
@ 2012-04-24 16:42       ` Andre Guedes
  2012-04-24 17:04         ` Marcel Holtmann
  0 siblings, 1 reply; 10+ messages in thread
From: Andre Guedes @ 2012-04-24 16:42 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

Hi Marcel,

On Thu, Apr 5, 2012 at 7:18 PM, Andre Guedes <andre.guedes@openbossa.org> w=
rote:
> Hi Marcel,
>
> On Thu, Apr 5, 2012 at 2:49 PM, Marcel Holtmann <marcel@holtmann.org> wro=
te:
>> Hi Andre,
>>
>>> This patch adds the address type info to struct sockaddr_l2 so
>>> user-space can inform the remote device address type required
>>> to establish LE connections.
>>>
>>> Soon, instead of looking the advertising cache up to discover the
>>> address type, we'll use this address type info to establish LE
>>> connections.
>>>
>>> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
>>> ---
>>> =A0include/net/bluetooth/l2cap.h | =A0 =A01 +
>>> =A01 file changed, 1 insertion(+)
>>>
>>> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2ca=
p.h
>>> index f6f0500..d14967e 100644
>>> --- a/include/net/bluetooth/l2cap.h
>>> +++ b/include/net/bluetooth/l2cap.h
>>> @@ -57,6 +57,7 @@ struct sockaddr_l2 {
>>> =A0 =A0 =A0 __le16 =A0 =A0 =A0 =A0 =A0l2_psm;
>>> =A0 =A0 =A0 bdaddr_t =A0 =A0 =A0 =A0l2_bdaddr;
>>> =A0 =A0 =A0 __le16 =A0 =A0 =A0 =A0 =A0l2_cid;
>>> + =A0 =A0 __u8 =A0 =A0 =A0 =A0 =A0 =A0l2_bdaddr_type;
>>> =A0};
>>
>> so I am trying to come up with a better name for this value. It feels a
>> little bit too long to me.
>>
>> I was considering l2_bdtype, but that is not really semantically correct
>> here. Or would it be fine? We could do l2_bdatype, but that does not
>> really make it any better either.
>
> Yes, it is a little big to me too. But that was the best name I could
> find. Other names just don't clearly say what this field means.

So, do we keep this name?

Andre

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

* Re: [RFC v3 1/5] Bluetooth: Add address type to struct sockaddr_l2
  2012-04-24 16:42       ` Andre Guedes
@ 2012-04-24 17:04         ` Marcel Holtmann
  0 siblings, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2012-04-24 17:04 UTC (permalink / raw)
  To: Andre Guedes; +Cc: linux-bluetooth

Hi Andre,

> > On Thu, Apr 5, 2012 at 2:49 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> >> Hi Andre,
> >>
> >>> This patch adds the address type info to struct sockaddr_l2 so
> >>> user-space can inform the remote device address type required
> >>> to establish LE connections.
> >>>
> >>> Soon, instead of looking the advertising cache up to discover the
> >>> address type, we'll use this address type info to establish LE
> >>> connections.
> >>>
> >>> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> >>> ---
> >>>  include/net/bluetooth/l2cap.h |    1 +
> >>>  1 file changed, 1 insertion(+)
> >>>
> >>> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> >>> index f6f0500..d14967e 100644
> >>> --- a/include/net/bluetooth/l2cap.h
> >>> +++ b/include/net/bluetooth/l2cap.h
> >>> @@ -57,6 +57,7 @@ struct sockaddr_l2 {
> >>>       __le16          l2_psm;
> >>>       bdaddr_t        l2_bdaddr;
> >>>       __le16          l2_cid;
> >>> +     __u8            l2_bdaddr_type;
> >>>  };
> >>
> >> so I am trying to come up with a better name for this value. It feels a
> >> little bit too long to me.
> >>
> >> I was considering l2_bdtype, but that is not really semantically correct
> >> here. Or would it be fine? We could do l2_bdatype, but that does not
> >> really make it any better either.
> >
> > Yes, it is a little big to me too. But that was the best name I could
> > find. Other names just don't clearly say what this field means.
> 
> So, do we keep this name?

I honestly have not made up mind. Send a new patch anyway.

Regards

Marcel



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

end of thread, other threads:[~2012-04-24 17:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-05 17:17 [RFC v3 0/5] LE Connection Andre Guedes
2012-04-05 17:17 ` [RFC v3 1/5] Bluetooth: Add address type to struct sockaddr_l2 Andre Guedes
2012-04-05 17:49   ` Marcel Holtmann
2012-04-05 22:18     ` Andre Guedes
2012-04-24 16:42       ` Andre Guedes
2012-04-24 17:04         ` Marcel Holtmann
2012-04-05 17:17 ` [RFC v3 2/5] Bluetooth: Move address type macros to bluetooth.h Andre Guedes
2012-04-05 17:17 ` [RFC v3 3/5] Bluetooth: Add dst_type parameter to hci_connect Andre Guedes
2012-04-05 17:17 ` [RFC v3 4/5] Bluetooth: Use address type info from User-space Andre Guedes
2012-04-05 17:17 ` [RFC v3 5/5] Bluetooth: Remove advertising cache Andre Guedes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.