|
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 // Defines the interface to the BCA & flow control. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 #ifndef BCACONTROLLER_H |
|
23 #define BCACONTROLLER_H |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <c32comm.h> |
|
27 |
|
28 #include "MControllerObserver.h" |
|
29 #include "bttlog.h" |
|
30 #include "Constants.h" |
|
31 |
|
32 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS |
|
33 #include "IPTagHeader.h" |
|
34 #endif // RAWIP_HEADER_APPENDED_TO_PACKETS |
|
35 |
|
36 class CBttLogger; |
|
37 |
|
38 /** |
|
39 @internalComponent |
|
40 */ |
|
41 class CBcaController : public CBase |
|
42 { |
|
43 public: |
|
44 CBcaController(MControllerObserver& aObserver, CBttLogger* aTheLogger); |
|
45 void BaseConstructL(); |
|
46 ~CBcaController(); |
|
47 |
|
48 public: // Flow Control |
|
49 void UpdateInternalFlowFlag(TFlowControl aValue); |
|
50 void UpdateContextStateFlag(TBool aValue); |
|
51 TBool IsTxPossible(); |
|
52 |
|
53 public: |
|
54 virtual void StartL() = 0; |
|
55 virtual void Stop(TInt aError = KErrNone) = 0; |
|
56 |
|
57 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS |
|
58 public: //tag headers |
|
59 void SetType(TUint16 aType); |
|
60 void AddHeader(TDes8& aDes); |
|
61 TUint16 RemoveHeader(RMBufChain& aPdu); |
|
62 #endif // RAWIP_HEADER_APPENDED_TO_PACKETS |
|
63 |
|
64 public: // Process Down/Up stack data packets |
|
65 void Process(TDesC8& aPdu); |
|
66 TInt Send(RMBufChain& aPdu); |
|
67 void SendComplete(); |
|
68 // Get the NIF reference. |
|
69 inline MControllerObserver& GetObserver(); |
|
70 protected: |
|
71 virtual void BcaSend(RMBufChain& aPdu) = 0; |
|
72 virtual void BcaProcess(TDesC8& aPdu) = 0; |
|
73 virtual void BcaSendComplete() = 0; |
|
74 virtual TInt BcaSendBufferLength() = 0; |
|
75 |
|
76 protected: |
|
77 enum TSendState |
|
78 { |
|
79 EIdle, |
|
80 ESending, |
|
81 EShuttingDown |
|
82 }; |
|
83 |
|
84 enum TInitialisationState |
|
85 { |
|
86 EStart, |
|
87 EBcaController, |
|
88 EInitialised |
|
89 }; |
|
90 |
|
91 inline TInt GetSendState(); |
|
92 inline void SendState(TSendState aState); |
|
93 |
|
94 private: // Flow Control |
|
95 void ResumeSending(); |
|
96 //Buffer control |
|
97 TBool IsSendQueueEmpty(); |
|
98 TBool IsSendQueueFull(); |
|
99 void AppendToSendQueue(RMBufChain& aPdu); |
|
100 TBool RemoveFromSendQueue(RMBufChain& aPdu); |
|
101 void EmptySendQueue(); |
|
102 |
|
103 private: // Unowned data. |
|
104 MControllerObserver& iObserver; |
|
105 protected: |
|
106 CBttLogger* iTheLogger; |
|
107 |
|
108 private: |
|
109 // Flow control flags |
|
110 TFlowControl iTxFlowControl; |
|
111 TBool iTxContextActive; |
|
112 TSendState iSendState; |
|
113 |
|
114 /** The internal packet buffer */ |
|
115 RMBufPktQ iSendQueue; |
|
116 /** The maximum number of packets that we want in an internal queue */ |
|
117 TInt iMaxSendQueueLen; |
|
118 /** Current number of packets in the internal packet buffer */ |
|
119 TInt iNumPacketsInSendQueue; |
|
120 |
|
121 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS |
|
122 CIPTagHeader* iIPTagHeader; |
|
123 #endif // RAWIP_HEADER_APPENDED_TO_PACKETS |
|
124 }; |
|
125 |
|
126 void CBcaController::SendState(TSendState aState) |
|
127 { |
|
128 iSendState = aState; |
|
129 } |
|
130 |
|
131 TInt CBcaController::GetSendState() |
|
132 { |
|
133 return iSendState; |
|
134 } |
|
135 |
|
136 |
|
137 MControllerObserver& CBcaController::GetObserver() |
|
138 { |
|
139 return iObserver; |
|
140 } |
|
141 |
|
142 #endif // BCACONTROLLER_H |