# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1263842044 -7200 # Node ID ef893827b4d1ddea11ed5a16c0f34e305ae4879d # Parent c9c2ad51f972e6994668637ba8285bbaa77b0408 Revision: 201001 Kit: 201003 diff -r c9c2ad51f972 -r ef893827b4d1 help/inc/vpn.hlp.hrh --- a/help/inc/vpn.hlp.hrh Thu Jan 07 13:26:15 2010 +0200 +++ b/help/inc/vpn.hlp.hrh Mon Jan 18 21:14:04 2010 +0200 @@ -2,9 +2,9 @@ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available -* under the terms of the License "Symbian Foundation License v1.0" +* under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available -* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/ikecert/src/ikepkiutils.cpp --- a/vpnengine/ikecert/src/ikepkiutils.cpp Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/ikecert/src/ikepkiutils.cpp Mon Jan 18 21:14:04 2010 +0200 @@ -219,6 +219,7 @@ } if ( caArray->Count() == 1) { + __ASSERT_DEBUG(firstCertPayload != NULL, User::Invariant()); const TPtrC8 userCertStream(firstCertPayload->Certificate(), (TPayloadIkev2::Cast(firstCertPayload)->GetLength() - TCertPayloadIkev2::Size())); diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/ikev1lib/src/ikev1isakmpstream.cpp --- a/vpnengine/ikev1lib/src/ikev1isakmpstream.cpp Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/ikev1lib/src/ikev1isakmpstream.cpp Mon Jan 18 21:14:04 2010 +0200 @@ -116,7 +116,7 @@ //including the SPI iBuf.SetLength(pos + sizeof(proposal)); //leave room to insert later the proposal TAttrib *attr=prop->iAttrList; - for (TInt i=0; i < proposal.GetNumTrans(); i++) //Adds all the transforms + for (TInt i=0; (i < proposal.GetNumTrans()) && (attr != NULL); i++) //Adds all the transforms { if ( !attr->iNext ) next_payload = ISAKMP_PAYLOAD_NONE; // Last trasnform diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/ikev1lib/src/ikev1negotiation.cpp --- a/vpnengine/ikev1lib/src/ikev1negotiation.cpp Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/ikev1lib/src/ikev1negotiation.cpp Mon Jan 18 21:14:04 2010 +0200 @@ -1039,10 +1039,10 @@ KKmdIkeAuthFailedErr, iPluginSession->VpnIapId(), &iRemoteAddr ); - SendDeleteL(PROTO_ISAKMP); - SetFinished(); - } - } + SendDeleteL( PROTO_ISAKMP ); + SetErrorStatus( KKmdIkeAuthFailedErr ); + } + } } else ret = EFalse; diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/ikev2lib/src/ipsecproposal.cpp --- a/vpnengine/ikev2lib/src/ipsecproposal.cpp Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/ikev2lib/src/ipsecproposal.cpp Mon Jan 18 21:14:04 2010 +0200 @@ -128,9 +128,14 @@ if ( IntegAlg ) { TransCnt ++; - if ( Transform ) - Transform = (TTransformIkev2*)TPayloadIkev2::Cast(Transform)->Next(); - else Proposal->TransformPl(); + if ( Transform ) + { + Transform = (TTransformIkev2*)TPayloadIkev2::Cast(Transform)->Next(); + } + else + { + Transform = Proposal->TransformPl(); + } TPayloadIkev2::Cast(Transform)->Init(); // Initialize Payload general header TPayloadIkev2::Cast(Transform)->SetNextPayload(IKEV2_PAYLOAD_TRANS); Transform->SetType(IKEV2_INTEG); // Integrity Algorithm transform @@ -257,6 +262,7 @@ break; default: + User::Leave(KErrNotSupported); break; } diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/pkiservice/src/pkimapper.cpp --- a/vpnengine/pkiservice/src/pkimapper.cpp Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/pkiservice/src/pkimapper.cpp Mon Jan 18 21:14:04 2010 +0200 @@ -147,7 +147,7 @@ TCertificateListEntry& aResultCertInfo) { TInt index; - TInt err; + TInt err = KErrNone; TRAPD(leave, err = ResolveCertMappingL(aSecDesc, iObjectName, index, aInfoOnly, diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/vpnconnagt/inc/vpnconnagt.h --- a/vpnengine/vpnconnagt/inc/vpnconnagt.h Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/vpnconnagt/inc/vpnconnagt.h Mon Jan 18 21:14:04 2010 +0200 @@ -12,749 +12,343 @@ * Contributors: * * Description: VPN Connection Agent declaration. - * */ - - - - /** - * @file vpnconnagt.h - - * - - * VPN Connection Agent declaration. - * - + * VPN Connection Agent declaration. + * */ - - - - - #if !defined __VPN_CONN_AGT_H__ - #define __VPN_CONN_AGT_H__ - - // INCLUDES - #include - - #include "eventmediatorapi.h" - - - #include "vpnconnagtprog.h" - #include "vpnconnagtdefs.h" - #include "eventdefssit.h" - #include "log_r6.h" - - // CONSTANTS - const TInt KMajorVerNumber=1; - const TInt KMinorVerNumber=0; - const TInt KBuildVerNumber=0; - - _LIT(KVPNConnAgtName,"vpnconnagt"); - +/** + * A Factory for creating a VPNConnAgent. + */ +class CVPNConnAgtFactory : public CNifAgentFactory + { + /** + @internalComponent + */ + protected: // Methods + /** + * "Installs" this factory to the system. From this Agent point of view + * it doesn't do anything... + */ + void InstallL(); -class CAsyncDisconnecter; + /** + * Creates a new VPN Agent instance. + * @param aName Not used. + * @return Returns the pointer to the agent created if succeed. Otherwise it + * leaves. + */ + CNifAgentBase *NewAgentL(const TDesC& aName); - + /** + * Returns the information defined in TNifAgentInfo. + * @param aInfo The reference to the TNifAgentInfo object to be used to pass + * the needed information. + * @param aIndex Not used. + */ + TInt Info(TNifAgentInfo& aInfo, TInt aIndex) const; + }; /** - - * A Factory for creating a VPNConnAgent. + * Class declaration for VPN connection agent. Each agent reference + * has it's own instance of agent and nif. Nif sends it's name via + * agent reference to agent. This triggers agent to initialize the VPN connection + * through the VPN Manager Server. After VPN tunnel has been created + * agent sends the IP address and the DNS addresses to the nif which + * in turn informs the Nifman and IP stack that the connection has + * been created. + */ +class CVPNConnAgt : public CAgentBase, public MEventObserver + { + /** + @internalComponent + */ + friend class CAsyncDisconnecter; + public: // Methods + /** + * Static constructor. + * @return The return value is the pointer to the CVPNConnAgt + * if it succeed. Otherwise the fuction leaves. + */ + static CVPNConnAgt* NewL(); - */ + /** + * Default C++ destructor. + * Cancels all the Callbacks. + */ + virtual ~CVPNConnAgt(); + + // from CNifAgentBase + /** + * Returns the information defined in TNifAgentInfo. + * @param aInfo A reference to TNifAgentInfo object which is + * used to pass the information to caller of this function. + */ + void Info(TNifAgentInfo& aInfo) const; -class CVPNConnAgtFactory : public CNifAgentFactory + /** + * Starts the connection creation process. + * @param aType Not used. + */ + void Connect(TAgentConnectType aType); + + /** + * Starts the connection by calling Connect(TAgentConnectType aType). + * @param aType Type of the connection e.g. EAgentReconnect. + * @param aOverrideSettings Not used. + */ + void Connect(TAgentConnectType aType, CStoreableOverrideSettings* aOverrideSettings); + + /** + * Starts the cancellation of the connect. + */ + void CancelConnect(); + + /** + * Disconnects an ongoing connection. + * @param aReason Not used. + */ + void Disconnect(TInt aReason); - { + /** + * Called after Connect() in connection creation phase. Connection configuration + * parameters are read and request for the VPNManServer to open the connection + * is done. During the execution of this function VPN Nif is created. + * @param aError Not used. + */ + void ServiceStarted(TInt& aError); - /** + /** + * The addresses got from the VPN Manager Server are send to VPN Nif. + * Nifman is informed with the progress call (with parameter EVPNConnAgtConnected). + * MNifAgentNotify interface's ConnectComplete() is called (this generates the Start() + * call to VPN Nif. + * @param aError Not used. + */ + void ConnectionComplete(TInt aError); + + /** + * Causes the deactivationing/unloading of the VPN Policies. + */ + void DisconnectionComplete(); + + /** + * Not Supported. + * @param aBuffer Not used. + * @return Always returns KErrNotSupported. + */ + TInt GetExcessData(TDes8& aBuffer); - @internalComponent + /** + * Used to deliver the name of the VPN Nif to the VPN Agent. + * @param aEvent If the value of this is ENifToVPNAgentEventTypeIfName the name of the + * VPN Nif is copied from the aInfo parameter. + * @param aInfo TName type pointer containing the name of the VPN NIf (if aEvent value is + * ENifToVPNAgentEventTypeIfName). + * @return Returns KErrNone if the fuction is used to deliver the name of the VPN Nif, + * otherwise it returns KErrNotSupported. + */ + TInt Notification(TNifToAgentEventType aEvent, TAny* aInfo); + + /** + * Passes the last error code to the caller. + * @param aError Reference to the TInt type error code. + */ + void GetLastError(TInt& aError); - */ + /** + * + */ + TBool IsReconnect() const {return (ETrue);}; + + /** + * Not supported. + */ + TInt IncomingConnectionReceived(); + + /** + * Is called when an event comes from real interface via event mediator. + * @param aStatus Error code if the call fails. KErrNone if everything succees. + * @param aType Type pf the event e.g. ESingleInterfaceEvent. + * @param aData Pointer to the TInterfaceNotificationBuf type packaged buffer. Contains + * the status of the real interface. + */ + void EventOccured(TInt aStatus, TEventType aType, TDesC8* aData); protected: // Methods - - /** - - * "Installs" this factory to the system. From this Agent point of view - - * it doesn't do anything... - - */ - - void InstallL(); - - - - /** - - * Creates a new VPN Agent instance. - - * @param aName Not used. - - * @return Returns the pointer to the agent created if succeed. Otherwise it - - * leaves. - - */ - - CNifAgentBase *NewAgentL(const TDesC& aName); - - - - /** - - * Returns the information defined in TNifAgentInfo. - - * @param aInfo The reference to the TNifAgentInfo object to be used to pass - - * the needed information. - - * @param aIndex Not used. - - */ - - TInt Info(TNifAgentInfo& aInfo, TInt aIndex) const; - - }; - - - - - -/** - - * Class declaration for VPN connection agent. Each agent reference - - * has it's own instance of agent and nif. Nif sends it's name via - - * agent reference to agent. This triggers agent to initialize the VPN connection - - * through the VPN Manager Server. After VPN tunnel has been created - - * agent sends the IP address and the DNS addresses to the nif which - - * in turn informs the Nifman and IP stack that the connection has - - * been created. - - */ - -class CVPNConnAgt : public CAgentBase, public MEventObserver - - { - - /** - - @internalComponent - - */ - - friend class CAsyncDisconnecter; - - public: // Methods - - - - /** - - * Static constructor. - - * @return The return value is the pointer to the CVPNConnAgt - - * if it succeed. Otherwise the fuction leaves. - - */ - - static CVPNConnAgt* NewL(); - - - - /** - - * Default C++ destructor. - - * Cancels all the Callbacks. - - */ - - virtual ~CVPNConnAgt(); - - - - // from CNifAgentBase - - /** - - * Returns the information defined in TNifAgentInfo. - - * @param aInfo A reference to TNifAgentInfo object which is - - * used to pass the information to caller of this function. - - */ - - void Info(TNifAgentInfo& aInfo) const; - - - - /** - - * Starts the connection creation process. - - * @param aType Not used. - - */ - - void Connect(TAgentConnectType aType); - - - - /** - - * Starts the connection by calling Connect(TAgentConnectType aType). - - * @param aType Type of the connection e.g. EAgentReconnect. - - * @param aOverrideSettings Not used. - - */ - - void Connect(TAgentConnectType aType, CStoreableOverrideSettings* aOverrideSettings); - - - - /** - - * Starts the cancellation of the connect. - + * Overwrites the default implementation to catch the ip version reading from the + * database. This value is retrieved from the VPN Manager Server. + * @param aField Colum name in the CommDb. Ip version colum name is SERVICE_IF_NETWORKS. + * @param aValue Value to be returned. In SERVICE_IF_NETWORKS case it's ip or ip6. + * @param aMessage Message to validate capabilities + * @return Returns KErrNone if the function succeed. Otherwise it returns system wide + * error code. */ - - void CancelConnect(); - - - - /** - - * Disconnects an ongoing connection. - - * @param aReason Not used. - - */ - - void Disconnect(TInt aReason); - - - - /** - - * Called after Connect() in connection creation phase. Connection configuration - - * parameters are read and request for the VPNManServer to open the connection - - * is done. During the execution of this function VPN Nif is created. - - * @param aError Not used. - - */ - - void ServiceStarted(TInt& aError); - - - - /** - - * The addresses got from the VPN Manager Server are send to VPN Nif. - - * Nifman is informed with the progress call (with parameter EVPNConnAgtConnected). - - * MNifAgentNotify interface's ConnectComplete() is called (this generates the Start() - - * call to VPN Nif. - - * @param aError Not used. - - */ - - void ConnectionComplete(TInt aError); - - - - /** - - * Causes the deactivationing/unloading of the VPN Policies. - - */ - - void DisconnectionComplete(); - - - - /** - - * Not Supported. - - * @param aBuffer Not used. - - * @return Always returns KErrNotSupported. - - */ - - TInt GetExcessData(TDes8& aBuffer); - - - - /** - - * Used to deliver the name of the VPN Nif to the VPN Agent. - - * @param aEvent If the value of this is ENifToVPNAgentEventTypeIfName the name of the - - * VPN Nif is copied from the aInfo parameter. - - * @param aInfo TName type pointer containing the name of the VPN NIf (if aEvent value is - - * ENifToVPNAgentEventTypeIfName). - - * @return Returns KErrNone if the fuction is used to deliver the name of the VPN Nif, - - * otherwise it returns KErrNotSupported. - - */ - - TInt Notification(TNifToAgentEventType aEvent, TAny* aInfo); - - - - /** - - * Passes the last error code to the caller. - - * @param aError Reference to the TInt type error code. - - */ - - void GetLastError(TInt& aError); - - - - /** - - * - - */ - - TBool IsReconnect() const {return (ETrue);}; - - - - /** - - * Not supported. - - */ - - TInt IncomingConnectionReceived(); - - - - /** - - * Is called when an event comes from real interface via event mediator. - - * @param aStatus Error code if the call fails. KErrNone if everything succees. - - * @param aType Type pf the event e.g. ESingleInterfaceEvent. - - * @param aData Pointer to the TInterfaceNotificationBuf type packaged buffer. Contains - - * the status of the real interface. - - */ - - void EventOccured(TInt aStatus, TEventType aType, TDesC8* aData); - - - - protected: // Methods - - - - /** - - * Overwrites the default implementation to catch the ip version reading from the - - * database. This value is retrieved from the VPN Manager Server. - - * @param aField Colum name in the CommDb. Ip version colum name is SERVICE_IF_NETWORKS. - - * @param aValue Value to be returned. In SERVICE_IF_NETWORKS case it's ip or ip6. - - * @param aMessage Message to validate capabilities - - * @return Returns KErrNone if the function succeed. Otherwise it returns system wide - - * error code. - - */ - TInt DoReadDes(const TDesC& aField, TDes16& aValue, const RMessagePtr2* aMessage ); - - - - /** - * Returns the pointer to the parameter object defined in vpnconnagtdefs.h. - * @return The pointer to the connection parameter object. - */ - TVPNParameters* VPNParameters() { return &iVPNParameters; }; - - - /** - - * Returns the pointer to the name of the VPN Nif sent by the nif itself. - - * @return The pointer to the TName type object containing the name of the - - * VPN Nif. - - */ - - TName* VPNNifName(void){ return iVPNParameters.GetVPNNifName();}; - - - /** - - * Returns the pointer to the interface from the Agent to Nifman. This interface - - * is used to e.g. send progress notifications from Agent to Nifman. - - * @return The pointer to the interface from the Agent to Nifman. - + * Returns the pointer to the name of the VPN Nif sent by the nif itself. + * @return The pointer to the TName type object containing the name of the + * VPN Nif. */ - - MNifAgentNotify* Notify() { return iNotify; }; - - - - /** - - * After deactivationing/unloading of the VPN Policies Nifman is informed with the - - * progress call (with EVPNConnAgtDisconnected). - - * MNifAgentNotify interface's DisconnectComplete() is called (this generates the deletion - - * of the VPN Nif and at the end deletion of the agent. - - * - - */ - - void VPNDisconnCompleted(TInt aError); - - - - private: // Methods - - - - /** - - * Second phase constructor. - - */ - - void ConstructL(); - - + TName* VPNNifName(void){ return iVPNParameters.GetVPNNifName();}; /** - - * Default constructor. - - */ - - CVPNConnAgt(); - - - - /** - - * CallBack to start the service (means the connection creation). - - * @param aThisPtr Pointer to the CVPNConnAgt type object. - - * @return Always returns KErrNone. - + * Returns the pointer to the interface from the Agent to Nifman. This interface + * is used to e.g. send progress notifications from Agent to Nifman. + * @return The pointer to the interface from the Agent to Nifman. */ - - static TInt ServiceStartedCb(TAny* aThisPtr); - - - + MNifAgentNotify* Notify() { return iNotify; }; + /** - - * CallBack to complete the connection. + * After deactivationing/unloading of the VPN Policies Nifman is informed with the + * progress call (with EVPNConnAgtDisconnected). + * MNifAgentNotify interface's DisconnectComplete() is called (this generates the deletion + * of the VPN Nif and at the end deletion of the agent. + * + */ + void VPNDisconnCompleted(TInt aError); - * @param aThisPtr Pointer to the CVPNConnAgt type object. - - * @return Always returns KErrNone. - + private: // Methods + /** + * Second phase constructor. */ - - static TInt ConnectCompleteCb(TAny* aThisPtr); - - + void ConstructL(); /** - - * CallBack to disconnect. + * Default constructor. + */ + CVPNConnAgt(); + /** + * CallBack to start the service (means the connection creation). * @param aThisPtr Pointer to the CVPNConnAgt type object. - * @return Always returns KErrNone. - */ - - static TInt DisconnectCompleteCb(TAny* aThisPtr); - - + static TInt ServiceStartedCb(TAny* aThisPtr); /** - - * Reads needed configuration settings from the CommDb database. - + * CallBack to complete the connection. + * @param aThisPtr Pointer to the CVPNConnAgt type object. + * @return Always returns KErrNone. */ - - void ReadConfigurationL(); - - + static TInt ConnectCompleteCb(TAny* aThisPtr); /** - - * Starts the listening of real interface events. - + * CallBack to disconnect. + * @param aThisPtr Pointer to the CVPNConnAgt type object. + * @return Always returns KErrNone. */ - - void ListenRealIAP(); - - + static TInt DisconnectCompleteCb(TAny* aThisPtr); /** - - * Starts the listening of virtual nif address change event. - + * Reads needed configuration settings from the CommDb database. */ - - void ListenAddressChange(); - - + void ReadConfigurationL(); /** - - * Cancels the listening of the real interface events and the - - * listening of virtual nif address change event. - + * Starts the listening of real interface events. */ + void ListenRealIAP(); - void CancelListeners(); - - - - - - private: - - + /** + * Starts the listening of virtual nif address change event. + */ + void ListenAddressChange(); /** - - * Defines the internal states. - + * Cancels the listening of the real interface events and the + * listening of virtual nif address change event. */ - - enum TRequestState - - { - - EGettingProtocolVersion, - - EConnecting, - - EConnected, + void CancelListeners(); + private: + /** + * Defines the internal states. + */ + enum TRequestState + { + EGettingProtocolVersion, + EConnecting, + EConnected, EClosingConnection, - EConnectionClosed, - EStartingRealIf, - EListeningEvents, - EIdle - }; - - - - /** CallBack object to implement ServiceStarted asynchronously. */ - CAsyncCallBack iServiceStartedCallback; - - /** CallBack object to implement ConnectCompleted asynchronously. */ - CAsyncCallBack iConnectCompleteCallback; - - /** CallBack object to implement Disconnect asynchronously. */ - CAsyncCallBack iDisconnectCallback; - - /** Defines wether Agent is connected (Connection completed successfully). */ - TBool iConnected; - - /** Connection configuration parameter member object. See vpnconnagtdefs.h. */ - TVPNParameters iVPNParameters; - - /** An integer to keep last error code in memory. */ - TInt iLastErrorCode; - - /** An API to EventMediator */ - REventMediator iEventMediator; - - /** Tells if vpnconnagt must close tunnelnif */ - TBool iEventActivatedClose; - - /** This defines the shutdown type to the kmd. Value 0 is normal and 1 is to - force it to shutdown without trying to send any packets anymore */ - TDeactivateType iDisconnectType; - - /* State of the agent object */ - TRequestState iState; - - /** Boolean to define wether disconnecting operation is ongoing */ - TBool iDisconnecting; - - /** PckgBufs used when creating connection through eventmediator api */ - TPckgBuf iProtocolVersionDes; - TPckgBuf iStartVpnConnDes; - TPckgBuf iCloseVpnConnDes; - TPckgBuf iObserveRealIapConnDes; - - - - /** Poiter to an object which confirms disconnect operation to Nifman */ - - CAsyncDisconnecter* iAD; - }; - - -class CAsyncDisconnecter : public CAsyncOneShot - - { - - /** - - @internalComponent - - */ - - public: - - static CAsyncDisconnecter* NewL(CVPNConnAgt* aAgent); - - void ConfirmDisconnect(); - - - - private: - - CAsyncDisconnecter(CVPNConnAgt* aAgent); - - void RunL(); // From CAsyncOneShot - - - - private: - - CVPNConnAgt* iAgent; - - }; - - - #endif // VPN_CONN_AGT_H diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/vpnconnagt/src/vpnconnagt.cpp --- a/vpnengine/vpnconnagt/src/vpnconnagt.cpp Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/vpnconnagt/src/vpnconnagt.cpp Mon Jan 18 21:14:04 2010 +0200 @@ -93,8 +93,6 @@ iServiceStartedCallback.Cancel(); iConnectCompleteCallback.Cancel(); iDisconnectCallback.Cancel(); - - delete iAD; } // --------------------------------------------------------------------------- @@ -123,8 +121,6 @@ iDisconnecting = EFalse; LOG_("CVPNConnAgt::ReadConfigurationL EventMediator"); User::LeaveIfError(iEventMediator.Connect()); - - iAD = CAsyncDisconnecter::NewL(this); } // --------------------------------------------------------------------------- @@ -412,7 +408,8 @@ return; } - iAD->ConfirmDisconnect(); + iNotify->AgentProgress(EVPNConnAgtDisconnected, KErrNone); + iNotify->DisconnectComplete(); iDisconnecting = EFalse; } @@ -514,10 +511,11 @@ iEventActivatedClose = EFalse; iNotify->Notification(EAgentToNifEventTypeDisableConnection, NULL); } - - iAD->ConfirmDisconnect(); + + iNotify->AgentProgress(EVPNConnAgtDisconnected, KErrNone); + iNotify->DisconnectComplete(); + iDisconnecting = EFalse; - iConnected = EFalse; iState = EIdle; @@ -585,6 +583,7 @@ break; } default: + LOG(Log::Printf(_L("Unknown event --> Silently Ignore.\n"))); break; } } @@ -758,48 +757,3 @@ LOG_1("CVPNConnAgt::ReadConfigurationL RealNetworkId:%d", iVPNParameters.GetRealNetworkId()); } - - -//////////////////////CAsyncDisconnecter//////////////////// - -// --------------------------------------------------------------------------- -// CAsyncDisconnecter -// --------------------------------------------------------------------------- -// -CAsyncDisconnecter::CAsyncDisconnecter( - CVPNConnAgt* aAgent): - CAsyncOneShot(EPriorityNormal) - { - iAgent = aAgent; - } - -// --------------------------------------------------------------------------- -// NewL -// --------------------------------------------------------------------------- -// -CAsyncDisconnecter* CAsyncDisconnecter::NewL( - CVPNConnAgt* aAgent) - { - return new (ELeave) CAsyncDisconnecter(aAgent); - } - -// --------------------------------------------------------------------------- -// ConfirmDisconnect -// --------------------------------------------------------------------------- -// -void CAsyncDisconnecter::ConfirmDisconnect() - { - Call(); - } - -// --------------------------------------------------------------------------- -// RunL -// --------------------------------------------------------------------------- -// -void CAsyncDisconnecter::RunL() - { - LOG_1("CAsyncDisconnecter::RunL, iStatus:%d", iStatus.Int() ); - iAgent->Notify()->AgentProgress(EVPNConnAgtDisconnected, KErrNone); - iAgent->Notify()->DisconnectComplete(); - } - diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/vpnmanager/group/vpnmanager.mmp --- a/vpnengine/vpnmanager/group/vpnmanager.mmp Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/vpnmanager/group/vpnmanager.mmp Mon Jan 18 21:14:04 2010 +0200 @@ -36,7 +36,6 @@ SOURCE vpnmanagersession.cpp SOURCE vpnmanagerstarter.cpp SOURCE uuid.cpp -SOURCE requestdispatcher.cpp SOURCE eventlogger.cpp SOURCE vpnmanagerserver.cpp SOURCE cmmanagerutils.cpp diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/vpnmanager/group/vpnmanager_test.mmp --- a/vpnengine/vpnmanager/group/vpnmanager_test.mmp Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/vpnmanager/group/vpnmanager_test.mmp Mon Jan 18 21:14:04 2010 +0200 @@ -38,7 +38,6 @@ SOURCE vpnmanagersession.cpp SOURCE vpnmanagerstarter.cpp SOURCE uuid.cpp -SOURCE requestdispatcher.cpp SOURCE eventlogger.cpp SOURCE vpnmanagerserver.cpp SOURCE cmmanagerutils.cpp diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/vpnmanager/inc/requestdispatcher.h --- a/vpnengine/vpnmanager/inc/requestdispatcher.h Thu Jan 07 13:26:15 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* -* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Dispatches requests from clients to CVpnApiServant. -* -*/ - -#ifndef __REQUESTDISPATCHER_H__ -#define __REQUESTDISPATCHER_H__ - -#include - -class RFs; -class CVpnApiServant; - - -/** - * Server-level request dispatcher. - * Dispatches the requests received from VPN Manager - * client to the actual request servants that operate - * at the server level (of which there is only one - * instance). - */ -class CRequestDispatcher : public CBase - { -public: - static CRequestDispatcher* NewL(RFs& aFs); - ~CRequestDispatcher(); - - TBool ServiceL(const RMessage2& aMessage, CSession2* aSession); - -private: - CRequestDispatcher(RFs& aFs); - void ConstructL(); - -public: - CVpnApiServant* iVpnApiServant; - RFs& iFs; - }; - - -#endif // __REQUESTDISPATCHER_H__ diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/vpnmanager/inc/vpnmanagerserver.h --- a/vpnengine/vpnmanager/inc/vpnmanagerserver.h Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/vpnmanager/inc/vpnmanagerserver.h Mon Jan 18 21:14:04 2010 +0200 @@ -26,7 +26,7 @@ #include #include "vpnmanagerserverdefs.h" -class CRequestDispatcher; +class CVpnApiServant; /** * The main server class @@ -107,7 +107,7 @@ TInt iSessionCount; /** The handler of client requests */ - CRequestDispatcher* iRequestDispatcher; + CVpnApiServant* iVpnApiServant; /** The common file server session used throughout the VPN Manager */ RFs iFs; diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/vpnmanager/inc/vpnmanagersession.h --- a/vpnengine/vpnmanager/inc/vpnmanagersession.h Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/vpnmanager/inc/vpnmanagersession.h Mon Jan 18 21:14:04 2010 +0200 @@ -23,8 +23,8 @@ #include class CVpnManagerServer; -class CRequestDispatcher; - +class CVpnApiServant; + /** * A handler for the service requests received from clients. * An instance of class CVpnManagerSession is created for each client. @@ -42,7 +42,7 @@ * @result Pointer to the new session */ static CVpnManagerSession* NewL(CVpnManagerServer& aServer, - CRequestDispatcher& aRequestDispatcher); + CVpnApiServant& aVpnApiServant); /** * Creates a CVpnManagerSession object using two phase construction, * and returns a pointer to the created object @@ -54,7 +54,7 @@ * @result Pointer to the new session */ static CVpnManagerSession* NewLC(CVpnManagerServer& aServer, - CRequestDispatcher& aRequestDispatcher); + CVpnApiServant& aVpnApiServant); /** * Destroy the object and release all memory objects @@ -78,7 +78,7 @@ * @param The server */ CVpnManagerSession(CVpnManagerServer& aServer, - CRequestDispatcher& aRequestDispatcher); + CVpnApiServant& aVpnApiServant); /** * The second phase of two phase construction @@ -88,7 +88,7 @@ private: RMessage2 iMessage; CVpnManagerServer& iServer; - CRequestDispatcher& iRequestDispatcher; + CVpnApiServant& iVpnApiServant; }; #endif // __VPNMANAGERSESSION_H__ diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/vpnmanager/src/policyimporter.cpp --- a/vpnengine/vpnmanager/src/policyimporter.cpp Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/vpnmanager/src/policyimporter.cpp Mon Jan 18 21:14:04 2010 +0200 @@ -92,6 +92,10 @@ { CActiveScheduler::Add(this); User::LeaveIfError(iPkiService.Connect()); + + //Policy importer allow installation of + //future and expired certificates. + iPkiService.SetInformational(ETrue); } CPolicyImporter::~CPolicyImporter() diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/vpnmanager/src/policypatcher.cpp --- a/vpnengine/vpnmanager/src/policypatcher.cpp Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/vpnmanager/src/policypatcher.cpp Mon Jan 18 21:14:04 2010 +0200 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2003-2008 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -402,8 +402,11 @@ //Checking also last attribute of Subject Name string if ( jAppendL(equalSignArr->At(equalArrItemCount-1)); - updateArr->AppendL(subjLth-1); + updateArr->AppendL(equalSignArr->At(equalArrItemCount-1) + 1); + updateArr->AppendL(subjLth); + + updateArrCount++; + updateArrCount++; } TBuf8<256> resultBuf; @@ -416,10 +419,6 @@ { while (i updateStr(KReplacementChar); - - updateStr.Append(aSubj.Mid(updateArr->At(i),1)); - if ( resultBuf.Length()<256 ) resultBuf.Insert(updateArr->At(i) + i, KReplacementChar); else diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/vpnmanager/src/requestdispatcher.cpp --- a/vpnengine/vpnmanager/src/requestdispatcher.cpp Thu Jan 07 13:26:15 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* -* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Dispatches requests from clients (API) to CVpnApiServant. -* -*/ - -#include "requestdispatcher.h" -#include "vpnapiservant.h" - - -CRequestDispatcher* CRequestDispatcher::NewL(RFs& aFs) - { - CRequestDispatcher* self = new (ELeave) CRequestDispatcher(aFs); - CleanupStack::PushL(self) ; - self->ConstructL() ; - CleanupStack::Pop(self); - return self ; - } - -void CRequestDispatcher::ConstructL() - { - iVpnApiServant = CVpnApiServant::NewL(iFs); - } - -CRequestDispatcher::CRequestDispatcher(RFs& aFs) - : iFs(aFs) - { - } - -CRequestDispatcher::~CRequestDispatcher() - { - delete iVpnApiServant; - } - -TBool CRequestDispatcher::ServiceL(const RMessage2& aMessage, CSession2* /*aSession*/) - { - TBool requestHandled = EFalse; - - requestHandled = iVpnApiServant->ServiceL(aMessage); - - if (!requestHandled) - { - User::Leave(KErrNotSupported); - } - - return requestHandled; - } diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/vpnmanager/src/vpnapiservant.cpp --- a/vpnengine/vpnmanager/src/vpnapiservant.cpp Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/vpnmanager/src/vpnapiservant.cpp Mon Jan 18 21:14:04 2010 +0200 @@ -381,15 +381,55 @@ // Read policy data TInt len = aMessage.GetDesLength(SECOND_ARGUMENT); - HBufC8* policyData = HBufC8::NewL(len); - CleanupStack::PushL(policyData); - + HBufC8* policyData = HBufC8::NewLC(len); TPtr8 ptrPolicyData = policyData->Des(); aMessage.ReadL(SECOND_ARGUMENT, ptrPolicyData); + //Make a validy check to the policy data + //by parsing it and checking certificate formats + HBufC* policyData16 = HBufC::NewLC(policyData->Length()); + policyData16->Des().Copy(*policyData); + + CIkeDataArray* ikeDataArray = CIkeDataArray::NewL(1); + CleanupStack::PushL(ikeDataArray); + + TIkeParser* ikeParser = new (ELeave) TIkeParser(*policyData16); + CleanupStack::PushL(ikeParser); + ikeParser->ParseIKESectionsL(ikeDataArray); + for (TInt i = 0; i < ikeDataArray->Count(); ++i) + { + const CIkeData* ikeData = ikeDataArray->At(i); + if (ikeData->iCAList != NULL) + { + for (TInt j = 0; j < ikeData->iCAList->Count(); j++) + { + if (ikeData->iCAList->At(j)->iFormat == BIN_CERT) + { + LOG(Log::Printf(_L("Policy contains BIN certificates --> Failing"))); + //Ca cert in wrong format --> Error + User::Leave(KVpnErrInvalidPolicyFile); + } + } + } + if ((ikeData->iOwnCert.iData.Length() > 0 && + ikeData->iOwnCert.iFormat == BIN_CERT) || + (ikeData->iPrivKey.iData.Length() > 0 && + ikeData->iPrivKey.iFormat == BIN_CERT) || + (ikeData->iPeerCert.iData.Length() > 0 && + ikeData->iPeerCert.iFormat == BIN_CERT)) + { + LOG(Log::Printf(_L("Policy contains BIN certificates --> Failing"))); + //Key or user cert in wrong format + User::Leave(KVpnErrInvalidPolicyFile); + } + } + + CleanupStack::PopAndDestroy(); //ikeParser + CleanupStack::PopAndDestroy(ikeDataArray); + CleanupStack::PopAndDestroy(policyData16); + LOG(Log::Printf(_L("Calling: iPolicyStore->AddNewPolicyL"))); - // Add the policy to the policy store TRAPD(err, iPolicyStore->AddNewPolicyL(*policyDetails, *policyData)); if (err == KErrNone) { diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/vpnmanager/src/vpnmanagerserver.cpp --- a/vpnengine/vpnmanager/src/vpnmanagerserver.cpp Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/vpnmanager/src/vpnmanagerserver.cpp Mon Jan 18 21:14:04 2010 +0200 @@ -21,7 +21,7 @@ #include "vpnmanagerserver.h" #include "vpnmanagersession.h" -#include "requestdispatcher.h" +#include "vpnapiservant.h" const TUint CVpnManagerServer::iVpnManRangeCount = 3; @@ -60,7 +60,7 @@ CVpnManagerServer::~CVpnManagerServer() { - delete iRequestDispatcher; + delete iVpnApiServant; iFs.Close(); } @@ -83,7 +83,7 @@ { User::LeaveIfError(iFs.Connect()); User::LeaveIfError(iFs.CreatePrivatePath(EDriveC)); - iRequestDispatcher = CRequestDispatcher::NewL(iFs); + iVpnApiServant = CVpnApiServant::NewL(iFs); StartL(KVpnManagerServer); } @@ -102,7 +102,7 @@ // Make new session return CVpnManagerSession::NewL(*const_cast(this), - *iRequestDispatcher); + *iVpnApiServant); } void CVpnManagerServer::IncrementSessions() diff -r c9c2ad51f972 -r ef893827b4d1 vpnengine/vpnmanager/src/vpnmanagersession.cpp --- a/vpnengine/vpnmanager/src/vpnmanagersession.cpp Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnengine/vpnmanager/src/vpnmanagersession.cpp Mon Jan 18 21:14:04 2010 +0200 @@ -20,29 +20,29 @@ #include "vpnmanagerserver.h" #include "vpnmanagerserverdefs.h" #include "vpnmanagersession.h" -#include "requestdispatcher.h" +#include "vpnapiservant.h" #include CVpnManagerSession* CVpnManagerSession::NewL(CVpnManagerServer& aServer, - CRequestDispatcher& aRequestDispatcher) + CVpnApiServant& aVpnApiServant) { - CVpnManagerSession* self = CVpnManagerSession::NewLC(aServer, aRequestDispatcher); + CVpnManagerSession* self = CVpnManagerSession::NewLC(aServer, aVpnApiServant); CleanupStack::Pop(self); return self; } CVpnManagerSession* CVpnManagerSession::NewLC(CVpnManagerServer& aServer, - CRequestDispatcher& aRequestDispatcher) + CVpnApiServant& aVpnApiServant) { - CVpnManagerSession* self = new (ELeave) CVpnManagerSession(aServer, aRequestDispatcher); + CVpnManagerSession* self = new (ELeave) CVpnManagerSession(aServer, aVpnApiServant); CleanupStack::PushL(self) ; self->ConstructL() ; return self ; } CVpnManagerSession::CVpnManagerSession(CVpnManagerServer& aServer, - CRequestDispatcher& aRequestDispatcher) - : iServer(aServer), iRequestDispatcher(aRequestDispatcher) + CVpnApiServant& aVpnApiServant) + : iServer(aServer), iVpnApiServant(aVpnApiServant) { } @@ -58,5 +58,5 @@ void CVpnManagerSession::ServiceL(const RMessage2& aMessage) { - iRequestDispatcher.ServiceL(aMessage, this); + iVpnApiServant.ServiceL(aMessage); } diff -r c9c2ad51f972 -r ef893827b4d1 vpnui/vpnmanagementui/src/vpnmanagementuilogcontainer.cpp --- a/vpnui/vpnmanagementui/src/vpnmanagementuilogcontainer.cpp Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnui/vpnmanagementui/src/vpnmanagementuilogcontainer.cpp Mon Jan 18 21:14:04 2010 +0200 @@ -549,6 +549,8 @@ message = StringLoader::LoadLC( R_VPN_DETAIL_LOG_ENTRY_ERROR ); } + __ASSERT_DEBUG(message != NULL, User::Invariant()); + HBufC* messageText = HBufC::NewLC(message->Length() + eventText->Length() + 2); messageText->Des().Append(*message); //Append category diff -r c9c2ad51f972 -r ef893827b4d1 vpnui/vpnpolins/group/ats_vpnpolins.mmp --- a/vpnui/vpnpolins/group/ats_vpnpolins.mmp Thu Jan 07 13:26:15 2010 +0200 +++ b/vpnui/vpnpolins/group/ats_vpnpolins.mmp Mon Jan 18 21:14:04 2010 +0200 @@ -15,6 +15,7 @@ * */ +#include TARGET vpnpolins.exe TARGETTYPE exe @@ -25,25 +26,23 @@ MACRO ATS_BUILD -SOURCEPATH ..\src +SOURCEPATH ../src SOURCE policyinstaller.cpp SOURCE zipfiledecompressor.cpp SOURCE cmdfileparser.cpp SOURCE vpnbundlehandler.cpp SOURCE vpndevlockhandler.cpp -USERINCLUDE ..\inc -USERINCLUDE ..\..\vpnpolicyrecognizer\inc -USERINCLUDE ..\..\..\vpnengine\vpnextapi\inc -USERINCLUDE ..\..\..\vpnengine\vpnmanager\inc -USERINCLUDE ..\..\..\vpnengine\acuagent\inc -USERINCLUDE ..\..\..\vpnengine\acupluginlib\inc -USERINCLUDE ..\..\vpnecomnotifier\inc -USERINCLUDE ..\..\..\vpnengine\pkiserviceapi\inc -USERINCLUDE ..\..\..\vpnengine\vpncommon\inc -USERINCLUDE ..\..\..\vpnengine\utlpkcs12\inc -USERINCLUDE ..\..\..\vpnengine\utlxml\inc -SYSTEMINCLUDE \epoc32\include +USERINCLUDE ../inc +USERINCLUDE ../../vpnpolicyrecognizer/inc +USERINCLUDE ../../../vpnengine/vpnmanager/inc +USERINCLUDE ../../vpnecomnotifier/inc +USERINCLUDE ../../../vpnengine/pkiserviceapi/inc +USERINCLUDE ../../../vpnengine/vpncommon/inc +USERINCLUDE ../../../vpnengine/utlpkcs12/inc +USERINCLUDE ../../../vpnengine/utlxml/inc + +MW_LAYER_SYSTEMINCLUDE START RESOURCE ..\data\vpnpolins_reg.rss TARGETPATH \private\10003a3f\apps @@ -63,3 +62,4 @@ // File logger only needed for debug builds DEBUGLIBRARY flogger.lib +