wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_frame_wsc_ie.cpp
changeset 0 c40eb8fe8501
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Class for parsing WSC IEs.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "core_frame_wsc_ie.h"
       
    20 #include "core_tools.h"
       
    21 #include "am_debug.h"
       
    22 
       
    23 /** Defining this enables IE parsing related traces. */
       
    24 //#define WLAN_CORE_DEEP_DEBUG 1
       
    25 
       
    26 const u8_t CORE_FRAME_WSC_IE_OUI_OFFSET = 2;
       
    27 const u8_t CORE_FRAME_WSC_IE_OUI_LENGTH = 4;
       
    28 const u8_t CORE_FRAME_WSC_IE_OUI[] = { 0x00, 0x50, 0xF2, 0x04 };
       
    29 
       
    30 /** Offset to first Protected Setup attribute type in IE */
       
    31 const u8_t CORE_FRAME_WSC_IE_PROTECTED_SETUP_DATA_OFFSET = 
       
    32                 CORE_FRAME_WSC_IE_OUI_OFFSET + CORE_FRAME_WSC_IE_OUI_LENGTH;
       
    33 /** Offset from AttributeType field to DataLength field */
       
    34 const u8_t CORE_FRAME_WSC_IE_DATA_LENGTH_OFFSET = 2;
       
    35 /** Offset from AttributeType field to Data field */
       
    36 const u8_t CORE_FRAME_WSC_IE_DATA_AREA_OFFSET   = 4;
       
    37 
       
    38 /** Maximum length of ASCII text fields. Used to prevent possible buffer overrun in debug print. */
       
    39 const u16_t CORE_FRAME_WSC_IE_MANUFACTURER_MAX_LENGTH   = 64;
       
    40 const u16_t CORE_FRAME_WSC_IE_MODEL_NAME_MAX_LENGTH     = 32;
       
    41 
       
    42 /** IDs for different data elements in WSC IE. */
       
    43 const u16_t CORE_FRAME_WSC_IE_ASSOCIATION_STATE     = 0x1002;
       
    44 const u16_t CORE_FRAME_WSC_IE_CONFIG_METHODS        = 0x1008;
       
    45 const u16_t CORE_FRAME_WSC_IE_CONFIGURATION_ERROR   = 0x1009;
       
    46 const u16_t CORE_FRAME_WSC_IE_DEVICE_NAME           = 0x1011;
       
    47 const u16_t CORE_FRAME_WSC_IE_DEVICE_PASSWORD_ID    = 0x1012;
       
    48 const u16_t CORE_FRAME_WSC_IE_MANUFACTURER          = 0x1021;
       
    49 const u16_t CORE_FRAME_WSC_IE_MODEL_NAME            = 0x1023;
       
    50 const u16_t CORE_FRAME_WSC_IE_MODEL_NUMBER          = 0x1024;
       
    51 const u16_t CORE_FRAME_WSC_IE_REQUEST_TYPE          = 0x103A;
       
    52 const u16_t CORE_FRAME_WSC_IE_RESPONSE_TYPE         = 0x103B;
       
    53 const u16_t CORE_FRAME_WSC_IE_RF_BANDS              = 0x103C;
       
    54 const u16_t CORE_FRAME_WSC_IE_SELECTED_REGISTRAR    = 0x1041;
       
    55 const u16_t CORE_FRAME_WSC_IE_SERIAL_NUMBER         = 0x1042;
       
    56 const u16_t CORE_FRAME_WSC_IE_PROTECTED_SETUP_STATE = 0x1044;
       
    57 const u16_t CORE_FRAME_WSC_IE_UUID_E                = 0x1047;
       
    58 const u16_t CORE_FRAME_WSC_IE_UUID_R                = 0x1048;
       
    59 const u16_t CORE_FRAME_WSC_IE_VERSION               = 0x104A;
       
    60 const u16_t CORE_FRAME_WSC_IE_SELECTED_REGISTRAR_CONFIG_METHODS = 0x1053;
       
    61 const u16_t CORE_FRAME_WSC_IE_PRIMARY_DEVICE_TYPE   = 0x1054;
       
    62 const u16_t CORE_FRAME_WSC_IE_AP_SETUP_LOCKED       = 0x1057;
       
    63 
       
    64 
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 core_frame_wsc_ie_c* core_frame_wsc_ie_c::instance(
       
    70     const core_frame_dot11_ie_c& ie )
       
    71     {
       
    72     if ( core_tools_c::compare(
       
    73         &ie.data()[CORE_FRAME_WSC_IE_OUI_OFFSET],
       
    74         CORE_FRAME_WSC_IE_OUI_LENGTH,
       
    75         &CORE_FRAME_WSC_IE_OUI[0],
       
    76         CORE_FRAME_WSC_IE_OUI_LENGTH ) )
       
    77         {
       
    78 #ifdef WLAN_CORE_DEEP_DEBUG
       
    79         DEBUG( "core_frame_wsc_ie_c::instance() - not a valid IE, WSC OUI missing" );
       
    80 #endif // WLAN_CORE_DEEP_DEBUG
       
    81 
       
    82         return NULL;
       
    83         }
       
    84 
       
    85     core_frame_wsc_ie_c* instance = new core_frame_wsc_ie_c(
       
    86         ie.data_length(),
       
    87         ie.data(),
       
    88         0 );
       
    89     if ( !instance )
       
    90         {
       
    91         DEBUG( "core_frame_wsc_ie_c::instance() - unable to create an instance" );
       
    92 
       
    93         return NULL;
       
    94         }
       
    95     
       
    96     instance->search_attributes();
       
    97     
       
    98     return instance;
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // ---------------------------------------------------------------------------
       
   103 // 
       
   104 core_frame_wsc_ie_c* core_frame_wsc_ie_c::instance(
       
   105         const u8_t version,
       
   106         const u8_t request_type )
       
   107     {
       
   108     // Count size of needed buffer.
       
   109     const u16_t max_length = 
       
   110         CORE_FRAME_DOT11_IE_HEADER_LENGTH
       
   111         + CORE_FRAME_WSC_IE_OUI_LENGTH
       
   112         + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET + sizeof( version )
       
   113         + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET + sizeof( request_type );
       
   114 
       
   115     u8_t* buffer = new u8_t[max_length];
       
   116     if ( !buffer )
       
   117         {
       
   118         DEBUG( "core_frame_wsc_ie_c::instance() - unable create the internal buffer" );
       
   119         return NULL;
       
   120         }
       
   121 
       
   122     core_frame_wsc_ie_c* instance =
       
   123         new core_frame_wsc_ie_c( 0, buffer, max_length );
       
   124     if ( !instance )
       
   125         {
       
   126         DEBUG( "core_frame_wsc_ie_c::instance() - unable to create an instance" );
       
   127         delete[] buffer;
       
   128 
       
   129         return NULL;
       
   130         }
       
   131 
       
   132     instance->generate(
       
   133         version,
       
   134         request_type );
       
   135     
       
   136     // Update members according to generated values.
       
   137     // This is not necessary needed, but in testing phase this is useful.
       
   138     instance->search_attributes();
       
   139     
       
   140     return instance;
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // ---------------------------------------------------------------------------
       
   145 //       
       
   146 core_frame_wsc_ie_c::~core_frame_wsc_ie_c()
       
   147     {
       
   148     DEBUG( "core_frame_wsc_ie_c::~core_frame_wsc_ie_c()" );
       
   149     }
       
   150 
       
   151 
       
   152 // ---------------------------------------------------------------------------
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 u16_t core_frame_wsc_ie_c::association_state() const
       
   156     {
       
   157     if ( association_state_ind_m == 0 )
       
   158         {
       
   159         DEBUG( "core_frame_wsc_ie_c::association_state() - association_state field not found from IE" );
       
   160         return 0;
       
   161         }
       
   162     return core_tools_c::get_u16_big_endian(
       
   163         data_m, association_state_ind_m);
       
   164     }
       
   165 
       
   166 // ---------------------------------------------------------------------------
       
   167 // ---------------------------------------------------------------------------
       
   168 //
       
   169 u16_t core_frame_wsc_ie_c::config_methods() const
       
   170     {
       
   171     if ( config_methods_ind_m == 0 )
       
   172         {
       
   173         DEBUG( "core_frame_wsc_ie_c::config_methods() - config_methods field not found from IE" );
       
   174         return 0;
       
   175         }
       
   176     return core_tools_c::get_u16_big_endian(
       
   177         data_m, config_methods_ind_m);
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // ---------------------------------------------------------------------------
       
   182 //
       
   183 u16_t core_frame_wsc_ie_c::configuration_error() const
       
   184     {
       
   185     if ( configuration_error_ind_m == 0 )
       
   186         {
       
   187         DEBUG( "core_frame_wsc_ie_c::configuration_error() - configuration_error field not found from IE" );
       
   188         return 0;
       
   189         }
       
   190     return core_tools_c::get_u16_big_endian(
       
   191         data_m, configuration_error_ind_m);
       
   192     }
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // ---------------------------------------------------------------------------
       
   196 //
       
   197 const u8_t* core_frame_wsc_ie_c::device_name() const
       
   198     {
       
   199     if ( device_name_ind_m == 0 )
       
   200         {
       
   201         DEBUG( "core_frame_wsc_ie_c::device_name() - device_name field not found from IE" );
       
   202         return NULL;
       
   203         }
       
   204     return &data_m[device_name_ind_m];
       
   205     }
       
   206     
       
   207 // ---------------------------------------------------------------------------
       
   208 // ---------------------------------------------------------------------------
       
   209 //
       
   210 u16_t core_frame_wsc_ie_c::device_password_id() const
       
   211     {
       
   212     if ( device_password_id_ind_m == 0 )
       
   213         {
       
   214         DEBUG( "core_frame_wsc_ie_c::device_password_id() - device_password_id field not found from IE" );
       
   215         return 0xFFFF;
       
   216         }
       
   217     return core_tools_c::get_u16_big_endian(
       
   218         data_m, device_password_id_ind_m);
       
   219     }
       
   220 
       
   221 // ---------------------------------------------------------------------------
       
   222 // ---------------------------------------------------------------------------
       
   223 //
       
   224 const u8_t* core_frame_wsc_ie_c::manufacturer() const
       
   225     {
       
   226     if ( manufacturer_ind_m == 0 )
       
   227         {
       
   228         DEBUG( "core_frame_wsc_ie_c::manufacturer() - manufacturer field not found from IE" );
       
   229         return NULL;
       
   230         }
       
   231     return &data_m[manufacturer_ind_m];
       
   232     }
       
   233 
       
   234 // ---------------------------------------------------------------------------
       
   235 // ---------------------------------------------------------------------------
       
   236 //
       
   237 const u8_t* core_frame_wsc_ie_c::model_name() const
       
   238     {
       
   239     if ( model_name_ind_m == 0 )
       
   240         {
       
   241         DEBUG( "core_frame_wsc_ie_c::model_name() - model_name field not found from IE" );
       
   242         return NULL;
       
   243         }
       
   244     return &data_m[model_name_ind_m];
       
   245     }
       
   246 
       
   247 // ---------------------------------------------------------------------------
       
   248 // ---------------------------------------------------------------------------
       
   249 //
       
   250 const u8_t* core_frame_wsc_ie_c::model_number() const
       
   251     {
       
   252     if ( model_number_ind_m == 0 )
       
   253         {
       
   254         DEBUG( "core_frame_wsc_ie_c::model_number() - model_number field not found from IE" );
       
   255         return NULL;
       
   256         }
       
   257     return &data_m[model_number_ind_m];
       
   258     }
       
   259     
       
   260 // ---------------------------------------------------------------------------
       
   261 // ---------------------------------------------------------------------------
       
   262 //
       
   263 u8_t core_frame_wsc_ie_c::request_type() const
       
   264     {
       
   265     if ( request_type_ind_m == 0 )
       
   266         {
       
   267         DEBUG( "core_frame_wsc_ie_c::request_type() - request_type field not found from IE" );
       
   268         return 0xFF;
       
   269         }
       
   270     return data_m[request_type_ind_m];
       
   271     }
       
   272 
       
   273 // ---------------------------------------------------------------------------
       
   274 // ---------------------------------------------------------------------------
       
   275 //
       
   276 u8_t core_frame_wsc_ie_c::response_type() const
       
   277     {
       
   278     if ( response_type_ind_m == 0 )
       
   279         {
       
   280         DEBUG( "core_frame_wsc_ie_c::response_type() - response_type field not found from IE" );
       
   281         return 0xFF;
       
   282         }
       
   283     return data_m[response_type_ind_m];
       
   284     }
       
   285 
       
   286 // ---------------------------------------------------------------------------
       
   287 // ---------------------------------------------------------------------------
       
   288 //
       
   289 u8_t core_frame_wsc_ie_c::rf_bands() const
       
   290     {
       
   291     if ( rf_bands_ind_m == 0 )
       
   292         {
       
   293         DEBUG( "core_frame_wsc_ie_c::rf_bands() - rf_bands field not found from IE" );
       
   294         return 0;
       
   295         }
       
   296     return data_m[rf_bands_ind_m];
       
   297     }
       
   298 
       
   299 // ---------------------------------------------------------------------------
       
   300 // ---------------------------------------------------------------------------
       
   301 //
       
   302 bool_t core_frame_wsc_ie_c::selected_registrar() const
       
   303     {
       
   304     if ( selected_registrar_ind_m == 0 )
       
   305         {
       
   306         DEBUG( "core_frame_wsc_ie_c::selected_registrar() - selected_registrar field not found from IE" );
       
   307         return false_t;
       
   308         }
       
   309     else if ( data_m[selected_registrar_ind_m] == 0 )
       
   310         {
       
   311         return false_t;
       
   312         }
       
   313     else
       
   314         {
       
   315         return true_t;
       
   316         }
       
   317     }
       
   318 
       
   319 // ---------------------------------------------------------------------------
       
   320 // ---------------------------------------------------------------------------
       
   321 //
       
   322 const u8_t* core_frame_wsc_ie_c::serial_number() const
       
   323     {
       
   324     if ( serial_number_ind_m == 0 )
       
   325         {
       
   326         DEBUG( "core_frame_wsc_ie_c::serial_number() - serial_number field not found from IE" );
       
   327         return NULL;
       
   328         }
       
   329     return &data_m[serial_number_ind_m];
       
   330     }
       
   331 
       
   332 // ---------------------------------------------------------------------------
       
   333 // ---------------------------------------------------------------------------
       
   334 //
       
   335 u8_t core_frame_wsc_ie_c::protected_setup_state() const
       
   336     {
       
   337     if ( protected_setup_state_ind_m == 0 )
       
   338         {
       
   339         DEBUG( "core_frame_wsc_ie_c::protected_setup_state() - protected_setup_state field not found from IE" );
       
   340         return 0;
       
   341         }
       
   342     return data_m[protected_setup_state_ind_m];
       
   343     }
       
   344 
       
   345 // ---------------------------------------------------------------------------
       
   346 // ---------------------------------------------------------------------------
       
   347 //
       
   348 const u8_t* core_frame_wsc_ie_c::uuid_e() const
       
   349     {
       
   350     if ( uuid_e_ind_m == 0 )
       
   351         {
       
   352         DEBUG( "core_frame_wsc_ie_c::uuid_e() - uuid_e field not found from IE" );
       
   353         return NULL;
       
   354         }
       
   355     return &data_m[uuid_e_ind_m];
       
   356     }
       
   357 
       
   358 // ---------------------------------------------------------------------------
       
   359 // ---------------------------------------------------------------------------
       
   360 //
       
   361 const u8_t* core_frame_wsc_ie_c::uuid_r() const
       
   362     {
       
   363     if ( uuid_r_ind_m == 0 )
       
   364         {
       
   365         DEBUG( "core_frame_wsc_ie_c::uuid_r() - uuid_r field not found from IE" );
       
   366         return NULL;
       
   367         }
       
   368     return &data_m[uuid_r_ind_m];
       
   369     }
       
   370 
       
   371 // ---------------------------------------------------------------------------
       
   372 // ---------------------------------------------------------------------------
       
   373 //
       
   374 u8_t core_frame_wsc_ie_c::version() const
       
   375     {
       
   376     if ( version_ind_m == 0 )
       
   377         {
       
   378         DEBUG( "core_frame_wsc_ie_c::version() - version field not found from IE" );
       
   379         return 0x00;
       
   380         }
       
   381     return data_m[version_ind_m];
       
   382     }
       
   383 
       
   384 // ---------------------------------------------------------------------------
       
   385 // ---------------------------------------------------------------------------
       
   386 //
       
   387 u16_t core_frame_wsc_ie_c::selected_registrar_config_methods() const
       
   388     {
       
   389     if ( selected_registrar_config_methods_ind_m == 0 )
       
   390         {
       
   391         DEBUG( "core_frame_wsc_ie_c::selected_registrar_config_methods() - selected_registrar_config_methods field not found from IE" );
       
   392         return 0;
       
   393         }
       
   394     return core_tools_c::get_u16_big_endian(
       
   395         data_m, selected_registrar_config_methods_ind_m);
       
   396     }
       
   397 
       
   398 // ---------------------------------------------------------------------------
       
   399 // ---------------------------------------------------------------------------
       
   400 //
       
   401 const u8_t* core_frame_wsc_ie_c::primary_device_type() const
       
   402     {
       
   403     if ( primary_device_type_ind_m == 0 )
       
   404         {
       
   405         DEBUG( "core_frame_wsc_ie_c::primary_device_type() - primary_device_type field not found from IE" );
       
   406         return 0;
       
   407         }
       
   408     return &data_m[primary_device_type_ind_m];
       
   409     }
       
   410 
       
   411 // ---------------------------------------------------------------------------
       
   412 // ---------------------------------------------------------------------------
       
   413 //
       
   414 bool_t core_frame_wsc_ie_c::ap_setup_locked() const
       
   415     {
       
   416     if ( ap_setup_locked_ind_m == 0 )
       
   417         {
       
   418         DEBUG( "core_frame_wsc_ie_c::ap_setup_locked() - ap_setup_locked field not found from IE" );
       
   419         return false_t;
       
   420         }
       
   421     else if ( data_m[ap_setup_locked_ind_m] == 0 )
       
   422         {
       
   423         return false_t;
       
   424         }
       
   425     else
       
   426         {
       
   427         return true_t;
       
   428         }
       
   429     }
       
   430 
       
   431 
       
   432 
       
   433 
       
   434 // ---------------------------------------------------------------------------
       
   435 // ---------------------------------------------------------------------------
       
   436 /** Search attributes from WSC IE.
       
   437  * 
       
   438  * The main idea in searching is to loop through IE, and store index of each attribute
       
   439  * to member variable. After loop, it is easy to get needed attribute with stored index.
       
   440  * 
       
   441  * All data is in big endian format.
       
   442  */
       
   443 void core_frame_wsc_ie_c::search_attributes()
       
   444     {
       
   445     DEBUG( "core_frame_wsc_ie_c::search_attributes()" );
       
   446     
       
   447     u16_t index( CORE_FRAME_WSC_IE_PROTECTED_SETUP_DATA_OFFSET );
       
   448     while (index < data_length())
       
   449         {
       
   450         u16_t attribute_type = core_tools_c::get_u16_big_endian(
       
   451             data_m, index);
       
   452             
       
   453         u16_t attribute_data_length = core_tools_c::get_u16_big_endian(
       
   454             data_m, index + CORE_FRAME_WSC_IE_DATA_LENGTH_OFFSET);
       
   455         //DEBUG3( "core_frame_wsc_ie_c::search_attributes() - found attribute 0x%04x at index %u (length=%u)", attribute_type, index, attribute_data_length);
       
   456         
       
   457         // Check if all attribute data does not fit current IE.
       
   458         if ( ( index + attribute_data_length + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET ) > data_length())
       
   459             {
       
   460             DEBUG5( "core_frame_wsc_ie_c::search_attributes() - attribute 0x%04x does not fit current IE, giving up. IE length=%u, Attribute length=%u ([%u..%u])", 
       
   461                 attribute_type,
       
   462                 data_length(), 
       
   463                 attribute_data_length,
       
   464                 index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET,
       
   465                 index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET + attribute_data_length - 1 );
       
   466             return;
       
   467             }
       
   468             
       
   469         switch (attribute_type)
       
   470             {
       
   471             case CORE_FRAME_WSC_IE_ASSOCIATION_STATE:
       
   472                 {
       
   473                 association_state_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   474                 DEBUG2( "core_frame_wsc_ie_c::search_attributes() - ASSOCIATION_STATE data at index %u (value = %u)", 
       
   475                     association_state_ind_m, association_state() );
       
   476                 break;
       
   477                 }
       
   478                 
       
   479             case CORE_FRAME_WSC_IE_CONFIG_METHODS:
       
   480                 {
       
   481                 config_methods_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   482                 DEBUG2( "core_frame_wsc_ie_c::search_attributes() - CONFIG_METHODS data at index %u (value = 0x%02X)", 
       
   483                     config_methods_ind_m, config_methods() );
       
   484                 break;
       
   485                 }
       
   486                 
       
   487             case CORE_FRAME_WSC_IE_CONFIGURATION_ERROR:
       
   488                 {
       
   489                 configuration_error_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   490                 DEBUG2( "core_frame_wsc_ie_c::search_attributes() - CONFIGURATION_ERROR data at index %u (value = %u)", 
       
   491                     configuration_error_ind_m, configuration_error() );
       
   492                 break;
       
   493                 }
       
   494                 
       
   495             case CORE_FRAME_WSC_IE_DEVICE_NAME:
       
   496                 {
       
   497                 device_name_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   498                 DEBUG1( "core_frame_wsc_ie_c::search_attributes() - DEVICE_NAME data at index %u, data (UTF-8):", 
       
   499                     device_name_ind_m );
       
   500                 const u8_t* debug_device_name = device_name();
       
   501                 if (debug_device_name)
       
   502                     {
       
   503                     DEBUG_BUFFER( attribute_data_length, debug_device_name);
       
   504                     }
       
   505                 break;
       
   506                 }
       
   507                 
       
   508             case CORE_FRAME_WSC_IE_DEVICE_PASSWORD_ID:
       
   509                 {
       
   510                 device_password_id_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   511                 DEBUG2( "core_frame_wsc_ie_c::search_attributes() - DEVICE_PASSWORD_ID data at index %u (value = %u)", 
       
   512                     device_password_id_ind_m, device_password_id() );
       
   513                 break;
       
   514                 }
       
   515                 
       
   516             case CORE_FRAME_WSC_IE_MANUFACTURER:
       
   517                 {
       
   518                 manufacturer_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   519                 DEBUG1( "core_frame_wsc_ie_c::search_attributes() - MANUFACTURER data at index %u, data (ASCII):", 
       
   520                     manufacturer_ind_m );
       
   521                 const u8_t* debug_manufacturer = manufacturer();
       
   522                 if (debug_manufacturer)
       
   523                     {
       
   524                     u16_t length = attribute_data_length;
       
   525                     if ( length > CORE_FRAME_WSC_IE_MANUFACTURER_MAX_LENGTH )
       
   526                         {
       
   527                         length = CORE_FRAME_WSC_IE_MANUFACTURER_MAX_LENGTH;
       
   528                         }
       
   529                     DEBUG1S("MANUFACTURER: ", length, debug_manufacturer);
       
   530                     }
       
   531                 break;
       
   532                 }
       
   533 
       
   534             case CORE_FRAME_WSC_IE_MODEL_NAME:
       
   535                 {
       
   536                 model_name_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   537                 DEBUG1( "core_frame_wsc_ie_c::search_attributes() - MODEL_NAME data at index %u, data (ASCII):", 
       
   538                     model_name_ind_m );
       
   539                 const u8_t* debug_model_name = model_name();
       
   540                 if (debug_model_name)
       
   541                     {
       
   542                     u16_t length = attribute_data_length;
       
   543                     if ( length > CORE_FRAME_WSC_IE_MODEL_NAME_MAX_LENGTH )
       
   544                         {
       
   545                         length = CORE_FRAME_WSC_IE_MODEL_NAME_MAX_LENGTH;
       
   546                         }
       
   547                     DEBUG1S("MODEL_NAME: ", length, debug_model_name);
       
   548                     }
       
   549                 break;
       
   550                 }
       
   551                 
       
   552             case CORE_FRAME_WSC_IE_MODEL_NUMBER:
       
   553                 {
       
   554                 model_number_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   555                 DEBUG1( "core_frame_wsc_ie_c::search_attributes() - MODEL_NUMBER data at index %u, data:", 
       
   556                     model_number_ind_m );
       
   557                 const u8_t* debug_model_number = model_number();
       
   558                 if (debug_model_number)
       
   559                     {
       
   560                     DEBUG_BUFFER( attribute_data_length, debug_model_number);
       
   561                     }
       
   562                 break;
       
   563                 }
       
   564 
       
   565             case CORE_FRAME_WSC_IE_REQUEST_TYPE:
       
   566                 {
       
   567                 request_type_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   568                 DEBUG2( "core_frame_wsc_ie_c::search_attributes() - REQUEST_TYPE data at index %u (value = %u)", 
       
   569                     request_type_ind_m, request_type() );
       
   570                 break;
       
   571                 }
       
   572                 
       
   573             case CORE_FRAME_WSC_IE_RESPONSE_TYPE:
       
   574                 {
       
   575                 response_type_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   576                 DEBUG2( "core_frame_wsc_ie_c::search_attributes() - RESPONSE_TYPE data at index %u (value = %u)", 
       
   577                     response_type_ind_m, response_type() );
       
   578                 break;
       
   579                 }
       
   580                 
       
   581             case CORE_FRAME_WSC_IE_RF_BANDS:
       
   582                 {
       
   583                 rf_bands_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   584                 DEBUG2( "core_frame_wsc_ie_c::search_attributes() - RF_BANDS data at index %u (value = %u)", 
       
   585                     rf_bands_ind_m, rf_bands() );
       
   586                 break;
       
   587                 }
       
   588                 
       
   589             case CORE_FRAME_WSC_IE_SELECTED_REGISTRAR:
       
   590                 {
       
   591                 selected_registrar_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   592                 DEBUG2( "core_frame_wsc_ie_c::search_attributes() - SELECTED_REGISTRAR data at index %u (value = %u)", 
       
   593                     selected_registrar_ind_m, selected_registrar() );
       
   594                 break;
       
   595                 }
       
   596 
       
   597             case CORE_FRAME_WSC_IE_SERIAL_NUMBER:
       
   598                 {
       
   599                 serial_number_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   600                 DEBUG1( "core_frame_wsc_ie_c::search_attributes() - SERIAL_NUMBER data at index %u, data:", 
       
   601                     serial_number_ind_m );
       
   602                 const u8_t* debug_serial_number = serial_number();
       
   603                 if (debug_serial_number)
       
   604                     {
       
   605                     DEBUG_BUFFER( attribute_data_length, debug_serial_number);
       
   606                     }
       
   607                 break;
       
   608                 }
       
   609 
       
   610             case CORE_FRAME_WSC_IE_PROTECTED_SETUP_STATE:
       
   611                 {
       
   612                 protected_setup_state_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   613                 DEBUG2( "core_frame_wsc_ie_c::search_attributes() - PROTECTED_SETUP_STATE data at index %u (value = %u)", 
       
   614                     protected_setup_state_ind_m, protected_setup_state() );
       
   615                 break;
       
   616                 }
       
   617                 
       
   618             case CORE_FRAME_WSC_IE_UUID_E:
       
   619                 {
       
   620                 uuid_e_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   621                 DEBUG1( "core_frame_wsc_ie_c::search_attributes() - UUID_E data at index %u, data:", 
       
   622                     uuid_e_ind_m );
       
   623                 
       
   624                 const u8_t* debug_uuid_e = uuid_e();
       
   625                 if (debug_uuid_e)
       
   626                     {
       
   627                     DEBUG_BUFFER( attribute_data_length, debug_uuid_e);
       
   628                     }
       
   629                 break;
       
   630                 }
       
   631                 
       
   632             case CORE_FRAME_WSC_IE_UUID_R:
       
   633                 {
       
   634                 uuid_r_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   635                 DEBUG1( "core_frame_wsc_ie_c::search_attributes() - UUID_R data at index %u, data:", 
       
   636                     uuid_r_ind_m );
       
   637                 
       
   638                 const u8_t* debug_uuid_r = uuid_r();
       
   639                 if (debug_uuid_r)
       
   640                     {
       
   641                     DEBUG_BUFFER( attribute_data_length, debug_uuid_r);
       
   642                     }
       
   643                 break;
       
   644                 }
       
   645                 
       
   646             case CORE_FRAME_WSC_IE_VERSION:
       
   647                 {
       
   648                 version_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   649                 u8_t wsc_version = version();
       
   650                 DEBUG3( "core_frame_wsc_ie_c::search_attributes() - VERSION data at index %u (value = %x.%x)", 
       
   651                     version_ind_m, (wsc_version&0xF0)>>4, (wsc_version&0x0F) );
       
   652                 break;
       
   653                 }
       
   654                 
       
   655             case CORE_FRAME_WSC_IE_SELECTED_REGISTRAR_CONFIG_METHODS:
       
   656                 {
       
   657                 selected_registrar_config_methods_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   658                 DEBUG2( "core_frame_wsc_ie_c::search_attributes() - SELECTED_REGISTRAR_CONFIG_METHODS data at index %u (value = 0x%02X)", 
       
   659                     selected_registrar_config_methods_ind_m, selected_registrar_config_methods() );
       
   660                 break;
       
   661                 }
       
   662                 
       
   663             case CORE_FRAME_WSC_IE_PRIMARY_DEVICE_TYPE:
       
   664                 {
       
   665                 primary_device_type_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   666                 
       
   667                 const u8_t* device_type = primary_device_type();
       
   668                 DEBUG3( "core_frame_wsc_ie_c::search_attributes() - PRIMARY_DEVICE_TYPE data at index %u (CategoryID = %u, SubcategoryID = %u)", 
       
   669                     primary_device_type_ind_m,
       
   670                     core_tools_c::get_u16_big_endian(
       
   671                         device_type, 0),
       
   672                     core_tools_c::get_u16_big_endian(
       
   673                         device_type, 2+CORE_FRAME_WSC_IE_OUI_LENGTH) );
       
   674                 break;
       
   675                 }
       
   676                 
       
   677             case CORE_FRAME_WSC_IE_AP_SETUP_LOCKED:
       
   678                 {
       
   679                 ap_setup_locked_ind_m = index + CORE_FRAME_WSC_IE_DATA_AREA_OFFSET;
       
   680                 DEBUG2( "core_frame_wsc_ie_c::search_attributes() - AP_SETUP_LOCKED data at index %u (value = %u)", 
       
   681                     ap_setup_locked_ind_m, ap_setup_locked() );
       
   682                 break;
       
   683                 }
       
   684                 
       
   685             default:
       
   686                 DEBUG3( "core_frame_wsc_ie_c::search_attributes() - unhandled attribute 0x%04x from index %u (length = %u)", 
       
   687                     attribute_type, index, attribute_data_length );
       
   688             }
       
   689         // update index to start of next attribute
       
   690         index += CORE_FRAME_WSC_IE_DATA_AREA_OFFSET + attribute_data_length;
       
   691         }
       
   692     }
       
   693 
       
   694 // ---------------------------------------------------------------------------
       
   695 // ---------------------------------------------------------------------------
       
   696 // Generate IE for Association request
       
   697 void core_frame_wsc_ie_c::generate(
       
   698     const u8_t version,
       
   699     const u8_t request_type )
       
   700     {
       
   701     ASSERT( !data_length_m );
       
   702     ASSERT( max_data_length_m );   
       
   703 
       
   704     core_frame_dot11_ie_c::generate(
       
   705         core_frame_dot11_ie_element_id_wpa );
       
   706 
       
   707     // WSC OUI field
       
   708     core_tools_c::copy(
       
   709         &data_m[data_length_m],
       
   710         &CORE_FRAME_WSC_IE_OUI[0],
       
   711         CORE_FRAME_WSC_IE_OUI_LENGTH );
       
   712     data_length_m += CORE_FRAME_WSC_IE_OUI_LENGTH;
       
   713 
       
   714 
       
   715     // ------------------------------------
       
   716     // Version
       
   717     // AttributeType
       
   718     u16_t attribute_type = core_tools_c::convert_host_to_big_endian( CORE_FRAME_WSC_IE_VERSION );
       
   719     core_tools_c::copy(
       
   720         &data_m[data_length_m],
       
   721         &attribute_type,
       
   722         //reinterpret_cast<u8_t*>(&attribute_type),
       
   723         sizeof( attribute_type ) );
       
   724     data_length_m += sizeof( attribute_type );
       
   725     
       
   726     // DataLength
       
   727     u16_t data_length = sizeof(version);
       
   728     data_length = core_tools_c::convert_host_to_big_endian( data_length );
       
   729     core_tools_c::copy(
       
   730         &data_m[data_length_m],
       
   731         &data_length,
       
   732         //reinterpret_cast<u8_t*>(&data_length),
       
   733         sizeof( data_length ) );
       
   734     data_length_m += sizeof( data_length );
       
   735     
       
   736     // actual data
       
   737     data_m[data_length_m] = version;
       
   738     data_length_m += sizeof(version);
       
   739     
       
   740     // ------------------------------------
       
   741     // Request type
       
   742     // AttributeType
       
   743     attribute_type = core_tools_c::convert_host_to_big_endian( CORE_FRAME_WSC_IE_REQUEST_TYPE );
       
   744     core_tools_c::copy(
       
   745         &data_m[data_length_m],
       
   746         &attribute_type,
       
   747         sizeof( attribute_type ) );
       
   748     data_length_m += sizeof( attribute_type );
       
   749     
       
   750     // DataLength
       
   751     data_length = sizeof(request_type);
       
   752     data_length = core_tools_c::convert_host_to_big_endian( data_length );
       
   753     core_tools_c::copy(
       
   754         &data_m[data_length_m],
       
   755         &data_length,
       
   756         sizeof( data_length ) );
       
   757     data_length_m += sizeof( data_length );
       
   758     
       
   759     // actual data
       
   760     data_m[data_length_m] = request_type;
       
   761     data_length_m += sizeof(request_type);
       
   762     
       
   763     
       
   764     // Set length of whole IE
       
   765     set_length( data_length_m );
       
   766     }
       
   767 
       
   768 // ---------------------------------------------------------------------------
       
   769 // ---------------------------------------------------------------------------
       
   770 //
       
   771 core_frame_wsc_ie_c::core_frame_wsc_ie_c(
       
   772     u16_t data_length,
       
   773     const u8_t* data,
       
   774     u16_t max_data_length ) :
       
   775     core_frame_dot11_ie_c( data_length, data, max_data_length ),
       
   776     association_state_ind_m( 0 ),
       
   777     config_methods_ind_m( 0 ),
       
   778     configuration_error_ind_m( 0 ),
       
   779     device_name_ind_m( 0 ),
       
   780     device_password_id_ind_m( 0 ),
       
   781     manufacturer_ind_m( 0 ),
       
   782     model_name_ind_m( 0 ),
       
   783     model_number_ind_m( 0 ),
       
   784     request_type_ind_m( 0 ),
       
   785     response_type_ind_m( 0 ),
       
   786     rf_bands_ind_m( 0 ),
       
   787     selected_registrar_ind_m( 0 ),
       
   788     serial_number_ind_m( 0 ),
       
   789     protected_setup_state_ind_m( 0 ),
       
   790     uuid_e_ind_m( 0 ),
       
   791     uuid_r_ind_m( 0 ),
       
   792     version_ind_m( 0 ),
       
   793     selected_registrar_config_methods_ind_m( 0 ),
       
   794     primary_device_type_ind_m( 0 ),
       
   795     ap_setup_locked_ind_m( 0 )
       
   796     {
       
   797     DEBUG( "core_frame_wsc_ie_c::core_frame_wsc_ie_c()" );
       
   798     }