os/security/contentmgmt/cafstreamingsupport/source/ipsec/ipseckeystreamsink.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2007 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:
    15 *
    16 */
    17 
    18 
    19 /** 
    20 @file
    21 
    22 @internalComponent
    23 @released
    24 */
    25 
    26 #include <caf/streaming/keystreamsink.h>
    27 #include <caf/streaming/keyassociation.h>
    28 
    29 #include <in_sock.h>
    30 #include <lib_pfkey.h>
    31 #include <pfkey_send.h>
    32 #include <ipsecpolapi.h>
    33 
    34 #ifndef __IPSECKEYSTREAMSINK_H__
    35 #define __IPSECKEYSTREAMSINK_H__
    36 
    37 class RDesReadStream;
    38 
    39 namespace StreamAccess
    40 {
    41 	NONSHARABLE_CLASS(CIpSecKeyStreamSink) : public CKeyStreamSink
    42 	{
    43 	public:
    44 		 static CIpSecKeyStreamSink* NewLC(RReadStream& aReadStream);
    45 		 static CIpSecKeyStreamSink* NewLC(const TInetAddr& aSrcAddr, const TInetAddr& aDstAddr);
    46 		 ~CIpSecKeyStreamSink();
    47 		 		 
    48 		 // CKeyStreamSink interface
    49 		 CKeyStreamSink* CloneLC() const;
    50 		 void ProcessNewKeyAssociationL(const CKeyAssociation& aKeyAssociation);
    51 		 void SetEncryptionAlgorithmL(const TEncryptionAlgorithm& aEncryptionAlgorithm);
    52 		 void SetAuthenticationAlgorithmL(const TAuthenticationAlgorithm& aAuthenticationAlgorithm);	 
    53 	protected:
    54 		 void DoExternalizeL(RWriteStream& aStream) const;
    55 	private:
    56 		 void ConstructL();
    57 		 void SetPolicyL();
    58 		 void RemoveSaL(TUint32 aSpi);
    59 		 void SynchronousSendAndVerifyMessageL(TPfkeySendMsg& aMessage, TInt aMessageType, TUint32 aSpi);
    60 		 TBool CompareReceivedMessageExtensionsL(TPfkeyRecvMsg &aReceivedReply, TUint32 aSpi) const;
    61 		 void VerifyAssociationsNotSentL() const;
    62 		 CIpSecKeyStreamSink(const TInetAddr& aSrcAddr, const TInetAddr& aDstAddr);
    63 		 void AddAssociationL(TPfkeySendMsg& aMessage, TUint32 aSpi);
    64 	private:
    65 		 RSocketServ iSocketServ;
    66 		 /** Handle to policy server */
    67 		 RIpsecPolicyServ iPolicyServer;
    68 		 /** Handle to SADB socket */
    69 		 RSADB iSADB;
    70  		 TInetAddr iSourceAddr;
    71 		 TInetAddr iDestinationAddr;
    72 		 TUint8 iAuthAlg;
    73 		 TUint8 iEncAlg;
    74 		 TUint32 iSequenceNumber;
    75 		 /** Signifies whether a security policy has already been set */
    76 		 TBool iPolicySet;
    77 		 TPolicyHandlePckg iPolicyHandle;
    78 		 /** Used for removing old SA-s, managed as a FIFO queue */
    79 		 RArray<TUint32> iSubmittedSpiList; 
    80 		 /** Number of supported concurrent SA-s */
    81 		 TInt iMaxSpiNumber; 
    82 	};
    83 } // namespace StreamAccess
    84 #endif /* __IPSECKEYSTREAMSINK_H__ */
    85 
    86