bluetooth/btstack/l2cap/L2CapSDU.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 06 Jul 2010 15:33:04 +0300
changeset 32 f72906e669b4
parent 0 29b1cd4cb562
permissions -rw-r--r--
Revision: 201027 Kit: 2010127

// Copyright (c) 2004-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:
//

#ifndef L2CAPSDU_H_
#define L2CAPSDU_H_

#include <e32def.h>
#include <e32base.h>
#include <es_mbuf.h>

#include "L2CapPDU.h"

class CL2CapSDU;
class ML2CapSDUHandler
	{
public:
	virtual void ProcessFlushTimerExpiry(CL2CapSDU& aL2CapSDU) = 0;
	};



NONSHARABLE_CLASS(CL2CapSDU) : public CBase
	{
public:		
	// MBuf based descriptor creation.
	static CL2CapSDU* NewLC(RMBufChain& aSDUData,
                            ML2CapSDUHandler& aParent,
			                TUint16 aPDUSize,
                            TBool aIsBasicDataVersion = ETrue,
			                TUint16 aTimerDuration = KInfiniteFlush);
	static CL2CapSDU* NewL(RMBufChain& aSDUData,
		                   ML2CapSDUHandler& aParent,
			               TUint16 aPDUSize,
		                   TBool aIsBasicDataVersion = ETrue,
			               TUint16 aTimerDuration = KInfiniteFlush);

	static TInt FlushTimerExpired(TAny* aL2CapSDU);
	
	
	virtual ~CL2CapSDU();

	static TInt GetSDUOverhead(TBool aBasicMode);

	TBool GetPDU(HL2CapPDU*& aReturnedPDU);
	
	TBool IsSDUEmpty() const;
	TBool CurrentPDUIsFirstPDU();

	void StartFlushTimer(TUint16 aTimerDuration);
	
	TInt ChangeSDUSegmentation(TBool aIsBasicDataVersion, TUint16 aPDUSize);
#ifdef _DEBUG
	TInt DebugManualFlush();
#endif

		
private:
	CL2CapSDU(ML2CapSDUHandler& aParent, RMBufChain& aDataFrame, TUint16 aReassembledSDULength);
	CL2CapSDU(ML2CapSDUHandler& aParent);

	void ConstructL(RMBufChain& aSDUData, TBool aIsBasicDataVersion, TUint16 aTimerDuration, TUint16 aPDUSize); 
	TInt SegmentSDUIntoPDUs(RMBufChain& aSDUData, TBool aIsBasicDataVersion, TUint16 aPDUSize);
	void HandleFlushTimerExpired();

public:
	TDblQueLink iLink;
	
private:
	ML2CapSDUHandler& iParent;

	TDblQue<HL2CapPDU> iPDUs;
	TDblQueIter<HL2CapPDU> iCurrentPDU;

	TDeltaTimerEntry iFlushTimerEntry;
	TBool iFlushTimerRunning;
	
	RMBufChain iIncomingSDU;
	};


#endif