/* Called when we receive a feature request or a slave initiated feature request. */
static int ble_ll_ctrl_rx_feature_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr, uint8_t *rspbuf, uint8_t opcode)
/* Called when we receive a feature request or a slave initiated feature request. */
static int ble_ll_ctrl_rx_feature_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr, uint8_t *rspbuf, uint8_t opcode)
{
    uint8_t rsp_opcode;
    uint64_t our_feat;
    if (opcode ==  BLE_LL_CTRL_SLAVE_FEATURE_REQ) {
        if (connsm->conn_role != BLE_LL_CONN_ROLE_MASTER) {
            return BLE_LL_CTRL_UNKNOWN_RSP;
        }
    } else {
        if (connsm->conn_role != BLE_LL_CONN_ROLE_SLAVE) {
            return BLE_LL_CTRL_UNKNOWN_RSP;
        }
    }
    our_feat = ble_ll_read_supp_features();
    rsp_opcode = BLE_LL_CTRL_FEATURE_RSP;
    ble_ll_ctrl_update_features(connsm, dptr);
    connsm->conn_features &= our_feat;
    put_le64(rspbuf + 1, our_feat);
    rspbuf[1] = connsm->conn_features;
    return rsp_opcode;
}