diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2013-05-14 15:24:44 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2013-12-05 10:05:33 -0500 |
commit | 791d60f71a8d743df17a5029bb080a24afc4fff6 (patch) | |
tree | 8d285b7a72d09e3c8eae4485c7cf865cd05f1fc7 /net/bluetooth/l2cap_core.c | |
parent | ad32a2f5ced269f5516950fc8f52b6673462d208 (diff) |
Bluetooth: Refactor L2CAP connect rejection to its own function
We'll need to have a separate code path for LE based connection
rejection so it's cleaner to move out the response construction code
into its own function (and later a second one for LE).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/l2cap_core.c')
-rw-r--r-- | net/bluetooth/l2cap_core.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 256662578f89..5f9287fd86df 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -617,6 +617,27 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err) | |||
617 | return; | 617 | return; |
618 | } | 618 | } |
619 | 619 | ||
620 | static void l2cap_chan_connect_reject(struct l2cap_chan *chan) | ||
621 | { | ||
622 | struct l2cap_conn *conn = chan->conn; | ||
623 | struct l2cap_conn_rsp rsp; | ||
624 | u16 result; | ||
625 | |||
626 | if (test_bit(FLAG_DEFER_SETUP, &chan->flags)) | ||
627 | result = L2CAP_CR_SEC_BLOCK; | ||
628 | else | ||
629 | result = L2CAP_CR_BAD_PSM; | ||
630 | |||
631 | l2cap_state_change(chan, BT_DISCONN); | ||
632 | |||
633 | rsp.scid = cpu_to_le16(chan->dcid); | ||
634 | rsp.dcid = cpu_to_le16(chan->scid); | ||
635 | rsp.result = cpu_to_le16(result); | ||
636 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO); | ||
637 | |||
638 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp); | ||
639 | } | ||
640 | |||
620 | void l2cap_chan_close(struct l2cap_chan *chan, int reason) | 641 | void l2cap_chan_close(struct l2cap_chan *chan, int reason) |
621 | { | 642 | { |
622 | struct l2cap_conn *conn = chan->conn; | 643 | struct l2cap_conn *conn = chan->conn; |
@@ -639,24 +660,9 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) | |||
639 | break; | 660 | break; |
640 | 661 | ||
641 | case BT_CONNECT2: | 662 | case BT_CONNECT2: |
642 | if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && | 663 | if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED) { |
643 | conn->hcon->type == ACL_LINK) { | 664 | if (conn->hcon->type == ACL_LINK) |
644 | struct l2cap_conn_rsp rsp; | 665 | l2cap_chan_connect_reject(chan); |
645 | __u16 result; | ||
646 | |||
647 | if (test_bit(FLAG_DEFER_SETUP, &chan->flags)) | ||
648 | result = L2CAP_CR_SEC_BLOCK; | ||
649 | else | ||
650 | result = L2CAP_CR_BAD_PSM; | ||
651 | |||
652 | l2cap_state_change(chan, BT_DISCONN); | ||
653 | |||
654 | rsp.scid = cpu_to_le16(chan->dcid); | ||
655 | rsp.dcid = cpu_to_le16(chan->scid); | ||
656 | rsp.result = cpu_to_le16(result); | ||
657 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO); | ||
658 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, | ||
659 | sizeof(rsp), &rsp); | ||
660 | } | 666 | } |
661 | 667 | ||
662 | l2cap_chan_del(chan, reason); | 668 | l2cap_chan_del(chan, reason); |