aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/l2cap_sock.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/l2cap_sock.c')
-rw-r--r--net/bluetooth/l2cap_sock.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index e2f14f1783f6..fa2bc5d85560 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -681,6 +681,48 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
681 return err; 681 return err;
682} 682}
683 683
684static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags)
685{
686 struct sock *sk = sock->sk;
687
688 lock_sock(sk);
689
690 if (sk->sk_state == BT_CONNECT2 && bt_sk(sk)->defer_setup) {
691 struct l2cap_conn_rsp rsp;
692 struct l2cap_conn *conn = l2cap_pi(sk)->conn;
693 u8 buf[128];
694
695 sk->sk_state = BT_CONFIG;
696
697 rsp.scid = cpu_to_le16(l2cap_pi(sk)->dcid);
698 rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid);
699 rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS);
700 rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO);
701 l2cap_send_cmd(l2cap_pi(sk)->conn, l2cap_pi(sk)->ident,
702 L2CAP_CONN_RSP, sizeof(rsp), &rsp);
703
704 if (l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT) {
705 release_sock(sk);
706 return 0;
707 }
708
709 l2cap_pi(sk)->conf_state |= L2CAP_CONF_REQ_SENT;
710 l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
711 l2cap_build_conf_req(sk, buf), buf);
712 l2cap_pi(sk)->num_conf_req++;
713
714 release_sock(sk);
715 return 0;
716 }
717
718 release_sock(sk);
719
720 if (sock->type == SOCK_STREAM)
721 return bt_sock_stream_recvmsg(iocb, sock, msg, len, flags);
722
723 return bt_sock_recvmsg(iocb, sock, msg, len, flags);
724}
725
684static int l2cap_sock_release(struct socket *sock) 726static int l2cap_sock_release(struct socket *sock)
685{ 727{
686 struct sock *sk = sock->sk; 728 struct sock *sk = sock->sk;