eapol/eapol_framework/eapol_symbian/eap_if/include/REapSession.h
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
child 55 9c2aa05919d9
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
     1 /*
       
     2 * Copyright (c) 2001-2010 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:  EAP and WLAN authentication protocols.
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 21 %
       
    20 */
       
    21 
       
    22 
       
    23 #ifndef EAPSESSION_H_
       
    24 #define EAPSESSION_H_
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <e32std.h>
       
    28 #include <ecom.h>
       
    29 #include "EapServerClientDef.h"
       
    30 #include "EapServer.h"
       
    31 #include "EapScheduler.h"
       
    32 #include "eap_am_tools.h"
       
    33 #include "eap_am_types.h"
       
    34 #include "SendPacketHandler.h"
       
    35 #include "EapMessageQueue.h"
       
    36 
       
    37 //----------------------------------------------------------------
       
    38 
       
    39 class MEapolPacketHandler
       
    40     {
       
    41 public:
       
    42     virtual void EapolHandleL(const TDesC8& aData) = 0;
       
    43     };
       
    44 
       
    45 //----------------------------------------------------------------
       
    46 
       
    47 class CSendHandler;
       
    48 class CEapCoreInterfaceImplementation;
       
    49 class CEapClientProcessHandler;
       
    50 
       
    51 //----------------------------------------------------------------
       
    52 
       
    53 class CEapolPacketHandler : public CBase, public MEapolPacketHandler
       
    54     {
       
    55     void EapolHandleL(const TDesC8& aData);
       
    56 private:
       
    57     CEapCoreInterfaceImplementation* iClient;
       
    58     };
       
    59 
       
    60 //----------------------------------------------------------------
       
    61 
       
    62 class EAP_EXPORT REapSession :  public RSessionBase
       
    63     {
       
    64 public:
       
    65 
       
    66     // construct
       
    67     inline REapSession()
       
    68 		: iSendHandler(0)
       
    69 		, iProcessHandler(0)
       
    70 		, iStatus(KErrNone)
       
    71 		, iTools(0)
       
    72 		, iClient(0)
       
    73 		, iEapMessageQueue(0)
       
    74 	{
       
    75 	};
       
    76 
       
    77 	EAP_FUNC_IMPORT virtual ~REapSession();
       
    78 
       
    79 
       
    80 	EAP_FUNC_IMPORT void ConnectL(
       
    81 		abs_eap_am_tools_c * const tools,
       
    82 		MSendPacketHandler * Client,
       
    83 		const TBuf<KMaxServerExe> ServerName,
       
    84 		const TBuf<KMaxServerExe> ServerExe,
       
    85 		const void * const aConfigurationData,
       
    86 		const TInt aConfigurationDataLength,
       
    87 		const TEapRequests aIfRequest);
       
    88 
       
    89     EAP_FUNC_IMPORT void Close();
       
    90 
       
    91     EAP_FUNC_IMPORT bool get_is_valid();
       
    92  
       
    93     /// Function receives the data message from lower layer.
       
    94     /// Data is formatted to Attribute-Value Pairs.
       
    95     /// Look at eap_tlv_header_c and eap_tlv_message_data_c.
       
    96     EAP_FUNC_IMPORT eap_status_e process_data(const TEapRequests aMessageType, const void * const data, const u32_t length);
       
    97 
       
    98 	const EapMessageBuffer * GetFirstMessage();
       
    99 
       
   100 	TInt DeleteFirstMessage();
       
   101 
       
   102 	void Process(const EapMessageBuffer * const buffer, TRequestStatus &aStatus) const;
       
   103 
       
   104 private:
       
   105     /**
       
   106     * Version information.
       
   107     * @return Version information.
       
   108     */
       
   109     TVersion Version() const;
       
   110 
       
   111     friend class CSendHandler;
       
   112 
       
   113     void Receive(TDes8& aBuffer, TRequestStatus& aStatus);
       
   114 
       
   115     void CancelReceive();
       
   116 
       
   117     CSendHandler* iSendHandler;
       
   118 
       
   119 	CEapClientProcessHandler* iProcessHandler;
       
   120 
       
   121     TRequestStatus iStatus;
       
   122 
       
   123     abs_eap_am_tools_c * iTools;
       
   124 
       
   125     MSendPacketHandler* iClient;
       
   126 
       
   127     RProcess iServer;
       
   128 
       
   129 	EapMessageQueue* iEapMessageQueue;
       
   130     };
       
   131 
       
   132 //----------------------------------------------------------------
       
   133 
       
   134 class CSendHandler : public CActive
       
   135     {
       
   136 
       
   137 public:
       
   138     // construct/destruct
       
   139     CSendHandler(
       
   140 		abs_eap_am_tools_c * const tools,
       
   141 		REapSession& aSession); //MEapolPacketHandler& aHandler, 
       
   142 
       
   143     virtual ~CSendHandler();
       
   144 
       
   145     // operation
       
   146     void Receive();
       
   147 
       
   148 private:
       
   149     // from CActive
       
   150     void RunL();
       
   151     void DoCancel();
       
   152 	TInt RunError(TInt aError);
       
   153 
       
   154 
       
   155 private:
       
   156 
       
   157     abs_eap_am_tools_c * iTools;
       
   158 
       
   159     REapSession& iSession;
       
   160 
       
   161     TBuf8<KMaxEapData> iBuffer;
       
   162    
       
   163     };
       
   164 
       
   165 //----------------------------------------------------------------
       
   166 
       
   167 class CEapClientProcessHandler
       
   168 : public CActive
       
   169     {
       
   170 
       
   171 public:
       
   172 
       
   173     CEapClientProcessHandler(
       
   174 		abs_eap_am_tools_c * const tools,
       
   175 		REapSession& aSession);
       
   176 
       
   177     virtual ~CEapClientProcessHandler();
       
   178 
       
   179 	void Activate();
       
   180 
       
   181 private:
       
   182 
       
   183     // from CActive
       
   184     void RunL();
       
   185     void DoCancel();
       
   186 	TInt RunError(TInt aError);
       
   187 
       
   188 
       
   189 private:
       
   190 
       
   191     abs_eap_am_tools_c * iTools;
       
   192 
       
   193     REapSession& iSession;
       
   194 
       
   195 	bool iProcessPending;
       
   196     };
       
   197 
       
   198 //----------------------------------------------------------------
       
   199 
       
   200 #endif /* EAPSESSION_H_ */