rtp/srtpstack/inc/srtppacketrtp.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2004 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:    SRTP packet class (RTP)
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __SRTP_PACKET_RTP_H__
       
    22 #define __SRTP_PACKET_RTP_H__
       
    23 
       
    24 // INCLUDES
       
    25 #include <in_sock.h>
       
    26 #include "srtppacket.h"
       
    27 #include <e32math.h>
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CSRTPCryptoHandler;
       
    31 
       
    32 /**
       
    33 * Contains general RTP-specific packet routines
       
    34 */
       
    35 class CSRTPPacketRTP : public CSRTPPacket
       
    36     {
       
    37     public:
       
    38     	static CSRTPPacketRTP* NewL(const TDesC8& aPacket,
       
    39                       CSRTPCryptoHandler& aHandler);
       
    40                       
       
    41         /**
       
    42         * Get sequence number.
       
    43         * @return 16 bit sequence number.
       
    44         */                              
       
    45         TUint16 SequenceNumber();         
       
    46 
       
    47         /**
       
    48         * Get packet index.
       
    49         * @return TUint64 packet index.
       
    50         */                              
       
    51         TUint64 PacketIndex();
       
    52 
       
    53         /**
       
    54         * Set packet index.
       
    55         * @param aPacketIndex  new packet index
       
    56         * @return void
       
    57         */                              
       
    58         void SetPacketIndex(TUint64 aPacketIndex);
       
    59 
       
    60         /**
       
    61         * Count sender packet index.
       
    62         * @return void
       
    63         */                              
       
    64         void CountSenderPacketIndex();  
       
    65 
       
    66         /**
       
    67         * Create encrypted packet.
       
    68         * @param aEncryptedPayloadPtr  encrypted payload to be copied
       
    69         * @leave KErrNone if success, system-wide error code otherwise        
       
    70         * @return HBufC8* encrypted packet
       
    71         */                              
       
    72         HBufC8* CreateEncryptedPacketL(TUint8* aEncryptedPayloadPtr);
       
    73         
       
    74         /**
       
    75         * virtual function for creating decrypted packet.
       
    76         * @param aDecryptedPayloadPtr  decrypted payload to be copied
       
    77         * @leave KErrNone if success, system-wide error code otherwise        
       
    78         * @return HBufC8* decrypted packet
       
    79         * implemented in CSRTPPacketSRTP.
       
    80         */                              
       
    81         virtual HBufC8* CreateDecryptedPacketL(TUint8* aDecryptedPayloadPtr);
       
    82 
       
    83         /**
       
    84         * virtual function for getting the authentication tag
       
    85         * implemented in CSRTPPacketSRTP.
       
    86         */                              
       
    87         virtual TPtrC8 AuthenticationTag();
       
    88 
       
    89         /**
       
    90         * virtual function for getting the master key identifier
       
    91         * implemented in CSRTPPacketSRTP.
       
    92         */                              
       
    93         virtual TPtrC8 MasterKeyIdentifier();
       
    94         
       
    95 		/*
       
    96         * Update header length member
       
    97         * @leave KErrNone if success, system-wide error code otherwise        
       
    98         * @return void
       
    99         */
       
   100         void UpdateHeaderLengthL();  
       
   101         
       
   102         /**
       
   103         * Get Sender Roll-Over Counter from RTP/SRTP packets defined by RCC mode
       
   104         * @return 32 bit unsigned integer 
       
   105         */                              
       
   106         TUint32 GetSenderROC(); 
       
   107                         
       
   108     protected: //methods        
       
   109         CSRTPPacketRTP (const TDesC8& aPacket,
       
   110                       CSRTPCryptoHandler& aHandler);
       
   111         ~CSRTPPacketRTP(); 
       
   112 
       
   113         /**
       
   114         * Update payload length information
       
   115         * @return void
       
   116         */                              
       
   117         void UpdatePayloadLength();
       
   118         void ConstructL();   
       
   119         
       
   120         TBool TagWithROCLengthL();  
       
   121                 
       
   122     private: //methods
       
   123     
       
   124        /**
       
   125         * Read sequence number and update class member
       
   126         * @return void
       
   127         */                              
       
   128         void UpdateSequenceNumber();    
       
   129                                     
       
   130        /**
       
   131         * Count size of the encrypted packet
       
   132         * @return TUint size of the encrypted packet
       
   133         */                              
       
   134         TUint CountEncryptedPacketSizeL();        
       
   135 
       
   136        /**
       
   137         * Count size of the decrypted packet
       
   138         * @return TUint size of the decrypted packet
       
   139         */                              
       
   140         TUint CountDecryptedPacketSize();                
       
   141             
       
   142     private: //data    
       
   143         TUint16                       iSequenceNumber;   // sequence number
       
   144         TUint64                       iPacketIndex;      // packet index   
       
   145         TUint32 					  iSenderROC; 		 //used in RCC modes       
       
   146      #ifdef EUNIT_TESTING
       
   147         friend class UT_CSRTPCryptoHandlerSRTP;
       
   148         friend class UT_CSRTPCryptoHandler;
       
   149     #endif     
       
   150               
       
   151     };
       
   152 
       
   153 #endif // __SRTP_PACKET_RTP_H__
       
   154