24
|
1 |
// Copyright (c) 2004-2010 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 interface
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
*/
|
|
21 |
|
|
22 |
#ifndef BCAIOCONTROLLER_H
|
|
23 |
#define BCAIOCONTROLLER_H
|
|
24 |
|
|
25 |
#include <e32base.h>
|
|
26 |
#include <c32comm.h>
|
|
27 |
#include <networking/bca.h>
|
|
28 |
#include <networking/bcafactory.h>
|
|
29 |
// for the constants for sending/blocking
|
|
30 |
#include <comms-infras/ss_flowbinders.h>
|
|
31 |
#include "MControllerObserver.h"
|
|
32 |
#include "Constants.h"
|
|
33 |
|
|
34 |
using namespace BasebandChannelAdaptation;
|
|
35 |
|
|
36 |
class CBttLogger;
|
|
37 |
class CSender;
|
|
38 |
class CReceiver;
|
|
39 |
class CBcaControl;
|
|
40 |
|
|
41 |
/**
|
|
42 |
|
|
43 |
@internalComponent
|
|
44 |
*/
|
|
45 |
void Panic(TRawIPNifPanic aPanic);
|
|
46 |
|
|
47 |
/**
|
|
48 |
|
|
49 |
@internalComponent
|
|
50 |
*/
|
|
51 |
typedef MBcaFactory* (*TNewBcaFactoryL)();
|
|
52 |
|
|
53 |
|
|
54 |
/**
|
|
55 |
@internalComponent
|
|
56 |
*/
|
|
57 |
class CBcaIoController : public CBase
|
|
58 |
{
|
|
59 |
public:
|
|
60 |
static CBcaIoController* NewL(MControllerObserver& aObserver, CBttLogger* aTheLogger);
|
|
61 |
~CBcaIoController();
|
|
62 |
|
|
63 |
void StartL();
|
|
64 |
void Stop(TInt aError = KErrNone);
|
|
65 |
ESock::MLowerDataSender::TSendResult Send(RMBufChain& aPdu);
|
|
66 |
void SendComplete();
|
|
67 |
|
|
68 |
inline CSender& Sender();
|
|
69 |
inline CReceiver& Receiver();
|
|
70 |
inline TUint Nsapi();
|
|
71 |
void SetBcaStackAndName(const TDesC& aBcaStack, const TDesC& aBcaName);
|
|
72 |
inline TPtrC BcaStack()const;
|
|
73 |
inline TPtrC BcaName()const;
|
|
74 |
inline MBca* Bca();
|
|
75 |
inline void SetBca(MBca* aBca);
|
|
76 |
inline void SetPort(const TDesC& aPortName);
|
|
77 |
inline TPtrC Port() const;
|
|
78 |
inline void SetIapId(TUint32 aIapId);
|
|
79 |
inline TUint32 IapId();
|
|
80 |
inline void BlockSending(void) { iFlowBlocked = ETrue; }
|
|
81 |
void ResumeSending();
|
|
82 |
|
|
83 |
// Get the NIF reference.
|
|
84 |
inline MControllerObserver& GetObserver() { return iObserver; }
|
|
85 |
|
|
86 |
#ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
|
|
87 |
// tag headers
|
|
88 |
void SetType(TUint16 aType);
|
|
89 |
void AddHeader(TDes8& aDes);
|
|
90 |
TUint16 RemoveHeader(RMBufChain& aPdu);
|
|
91 |
#endif // RAWIP_HEADER_APPENDED_TO_PACKETS
|
|
92 |
|
|
93 |
protected:
|
|
94 |
CBttLogger* iTheLogger;
|
|
95 |
TUint iMaxTxPacketSize;
|
|
96 |
TUint iMaxRxPacketSize;
|
|
97 |
|
|
98 |
private:
|
|
99 |
|
|
100 |
CBcaIoController(MControllerObserver& aObserver, CBttLogger* aTheLogger);
|
|
101 |
void ConstructL();
|
|
102 |
|
|
103 |
enum TSendState
|
|
104 |
{
|
|
105 |
EIdle,
|
|
106 |
ESending,
|
|
107 |
EShuttingDown
|
|
108 |
};
|
|
109 |
|
|
110 |
enum TInitialisationState
|
|
111 |
{
|
|
112 |
EStart,
|
|
113 |
EBcaController,
|
|
114 |
EInitialised
|
|
115 |
};
|
|
116 |
|
|
117 |
// Flow control flags
|
|
118 |
TSendState iSendState;
|
|
119 |
|
|
120 |
inline void SendState(TSendState aState) { iSendState = aState; }
|
|
121 |
|
|
122 |
|
|
123 |
// uplink flow control
|
|
124 |
TBool iFlowBlocked;
|
|
125 |
|
|
126 |
// Buffer control
|
|
127 |
inline TBool IsSendQueueEmpty() { return iSendQueue.IsEmpty(); }
|
|
128 |
inline TBool IsSendQueueFull() { return (iNumPacketsInSendQueue >= iMaxSendQueueLen) ? ETrue : EFalse; }
|
|
129 |
|
|
130 |
inline void AppendToSendQueue(RMBufChain& aPdu)
|
|
131 |
{
|
|
132 |
iSendQueue.Append(aPdu);
|
|
133 |
iNumPacketsInSendQueue++;
|
|
134 |
}
|
|
135 |
|
|
136 |
inline TBool RemoveFromSendQueue(RMBufChain& aPdu)
|
|
137 |
{
|
|
138 |
TBool ret = iSendQueue.Remove(aPdu);
|
|
139 |
if(ret)
|
|
140 |
{
|
|
141 |
iNumPacketsInSendQueue--;
|
|
142 |
}
|
|
143 |
return ret;
|
|
144 |
}
|
|
145 |
|
|
146 |
/** The internal packet buffer */
|
|
147 |
RMBufPktQ iSendQueue;
|
|
148 |
/** The maximum number of packets that we want in an internal queue */
|
|
149 |
TUint iMaxSendQueueLen;
|
|
150 |
/** Current number of packets in the internal packet buffer */
|
|
151 |
TInt iNumPacketsInSendQueue;
|
|
152 |
|
|
153 |
MControllerObserver& iObserver;
|
|
154 |
|
|
155 |
// Unowned data.
|
|
156 |
/** Pointer to the BCA */
|
|
157 |
MBca* iMBca;
|
|
158 |
|
|
159 |
/** used to send data*/
|
|
160 |
CSender* iSender;
|
|
161 |
/** used to receive data*/
|
|
162 |
CReceiver* iReceiver;
|
|
163 |
/** used to load, open and close the BCA*/
|
|
164 |
CBcaControl* iLoader;
|
|
165 |
/** IAP ID used to open CommDB*/
|
|
166 |
TUint32 iIapId;
|
|
167 |
/** Bca name*/
|
|
168 |
TPtrC iBcaName;
|
|
169 |
/** Bca Stack*/
|
|
170 |
TPtrC iBcaStack;
|
|
171 |
/** CommPort Name*/
|
|
172 |
TPtrC iCommPort;
|
|
173 |
|
|
174 |
|
|
175 |
};
|
|
176 |
|
|
177 |
inline CSender& CBcaIoController::Sender()
|
|
178 |
/**
|
|
179 |
* Returns reference to CSender object
|
|
180 |
*
|
|
181 |
* @return iSender The CSender reference
|
|
182 |
*/
|
|
183 |
{
|
|
184 |
return *iSender;
|
|
185 |
}
|
|
186 |
|
|
187 |
inline CReceiver& CBcaIoController::Receiver()
|
|
188 |
/**
|
|
189 |
* Returns reference to CReceiver object
|
|
190 |
*
|
|
191 |
* @return iReceiver The CReceiver reference
|
|
192 |
*/
|
|
193 |
{
|
|
194 |
return *iReceiver;
|
|
195 |
}
|
|
196 |
|
|
197 |
/** returns the BCA Stack*/
|
|
198 |
inline TPtrC CBcaIoController::BcaStack()const
|
|
199 |
{
|
|
200 |
return iBcaStack;
|
|
201 |
}
|
|
202 |
|
|
203 |
/** returns the BCA name*/
|
|
204 |
inline TPtrC CBcaIoController::BcaName()const
|
|
205 |
{
|
|
206 |
return iBcaName;
|
|
207 |
}
|
|
208 |
|
|
209 |
/** retrurns the BCA pointer.*/
|
|
210 |
inline MBca* CBcaIoController::Bca()
|
|
211 |
{
|
|
212 |
return iMBca;
|
|
213 |
}
|
|
214 |
/** sets the BCA pointer.
|
|
215 |
|
|
216 |
* @param aBca BCA pointer.
|
|
217 |
*/
|
|
218 |
inline void CBcaIoController::SetBca(MBca* aBca)
|
|
219 |
{
|
|
220 |
iMBca = aBca;
|
|
221 |
}
|
|
222 |
|
|
223 |
/** sets the IAP ID
|
|
224 |
|
|
225 |
* @param aIapId IAP ID to be set.
|
|
226 |
*/
|
|
227 |
inline void CBcaIoController::SetIapId(TUint32 aIapId)
|
|
228 |
{
|
|
229 |
iIapId = aIapId;
|
|
230 |
}
|
|
231 |
|
|
232 |
/** returns the IAP ID*/
|
|
233 |
inline TUint32 CBcaIoController::IapId()
|
|
234 |
{
|
|
235 |
return iIapId;
|
|
236 |
}
|
|
237 |
|
|
238 |
/** sets the port name
|
|
239 |
|
|
240 |
* @param aPortName port name to be set.
|
|
241 |
*/
|
|
242 |
inline void CBcaIoController::SetPort(const TDesC& aPortName)
|
|
243 |
{
|
|
244 |
iCommPort.Set(aPortName);
|
|
245 |
}
|
|
246 |
|
|
247 |
/** returns the port name*/
|
|
248 |
inline TPtrC CBcaIoController::Port()const
|
|
249 |
{
|
|
250 |
return iCommPort;
|
|
251 |
}
|
|
252 |
|
|
253 |
/** class used to load, open and shutdown the BCA and also start and shutdown the NIF.
|
|
254 |
@internalComponent
|
|
255 |
*/
|
|
256 |
class CBcaControl : public CActive
|
|
257 |
{
|
|
258 |
public:
|
|
259 |
CBcaControl(CBcaIoController& aObserver, CBttLogger* aTheLogger);
|
|
260 |
~CBcaControl();
|
|
261 |
public:
|
|
262 |
void StartLoadL();
|
|
263 |
void ShutdownBca(TInt aError);
|
|
264 |
inline MBca* Bca();
|
|
265 |
protected:
|
|
266 |
// Inherited from CActive.
|
|
267 |
virtual void RunL();
|
|
268 |
virtual void DoCancel();
|
|
269 |
private: // Unowned data.
|
|
270 |
CBcaIoController& iObserver;
|
|
271 |
CBttLogger* iTheLogger;
|
|
272 |
private:
|
|
273 |
enum TBcaState
|
|
274 |
{
|
|
275 |
/** Bca ready to start */
|
|
276 |
EIdling,
|
|
277 |
/** Bca to be closed*/
|
|
278 |
EClosing,
|
|
279 |
/** Bca IAP is set*/
|
|
280 |
EIAPSet,
|
|
281 |
/** Bca stack is set*/
|
|
282 |
EBcaStackSet,
|
|
283 |
/** Bca channel is open */
|
|
284 |
EBcaOpened
|
|
285 |
};
|
|
286 |
|
|
287 |
private:
|
|
288 |
|
|
289 |
/** BCA owned by NIF*/
|
|
290 |
MBca* iMBca;
|
|
291 |
/** used to load library*/
|
|
292 |
TAutoClose<RLibrary> iBcaDll;
|
|
293 |
/** BCA state*/
|
|
294 |
TBcaState iState;
|
|
295 |
/** NIF shut down error*/
|
|
296 |
TInt iError;
|
|
297 |
};
|
|
298 |
|
|
299 |
/** returns the BCA pointer. */
|
|
300 |
inline MBca* CBcaControl::Bca()
|
|
301 |
{
|
|
302 |
return iMBca;
|
|
303 |
}
|
|
304 |
|
|
305 |
#endif // BCAIOCONTROLLER_H
|
|
306 |
|