wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_frame_radio_measurement_action.cpp
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:  Class for parsing and generating 802.11 action frames in RM category.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "core_frame_radio_measurement_action.h"
       
    20 #include "core_frame_rm_ie.h"
       
    21 #include "core_tools.h"
       
    22 #include "am_debug.h"
       
    23 
       
    24 // ======== MEMBER FUNCTIONS ========
       
    25 
       
    26 const u16_t CORE_FRAME_RADIO_MEASUREMENT_ACTION_MIN_LENGTH = 28;
       
    27 const u16_t CORE_FRAME_RADIO_MEASUREMENT_ACTION_TYPE_INDEX = 25;
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 core_frame_radio_measurement_action_c* core_frame_radio_measurement_action_c::instance(
       
    33     const core_frame_action_c& frame,
       
    34     bool_t is_copied )
       
    35     {
       
    36     DEBUG( "core_frame_radio_measurement_action_c::instance()" );
       
    37     DEBUG1( "core_frame_radio_measurement_action_c::instance() - is_copied %u",
       
    38         is_copied );  
       
    39 
       
    40     if ( frame.data_length() < CORE_FRAME_RADIO_MEASUREMENT_ACTION_MIN_LENGTH )
       
    41         {
       
    42         DEBUG( "core_frame_action_rm_c::instance() - not a valid 802.11 frame, frame is too short" );
       
    43         
       
    44         return NULL;
       
    45         }
       
    46 
       
    47     u8_t* buffer = const_cast<u8_t*>( frame.data() );
       
    48     u16_t buffer_length( 0 );
       
    49 
       
    50     if( is_copied )
       
    51         {
       
    52         buffer_length = frame.data_length();
       
    53         buffer = new u8_t[buffer_length];
       
    54         
       
    55         if( !buffer )
       
    56             {
       
    57             DEBUG( "core_frame_radio_measurement_action_c::instance() - not able to allocate buffer for copying" );
       
    58         
       
    59             return NULL;            
       
    60             }
       
    61 
       
    62         core_tools_c::copy( buffer, frame.data(), buffer_length );
       
    63         }
       
    64 
       
    65     core_frame_radio_measurement_action_c* instance = new core_frame_radio_measurement_action_c(
       
    66         buffer_length,
       
    67         buffer,
       
    68         buffer_length );
       
    69 
       
    70     if ( !instance )
       
    71         {
       
    72         DEBUG( "core_frame_radio_measurement_action_c::instance() - unable to create an instance" );
       
    73         
       
    74         return NULL;
       
    75         }
       
    76 
       
    77     return instance;
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 core_frame_radio_measurement_action_c::~core_frame_radio_measurement_action_c()
       
    84     {
       
    85     DEBUG1( "core_frame_radio_measurement_action_c::~core_frame_radio_measurement_action_c() @ 0x%08X", this );
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 u8_t core_frame_radio_measurement_action_c::action_type() const
       
    92     {
       
    93     return data_m[CORE_FRAME_RADIO_MEASUREMENT_ACTION_TYPE_INDEX];
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 core_frame_radio_measurement_action_c::core_frame_radio_measurement_action_c(
       
   100     u16_t data_length,
       
   101     const u8_t* data,
       
   102     u16_t max_data_length ) :
       
   103     core_frame_action_c( data_length, data, max_data_length )
       
   104     {
       
   105     }