networksecurity/tls/protocol/applicationdata.h
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 /**
       
     2 * Copyright (c) 2003-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 "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:
       
    15 * SSL3.0 and TLS1.0 Application data header file.
       
    16 * This file describes the Application data (transmission and reception)
       
    17 * state machines.
       
    18 * 
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @file ApplicationData.h
       
    26 */
       
    27 
       
    28 #ifndef _APPLICATIONDATA_H_
       
    29 #define _APPLICATIONDATA_H_
       
    30 
       
    31 #include <comms-infras/statemachine.h>
       
    32 #include "LOGFILE.H"
       
    33 #include "tlsconnection.h"
       
    34 
       
    35 class CRecordComposer;
       
    36 class CSendAlert;
       
    37 class CHelloRequest;
       
    38 class CSendAppData : public CStateMachine
       
    39 /** 
       
    40  * Describes a state machine which sends an Application's data to a remote server.
       
    41  */
       
    42 {
       
    43 public:
       
    44 	static CSendAppData* NewL( CRecordComposer& aRecordComposer ); 
       
    45 	~CSendAppData();
       
    46 	void Start( TRequestStatus* aClientStatus, MStateMachineNotify* aStateMachineNotify );
       
    47 
       
    48 	// These are called by CTlsConnection when a re-negotiation request comes through.
       
    49 	void Suspend();
       
    50 	void ResumeL();
       
    51 
       
    52 	void SetUserData( TDesC8* aAppData );
       
    53 	void SetSockXfrLength( TInt* aLen );
       
    54 	CSendAlert* SendAlert() const;
       
    55 
       
    56 	void SetHelloRequest( CHelloRequest* aHelloReq );
       
    57    
       
    58 protected:
       
    59 	CSendAppData( CRecordComposer& aRecordComposer );
       
    60 	void ConstructL( CRecordComposer& aRecordComposer );
       
    61 
       
    62 	virtual void DoCancel();
       
    63 	virtual void OnCompletion();
       
    64 
       
    65 protected:
       
    66 	TDesC8* iAppData;	// Keeps app buffer to send data from during re-negotiation
       
    67 	TInt  iCurrentPos;	// Keeps CRecordComposer::iCurrentPos during re-negotiation
       
    68 	TInt* iSockXfrLength;
       
    69 	CRecordComposer& iRecordComposer;
       
    70 	CSendAlert* iSendAlert;
       
    71 	CHelloRequest* iHelloReq; //to check whether hello req's been received and is waiting for
       
    72 	//a record to be sent to start renegotiation - reference only no ownership
       
    73 };
       
    74 
       
    75 
       
    76 /////////////////////////////////////////////////////////////////////////////////////////////
       
    77 
       
    78 
       
    79 class CRecordParser;
       
    80 class CTlsConnection;
       
    81 class CRecvAppData : public CStateMachine
       
    82 /** 
       
    83  * Describes a state machine which receives data from a 
       
    84  * remote server, intended for an Application using a Secure socket.
       
    85  */
       
    86 {
       
    87 public:
       
    88 	static CRecvAppData* NewL( CTlsConnection& aTlsConnection ); 
       
    89 	~CRecvAppData();
       
    90 	void Start( TRequestStatus* aClientStatus, MStateMachineNotify* aStateMachineNotify );
       
    91 
       
    92 	// These are called by CTlsConnection when a re-negotiation request comes through
       
    93 	void Suspend();
       
    94 	void ResumeL( CTlsConnection& aTlsConnection );
       
    95 
       
    96 	CSendAlert* SendAlert() const;
       
    97 	void SetSockXfrLength( TInt* aLen );
       
    98 
       
    99 	CHelloRequest* HelloRequest() const;
       
   100 
       
   101 protected:
       
   102 	CRecvAppData( CTlsConnection& aTlsConnection );
       
   103 	void ConstructL( CTlsConnection& aTlsConnection );
       
   104 
       
   105 	virtual void DoCancel();
       
   106 	virtual void OnCompletion();
       
   107 
       
   108 protected:
       
   109 	TPtr8 iHeldData;	// Keeps CRecordParser::iHeldData (ptr in CStateMachine::iFragment)
       
   110 						// during re-negotiation (marks a point in CStateMachine::iFragment)
       
   111 	TDes8* iAppData;	// Keeps app buffer to receive data into during re-negotiation
       
   112 	TInt* iSockXfrLength;
       
   113 
       
   114 	CRecordParser& iRecordParser;
       
   115 	CSendAlert* iSendAlert;
       
   116 	CHelloRequest* iHelloReq; //to check whether hello req's been received and is waiting for
       
   117 	//a record to be sent to start renegotiation - reference only no ownership
       
   118 };
       
   119 
       
   120 
       
   121 
       
   122 // Inline methods - CSendAppData class
       
   123 inline void CSendAppData::Start( TRequestStatus* aClientStatus, MStateMachineNotify* aStateMachineNotify )
       
   124 /**
       
   125  * Starts the 'Send Application data' state machine by calling the 
       
   126  * Start() method of the base state machine class (CStateMachine).
       
   127  *
       
   128  * @param aClientStatus Pointer to a TRequestStatus object that completes when  
       
   129  * data transmission is complete.
       
   130  * @param aStateMachineNotify Pointer to a MStateMachineNotify interface object.
       
   131  */
       
   132 {
       
   133 	LOG(Log::Printf(_L("CSendAppData::Start()\n"));)
       
   134 	CStateMachine::Start( aClientStatus, (CAsynchEvent*)(iSendAlert), aStateMachineNotify );
       
   135 }
       
   136 
       
   137 inline CSendAlert* CSendAppData::SendAlert() const
       
   138 {
       
   139 	LOG(Log::Printf(_L("CSendAppData::SendAlert()\n"));)
       
   140 	return iSendAlert;
       
   141 }
       
   142 
       
   143 inline void CSendAppData::SetUserData( TDesC8* aAppData )
       
   144 {
       
   145 	LOG(Log::Printf(_L("CSendAppData::SetUserData()\n"));)
       
   146 	
       
   147 	__ASSERT_DEBUG( iCurrentPos == 0, TlsPanic( ETlsPanicUserDataAlreadySet) );
       
   148 	iAppData = aAppData;
       
   149 }
       
   150 
       
   151 inline void CSendAppData::SetHelloRequest( CHelloRequest* aHelloReq )
       
   152 {
       
   153 	iHelloReq = aHelloReq;
       
   154 }
       
   155 
       
   156 
       
   157 // Inline methods - CRecvAppData class
       
   158 inline void CRecvAppData::Start( TRequestStatus* aClientStatus, MStateMachineNotify* aStateMachineNotify )
       
   159 /**
       
   160  * Starts the 'Receive Application data' state machine by calling the 
       
   161  * Start() method of the base state machine class (CStateMachine).
       
   162  *
       
   163  * @param aClientStatus Pointer to a TRequestStatus object that completes when  
       
   164  * data reception is complete.
       
   165  * @param aStateMachineNotify Pointer to a MStateMachineNotify interface object.
       
   166  */
       
   167 {
       
   168 	LOG(Log::Printf(_L("CRecvAppData::Start()\n"));)
       
   169 	CStateMachine::Start( aClientStatus, (CAsynchEvent*)iSendAlert, aStateMachineNotify );
       
   170 }
       
   171 
       
   172 inline void CRecvAppData::SetSockXfrLength( TInt* aLen )
       
   173 {
       
   174 	LOG(Log::Printf(_L("CRecvAppData::SetSockXfrLength()\n"));)
       
   175 	iSockXfrLength = aLen;
       
   176 }
       
   177 
       
   178 inline CHelloRequest* CRecvAppData::HelloRequest() const
       
   179 {
       
   180 	return iHelloReq;
       
   181 }
       
   182 
       
   183 inline CSendAlert* CRecvAppData::SendAlert() const
       
   184 {
       
   185 	LOG(Log::Printf(_L("CRecvAppData::SendAlert()\n"));)
       
   186 	return iSendAlert;
       
   187 }
       
   188 
       
   189 #endif