natfw/natfwunsaf_protocols/unsaf_codec/src/natfwunsafallocateresponse.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006-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 "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 
       
    21 #include "natfwunsafallocateresponse.h"
       
    22 
       
    23 // -----------------------------------------------------------------------------
       
    24 // CNATFWUNSAFAllocateResponse::NewL
       
    25 // -----------------------------------------------------------------------------
       
    26 //
       
    27 CNATFWUNSAFAllocateResponse*
       
    28 CNATFWUNSAFAllocateResponse::NewL(
       
    29     const TNATFWUNSAFTransactionID& aTransactionID)
       
    30     {
       
    31     CNATFWUNSAFAllocateResponse* self = CNATFWUNSAFAllocateResponse::NewLC(
       
    32         aTransactionID);
       
    33     CleanupStack::Pop(self);
       
    34     return self;
       
    35     }
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CNATFWUNSAFAllocateResponse::NewLC
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CNATFWUNSAFAllocateResponse*
       
    42 CNATFWUNSAFAllocateResponse::NewLC(
       
    43     const TNATFWUNSAFTransactionID& aTransactionID)
       
    44     {
       
    45     CNATFWUNSAFAllocateResponse* self =
       
    46         new (ELeave) CNATFWUNSAFAllocateResponse(aTransactionID);
       
    47     CleanupStack::PushL(self);
       
    48     return self;
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CNATFWUNSAFAllocateResponse::CreateL
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 CNATFWUNSAFMessage*
       
    56 CNATFWUNSAFAllocateResponse::CreateL(
       
    57     const TNATFWUNSAFTransactionID& aTransactionID)
       
    58     {
       
    59     return NewL(aTransactionID);
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CNATFWUNSAFAllocateResponse::CNATFWUNSAFAllocateResponse
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CNATFWUNSAFAllocateResponse::CNATFWUNSAFAllocateResponse(
       
    67     const TNATFWUNSAFTransactionID& aTransactionID) :
       
    68     CNATFWUNSAFMessage(aTransactionID)
       
    69     {
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CNATFWUNSAFAllocateResponse::~CNATFWUNSAFAllocateResponse
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 CNATFWUNSAFAllocateResponse::~CNATFWUNSAFAllocateResponse()
       
    77     {
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CNATFWUNSAFAllocateResponse::Type
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 CNATFWUNSAFMessage::TType CNATFWUNSAFAllocateResponse::Type() const
       
    85     {
       
    86     return CNATFWUNSAFMessage::EAllocateResponse;
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CNATFWUNSAFAllocateResponse::Validate
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 TBool CNATFWUNSAFAllocateResponse::Validate() const
       
    94     {
       
    95     return (HasAttribute(CNATFWUNSAFAttribute::ERelayAddress) &&
       
    96             HasAttribute(CNATFWUNSAFAttribute::EXorMappedAddress) &&
       
    97             HasAttribute(CNATFWUNSAFAttribute::ELifetime) &&
       
    98             HasAttribute(CNATFWUNSAFAttribute::EBandwidth) &&
       
    99             HasAttribute(CNATFWUNSAFAttribute::EMessageIntegrity));
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CNATFWUNSAFAllocateResponse::IsAllowed
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 TBool CNATFWUNSAFAllocateResponse::IsAllowed(TUint16 aAttributeType) const
       
   107     {
       
   108     return (aAttributeType == CNATFWUNSAFAttribute::ERelayAddress ||
       
   109             aAttributeType == CNATFWUNSAFAttribute::EXorMappedAddress ||
       
   110             aAttributeType == CNATFWUNSAFAttribute::ELifetime ||
       
   111             aAttributeType == CNATFWUNSAFAttribute::EBandwidth ||
       
   112             aAttributeType == CNATFWUNSAFAttribute::EMappedAddress ||
       
   113             aAttributeType == CNATFWUNSAFAttribute::EMessageIntegrity ||
       
   114             aAttributeType == CNATFWUNSAFAttribute::EFingerprint);
       
   115     }