eapol/eapol_framework/wapi_symbian/wlanwapiif/src/wlan_wapi_if_implementation.cpp
changeset 17 8840d3e38314
equal deleted inserted replaced
2:1c7bc153c08e 17:8840d3e38314
       
     1 /*
       
     2 * ============================================================================
       
     3 *  Name        : ./accesssec/eapol/eapol_framework/wapi_symbian/wlanwapiif/src/wlan_wapi_if_implementation.cpp
       
     4 *  Part of     : WAPI / WAPI       *** Info from the SWAD
       
     5 *  Description : WAPI authentication
       
     6 *  Version     : %version: 5.1.2 % << Don't touch! Updated by Synergy at check-out.
       
     7 *
       
     8 *  Copyright © 2001-2009 Nokia.  All rights reserved.
       
     9 *  This material, including documentation and any related computer
       
    10 *  programs, is protected by copyright controlled by Nokia.  All
       
    11 *  rights are reserved.  Copying, including reproducing, storing,
       
    12 *  adapting or translating, any or all of this material requires the
       
    13 *  prior written consent of Nokia.  This material also contains
       
    14 *  confidential information which may not be disclosed to others
       
    15 *  without the prior written consent of Nokia.
       
    16 * ============================================================================
       
    17 * Template version: 4.1.1
       
    18 */
       
    19 
       
    20 // INCLUDES
       
    21 #include <e32std.h>
       
    22 #include <implementationproxy.h>
       
    23 
       
    24 #include "abs_eap_am_tools.h"
       
    25 
       
    26 #include "wapi_message_wlan_authentication.h"
       
    27 #include "wlan_wapi_if_implementation.h"
       
    28 #include "wlan_eap_if_send_status.h"
       
    29 
       
    30 //-----------------------------------------------------------------------------------------
       
    31 
       
    32 /**
       
    33  * Pairs ECom implementation UIDs with a pointer to the instantiation 
       
    34  * method for that implementation. Required for all ECom implementation
       
    35  * collections.
       
    36  */
       
    37 const TImplementationProxy ImplementationTable[] =
       
    38 {
       
    39     {{KCWlanWapiClientUid}, reinterpret_cast<TProxyNewLPtr>(CWlanWAPIInterfaceImplementation::NewL)} 
       
    40 };
       
    41 
       
    42 //-----------------------------------------------------------------------------------------
       
    43 
       
    44 /**
       
    45  * Static constructor.
       
    46  * @param aPartner Pointer to callback instance.
       
    47  * @return Pointer to the constructed instance.
       
    48  */
       
    49 CWlanWAPIInterfaceImplementation* CWlanWAPIInterfaceImplementation::NewL(MWlanEapolCallbackInterface * aPartner)
       
    50 {
       
    51 	CWlanWAPIInterfaceImplementation* self = new (ELeave) CWlanWAPIInterfaceImplementation;
       
    52 
       
    53 	CleanupStack::PushL(self);
       
    54 
       
    55 	self->ConstructL(aPartner);
       
    56 
       
    57 	if (self->get_is_valid() != true)
       
    58 	{
       
    59 		User::Leave(KErrGeneral);
       
    60 	}
       
    61 
       
    62 	CleanupStack::Pop(self);
       
    63 
       
    64 	return self;
       
    65 }
       
    66 
       
    67 //-----------------------------------------------------------------------------------------
       
    68 
       
    69 /**
       
    70  * C++ default constructor.
       
    71  */
       
    72 CWlanWAPIInterfaceImplementation::CWlanWAPIInterfaceImplementation()
       
    73 : m_am_tools(0)
       
    74 , m_partner(0)
       
    75 , m_wauth(0)
       
    76 , m_is_valid(true)
       
    77 {
       
    78 }
       
    79 
       
    80 //-----------------------------------------------------------------------------------------
       
    81 
       
    82 /**
       
    83  * Destructor.
       
    84  */
       
    85 CWlanWAPIInterfaceImplementation::~CWlanWAPIInterfaceImplementation()
       
    86 {
       
    87 	m_partner = 0;
       
    88 
       
    89 	delete m_wauth;
       
    90 	m_wauth = 0;
       
    91 
       
    92   m_am_tools->am_cancel_all_timers();
       
    93 	abs_eap_am_tools_c::delete_abs_eap_am_tools_c(m_am_tools);
       
    94 	m_am_tools = 0;
       
    95 
       
    96 }
       
    97 
       
    98 //-----------------------------------------------------------------------------------------
       
    99 
       
   100 /**
       
   101  * Configure plugin implementation.
       
   102  *
       
   103  * @since S60 v3.2
       
   104  * @param aHeaderOffset Offset of EAP-header in packet_send.
       
   105  * @param aMTU Maximum transfer unit (MTU).
       
   106  * @param aTrailerLength Length of trailer needed by lower levels..
       
   107  * @return Return value is specified in interface specification.
       
   108  */
       
   109 TInt CWlanWAPIInterfaceImplementation::Configure(
       
   110 	const TInt aHeaderOffset,
       
   111 	const TInt aMTU,
       
   112 	const TInt aTrailerLength)
       
   113 {
       
   114 	m_am_tools = abs_eap_am_tools_c::new_abs_eap_am_tools_c();
       
   115 	
       
   116 	if (m_am_tools == 0)
       
   117 		{
       
   118 			return wlan_eap_if_send_status_conversion_c::convert(
       
   119 			EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); 			
       
   120 		}
       
   121 
       
   122 	// eapol_message_wlan_authentication_c object uses the tools object.
       
   123 	m_wauth = new wapi_message_wlan_authentication_c(
       
   124 		m_am_tools,
       
   125 		this);
       
   126 
       
   127 	if (m_wauth != 0
       
   128 		&& m_wauth->get_is_valid() == true)
       
   129 	{
       
   130 		eap_status_e status = m_wauth->configure(
       
   131 			aHeaderOffset,
       
   132 			aMTU,
       
   133 			aTrailerLength);
       
   134 		if (status != eap_status_ok)
       
   135 		{
       
   136 			return wlan_eap_if_send_status_conversion_c::convert(
       
   137 				EAP_STATUS_RETURN(m_am_tools, status));
       
   138 		}
       
   139 	}
       
   140 	else
       
   141 	{
       
   142 		return wlan_eap_if_send_status_conversion_c::convert(
       
   143 			EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error));
       
   144 	}
       
   145 
       
   146 	return wlan_eap_if_send_status_ok;
       
   147 }
       
   148 
       
   149 //-----------------------------------------------------------------------------------------
       
   150 
       
   151 /**
       
   152  * Shutdown plugin implementation.
       
   153  *
       
   154  * @since S60 v3.2
       
   155  * @return Return value is specified in interface specification.
       
   156  */        
       
   157 TInt CWlanWAPIInterfaceImplementation::Shutdown()
       
   158 {
       
   159 	eap_status_e status = m_wauth->shutdown();
       
   160 
       
   161 	return wlan_eap_if_send_status_conversion_c::convert(
       
   162 			EAP_STATUS_RETURN(m_am_tools, status));
       
   163 }
       
   164 
       
   165 //-----------------------------------------------------------------------------------------
       
   166 
       
   167 /**
       
   168  * Send data to EAPOL.
       
   169  *
       
   170  * @since S60 v3.2
       
   171  * @param aData Pointer to the data to be sent.
       
   172  * @param aLength Length of the data to be sent.
       
   173  * @return Return value is specified in interface specification.
       
   174  */
       
   175 TInt CWlanWAPIInterfaceImplementation::ProcessData(
       
   176 	const void * const aData, 
       
   177 	const TInt aLength )
       
   178 {
       
   179 	return m_wauth->process_data(aData, aLength);
       
   180 }
       
   181 
       
   182 //-----------------------------------------------------------------------------------------
       
   183 
       
   184 /**
       
   185  * Symbian 2nd phase constructor.
       
   186  */
       
   187 void CWlanWAPIInterfaceImplementation::ConstructL(MWlanEapolCallbackInterface * aPartner)
       
   188 {
       
   189 	m_partner = aPartner;
       
   190 }
       
   191 
       
   192 //-----------------------------------------------------------------------------------------
       
   193 
       
   194 bool CWlanWAPIInterfaceImplementation::get_is_valid()
       
   195 {
       
   196 	return m_is_valid;
       
   197 }
       
   198 
       
   199 //-----------------------------------------------------------------------------------------
       
   200 
       
   201 /// Function sends the data message to lower layer.
       
   202 /// Data is formatted to Attribute-Value Pairs.
       
   203 /// Look at eap_tlv_header_c and eap_tlv_message_data_c.
       
   204 wlan_eap_if_send_status_e CWlanWAPIInterfaceImplementation::send_data(const void * const data, const u32_t length)
       
   205 {
       
   206 	return static_cast<wlan_eap_if_send_status_e>(m_partner->SendData(
       
   207         data, 
       
   208         length));
       
   209 }
       
   210 
       
   211 //-----------------------------------------------------------------------------------------
       
   212 
       
   213 // ======== GLOBAL FUNCTIONS ========
       
   214 
       
   215 // ---------------------------------------------------------
       
   216 // Returns an instance of the proxy table.
       
   217 // Returns: KErrNone
       
   218 // ---------------------------------------------------------
       
   219 //
       
   220 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
       
   221     {
       
   222     aTableCount = sizeof( ImplementationTable) / sizeof( TImplementationProxy );
       
   223     return ImplementationTable;
       
   224     }
       
   225 
       
   226 //-----------------------------------------------------------------------------------------
       
   227 
       
   228 // End of file.
       
   229