apache-mynewt-bot commented on PR #1424:
URL: https://github.com/apache/mynewt-nimble/pull/1424#issuecomment-1366794889

   
   <!-- style-bot -->
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
   #### nimble/controller/src/ble_ll_ctrl.c
   <details>
   
   ```diff
   @@ -2097,53 +2096,53 @@
                (connsm->max_tx_time <= BLE_LL_CONN_SUPP_TIME_MIN) &&
                (connsm->max_rx_time <= BLE_LL_CONN_SUPP_TIME_MIN)) {
                return;
   -    } else {
   -        if ((connsm->max_tx_octets < BLE_LL_CONN_SUPP_BYTES_MIN) &&
   -            (connsm->max_rx_octets < BLE_LL_CONN_SUPP_BYTES_MIN) &&
   -            (connsm->max_tx_time < BLE_LL_CONN_SUPP_TIME_MIN) &&
   -            (connsm->max_rx_time < BLE_LL_CONN_SUPP_TIME_MIN)) {
   -            return;
   -    }
   -
   -    ble_ll_ctrl_proc_start(connsm, BLE_LL_CTRL_PROC_DATA_LEN_UPD, NULL);
   -}
   -
   -static void
   -ble_ll_ctrl_update_features(struct ble_ll_conn_sm *connsm, uint8_t *feat)
   -{
   -    connsm->conn_features = feat[0];
   -    memcpy(connsm->remote_features, feat + 1, 7);
   -
   -    /* If we received peer's features for the 1st time, we should try DLE */
   -    if (!connsm->csmflags.cfbit.rxd_features) {
   +        } else {
   +            if ((connsm->max_tx_octets < BLE_LL_CONN_SUPP_BYTES_MIN) &&
   +                (connsm->max_rx_octets < BLE_LL_CONN_SUPP_BYTES_MIN) &&
   +                (connsm->max_tx_time < BLE_LL_CONN_SUPP_TIME_MIN) &&
   +                (connsm->max_rx_time < BLE_LL_CONN_SUPP_TIME_MIN)) {
   +                return;
   +            }
   +
   +            ble_ll_ctrl_proc_start(connsm, BLE_LL_CTRL_PROC_DATA_LEN_UPD, 
NULL);
   +        }
   +
   +        static void
   +        ble_ll_ctrl_update_features(struct ble_ll_conn_sm *connsm, uint8_t 
*feat)
   +        {
   +            connsm->conn_features = feat[0];
   +            memcpy(connsm->remote_features, feat + 1, 7);
   +
   +            /* If we received peer's features for the 1st time, we should 
try DLE */
   +            if (!connsm->csmflags.cfbit.rxd_features) {
    #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CODED_PHY)
   -        /*
   -         * If connection was established on uncoded PHY, by default we use
   -         * MaxTxTime and MaxRxTime applicable for that PHY since we are not
   -         * allowed to indicate longer supported time if peer does not 
support
   -         * LE Coded PHY. However, once we know that peer does support it we 
can
   -         * update those values to ones applicable for coded PHY.
   -         */
   -        if (ble_ll_conn_rem_feature_check(connsm, 
BLE_LL_FEAT_LE_CODED_PHY)) {
   -            if (connsm->host_req_max_tx_time) {
   -                connsm->max_tx_time = max(connsm->max_tx_time,
   +                /*
   +                 * If connection was established on uncoded PHY, by default 
we use
   +                 * MaxTxTime and MaxRxTime applicable for that PHY since we 
are not
   +                 * allowed to indicate longer supported time if peer does 
not support
   +                 * LE Coded PHY. However, once we know that peer does 
support it we can
   +                 * update those values to ones applicable for coded PHY.
   +                 */
   +                if (ble_ll_conn_rem_feature_check(connsm, 
BLE_LL_FEAT_LE_CODED_PHY)) {
   +                    if (connsm->host_req_max_tx_time) {
   +                        connsm->max_tx_time = max(connsm->max_tx_time,
                                              connsm->host_req_max_tx_time);
   -            } else {
   -                connsm->max_tx_time = 
g_ble_ll_conn_params.conn_init_max_tx_time_coded;
   -            }
   -            if (connsm->host_req_max_rx_time) {
   -                connsm->max_rx_time = max(connsm->max_rx_time,
   +                    } else {
   +                        connsm->max_tx_time = 
g_ble_ll_conn_params.conn_init_max_tx_time_coded;
   +                    }
   +                    if (connsm->host_req_max_rx_time) {
   +                        connsm->max_rx_time = max(connsm->max_rx_time,
                                              connsm->host_req_max_rx_time);
   -            } else {
   -                connsm->max_rx_time = BLE_LL_CONN_SUPP_TIME_MAX_CODED;
   -            }
   -        }
   -#endif
   -
   -        connsm->csmflags.cfbit.pending_initiate_dle = 1;
   -        connsm->csmflags.cfbit.rxd_features = 1;
   -    }
   -}
   +                    } else {
   +                        connsm->max_rx_time = 
BLE_LL_CONN_SUPP_TIME_MAX_CODED;
   +                    }
   +                }
   +#endif
   +
   +                connsm->csmflags.cfbit.pending_initiate_dle = 1;
   +                connsm->csmflags.cfbit.rxd_features = 1;
   +            }
   +        }
    
    /**
     * Called when we receive a feature request or a peripheral initiated 
feature
   @@ -2746,320 +2745,320 @@
     * @param om
     * @param connsm
     */
   -int
   -ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
   -{
   -    uint64_t features;
   -    uint64_t feature;
   -    uint8_t len;
   -    uint8_t opcode;
   -    uint8_t rsp_opcode;
   -    uint8_t *dptr;
   -    uint8_t *rspbuf;
   -    uint8_t *rspdata;
   +        int
   +        ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf 
*om)
   +        {
   +            uint64_t features;
   +            uint64_t feature;
   +            uint8_t len;
   +            uint8_t opcode;
   +            uint8_t rsp_opcode;
   +            uint8_t *dptr;
   +            uint8_t *rspbuf;
   +            uint8_t *rspdata;
    #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION)
   -    int restart_encryption;
   -#endif
   -    int rc = 0;
   -
   -    /* XXX: where do we validate length received and packet header length?
   -     * do this in LL task when received. Someplace!!! What I mean
   -     * is we should validate the over the air length with the mbuf length.
   -       Should the PHY do that???? */
   -
   -    /*
   -     * dptr points to om_data pointer. The first byte of om_data is the
   -     * first byte of the Data Channel PDU header. Get length from header and
   -     * opcode from LL control PDU.
   -     */
   -    dptr = om->om_data;
   -    len = dptr[1];
   -    opcode = dptr[2];
   +            int restart_encryption;
   +#endif
   +            int rc = 0;
   +
   +            /* XXX: where do we validate length received and packet header 
length?
   +             * do this in LL task when received. Someplace!!! What I mean
   +             * is we should validate the over the air length with the mbuf 
length.
   +               Should the PHY do that???? */
   +
   +            /*
   +             * dptr points to om_data pointer. The first byte of om_data is 
the
   +             * first byte of the Data Channel PDU header. Get length from 
header and
   +             * opcode from LL control PDU.
   +             */
   +            dptr = om->om_data;
   +            len = dptr[1];
   +            opcode = dptr[2];
    
    #if MYNEWT_VAL(BLE_LL_HCI_LLCP_TRACE)
   -    ble_ll_hci_ev_send_vs_llcp_trace(0x03, connsm->conn_handle,
   +            ble_ll_hci_ev_send_vs_llcp_trace(0x03, connsm->conn_handle,
                                         connsm->event_cntr,
                                         &dptr[2], len);
    #endif
    
   -    /*
   -     * rspbuf points to first byte of response. The response buffer does not
   -     * contain the Data Channel PDU. Thus, the first byte of rspbuf is the
   -     * LL control PDU payload (the opcode of the control PDU). rspdata
   -     * points to CtrData in the control PDU.
   -     */
   -    rspbuf = dptr;
   -    rspdata = rspbuf + 1;
   -
   -    /* Move data pointer to start of control data (2 byte PDU hdr + opcode) 
*/
   -    dptr += (BLE_LL_PDU_HDR_LEN + 1);
   -
   -    /*
   -     * Subtract the opcode from the length. Note that if the length was 
zero,
   -     * which would be an error, we will fail the check against the length
   -     * of the control packet.
   -     */
   -    --len;
   -
   -    ble_ll_trace_u32x2(BLE_LL_TRACE_ID_CTRL_RX, opcode, len);
   +            /*
   +             * rspbuf points to first byte of response. The response buffer 
does not
   +             * contain the Data Channel PDU. Thus, the first byte of rspbuf 
is the
   +             * LL control PDU payload (the opcode of the control PDU). 
rspdata
   +             * points to CtrData in the control PDU.
   +             */
   +            rspbuf = dptr;
   +            rspdata = rspbuf + 1;
   +
   +            /* Move data pointer to start of control data (2 byte PDU hdr + 
opcode) */
   +            dptr += (BLE_LL_PDU_HDR_LEN + 1);
   +
   +            /*
   +             * Subtract the opcode from the length. Note that if the length 
was zero,
   +             * which would be an error, we will fail the check against the 
length
   +             * of the control packet.
   +             */
   +            --len;
   +
   +            ble_ll_trace_u32x2(BLE_LL_TRACE_ID_CTRL_RX, opcode, len);
    
    #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION)
   -    restart_encryption = 0;
   -#endif
   -
   -    /* If opcode comes from reserved value or CtrlData fields is invalid
   -     * we shall respond with LL_UNKNOWN_RSP
   -     */
   -    if ((opcode >= BLE_LL_CTRL_OPCODES) ||
   -        (len != g_ble_ll_ctrl_pkt_lengths[opcode])) {
   -        rc = -1;
   -        rsp_opcode = BLE_LL_CTRL_UNKNOWN_RSP;
   -        goto ll_ctrl_send_rsp;
   -    }
   -
   -    /* Check if the feature is supported. */
   -    switch (opcode) {
   -    case BLE_LL_CTRL_LENGTH_REQ:
   -        feature = BLE_LL_FEAT_DATA_LEN_EXT;
   -        break;
   -    case BLE_LL_CTRL_PERIPH_FEATURE_REQ:
   -        feature = BLE_LL_FEAT_PERIPH_INIT;
   -        break;
   -    case BLE_LL_CTRL_CONN_PARM_REQ:
   -    case BLE_LL_CTRL_CONN_PARM_RSP:
   -        feature = BLE_LL_FEAT_CONN_PARM_REQ;
   -        break;
   -    case BLE_LL_CTRL_ENC_REQ:
   -    case BLE_LL_CTRL_START_ENC_REQ:
   -    case BLE_LL_CTRL_PAUSE_ENC_REQ:
   -        feature = BLE_LL_FEAT_LE_ENCRYPTION;
   -        break;
   -    case BLE_LL_CTRL_PING_REQ:
   -        feature = BLE_LL_FEAT_LE_PING;
   -        break;
   -    case BLE_LL_CTRL_PHY_REQ:
   -        feature = BLE_LL_FEAT_LE_2M_PHY | BLE_LL_FEAT_LE_CODED_PHY;
   -        break;
   -    case BLE_LL_CTRL_MIN_USED_CHAN_IND:
   -        feature = BLE_LL_FEAT_MIN_USED_CHAN;
   -        break;
   -    case BLE_LL_CTRL_PERIODIC_SYNC_IND:
   -        feature = BLE_LL_FEAT_SYNC_TRANS_RECV;
   -        break;
   -    case BLE_LL_CTRL_SUBRATE_REQ:
   -    case BLE_LL_CTRL_SUBRATE_IND:
   -        feature = BLE_LL_FEAT_CONN_SUBRATING;
   -        break;
   -    default:
   -        feature = 0;
   -        break;
   -    }
   -
   -    if (feature) {
   -        features = ble_ll_read_supp_features();
   -        if ((features & feature) == 0) {
   -            if (opcode == BLE_LL_CTRL_ENC_REQ) {
   -                if (connsm->conn_features & BLE_LL_FEAT_EXTENDED_REJ) {
   -                    rsp_opcode = BLE_LL_CTRL_REJECT_IND_EXT;
   -                    rspbuf[1] = opcode;
   -                    rspbuf[2] = BLE_ERR_UNSUPP_REM_FEATURE;
   -
   -                } else {
   -                    rsp_opcode = BLE_LL_CTRL_REJECT_IND;
   -                    rspbuf[1] = BLE_ERR_UNSUPP_REM_FEATURE;
   -                }
   -            } else {
   -                /* Construct unknown rsp pdu */
   -                rsp_opcode = BLE_LL_CTRL_UNKNOWN_RSP;
   -            }
   -            goto ll_ctrl_send_rsp;
   -        }
   -    }
   -
   -    /* Process opcode */
   -    rsp_opcode = BLE_ERR_MAX;
   -    switch (opcode) {
   -    case BLE_LL_CTRL_CONN_UPDATE_IND:
   -        rsp_opcode = ble_ll_ctrl_rx_conn_update(connsm, dptr);
   -        break;
   -    case BLE_LL_CTRL_CHANNEL_MAP_REQ:
   -        rsp_opcode = ble_ll_ctrl_rx_chanmap_req(connsm, dptr);
   -        break;
   -    case BLE_LL_CTRL_LENGTH_REQ:
   -        /* Extract parameters and check if valid */
   -        if (ble_ll_ctrl_len_proc(connsm, dptr)) {
   -            rc  = -1;
   -            rsp_opcode = BLE_LL_CTRL_UNKNOWN_RSP;
   -            goto ll_ctrl_send_rsp;
   -        }
   -
   -        /*
   -         * If we have not started this procedure ourselves and it is
   -         * pending, no need to perform it.
   -         */
   -        if ((connsm->cur_ctrl_proc != BLE_LL_CTRL_PROC_DATA_LEN_UPD) &&
   -            IS_PENDING_CTRL_PROC(connsm, BLE_LL_CTRL_PROC_DATA_LEN_UPD)) {
   -            CLR_PENDING_CTRL_PROC(connsm, BLE_LL_CTRL_PROC_DATA_LEN_UPD);
   -        }
   -
   -        /* Send a response */
   -        rsp_opcode = BLE_LL_CTRL_LENGTH_RSP;
   -        ble_ll_ctrl_datalen_upd_make(connsm, rspbuf);
   -        break;
   -    case BLE_LL_CTRL_LENGTH_RSP:
   -        /* According to specification, process this only if we asked for 
it. */
   -        if (connsm->cur_ctrl_proc == BLE_LL_CTRL_PROC_DATA_LEN_UPD) {
   -            /*
   -             * Process the received data. If received data is invalid, we'll
   -             * reply with LL_UNKNOWN_RSP as per spec, but we still need to 
stop
   -             * control procedure to avoid timeout.
   +            restart_encryption = 0;
   +#endif
   +
   +            /* If opcode comes from reserved value or CtrlData fields is 
invalid
   +             * we shall respond with LL_UNKNOWN_RSP
                 */
   -            if (ble_ll_ctrl_len_proc(connsm, dptr)) {
   +            if ((opcode >= BLE_LL_CTRL_OPCODES) ||
   +                (len != g_ble_ll_ctrl_pkt_lengths[opcode])) {
                    rc = -1;
                    rsp_opcode = BLE_LL_CTRL_UNKNOWN_RSP;
   -            }
   -
   -            /* Stop the control procedure */
   -            ble_ll_ctrl_proc_stop(connsm, BLE_LL_CTRL_PROC_DATA_LEN_UPD);
   -        }
   -        break;
   -    case BLE_LL_CTRL_UNKNOWN_RSP:
   -        rsp_opcode = ble_ll_ctrl_proc_unk_rsp(connsm, dptr, rspdata);
   -        break;
   -    case BLE_LL_CTRL_FEATURE_REQ:
   -        rsp_opcode = ble_ll_ctrl_rx_feature_req(connsm, dptr, rspbuf, 
opcode);
   -        break;
   -    /* XXX: check to see if ctrl procedure was running? Do we care? */
   -    case BLE_LL_CTRL_FEATURE_RSP:
   -        ble_ll_ctrl_rx_feature_rsp(connsm, dptr);
   -        break;
   -    case BLE_LL_CTRL_VERSION_IND:
   -        rsp_opcode = ble_ll_ctrl_rx_version_ind(connsm, dptr, rspdata);
   -        break;
   -    case BLE_LL_CTRL_PERIPH_FEATURE_REQ:
   -        rsp_opcode = ble_ll_ctrl_rx_feature_req(connsm, dptr, rspbuf, 
opcode);
   -        break;
   +                goto ll_ctrl_send_rsp;
   +            }
   +
   +            /* Check if the feature is supported. */
   +            switch (opcode) {
   +            case BLE_LL_CTRL_LENGTH_REQ:
   +                feature = BLE_LL_FEAT_DATA_LEN_EXT;
   +                break;
   +            case BLE_LL_CTRL_PERIPH_FEATURE_REQ:
   +                feature = BLE_LL_FEAT_PERIPH_INIT;
   +                break;
   +            case BLE_LL_CTRL_CONN_PARM_REQ:
   +            case BLE_LL_CTRL_CONN_PARM_RSP:
   +                feature = BLE_LL_FEAT_CONN_PARM_REQ;
   +                break;
   +            case BLE_LL_CTRL_ENC_REQ:
   +            case BLE_LL_CTRL_START_ENC_REQ:
   +            case BLE_LL_CTRL_PAUSE_ENC_REQ:
   +                feature = BLE_LL_FEAT_LE_ENCRYPTION;
   +                break;
   +            case BLE_LL_CTRL_PING_REQ:
   +                feature = BLE_LL_FEAT_LE_PING;
   +                break;
   +            case BLE_LL_CTRL_PHY_REQ:
   +                feature = BLE_LL_FEAT_LE_2M_PHY | BLE_LL_FEAT_LE_CODED_PHY;
   +                break;
   +            case BLE_LL_CTRL_MIN_USED_CHAN_IND:
   +                feature = BLE_LL_FEAT_MIN_USED_CHAN;
   +                break;
   +            case BLE_LL_CTRL_PERIODIC_SYNC_IND:
   +                feature = BLE_LL_FEAT_SYNC_TRANS_RECV;
   +                break;
   +            case BLE_LL_CTRL_SUBRATE_REQ:
   +            case BLE_LL_CTRL_SUBRATE_IND:
   +                feature = BLE_LL_FEAT_CONN_SUBRATING;
   +                break;
   +            default:
   +                feature = 0;
   +                break;
   +            }
   +
   +            if (feature) {
   +                features = ble_ll_read_supp_features();
   +                if ((features & feature) == 0) {
   +                    if (opcode == BLE_LL_CTRL_ENC_REQ) {
   +                        if (connsm->conn_features & 
BLE_LL_FEAT_EXTENDED_REJ) {
   +                            rsp_opcode = BLE_LL_CTRL_REJECT_IND_EXT;
   +                            rspbuf[1] = opcode;
   +                            rspbuf[2] = BLE_ERR_UNSUPP_REM_FEATURE;
   +
   +                        } else {
   +                            rsp_opcode = BLE_LL_CTRL_REJECT_IND;
   +                            rspbuf[1] = BLE_ERR_UNSUPP_REM_FEATURE;
   +                        }
   +                    } else {
   +                        /* Construct unknown rsp pdu */
   +                        rsp_opcode = BLE_LL_CTRL_UNKNOWN_RSP;
   +                    }
   +                    goto ll_ctrl_send_rsp;
   +                }
   +            }
   +
   +            /* Process opcode */
   +            rsp_opcode = BLE_ERR_MAX;
   +            switch (opcode) {
   +            case BLE_LL_CTRL_CONN_UPDATE_IND:
   +                rsp_opcode = ble_ll_ctrl_rx_conn_update(connsm, dptr);
   +                break;
   +            case BLE_LL_CTRL_CHANNEL_MAP_REQ:
   +                rsp_opcode = ble_ll_ctrl_rx_chanmap_req(connsm, dptr);
   +                break;
   +            case BLE_LL_CTRL_LENGTH_REQ:
   +                /* Extract parameters and check if valid */
   +                if (ble_ll_ctrl_len_proc(connsm, dptr)) {
   +                    rc = -1;
   +                    rsp_opcode = BLE_LL_CTRL_UNKNOWN_RSP;
   +                    goto ll_ctrl_send_rsp;
   +                }
   +
   +                /*
   +                 * If we have not started this procedure ourselves and it is
   +                 * pending, no need to perform it.
   +                 */
   +                if ((connsm->cur_ctrl_proc != 
BLE_LL_CTRL_PROC_DATA_LEN_UPD) &&
   +                    IS_PENDING_CTRL_PROC(connsm, 
BLE_LL_CTRL_PROC_DATA_LEN_UPD)) {
   +                    CLR_PENDING_CTRL_PROC(connsm, 
BLE_LL_CTRL_PROC_DATA_LEN_UPD);
   +                }
   +
   +                /* Send a response */
   +                rsp_opcode = BLE_LL_CTRL_LENGTH_RSP;
   +                ble_ll_ctrl_datalen_upd_make(connsm, rspbuf);
   +                break;
   +            case BLE_LL_CTRL_LENGTH_RSP:
   +                /* According to specification, process this only if we 
asked for it. */
   +                if (connsm->cur_ctrl_proc == BLE_LL_CTRL_PROC_DATA_LEN_UPD) 
{
   +                    /*
   +                     * Process the received data. If received data is 
invalid, we'll
   +                     * reply with LL_UNKNOWN_RSP as per spec, but we still 
need to stop
   +                     * control procedure to avoid timeout.
   +                     */
   +                    if (ble_ll_ctrl_len_proc(connsm, dptr)) {
   +                        rc = -1;
   +                        rsp_opcode = BLE_LL_CTRL_UNKNOWN_RSP;
   +                    }
   +
   +                    /* Stop the control procedure */
   +                    ble_ll_ctrl_proc_stop(connsm, 
BLE_LL_CTRL_PROC_DATA_LEN_UPD);
   +                }
   +                break;
   +            case BLE_LL_CTRL_UNKNOWN_RSP:
   +                rsp_opcode = ble_ll_ctrl_proc_unk_rsp(connsm, dptr, 
rspdata);
   +                break;
   +            case BLE_LL_CTRL_FEATURE_REQ:
   +                rsp_opcode = ble_ll_ctrl_rx_feature_req(connsm, dptr, 
rspbuf, opcode);
   +                break;
   +            /* XXX: check to see if ctrl procedure was running? Do we care? 
*/
   +            case BLE_LL_CTRL_FEATURE_RSP:
   +                ble_ll_ctrl_rx_feature_rsp(connsm, dptr);
   +                break;
   +            case BLE_LL_CTRL_VERSION_IND:
   +                rsp_opcode = ble_ll_ctrl_rx_version_ind(connsm, dptr, 
rspdata);
   +                break;
   +            case BLE_LL_CTRL_PERIPH_FEATURE_REQ:
   +                rsp_opcode = ble_ll_ctrl_rx_feature_req(connsm, dptr, 
rspbuf, opcode);
   +                break;
    #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION)
   -    case BLE_LL_CTRL_ENC_REQ:
   -        rsp_opcode = ble_ll_ctrl_rx_enc_req(connsm, dptr, rspdata);
   -        break;
   -    case BLE_LL_CTRL_ENC_RSP:
   -        ble_ll_ctrl_rx_enc_rsp(connsm, dptr);
   -        break;
   -    case BLE_LL_CTRL_START_ENC_REQ:
   -        rsp_opcode = ble_ll_ctrl_rx_start_enc_req(connsm);
   -        break;
   -    case BLE_LL_CTRL_START_ENC_RSP:
   -        rsp_opcode = ble_ll_ctrl_rx_start_enc_rsp(connsm);
   -        break;
   -    case BLE_LL_CTRL_PAUSE_ENC_REQ:
   -        rsp_opcode = ble_ll_ctrl_rx_pause_enc_req(connsm);
   -        break;
   -    case BLE_LL_CTRL_PAUSE_ENC_RSP:
   -        rsp_opcode = ble_ll_ctrl_rx_pause_enc_rsp(connsm);
   -        if (rsp_opcode == BLE_LL_CTRL_PAUSE_ENC_RSP) {
   -            restart_encryption = 1;
   -        }
   -        break;
   -#endif
   -    case BLE_LL_CTRL_PING_REQ:
   -        rsp_opcode = BLE_LL_CTRL_PING_RSP;
   -        break;
   -    case BLE_LL_CTRL_PING_RSP:
   -        ble_ll_ctrl_rx_ping_rsp(connsm);
   -        break;
   -    case BLE_LL_CTRL_CONN_PARM_REQ:
   -        rsp_opcode = ble_ll_ctrl_rx_conn_param_req(connsm, dptr, rspbuf);
   -        break;
   -    case BLE_LL_CTRL_CONN_PARM_RSP:
   -        rsp_opcode = ble_ll_ctrl_rx_conn_param_rsp(connsm, dptr, rspbuf);
   -        break;
   -    /* Fall-through intentional... */
   -    case BLE_LL_CTRL_REJECT_IND:
   -    case BLE_LL_CTRL_REJECT_IND_EXT:
   -        /* Sometimes reject triggers sending other LL CTRL msg */
   -        rsp_opcode = ble_ll_ctrl_rx_reject_ind(connsm, dptr, opcode, 
rspdata);
   -        break;
   +            case BLE_LL_CTRL_ENC_REQ:
   +                rsp_opcode = ble_ll_ctrl_rx_enc_req(connsm, dptr, rspdata);
   +                break;
   +            case BLE_LL_CTRL_ENC_RSP:
   +                ble_ll_ctrl_rx_enc_rsp(connsm, dptr);
   +                break;
   +            case BLE_LL_CTRL_START_ENC_REQ:
   +                rsp_opcode = ble_ll_ctrl_rx_start_enc_req(connsm);
   +                break;
   +            case BLE_LL_CTRL_START_ENC_RSP:
   +                rsp_opcode = ble_ll_ctrl_rx_start_enc_rsp(connsm);
   +                break;
   +            case BLE_LL_CTRL_PAUSE_ENC_REQ:
   +                rsp_opcode = ble_ll_ctrl_rx_pause_enc_req(connsm);
   +                break;
   +            case BLE_LL_CTRL_PAUSE_ENC_RSP:
   +                rsp_opcode = ble_ll_ctrl_rx_pause_enc_rsp(connsm);
   +                if (rsp_opcode == BLE_LL_CTRL_PAUSE_ENC_RSP) {
   +                    restart_encryption = 1;
   +                }
   +                break;
   +#endif
   +            case BLE_LL_CTRL_PING_REQ:
   +                rsp_opcode = BLE_LL_CTRL_PING_RSP;
   +                break;
   +            case BLE_LL_CTRL_PING_RSP:
   +                ble_ll_ctrl_rx_ping_rsp(connsm);
   +                break;
   +            case BLE_LL_CTRL_CONN_PARM_REQ:
   +                rsp_opcode = ble_ll_ctrl_rx_conn_param_req(connsm, dptr, 
rspbuf);
   +                break;
   +            case BLE_LL_CTRL_CONN_PARM_RSP:
   +                rsp_opcode = ble_ll_ctrl_rx_conn_param_rsp(connsm, dptr, 
rspbuf);
   +                break;
   +            /* Fall-through intentional... */
   +            case BLE_LL_CTRL_REJECT_IND:
   +            case BLE_LL_CTRL_REJECT_IND_EXT:
   +                /* Sometimes reject triggers sending other LL CTRL msg */
   +                rsp_opcode = ble_ll_ctrl_rx_reject_ind(connsm, dptr, 
opcode, rspdata);
   +                break;
    #if (BLE_LL_BT5_PHY_SUPPORTED == 1)
   -    case BLE_LL_CTRL_PHY_REQ:
   -        rsp_opcode = ble_ll_ctrl_rx_phy_req(connsm, dptr, rspdata);
   -        break;
   -    case BLE_LL_CTRL_PHY_RSP:
   -        rsp_opcode = ble_ll_ctrl_rx_phy_rsp(connsm, dptr, rspdata);
   -        break;
   -    case BLE_LL_CTRL_PHY_UPDATE_IND:
   -        rsp_opcode = ble_ll_ctrl_rx_phy_update_ind(connsm, dptr);
   -        break;
   +            case BLE_LL_CTRL_PHY_REQ:
   +                rsp_opcode = ble_ll_ctrl_rx_phy_req(connsm, dptr, rspdata);
   +                break;
   +            case BLE_LL_CTRL_PHY_RSP:
   +                rsp_opcode = ble_ll_ctrl_rx_phy_rsp(connsm, dptr, rspdata);
   +                break;
   +            case BLE_LL_CTRL_PHY_UPDATE_IND:
   +                rsp_opcode = ble_ll_ctrl_rx_phy_update_ind(connsm, dptr);
   +                break;
    #endif
    #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_SCA_UPDATE)
   -    case BLE_LL_CTRL_CLOCK_ACCURACY_REQ:
   -        rsp_opcode = ble_ll_ctrl_rx_sca_req(connsm, dptr, rspdata);
   -        break;
   -    case BLE_LL_CTRL_CLOCK_ACCURACY_RSP:
   -        rsp_opcode = ble_ll_ctrl_rx_sca_rsp(connsm, dptr);
   -        break;
   +            case BLE_LL_CTRL_CLOCK_ACCURACY_REQ:
   +                rsp_opcode = ble_ll_ctrl_rx_sca_req(connsm, dptr, rspdata);
   +                break;
   +            case BLE_LL_CTRL_CLOCK_ACCURACY_RSP:
   +                rsp_opcode = ble_ll_ctrl_rx_sca_rsp(connsm, dptr);
   +                break;
    #endif
    
    #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_ISO)
   -    case BLE_LL_CTRL_CIS_REQ:
   -        rsp_opcode = ble_ll_ctrl_rx_cis_req(connsm, dptr, rspdata);
   -        break;
   -    case BLE_LL_CTRL_CIS_RSP:
   -        rsp_opcode = ble_ll_ctrl_rx_cis_rsp(connsm, dptr, rspdata);
   -        break;
   -    case BLE_LL_CTRL_CIS_IND:
   -        rsp_opcode = ble_ll_ctrl_rx_cis_ind(connsm, dptr);
   -        break;
   +            case BLE_LL_CTRL_CIS_REQ:
   +                rsp_opcode = ble_ll_ctrl_rx_cis_req(connsm, dptr, rspdata);
   +                break;
   +            case BLE_LL_CTRL_CIS_RSP:
   +                rsp_opcode = ble_ll_ctrl_rx_cis_rsp(connsm, dptr, rspdata);
   +                break;
   +            case BLE_LL_CTRL_CIS_IND:
   +                rsp_opcode = ble_ll_ctrl_rx_cis_ind(connsm, dptr);
   +                break;
    #endif
    #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PERIODIC_ADV_SYNC_TRANSFER)
   -    case BLE_LL_CTRL_PERIODIC_SYNC_IND:
   -        rsp_opcode = ble_ll_ctrl_rx_periodic_sync_ind(connsm, dptr);
   -        break;
   +            case BLE_LL_CTRL_PERIODIC_SYNC_IND:
   +                rsp_opcode = ble_ll_ctrl_rx_periodic_sync_ind(connsm, dptr);
   +                break;
    #endif
    #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_ENHANCED_CONN_UPDATE)
   -    case BLE_LL_CTRL_SUBRATE_REQ:
   -        rsp_opcode = ble_ll_ctrl_rx_subrate_req(connsm, dptr, rspdata);
   -        break;
   -    case BLE_LL_CTRL_SUBRATE_IND:
   -        rsp_opcode = ble_ll_ctrl_rx_subrate_ind(connsm, dptr, rspdata);
   -        break;
   -#endif
   -    default:
   -        /* Nothing to do here */
   -        break;
   -    }
   -
   -    /* Free mbuf or send response */
   +            case BLE_LL_CTRL_SUBRATE_REQ:
   +                rsp_opcode = ble_ll_ctrl_rx_subrate_req(connsm, dptr, 
rspdata);
   +                break;
   +            case BLE_LL_CTRL_SUBRATE_IND:
   +                rsp_opcode = ble_ll_ctrl_rx_subrate_ind(connsm, dptr, 
rspdata);
   +                break;
   +#endif
   +            default:
   +                /* Nothing to do here */
   +                break;
   +            }
   +
   +            /* Free mbuf or send response */
    ll_ctrl_send_rsp:
   -    if (rsp_opcode == BLE_ERR_MAX) {
   -        os_mbuf_free_chain(om);
   -    } else {
   -        /*
   -         * Write the response opcode into the buffer. If this is an unknown
   -         * response, put opcode of unknown pdu into buffer.
   -         */
   -        rspbuf[0] = rsp_opcode;
   -        if (rsp_opcode == BLE_LL_CTRL_UNKNOWN_RSP) {
   -            rspbuf[1] = opcode;
   -        }
   -        len = g_ble_ll_ctrl_pkt_lengths[rsp_opcode] + 1;
   -        ble_ll_conn_enqueue_pkt(connsm, om, BLE_LL_LLID_CTRL, len);
   +            if (rsp_opcode == BLE_ERR_MAX) {
   +                os_mbuf_free_chain(om);
   +            } else {
   +                /*
   +                 * Write the response opcode into the buffer. If this is an 
unknown
   +                 * response, put opcode of unknown pdu into buffer.
   +                 */
   +                rspbuf[0] = rsp_opcode;
   +                if (rsp_opcode == BLE_LL_CTRL_UNKNOWN_RSP) {
   +                    rspbuf[1] = opcode;
   +                }
   +                len = g_ble_ll_ctrl_pkt_lengths[rsp_opcode] + 1;
   +                ble_ll_conn_enqueue_pkt(connsm, om, BLE_LL_LLID_CTRL, len);
    #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION)
   -        if (restart_encryption) {
   -            /* XXX: what happens if this fails? Meaning we cant allocate
   -               mbuf? */
   -            ble_ll_ctrl_proc_init(connsm, BLE_LL_CTRL_PROC_ENCRYPT, NULL);
   -        }
   -#endif
   -    }
   -
   -    if (connsm->csmflags.cfbit.pending_initiate_dle) {
   -        connsm->csmflags.cfbit.pending_initiate_dle = 0;
   -        ble_ll_ctrl_initiate_dle(connsm, true);
   -    }
   -
   -    return rc;
   -}
   +                if (restart_encryption) {
   +                    /* XXX: what happens if this fails? Meaning we cant 
allocate
   +                       mbuf? */
   +                    ble_ll_ctrl_proc_init(connsm, BLE_LL_CTRL_PROC_ENCRYPT, 
NULL);
   +                }
   +#endif
   +            }
   +
   +            if (connsm->csmflags.cfbit.pending_initiate_dle) {
   +                connsm->csmflags.cfbit.pending_initiate_dle = 0;
   +                ble_ll_ctrl_initiate_dle(connsm, true);
   +            }
   +
   +            return rc;
   +        }
    
    /**
     * Called to create and send a REJECT_IND_EXT control PDU or a REJECT_IND
   ```
   
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to