提交 e072745f 编写于 作者: G Gustavo F. Padovan 提交者: Marcel Holtmann

Bluetooth: Split l2cap_data_channel_sframe()

Create a function for each type fo S-frame and avoid a lot of nested
code.
Signed-off-by: NGustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: NJoão Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
上级 73edaa99
......@@ -3475,22 +3475,11 @@ static inline int l2cap_data_channel_iframe(struct sock *sk, u16 rx_control, str
return 0;
}
static inline int l2cap_data_channel_sframe(struct sock *sk, u16 rx_control, struct sk_buff *skb)
static inline void l2cap_data_channel_rrframe(struct sock *sk, u16 rx_control)
{
struct l2cap_pinfo *pi = l2cap_pi(sk);
u8 tx_seq = __get_reqseq(rx_control);
BT_DBG("sk %p rx_control 0x%4.4x len %d", sk, rx_control, skb->len);
if (L2CAP_CTRL_FINAL & rx_control) {
del_timer(&pi->monitor_timer);
if (pi->unacked_frames > 0)
__mod_retrans_timer();
pi->conn_state &= ~L2CAP_CONN_WAIT_F;
}
switch (rx_control & L2CAP_CTRL_SUPERVISE) {
case L2CAP_SUPER_RCV_READY:
if (rx_control & L2CAP_CTRL_POLL) {
l2cap_send_i_or_rr_or_rnr(sk);
pi->conn_state &= ~L2CAP_CONN_REMOTE_BUSY;
......@@ -3522,9 +3511,13 @@ static inline int l2cap_data_channel_sframe(struct sock *sk, u16 rx_control, str
else
l2cap_ertm_send(sk);
}
break;
}
static inline void l2cap_data_channel_rejframe(struct sock *sk, u16 rx_control)
{
struct l2cap_pinfo *pi = l2cap_pi(sk);
u8 tx_seq = __get_reqseq(rx_control);
case L2CAP_SUPER_REJECT:
pi->conn_state &= ~L2CAP_CONN_REMOTE_BUSY;
pi->expected_ack_seq = __get_reqseq(rx_control);
......@@ -3548,10 +3541,12 @@ static inline int l2cap_data_channel_sframe(struct sock *sk, u16 rx_control, str
pi->conn_state |= L2CAP_CONN_REJ_ACT;
}
}
}
static inline void l2cap_data_channel_srejframe(struct sock *sk, u16 rx_control)
{
struct l2cap_pinfo *pi = l2cap_pi(sk);
u8 tx_seq = __get_reqseq(rx_control);
break;
case L2CAP_SUPER_SELECT_REJECT:
pi->conn_state &= ~L2CAP_CONN_REMOTE_BUSY;
if (rx_control & L2CAP_CTRL_POLL) {
......@@ -3569,17 +3564,20 @@ static inline int l2cap_data_channel_sframe(struct sock *sk, u16 rx_control, str
pi->conn_state &= ~L2CAP_CONN_SREJ_ACT;
else
l2cap_retransmit_frame(sk, tx_seq);
}
else {
} else {
l2cap_retransmit_frame(sk, tx_seq);
if (pi->conn_state & L2CAP_CONN_WAIT_F) {
pi->srej_save_reqseq = tx_seq;
pi->conn_state |= L2CAP_CONN_SREJ_ACT;
}
}
break;
}
static inline void l2cap_data_channel_rnrframe(struct sock *sk, u16 rx_control)
{
struct l2cap_pinfo *pi = l2cap_pi(sk);
u8 tx_seq = __get_reqseq(rx_control);
case L2CAP_SUPER_RCV_NOT_READY:
pi->conn_state |= L2CAP_CONN_REMOTE_BUSY;
pi->expected_ack_seq = tx_seq;
l2cap_drop_acked_frames(sk);
......@@ -3589,6 +3587,34 @@ static inline int l2cap_data_channel_sframe(struct sock *sk, u16 rx_control, str
u16 control = L2CAP_CTRL_FINAL;
l2cap_send_rr_or_rnr(pi, control);
}
}
static inline int l2cap_data_channel_sframe(struct sock *sk, u16 rx_control, struct sk_buff *skb)
{
BT_DBG("sk %p rx_control 0x%4.4x len %d", sk, rx_control, skb->len);
if (L2CAP_CTRL_FINAL & rx_control) {
del_timer(&l2cap_pi(sk)->monitor_timer);
if (l2cap_pi(sk)->unacked_frames > 0)
__mod_retrans_timer();
l2cap_pi(sk)->conn_state &= ~L2CAP_CONN_WAIT_F;
}
switch (rx_control & L2CAP_CTRL_SUPERVISE) {
case L2CAP_SUPER_RCV_READY:
l2cap_data_channel_rrframe(sk, rx_control);
break;
case L2CAP_SUPER_REJECT:
l2cap_data_channel_rejframe(sk, rx_control);
break;
case L2CAP_SUPER_SELECT_REJECT:
l2cap_data_channel_srejframe(sk, rx_control);
break;
case L2CAP_SUPER_RCV_NOT_READY:
l2cap_data_channel_rnrframe(sk, rx_control);
break;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册