diff options
author | Andrei Emeltchenko <andrei.emeltchenko@intel.com> | 2011-10-11 06:37:48 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-10-13 15:45:10 -0400 |
commit | 793c2f1cb9d722231290daf1744e6c5b7269f445 (patch) | |
tree | b46ea72bcadbce72fd76241f852bdc2d358a4c4a | |
parent | fb45de7dbaf2cf8eec43a88bdb98889f0d4d5d5f (diff) |
Bluetooth: EWS: rewrite check frame type function
Check frame function uses now information about control field type.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-rw-r--r-- | include/net/bluetooth/l2cap.h | 18 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 9 |
2 files changed, 21 insertions, 6 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 3ca24af7ebc5..9444dceaee19 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -548,8 +548,22 @@ static inline __u32 __set_txseq(struct l2cap_chan *chan, __u32 txseq) | |||
548 | return (txseq << L2CAP_CTRL_TXSEQ_SHIFT) & L2CAP_CTRL_TXSEQ; | 548 | return (txseq << L2CAP_CTRL_TXSEQ_SHIFT) & L2CAP_CTRL_TXSEQ; |
549 | } | 549 | } |
550 | 550 | ||
551 | #define __is_iframe(ctrl) (!((ctrl) & L2CAP_CTRL_FRAME_TYPE)) | 551 | static inline bool __is_sframe(struct l2cap_chan *chan, __u32 ctrl) |
552 | #define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE) | 552 | { |
553 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
554 | return ctrl & L2CAP_EXT_CTRL_FRAME_TYPE; | ||
555 | else | ||
556 | return ctrl & L2CAP_CTRL_FRAME_TYPE; | ||
557 | } | ||
558 | |||
559 | static inline __u32 __set_sframe(struct l2cap_chan *chan) | ||
560 | { | ||
561 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
562 | return L2CAP_EXT_CTRL_FRAME_TYPE; | ||
563 | else | ||
564 | return L2CAP_CTRL_FRAME_TYPE; | ||
565 | } | ||
566 | |||
553 | static inline __u8 __get_ctrl_sar(struct l2cap_chan *chan, __u32 ctrl) | 567 | static inline __u8 __get_ctrl_sar(struct l2cap_chan *chan, __u32 ctrl) |
554 | { | 568 | { |
555 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | 569 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 1c367d6af995..9262a00bce55 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -578,7 +578,8 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) | |||
578 | BT_DBG("chan %p, control 0x%2.2x", chan, control); | 578 | BT_DBG("chan %p, control 0x%2.2x", chan, control); |
579 | 579 | ||
580 | count = min_t(unsigned int, conn->mtu, hlen); | 580 | count = min_t(unsigned int, conn->mtu, hlen); |
581 | control |= L2CAP_CTRL_FRAME_TYPE; | 581 | |
582 | control |= __set_sframe(chan); | ||
582 | 583 | ||
583 | if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) | 584 | if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) |
584 | control |= L2CAP_CTRL_FINAL; | 585 | control |= L2CAP_CTRL_FINAL; |
@@ -3707,7 +3708,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) | |||
3707 | if (l2cap_check_fcs(chan, skb)) | 3708 | if (l2cap_check_fcs(chan, skb)) |
3708 | goto drop; | 3709 | goto drop; |
3709 | 3710 | ||
3710 | if (__is_sar_start(chan, control) && __is_iframe(control)) | 3711 | if (__is_sar_start(chan, control) && !__is_sframe(chan, control)) |
3711 | len -= 2; | 3712 | len -= 2; |
3712 | 3713 | ||
3713 | if (chan->fcs == L2CAP_FCS_CRC16) | 3714 | if (chan->fcs == L2CAP_FCS_CRC16) |
@@ -3734,7 +3735,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) | |||
3734 | goto drop; | 3735 | goto drop; |
3735 | } | 3736 | } |
3736 | 3737 | ||
3737 | if (__is_iframe(control)) { | 3738 | if (!__is_sframe(chan, control)) { |
3738 | if (len < 0) { | 3739 | if (len < 0) { |
3739 | l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); | 3740 | l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); |
3740 | goto drop; | 3741 | goto drop; |
@@ -3817,7 +3818,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk | |||
3817 | if (chan->fcs == L2CAP_FCS_CRC16) | 3818 | if (chan->fcs == L2CAP_FCS_CRC16) |
3818 | len -= 2; | 3819 | len -= 2; |
3819 | 3820 | ||
3820 | if (len > chan->mps || len < 0 || __is_sframe(control)) | 3821 | if (len > chan->mps || len < 0 || __is_sframe(chan, control)) |
3821 | goto drop; | 3822 | goto drop; |
3822 | 3823 | ||
3823 | tx_seq = __get_txseq(chan, control); | 3824 | tx_seq = __get_txseq(chan, control); |