aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>2011-10-11 06:37:52 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-10-13 15:50:14 -0400
commite4ca6d9854dc252e294007fc91249ce34d9a82e8 (patch)
tree7fb26dbe1312aab0c38811ef695482f033d5995f
parente37817353bf94a4e00faad78ffb8cc07f8556252 (diff)
Bluetooth: EWS: recalculate L2CAP header size
Recalculate length of L2CAP header based on Control field length. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-rw-r--r--net/bluetooth/l2cap_core.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 97aa545d66d9..439e7150f150 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -566,12 +566,17 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control)
566 struct sk_buff *skb; 566 struct sk_buff *skb;
567 struct l2cap_hdr *lh; 567 struct l2cap_hdr *lh;
568 struct l2cap_conn *conn = chan->conn; 568 struct l2cap_conn *conn = chan->conn;
569 int count, hlen = L2CAP_HDR_SIZE + 2; 569 int count, hlen;
570 u8 flags; 570 u8 flags;
571 571
572 if (chan->state != BT_CONNECTED) 572 if (chan->state != BT_CONNECTED)
573 return; 573 return;
574 574
575 if (test_bit(FLAG_EXT_CTRL, &chan->flags))
576 hlen = L2CAP_EXT_HDR_SIZE;
577 else
578 hlen = L2CAP_ENH_HDR_SIZE;
579
575 if (chan->fcs == L2CAP_FCS_CRC16) 580 if (chan->fcs == L2CAP_FCS_CRC16)
576 hlen += 2; 581 hlen += 2;
577 582
@@ -1534,7 +1539,7 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan,
1534 struct sock *sk = chan->sk; 1539 struct sock *sk = chan->sk;
1535 struct l2cap_conn *conn = chan->conn; 1540 struct l2cap_conn *conn = chan->conn;
1536 struct sk_buff *skb; 1541 struct sk_buff *skb;
1537 int err, count, hlen = L2CAP_HDR_SIZE + 2; 1542 int err, count, hlen;
1538 struct l2cap_hdr *lh; 1543 struct l2cap_hdr *lh;
1539 1544
1540 BT_DBG("sk %p len %d", sk, (int)len); 1545 BT_DBG("sk %p len %d", sk, (int)len);
@@ -1542,6 +1547,11 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan,
1542 if (!conn) 1547 if (!conn)
1543 return ERR_PTR(-ENOTCONN); 1548 return ERR_PTR(-ENOTCONN);
1544 1549
1550 if (test_bit(FLAG_EXT_CTRL, &chan->flags))
1551 hlen = L2CAP_EXT_HDR_SIZE;
1552 else
1553 hlen = L2CAP_ENH_HDR_SIZE;
1554
1545 if (sdulen) 1555 if (sdulen)
1546 hlen += 2; 1556 hlen += 2;
1547 1557
@@ -3098,7 +3108,12 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn,
3098static int l2cap_check_fcs(struct l2cap_chan *chan, struct sk_buff *skb) 3108static int l2cap_check_fcs(struct l2cap_chan *chan, struct sk_buff *skb)
3099{ 3109{
3100 u16 our_fcs, rcv_fcs; 3110 u16 our_fcs, rcv_fcs;
3101 int hdr_size = L2CAP_HDR_SIZE + 2; 3111 int hdr_size;
3112
3113 if (test_bit(FLAG_EXT_CTRL, &chan->flags))
3114 hdr_size = L2CAP_EXT_HDR_SIZE;
3115 else
3116 hdr_size = L2CAP_ENH_HDR_SIZE;
3102 3117
3103 if (chan->fcs == L2CAP_FCS_CRC16) { 3118 if (chan->fcs == L2CAP_FCS_CRC16) {
3104 skb_trim(skb, skb->len - 2); 3119 skb_trim(skb, skb->len - 2);