wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/inc/core_operation_handle_measurement_request.h
changeset 0 c40eb8fe8501
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Statemachine for handling received measurement request.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CORE_OPERATION_HANDLE_MEASUREMENT_REQUEST_H
       
    20 #define CORE_OPERATION_HANDLE_MEASUREMENT_REQUEST_H
       
    21 
       
    22 #include "core_operation_base.h"
       
    23 #include "abs_core_frame_handler.h"
       
    24 #include "abs_core_event_handler.h"
       
    25 #include "core_type_list.h"
       
    26 #include "core_frame_rm_ie.h"
       
    27 #include "core_frame_rm_ie_beacon_request.h"
       
    28 #include "core_frame_rm_ie_beacon_report.h"
       
    29 #include "core_frame_mgmt_ie.h"
       
    30 
       
    31 // forward declarations
       
    32 class core_frame_action_rm_c;
       
    33 class core_frame_dot11_ie_c;
       
    34 class core_frame_action_c;
       
    35 
       
    36 NONSHARABLE_CLASS( core_measurement_status_c )
       
    37     {
       
    38 public:
       
    39     
       
    40     core_measurement_status_c() :
       
    41             da_m ( ZERO_MAC_ADDR ),
       
    42             sa_m ( ZERO_MAC_ADDR ),
       
    43             error_in_request_m ( false_t ),
       
    44             refuse_request_m ( false_t ),
       
    45             too_short_interval_m ( false_t )
       
    46         {}
       
    47         
       
    48     ~core_measurement_status_c()
       
    49         {}
       
    50     
       
    51 public:
       
    52     inline const core_mac_address_s& da() const { return da_m; }
       
    53     inline const core_mac_address_s& sa() const { return sa_m; }
       
    54     inline bool_t error_in_request() const { return error_in_request_m; }
       
    55     inline bool_t refuse_request() const { return refuse_request_m; }
       
    56     inline bool_t too_short_interval() const { return too_short_interval_m; }
       
    57     inline void set_error_in_request( bool_t state ){ error_in_request_m = state; }
       
    58     inline void set_refuse_request( bool_t state ){ refuse_request_m = state; }
       
    59     inline void set_too_short_interval( bool_t state ){ too_short_interval_m = state; }
       
    60     inline void set_sa( core_mac_address_s sa ){ sa_m = sa; }
       
    61     inline void set_da( core_mac_address_s da ){ da_m = da; }
       
    62     inline core_scan_channels_s get_scan_channels() const { return channels_m; }
       
    63     inline void set_scan_channels( core_scan_channels_s channels ){ channels_m = channels; }
       
    64     
       
    65 private:
       
    66     core_mac_address_s da_m;
       
    67     core_mac_address_s sa_m;
       
    68     bool_t error_in_request_m;
       
    69     bool_t refuse_request_m;
       
    70     bool_t too_short_interval_m;
       
    71     core_scan_channels_s channels_m;
       
    72     };
       
    73 
       
    74 /**
       
    75  * Statemachine for handling received measurement request.
       
    76  *
       
    77  * @lib wlmserversrv.lib
       
    78  * @since S60 v5.2
       
    79  */
       
    80 NONSHARABLE_CLASS( core_operation_handle_measurement_request_c ) :
       
    81     public core_operation_base_c,
       
    82     public abs_core_frame_handler_c,
       
    83     public abs_core_event_handler_c
       
    84     {
       
    85 
       
    86 public:
       
    87 
       
    88     /**
       
    89      * The possible states of the operation.
       
    90      */
       
    91     enum core_state_e
       
    92         {
       
    93         core_state_init = core_base_state_next,
       
    94         core_state_get_next_ie,
       
    95         core_state_process_current_ie,
       
    96         core_state_make_measurement,
       
    97         core_state_create_response,
       
    98         core_state_scan_start,
       
    99         core_state_create_negative_response,
       
   100         core_state_send_response,
       
   101         core_state_operation_finished,
       
   102         core_state_MAX
       
   103         };
       
   104 
       
   105     /**
       
   106      * Constructor.
       
   107      */
       
   108     core_operation_handle_measurement_request_c(
       
   109         u32_t request_id,
       
   110         core_server_c* server,
       
   111         abs_core_driverif_c* drivers,
       
   112         abs_core_server_callback_c* adaptation,
       
   113         core_frame_action_rm_c* measurement_request );
       
   114 
       
   115     virtual ~core_operation_handle_measurement_request_c();
       
   116     
       
   117 protected:
       
   118 
       
   119     /**
       
   120      * This method is called when a pending request has been completed
       
   121      * and so sub-operations are pending.
       
   122      *
       
   123      * @since S60 v5.2
       
   124      * @return status of the operation:
       
   125      *     core_error_request_pending if the operation is not finished,
       
   126      *     otherwise the status code of the finished operation
       
   127      */
       
   128     core_error_e next_state();
       
   129     
       
   130     /**
       
   131      * From abs_core_frame_handler_c Called by the core server when a dot11 frame has been received.
       
   132      *
       
   133      * @since S60 v5.2
       
   134      * @param frame Pointer to a dot11 frame parser.
       
   135      * @param rcpi RCPI value of the frame.
       
   136      * @return true_t if the frame was handled, false_t otherwise.
       
   137      */
       
   138     bool_t receive_frame(
       
   139         const core_frame_dot11_c* frame,
       
   140         u8_t rcpi );
       
   141 
       
   142     /**
       
   143      * From abs_core_event_handler_c Called by the core server when an indication has been received.
       
   144      *
       
   145      * @since S60 v5.2
       
   146      * @param indication Adaptation layer event.
       
   147      * @return true_t if the indication was handled, false_t if not handled.
       
   148      */
       
   149     bool_t notify(
       
   150         core_am_indication_e indication );
       
   151     
       
   152     /**
       
   153      * This method is called when the operation is cancelled from the outside.
       
   154      *
       
   155      * @since S60 v5.2
       
   156      * @param do_graceful_cancel Whether cancel should be graceful or forced.
       
   157      */
       
   158     void user_cancel(
       
   159         bool_t do_graceful_cancel );
       
   160     
       
   161 private:
       
   162     
       
   163     /**
       
   164      * This method parses the received measurement request IE and
       
   165      * fills in the parameters of the measurement request structure.
       
   166      *
       
   167      * @since S60 v5.2
       
   168      * @param ie Reference to the received measurement IE
       
   169      * @param parsed_mask Mask defining what information was parsed from the IE
       
   170      */
       
   171     void parse( core_frame_dot11_ie_c* ie, u16_t& parsed_mask );
       
   172     
       
   173     /**
       
   174      * This method creates a negative response to received measurement request.
       
   175      *
       
   176      * @since S60 v5.2
       
   177      * @return true_t if response created, false_t otherwise
       
   178      */
       
   179     bool_t create_negative_response();
       
   180 
       
   181     /**
       
   182      * This method creates a negative response to the received measurement request
       
   183      * refusing to perform the requested measurement or creates an empty response
       
   184      * to the received measurement request or creates an incapable response to a
       
   185      * measurement request.
       
   186      *
       
   187      * @since S60 v5.2
       
   188      * @param measurement_report_mode Measurement report mode
       
   189      * @return true_t if response created, false_t otherwise
       
   190      */
       
   191     bool_t create_negative_response_based_on_meas_report_mode( u8_t measurement_report_mode );
       
   192 
       
   193     /**
       
   194      * This method creates a response to received invalid measurement request.
       
   195      *
       
   196      * @since S60 v5.2
       
   197      * @return true_t if response created, false_t otherwise
       
   198      */
       
   199     bool_t create_response_to_invalid_request();
       
   200     
       
   201     /**
       
   202      * This method validates the received beacon request.
       
   203      *
       
   204      * @since S60 v5.2
       
   205      */
       
   206     void validate_measurement_request();
       
   207     
       
   208     /**
       
   209      * This method validates the received beacon request.
       
   210      *
       
   211      * @since S60 v5.2
       
   212      */
       
   213     void validate_beacon_request();
       
   214     
       
   215     /**
       
   216      * This method validates the Beacon Reporting Information IE.
       
   217      *
       
   218      * @since S60 v5.2
       
   219      */
       
   220     void validate_beacon_reporting_information();
       
   221     
       
   222     /**
       
   223      * This method validates the Beacon Reporting Detail IE.
       
   224      *
       
   225      * @since S60 v5.2
       
   226      */
       
   227     void validate_beacon_reporting_detail();
       
   228     
       
   229     /**
       
   230      * This method validates the interval that the measurement
       
   231      * requests are coming is not too small.
       
   232      *
       
   233      * @since S60 v5.2
       
   234      * @return true_t if interval long enough, false_t otherwise
       
   235      */
       
   236     bool_t validate_measurement_interval();
       
   237     
       
   238     /**
       
   239      * Add IE to Measurement Response, creates Measurement Response if
       
   240      * it doesn't already exist.
       
   241      *
       
   242      * @since S60 v5.2
       
   243      * @param ie Reference to IE to be added to Measurement Response
       
   244      * @return true_t if successful, false_t otherwise
       
   245      */
       
   246     bool_t add_to_report( const core_frame_rm_ie_c* ie );
       
   247     
       
   248     /**
       
   249      * This method validates the requested scan channels.
       
   250      *
       
   251      * @since S60 v5.2
       
   252      * @return true_t if scan can be done, false_t otherwise
       
   253      */
       
   254     bool_t validate_scan_channels();
       
   255     
       
   256     /**
       
   257      * Return channel time to use in scan.
       
   258      *
       
   259      * @since S60 v5.2
       
   260      * @return channel times to use in scan
       
   261      * @param measurement_mode Request's Measurement Mode
       
   262      */
       
   263     u16_t get_channel_time( core_frame_rm_ie_beacon_request_c::core_beacon_request_scan_mode_e measurement_mode );
       
   264     
       
   265     /**
       
   266      * Return SSID to use in scan.
       
   267      *
       
   268      * @since S60 v5.2
       
   269      * @return SSID to use in scan
       
   270      */
       
   271     core_ssid_s get_ssid();
       
   272     
       
   273     /**
       
   274      * Return channels to use in scan.
       
   275      *
       
   276      * @since S60 v5.2
       
   277      * @return Channels to use in scan.
       
   278      */
       
   279     core_scan_channels_c get_channels();
       
   280 
       
   281     /**
       
   282      * Check if Beacon/Probe matches to requested data.
       
   283      *
       
   284      * @since S60 v5.2
       
   285      * @return true_t if match, false_t otherwise
       
   286      */
       
   287     bool_t match_found( core_ap_data_c& ap_data );
       
   288     
       
   289     /**
       
   290      * Create response frame to a measurement request.
       
   291      *
       
   292      * @since S60 v5.2
       
   293      * @return true_t if success, false_t otherwise
       
   294      */
       
   295     bool_t create_response(
       
   296         core_ap_data_c& ap_data );
       
   297     
       
   298     /**
       
   299      * Initialise internal data members for processing next beacon request IE.
       
   300      *
       
   301      * @since S60 v5.2
       
   302      */
       
   303     void initialise_beacon_request_data();
       
   304     
       
   305     /**
       
   306      * Get random delay utilising Randomization Interval.
       
   307      *
       
   308      * @since S60 v5.2
       
   309      * @return random delay
       
   310      */
       
   311     u32_t get_random_delay();
       
   312     
       
   313 private: // data
       
   314    
       
   315     /** The received Measurement Request frame. */
       
   316     core_frame_action_rm_c* measurement_request_m;
       
   317     
       
   318     /** List of IEs included in the received Measurement Request */
       
   319     core_type_list_c<core_frame_dot11_ie_c> ie_list_m;
       
   320     
       
   321     /** Structure containing status data for the operation logic */
       
   322     core_measurement_status_c status_m;
       
   323 
       
   324     /** Bitmask about which IEs are successfully parsed. */
       
   325     u16_t parsed_mask_m;
       
   326     
       
   327     /** Reference to IE currently under processing. */
       
   328     core_frame_dot11_ie_c* current_ie_m;
       
   329     
       
   330     /** The Measurement Report frame to be sent. */
       
   331     core_frame_action_c* report_m;
       
   332     
       
   333     /** Parser for Measurement Request IE. */
       
   334     core_frame_rm_ie_c* meas_req_parser_m;
       
   335     
       
   336     /** Parser for Beacon Request IE. */
       
   337     core_frame_rm_ie_beacon_request_c* beacon_req_parser_m;
       
   338     
       
   339     /** Parser for SSID Sub-Element. */
       
   340     core_frame_mgmt_ie_ssid_c* ssid_parser_m;
       
   341     
       
   342     /** Parser for Beacon Reporting Information Sub-Element. */
       
   343     core_frame_rm_ie_beacon_request_ie_c* bri_parser_m;
       
   344     
       
   345     /** Parser for Beacon Reporting Detail Sub-Element. */
       
   346     core_frame_rm_ie_beacon_request_detail_ie_c* brd_parser_m;
       
   347     
       
   348     /** Parser for AP Channel Report Sub-Element. */
       
   349     core_frame_mgmt_ie_ap_channel_report_c* ap_ch_rep_parser_m;
       
   350 
       
   351     /** Parser for Request IE Sub-Element. */
       
   352     core_frame_mgmt_ie_request_ie_c* request_ie_parser_m;
       
   353     
       
   354     /** Measurement Duration used in the actual measurement. */
       
   355     u16_t actual_measurement_duration_m;
       
   356     
       
   357     };
       
   358 
       
   359 #endif // CORE_OPERATION_HANDLE_MEASUREMENT_REQUEST_H