networksecurity/tls/protocol/AlertProtocolEvents.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 * Alert protocol messages class header file.
       
    16 * Describes a concrete class for SSL3.0/TLS1.0 Alert Protocol messages (events).
       
    17 * These messages convey the severity of the message and a description of the alert.  
       
    18 * 
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @file AlertProtocolEvents.h
       
    26 */
       
    27  
       
    28 #ifndef _ALERTPROTOCOLEVENTS_H_
       
    29 #define _ALERTPROTOCOLEVENTS_H_
       
    30 
       
    31 #include "tlsevent.h"
       
    32 
       
    33 const TUint8 KAlertMsgLength = 2;	// Length of an Alert message.
       
    34 
       
    35 // Alert level
       
    36 enum ETlsAlertLevel
       
    37 {
       
    38 	EAlertWarning = 1,					/** Warning */
       
    39 	EAlertFatal = 2						/** Fatal alert */
       
    40 };
       
    41 
       
    42 class CRecordComposer;
       
    43 class CStateMachine;
       
    44 class CSendAlert : public CTlsEvent
       
    45 /**
       
    46  * @class This class describes an Alert message sent by the protocol.
       
    47  * @brief This message consists of 2 bytes describing an Alert level and its
       
    48  * description. It is compressed and encrypted under the current connection state.
       
    49  *
       
    50  * Note that Alert messages (sent or received) are not part of the Handshake protocol 
       
    51  * and as such do not derive from the CHandshakeTransmit or CHandshakeReceive classes.
       
    52  */
       
    53 {
       
    54 public:
       
    55    CSendAlert( CStateMachine& aStateMachine, CRecordComposer& aRecordComposer );
       
    56 
       
    57    virtual CAsynchEvent* ProcessL( TRequestStatus& aStatus );
       
    58 
       
    59 private:
       
    60    CRecordComposer& iRecordComposer;
       
    61    TBuf8<KAlertMsgLength> iAlertMsg; //message to send
       
    62 };
       
    63 
       
    64 class CRecordParser;
       
    65 class CRecvAlert : public CTlsEvent
       
    66 /**
       
    67  * @class This class describes an Alert message received by the protocol (i.e., sent 
       
    68  * by the server). 
       
    69  * @brief This message consists of 2 bytes describing an Alert level and its
       
    70  * description. It is decompressed and decrypted under the current connection 
       
    71  * state.
       
    72  */
       
    73 {
       
    74 public:
       
    75    CRecvAlert( CStateMachine& aStateMachine, CRecordParser& aRecordParser, CSendAlert& aSendAlert );
       
    76 
       
    77    virtual TBool AcceptRecord( TInt aRecordType ) const;
       
    78    virtual CAsynchEvent* ProcessL( TRequestStatus& aStatus );
       
    79 public:
       
    80    CRecordParser& iRecordParser;
       
    81    CSendAlert& iSendAlert;
       
    82 };
       
    83 
       
    84 // Inline methods
       
    85 inline CSendAlert::CSendAlert( CStateMachine& aStateMachine, CRecordComposer& aRecordComposer ) :
       
    86    CTlsEvent( NULL, &aStateMachine ),
       
    87    iRecordComposer( aRecordComposer )
       
    88 /**
       
    89  * Constructor
       
    90  */
       
    91 {
       
    92 }
       
    93 
       
    94 inline CRecvAlert::CRecvAlert( CStateMachine& aStateMachine, CRecordParser& aRecordParser, CSendAlert& aSendAlert ) :
       
    95    CTlsEvent( NULL, &aStateMachine ),
       
    96    iRecordParser( aRecordParser ),
       
    97    iSendAlert( aSendAlert )
       
    98 /**
       
    99  * Constructor
       
   100  */
       
   101 {
       
   102 }
       
   103 
       
   104 #endif
       
   105