mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
component/bt : run astyle handle the code files
This commit is contained in:
235
components/bt/bluedroid/stack/rfcomm/rfc_ts_frames.c
Executable file → Normal file
235
components/bt/bluedroid/stack/rfcomm/rfc_ts_frames.c
Executable file → Normal file
@@ -44,8 +44,9 @@ void rfc_send_sabme (tRFC_MCB *p_mcb, UINT8 dlci)
|
||||
UINT8 *p_data;
|
||||
UINT8 cr = RFCOMM_CR(p_mcb->is_initiator, TRUE);
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_buf->offset = L2CAP_MIN_OFFSET;
|
||||
p_data = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
@@ -76,8 +77,9 @@ void rfc_send_ua (tRFC_MCB *p_mcb, UINT8 dlci)
|
||||
UINT8 *p_data;
|
||||
UINT8 cr = RFCOMM_CR(p_mcb->is_initiator, FALSE);
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_buf->offset = L2CAP_MIN_OFFSET;
|
||||
p_data = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
@@ -108,8 +110,9 @@ void rfc_send_dm (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN pf)
|
||||
UINT8 *p_data;
|
||||
UINT8 cr = RFCOMM_CR(p_mcb->is_initiator, FALSE);
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_buf->offset = L2CAP_MIN_OFFSET;
|
||||
p_data = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
@@ -140,8 +143,9 @@ void rfc_send_disc (tRFC_MCB *p_mcb, UINT8 dlci)
|
||||
UINT8 *p_data;
|
||||
UINT8 cr = RFCOMM_CR(p_mcb->is_initiator, TRUE);
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_buf->offset = L2CAP_MIN_OFFSET;
|
||||
p_data = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
@@ -173,36 +177,35 @@ void rfc_send_buf_uih (tRFC_MCB *p_mcb, UINT8 dlci, BT_HDR *p_buf)
|
||||
UINT8 credits;
|
||||
|
||||
p_buf->offset -= RFCOMM_CTRL_FRAME_LEN;
|
||||
if (p_buf->len > 127)
|
||||
if (p_buf->len > 127) {
|
||||
p_buf->offset--;
|
||||
}
|
||||
|
||||
if (dlci)
|
||||
if (dlci) {
|
||||
credits = (UINT8)p_buf->layer_specific;
|
||||
else
|
||||
} else {
|
||||
credits = 0;
|
||||
}
|
||||
|
||||
if (credits)
|
||||
if (credits) {
|
||||
p_buf->offset--;
|
||||
}
|
||||
|
||||
p_data = (UINT8 *)(p_buf + 1) + p_buf->offset;
|
||||
|
||||
/* UIH frame, command, PF = 0, dlci */
|
||||
*p_data++ = RFCOMM_EA | cr | (dlci << RFCOMM_SHIFT_DLCI);
|
||||
*p_data++ = RFCOMM_UIH | ((credits) ? RFCOMM_PF : 0);
|
||||
if (p_buf->len <= 127)
|
||||
{
|
||||
if (p_buf->len <= 127) {
|
||||
*p_data++ = RFCOMM_EA | (p_buf->len << 1);
|
||||
p_buf->len += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
*p_data++ = (p_buf->len & 0x7f) << 1;
|
||||
*p_data++ = p_buf->len >> RFCOMM_SHIFT_LENGTH2;
|
||||
p_buf->len += 4;
|
||||
}
|
||||
|
||||
if (credits)
|
||||
{
|
||||
if (credits) {
|
||||
*p_data++ = credits;
|
||||
p_buf->len++;
|
||||
}
|
||||
@@ -211,12 +214,9 @@ void rfc_send_buf_uih (tRFC_MCB *p_mcb, UINT8 dlci, BT_HDR *p_buf)
|
||||
|
||||
*p_data = RFCOMM_UIH_FCS ((UINT8 *)(p_buf + 1) + p_buf->offset, dlci);
|
||||
|
||||
if (dlci == RFCOMM_MX_DLCI)
|
||||
{
|
||||
if (dlci == RFCOMM_MX_DLCI) {
|
||||
rfc_check_send_cmd(p_mcb, p_buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
L2CA_DataWrite (p_mcb->lcid, p_buf);
|
||||
}
|
||||
}
|
||||
@@ -234,8 +234,9 @@ void rfc_send_pn (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN is_command, UINT16 mtu, U
|
||||
BT_HDR *p_buf;
|
||||
UINT8 *p_data;
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN;
|
||||
p_data = (UINT8 *)(p_buf + 1) + p_buf->offset;
|
||||
@@ -249,10 +250,11 @@ void rfc_send_pn (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN is_command, UINT16 mtu, U
|
||||
/* It appeared that we need to reply with the same priority bits as we received.
|
||||
** We will use the fact that we reply in the same context so rx_frame can still be used.
|
||||
*/
|
||||
if (is_command)
|
||||
if (is_command) {
|
||||
*p_data++ = RFCOMM_PN_PRIORITY_0;
|
||||
else
|
||||
} else {
|
||||
*p_data++ = rfc_cb.rfc.rx_frame.u.pn.priority;
|
||||
}
|
||||
|
||||
*p_data++ = RFCOMM_T1_DSEC;
|
||||
*p_data++ = mtu & 0xFF;
|
||||
@@ -279,8 +281,9 @@ void rfc_send_fcon (tRFC_MCB *p_mcb, BOOLEAN is_command)
|
||||
BT_HDR *p_buf;
|
||||
UINT8 *p_data;
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN;
|
||||
p_data = (UINT8 *)(p_buf + 1) + p_buf->offset;
|
||||
@@ -307,8 +310,9 @@ void rfc_send_fcoff (tRFC_MCB *p_mcb, BOOLEAN is_command)
|
||||
BT_HDR *p_buf;
|
||||
UINT8 *p_data;
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN;
|
||||
p_data = (UINT8 *)(p_buf + 1) + p_buf->offset;
|
||||
@@ -342,16 +346,18 @@ void rfc_send_msc (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN is_command,
|
||||
signals = p_pars->modem_signal;
|
||||
break_duration = p_pars->break_signal;
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN;
|
||||
p_data = (UINT8 *)(p_buf + 1) + p_buf->offset;
|
||||
|
||||
if (break_duration)
|
||||
if (break_duration) {
|
||||
len = RFCOMM_MX_MSC_LEN_WITH_BREAK;
|
||||
else
|
||||
} else {
|
||||
len = RFCOMM_MX_MSC_LEN_NO_BREAK;
|
||||
}
|
||||
|
||||
*p_data++ = RFCOMM_EA | RFCOMM_I_CR(is_command) | RFCOMM_MX_MSC;
|
||||
*p_data++ = RFCOMM_EA | (len << 1);
|
||||
@@ -364,8 +370,7 @@ void rfc_send_msc (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN is_command,
|
||||
((signals & MODEM_SIGNAL_RI) ? RFCOMM_MSC_IC : 0) |
|
||||
((signals & MODEM_SIGNAL_DCD) ? RFCOMM_MSC_DV : 0);
|
||||
|
||||
if (break_duration)
|
||||
{
|
||||
if (break_duration) {
|
||||
*p_data++ = RFCOMM_EA | RFCOMM_MSC_BREAK_PRESENT_MASK |
|
||||
(break_duration << RFCOMM_MSC_SHIFT_BREAK);
|
||||
}
|
||||
@@ -389,8 +394,9 @@ void rfc_send_rls (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN is_command, UINT8 status
|
||||
BT_HDR *p_buf;
|
||||
UINT8 *p_data;
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN;
|
||||
p_data = (UINT8 *)(p_buf + 1) + p_buf->offset;
|
||||
@@ -420,8 +426,9 @@ void rfc_send_nsc (tRFC_MCB *p_mcb)
|
||||
BT_HDR *p_buf;
|
||||
UINT8 *p_data;
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN;
|
||||
p_data = (UINT8 *)(p_buf + 1) + p_buf->offset;
|
||||
@@ -430,7 +437,7 @@ void rfc_send_nsc (tRFC_MCB *p_mcb)
|
||||
*p_data++ = RFCOMM_EA | (RFCOMM_MX_NSC_LEN << 1);
|
||||
|
||||
*p_data++ = rfc_cb.rfc.rx_frame.ea |
|
||||
(rfc_cb.rfc.rx_frame.cr << RFCOMM_SHIFT_CR) |
|
||||
(rfc_cb.rfc.rx_frame.cr << RFCOMM_SHIFT_CR) |
|
||||
rfc_cb.rfc.rx_frame.type;
|
||||
|
||||
/* Total length is sizeof NSC data + mx header 2 */
|
||||
@@ -453,32 +460,30 @@ void rfc_send_rpn (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN is_command,
|
||||
BT_HDR *p_buf;
|
||||
UINT8 *p_data;
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN;
|
||||
p_data = (UINT8 *)(p_buf + 1) + p_buf->offset;
|
||||
|
||||
*p_data++ = RFCOMM_EA | RFCOMM_I_CR(is_command) | RFCOMM_MX_RPN;
|
||||
|
||||
if (!p_pars)
|
||||
{
|
||||
if (!p_pars) {
|
||||
*p_data++ = RFCOMM_EA | (RFCOMM_MX_RPN_REQ_LEN << 1);
|
||||
|
||||
*p_data++ = RFCOMM_EA | RFCOMM_CR_MASK | (dlci << RFCOMM_SHIFT_DLCI);
|
||||
|
||||
p_buf->len = RFCOMM_MX_RPN_REQ_LEN + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
*p_data++ = RFCOMM_EA | (RFCOMM_MX_RPN_LEN << 1);
|
||||
|
||||
*p_data++ = RFCOMM_EA | RFCOMM_CR_MASK | (dlci << RFCOMM_SHIFT_DLCI);
|
||||
*p_data++ = p_pars->baud_rate;
|
||||
*p_data++ = (p_pars->byte_size << RFCOMM_RPN_BITS_SHIFT)
|
||||
| (p_pars->stop_bits << RFCOMM_RPN_STOP_BITS_SHIFT)
|
||||
| (p_pars->parity << RFCOMM_RPN_PARITY_SHIFT)
|
||||
| (p_pars->parity_type << RFCOMM_RPN_PARITY_TYPE_SHIFT);
|
||||
| (p_pars->stop_bits << RFCOMM_RPN_STOP_BITS_SHIFT)
|
||||
| (p_pars->parity << RFCOMM_RPN_PARITY_SHIFT)
|
||||
| (p_pars->parity_type << RFCOMM_RPN_PARITY_TYPE_SHIFT);
|
||||
*p_data++ = p_pars->fc_type;
|
||||
*p_data++ = p_pars->xon_char;
|
||||
*p_data++ = p_pars->xoff_char;
|
||||
@@ -507,13 +512,13 @@ void rfc_send_test (tRFC_MCB *p_mcb, BOOLEAN is_command, BT_HDR *p_buf)
|
||||
UINT8 *p_src, *p_dest;
|
||||
|
||||
/* Shift buffer to give space for header */
|
||||
if (p_buf->offset < (L2CAP_MIN_OFFSET + RFCOMM_MIN_OFFSET + 2))
|
||||
{
|
||||
if (p_buf->offset < (L2CAP_MIN_OFFSET + RFCOMM_MIN_OFFSET + 2)) {
|
||||
p_src = (UINT8 *) (p_buf + 1) + p_buf->offset + p_buf->len - 1;
|
||||
p_dest = (UINT8 *) (p_buf + 1) + L2CAP_MIN_OFFSET + RFCOMM_MIN_OFFSET + 2 + p_buf->len - 1;
|
||||
|
||||
for (xx = 0; xx < p_buf->len; xx++)
|
||||
for (xx = 0; xx < p_buf->len; xx++) {
|
||||
*p_dest-- = *p_src--;
|
||||
}
|
||||
|
||||
p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_MIN_OFFSET + 2;
|
||||
}
|
||||
@@ -543,8 +548,9 @@ void rfc_send_credit(tRFC_MCB *p_mcb, UINT8 dlci, UINT8 credit)
|
||||
UINT8 *p_data;
|
||||
UINT8 cr = RFCOMM_CR(p_mcb->is_initiator, TRUE);
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
|
||||
if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_buf->offset = L2CAP_MIN_OFFSET;
|
||||
p_data = (UINT8 *)(p_buf + 1) + p_buf->offset;
|
||||
@@ -575,15 +581,13 @@ UINT8 rfc_parse_data (tRFC_MCB *p_mcb, MX_FRAME *p_frame, BT_HDR *p_buf)
|
||||
UINT8 *p_start = p_data;
|
||||
UINT16 len;
|
||||
|
||||
if (p_buf->len < RFCOMM_CTRL_FRAME_LEN)
|
||||
{
|
||||
if (p_buf->len < RFCOMM_CTRL_FRAME_LEN) {
|
||||
RFCOMM_TRACE_ERROR ("Bad Length1: %d", p_buf->len);
|
||||
return (RFC_EVENT_BAD_FRAME);
|
||||
}
|
||||
|
||||
RFCOMM_PARSE_CTRL_FIELD (ead, p_frame->cr, p_frame->dlci, p_data);
|
||||
if( !ead )
|
||||
{
|
||||
if ( !ead ) {
|
||||
RFCOMM_TRACE_ERROR ("Bad Address(EA must be 1)");
|
||||
return (RFC_EVENT_BAD_FRAME);
|
||||
}
|
||||
@@ -595,17 +599,15 @@ UINT8 rfc_parse_data (tRFC_MCB *p_mcb, MX_FRAME *p_frame, BT_HDR *p_buf)
|
||||
|
||||
/* handle credit if credit based flow control */
|
||||
if ((p_mcb->flow == PORT_FC_CREDIT) && (p_frame->type == RFCOMM_UIH) &&
|
||||
(p_frame->dlci != RFCOMM_MX_DLCI) && (p_frame->pf == 1))
|
||||
{
|
||||
(p_frame->dlci != RFCOMM_MX_DLCI) && (p_frame->pf == 1)) {
|
||||
p_frame->credit = *p_data++;
|
||||
p_buf->len--;
|
||||
p_buf->offset++;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
p_frame->credit = 0;
|
||||
}
|
||||
|
||||
if (p_buf->len != len)
|
||||
{
|
||||
if (p_buf->len != len) {
|
||||
RFCOMM_TRACE_ERROR ("Bad Length2 %d %d", p_buf->len, len);
|
||||
return (RFC_EVENT_BAD_FRAME);
|
||||
}
|
||||
@@ -616,71 +618,61 @@ UINT8 rfc_parse_data (tRFC_MCB *p_mcb, MX_FRAME *p_frame, BT_HDR *p_buf)
|
||||
/* reply with F=1 */
|
||||
/* According to TS 07.10 spec ivalid frames are discarded without */
|
||||
/* notification to the sender */
|
||||
switch (p_frame->type)
|
||||
{
|
||||
switch (p_frame->type) {
|
||||
case RFCOMM_SABME:
|
||||
if (RFCOMM_FRAME_IS_RSP(p_mcb->is_initiator, p_frame->cr)
|
||||
|| !p_frame->pf || len || !RFCOMM_VALID_DLCI (p_frame->dlci)
|
||||
|| !rfc_check_fcs (RFCOMM_CTRL_FRAME_LEN, p_start, fcs))
|
||||
{
|
||||
|| !p_frame->pf || len || !RFCOMM_VALID_DLCI (p_frame->dlci)
|
||||
|| !rfc_check_fcs (RFCOMM_CTRL_FRAME_LEN, p_start, fcs)) {
|
||||
RFCOMM_TRACE_ERROR ("Bad SABME");
|
||||
return (RFC_EVENT_BAD_FRAME);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return (RFC_EVENT_SABME);
|
||||
}
|
||||
|
||||
case RFCOMM_UA:
|
||||
if (RFCOMM_FRAME_IS_CMD(p_mcb->is_initiator, p_frame->cr)
|
||||
|| !p_frame->pf || len || !RFCOMM_VALID_DLCI (p_frame->dlci)
|
||||
|| !rfc_check_fcs (RFCOMM_CTRL_FRAME_LEN, p_start, fcs))
|
||||
{
|
||||
|| !p_frame->pf || len || !RFCOMM_VALID_DLCI (p_frame->dlci)
|
||||
|| !rfc_check_fcs (RFCOMM_CTRL_FRAME_LEN, p_start, fcs)) {
|
||||
RFCOMM_TRACE_ERROR ("Bad UA");
|
||||
return (RFC_EVENT_BAD_FRAME);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return (RFC_EVENT_UA);
|
||||
}
|
||||
|
||||
case RFCOMM_DM:
|
||||
if (RFCOMM_FRAME_IS_CMD(p_mcb->is_initiator, p_frame->cr)
|
||||
|| len || !RFCOMM_VALID_DLCI(p_frame->dlci)
|
||||
|| !rfc_check_fcs (RFCOMM_CTRL_FRAME_LEN, p_start, fcs))
|
||||
{
|
||||
|| len || !RFCOMM_VALID_DLCI(p_frame->dlci)
|
||||
|| !rfc_check_fcs (RFCOMM_CTRL_FRAME_LEN, p_start, fcs)) {
|
||||
RFCOMM_TRACE_ERROR ("Bad DM");
|
||||
return (RFC_EVENT_BAD_FRAME);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return (RFC_EVENT_DM);
|
||||
}
|
||||
|
||||
case RFCOMM_DISC:
|
||||
if (RFCOMM_FRAME_IS_RSP(p_mcb->is_initiator, p_frame->cr)
|
||||
|| !p_frame->pf || len || !RFCOMM_VALID_DLCI(p_frame->dlci)
|
||||
|| !rfc_check_fcs (RFCOMM_CTRL_FRAME_LEN, p_start, fcs))
|
||||
{
|
||||
|| !p_frame->pf || len || !RFCOMM_VALID_DLCI(p_frame->dlci)
|
||||
|| !rfc_check_fcs (RFCOMM_CTRL_FRAME_LEN, p_start, fcs)) {
|
||||
RFCOMM_TRACE_ERROR ("Bad DISC");
|
||||
return (RFC_EVENT_BAD_FRAME);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return (RFC_EVENT_DISC);
|
||||
}
|
||||
|
||||
case RFCOMM_UIH:
|
||||
if (!RFCOMM_VALID_DLCI(p_frame->dlci))
|
||||
{
|
||||
if (!RFCOMM_VALID_DLCI(p_frame->dlci)) {
|
||||
RFCOMM_TRACE_ERROR ("Bad UIH - invalid DLCI");
|
||||
return (RFC_EVENT_BAD_FRAME);
|
||||
}
|
||||
else if (!rfc_check_fcs (2, p_start, fcs))
|
||||
{
|
||||
} else if (!rfc_check_fcs (2, p_start, fcs)) {
|
||||
RFCOMM_TRACE_ERROR ("Bad UIH - FCS");
|
||||
return (RFC_EVENT_BAD_FRAME);
|
||||
}
|
||||
else if (RFCOMM_FRAME_IS_RSP(p_mcb->is_initiator, p_frame->cr))
|
||||
{
|
||||
} else if (RFCOMM_FRAME_IS_RSP(p_mcb->is_initiator, p_frame->cr)) {
|
||||
/* we assume that this is ok to allow bad implementations to work */
|
||||
RFCOMM_TRACE_ERROR ("Bad UIH - response");
|
||||
return (RFC_EVENT_UIH);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return (RFC_EVENT_UIH);
|
||||
}
|
||||
}
|
||||
|
||||
return (RFC_EVENT_BAD_FRAME);
|
||||
@@ -707,8 +699,7 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
|
||||
p_rx_frame->cr = (*p_data & RFCOMM_CR_MASK) >> RFCOMM_SHIFT_CR;
|
||||
p_rx_frame->type = *p_data++ & ~(RFCOMM_CR_MASK | RFCOMM_EA_MASK);
|
||||
|
||||
if (!p_rx_frame->ea || !length)
|
||||
{
|
||||
if (!p_rx_frame->ea || !length) {
|
||||
RFCOMM_TRACE_ERROR ("Illegal MX Frame ea:%d len:%d", p_rx_frame->ea, length);
|
||||
GKI_freebuf (p_buf);
|
||||
return;
|
||||
@@ -723,24 +714,22 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
|
||||
mx_len = *p_data++ >> RFCOMM_SHIFT_LENGTH1;
|
||||
length--;
|
||||
|
||||
if (!ea)
|
||||
{
|
||||
if (!ea) {
|
||||
mx_len += *p_data++ << RFCOMM_SHIFT_LENGTH2;
|
||||
length --;
|
||||
}
|
||||
|
||||
if (mx_len != length)
|
||||
{
|
||||
if (mx_len != length) {
|
||||
RFCOMM_TRACE_ERROR ("Bad MX frame");
|
||||
GKI_freebuf (p_buf);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (p_rx_frame->type)
|
||||
{
|
||||
switch (p_rx_frame->type) {
|
||||
case RFCOMM_MX_PN:
|
||||
if (length != RFCOMM_MX_PN_LEN)
|
||||
if (length != RFCOMM_MX_PN_LEN) {
|
||||
break;
|
||||
}
|
||||
|
||||
p_rx_frame->dlci = *p_data++ & RFCOMM_PN_DLCI_MASK;
|
||||
p_rx_frame->u.pn.frame_type = *p_data & RFCOMM_PN_FRAME_TYPE_MASK;
|
||||
@@ -753,10 +742,9 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
|
||||
p_rx_frame->u.pn.k = *p_data++ & RFCOMM_PN_K_MASK;
|
||||
|
||||
if (!p_rx_frame->dlci
|
||||
|| !RFCOMM_VALID_DLCI (p_rx_frame->dlci)
|
||||
|| (p_rx_frame->u.pn.mtu < RFCOMM_MIN_MTU)
|
||||
|| (p_rx_frame->u.pn.mtu > RFCOMM_MAX_MTU))
|
||||
{
|
||||
|| !RFCOMM_VALID_DLCI (p_rx_frame->dlci)
|
||||
|| (p_rx_frame->u.pn.mtu < RFCOMM_MIN_MTU)
|
||||
|| (p_rx_frame->u.pn.mtu > RFCOMM_MAX_MTU)) {
|
||||
RFCOMM_TRACE_ERROR ("Bad PN frame");
|
||||
break;
|
||||
}
|
||||
@@ -767,8 +755,9 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
|
||||
return;
|
||||
|
||||
case RFCOMM_MX_TEST:
|
||||
if (!length)
|
||||
if (!length) {
|
||||
break;
|
||||
}
|
||||
|
||||
p_rx_frame->u.test.p_data = p_data;
|
||||
p_rx_frame->u.test.data_len = length;
|
||||
@@ -776,15 +765,17 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
|
||||
p_buf->offset += 2;
|
||||
p_buf->len -= 2;
|
||||
|
||||
if (is_command)
|
||||
if (is_command) {
|
||||
rfc_send_test (p_mcb, FALSE, p_buf);
|
||||
else
|
||||
} else {
|
||||
rfc_process_test_rsp (p_mcb, p_buf);
|
||||
}
|
||||
return;
|
||||
|
||||
case RFCOMM_MX_FCON:
|
||||
if (length != RFCOMM_MX_FCON_LEN)
|
||||
if (length != RFCOMM_MX_FCON_LEN) {
|
||||
break;
|
||||
}
|
||||
|
||||
GKI_freebuf (p_buf);
|
||||
|
||||
@@ -792,8 +783,9 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
|
||||
return;
|
||||
|
||||
case RFCOMM_MX_FCOFF:
|
||||
if (length != RFCOMM_MX_FCOFF_LEN)
|
||||
if (length != RFCOMM_MX_FCOFF_LEN) {
|
||||
break;
|
||||
}
|
||||
|
||||
GKI_freebuf (p_buf);
|
||||
|
||||
@@ -807,21 +799,17 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
|
||||
p_rx_frame->dlci = *p_data++ >> RFCOMM_SHIFT_DLCI;
|
||||
|
||||
if (!ea || !cr || !p_rx_frame->dlci
|
||||
|| !RFCOMM_VALID_DLCI (p_rx_frame->dlci))
|
||||
{
|
||||
|| !RFCOMM_VALID_DLCI (p_rx_frame->dlci)) {
|
||||
RFCOMM_TRACE_ERROR ("Bad MSC frame");
|
||||
break;
|
||||
}
|
||||
|
||||
p_rx_frame->u.msc.signals = *p_data++;
|
||||
|
||||
if (mx_len == RFCOMM_MX_MSC_LEN_WITH_BREAK)
|
||||
{
|
||||
if (mx_len == RFCOMM_MX_MSC_LEN_WITH_BREAK) {
|
||||
p_rx_frame->u.msc.break_present = *p_data & RFCOMM_MSC_BREAK_PRESENT_MASK;
|
||||
p_rx_frame->u.msc.break_duration = (*p_data & RFCOMM_MSC_BREAK_MASK) >> RFCOMM_MSC_SHIFT_BREAK;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p_rx_frame->u.msc.break_present = FALSE;
|
||||
p_rx_frame->u.msc.break_duration = 0;
|
||||
}
|
||||
@@ -831,8 +819,9 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
|
||||
return;
|
||||
|
||||
case RFCOMM_MX_NSC:
|
||||
if ((length != RFCOMM_MX_NSC_LEN) || !is_command)
|
||||
if ((length != RFCOMM_MX_NSC_LEN) || !is_command) {
|
||||
break;
|
||||
}
|
||||
|
||||
p_rx_frame->u.nsc.ea = *p_data & RFCOMM_EA;
|
||||
p_rx_frame->u.nsc.cr = (*p_data & RFCOMM_CR_MASK) >> RFCOMM_SHIFT_CR;
|
||||
@@ -844,24 +833,23 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
|
||||
return;
|
||||
|
||||
case RFCOMM_MX_RPN:
|
||||
if ((length != RFCOMM_MX_RPN_REQ_LEN) && (length != RFCOMM_MX_RPN_LEN))
|
||||
if ((length != RFCOMM_MX_RPN_REQ_LEN) && (length != RFCOMM_MX_RPN_LEN)) {
|
||||
break;
|
||||
}
|
||||
|
||||
ea = *p_data & RFCOMM_EA;
|
||||
cr = (*p_data & RFCOMM_CR_MASK) >> RFCOMM_SHIFT_CR;
|
||||
p_rx_frame->dlci = *p_data++ >> RFCOMM_SHIFT_DLCI;
|
||||
|
||||
if (!ea || !cr || !p_rx_frame->dlci
|
||||
|| !RFCOMM_VALID_DLCI (p_rx_frame->dlci))
|
||||
{
|
||||
|| !RFCOMM_VALID_DLCI (p_rx_frame->dlci)) {
|
||||
RFCOMM_TRACE_ERROR ("Bad RPN frame");
|
||||
break;
|
||||
}
|
||||
|
||||
p_rx_frame->u.rpn.is_request = (length == RFCOMM_MX_RPN_REQ_LEN);
|
||||
|
||||
if (!p_rx_frame->u.rpn.is_request)
|
||||
{
|
||||
if (!p_rx_frame->u.rpn.is_request) {
|
||||
p_rx_frame->u.rpn.baud_rate = *p_data++;
|
||||
p_rx_frame->u.rpn.byte_size = (*p_data >> RFCOMM_RPN_BITS_SHIFT) & RFCOMM_RPN_BITS_MASK;
|
||||
p_rx_frame->u.rpn.stop_bits = (*p_data >> RFCOMM_RPN_STOP_BITS_SHIFT) & RFCOMM_RPN_STOP_BITS_MASK;
|
||||
@@ -879,8 +867,9 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
|
||||
return;
|
||||
|
||||
case RFCOMM_MX_RLS:
|
||||
if (length != RFCOMM_MX_RLS_LEN)
|
||||
if (length != RFCOMM_MX_RLS_LEN) {
|
||||
break;
|
||||
}
|
||||
|
||||
ea = *p_data & RFCOMM_EA;
|
||||
cr = (*p_data & RFCOMM_CR_MASK) >> RFCOMM_SHIFT_CR;
|
||||
@@ -889,8 +878,7 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
|
||||
p_rx_frame->u.rls.line_status = (*p_data & ~0x01);
|
||||
|
||||
if (!ea || !cr || !p_rx_frame->dlci
|
||||
|| !RFCOMM_VALID_DLCI (p_rx_frame->dlci))
|
||||
{
|
||||
|| !RFCOMM_VALID_DLCI (p_rx_frame->dlci)) {
|
||||
RFCOMM_TRACE_ERROR ("Bad RPN frame");
|
||||
break;
|
||||
}
|
||||
@@ -903,7 +891,8 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
|
||||
|
||||
GKI_freebuf (p_buf);
|
||||
|
||||
if (is_command)
|
||||
if (is_command) {
|
||||
rfc_send_nsc (p_mcb);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user