bluetoothcommsprofiles/btpan/bnep/RBnepSetupConnectionResponseControl.cpp
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalComponent
       
    19 */
       
    20 
       
    21 #include <bluetooth/logger.h>
       
    22 #include <es_sock.h>
       
    23 #include "RBnepSetupConnectionResponseControl.h"
       
    24 
       
    25 #ifdef __FLOG_ACTIVE
       
    26 _LIT8(KLogComponent, LOG_COMPONENT_PAN_BNEP);
       
    27 #endif
       
    28 
       
    29 /**
       
    30    Retrieve the value from a connection setup response 
       
    31    @internalComponent
       
    32 */
       
    33 void RBnepSetupConnectionResponseControl::ConnectionSetupResponseL (TBnepSetupConnectionResponseMessage& aResponse)
       
    34     {
       
    35     LOG_FUNC
       
    36     if( (First()->Ptr() + KSetupResponseFieldOffset + KSizeOfBnepResponseCode) <= (First()->EndPtr()) )
       
    37         {
       
    38         aResponse = static_cast<TBnepSetupConnectionResponseMessage>(BigEndian::Get16((First()->Ptr() + KSetupResponseFieldOffset)));
       
    39         }
       
    40     else
       
    41         {
       
    42         User::Leave(KErrOverflow);
       
    43         }
       
    44     }
       
    45 
       
    46 /**
       
    47    Allocate the memory necessary for a response 
       
    48    @internalComponent
       
    49 */
       
    50 void RBnepSetupConnectionResponseControl::InitL ()
       
    51     {
       
    52     LOG_FUNC
       
    53     AllocL(KMaxSizeOfSetupResponse);
       
    54     }
       
    55 
       
    56 /**
       
    57    Set the value in a connection setup response 
       
    58    @internalComponent
       
    59 */
       
    60 void RBnepSetupConnectionResponseControl::SetConnectionSetupResponseL (TBnepSetupConnectionResponseMessage aResponse)
       
    61     {
       
    62     LOG_FUNC
       
    63     if(KMaxSizeOfSetupResponse <= Length())
       
    64         {
       
    65         TPckgBuf<TUint8> controlType(static_cast<TUint8>(EBnepSetupConnectionResponseMessage));
       
    66         CopyIn(controlType, KControlTypeOffset);
       
    67         TBuf8<sizeof(TUint16)> response;
       
    68         response.SetMax();
       
    69         BigEndian::Put16(&response[0], static_cast<TUint16>(aResponse));
       
    70         CopyIn(response,KSetupResponseFieldOffset);
       
    71         TrimEnd(KSetupResponseFieldOffset + sizeof(TUint16));
       
    72         DUMPFRAME(_L8("RBnepSetupConnectionResponseControl"));
       
    73         }
       
    74     else
       
    75         {
       
    76         User::Leave(KErrUnderflow);
       
    77         }
       
    78     }
       
    79 
       
    80