Revision: 201007 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 12 Mar 2010 15:48:43 +0200
branchRCL_3
changeset 12 68dc8923de26
parent 8 032d3a818f49
child 13 e4ed1060deb1
Revision: 201007 Kit: 201008
group/vpnclient_version_update.flm
group/vpnclient_version_update.xml
layers.sysdef.xml
vpnengine/ikeutils/inc/ipsecsadata.h
vpnengine/ikeutils/inc/pfkeyextdatautil.h
vpnengine/ikeutils/inc/vpnaddrinfo.h
vpnengine/ikeutils/src/pfkeyextdatautil.cpp
vpnengine/ikeutils/src/vpnaddrinfo.cpp
vpnengine/ikev1lib/inc/ikev1extra.h
vpnengine/ikev1lib/inc/ikev1negotiation.h
vpnengine/ikev1lib/inc/ikev1receiver.h
vpnengine/ikev1lib/src/ikev1extra.cpp
vpnengine/ikev1lib/src/ikev1negotiation.cpp
vpnengine/ikev1lib/src/ikev1pluginsession.cpp
vpnengine/ikev1lib/src/ikev1receiver.cpp
vpnengine/ikev2lib/inc/ikev2SA.h
vpnengine/ikev2lib/src/ikev2negotiation.cpp
vpnengine/ikev2lib/src/ikev2pluginsession.cpp
vpnengine/ikev2lib/src/ikev2sa.cpp
vpnengine/utlpkcs10/EABI/utlpkcs10U.def
vpnengine/utlpkcs10/bwins/UTLPKCS10U.DEF
vpnengine/utlpkcs10/inc/pkcs10.h
vpnengine/utlpkcs10/src/pkcs10.cpp
vpnengine/vpnmanager/inc/cmmanagerutils.h
vpnengine/vpnmanager/src/cmmanagerutils.cpp
vpnui/vpnmanagementui/src/vpnuiloader.cpp
--- a/group/vpnclient_version_update.flm	Fri Feb 19 23:50:52 2010 +0200
+++ b/group/vpnclient_version_update.flm	Fri Mar 12 15:48:43 2010 +0200
@@ -2,7 +2,7 @@
 # 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 "Eclipse Public License v1.0"
+# 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".
 #
--- a/group/vpnclient_version_update.xml	Fri Feb 19 23:50:52 2010 +0200
+++ b/group/vpnclient_version_update.xml	Fri Mar 12 15:48:43 2010 +0200
@@ -4,7 +4,7 @@
 # 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 "Eclipse Public License v1.0"
+# 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".
 #
@@ -19,7 +19,7 @@
 #  Name        : vpnclient_version_update.xml
 #  Part of     : vpnclient
 #  Description : 
-#  Version     : %version: 1 %
+#  Version     : %version: 2 %
 # ============================================================================
 -->
 
--- a/layers.sysdef.xml	Fri Feb 19 23:50:52 2010 +0200
+++ b/layers.sysdef.xml	Fri Mar 12 15:48:43 2010 +0200
@@ -8,8 +8,7 @@
     <layer name="mw_layer">
       <module name="vpnclient"> 
      	<unit unitID="netdo.vpnclient"
-       mrp="" bldFile="&layer_real_source_path;/group"
-       filter="!oem_build" name="vpnclient" />
+       mrp="" bldFile="&layer_real_source_path;/group" name="vpnclient" />
      </module>
     </layer>
   </systemModel>
--- a/vpnengine/ikeutils/inc/ipsecsadata.h	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikeutils/inc/ipsecsadata.h	Fri Mar 12 15:48:43 2010 +0200
@@ -33,7 +33,7 @@
 class TIpsecSAData
     {
 public:
-    TIpsecSAData();
+    IMPORT_C TIpsecSAData();
     
 public: // data
     TUint8      iSAType;
--- a/vpnengine/ikeutils/inc/pfkeyextdatautil.h	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikeutils/inc/pfkeyextdatautil.h	Fri Mar 12 15:48:43 2010 +0200
@@ -44,7 +44,7 @@
      * @param aDestinAddr Destination address
      * @param aOriginalAddr Peer original address
      */
-    EXPORT_C static void BuildUdpEncExtensionData( TDes8& aExtData,
+    IMPORT_C static void BuildUdpEncExtensionData( TDes8& aExtData,
                                                    TUint32 aNAT_D_Flags,
                                                    TBool aNATDetected,
                                                    TBool aNokiaNATProbeUsed,
--- a/vpnengine/ikeutils/inc/vpnaddrinfo.h	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikeutils/inc/vpnaddrinfo.h	Fri Mar 12 15:48:43 2010 +0200
@@ -45,7 +45,7 @@
      * @param aVPNAddress Internal address info (returned)
      * @param aDebug Debug trace interface
      */
-    EXPORT_C static void BuildVPNAddrInfo( const CInternalAddress* aInternalAddr,
+    IMPORT_C static void BuildVPNAddrInfo( const CInternalAddress* aInternalAddr,
                                            const TInetAddr& aDnsServerAddr,
                                            TVPNAddress& aVPNAddress,
                                            MIkeDebug& aDebug );        
--- a/vpnengine/ikeutils/src/pfkeyextdatautil.cpp	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikeutils/src/pfkeyextdatautil.cpp	Fri Mar 12 15:48:43 2010 +0200
@@ -37,7 +37,7 @@
 // (common macros with IPSEC)
 // ---------------------------------------------------------------------------
 //
-void PFKeyExtDataUtil::BuildUdpEncExtensionData( TDes8& aExtData,
+EXPORT_C void PFKeyExtDataUtil::BuildUdpEncExtensionData( TDes8& aExtData,
                                                  TUint32 aNAT_D_Flags,
                                                  TBool aNATDetected,
                                                  TBool aNokiaNATProbeUsed,
--- a/vpnengine/ikeutils/src/vpnaddrinfo.cpp	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikeutils/src/vpnaddrinfo.cpp	Fri Mar 12 15:48:43 2010 +0200
@@ -29,7 +29,7 @@
 // Build internal address info object from internal address information. 
 // ---------------------------------------------------------------------------
 //
-void VPNAddrInfo::BuildVPNAddrInfo( const CInternalAddress* aInternalAddr,
+EXPORT_C void VPNAddrInfo::BuildVPNAddrInfo( const CInternalAddress* aInternalAddr,
                                     const TInetAddr& aDnsServerAddr,
                                     TVPNAddress& aVPNAddress,
                                     MIkeDebug& aDebug )
--- a/vpnengine/ikev1lib/inc/ikev1extra.h	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikev1lib/inc/ikev1extra.h	Fri Mar 12 15:48:43 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 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"
@@ -165,6 +165,8 @@
     TInt   iTransNum;           //Remote transform number selected
     TPtrC8 iReducedLifeSecs;    //Own lifetime (in case is smaller then received)
     TPtrC8 iReducedLifeKBytes;  //Own lifesize (in case is smaller then received)
+    TPtrC8 iResponderLifetimeSecs;    //Responder lifetime
+    TPtrC8 iResponderLifetimeKBytes;  //Responder lifetime size    
     TUint8 iReplayWindowLength;
 };
 
@@ -188,9 +190,9 @@
     TUint8 iTransformNum;   //Transform number
     TUint8 iTransformID;    //Transform ID
     TBuf8<MAX_LIFE_DURATION> iLifeDurationSecs;
-    //TBool iLifetimeReduced;
     TBuf8<MAX_LIFE_DURATION> iLifeDurationKBytes;
-    //TBool iLifesizeReduced;
+    TBuf8<MAX_LIFE_DURATION> iResponderLifetimeSecs;
+    TBuf8<MAX_LIFE_DURATION> iResponderLifetimeKBytes;        
     TUint16 iGroupDesc;     //OAKLEY GROUP
     TUint16 iEncMode;       //Encapsulation Mode
     TUint16 iAuthAlg;       //HMAC
--- a/vpnengine/ikev1lib/inc/ikev1negotiation.h	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikev1lib/inc/ikev1negotiation.h	Fri Mar 12 15:48:43 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 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"
@@ -362,6 +362,15 @@
     TBool IsRetransmit(TLastIKEMsg& aRef);    
     void SaveRetransmitInfo(TLastIKEMsg& aRef);
     void SaveLastMsgL();
+    
+    HBufC8* GetPskFromPolicyL();
+    
+    void SetPhase2LifeDurations( const TInt64 aSoftAddTime,
+                                 const TInt64 aHardAddTime,
+                                 const TInt64 aSoftBytes,
+                                 const TInt64 aHardBytes,
+                                 TAttrib_II& aAttr_II,
+                                 TBool aResponder );    
 
 public:
 	TCookie iCookie_I;      // Initiator Cookie (Used with responder to create KEYID)
--- a/vpnengine/ikev1lib/inc/ikev1receiver.h	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikev1lib/inc/ikev1receiver.h	Fri Mar 12 15:48:43 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-2010 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"
@@ -80,6 +80,11 @@
     */
     void StartReceive();
     
+    /**
+    * Cancels receiving.
+    */
+    void CancelReceive();
+    
 private:
     
     CIkev1Receiver( MIkeDataInterface& aDataInterface,
@@ -135,6 +140,12 @@
     TInt                        iLocalPort;
     
     /**
+     * Informs if receiving data.
+     * Own.
+     */
+    TBool                       iReceiving;
+    
+    /**
      * IKE data interface.
      * Not own.
      */
--- a/vpnengine/ikev1lib/src/ikev1extra.cpp	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikev1lib/src/ikev1extra.cpp	Fri Mar 12 15:48:43 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 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"
@@ -250,8 +250,8 @@
     if ( iTransformID != aAttr.iTransformID ) //Transform ID
         return KErrTransformID;
 
-    if ((iGroupDesc != aAttr.iGroupDesc) &&
-        (!(iGroupDesc == 0) && (aAttr.iGroupDesc == MODP_768))) //OAKLEY GROUP
+    if ((aAttr.iGroupDesc < iGroupDesc) &&
+        (!(iGroupDesc == 0)))    
         return KErrGroupDesc;
     if (iEncMode != aAttr.iEncMode) //Encapsulation Mode
         return KErrEncMode;
@@ -291,6 +291,10 @@
             return KErrLifeTime;
         if (iLifeDurationKBytes.Compare(aAttr.iLifeDurationKBytes)!=0)
             return KErrLifeSize;
+        if (iResponderLifetimeSecs.Compare(aAttr.iResponderLifetimeSecs)!=0)
+            return KErrLifeTime;
+        if (iResponderLifetimeKBytes.Compare(aAttr.iResponderLifetimeKBytes)!=0)
+            return KErrLifeSize;        
     }
     return KErrNone;
 }
@@ -301,6 +305,8 @@
     iTransformID = aAttr.iTransformID;  //Transform ID
     iLifeDurationSecs.Copy(aAttr.iLifeDurationSecs);
     iLifeDurationKBytes.Copy(aAttr.iLifeDurationKBytes);
+    iResponderLifetimeSecs.Copy(aAttr.iResponderLifetimeSecs);
+    iResponderLifetimeKBytes.Copy(aAttr.iResponderLifetimeKBytes);    
     iGroupDesc = aAttr.iGroupDesc;      //OAKLEY GROUP
     iEncMode = aAttr.iEncMode;      //Encapsulation Mode
     iAuthAlg = aAttr.iAuthAlg;      //HMAC
@@ -426,6 +432,8 @@
                 tmodif->iReplayWindowLength = prop1->iReplayWindowLength;   //to update SAD correctly
                 tmodif->iReducedLifeSecs.Set(prop1->iAttrList->At(local_num)->iLifeDurationSecs);
                 tmodif->iReducedLifeKBytes.Set(prop1->iAttrList->At(local_num)->iLifeDurationKBytes);
+                tmodif->iResponderLifetimeSecs.Set(prop1->iAttrList->At(local_num)->iResponderLifetimeSecs);
+                tmodif->iResponderLifetimeKBytes.Set(prop1->iAttrList->At(local_num)->iResponderLifetimeKBytes);                
                 aTransArray->AppendL(tmodif);   //add to the array and go for the next
                 CleanupStack::Pop();      //tmodif safe
                 if ( (i1 + 1) < Count() ) //still proposals left in 'this' list
--- a/vpnengine/ikev1lib/src/ikev1negotiation.cpp	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikev1lib/src/ikev1negotiation.cpp	Fri Mar 12 15:48:43 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 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"
@@ -833,37 +833,12 @@
         }  
     }
 
-    //Only Hard Lifetimes taken into account
-    TInt64 lifetime64 = aReq.iProposal.iComb->sadb_comb_soft_addtime;
-    iHardLifetime = aReq.iProposal.iComb->sadb_comb_hard_addtime;
-    
-    if ( lifetime64 == 0 )
-        {
-        lifetime64 = iHardLifetime;
-        }
-    
-    TUint high = 0;
-    TUint low = 0;
-    if (lifetime64!=0)
-    {
-        high = ByteOrder::Swap32(I64HIGH(lifetime64));
-        if (high > 0)
-            attr_II->iLifeDurationSecs.Copy((TUint8 *)&high, sizeof(high));
-        low = ByteOrder::Swap32(I64LOW(lifetime64));
-        attr_II->iLifeDurationSecs.Append((TUint8 *)&low, sizeof(low));
-    }
-
-    //Bytes lifetime
-    lifetime64 = aReq.iProposal.iComb->sadb_comb_soft_bytes;
-    lifetime64 = (lifetime64/1024); //Bytes to KB
-    if (lifetime64 != 0)
-    {
-        high = ByteOrder::Swap32(I64HIGH(lifetime64));      
-        if (high > 0)
-            attr_II->iLifeDurationKBytes.Copy((TUint8 *)&high, sizeof(high));
-        low = ByteOrder::Swap32(I64LOW(lifetime64));        
-        attr_II->iLifeDurationKBytes.Append((TUint8 *)&low, sizeof(low));
-    }
+    SetPhase2LifeDurations( aReq.iProposal.iComb->sadb_comb_soft_addtime,
+                            aReq.iProposal.iComb->sadb_comb_hard_addtime,
+                            aReq.iProposal.iComb->sadb_comb_soft_bytes,
+                            aReq.iProposal.iComb->sadb_comb_hard_bytes,
+                            *attr_II,
+                            EFalse );
 
     //Save some pf_key data to use later in PFKEY_UPDATE msg
     iAcquireSeq = aReq.iBase.iMsg->sadb_msg_seq;        //msg Seq. number
@@ -1735,31 +1710,14 @@
             break;
 		}
 		
-        //Only Hard Lifetimes taken into account
-        TInt64 lifetime64 = spec->iHard.iAddTime;
-        TUint high = 0;
-        TUint low = 0;
-        if (lifetime64!=0)
-        {
-            high = ByteOrder::Swap32(I64HIGH(lifetime64));          
-            if (high > 0)
-                attr_II->iLifeDurationSecs.Copy((TUint8 *)&high, sizeof(high));
-            low = ByteOrder::Swap32(I64LOW(lifetime64));                        
-            attr_II->iLifeDurationSecs.Append((TUint8 *)&low, sizeof(low));
-        }
-
-        //Bytes lifetime
-        lifetime64 = spec->iHard.iBytes;
-        lifetime64 = (lifetime64/1024); //Bytes to KB
-        if (lifetime64 != 0)
-        {
-            high = ByteOrder::Swap32(I64HIGH(lifetime64));                      
-            if (high > 0)
-                attr_II->iLifeDurationKBytes.Copy((TUint8 *)&high, sizeof(high));
-            low = ByteOrder::Swap32(I64LOW(lifetime64));                                    
-            attr_II->iLifeDurationKBytes.Append((TUint8 *)&low, sizeof(low));
-        }
-        if (iPFS)
+	    SetPhase2LifeDurations( spec->iSoft.iAddTime,
+                                spec->iHard.iAddTime,
+                                spec->iSoft.iBytes,
+                                spec->iHard.iBytes,
+	                            *attr_II,
+	                            ETrue );
+
+	    if (iPFS)
         {
             switch (iHostData->iGroupDesc_II)
             {
@@ -3938,7 +3896,6 @@
         AppendAttributeError(num, err_buf);
         DEBUG_LOG(err_buf);
 #endif        
-        SetErrorStatus( KKmdIkeNoProposalErr );
         SendNotifyL(NO_PROPOSAL_CHOSEN);
         CleanupStack::PopAndDestroy(3); //transarray + recv_proposals + payload
         return EFalse;
@@ -4011,7 +3968,7 @@
     }
     
     TTransModifier *tmodif;
-    TInt64 own_time, own_bytes, peer_time, peer_bytes;
+    TInt64 own_time, own_bytes, peer_time, peer_bytes, responderLifetime_time, responderLifetime_bytes;
     delete iChosenProp_IIList;  //Must be erased because can contain data from previous retransmissions
 	iChosenProp_IIList = NULL;	
     iChosenProp_IIList = new (ELeave) CProposal_IIList(1);
@@ -4037,6 +3994,7 @@
         attr_II = prop->iAttrList->At(tmodif->iTransNum);   //look for the chosen transform in the prop
         ComputeLifetimes_II(tmodif->iReducedLifeSecs, tmodif->iReducedLifeKBytes, own_time, own_bytes);
         ComputeLifetimes_II(attr_II->iLifeDurationSecs, attr_II->iLifeDurationKBytes, peer_time, peer_bytes);
+        ComputeLifetimes_II(tmodif->iResponderLifetimeSecs, tmodif->iResponderLifetimeKBytes, responderLifetime_time, responderLifetime_bytes);
         
         //Only copy the chosen transform
         new_attr_II = new (ELeave) TChosenAttrib_II();
@@ -4057,7 +4015,19 @@
         }
         else
             new_attr_II->iReducedLifeKBytes.Set(NULL, 0);
-
+        
+        if (responderLifetime_time)
+        {
+            new_attr_II->iResponderLifetimeSecs = tmodif->iResponderLifetimeSecs;
+            DEBUG_LOG1(_L("Responder lifetime set to %d"), responderLifetime_time);        
+        }
+
+        if (responderLifetime_bytes)
+        {
+            new_attr_II->iResponderLifetimeKBytes = tmodif->iResponderLifetimeKBytes;
+            DEBUG_LOG1(_L("Responder lifetime in bytes set to %d"), responderLifetime_bytes);        
+        }
+        
         new_propII->iAttrList->AppendL(new_attr_II);
         CleanupStack::Pop();    //new_attrII safe
 
@@ -7347,17 +7317,12 @@
         prf_data->Des().Copy(iNONCE_I.Ptr(),iNONCE_I.Length());
         prf_data->Des().Append(iNONCE_R.Ptr(),iNONCE_R.Length());
         DEBUG_LOG(_L("Pre-shared Key"));
-#ifdef _UNICODE
-        HBufC8 *preshared_key_buf = HBufC8::NewLC(iHostData->iPresharedKey.iKey.Length());
-        preshared_key_buf->Des().Copy(iHostData->iPresharedKey.iKey);
+
+        HBufC8 *preshared_key_buf = GetPskFromPolicyL();
+        CleanupStack::PushL(preshared_key_buf);        
         TPtrC8 preshared_key_ptr(preshared_key_buf->Des());
-#else
-        TPtrC8 preshared_key_ptr(iHostData->iPresharedKey.iKey);
-#endif
         ComputePRFL(iSKEYID, preshared_key_ptr, prf_data->Des());
-#ifdef _UNICODE
-        CleanupStack::PopAndDestroy();  //presharedkey_buf
-#endif
+        CleanupStack::PopAndDestroy(preshared_key_buf);
         }
         break;
     default://method not implemented
@@ -8091,7 +8056,10 @@
         attr_II = (TChosenAttrib_II *)prop->iAttrList->At(0);   //only 1 transform is chosen no matter how many there are
 
         if ((attr_II->iReducedLifeSecs.Length() != 0) || (attr_II->iReducedLifeKBytes.Length() != 0))   //Any lifetime to update
-            aMsg.IsakmpResponderLifetime(prop->iProtocol, inboundspi_node.iSPI, attr_II->iReducedLifeSecs, attr_II->iReducedLifeKBytes);
+            aMsg.IsakmpResponderLifetime(prop->iProtocol,
+                                         inboundspi_node.iSPI,
+                                         attr_II->iResponderLifetimeSecs,
+                                         attr_II->iResponderLifetimeKBytes);
 
     }
 }
@@ -8302,5 +8270,127 @@
         }    
 }
 
-
-
+HBufC8* CIkev1Negotiation::GetPskFromPolicyL()
+{
+    ASSERT(iHostData);
+    //
+    // Get Preshared Key from IKE policy and return in to caller in
+    // HBufc8.
+    //
+    HBufC8* psk = NULL;
+    if ( iHostData->iPresharedKey.iFormat ==  STRING_KEY )
+    {
+        psk = HBufC8::NewL(iHostData->iPresharedKey.iKey.Length());
+        psk->Des().Copy(iHostData->iPresharedKey.iKey);
+    }
+    else if ( iHostData->iPresharedKey.iFormat == HEX_KEY ) 
+    {
+        psk = HBufC8::NewL(iHostData->iPresharedKey.iKey.Length() / 2);        
+        
+        for(TInt i = 0; i < iHostData->iPresharedKey.iKey.Length(); i += 2)
+        {        
+            TPtrC hexByte(iHostData->iPresharedKey.iKey.Mid(i, 2));
+            TLex lex(hexByte);
+            TUint8 value;
+            User::LeaveIfError(lex.Val(value, EHex));
+            
+            psk->Des().Append(&value, 1);
+        }
+        
+    }
+
+    return psk;
+}
+
+void CIkev1Negotiation::SetPhase2LifeDurations( const TInt64 aSoftAddTime,
+                                                const TInt64 aHardAddTime,
+                                                const TInt64 aSoftBytes,
+                                                const TInt64 aHardBytes,
+                                                TAttrib_II& aAttr_II,
+                                                TBool aResponder )    
+{
+    TInt64 lifetime64 = aSoftAddTime;
+    iHardLifetime = aHardAddTime;
+    
+    if ( lifetime64 == 0 ||
+         aResponder )
+        {
+        lifetime64 = iHardLifetime;
+        }
+    
+    TUint high = 0;
+    TUint low = 0;
+    if ( lifetime64 != 0 )
+        {
+        high = ByteOrder::Swap32(I64HIGH(lifetime64));
+        if (high > 0)
+            {
+            aAttr_II.iLifeDurationSecs.Copy((TUint8 *)&high, sizeof(high));
+            }
+        low = ByteOrder::Swap32(I64LOW(lifetime64));
+        aAttr_II.iLifeDurationSecs.Append((TUint8 *)&low, sizeof(low));
+        }
+    
+    if ( aResponder )
+        {
+        // Set responder lifetime.
+        lifetime64 = aSoftAddTime;
+        if ( lifetime64 == 0 )
+            {
+            lifetime64 = iHardLifetime;
+            }    
+        
+        if ( lifetime64 != 0 )
+            {
+            high = ByteOrder::Swap32(I64HIGH(lifetime64));
+            if (high > 0)
+                {
+                aAttr_II.iResponderLifetimeSecs.Copy((TUint8 *)&high, sizeof(high));            
+                }
+            low = ByteOrder::Swap32(I64LOW(lifetime64));
+            aAttr_II.iResponderLifetimeSecs.Append((TUint8 *)&low, sizeof(low));
+            }        
+        }
+
+    //Bytes lifetime
+    lifetime64 = aSoftBytes;
+    
+    if ( lifetime64 == 0 ||
+         aResponder )
+        {
+        lifetime64 = aHardBytes;
+        }
+        
+    lifetime64 = (lifetime64/1024); //Bytes to KB
+    if ( lifetime64 != 0 )
+        {
+        high = ByteOrder::Swap32(I64HIGH(lifetime64));      
+        if (high > 0)
+            aAttr_II.iLifeDurationKBytes.Copy((TUint8 *)&high, sizeof(high));
+        low = ByteOrder::Swap32(I64LOW(lifetime64));        
+        aAttr_II.iLifeDurationKBytes.Append((TUint8 *)&low, sizeof(low));
+        }    
+    
+    if ( aResponder )
+        {
+        // Set responder lifetime.
+        if ( lifetime64 == 0 )
+            {
+            lifetime64 = iHardLifetime;
+            }    
+        lifetime64 = (lifetime64/1024); //Bytes to KB
+        
+        if ( lifetime64 != 0 )
+            {
+            high = ByteOrder::Swap32(I64HIGH(lifetime64));
+            if (high > 0)
+                {
+                aAttr_II.iResponderLifetimeKBytes.Copy((TUint8 *)&high, sizeof(high));            
+                }
+            low = ByteOrder::Swap32(I64LOW(lifetime64));
+            aAttr_II.iResponderLifetimeKBytes.Append((TUint8 *)&low, sizeof(low));
+            }        
+        }    
+}
+
+
--- a/vpnengine/ikev1lib/src/ikev1pluginsession.cpp	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikev1lib/src/ikev1pluginsession.cpp	Fri Mar 12 15:48:43 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-2010 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"
@@ -1447,7 +1447,8 @@
                CleanupStack::Pop();    //negotiation safe
                return;
                }
-            CleanupStack::PopAndDestroy();
+            CleanupStack::Pop();
+            DeleteNegotiation(negotiation);
             }            
         return;
         }
@@ -1900,7 +1901,7 @@
 //
 void CIkev1PluginSession::DoCancelDataTransfer()
     {
-    iReceiver->Cancel();
+    iReceiver->CancelReceive();
     iDataInterface.StopReceive();
     DoEmptySendQueue();
     iSender->Cancel();
--- a/vpnengine/ikev1lib/src/ikev1receiver.cpp	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikev1lib/src/ikev1receiver.cpp	Fri Mar 12 15:48:43 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-2010 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"
@@ -82,10 +82,21 @@
 //
 void CIkev1Receiver::StartReceive()
     {
+    iReceiving = ETrue;
     DoReceive();
     }
 
 // ---------------------------------------------------------------------------
+// Cancels receive.
+// ---------------------------------------------------------------------------
+//
+void CIkev1Receiver::CancelReceive()
+    {
+    iReceiving = EFalse;
+    Cancel();
+    }
+
+// ---------------------------------------------------------------------------
 // From class CActive
 // Handles completion of receive. 
 // ---------------------------------------------------------------------------
@@ -112,13 +123,15 @@
         }
     else
         {
+        iReceiving = EFalse;
         iCallback.ReceiveError( iStatus.Int() );
         }
     
     delete iUdpData;
     iUdpData = NULL;
     
-    if ( iStatus.Int() == KErrNone )
+    if ( iReceiving &&
+         iStatus.Int() == KErrNone )
         {
         // Continue receiving.
         DoReceive();
@@ -145,6 +158,8 @@
 //
 TInt CIkev1Receiver::RunError( TInt aError )
     {
+    iReceiving = EFalse;
+    
     delete iUdpData;
     iUdpData = NULL;
     
--- a/vpnengine/ikev2lib/inc/ikev2SA.h	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikev2lib/inc/ikev2SA.h	Fri Mar 12 15:48:43 2010 +0200
@@ -73,6 +73,7 @@
 	TIkeV2IpsecSAData*  iIpsecSaQue;     // Ipsec SA information queue
 	CIkeV2KeepAlive* iIkeKeepAlive;   // Pointer to common IKE keepalive object	
 	TUint32        iRemainingTime;   // Current lifetime left
+	TUint32        iRekeyingThreshold;
 
     };
 
--- a/vpnengine/ikev2lib/src/ikev2negotiation.cpp	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikev2lib/src/ikev2negotiation.cpp	Fri Mar 12 15:48:43 2010 +0200
@@ -2620,7 +2620,6 @@
 				   DEBUG_LOG1(_L("IKE SA Rekey started by peer for SAID: %d"), iHdr.SaId());							   						   
 				   iState = KStateIkeSARekeyResponse;
 				   Status = ProcessIkeSARekeyL(aIkeMsg);
-				   iIkeV2PlugInSession.UpdateIkev2SAL(&iHdr, NULL);
 				}
 				return Status;
 			}
--- a/vpnengine/ikev2lib/src/ikev2pluginsession.cpp	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikev2lib/src/ikev2pluginsession.cpp	Fri Mar 12 15:48:43 2010 +0200
@@ -273,18 +273,14 @@
 void CIkev2PluginSession::DoDeleteIkeSAExhangeL(TIkev2SAData& aIkev2SAdata)
     {
     DEBUG_LOG1(_L("Deleting IKE SA SAID =  %d"), aIkev2SAdata.SaId());
-                
-    __ASSERT_DEBUG(iFirstNegotiation == NULL, User::Invariant());
-    
-   CIkev2Negotiation* negotiation = CIkev2Negotiation::NewL(*this, iPfKeySocketIf, 
-                                                            iEventLogger, *iMessageSendQue, 
-                                                            iDebug, aIkev2SAdata);
-   CleanupStack::PushL(negotiation);
-   negotiation->StartIkeSADeleteL();
-   CleanupStack::Pop(negotiation);
-   
-   __ASSERT_DEBUG( !negotiation->Stopped(), User::Invariant() );
-
+                    
+    CIkev2Negotiation* negotiation = CIkev2Negotiation::NewL(*this, iPfKeySocketIf, 
+                                                             iEventLogger, *iMessageSendQue, 
+                                                             iDebug, aIkev2SAdata);
+    CleanupStack::PushL(negotiation);
+    negotiation->StartIkeSADeleteL();
+    CleanupStack::Pop(negotiation);
+    __ASSERT_DEBUG( !negotiation->Stopped(), User::Invariant() );    
     }
 
 
--- a/vpnengine/ikev2lib/src/ikev2sa.cpp	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/ikev2lib/src/ikev2sa.cpp	Fri Mar 12 15:48:43 2010 +0200
@@ -22,6 +22,9 @@
 #include "ikev2ipsecsadata.h"
 #include "ikev2pluginsession.h"
 
+static const TUint32 KMinRekeyingThreshold = 70;
+static const TUint32 KMaxRekeyingThreshold = 95;
+
 CIkev2SA* CIkev2SA::NewL(CIkev2PluginSession& aIkeV2PluginSession, TIkev2SAData& aIkev2SAdata, MIkeDebug& aDebug)
 {
 	CIkev2SA *sa = new (ELeave) CIkev2SA(aIkeV2PluginSession, aDebug);
@@ -45,9 +48,32 @@
 	// Calculate lifetime value for the new IKE SA
 	// The jitter value is adjusted from SA internal ID (SAId mod 8) 
 	//
-    iRemainingTime = iIkeV2SaData.iLifetime + (iIkeV2SaData.SaId() % 8);
+	
+	if (iIkeV2SaData.iIkeData->iRekeyingThreshold != 0)
+	    {
+        if (iIkeV2SaData.iIkeData->iRekeyingThreshold < KMinRekeyingThreshold)
+            {
+            iRekeyingThreshold = KMinRekeyingThreshold;
+            }
+        else if (iIkeV2SaData.iIkeData->iRekeyingThreshold > KMaxRekeyingThreshold)
+            {
+            iRekeyingThreshold = KMaxRekeyingThreshold;
+            }
+        else
+            {
+            iRekeyingThreshold = iIkeV2SaData.iIkeData->iRekeyingThreshold;
+            }
+        TReal lifeTime = (TReal)iIkeV2SaData.iLifetime * ((TReal)iRekeyingThreshold / 100.0);
+        iRemainingTime = (TUint32)lifeTime + (iIkeV2SaData.SaId() % 8);
+	    }
+	else
+	    {
+        iRemainingTime = iIkeV2SaData.iLifetime + (iIkeV2SaData.SaId() % 8);
+	    }
+	    
 	iIkeV2SaData.iSAState  = KSaStateReady;
 
+	
 	TInt DPDHeartbeat = 0;
 	if ( iIkeV2SaData.iIkeData->iDPDHeartBeat )
 	   DPDHeartbeat = iIkeV2SaData.iIkeData->iDPDHeartBeat;      
@@ -236,7 +262,7 @@
             iIkeV2SaData.SaId(), iRemainingTime );
 	if (iRemainingTime == 0) 
 	{										 		
-		if ( iIpsecSaQue )
+		if ( iIpsecSaQue && iRekeyingThreshold != 0)
 		{
 		    iIkeV2PluginSession.RekeyIkeSAL(&iIkeV2SaData);
 		}
--- a/vpnengine/utlpkcs10/EABI/utlpkcs10U.def	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/utlpkcs10/EABI/utlpkcs10U.def	Fri Mar 12 15:48:43 2010 +0200
@@ -13,4 +13,6 @@
 	_ZN10CPkcs10ReqD2Ev @ 12 NONAME
 	_ZTI10CPkcs10Req @ 13 NONAME ; #<TI>#
 	_ZTV10CPkcs10Req @ 14 NONAME ; #<VT>#
+	_ZN10CPkcs10ReqC1Ev @ 15 NONAME
+	_ZN10CPkcs10ReqC2Ev @ 16 NONAME
 
--- a/vpnengine/utlpkcs10/bwins/UTLPKCS10U.DEF	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/utlpkcs10/bwins/UTLPKCS10U.DEF	Fri Mar 12 15:48:43 2010 +0200
@@ -9,4 +9,5 @@
 	?SetDistinguishedNameExtendedL@CPkcs10Req@@QAEHABVTDesC8@@@Z @ 8 NONAME ; int CPkcs10Req::SetDistinguishedNameExtendedL(class TDesC8 const &)
 	?SetPublicKey@CPkcs10Req@@QAEHABVTDesC8@@@Z @ 9 NONAME ; int CPkcs10Req::SetPublicKey(class TDesC8 const &)
 	?SetSubjectAltNameRfc822@CPkcs10Req@@QAEHABVTDesC8@@@Z @ 10 NONAME ; int CPkcs10Req::SetSubjectAltNameRfc822(class TDesC8 const &)
+	??0CPkcs10Req@@QAE@XZ @ 11 NONAME ; CPkcs10Req::CPkcs10Req(void)
 
--- a/vpnengine/utlpkcs10/inc/pkcs10.h	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/utlpkcs10/inc/pkcs10.h	Fri Mar 12 15:48:43 2010 +0200
@@ -130,10 +130,8 @@
 class CPkcs10Req : public CBase
 {
     public:
-#ifdef __EABI__
         /** Cause vtable & typeinfo to be exported */
-        IMPORT_C CPkcs10Req() {};
-#endif
+        IMPORT_C CPkcs10Req();
         IMPORT_C ~CPkcs10Req();
         //////////////////////////////////////////////////////////////////////
         //  Visible interface
--- a/vpnengine/utlpkcs10/src/pkcs10.cpp	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/utlpkcs10/src/pkcs10.cpp	Fri Mar 12 15:48:43 2010 +0200
@@ -27,6 +27,10 @@
 #include "pkidefs.h"
 #include "utlcrypto.h"
 
+EXPORT_C CPkcs10Req::CPkcs10Req()
+	{
+	}
+
 //////////////////////////////////////////////////////////////////////////////
 // Destructor
 //////////////////////////////////////////////////////////////////////////////
--- a/vpnengine/vpnmanager/inc/cmmanagerutils.h	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/vpnmanager/inc/cmmanagerutils.h	Fri Mar 12 15:48:43 2010 +0200
@@ -48,8 +48,7 @@
                                                   const TUint32 aInternetDestinationId);
     
     
-    static HBufC* CreateConnectionMethodNameLC(RCmManagerExt& aCmManagerExt,
-                                               const TDesC& aPolicyName);
+    static HBufC* CreateConnectionMethodNameLC(const TDesC& aPolicyName);
 
     static HBufC* CreateIntranetDestinationNameLC(RCmManagerExt& aCmManagerExt);
     
--- a/vpnengine/vpnmanager/src/cmmanagerutils.cpp	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnengine/vpnmanager/src/cmmanagerutils.cpp	Fri Mar 12 15:48:43 2010 +0200
@@ -65,8 +65,7 @@
     if ( internetDestinationId != 0)
         {                        
         //Generate name for the connection method
-        HBufC* name = CreateConnectionMethodNameLC(cmManagerExt,
-                                                   aVpnPolicyInfo.iName);
+        HBufC* name = CreateConnectionMethodNameLC(aVpnPolicyInfo.iName);
         
         //Create VPN connection method        
         RCmConnectionMethodExt vpnConnectionMethod =
@@ -111,59 +110,16 @@
     LOG_("CmManagerUtils::SetVpnConnectionMethodAttributesL - end \n");
     }
 
-HBufC* CmManagerUtils::CreateConnectionMethodNameLC(RCmManagerExt& aCmManagerExt,
-                                                    const TDesC& aPolicyName)
+HBufC* CmManagerUtils::CreateConnectionMethodNameLC(const TDesC& aPolicyName)
     {
-    using namespace CMManager;
-    
+       
     LOG_("CmManagerUtils::CreateConnectionMethodNameLC \n");
     
     HBufC* name = HBufC::NewLC(KMaxDestinationNameLength);
     TPtr namePtr = name->Des();
     
-    RArray<TUint32> connections;
-    CleanupClosePushL( connections );    
-    aCmManagerExt.ConnectionMethodL( connections, EFalse, EFalse, EFalse );
+    namePtr.Copy(aPolicyName.Left(KMaxDestinationNameLength));   
     
-    TInt connectionMethodCount = connections.Count();    
-    TBool matchFound = EFalse;
-    TInt counter = 1;
-    do 
-        {       
-        matchFound = EFalse;
-        
-        namePtr.Copy(aPolicyName.Left(KMaxDestinationNameLength));   
-        if (counter > 1)
-            {
-            TBuf<10> numberValue;
-            numberValue.Format(_L("(%d)"), counter);
-            if (namePtr.MaxLength() < numberValue.Length() + namePtr.Length())                
-                {
-                namePtr.SetLength(namePtr.MaxLength() - numberValue.Length());
-                
-                }
-            namePtr.Append(numberValue);
-            }
-             
-        for (TInt i = 0; i < connectionMethodCount; i++)
-            {
-           RCmConnectionMethodExt connectionMethod = aCmManagerExt.ConnectionMethodL( connections[i] );
-           CleanupClosePushL(connectionMethod);
-           HBufC* existingName = connectionMethod.GetStringAttributeL( ECmName );
-           CleanupStack::PopAndDestroy(); //connectionMethod
-            
-            if (name->Compare(*existingName) == 0)
-                {
-                delete existingName;
-                matchFound = ETrue;
-                break;
-                }                   
-            delete existingName;                    
-            }
-        counter++;
-        }while(matchFound);
-        
-    CleanupStack::PopAndDestroy(); // connections    
     LOG_("CmManagerUtils::CreateConnectionMethodNameLC - end \n");
     return name;
     }
--- a/vpnui/vpnmanagementui/src/vpnuiloader.cpp	Fri Feb 19 23:50:52 2010 +0200
+++ b/vpnui/vpnmanagementui/src/vpnuiloader.cpp	Fri Mar 12 15:48:43 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2003 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2003 - 2010 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"
@@ -70,12 +70,6 @@
     {
     LOG_("CVpnUiLoader::~CVpnUiLoader()");
     iVpnManagementUiView = NULL;
-    
-    if ( iLogViewVisited == EFalse )
-       delete iVpnManagementUiLogView;
-        
-    if ( iPolicyViewVisited == EFalse )
-       delete iVpnManagementUiPolicyView;
        
     delete iVpnManagementUiParametersView;
     delete iVpnManagementUiServerView;
@@ -139,12 +133,8 @@
     
 	iPreviousAppViewId = aViewId;
 	CreateWindowL();
-
-    iVpnManagementUiPolicyView = CVpnManagementUiPolicyView::NewL( 
-        aRect, *this);
     iVpnManagementUiServerView = CVpnManagementUiServerView::NewL( 
         aRect, *this);
-    iVpnManagementUiLogView = CVpnManagementUiLogView::NewL( aRect, *this);
     iVpnManagementUiParametersView = CServerSettingsView::NewL( aRect, *this);
 
 	SetRect(aRect);
@@ -197,11 +187,12 @@
             }
 		case KChangeViewBack:
       ((CAknViewAppUi*)iAvkonAppUi)->RemoveView(KVpnManagementUiPolicyViewId);
+		    iPolicyViewVisited = EFalse;
 			((CAknViewAppUi*)iAvkonAppUi)->RemoveView(KVpnManagementUiLogViewId);
+			iLogViewVisited = EFalse;
 			((CAknViewAppUi*)iAvkonAppUi)->RemoveView(KVpnManagementUiParametersViewId);
 			((CAknViewAppUi*)iAvkonAppUi)->RemoveView(KVpnManagementUiServerViewId);
 			((CAknViewAppUi*)iAvkonAppUi)->ActivateLocalViewL( iGsViewId.iViewUid );
-			ReleaseResource(ETrue);
             if(iObserver)
                 {
                 iObserver->UiComplete(KUirEventNone);
@@ -218,7 +209,12 @@
 
 			iPreviousViewId = localCurrentViewId.iViewUid;
 			if ( iPolicyViewVisited == EFalse)
+			    {
+                TRect rect;
+                iVpnManagementUiPolicyView = CVpnManagementUiPolicyView::NewL( 
+		            rect, *this);
 			    ((CAknViewAppUi*)iAvkonAppUi)->AddViewL(iVpnManagementUiPolicyView);
+			    }
 			iPolicyViewVisited=ETrue;
 			((CAknViewAppUi*)iAvkonAppUi)->ActivateLocalViewL(
                   KVpnManagementUiPolicyViewId );
@@ -249,7 +245,11 @@
 
 			iPreviousViewId = localCurrentViewId.iViewUid;
 			if ( iLogViewVisited == EFalse)
+			    {
+                TRect rect;
+                iVpnManagementUiLogView = CVpnManagementUiLogView::NewL( rect, *this);
 			    ((CAknViewAppUi*)iAvkonAppUi)->AddViewL(iVpnManagementUiLogView);
+			    }
 			iLogViewVisited=ETrue;
 			((CAknViewAppUi*)iAvkonAppUi)->ActivateLocalViewL(
                   KVpnManagementUiLogViewId );