aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/bluetooth/l2cap.h
diff options
context:
space:
mode:
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>2011-10-11 06:37:45 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-10-13 15:44:53 -0400
commit7e0ef6ee13ecdf38c2c8b0b0c8ef729710b994eb (patch)
tree1c56a49a58982481ad89cb0daedd2c6e7e1259a7 /include/net/bluetooth/l2cap.h
parentab784b7383735681660ccbdda4569fff196c2672 (diff)
Bluetooth: EWS: rewrite handling SAR bits
Segmentation and Reassembly (SAR) occupies different windows in standard and extended control fields. Convert hardcoded masks to relative ones and use shift to access SAR bits. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'include/net/bluetooth/l2cap.h')
-rw-r--r--include/net/bluetooth/l2cap.h37
1 files changed, 32 insertions, 5 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index f24f5cf820d7..0759ac68af5e 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -146,10 +146,10 @@ struct l2cap_conninfo {
146#define L2CAP_SUPER_SREJ 0x03 146#define L2CAP_SUPER_SREJ 0x03
147 147
148/* L2CAP Segmentation and Reassembly */ 148/* L2CAP Segmentation and Reassembly */
149#define L2CAP_SDU_UNSEGMENTED 0x0000 149#define L2CAP_SAR_UNSEGMENTED 0x00
150#define L2CAP_SDU_START 0x4000 150#define L2CAP_SAR_START 0x01
151#define L2CAP_SDU_END 0x8000 151#define L2CAP_SAR_END 0x02
152#define L2CAP_SDU_CONTINUE 0xC000 152#define L2CAP_SAR_CONTINUE 0x03
153 153
154/* L2CAP Command rej. reasons */ 154/* L2CAP Command rej. reasons */
155#define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 155#define L2CAP_REJ_NOT_UNDERSTOOD 0x0000
@@ -516,7 +516,34 @@ static inline int l2cap_tx_window_full(struct l2cap_chan *ch)
516#define __get_reqseq(ctrl) (((ctrl) & L2CAP_CTRL_REQSEQ) >> 8) 516#define __get_reqseq(ctrl) (((ctrl) & L2CAP_CTRL_REQSEQ) >> 8)
517#define __is_iframe(ctrl) (!((ctrl) & L2CAP_CTRL_FRAME_TYPE)) 517#define __is_iframe(ctrl) (!((ctrl) & L2CAP_CTRL_FRAME_TYPE))
518#define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE) 518#define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE)
519#define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START) 519static inline __u8 __get_ctrl_sar(struct l2cap_chan *chan, __u32 ctrl)
520{
521 if (test_bit(FLAG_EXT_CTRL, &chan->flags))
522 return (ctrl & L2CAP_EXT_CTRL_SAR) >> L2CAP_EXT_CTRL_SAR_SHIFT;
523 else
524 return (ctrl & L2CAP_CTRL_SAR) >> L2CAP_CTRL_SAR_SHIFT;
525}
526
527static inline __u32 __set_ctrl_sar(struct l2cap_chan *chan, __u32 sar)
528{
529 if (test_bit(FLAG_EXT_CTRL, &chan->flags))
530 return (sar << L2CAP_EXT_CTRL_SAR_SHIFT) & L2CAP_EXT_CTRL_SAR;
531 else
532 return (sar << L2CAP_CTRL_SAR_SHIFT) & L2CAP_CTRL_SAR;
533}
534
535static inline bool __is_sar_start(struct l2cap_chan *chan, __u32 ctrl)
536{
537 return __get_ctrl_sar(chan, ctrl) == L2CAP_SAR_START;
538}
539
540static inline __u32 __get_sar_mask(struct l2cap_chan *chan)
541{
542 if (test_bit(FLAG_EXT_CTRL, &chan->flags))
543 return L2CAP_EXT_CTRL_SAR;
544 else
545 return L2CAP_CTRL_SAR;
546}
520 547
521static inline __u8 __get_ctrl_super(struct l2cap_chan *chan, __u32 ctrl) 548static inline __u8 __get_ctrl_super(struct l2cap_chan *chan, __u32 ctrl)
522{ 549{