24
|
1 |
// Copyright (c) 2008-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 |
// PDP Connection Provider implementation
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
@internalComponent
|
|
21 |
*/
|
|
22 |
|
|
23 |
#include "PDPCPR.h"
|
|
24 |
#include <comms-infras/ss_log.h>
|
|
25 |
#include <comms-infras/ss_msgintercept.h>
|
|
26 |
#include <comms-infras/corecpractivities.h>
|
|
27 |
#include <elements/nm_address.h>
|
|
28 |
#include <comms-infras/ss_nodemessages_parameters.h>
|
|
29 |
#include <comms-infras/corescprstates.h>
|
|
30 |
#include <elements/mm_context.h>
|
|
31 |
#include <etelmm.h>
|
|
32 |
#include <etelpckt.h>
|
|
33 |
#include <comms-infras/ss_metaconnprov.h>
|
|
34 |
#include "pdpprovision.h"
|
|
35 |
#include <etel.h>
|
|
36 |
#include <networking/cfbearers.h>
|
|
37 |
#include "pdpcpravailabilitylistener.h"
|
|
38 |
#include <comms-infras/ss_nodemessages.h>
|
|
39 |
#include <networking/ipcpr_states.h>
|
|
40 |
#include <comms-infras/linkmessages.h>
|
|
41 |
#include <elements/nm_interfaces.h>
|
|
42 |
#include <cs_genevent.h>
|
|
43 |
#include <networking/etelbearers.h>
|
|
44 |
|
|
45 |
using namespace ESock;
|
|
46 |
|
|
47 |
|
|
48 |
//-=========================================================
|
|
49 |
//
|
|
50 |
// CPDPConnectionProvider methods
|
|
51 |
//
|
|
52 |
//-=========================================================
|
|
53 |
|
|
54 |
//We reserve space for two preallocated activities that may start concurrently on the CPR
|
|
55 |
//node: destroy and data client stop.
|
|
56 |
static const TUint KDefaultMaxPreallocatedActivityCount = 2;
|
|
57 |
static const TUint KMaxPreallocatedActivitySize = sizeof(MeshMachine::CNodeRetryParallelActivity) + sizeof(MeshMachine::APreallocatedOriginators<4>);
|
|
58 |
static const TUint KPDPCPRPreallocatedActivityBufferSize = KDefaultMaxPreallocatedActivityCount * KMaxPreallocatedActivitySize;
|
|
59 |
|
|
60 |
namespace PDPCprLinkCharacteristicActivity
|
|
61 |
{
|
|
62 |
DECLARE_DEFINE_NODEACTIVITY(ECFActivityParamRequest, PDPCprLinkCharacteristic, TCFScpr::TGetParamsRequest)
|
|
63 |
NODEACTIVITY_ENTRY(MeshMachine::KNoTag, PDPCprStates::TUpdateBundleAndRespondWithRetrievedParams, PRStates::TAwaitingParamRequest, MeshMachine::TNoTag)
|
|
64 |
NODEACTIVITY_END()
|
|
65 |
}
|
|
66 |
|
|
67 |
// Agent SCPR Going Down Activity
|
|
68 |
namespace PDPDataClientGoneDownActivity
|
|
69 |
{
|
|
70 |
DECLARE_DEFINE_NODEACTIVITY(ECFActivityDataClientGoneDown, PDPScprGoneDown, TCFControlProvider::TDataClientGoneDown)
|
|
71 |
// AwaitingDataClientGoneDown used rather than AlwaysAccept to mark data client EStopped
|
|
72 |
FIRST_NODEACTIVITY_ENTRY(CoreNetStates::TAwaitingDataClientGoneDown, CoreNetStates::TNoTagOrNonDefault)
|
|
73 |
LAST_NODEACTIVITY_ENTRY(MeshMachine::KNoTag, PRStates::TSendGoneDown)
|
|
74 |
LAST_NODEACTIVITY_ENTRY(CoreNetStates::KNonDefault, MeshMachine::TDoNothing)
|
|
75 |
NODEACTIVITY_END()
|
|
76 |
}
|
|
77 |
|
|
78 |
namespace PDPCprActivities
|
|
79 |
{
|
|
80 |
DEFINE_ACTIVITY_MAP(activityMap)
|
|
81 |
ACTIVITY_MAP_ENTRY(PDPDataClientGoneDownActivity, PDPScprGoneDown)
|
|
82 |
ACTIVITY_MAP_ENTRY(PDPCprLinkCharacteristicActivity, PDPCprLinkCharacteristic)
|
|
83 |
ACTIVITY_MAP_END_BASE(CprActivities, coreCprActivities)
|
|
84 |
}
|
|
85 |
|
|
86 |
|
|
87 |
CPDPConnectionProvider* CPDPConnectionProvider::NewL(ESock::CConnectionProviderFactoryBase& aFactory)
|
|
88 |
{
|
|
89 |
CPDPConnectionProvider* provider = new (ELeave) CPDPConnectionProvider(aFactory);
|
|
90 |
CleanupStack::PushL(provider);
|
|
91 |
provider->ConstructL();
|
|
92 |
CleanupStack::Pop(provider);
|
|
93 |
return provider;
|
|
94 |
}
|
|
95 |
|
|
96 |
|
|
97 |
void CPDPConnectionProvider::StartListener()
|
|
98 |
/**
|
|
99 |
* Start listening for dynamic caps or network mode changes.
|
|
100 |
* @param None
|
|
101 |
* @return void
|
|
102 |
*/
|
|
103 |
{
|
|
104 |
iDynamicCapsEventListener->NotifyDynamicCapsChange(this);
|
|
105 |
iNetworkModeEventListener->NotifyNetworkModeChange(this);
|
|
106 |
}
|
|
107 |
|
|
108 |
void CPDPConnectionProvider::ConstructL()
|
|
109 |
/**
|
|
110 |
* PDP Connection Provider Second Phase Constructor
|
|
111 |
* @param None
|
|
112 |
* @return void
|
|
113 |
*/
|
|
114 |
{
|
|
115 |
CCoreConnectionProvider::ConstructL(KPDPCPRPreallocatedActivityBufferSize);
|
|
116 |
}
|
|
117 |
|
|
118 |
void CPDPConnectionProvider::StopListener()
|
|
119 |
/**
|
|
120 |
* Start listening for dynamic caps or network mode changes.
|
|
121 |
*/
|
|
122 |
{
|
|
123 |
if(iDynamicCapsEventListener)
|
|
124 |
{
|
|
125 |
iDynamicCapsEventListener->Cancel();
|
|
126 |
}
|
|
127 |
if(iNetworkModeEventListener)
|
|
128 |
{
|
|
129 |
iNetworkModeEventListener->Cancel();
|
|
130 |
}
|
|
131 |
}
|
|
132 |
|
|
133 |
CPDPConnectionProvider::CPDPConnectionProvider(ESock::CConnectionProviderFactoryBase& aFactory)
|
|
134 |
: CCoreConnectionProvider(aFactory, PDPCprActivities::activityMap::Self())
|
|
135 |
/**
|
|
136 |
* Construct PDP connection provider.
|
|
137 |
*/
|
|
138 |
{
|
|
139 |
LOG_NODE_CREATE(KESockConnectionTag, CPDPConnectionProvider);
|
|
140 |
}
|
|
141 |
|
|
142 |
CPDPConnectionProvider::~CPDPConnectionProvider()
|
|
143 |
/**
|
|
144 |
* Destroy PDP connection provider.
|
|
145 |
*/
|
|
146 |
{
|
|
147 |
LOG_NODE_DESTROY(KESockConnectionTag, CPDPConnectionProvider);
|
|
148 |
StopListener();
|
|
149 |
delete iDynamicCapsEventListener;
|
|
150 |
delete iNetworkModeEventListener;
|
|
151 |
}
|
|
152 |
|
|
153 |
void CPDPConnectionProvider::ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage)
|
|
154 |
{
|
|
155 |
//ESOCK_DEBUG_MESSAGE_INTERCEPT(aSender, aMessage, aRecipient);
|
|
156 |
MeshMachine::TNodeContext<CPDPConnectionProvider> ctx(*this, aMessage, aSender, aRecipient);
|
|
157 |
CCoreConnectionProvider::Received(ctx);
|
|
158 |
User::LeaveIfError(ctx.iReturn);
|
|
159 |
}
|
|
160 |
|
|
161 |
|
|
162 |
void CPDPConnectionProvider::BearerChangeDetectedL()
|
|
163 |
/**
|
|
164 |
* Update the parmeter set in case of modulation change and send TPlaneNotification message to
|
|
165 |
* all the control client.
|
|
166 |
*/
|
|
167 |
{
|
|
168 |
//Update bearers.
|
|
169 |
UpdateBearer();
|
|
170 |
|
|
171 |
//Send msg to all control clients
|
|
172 |
CEventParamsChanged* eventChanged = CEventParamsChanged::NewL(KBearerInfo);
|
|
173 |
|
|
174 |
CleanupStack::PushL(eventChanged);
|
|
175 |
//Create the family and set it to bearer type
|
|
176 |
XBearerInfo* bearerInfo = XBearerInfo::NewL();
|
|
177 |
CleanupStack::PushL(bearerInfo);
|
|
178 |
|
|
179 |
bearerInfo->SetBearerType(iBearerType);
|
|
180 |
|
|
181 |
//Add bearer family to parameter set.
|
|
182 |
eventChanged->AddParameterSetL(KBearerInfo, bearerInfo);
|
|
183 |
CleanupStack::Pop(2,eventChanged);
|
|
184 |
|
|
185 |
//Create the event node for bearer change notification.
|
|
186 |
CRefCountOwnedNotification* eventNode = new (ELeave) CRefCountOwnedNotification(eventChanged);
|
|
187 |
|
|
188 |
//Build the CPR plane notification message, which will be retrieved by IPCPR.
|
|
189 |
TCFSubConnControlClient::TPlaneNotification msg(eventNode);
|
|
190 |
|
|
191 |
Messages::TClientIter<Messages::TDefaultClientMatchPolicy> iter = this->GetClientIter<Messages::TDefaultClientMatchPolicy>(Messages::TClientType(TCFClientType::ECtrl));
|
|
192 |
Messages::RNodeInterface* ctl;
|
|
193 |
while ((ctl = iter++) != NULL)
|
|
194 |
{
|
|
195 |
msg.iRefCountOwnedNotification->Open();
|
|
196 |
ctl->PostMessage(this->NodeId(), msg);
|
|
197 |
}
|
|
198 |
|
|
199 |
}
|
|
200 |
|
|
201 |
|
|
202 |
void CPDPConnectionProvider::UpdateBearer()
|
|
203 |
/**
|
|
204 |
* Update bearer type based on the change of the dynamic caps or network mode.
|
|
205 |
*/
|
|
206 |
{
|
|
207 |
//Get dynamic caps
|
|
208 |
TUint dynamicCaps = iDynamicCapsEventListener->DynamicCaps();
|
|
209 |
//Get network mode
|
|
210 |
RMobilePhone::TMobilePhoneNetworkMode networkMode = iNetworkModeEventListener->NetworkMode();
|
|
211 |
|
|
212 |
//Resolve the bearer based on both dynamic caps and network mode
|
|
213 |
iBearerType = Bearer(dynamicCaps, networkMode);
|
|
214 |
iBearerSet = ETrue;
|
|
215 |
}
|
|
216 |
|
|
217 |
|
|
218 |
TUint32 CPDPConnectionProvider::Bearer(TUint aDynamicCaps, RMobilePhone::TMobilePhoneNetworkMode& aNetworkMode)
|
|
219 |
/**
|
|
220 |
* Determine bearer based on dynamic caps and network mode.
|
|
221 |
* @param aDynamicCaps a value of dynamic caps
|
|
222 |
* @param aNetworkMode a value of network mode
|
|
223 |
* @return Type of Bearer
|
|
224 |
*
|
|
225 |
*/
|
|
226 |
{
|
|
227 |
|
|
228 |
if ((aDynamicCaps & RPacketService::KCapsHSUPA) || (aDynamicCaps & RPacketService::KCapsHSDPA))
|
|
229 |
{
|
|
230 |
return KHsdpaBearer;
|
|
231 |
}
|
|
232 |
else if (aDynamicCaps & RPacketService::KCapsEGPRS)
|
|
233 |
{
|
|
234 |
return KEGprsBearer;
|
|
235 |
}
|
|
236 |
else
|
|
237 |
{
|
|
238 |
if(aNetworkMode == RMobilePhone::ENetworkModeGsm)
|
|
239 |
{
|
|
240 |
return KGprsBearer;
|
|
241 |
}
|
|
242 |
else if(aNetworkMode == RMobilePhone::ENetworkModeWcdma)
|
|
243 |
{
|
|
244 |
return KUmtsBearer;
|
|
245 |
}
|
|
246 |
else
|
|
247 |
{
|
|
248 |
return KDefaultBearer;
|
|
249 |
}
|
|
250 |
}
|
|
251 |
}
|
|
252 |
|
|
253 |
|
|
254 |
DEFINE_SMELEMENT(PDPCprStates::TUpdateBundle, NetStateMachine::MStateTransition, PDPCprStates::TContext)
|
|
255 |
void PDPCprStates::TUpdateBundle::DoL()
|
|
256 |
/**
|
|
257 |
* Process TGetParamsRequest
|
|
258 |
*/
|
|
259 |
{
|
|
260 |
// Node receives TGetParamsRequest msg containing the bundle.
|
|
261 |
// Determine current network type - GPRS/EDGE/UMTS/HSDPA and update the bundle.
|
|
262 |
const CTSYProvision& tsyProvision = static_cast<const CTSYProvision&>(iContext.Node().AccessPointConfig().FindExtensionL(
|
|
263 |
STypeId::CreateSTypeId(CTSYProvision::EUid, CTSYProvision::ETypeId)));
|
|
264 |
if(!iContext.Node().iDynamicCapsEventListener)
|
|
265 |
{
|
|
266 |
iContext.Node().iDynamicCapsEventListener = CPDPCPRDynamicCapsListener::NewL(&tsyProvision);
|
|
267 |
}
|
|
268 |
if (!iContext.Node().iNetworkModeEventListener)
|
|
269 |
{
|
|
270 |
iContext.Node().iNetworkModeEventListener = CPDPCPRNetworkModeListener::NewL(&tsyProvision);
|
|
271 |
}
|
|
272 |
|
|
273 |
if(iContext.Node().iBearerSet == EFalse)
|
|
274 |
{
|
|
275 |
iContext.Node().UpdateBearer();
|
|
276 |
}
|
|
277 |
|
|
278 |
TCFScpr::TGetParamsRequest& paramRequest = Messages::message_cast<TCFScpr::TGetParamsRequest>(iContext.iMessage);
|
|
279 |
if( (! paramRequest.iFamilyBundle.IsNull()) && (iContext.Node().GetParameterBundle() != paramRequest.iFamilyBundle))
|
|
280 |
{
|
|
281 |
iContext.Node().GetParameterBundle().Open(paramRequest.iFamilyBundle);
|
|
282 |
RParameterFamily family = iContext.Node().GetParameterBundle().FindFamily(KBearerInfo);
|
|
283 |
|
|
284 |
if(!family.IsNull())
|
|
285 |
{
|
|
286 |
XBearerInfo *bearerType = static_cast<XBearerInfo*>(family.FindParameterSet(STypeId::CreateSTypeId(KIpBearerInfoUid, KIpBearerInfoParameterType), RParameterFamily::ERequested));
|
|
287 |
|
|
288 |
if(bearerType)
|
|
289 |
{
|
|
290 |
bearerType->SetBearerType(iContext.Node().iBearerType);
|
|
291 |
}
|
|
292 |
}
|
|
293 |
}
|
|
294 |
|
|
295 |
if(iContext.Node().iDynamicCapsEventListener->IsDynamicCapsSupported())
|
|
296 |
{
|
|
297 |
// if Dynamic Caps supported, start listener, which would Notify of Dynamic Caps change
|
|
298 |
// no check required for network mode, since atleast one network mode is supported.
|
|
299 |
iContext.Node().StartListener();
|
|
300 |
}
|
|
301 |
}
|
|
302 |
|
|
303 |
|