diff options
author | David S. Miller <davem@davemloft.net> | 2011-04-25 15:46:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-25 15:46:37 -0400 |
commit | 345578d97c549995ddbcc178f16f710602cc06bb (patch) | |
tree | ce05e39a01ffce847f6f7f65f19b1e8e20dbf0c2 /net/bluetooth/l2cap_sock.c | |
parent | fe2a70eefa18a3e419dd9a23e16af14258b7cc20 (diff) | |
parent | cfef6047c4027a8448ec8dafeaf2bb362cc882e4 (diff) |
Merge branch 'for-davem' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
Diffstat (limited to 'net/bluetooth/l2cap_sock.c')
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 72 |
1 files changed, 24 insertions, 48 deletions
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 299fe56a9668..47394a178bd5 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -269,7 +269,7 @@ static int l2cap_sock_listen(struct socket *sock, int backlog) | |||
269 | goto done; | 269 | goto done; |
270 | } | 270 | } |
271 | 271 | ||
272 | if (!l2cap_pi(sk)->psm && !l2cap_pi(sk)->dcid) { | 272 | if (!l2cap_pi(sk)->psm && !l2cap_pi(sk)->scid) { |
273 | bdaddr_t *src = &bt_sk(sk)->src; | 273 | bdaddr_t *src = &bt_sk(sk)->src; |
274 | u16 psm; | 274 | u16 psm; |
275 | 275 | ||
@@ -757,35 +757,37 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms | |||
757 | case L2CAP_MODE_ERTM: | 757 | case L2CAP_MODE_ERTM: |
758 | case L2CAP_MODE_STREAMING: | 758 | case L2CAP_MODE_STREAMING: |
759 | /* Entire SDU fits into one PDU */ | 759 | /* Entire SDU fits into one PDU */ |
760 | if (len <= pi->remote_mps) { | 760 | if (len <= pi->chan->remote_mps) { |
761 | control = L2CAP_SDU_UNSEGMENTED; | 761 | control = L2CAP_SDU_UNSEGMENTED; |
762 | skb = l2cap_create_iframe_pdu(sk, msg, len, control, 0); | 762 | skb = l2cap_create_iframe_pdu(sk, msg, len, control, 0); |
763 | if (IS_ERR(skb)) { | 763 | if (IS_ERR(skb)) { |
764 | err = PTR_ERR(skb); | 764 | err = PTR_ERR(skb); |
765 | goto done; | 765 | goto done; |
766 | } | 766 | } |
767 | __skb_queue_tail(TX_QUEUE(sk), skb); | 767 | __skb_queue_tail(&pi->chan->tx_q, skb); |
768 | 768 | ||
769 | if (sk->sk_send_head == NULL) | 769 | if (pi->chan->tx_send_head == NULL) |
770 | sk->sk_send_head = skb; | 770 | pi->chan->tx_send_head = skb; |
771 | 771 | ||
772 | } else { | 772 | } else { |
773 | /* Segment SDU into multiples PDUs */ | 773 | /* Segment SDU into multiples PDUs */ |
774 | err = l2cap_sar_segment_sdu(sk, msg, len); | 774 | err = l2cap_sar_segment_sdu(pi->chan, msg, len); |
775 | if (err < 0) | 775 | if (err < 0) |
776 | goto done; | 776 | goto done; |
777 | } | 777 | } |
778 | 778 | ||
779 | if (pi->mode == L2CAP_MODE_STREAMING) { | 779 | if (pi->mode == L2CAP_MODE_STREAMING) { |
780 | l2cap_streaming_send(sk); | 780 | l2cap_streaming_send(pi->chan); |
781 | } else { | 781 | err = len; |
782 | if ((pi->conn_state & L2CAP_CONN_REMOTE_BUSY) && | 782 | break; |
783 | (pi->conn_state & L2CAP_CONN_WAIT_F)) { | 783 | } |
784 | err = len; | 784 | |
785 | break; | 785 | if ((pi->chan->conn_state & L2CAP_CONN_REMOTE_BUSY) && |
786 | } | 786 | (pi->chan->conn_state & L2CAP_CONN_WAIT_F)) { |
787 | err = l2cap_ertm_send(sk); | 787 | err = len; |
788 | break; | ||
788 | } | 789 | } |
790 | err = l2cap_ertm_send(pi->chan); | ||
789 | 791 | ||
790 | if (err >= 0) | 792 | if (err >= 0) |
791 | err = len; | 793 | err = len; |
@@ -808,29 +810,7 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct ms | |||
808 | lock_sock(sk); | 810 | lock_sock(sk); |
809 | 811 | ||
810 | if (sk->sk_state == BT_CONNECT2 && bt_sk(sk)->defer_setup) { | 812 | if (sk->sk_state == BT_CONNECT2 && bt_sk(sk)->defer_setup) { |
811 | struct l2cap_conn_rsp rsp; | 813 | __l2cap_connect_rsp_defer(sk); |
812 | struct l2cap_conn *conn = l2cap_pi(sk)->conn; | ||
813 | u8 buf[128]; | ||
814 | |||
815 | sk->sk_state = BT_CONFIG; | ||
816 | |||
817 | rsp.scid = cpu_to_le16(l2cap_pi(sk)->dcid); | ||
818 | rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); | ||
819 | rsp.result = cpu_to_le16(L2CAP_CR_SUCCESS); | ||
820 | rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); | ||
821 | l2cap_send_cmd(l2cap_pi(sk)->conn, l2cap_pi(sk)->ident, | ||
822 | L2CAP_CONN_RSP, sizeof(rsp), &rsp); | ||
823 | |||
824 | if (l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT) { | ||
825 | release_sock(sk); | ||
826 | return 0; | ||
827 | } | ||
828 | |||
829 | l2cap_pi(sk)->conf_state |= L2CAP_CONF_REQ_SENT; | ||
830 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | ||
831 | l2cap_build_conf_req(sk, buf), buf); | ||
832 | l2cap_pi(sk)->num_conf_req++; | ||
833 | |||
834 | release_sock(sk); | 814 | release_sock(sk); |
835 | return 0; | 815 | return 0; |
836 | } | 816 | } |
@@ -886,6 +866,7 @@ static void l2cap_sock_cleanup_listen(struct sock *parent) | |||
886 | void __l2cap_sock_close(struct sock *sk, int reason) | 866 | void __l2cap_sock_close(struct sock *sk, int reason) |
887 | { | 867 | { |
888 | struct l2cap_conn *conn = l2cap_pi(sk)->conn; | 868 | struct l2cap_conn *conn = l2cap_pi(sk)->conn; |
869 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | ||
889 | 870 | ||
890 | BT_DBG("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket); | 871 | BT_DBG("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket); |
891 | 872 | ||
@@ -900,9 +881,9 @@ void __l2cap_sock_close(struct sock *sk, int reason) | |||
900 | sk->sk_type == SOCK_STREAM) && | 881 | sk->sk_type == SOCK_STREAM) && |
901 | conn->hcon->type == ACL_LINK) { | 882 | conn->hcon->type == ACL_LINK) { |
902 | l2cap_sock_set_timer(sk, sk->sk_sndtimeo); | 883 | l2cap_sock_set_timer(sk, sk->sk_sndtimeo); |
903 | l2cap_send_disconn_req(conn, sk, reason); | 884 | l2cap_send_disconn_req(conn, chan, reason); |
904 | } else | 885 | } else |
905 | l2cap_chan_del(sk, reason); | 886 | l2cap_chan_del(chan, reason); |
906 | break; | 887 | break; |
907 | 888 | ||
908 | case BT_CONNECT2: | 889 | case BT_CONNECT2: |
@@ -921,16 +902,16 @@ void __l2cap_sock_close(struct sock *sk, int reason) | |||
921 | rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); | 902 | rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); |
922 | rsp.result = cpu_to_le16(result); | 903 | rsp.result = cpu_to_le16(result); |
923 | rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); | 904 | rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); |
924 | l2cap_send_cmd(conn, l2cap_pi(sk)->ident, | 905 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, |
925 | L2CAP_CONN_RSP, sizeof(rsp), &rsp); | 906 | sizeof(rsp), &rsp); |
926 | } | 907 | } |
927 | 908 | ||
928 | l2cap_chan_del(sk, reason); | 909 | l2cap_chan_del(chan, reason); |
929 | break; | 910 | break; |
930 | 911 | ||
931 | case BT_CONNECT: | 912 | case BT_CONNECT: |
932 | case BT_DISCONN: | 913 | case BT_DISCONN: |
933 | l2cap_chan_del(sk, reason); | 914 | l2cap_chan_del(chan, reason); |
934 | break; | 915 | break; |
935 | 916 | ||
936 | default: | 917 | default: |
@@ -1035,12 +1016,7 @@ void l2cap_sock_init(struct sock *sk, struct sock *parent) | |||
1035 | } | 1016 | } |
1036 | 1017 | ||
1037 | /* Default config options */ | 1018 | /* Default config options */ |
1038 | pi->conf_len = 0; | ||
1039 | pi->flush_to = L2CAP_DEFAULT_FLUSH_TO; | 1019 | pi->flush_to = L2CAP_DEFAULT_FLUSH_TO; |
1040 | skb_queue_head_init(TX_QUEUE(sk)); | ||
1041 | skb_queue_head_init(SREJ_QUEUE(sk)); | ||
1042 | skb_queue_head_init(BUSY_QUEUE(sk)); | ||
1043 | INIT_LIST_HEAD(SREJ_LIST(sk)); | ||
1044 | } | 1020 | } |
1045 | 1021 | ||
1046 | static struct proto l2cap_proto = { | 1022 | static struct proto l2cap_proto = { |