- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# /space/home/slher/rel/Beken/v6_4_5/macsw/ip/umac/src/scanu/scanu_task.c

Go to the documentation of this file.

    00001
    00013 #include "scanu_task.h"
    00014 #include "scanu.h"
    00015
    00016 #include "me.h"
    00017 #include "scan_task.h"
    00018 //#include "tpm.h"
    00019 #include "dbg.h"
    00020 #include "vif_mgmt.h"
    00021 #include "rxu_task.h"
    00022
    00048 static int
    00049 scanu_start_req_handler(ke_msg_id_t const msgid,
    00050                         struct scanu_start_req const *param,
    00051                         ke_task_id_t const dest_id,
    00052                         ke_task_id_t const src_id)
    00053 {
    00054     // record the SCAN information in the environment
    00055     scanu_env.joining = false;
    00056     scanu_env.param = param;
    00057     scanu_env.src_id = src_id;
    00058     scanu_env.band = PHY_BAND_2G4;
    00059     scanu_env.bssid = param->bssid;
    00060
    00061     #if (NX_ANT_DIV)
    00062     ke_msg_send_basic(MM_ANT_DIV_STOP_REQ, TASK_MM, TASK_SCANU);
    00063     #endif //(NX_ANT_DIV)
    00064
    00065     // start scanning
    00066     scanu_start();
    00067
    00068     return (KE_MSG_NO_FREE);
    00069 }
    00070
    00091 static int
    00092 scanu_join_req_handler(ke_msg_id_t const msgid,
    00093                         struct scanu_start_req const *param,
    00094                         ke_task_id_t const dest_id,
    00095                         ke_task_id_t const src_id)
    00096 {
    00097     struct vif_info_tag *vif = &vif_info_tab[param->vif_idx];
    00098     struct me_bss_info *bss = &vif->bss_info;
    00099     struct mac_scan_result *scan;
    00100
    00101     // Reset the valid flag of the BSS information
    00102     BSS_CAPA_RESET(bss);
    00103
    00104     // record the SCAN information in the environment
    00105     scanu_env.joining = true;
    00106     scanu_env.param = param;
    00107     scanu_env.src_id = src_id;
    00108     scanu_env.band = PHY_BAND_2G4;
    00109     scanu_env.bssid = param->bssid;
    00110     scanu_env.join_status = 0;
    00111     scan = scanu_find_result(&param->bssid, false);
    00112     if (scan && scan->multi_bssid_index)
    00113         mac_ref_bssid_get(scan->multi_bssid_index, scan->max_bssid_indicator,
    00114                           &scan->bssid, &scanu_env.ref_bssid);
    00115     else
    00116         scanu_env.ref_bssid = param->bssid;
    00117
    00118     // Sanity checks
    00119     ASSERT_ERR(!MAC_ADDR_GROUP(&param->bssid));
    00120
    00121     // start scanning
    00122     scanu_start();
    00123
    00124     return (KE_MSG_NO_FREE);
    00125 }
    00126
    00140 static int
    00141 scanu_get_scan_result_req_handler(ke_msg_id_t const msgid,
    00142                                   struct scanu_get_scan_result_req const *param,
    00143                                   ke_task_id_t const dest_id,
    00144                                   ke_task_id_t const src_id)
    00145 {
    00146     struct scanu_get_scan_result_cfm *cfm ;
    00147
    00148     cfm = KE_MSG_ALLOC(SCANU_GET_SCAN_RESULT_CFM, src_id, TASK_SCANU, scanu_get_scan_result_cfm);
    00149
    00150     if ((!scanu_env.result_cnt) || (param->idx >= scanu_env.result_cnt))
    00151     {
    00152         cfm->scan_result.valid_flag = false;
    00153     }
    00154     else
    00155     {
    00156         cfm->scan_result = scanu_env.scan_result[param->idx];
    00157     }
    00158
    00159     ke_msg_send(cfm);
    00160
    00161     return (KE_MSG_CONSUMED);
    00162 }
    00163
    00176 static int
    00177 scan_start_cfm_handler(ke_msg_id_t const msgid,
    00178                        struct scan_start_cfm const *param,
    00179                        ke_task_id_t const dest_id,
    00180                        ke_task_id_t const src_id)
    00181 {
    00182     // Check if the scanning procedure was correctly started by LMAC
    00183     if (param->status != CO_OK)
    00184         scanu_confirm(param->status);
    00185
    00186     return (KE_MSG_CONSUMED);
    00187 }
    00188
    00189
    00202 static int
    00203 scan_done_ind_handler(ke_msg_id_t const msgid,
    00204                       void const *param,
    00205                       ke_task_id_t const dest_id,
    00206                       ke_task_id_t const src_id)
    00207 {
    00208     // Update the band
    00209     scanu_env.band++;
    00210
    00211     // Scan the next band
    00212     scanu_scan_next();
    00213
    00214     return (KE_MSG_CONSUMED);
    00215 }
    00216
    00230 static int
    00231 rxu_mgt_ind_handler(ke_msg_id_t const msgid,
    00232                     struct rxu_mgt_ind const *param,
    00233                     ke_task_id_t const dest_id,
    00234                     ke_task_id_t const src_id)
    00235 {
    00236     int msg_status;
    00237
    00238     // Call frame handler
    00239     msg_status = scanu_frame_handler(param);
    00240
    00241     return (msg_status);
    00242 }
    00243
    00245 const struct ke_msg_handler scanu_idle[] =
    00246 {
    00247     {SCANU_START_REQ, (ke_msg_func_t)scanu_start_req_handler},
    00248     {SCANU_JOIN_REQ, (ke_msg_func_t)scanu_join_req_handler},
    00249     {SCANU_GET_SCAN_RESULT_REQ, (ke_msg_func_t)scanu_get_scan_result_req_handler},
    00250 };
    00251
    00253 const struct ke_msg_handler scanu_scanning[] =
    00254 {
    00255     {SCAN_START_CFM, (ke_msg_func_t)scan_start_cfm_handler},
    00256     {SCAN_DONE_IND, (ke_msg_func_t)scan_done_ind_handler},
    00257     {RXU_MGT_IND, (ke_msg_func_t)rxu_mgt_ind_handler},
    00258 };
    00259
    00261 const struct ke_msg_handler scanu_default_state[] =
    00262 {
    00263     // if receiving scan requests while not in IDLE, save message
    00264     {SCANU_START_REQ, ke_msg_save},
    00265     {SCANU_JOIN_REQ, ke_msg_save},
    00266     {SCANU_GET_SCAN_RESULT_REQ, ke_msg_save},
    00267     // if receiving probe responses or beacons out of scan, discard them
    00268     {RXU_MGT_IND, ke_msg_discard},
    00269 };
    00270
    00271
    00273 const struct ke_state_handler scanu_state_handler[SCANU_STATE_MAX] =
    00274 {
    00276     [SCANU_IDLE] = KE_STATE_HANDLER(scanu_idle),
    00278     [SCANU_SCANNING] = KE_STATE_HANDLER(scanu_scanning),
    00279 };
    00280
    00281
    00283 const struct ke_state_handler scanu_default_handler =
    00284     KE_STATE_HANDLER(scanu_default_state);
    00285
    00286
    00288 ke_state_t scanu_state[SCANU_IDX_MAX];
    00289
    00290