wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/inc/core_operation_protected_setup.h
changeset 0 c40eb8fe8501
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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 Wi-Fi Protected setup
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CORE_OPERATION_PROTECTED_SETUP_H
       
    20 #define CORE_OPERATION_PROTECTED_SETUP_H
       
    21 
       
    22 #include "core_operation_base.h"
       
    23 #include "genscanlist.h"
       
    24 #include "core_frame_dot11_ie.h"
       
    25 #include "core_type_list.h"
       
    26 #include "abs_core_protected_setup_handler.h"
       
    27 #include "abs_core_timer.h"
       
    28 
       
    29 class core_server_c;
       
    30 class core_ap_data_c;
       
    31 class abs_core_scan_list_iterator_c;
       
    32 
       
    33 /**
       
    34  * Statemachine for Wi-Fi Protected setup
       
    35  *
       
    36  * @lib wlmserversrv.lib
       
    37  * @since S60 v3.2
       
    38  */
       
    39 NONSHARABLE_CLASS( core_operation_protected_setup_c ) :
       
    40     public core_operation_base_c,
       
    41     public abs_core_protected_setup_handler_c
       
    42     {
       
    43 
       
    44 public:
       
    45 
       
    46     enum core_state_e
       
    47         {
       
    48         core_state_init = core_base_state_next, // init
       
    49         core_state_prepare_scanning,            // initial actions before scanning
       
    50         core_state_start_scanning,              // scanning is started
       
    51         core_state_scan,                        // analyse scanlist
       
    52         core_state_connect_and_setup,           // make connect and invoke EAPOL to start Protected Setup
       
    53         core_state_setup_completed,             // setup is done
       
    54         core_state_disconnect,
       
    55         core_state_disconnect_on_error,         // this will return correct return value when EAPOL returns failure
       
    56         core_state_disconnect_on_cancel,        // this will return correct return value when user cancelled operation
       
    57         core_state_disconnect_before_second_round_trip,
       
    58         core_state_walktime_expiration,
       
    59         core_state_user_cancel,                 // the operation has been cancelled from the outside
       
    60         core_state_setup_failed,                // EAPOL has returned a failure code
       
    61         core_state_MAX
       
    62         };
       
    63 
       
    64     /**
       
    65      * Constructor.
       
    66      */
       
    67     core_operation_protected_setup_c(
       
    68         u32_t request_id,
       
    69         core_server_c* server,        
       
    70         abs_core_driverif_c* drivers,
       
    71         abs_core_server_callback_c* adaptation,
       
    72         const core_iap_data_s& iap_data,
       
    73         core_type_list_c<core_iap_data_s>& iap_data_list,
       
    74         core_protected_setup_status_e& protected_setup_status );
       
    75 
       
    76     /**
       
    77      * Destructor.
       
    78      */
       
    79     virtual ~core_operation_protected_setup_c();
       
    80 
       
    81 protected:
       
    82 
       
    83     /**
       
    84      * This method is called when a pending request has been completed
       
    85      * and no sub-operations are pending.
       
    86      *
       
    87      * @since S60 v3.2
       
    88      * @return status of the operation:
       
    89      *     core_error_request_pending if the operation is not finished,
       
    90      *     otherwise the status code of the finished operation
       
    91      */
       
    92     core_error_e next_state();
       
    93     
       
    94     /**
       
    95      * This method is called when the operation needs to be canceled.
       
    96      *
       
    97      * @since S60 v3.1
       
    98      * @return status of the operation:
       
    99      *     core_error_request_pending if the operation is not finished,
       
   100      *     otherwise the status code of the finished operation
       
   101      */
       
   102     core_error_e cancel();
       
   103 
       
   104     /**
       
   105      * This method is called when the operation is cancelled from the outside.
       
   106      *
       
   107      * @since S60 v3.2
       
   108      * @param do_graceful_cancel Whether cancel should be graceful or forced.
       
   109      */
       
   110     void user_cancel(
       
   111         bool_t do_graceful_cancel );
       
   112 
       
   113     /**
       
   114      * Called by the timer framework when timer expires.
       
   115      */
       
   116     static void timer_expired( void* this_ptr );
       
   117 
       
   118     /**
       
   119      * Called by the core server when a network has been configured via
       
   120      * Protected Setup.
       
   121      *
       
   122      * @since S60 v3.2
       
   123      * @param iap_data Results of a successful Protected Setup operation. 
       
   124      */
       
   125     void handle_protected_setup_network(
       
   126         const core_iap_data_s& iap_data );
       
   127 
       
   128 private:
       
   129 
       
   130     /**
       
   131      * This method is called to count selected registrars from scanlist
       
   132      *
       
   133      * @since S60 v3.2
       
   134      * @param iter                Iterator used for going through scan list.
       
   135      * @param copy_ap_data_always Whether ap_data should be copied even when 
       
   136      *                            selected_registrar is not found.
       
   137      * @return number of selected registrars
       
   138      */
       
   139     u32_t check_selected_registrars(
       
   140         abs_core_scan_list_iterator_c * iter,
       
   141         bool_t copy_ap_data_always );
       
   142 
       
   143     /**
       
   144      * Determine the status based on the given arguments.
       
   145      *
       
   146      * @param request_status The request completion status.
       
   147      * @param management_status The association response status from the AP.
       
   148      * @param protected_setup_status The status will be written here.
       
   149      */
       
   150     core_error_e protected_setup_status(
       
   151         core_error_e request_status,
       
   152         core_management_status_e management_status,
       
   153         core_protected_setup_status_e& protected_setup_status ) const;
       
   154 
       
   155     // Prohibit copy constructor
       
   156     core_operation_protected_setup_c(
       
   157         const core_operation_protected_setup_c& );
       
   158     // Prohibit assigment operator
       
   159     core_operation_protected_setup_c& operator=(
       
   160         const core_operation_protected_setup_c& );
       
   161 
       
   162 private: // data
       
   163 
       
   164     /** IAP data. */
       
   165     core_iap_data_s core_iap_data_m;
       
   166 
       
   167     /** Storage for received credentials. */   
       
   168     core_type_list_c<core_iap_data_s>& iap_data_list_m;
       
   169 
       
   170     /** Protected Setup status that will be returned to adaptation */
       
   171     core_protected_setup_status_e& protected_setup_status_m;
       
   172 
       
   173     /** ScanList instance. */
       
   174     ScanList* scan_data_m;
       
   175 
       
   176     /** Walk time timer. */
       
   177     abs_core_timer_c* walktime_timer_m;
       
   178 
       
   179     /** AP that will be used Protected Setup. Not owned by this pointer. */
       
   180     core_ap_data_c* selected_ap_data_m;
       
   181 
       
   182     /** Tag used for scan results. */
       
   183     u8_t tag_m;
       
   184 
       
   185     /** Channels that will be used for scanning. */
       
   186 	core_scan_channels_s all_valid_scan_channels_m;
       
   187 
       
   188     /** The list of IEs that will be added to the association/resassociation request */
       
   189     core_type_list_c<core_frame_dot11_ie_c> assoc_ie_list_m;
       
   190 
       
   191     /** Whether the connection attempt is a reassociation. */
       
   192     bool_t is_reassociation_m;
       
   193 
       
   194     /** Status of connection attempt. */
       
   195     core_management_status_e management_status_m;
       
   196 
       
   197     /** Whether we are still connected to an AP. */
       
   198     bool_t is_connected_m;
       
   199     
       
   200     /** Count how many times protected setup AP's are scanned. */
       
   201     u8_t wps_scan_count_m;
       
   202     
       
   203     /** Mark whether selected registrar flag was on.
       
   204      * This will prevent two round-trips when flag is set already in first round-trip.
       
   205      */
       
   206     bool_t is_selected_registrar_found_m;
       
   207 
       
   208     /** Mark whether pushbutton method is used.
       
   209      * This information is used for selected_registrar counting.
       
   210      */
       
   211     bool_t is_pushbutton_method_used_m;
       
   212     
       
   213 };
       
   214 
       
   215 #endif // CORE_OPERATION_PROTECTED_SETUP_H