diff options
author | Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com> | 2015-04-03 12:14:55 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-04-03 23:21:34 +0200 |
commit | 836a061b19d7b4e2e5e05c2a87a366e33127cf88 (patch) | |
tree | 3f4d11ff3177d4f94832470dc0660e66dd027ad2 /net/bluetooth/bnep/core.c | |
parent | bf8b9a9cb77b14e37a8bc925be5db7bfd54d69a8 (diff) | |
download | linux-836a061b19d7b4e2e5e05c2a87a366e33127cf88.tar.gz linux-836a061b19d7b4e2e5e05c2a87a366e33127cf88.tar.bz2 linux-836a061b19d7b4e2e5e05c2a87a366e33127cf88.zip |
Bluetooth: bnep: Handle BNEP connection setup request
With this patch kernel will be able to handle setup request. This is
needed if we would like to handle control mesages with extension
headers. User space will be only resposible for reading setup data and
checking if scenario is conformance to specification (dst and src device
bnep role). In case of new user space, setup data must be leaved(peek
msg) on queue. New bnep session will be responsible for handling this
data.
Signed-off-by: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/bnep/core.c')
-rw-r--r-- | net/bluetooth/bnep/core.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index 0ee6f6d9d93e..1641367e54ca 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c @@ -231,7 +231,14 @@ static int bnep_rx_control(struct bnep_session *s, void *data, int len) break; case BNEP_SETUP_CONN_REQ: - err = bnep_send_rsp(s, BNEP_SETUP_CONN_RSP, BNEP_CONN_NOT_ALLOWED); + /* Successful response should be sent only once */ + if (test_bit(BNEP_SETUP_RESPONSE, &s->flags) && + !test_and_set_bit(BNEP_SETUP_RSP_SENT, &s->flags)) + err = bnep_send_rsp(s, BNEP_SETUP_CONN_RSP, + BNEP_SUCCESS); + else + err = bnep_send_rsp(s, BNEP_SETUP_CONN_RSP, + BNEP_CONN_NOT_ALLOWED); break; default: { @@ -551,7 +558,7 @@ static struct device_type bnep_type = { int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock) { - u32 valid_flags = 0; + u32 valid_flags = BIT(BNEP_SETUP_RESPONSE); struct net_device *dev; struct bnep_session *s, *ss; u8 dst[ETH_ALEN], src[ETH_ALEN]; @@ -596,6 +603,7 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock) s->sock = sock; s->role = req->role; s->state = BT_CONNECTED; + s->flags = req->flags; s->msg.msg_flags = MSG_NOSIGNAL; @@ -665,7 +673,7 @@ int bnep_del_connection(struct bnep_conndel_req *req) static void __bnep_copy_ci(struct bnep_conninfo *ci, struct bnep_session *s) { - u32 valid_flags = 0; + u32 valid_flags = BIT(BNEP_SETUP_RESPONSE); memset(ci, 0, sizeof(*ci)); memcpy(ci->dst, s->eh.h_source, ETH_ALEN); |