Skip to contentSkip to conversation

Bluetooth: Store address information in L2CAP channel structure

PATCH Applied Marcel Holtmann 2 participants 2 messages Oct 13, 2013

Subsystems (2)
lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH 1/1 Bluetooth: Store address information in L2CAP channel structure

With the effort of abstracting the L2CAP socket from the underlying L2CAP channel it is important to store the source and destination address information directly in the L2CAP channel structure.

Direct access to the HCI connection address information is not possible since they might not be avaiable at L2CAP channel creation time. The address information will be updated when the underlying BR/EDR or LE connection status changes.

---
 include/net/bluetooth/l2cap.h |  2 ++
 net/bluetooth/l2cap_core.c    | 61 +++++++++++++++++--------------------------
 net/bluetooth/l2cap_sock.c    |  6 ++---
 3 files changed, 29 insertions(+), 40 deletions(-)
include/net/bluetooth/l2cap.h +2 -0
index 1a929af..26b5066 100644
@@ -444,6 +444,8 @@ struct l2cap_chan {
 
 	__u8		state;
 
+	bdaddr_t	dst;
+	bdaddr_t	src;
 	__le16		psm;
 	__u16		dcid;
 	__u16		scid;
net/bluetooth/l2cap_core.c +24 -37

186 lines not on this page · raw message

net/bluetooth/l2cap_sock.c +3 -3
index bd6fe7f..9fe80d2 100644
@@ -112,7 +112,7 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
 		break;
 	}
 
-	bacpy(&bt_sk(sk)->src, &la.l2_bdaddr);
+	bacpy(&chan->src, &la.l2_bdaddr);
 
 	chan->state = BT_BOUND;
 	sk->sk_state = BT_BOUND;
@@ -274,11 +274,11 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr,
 
 	if (peer) {
 		la->l2_psm = chan->psm;
-		bacpy(&la->l2_bdaddr, &bt_sk(sk)->dst);
+		bacpy(&la->l2_bdaddr, &chan->dst);
 		la->l2_cid = cpu_to_le16(chan->dcid);
 	} else {
 		la->l2_psm = chan->sport;
-		bacpy(&la->l2_bdaddr, &bt_sk(sk)->src);
+		bacpy(&la->l2_bdaddr, &chan->src);
 		la->l2_cid = cpu_to_le16(chan->scid);
 	}
 
Signature · 1 line
1.8.3.1
#1 lore raw

Hi Marcel,

Quoted 9 lines · Marcel Holtmann

With the effort of abstracting the L2CAP socket from the underlying L2CAP channel it is important to store the source and destination address information directly in the L2CAP channel structure.

Direct access to the HCI connection address information is not possible since they might not be avaiable at L2CAP channel creation time. The address information will be updated when the underlying BR/EDR or LE connection status changes.

Quoted 6 lines
---
 include/net/bluetooth/l2cap.h |  2 ++
 net/bluetooth/l2cap_core.c    | 61 +++++++++++++++++--------------------------
 net/bluetooth/l2cap_sock.c    |  6 ++---
 3 files changed, 29 insertions(+), 40 deletions(-)

Applied to bluetooth-next. Thanks.

Johan