0
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 the License "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 |
#include <iscapi.h> //For ISC
|
|
21 |
#include <iscnokiadefinitions.h> //isc definitions
|
|
22 |
#include <pn_const.h>
|
|
23 |
#ifndef NCP_COMMON_BRIDGE_FAMILY
|
|
24 |
#include <nsisi.h>
|
|
25 |
#endif
|
|
26 |
#include <tisi.h> //for isimessage
|
|
27 |
#include <pipeisi.h> //pipe
|
|
28 |
#include <pipe_sharedisi.h> //pipe
|
|
29 |
#include "cmodematpipecontroller.h"
|
|
30 |
#include "cmodemathandler.h"
|
|
31 |
#include <at_modemisi.h> //redirectreq error codes
|
|
32 |
#include "modemattrace.h"
|
|
33 |
#include "cmodematsrv.h"
|
|
34 |
|
|
35 |
const TInt KInvalidPipeHandle = -1;
|
|
36 |
#ifndef NCP_COMMON_BRIDGE_FAMILY
|
|
37 |
const TUint8 PEP_COMM_IND_ID_ESCAPE(0x07);
|
|
38 |
const TInt KInvalidDteId = -1;
|
|
39 |
const TUint8 KFiller = 0;
|
|
40 |
const TUint8 KDefaultTrId(0);
|
|
41 |
const TUint8 KTaskIdQuerySize(20);
|
|
42 |
#endif
|
|
43 |
|
|
44 |
CModemAtPipeController* CModemAtPipeController::NewL( RIscApi& aIscApi,
|
|
45 |
TUint& aObjId,
|
|
46 |
CModemAtHandler& aHandler )
|
|
47 |
{
|
|
48 |
CModemAtPipeController* self = new (ELeave) CModemAtPipeController( aIscApi,aObjId, aHandler );
|
|
49 |
CleanupStack::PushL( self );
|
|
50 |
self->ConstructL();
|
|
51 |
CleanupStack::Pop( self );
|
|
52 |
return self;
|
|
53 |
}
|
|
54 |
|
|
55 |
void CModemAtPipeController::ConstructL()
|
|
56 |
{
|
|
57 |
C_TRACE (( _T("CModemAtPipeController::ConstructL()") ));
|
|
58 |
}
|
|
59 |
|
|
60 |
CModemAtPipeController::~CModemAtPipeController()
|
|
61 |
{
|
|
62 |
C_TRACE((_L(">>CModemAtPipeController::~CModemAtPipeController()")));
|
|
63 |
if( iSchedulerWait )
|
|
64 |
{
|
|
65 |
C_TRACE((_L("CModemAtPipeController::~CModemAtPipeController() iSchedulerWait->Stop")));
|
|
66 |
iSchedulerWait->AsyncStop();
|
|
67 |
delete iSchedulerWait;
|
|
68 |
iSchedulerWait = NULL;
|
|
69 |
}
|
|
70 |
C_TRACE((_L("<<CModemAtPipeController::~CModemAtPipeController()")));
|
|
71 |
}
|
|
72 |
|
|
73 |
CModemAtPipeController::CModemAtPipeController( RIscApi& aIscApi,
|
|
74 |
TUint& aObjId,
|
|
75 |
CModemAtHandler& aHandler ) :
|
|
76 |
iIscApi( aIscApi ),
|
|
77 |
iModemAtObjId( aObjId ),
|
|
78 |
iModemAtDevId( THIS_DEVICE ),
|
|
79 |
iPipeHandle( KInvalidPipeHandle ),
|
|
80 |
iDataportDevId( 0 ),
|
|
81 |
iDataportObjId( 0 ),
|
|
82 |
iCellmoDevId( 0 ),
|
|
83 |
iCellmoObjId( 0 ),
|
|
84 |
iAtHandler( aHandler ),
|
|
85 |
iSchedulerWait( NULL ),
|
|
86 |
iDteId( KInitialDteId )
|
|
87 |
{
|
|
88 |
C_TRACE (( _T("CModemAtPipeController::CModemAtPipeController()") ));
|
|
89 |
}
|
|
90 |
|
|
91 |
|
|
92 |
#ifndef NCP_COMMON_BRIDGE_FAMILY
|
|
93 |
void CModemAtPipeController::HandleNameServiceMessage( const TIsiReceiveC& aReceivedMessage )
|
|
94 |
{
|
|
95 |
C_TRACE (( _T("CModemAtPipeController::HandleNameServiceMessage()") ));
|
|
96 |
switch( aReceivedMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) )
|
|
97 |
{
|
|
98 |
case PNS_NAME_QUERY_RESP:
|
|
99 |
C_TRACE(_L("PNS_NAME_QUERY_RESP"));
|
|
100 |
HandleNameQueryResp( aReceivedMessage );
|
|
101 |
break;
|
|
102 |
|
|
103 |
case PNS_NAME_ADD_IND:
|
|
104 |
C_TRACE(_L("PNS_NAME_ADD_IND"));
|
|
105 |
HandleNameAddInd( aReceivedMessage );
|
|
106 |
break;
|
|
107 |
|
|
108 |
case PNS_NAME_REMOVE_IND:
|
|
109 |
C_TRACE(_L("PNS_NAME_REMOVE_IND"));
|
|
110 |
HandleNameRemoveInd( aReceivedMessage );
|
|
111 |
break;
|
|
112 |
|
|
113 |
default:
|
|
114 |
ASSERT_PANIC_ALWAYS( EFalse ) ;
|
|
115 |
break;
|
|
116 |
}
|
|
117 |
}
|
|
118 |
|
|
119 |
void CModemAtPipeController::HandlePipeServiceMessage( const TIsiReceiveC& aReceivedMessage)
|
|
120 |
{
|
|
121 |
C_TRACE (( _T("CModemAtPipeController::HandlePipeServiceMessage()") ));
|
|
122 |
switch( aReceivedMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) )
|
|
123 |
{
|
|
124 |
case PNS_PIPE_CREATE_RESP:
|
|
125 |
C_TRACE(_L("PIPE CREATE RESP"));
|
|
126 |
HandlePipeCreateResp( aReceivedMessage );
|
|
127 |
break;
|
|
128 |
|
|
129 |
case PNS_PIPE_REDIRECT_RESP:
|
|
130 |
C_TRACE(_L("PNS_PIPE_REDIRECT_RESP"));
|
|
131 |
HandlePipeRedirectResp( aReceivedMessage );
|
|
132 |
break;
|
|
133 |
|
|
134 |
case PNS_PIPE_REMOVE_RESP:
|
|
135 |
C_TRACE(_L("PNS_PIPE_REMOVE_RESP"));
|
|
136 |
HandlePipeRemoveResp( aReceivedMessage );
|
|
137 |
break;
|
|
138 |
|
|
139 |
case PNS_PIPE_ENABLE_RESP:
|
|
140 |
C_TRACE(_L("PNS_PIPE_ENABLE_RESP"));
|
|
141 |
HandlePipeEnabledResp( aReceivedMessage );
|
|
142 |
break;
|
|
143 |
|
|
144 |
case PNS_PEP_STATUS_IND :
|
|
145 |
C_TRACE(_L("PNS_PEP_STATUS_IND "));
|
|
146 |
HandlePepStatusInd( aReceivedMessage );
|
|
147 |
break;
|
|
148 |
|
|
149 |
default:
|
|
150 |
ASSERT_PANIC_ALWAYS( EFalse );
|
|
151 |
break;
|
|
152 |
}
|
|
153 |
}
|
|
154 |
|
|
155 |
|
|
156 |
TUint CModemAtPipeController::MatchDataportName( TUint aName)
|
|
157 |
{
|
|
158 |
|
|
159 |
/*
|
|
160 |
See from dataport:
|
|
161 |
void CDpMif::SendNameAddReqL():
|
|
162 |
|
|
163 |
case KDpDialUpPort:
|
|
164 |
case KDpPort4:
|
|
165 |
case KDpPort5:
|
|
166 |
{
|
|
167 |
messageData.Append( aUnit ); //name
|
|
168 |
messageData.Append( KDpPadding ); //name
|
|
169 |
messageData.Append( PN_PEP_TYPE_COMM ); //name
|
|
170 |
messageData.Append( PN_PIPE ); //name
|
|
171 |
break;
|
|
172 |
Only 3 last bytes count
|
|
173 |
*/
|
|
174 |
|
|
175 |
TUint KDpDialUpPort = 1;
|
|
176 |
TUint KDpPadding = 0;
|
|
177 |
TUint dataportName(0);
|
|
178 |
dataportName = (
|
|
179 |
( (TUint)PN_PIPE ) |
|
|
180 |
( (TUint)PN_PEP_TYPE_COMM << 8 ) |
|
|
181 |
( KDpPadding << 16) |
|
|
182 |
( KDpDialUpPort << 24 )
|
|
183 |
);
|
|
184 |
|
|
185 |
if( aName == dataportName )
|
|
186 |
{
|
|
187 |
return ETrue;
|
|
188 |
}
|
|
189 |
return EFalse;
|
|
190 |
}
|
|
191 |
|
|
192 |
void CModemAtPipeController::HandleNameAddInd( const TIsiReceiveC& aReceivedMessage )
|
|
193 |
{
|
|
194 |
C_TRACE (( _T("CModemAtPipeController::HandleNameAddInd()") ));
|
|
195 |
TInt count = aReceivedMessage.Get16bit( ISI_HEADER_SIZE + PNS_NAME_ADD_IND_OFFSET_MATCHESINMSG );
|
|
196 |
|
|
197 |
C_TRACE((_L("Count %d") ,count ));
|
|
198 |
TUint name = 0;
|
|
199 |
|
|
200 |
for( TInt i = 1; i <= count ; i++ )
|
|
201 |
{
|
|
202 |
name = aReceivedMessage.Get32bit(ISI_HEADER_SIZE+PNS_NAME_ADD_IND_OFFSET_NAMEENTRYTBL * i);
|
|
203 |
C_TRACE((_L("name [%d] 0x%x"), i ,name));
|
|
204 |
|
|
205 |
if( MatchDataportName(name) )
|
|
206 |
{
|
|
207 |
iDataportDevId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE +
|
|
208 |
PNS_NAME_ADD_IND_OFFSET_NAMEENTRYTBL * i + PN_NAME_SRV_ITEM_STR_OFFSET_DEV );
|
|
209 |
iDataportObjId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE +
|
|
210 |
PNS_NAME_ADD_IND_OFFSET_NAMEENTRYTBL * i + PN_NAME_SRV_ITEM_STR_OFFSET_OBJ);
|
|
211 |
|
|
212 |
if( iDataportDevId == THIS_DEVICE )
|
|
213 |
{
|
|
214 |
C_TRACE((_L("CREATE PIPE FROM DATAPORT when ATEXT plugins connect (devid %x o-bjid %x) "),iDataportDevId,iDataportObjId));
|
|
215 |
}
|
|
216 |
else
|
|
217 |
{
|
|
218 |
C_TRACE((_L("ERROR: PIPE not Created due to unmatching DevId: 0x%x or ObjId 0x%x"),iDataportDevId, iDataportObjId ));
|
|
219 |
TRACE_ASSERT_ALWAYS;
|
|
220 |
}
|
|
221 |
}
|
|
222 |
}
|
|
223 |
}
|
|
224 |
|
|
225 |
void CModemAtPipeController::HandleNameRemoveInd( const TIsiReceiveC& aReceivedMessage )
|
|
226 |
{
|
|
227 |
C_TRACE (( _T("CModemAtPipeController::HandleNameRemoveInd()") ));
|
|
228 |
TInt count = aReceivedMessage.Get16bit( ISI_HEADER_SIZE + PNS_NAME_REMOVE_IND_OFFSET_MATCHESINMSG );
|
|
229 |
|
|
230 |
C_TRACE((_L("Count %d") ,count ));
|
|
231 |
TUint name = 0;
|
|
232 |
|
|
233 |
for( TInt i = 1; i <= count ; i++ )
|
|
234 |
{
|
|
235 |
name = aReceivedMessage.Get32bit(ISI_HEADER_SIZE + PNS_NAME_REMOVE_IND_OFFSET_NAMEENTRYTBL * i);
|
|
236 |
C_TRACE((_L("name [%d] 0x%x"), i ,name));
|
|
237 |
|
|
238 |
if( MatchDataportName(name) )
|
|
239 |
{
|
|
240 |
TUint devId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE +
|
|
241 |
PNS_NAME_REMOVE_IND_OFFSET_NAMEENTRYTBL * i + PN_NAME_SRV_ITEM_STR_OFFSET_DEV );
|
|
242 |
TUint objId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE +
|
|
243 |
PNS_NAME_REMOVE_IND_OFFSET_NAMEENTRYTBL * i + PN_NAME_SRV_ITEM_STR_OFFSET_OBJ);
|
|
244 |
|
|
245 |
if( iDataportDevId == devId && iDataportObjId == objId )
|
|
246 |
{
|
|
247 |
C_TRACE((_L("Dataport removed from name service (devid %x o-bjid %x) "),iDataportDevId,iDataportObjId));
|
|
248 |
iDataportDevId = 0;
|
|
249 |
iDataportObjId = 0;
|
|
250 |
}
|
|
251 |
else
|
|
252 |
{
|
|
253 |
C_TRACE((_L("Unused dataport removed from name service. DevId: 0x%x or ObjId 0x%x"), iDataportDevId, iDataportObjId ));
|
|
254 |
TRACE_ASSERT_ALWAYS;
|
|
255 |
}
|
|
256 |
}
|
|
257 |
}
|
|
258 |
}
|
|
259 |
|
|
260 |
|
|
261 |
void CModemAtPipeController::HandleNameQueryResp( const TIsiReceiveC& aReceivedMessage )
|
|
262 |
{
|
|
263 |
C_TRACE((_L("CModemAtPipeHandler::HandleNameQueryResp")));
|
|
264 |
|
|
265 |
TInt count = aReceivedMessage.Get16bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_RESP_OFFSET_MATCHESINMSG );
|
|
266 |
C_TRACE((_L("Count d%d"), count ));
|
|
267 |
TInt name = 0;
|
|
268 |
TBool found = EFalse;
|
|
269 |
|
|
270 |
for( TInt i = 0; i < count ; i++ )
|
|
271 |
{
|
|
272 |
name = aReceivedMessage.Get32bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_RESP_OFFSET_NAMEENTRYTBL * i );
|
|
273 |
C_TRACE((_L("name [%d]%x"),i ,name ));
|
|
274 |
if(name == PN_AT_MODEM)
|
|
275 |
{
|
|
276 |
iCellmoDevId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE +
|
|
277 |
PNS_NAME_QUERY_RESP_OFFSET_NAMEENTRYTBL * i + PN_NAME_SRV_ITEM_STR_OFFSET_DEV );
|
|
278 |
iCellmoObjId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE +
|
|
279 |
PNS_NAME_QUERY_RESP_OFFSET_NAMEENTRYTBL * i + PN_NAME_SRV_ITEM_STR_OFFSET_OBJ );
|
|
280 |
found = ETrue;
|
|
281 |
C_TRACE((_L("devid %x objid %x"),iCellmoDevId,iCellmoObjId));
|
|
282 |
}
|
|
283 |
}
|
|
284 |
|
|
285 |
if( !found )
|
|
286 |
{
|
|
287 |
TRACE_ASSERT_ALWAYS;
|
|
288 |
User::Panic( _L("NO AT-MODEM"), KErrNotFound );
|
|
289 |
}
|
|
290 |
}
|
|
291 |
|
|
292 |
|
|
293 |
|
|
294 |
void CModemAtPipeController::SendCreatePipeMessage( const TUint8 aDevId, const TUint8 aObjId )
|
|
295 |
{
|
|
296 |
C_TRACE (( _T("CModemAtPipeController::SendCreatePipeMessage() DevId: 0x%x ObjId: 0x%x"), aDevId, aObjId ));
|
|
297 |
HBufC8* message = HBufC8::New( ISI_HEADER_SIZE + SIZE_PNS_PIPE_CREATE_REQ );
|
|
298 |
TRACE_ASSERT(message);
|
|
299 |
|
|
300 |
TPtr8 messageptr = message->Des();
|
|
301 |
TIsiSend isimessage( messageptr, ISI_HEADER_SIZE + SIZE_PNS_PIPE_CREATE_REQ );
|
|
302 |
isimessage.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_PIPE );
|
|
303 |
|
|
304 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_CREATE_REQ_OFFSET_UTID, 0);
|
|
305 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_CREATE_REQ_OFFSET_SUBFUNCTION, PNS_PIPE_CREATE_REQ );
|
|
306 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_CREATE_REQ_OFFSET_STATEAFTERCREATION ,PN_PIPE_DISABLE );
|
|
307 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_CREATE_REQ_OFFSET_PRIORITY ,0 );
|
|
308 |
|
|
309 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_CREATE_REQ_OFFSET_FIRSTPEPDEV, aDevId );
|
|
310 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_CREATE_REQ_OFFSET_FIRSTPEPOBJ, aObjId );
|
|
311 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_CREATE_REQ_OFFSET_FIRSTPEPTYPE, PN_PEP_TYPE_COMMON );
|
|
312 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_CREATE_REQ_OFFSET_FILLERBYTE1, KFiller );
|
|
313 |
|
|
314 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_CREATE_REQ_OFFSET_SECONDPEPDEV, THIS_DEVICE );
|
|
315 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_CREATE_REQ_OFFSET_SECONDPEPOBJ, iModemAtObjId );
|
|
316 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_CREATE_REQ_OFFSET_SECONDPEPTYPE, PN_PEP_TYPE_COMMON );
|
|
317 |
isimessage.Complete();
|
|
318 |
|
|
319 |
C_TRACE(_L("Created ISI-message"));
|
|
320 |
DUMP_MESSAGE( messageptr );
|
|
321 |
TInt retVal = iIscApi.Send( messageptr );
|
|
322 |
ASSERT_PANIC_ALWAYS( retVal == KErrNone );
|
|
323 |
delete message;
|
|
324 |
}
|
|
325 |
|
|
326 |
|
|
327 |
void CModemAtPipeController::HandlePipeCreateResp( const TIsiReceiveC& aReceivedMessage )
|
|
328 |
{
|
|
329 |
C_TRACE (( _T("CModemAtPipeController::HandlePipeCreateResp()") ));
|
|
330 |
TInt error = aReceivedMessage.Get8bit(ISI_HEADER_SIZE + PNS_PIPE_CREATE_RESP_OFFSET_ERRORCODE );
|
|
331 |
C_TRACE((_L("Pipe create resp: %d"), error ));
|
|
332 |
TRACE_ASSERT( iDteId != KInitialDteId );
|
|
333 |
|
|
334 |
if( error == PN_PIPE_NO_ERROR)
|
|
335 |
{
|
|
336 |
iPipeHandle = aReceivedMessage.Get8bit( ISI_HEADER_SIZE +
|
|
337 |
PNS_PIPE_CREATE_RESP_OFFSET_PIPEHANDLE );
|
|
338 |
C_TRACE( (_L("handle %d"), iPipeHandle ));
|
|
339 |
iPipeTable[iDteId].iHandle = iPipeHandle;
|
|
340 |
iPipeTable[iDteId].iFirstDevId = iDataportDevId;
|
|
341 |
iPipeTable[iDteId].iFirstObjId = iDataportObjId;
|
|
342 |
iPipeTable[iDteId].iSecondDevId = THIS_DEVICE;
|
|
343 |
iPipeTable[iDteId].iSecondObjId = iModemAtObjId;
|
|
344 |
ChangePipeState( iDteId, TPipeInfo::EPipeCreated );
|
|
345 |
iPipeHandle = KInvalidPipeHandle;
|
|
346 |
iDteId = KInitialDteId;
|
|
347 |
}
|
|
348 |
else
|
|
349 |
{
|
|
350 |
C_TRACE (( _T("iPipeHandle == KInvalidPipeHandle ")));
|
|
351 |
iPipeTable[iDteId].iHandle = KInvalidPipeHandle;
|
|
352 |
iPipeTable[iDteId].iFirstDevId = 0;
|
|
353 |
iPipeTable[iDteId].iFirstObjId = 0;
|
|
354 |
iPipeTable[iDteId].iSecondDevId = 0;
|
|
355 |
iPipeTable[iDteId].iSecondObjId = 0;
|
|
356 |
ChangePipeState( iDteId, TPipeInfo::EPipeNoPipe );
|
|
357 |
ASSERT_ALWAYS;
|
|
358 |
}
|
|
359 |
}
|
|
360 |
|
|
361 |
void CModemAtPipeController::LinkDteIdToPipe( const TUint8 aDteId )
|
|
362 |
{
|
|
363 |
C_TRACE (( _T("CModemAtPipeController::LinkDteIdToPipe(0x%x)"), aDteId ));
|
|
364 |
TRACE_ASSERT( aDteId < KMaxDteIdCount );
|
|
365 |
iDteId = aDteId;
|
|
366 |
if( iDataportDevId == THIS_DEVICE )
|
|
367 |
{
|
|
368 |
C_TRACE((_L("CREATE PIPE FROM DATAPORT (plugins are connecting) (devid %x o-bjid %x) "),iDataportDevId,iDataportObjId));
|
|
369 |
SendCreatePipeMessage( iDataportDevId, iDataportObjId );
|
|
370 |
}
|
|
371 |
else
|
|
372 |
{
|
|
373 |
C_TRACE((_L("Dataport has not been created (devid %x o-bjid %x) "), iDataportDevId, iDataportObjId ));
|
|
374 |
C_TRACE (( _T("iPipeHandle == KInvalidPipeHandle ")));
|
|
375 |
iPipeTable[aDteId].iHandle = KInvalidPipeHandle;
|
|
376 |
iPipeTable[aDteId].iFirstDevId = 0;
|
|
377 |
iPipeTable[aDteId].iFirstObjId = 0;
|
|
378 |
iPipeTable[aDteId].iSecondDevId = 0;
|
|
379 |
iPipeTable[aDteId].iSecondObjId = 0;
|
|
380 |
ChangePipeState( aDteId, TPipeInfo::EPipeNoPipe );
|
|
381 |
}
|
|
382 |
}
|
|
383 |
|
|
384 |
|
|
385 |
void CModemAtPipeController::HandlePipeRemoveResp( const TIsiReceiveC& aReceivedMessage )
|
|
386 |
{
|
|
387 |
C_TRACE (( _T(">>CModemAtPipeController::HandlePipeRemoveResp()") ));
|
|
388 |
TInt error = aReceivedMessage.Get8bit( ISI_HEADER_SIZE +
|
|
389 |
PNS_PIPE_REMOVE_RESP_OFFSET_ERRORCODE );
|
|
390 |
TInt pipehandle = aReceivedMessage.Get8bit( ISI_HEADER_SIZE +
|
|
391 |
PNS_PIPE_REMOVE_RESP_OFFSET_PIPEHANDLE );
|
|
392 |
|
|
393 |
TInt dteId = FindDteId( pipehandle );
|
|
394 |
ASSERT_PANIC_ALWAYS( dteId < KMaxDteIdCount )
|
|
395 |
ASSERT_PANIC_ALWAYS( error == PN_PIPE_NO_ERROR )
|
|
396 |
ChangePipeState( dteId, TPipeInfo::EPipeNoPipe );
|
|
397 |
|
|
398 |
iPipeTable[ dteId ].iHandle = KInvalidPipeHandle;
|
|
399 |
|
|
400 |
if( iSchedulerWait )
|
|
401 |
{
|
|
402 |
C_TRACE((_L("CModemAtPipeController::HandlePipeRemoveResp() iSchedulerWait->Stop")));
|
|
403 |
iSchedulerWait->AsyncStop();
|
|
404 |
delete iSchedulerWait;
|
|
405 |
iSchedulerWait = NULL;
|
|
406 |
}
|
|
407 |
C_TRACE((_L("<<CModemAtPipeController::HandlePipeRemoveResp()")));
|
|
408 |
}
|
|
409 |
|
|
410 |
|
|
411 |
void CModemAtPipeController::RemovePipe( const TUint8 aDteId )
|
|
412 |
{
|
|
413 |
C_TRACE (( _T("CModemAtPipeController::RemovePipe(%d, 0x%x)"), aDteId, this ));
|
|
414 |
ASSERT_PANIC_ALWAYS( aDteId < KMaxDteIdCount );
|
|
415 |
C_TRACE (( _T("iPipeTable[aDteId]:0x%x"), &iPipeTable[aDteId] ));
|
|
416 |
C_TRACE (( _T("iHandle: %d"), iPipeTable[aDteId].iHandle ));
|
|
417 |
C_TRACE (( _T("i1stDevId: %d"), iPipeTable[aDteId].iFirstDevId ));
|
|
418 |
C_TRACE (( _T("i1stObjId: %d"), iPipeTable[aDteId].iFirstObjId ));
|
|
419 |
C_TRACE (( _T("i2ndDevId: %d"), iPipeTable[aDteId].iSecondDevId ));
|
|
420 |
C_TRACE (( _T("i2ndObjId: %d"), iPipeTable[aDteId].iSecondObjId ));
|
|
421 |
|
|
422 |
if( iPipeTable[aDteId].iHandle != KInvalidPipeHandle )
|
|
423 |
{
|
|
424 |
if( ( iPipeTable[aDteId].iPipeState == TPipeInfo::EPipeRemoving ) ||
|
|
425 |
( iPipeTable[aDteId].iPipeState == TPipeInfo::EPipeNoPipe ) )
|
|
426 |
{
|
|
427 |
C_TRACE((_L("Already removing pipe or pipe is removed. Handle %d"), iPipeTable[aDteId].iHandle));
|
|
428 |
return;
|
|
429 |
}
|
|
430 |
C_TRACE((_L("Remove pipe. Handle %d"), iPipeTable[aDteId].iHandle));
|
|
431 |
ChangePipeState( aDteId, TPipeInfo::EPipeRemoving );
|
|
432 |
SendRemovePipeReq( iPipeTable[aDteId].iHandle );
|
|
433 |
}
|
|
434 |
else
|
|
435 |
{
|
|
436 |
C_TRACE((_L("No Pipe to Remove")));
|
|
437 |
}
|
|
438 |
}
|
|
439 |
|
|
440 |
|
|
441 |
void CModemAtPipeController::SendRemovePipeReq( const TUint8 aPipeHandle )
|
|
442 |
{
|
|
443 |
C_TRACE (( _T(">>CModemAtPipeController::SendRemovePipeReq()") ));
|
|
444 |
C_TRACE((_L("Remove pipe handle %d"), aPipeHandle));
|
|
445 |
TInt size = ISI_HEADER_SIZE + SIZE_PNS_PIPE_REMOVE_REQ;
|
|
446 |
HBufC8* message = HBufC8::New( size );
|
|
447 |
ASSERT_PANIC_ALWAYS( message );
|
|
448 |
|
|
449 |
TPtr8 messageptr = message->Des();
|
|
450 |
TIsiSend isimessage( messageptr, size );
|
|
451 |
isimessage.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_PIPE );
|
|
452 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REMOVE_REQ_OFFSET_UTID, 0 );
|
|
453 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REMOVE_REQ_OFFSET_SUBFUNCTION,
|
|
454 |
PNS_PIPE_REMOVE_REQ );
|
|
455 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REMOVE_REQ_OFFSET_PIPEHANDLE,
|
|
456 |
aPipeHandle ); //disabled
|
|
457 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REMOVE_REQ_OFFSET_FILLERBYTE1 ,0 );
|
|
458 |
isimessage.Complete();
|
|
459 |
C_TRACE(_L("Created ISI-message"));
|
|
460 |
|
|
461 |
TInt retVal = iIscApi.Send( messageptr );
|
|
462 |
ASSERT_PANIC_ALWAYS( retVal == KErrNone );
|
|
463 |
delete message;
|
|
464 |
if( !iSchedulerWait )
|
|
465 |
{
|
|
466 |
C_TRACE(_L("CModemAtPipeController::SendRemovePipeReq() iSchedulerWait->Start()"));
|
|
467 |
TRAPD(err, iSchedulerWait = new (ELeave) CActiveSchedulerWait);
|
|
468 |
ASSERT_PANIC_ALWAYS( err == KErrNone );
|
|
469 |
iSchedulerWait->Start();
|
|
470 |
}
|
|
471 |
C_TRACE (( _T("<<CModemAtPipeController::SendRemovePipeReq()") ));
|
|
472 |
}
|
|
473 |
|
|
474 |
void CModemAtPipeController::RedirectPipe( const TUint8 aDteId,
|
|
475 |
const TUint8 aNewDevId,
|
|
476 |
const TUint8 aNewObjId )
|
|
477 |
{
|
|
478 |
C_TRACE (( _T("CModemAtPipeController::RedirectPipe() dteid %d"), aDteId ));
|
|
479 |
C_TRACE((_L("CModemAtPipeController::RedirectPipe() New pep, deviceId: 0x%x objId: 0x%x "), aNewDevId, aNewObjId));
|
|
480 |
ASSERT_PANIC_ALWAYS( aDteId < KMaxDteIdCount )
|
|
481 |
ASSERT_PANIC_ALWAYS( iPipeTable[aDteId].iHandle != KInvalidPipeHandle )
|
|
482 |
|
|
483 |
if( iPipeTable[aDteId].iPipeState == TPipeInfo::EPipeRemoving ||
|
|
484 |
iPipeTable[aDteId].iPipeState == TPipeInfo::EPipeNoPipe )
|
|
485 |
{
|
|
486 |
C_TRACE(_L("CModemAtPipeController::RedirectPipe() Pipe is already removed -> cant redirect"));
|
|
487 |
return;
|
|
488 |
}
|
|
489 |
|
|
490 |
if( aNewDevId == THIS_DEVICE && aNewObjId == iModemAtObjId )
|
|
491 |
{
|
|
492 |
C_TRACE((_L("CModemAtPipeController::RedirectPipe() EPipeDisabled. iModemAtObjId: 0x%x"), iModemAtObjId));
|
|
493 |
ChangePipeState( aDteId, TPipeInfo::EPipeDisabled );
|
|
494 |
}
|
|
495 |
else
|
|
496 |
{
|
|
497 |
C_TRACE(_L("CModemAtPipeController::RedirectPipe() EPipeRedirected"));
|
|
498 |
ChangePipeState( aDteId, TPipeInfo::EPipeRedirected );
|
|
499 |
}
|
|
500 |
|
|
501 |
C_TRACE(_L("CModemAtPipeController::RedirectPipe() Redirecting pipe"));
|
|
502 |
|
|
503 |
HBufC8* message = HBufC8::New( ISI_HEADER_SIZE + SIZE_PNS_PIPE_REDIRECT_REQ );
|
|
504 |
ASSERT_PANIC_ALWAYS( message )
|
|
505 |
TPtr8 messageptr = message->Des();
|
|
506 |
TIsiSend isimessage( messageptr, ISI_HEADER_SIZE + SIZE_PNS_PIPE_REDIRECT_REQ );
|
|
507 |
isimessage.Set8bit( ISI_HEADER_OFFSET_RESOURCEID,PN_PIPE);
|
|
508 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_UTID, 0);
|
|
509 |
|
|
510 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_SUBFUNCTION,
|
|
511 |
PNS_PIPE_REDIRECT_REQ );
|
|
512 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_PIPEHANDLE,
|
|
513 |
iPipeTable[aDteId].iHandle );
|
|
514 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_STATEAFTERCREATION,
|
|
515 |
PN_PIPE_DISABLE );
|
|
516 |
//old pep
|
|
517 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_OLDPEPDEV,
|
|
518 |
iPipeTable[aDteId].iSecondDevId );
|
|
519 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_OLDPEPOBJ,
|
|
520 |
iPipeTable[aDteId].iSecondObjId );
|
|
521 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_OLDPEPTYPE, PN_PEP_TYPE_COMMON);
|
|
522 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_FILLERBYTE1, KFiller );
|
|
523 |
|
|
524 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_REPLACEMENTPEPDEV, aNewDevId );
|
|
525 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_REPLACEMENTPEPOBJ, aNewObjId );
|
|
526 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_REPLACEMENTPEPTYPE,
|
|
527 |
PN_PEP_TYPE_COMMON );
|
|
528 |
|
|
529 |
iPipeTable[aDteId].iSecondDevId = aNewDevId;
|
|
530 |
iPipeTable[aDteId].iSecondObjId = aNewObjId;
|
|
531 |
|
|
532 |
isimessage.Set8bit(ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_NSB, KFiller );
|
|
533 |
isimessage.Complete();
|
|
534 |
|
|
535 |
C_TRACE(_L("Created ISI-message"));
|
|
536 |
TInt retVal = iIscApi.Send( messageptr );
|
|
537 |
ASSERT_PANIC_ALWAYS( retVal == KErrNone );
|
|
538 |
delete message;
|
|
539 |
}
|
|
540 |
|
|
541 |
void CModemAtPipeController::HandlePipeRedirectResp( const TIsiReceiveC& aReceivedMessage )
|
|
542 |
{
|
|
543 |
C_TRACE (( _T("CModemAtPipeController::HandlePipeRedirectResp()") ));
|
|
544 |
TInt error = aReceivedMessage.Get8bit( ISI_HEADER_SIZE +
|
|
545 |
PNS_PIPE_REDIRECT_RESP_OFFSET_ERRORCODE );
|
|
546 |
TInt pipeHandle = aReceivedMessage.Get8bit( ISI_HEADER_SIZE +
|
|
547 |
PNS_PIPE_REDIRECT_RESP_OFFSET_PIPEHANDLE );
|
|
548 |
C_TRACE((_L("CModemAtPipeController::HandlePipeRedirectResp() pipehandle: %d"), pipeHandle ));
|
|
549 |
TInt dteId = FindDteId( pipeHandle );
|
|
550 |
|
|
551 |
if( error != PN_PIPE_NO_ERROR )
|
|
552 |
{
|
|
553 |
if( dteId != KInvalidDteId )
|
|
554 |
{
|
|
555 |
C_TRACE(( _L("CModemAtPipeController::HandlePipeRedirectResp() pipe error: %d"), error ));
|
|
556 |
iAtHandler.SendAtModemDataRedirectResultReq( dteId, AT_MODEM_REDIRECT_RESULT_ERROR);
|
|
557 |
RemovePipe( dteId );
|
|
558 |
return;
|
|
559 |
}
|
|
560 |
else
|
|
561 |
{
|
|
562 |
C_TRACE(( _L("CModemAtPipeController::HandlePipeRedirectResp() dteId not found, pipe error: %d"), error ));
|
|
563 |
TRACE_ASSERT_ALWAYS;
|
|
564 |
return;
|
|
565 |
}
|
|
566 |
}
|
|
567 |
|
|
568 |
iAtHandler.SendAtModemDataRedirectResultReq( dteId, AT_MODEM_REDIRECT_RESULT_OK );
|
|
569 |
|
|
570 |
if( iPipeTable[ dteId ].iPipeState != TPipeInfo::EPipeDisabled )
|
|
571 |
{
|
|
572 |
SendEnablePipeReq( pipeHandle );
|
|
573 |
}
|
|
574 |
|
|
575 |
}
|
|
576 |
|
|
577 |
void CModemAtPipeController::SendTaskIdQuery()
|
|
578 |
{
|
|
579 |
C_TRACE (( _T("CModemAtPipeController::SendTaskIdQuery()") ));
|
|
580 |
HBufC8* message = HBufC8::New( KTaskIdQuerySize );
|
|
581 |
TRACE_ASSERT( message );
|
|
582 |
if( message )
|
|
583 |
{
|
|
584 |
TPtr8 messageptr = message->Des();
|
|
585 |
TIsiSend isimessage( messageptr, KTaskIdQuerySize );
|
|
586 |
isimessage.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_NAMESERVICE );
|
|
587 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_UTID, KDefaultTrId );
|
|
588 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_SUBFUNCTION, PNS_NAME_QUERY_REQ );
|
|
589 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_RESERVED1, 0 );
|
|
590 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_RESERVED2, 0);
|
|
591 |
isimessage.Set32bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_NAME, PN_AT_MODEM );
|
|
592 |
isimessage.Set32bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_BITMASK, PN_AT_MODEM );
|
|
593 |
isimessage.Complete();
|
|
594 |
|
|
595 |
DUMP_MESSAGE( messageptr );
|
|
596 |
TInt retVal = iIscApi.Send( messageptr );
|
|
597 |
ASSERT_PANIC_ALWAYS( retVal == KErrNone );
|
|
598 |
delete message;
|
|
599 |
}
|
|
600 |
}
|
|
601 |
|
|
602 |
void CModemAtPipeController::SendEnablePipeReq( const TUint8 aPipeHandle )
|
|
603 |
{
|
|
604 |
C_TRACE (( _T("CModemAtPipeController::SendEnablePipeReq()") ));
|
|
605 |
HBufC8* message = HBufC8::New( ISI_HEADER_SIZE + SIZE_PNS_PIPE_ENABLE_REQ );
|
|
606 |
ASSERT_PANIC_ALWAYS( message )
|
|
607 |
TPtr8 messageptr = message->Des();
|
|
608 |
TIsiSend isimessage( messageptr, ISI_HEADER_SIZE + SIZE_PNS_PIPE_ENABLE_REQ );
|
|
609 |
isimessage.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_PIPE );
|
|
610 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_ENABLE_REQ_OFFSET_UTID, 0 );
|
|
611 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_ENABLE_REQ_OFFSET_SUBFUNCTION, PNS_PIPE_ENABLE_REQ );
|
|
612 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_ENABLE_REQ_OFFSET_PIPEHANDLE , aPipeHandle );
|
|
613 |
isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_ENABLE_REQ_OFFSET_FILLERBYTE1 , 0 );
|
|
614 |
isimessage.Complete();
|
|
615 |
|
|
616 |
DUMP_MESSAGE( messageptr );
|
|
617 |
TInt retVal = iIscApi.Send( messageptr );
|
|
618 |
ASSERT_PANIC_ALWAYS( retVal == KErrNone );
|
|
619 |
delete message;
|
|
620 |
}
|
|
621 |
|
|
622 |
TInt CModemAtPipeController::FindDteId( const TInt aHandle )
|
|
623 |
{
|
|
624 |
C_TRACE (( _T("CModemAtPipeController::FindDteId()") ));
|
|
625 |
TInt dteId = KInvalidDteId;
|
|
626 |
for( TInt i = 0 ; i < KMaxDteIdCount ; i++ )
|
|
627 |
{
|
|
628 |
if( iPipeTable[i].iHandle == aHandle )
|
|
629 |
{
|
|
630 |
dteId = i;
|
|
631 |
break;
|
|
632 |
}
|
|
633 |
}
|
|
634 |
|
|
635 |
TRACE_ASSERT( dteId != KInvalidDteId );
|
|
636 |
C_TRACE((_L("CModemAtPipeController::FindDteId() returns dteid: %d"),dteId));
|
|
637 |
return dteId;
|
|
638 |
}
|
|
639 |
|
|
640 |
|
|
641 |
void CModemAtPipeController::HandlePipeEnabledResp( const TIsiReceiveC& aReceivedMessage )
|
|
642 |
{
|
|
643 |
C_TRACE (( _T("CModemAtPipeController::HandlePipeEnabledResp()") ));
|
|
644 |
TInt error = aReceivedMessage.Get8bit(ISI_HEADER_SIZE +
|
|
645 |
PNS_PIPE_ENABLE_RESP_OFFSET_ERRORCODE);
|
|
646 |
TInt pipeHandle = aReceivedMessage.Get8bit(ISI_HEADER_SIZE +
|
|
647 |
PNS_PIPE_ENABLE_RESP_OFFSET_PIPEHANDLE);
|
|
648 |
TInt dteId = FindDteId(pipeHandle);
|
|
649 |
C_TRACE((_L("CModemAtPipeController::HandlePipeEnabledResp() pipehandle %d"), pipeHandle));
|
|
650 |
|
|
651 |
if( error == PN_PIPE_NO_ERROR )
|
|
652 |
{
|
|
653 |
ChangePipeState( dteId, TPipeInfo::EPipeEnabled );
|
|
654 |
}
|
|
655 |
else
|
|
656 |
{
|
|
657 |
C_TRACE((_L("CModemAtPipeController::HandlePipeEnabledResp() pipe error: %d"), error));
|
|
658 |
TRACE_ASSERT_ALWAYS;
|
|
659 |
}
|
|
660 |
}
|
|
661 |
|
|
662 |
|
|
663 |
void CModemAtPipeController::ChangePipeState(
|
|
664 |
const TInt aDteId,
|
|
665 |
TPipeInfo::EPipeState aState )
|
|
666 |
{
|
|
667 |
C_TRACE((_L("CModemAtPipeController::ChangePipeState(%d, %d)"), aDteId, aState));
|
|
668 |
C_TRACE(( _L("Was: iPipeTable[ %d ].iPipeState = %d"), aDteId, (TInt)iPipeTable[ aDteId ].iPipeState ));
|
|
669 |
iPipeTable[ aDteId ].iPipeState = aState;
|
|
670 |
if( aState == TPipeInfo::EPipeEnabled )
|
|
671 |
{
|
|
672 |
C_TRACE(( _T("DATA MODE") ));
|
|
673 |
iAtHandler.HandleCommandModeChange( aDteId, EDataMode );
|
|
674 |
}
|
|
675 |
else if( aState == TPipeInfo::EPipeDisabled )
|
|
676 |
{
|
|
677 |
C_TRACE(( _T("COMMAND MODE") ));
|
|
678 |
iAtHandler.HandleCommandModeChange( aDteId, ECommandMode );
|
|
679 |
}
|
|
680 |
}
|
|
681 |
|
|
682 |
void CModemAtPipeController::HandlePepStatusInd( const TIsiReceiveC& aReceivedMessage )
|
|
683 |
{
|
|
684 |
C_TRACE(( _L("CModemAtPipeController::HandlePepStatusInd")));
|
|
685 |
TUint8 pepType( aReceivedMessage.Get8bit( ISI_HEADER_SIZE +
|
|
686 |
PNS_PEP_STATUS_IND_OFFSET_PEPTYPE ) );
|
|
687 |
if( pepType == PN_PEP_TYPE_COMM )
|
|
688 |
{
|
|
689 |
TUint8 indicationId( aReceivedMessage.Get8bit( ISI_HEADER_SIZE +
|
|
690 |
PNS_PEP_STATUS_IND_OFFSET_INDICATIONID ) );
|
|
691 |
if( indicationId == PEP_COMM_IND_ID_ESCAPE )
|
|
692 |
{
|
|
693 |
TUint8 pipeHandle( aReceivedMessage.Get8bit( ISI_HEADER_SIZE +
|
|
694 |
PNS_PEP_STATUS_IND_OFFSET_PIPEHANDLE ) );
|
|
695 |
TInt dteId( FindDteId( pipeHandle ) );
|
|
696 |
C_TRACE( (_L("CModemAtPipeController PEP_COMM_IND_ID_ESCAPE received, pipehandle %d dteid %d"), pipeHandle, dteId ));
|
|
697 |
|
|
698 |
if( dteId != KInvalidDteId )
|
|
699 |
{
|
|
700 |
C_TRACE( (_L("SendEscapeSignalDetection dteid %d"), dteId ));
|
|
701 |
iAtHandler.SendEscapeSignalDetection( dteId );
|
|
702 |
}
|
|
703 |
}
|
|
704 |
// Not know should any other indicationid from comm pep type to be handled
|
|
705 |
else
|
|
706 |
{
|
|
707 |
C_TRACE((_L("CModemAtPipeController Indication ignored pepType %d indicationId: %d "), pepType, indicationId));
|
|
708 |
}
|
|
709 |
}
|
|
710 |
// pep type comm only supported one
|
|
711 |
else
|
|
712 |
{
|
|
713 |
C_TRACE((_L("CModemAtPipeController Peptype ignored %d "), pepType));
|
|
714 |
}
|
|
715 |
}
|
|
716 |
|
|
717 |
#endif // NCP_COMMON_BRIDGE_FAMILY
|
|
718 |
|