提交 755b82aa 编写于 作者: M Marcel Holtmann 提交者: Johan Hedberg

Bluetooth: Access HIDP session addresses through L2CAP channel

The L2CAP socket structure does not contain the address information
anymore. They need to be accessed through the L2CAP channel.
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
上级 88f1fd27
...@@ -767,10 +767,10 @@ static int hidp_setup_hid(struct hidp_session *session, ...@@ -767,10 +767,10 @@ static int hidp_setup_hid(struct hidp_session *session,
strncpy(hid->name, req->name, sizeof(req->name) - 1); strncpy(hid->name, req->name, sizeof(req->name) - 1);
snprintf(hid->phys, sizeof(hid->phys), "%pMR", snprintf(hid->phys, sizeof(hid->phys), "%pMR",
&bt_sk(session->ctrl_sock->sk)->src); &l2cap_pi(session->ctrl_sock->sk)->chan->src);
snprintf(hid->uniq, sizeof(hid->uniq), "%pMR", snprintf(hid->uniq, sizeof(hid->uniq), "%pMR",
&bt_sk(session->ctrl_sock->sk)->dst); &l2cap_pi(session->ctrl_sock->sk)->chan->dst);
hid->dev.parent = &session->conn->hcon->dev; hid->dev.parent = &session->conn->hcon->dev;
hid->ll_driver = &hidp_hid_driver; hid->ll_driver = &hidp_hid_driver;
...@@ -1283,23 +1283,29 @@ static int hidp_session_thread(void *arg) ...@@ -1283,23 +1283,29 @@ static int hidp_session_thread(void *arg)
static int hidp_verify_sockets(struct socket *ctrl_sock, static int hidp_verify_sockets(struct socket *ctrl_sock,
struct socket *intr_sock) struct socket *intr_sock)
{ {
struct l2cap_chan *ctrl_chan, *intr_chan;
struct bt_sock *ctrl, *intr; struct bt_sock *ctrl, *intr;
struct hidp_session *session; struct hidp_session *session;
if (!l2cap_is_socket(ctrl_sock) || !l2cap_is_socket(intr_sock)) if (!l2cap_is_socket(ctrl_sock) || !l2cap_is_socket(intr_sock))
return -EINVAL; return -EINVAL;
ctrl_chan = l2cap_pi(ctrl_sock->sk)->chan;
intr_chan = l2cap_pi(intr_sock->sk)->chan;
if (bacmp(&ctrl_chan->src, &intr_chan->src) ||
bacmp(&ctrl_chan->dst, &intr_chan->dst))
return -ENOTUNIQ;
ctrl = bt_sk(ctrl_sock->sk); ctrl = bt_sk(ctrl_sock->sk);
intr = bt_sk(intr_sock->sk); intr = bt_sk(intr_sock->sk);
if (bacmp(&ctrl->src, &intr->src) || bacmp(&ctrl->dst, &intr->dst))
return -ENOTUNIQ;
if (ctrl->sk.sk_state != BT_CONNECTED || if (ctrl->sk.sk_state != BT_CONNECTED ||
intr->sk.sk_state != BT_CONNECTED) intr->sk.sk_state != BT_CONNECTED)
return -EBADFD; return -EBADFD;
/* early session check, we check again during session registration */ /* early session check, we check again during session registration */
session = hidp_session_find(&ctrl->dst); session = hidp_session_find(&ctrl_chan->dst);
if (session) { if (session) {
hidp_session_put(session); hidp_session_put(session);
return -EEXIST; return -EEXIST;
...@@ -1332,7 +1338,7 @@ int hidp_connection_add(struct hidp_connadd_req *req, ...@@ -1332,7 +1338,7 @@ int hidp_connection_add(struct hidp_connadd_req *req,
if (!conn) if (!conn)
return -EBADFD; return -EBADFD;
ret = hidp_session_new(&session, &bt_sk(ctrl_sock->sk)->dst, ctrl_sock, ret = hidp_session_new(&session, &chan->dst, ctrl_sock,
intr_sock, req, conn); intr_sock, req, conn);
if (ret) if (ret)
goto out_conn; goto out_conn;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册