vpnengine/ikev2lib/src/ikev2expire.cpp
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     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 * CIkev2Expire. This class is used to handle PFKEY Expire primitives received 
       
    16 * from IPSec plug-in.
       
    17 *
       
    18 */
       
    19 #include "ikev2expire.h"
       
    20 #include "pfkeymsg.h"
       
    21 
       
    22 //
       
    23 //  CIkev2Expire
       
    24 //
       
    25 //  This class is used to handle PFKEY Expire primitives received from
       
    26 //  Ipsec plug-in. 
       
    27 //
       
    28 
       
    29 CIkev2Expire* CIkev2Expire::NewL(const TPfkeyMessage& aPfkeyMessage)
       
    30 {
       
    31     CIkev2Expire* Expire = new (ELeave)CIkev2Expire();
       
    32     TPtrC8 spiPtr(reinterpret_cast<const TUint8*>(&aPfkeyMessage.iSa.iExt->sadb_sa_spi), 
       
    33                   sizeof(aPfkeyMessage.iSa.iExt->sadb_sa_spi));
       
    34     Expire->SetSPI(spiPtr);
       
    35     Expire->SetProtocol(aPfkeyMessage.iBase.iMsg->sadb_msg_satype);
       
    36     return Expire;
       
    37 }
       
    38 
       
    39 void CIkev2Expire::Link(CIkev2Expire* aExpire, CIkev2Expire** aAnchor)
       
    40 {
       
    41     ASSERT(aExpire && aAnchor);
       
    42     aExpire->iNext = NULL;
       
    43     CIkev2Expire* Last  = *aAnchor;
       
    44     if ( Last )
       
    45     {   
       
    46         while ( Last->iNext )
       
    47         {
       
    48             Last = Last->iNext;
       
    49         }
       
    50         Last->iNext = aExpire;
       
    51     }
       
    52     else *aAnchor = aExpire;    
       
    53 }
       
    54 
       
    55 CIkev2Expire* CIkev2Expire::GetNext(CIkev2Expire** aAnchor)
       
    56 {
       
    57     ASSERT(aAnchor);
       
    58     CIkev2Expire* Elem = *aAnchor;
       
    59     if ( Elem )
       
    60         *aAnchor = Elem->iNext;
       
    61     return Elem;
       
    62 }  
       
    63 
       
    64 void CIkev2Expire::PurgeQue(CIkev2Expire** aAnchor)
       
    65 {
       
    66     ASSERT(aAnchor);
       
    67     CIkev2Expire* Elem = *aAnchor;
       
    68     while ( Elem )
       
    69     {
       
    70         *aAnchor = Elem->iNext;
       
    71         delete Elem;
       
    72         Elem = *aAnchor;
       
    73     }   
       
    74 }
       
    75 
       
    76 TPtrC8 CIkev2Expire::SPI() 
       
    77     { 
       
    78     return iSPI;
       
    79     }
       
    80 
       
    81 void CIkev2Expire::SetSPI(const TDesC8& aSPI) 
       
    82     { 
       
    83     iSPI = aSPI;
       
    84     }
       
    85 
       
    86 TUint8 CIkev2Expire::Protocol() 
       
    87     { 
       
    88     return iProtocol;
       
    89     }
       
    90 
       
    91 void CIkev2Expire::SetProtocol(TUint8 aProt) 
       
    92     { 
       
    93     iProtocol = aProt;
       
    94     }
       
    95