wlan_bearer/wlanengine/wlan_common/wlanengine_common_3.1/src/core_frame_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.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "core_frame_action.h"
       
    20 #include "core_tools.h"
       
    21 #include "am_debug.h"
       
    22 
       
    23 // ======== MEMBER FUNCTIONS ========
       
    24 
       
    25 const u16_t CORE_FRAME_ACTION_MIN_LENGTH = 25;
       
    26 const u16_t CORE_FRAME_ACTION_CATEGORY_INDEX = 24;
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 core_frame_action_c* core_frame_action_c::instance(
       
    32     const core_frame_dot11_c& frame )
       
    33     {
       
    34     DEBUG( "core_frame_action_c::instance()" );
       
    35 
       
    36     if ( frame.data_length() < CORE_FRAME_ACTION_MIN_LENGTH )
       
    37         {
       
    38         DEBUG( "core_frame_action_c::instance() - not a valid 802.11 frame, frame is too short" );
       
    39         
       
    40         return NULL;
       
    41         }
       
    42 
       
    43     core_frame_action_c* instance = new core_frame_action_c(
       
    44         frame.data_length(),
       
    45         frame.data(),
       
    46         0 );
       
    47     if ( !instance )
       
    48         {
       
    49         DEBUG( "core_frame_action_c::instance() - unable to create an instance" );
       
    50         
       
    51         return NULL;
       
    52         }
       
    53 
       
    54     if ( instance->type() != core_frame_dot11_c::core_dot11_type_action )
       
    55         {
       
    56         DEBUG( "core_frame_action_c::instance() - not a valid action frame" );
       
    57         delete instance;
       
    58 
       
    59         return NULL;
       
    60         }
       
    61 
       
    62     return instance;
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 core_frame_action_c::~core_frame_action_c()
       
    69     {
       
    70     DEBUG( "core_frame_action_c::~core_frame_action_c()" );
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 u8_t core_frame_action_c::category() const
       
    77     {
       
    78     return data_m[CORE_FRAME_ACTION_CATEGORY_INDEX];
       
    79     }
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 void core_frame_action_c::set_category( u8_t cat )
       
    85     {
       
    86     data_m[CORE_FRAME_ACTION_CATEGORY_INDEX] = cat;
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 void core_frame_action_c::generate(
       
    93     u16_t duration,
       
    94     const core_mac_address_s& destination,
       
    95     const core_mac_address_s& source,
       
    96     const core_mac_address_s& bssid,
       
    97     u16_t sequence_control,
       
    98     u8_t category )
       
    99     {
       
   100     ASSERT( !data_length_m );
       
   101     ASSERT( max_data_length_m );   
       
   102 
       
   103     core_frame_dot11_c::generate(    
       
   104         core_frame_dot11_c::core_dot11_type_action,
       
   105         duration,
       
   106         destination,
       
   107         source,
       
   108         bssid,
       
   109         sequence_control );
       
   110 
       
   111     // Category
       
   112     data_m[data_length_m++] = category;
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 core_frame_action_c::core_frame_action_c(
       
   119     u16_t data_length,
       
   120     const u8_t* data,
       
   121     u16_t max_data_length ) :
       
   122     core_frame_dot11_c( data_length, data, max_data_length )
       
   123     {
       
   124     DEBUG( "core_frame_action_c::core_frame_action_c()" );
       
   125     }