|
1 // Copyright (c) 2006-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 // IPDeftProto SubConnection Provider implementation |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 |
|
24 #include <comms-infras/corescprstates.h> |
|
25 #include <comms-infras/corescpractivities.h> |
|
26 #include "ipprotocprstates.h" |
|
27 |
|
28 #include "ipprotodeftscpr.h" |
|
29 #include "ipprotodeftscprstates.h" |
|
30 #include <comms-infras/linkmessages.h> // for TLinkMessage |
|
31 #include <comms-infras/ss_msgintercept.h> |
|
32 |
|
33 using namespace Messages; |
|
34 using namespace ESock; |
|
35 using namespace IPProtoDeftSCpr; |
|
36 using namespace MeshMachine; |
|
37 |
|
38 //We reserve space for two preallocated activities that may start concurrently on the default SCPR |
|
39 //node: destroy and data client stop. |
|
40 static const TUint KDefaultMaxPreallocatedActivityCount = 2; |
|
41 static const TUint KMaxPreallocatedActivitySize = sizeof(MeshMachine::CNodeRetryParallelActivity) + sizeof(MeshMachine::APreallocatedOriginators<4>); |
|
42 static const TUint KIPProtoDeftSCPRPreallocatedActivityBufferSize = KDefaultMaxPreallocatedActivityCount * KMaxPreallocatedActivitySize; |
|
43 |
|
44 //-========================================================= |
|
45 // |
|
46 // Activities |
|
47 // |
|
48 //-========================================================= |
|
49 |
|
50 |
|
51 namespace IPProtoDeftSCprProvisionActivity |
|
52 { |
|
53 DECLARE_DEFINE_NODEACTIVITY(ECFActivityStoreProvision, IPProtoDeftSCprProvision, TCFDataClient::TProvisionConfig) |
|
54 FIRST_NODEACTIVITY_ENTRY(CoreNetStates::TAwaitingProvision, MeshMachine::TNoTag) |
|
55 LAST_NODEACTIVITY_ENTRY(KNoTag, IPProtoDeftSCpr::TStoreProvision) |
|
56 NODEACTIVITY_END() |
|
57 } |
|
58 |
|
59 namespace IPProtoDeftSCprDataClientStopActivity |
|
60 { |
|
61 DECLARE_DEFINE_CUSTOM_NODEACTIVITY(ECFActivityStopDataClient, IPProtoDeftSCprStop, TCFDataClient::TStop, MeshMachine::CNodeRetryActivity::NewL) |
|
62 FIRST_NODEACTIVITY_ENTRY(CoreNetStates::TAwaitingDataClientStop, TNoTagOrProviderStoppedOrDaemonReleased) |
|
63 NODEACTIVITY_ENTRY(KNoTag, TStopNetCfgExt, TAwaitingStateChange, TDaemonReleasedStateChangedOrNoTag) |
|
64 NODEACTIVITY_ENTRY(KNoTag, TForwardToControlProviderAndResetSentTo, TAwaitingStateChange, TDaemonReleasedStateChangedOrNoTagBackward) |
|
65 THROUGH_NODEACTIVITY_ENTRY(KDaemonReleasedStateChanged, TForwardToControlProviderAndResetSentTo, TTag<KDaemonReleased>) |
|
66 NODEACTIVITY_ENTRY(KDaemonReleased, SCprStates::TStopYourFlows, CoreNetStates::TAwaitingDataClientStopped, MeshMachine::TTag<CoreNetStates::KProviderStopped>) |
|
67 |
|
68 |
|
69 THROUGH_NODEACTIVITY_ENTRY(CoreNetStates::KProviderStopped, TStopNetCfgExtDelete, CoreNetStates::TNoTagOrUnbindOnStop) |
|
70 NODEACTIVITY_ENTRY(CoreNetStates::KUnbind, CoreNetStates::TSendClientLeavingRequestToServiceProvider, MeshMachine::TAwaitingLeaveComplete, MeshMachine::TNoTag) |
|
71 THROUGH_NODEACTIVITY_ENTRY(KNoTag, PRStates::TDestroyOrphanedDataClients, MeshMachine::TNoTag) |
|
72 LAST_NODEACTIVITY_ENTRY(KNoTag, PRStates::TSendDataClientStopped) |
|
73 NODEACTIVITY_END() |
|
74 } |
|
75 |
|
76 //Activity to handle the Ioctl. |
|
77 //Ioctls are often handled by layer below ipproto. In ordered to maintain the genericity of ipproto we send these requests to the layer |
|
78 //below us. If the layer below us services the request then we pass on the response to the originators else if the layer below us doesn't handle |
|
79 //the Ioctl, we are errored. Once errored we clear the error and try netcfgextn to complete the Ioctls. |
|
80 namespace IPProtoDeftSCprIoctlActivity |
|
81 { |
|
82 DECLARE_DEFINE_CUSTOM_NODEACTIVITY(ECFActivityIoctl, IPProtoDeftSCprIoctl, TNodeSignal::TNullMessageId, MeshMachine::CNodeParallelMessageStoreActivityBase::NewL) |
|
83 FIRST_NODEACTIVITY_ENTRY(IpProtoCpr::TAwaitingIoctlMessage, IPProtoDeftSCpr::TTryServiceProviderOrTryNetCfgExt) |
|
84 NODEACTIVITY_ENTRY(KTryServiceProvider, IPProtoDeftSCpr::TForwardToServiceProvider, TAcceptErrorState<CoreNetStates::TAwaitingRMessage2Processed>, MeshMachine::TNoTagOrErrorTag) |
|
85 THROUGH_NODEACTIVITY_ENTRY(KErrorTag, MeshMachine::TClearError, MeshMachine::TTag<KTryNetCfgExt>) |
|
86 NODEACTIVITY_ENTRY(KTryNetCfgExt, IPProtoDeftSCpr::THandoffToNetCfgExt, IPProtoDeftSCpr::TAwaitingIoctlProcessed, MeshMachine::TNoTag) |
|
87 LAST_NODEACTIVITY_ENTRY(KNoTag, CoreStates::TPostToOriginators) |
|
88 NODEACTIVITY_END() |
|
89 } |
|
90 |
|
91 namespace IPProtoDeftSCprAgentEventActivity |
|
92 { |
|
93 DECLARE_DEFINE_NODEACTIVITY(IPProtoDeftSCpr::EActivityAgentEvent, AgentEvent, TLinkMessage::TAgentEventNotification) |
|
94 NODEACTIVITY_ENTRY(KNoTag, IPProtoDeftSCpr::TProcessAgentEvent, IPProtoDeftSCpr::TAwaitingAgentEventNotification, MeshMachine::TNoTag) |
|
95 NODEACTIVITY_END() |
|
96 } |
|
97 |
|
98 //-========================================================= |
|
99 // Data Monitoring Activities |
|
100 //-========================================================= |
|
101 namespace IPProtoDeftSCprDataMonitoringActivity |
|
102 { |
|
103 DECLARE_DEFINE_NODEACTIVITY(IPProtoDeftSCpr::EActivityDataMonitoring, IPProtoDeftSCprDataMonitoring, TCFDataMonitoringNotification::TDataMonitoringNotification) |
|
104 FIRST_NODEACTIVITY_ENTRY(IPProtoDeftSCpr::TAwaitingDataMonitoringNotification, MeshMachine::TNoTag) |
|
105 LAST_NODEACTIVITY_ENTRY(KNoTag, IPProtoDeftSCpr::TProcessDataMonitoringNotification) |
|
106 NODEACTIVITY_END() |
|
107 } |
|
108 |
|
109 //Activity to forward legacy progresses to IpProtoCpr. |
|
110 //It overrides the default behaviour of forwarding legacy progresses up to the Control Clients. |
|
111 //In the case of there being a config daemon, KLinkLayerOpen is swallowed. The config daemon will |
|
112 //send it's own when configuration is done. IK |
|
113 namespace IPProtoDeftSCprForwardStateChangeActivity |
|
114 { |
|
115 DECLARE_DEFINE_NODEACTIVITY(ECFActivityForwardStateChange, IPProtoDeftSCprForwardStateChange, TCFMessage::TStateChange) |
|
116 FIRST_NODEACTIVITY_ENTRY(MeshMachine::TAwaitingMessageState<TCFMessage::TStateChange>, IPProtoDeftSCpr::TNoTagOrSwallowMessage) |
|
117 LAST_NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TForwardToControlProvider) |
|
118 LAST_NODEACTIVITY_ENTRY(KSwallowMessage, MeshMachine::TDoNothing) |
|
119 NODEACTIVITY_END() |
|
120 } |
|
121 |
|
122 namespace IPProtoDeftSCprConfigureNetworkActivity |
|
123 { |
|
124 DECLARE_DEFINE_NODEACTIVITY(ECFActivityConfigureNetwork, IPProtoDeftSCprConfigureNetwork, TCFIPProtoMessage::TConfigureNetwork) |
|
125 FIRST_NODEACTIVITY_ENTRY(IPProtoDeftSCpr::TAwaitingConfigureNetwork, MeshMachine::TNoTag) |
|
126 NODEACTIVITY_ENTRY(KNoTag, TStartNetCfgExtAndResetSentTo, TAwaitingStateChangeOrCancel, TNetworkConfiguredOrErrorTagOrCancelTagOrNoTag) |
|
127 NODEACTIVITY_ENTRY(KNoTag, TForwardToControlProviderAndResetSentTo, TAwaitingStateChangeOrCancel, TNetworkConfiguredOrErrorTagOrCancelTagOrNoTagBackward) |
|
128 THROUGH_NODEACTIVITY_ENTRY(KErrorTag, TForwardToControlProviderAndStopNetCfgExt, MeshMachine::TTag<KNetworkConfigured>) |
|
129 LAST_NODEACTIVITY_ENTRY(KNetworkConfigured, TSendNetworkConfigured) |
|
130 LAST_NODEACTIVITY_ENTRY(KCancelTag, TStopNetCfgExtAndRaiseActivityError) |
|
131 NODEACTIVITY_END() |
|
132 } |
|
133 |
|
134 namespace IPProtoDeftSCprDataClientStartActivity |
|
135 { |
|
136 DECLARE_DEFINE_NODEACTIVITY(ECFActivityStartDataClient, IPProtoDeftSCprDataClientStart, TCFDataClient::TStart) |
|
137 FIRST_NODEACTIVITY_ENTRY(CoreNetStates::TAwaitingDataClientStart, MeshMachine::TNoTag) |
|
138 NODEACTIVITY_ENTRY(KNoTag, PRStates::TStartDataClients, MeshMachine::TAcceptErrorState<CoreNetStates::TAwaitingDataClientsStarted>, MeshMachine::TErrorTagOr<IPProtoDeftSCpr::TNoTagOrConfigureNetwork>) |
|
139 NODEACTIVITY_ENTRY(KConfigureNetwork, IPProtoDeftSCpr::TConfigureNetwork, IPProtoDeftSCpr::TAwaitingNetworkConfiguredOrError, IPProtoDeftSCpr::TErrorTagOrNoTag) |
|
140 LAST_NODEACTIVITY_ENTRY(KNoTag, PRStates::TSendDataClientStarted) |
|
141 |
|
142 NODEACTIVITY_ENTRY(KErrorTag, CoreNetStates::TStopSelf, CoreNetStates::TAwaitingDataClientStopped, MeshMachine::TTag<KErrorTag>) |
|
143 LAST_NODEACTIVITY_ENTRY(KErrorTag, MeshMachine::TRaiseAndClearActivityError) |
|
144 NODEACTIVITY_END() |
|
145 } |
|
146 |
|
147 namespace IPProtoDeftSCpr |
|
148 { |
|
149 DECLARE_DEFINE_ACTIVITY_MAP(stateMap) |
|
150 ACTIVITY_MAP_ENTRY(IPProtoDeftSCprProvisionActivity, IPProtoDeftSCprProvision) |
|
151 ACTIVITY_MAP_ENTRY(IPProtoDeftSCprDataClientStopActivity, IPProtoDeftSCprStop) |
|
152 ACTIVITY_MAP_ENTRY(IPProtoDeftSCprDataMonitoringActivity, IPProtoDeftSCprDataMonitoring) |
|
153 ACTIVITY_MAP_ENTRY(IPProtoDeftSCprForwardStateChangeActivity, IPProtoDeftSCprForwardStateChange) //Forward progress horizontally |
|
154 ACTIVITY_MAP_ENTRY(IPProtoDeftSCprConfigureNetworkActivity, IPProtoDeftSCprConfigureNetwork) |
|
155 ACTIVITY_MAP_ENTRY(IPProtoDeftSCprDataClientStartActivity, IPProtoDeftSCprDataClientStart) |
|
156 ACTIVITY_MAP_ENTRY(IPProtoDeftSCprAgentEventActivity, AgentEvent) |
|
157 ACTIVITY_MAP_ENTRY(IPProtoDeftSCprIoctlActivity, IPProtoDeftSCprIoctl) |
|
158 ACTIVITY_MAP_END_BASE(SCprActivities, coreSCprActivities) |
|
159 } |
|
160 |
|
161 |
|
162 CIPProtoDeftSubConnectionProvider::CIPProtoDeftSubConnectionProvider(ESock::CSubConnectionProviderFactoryBase& aFactory) |
|
163 :CCoreSubConnectionProvider(aFactory, IPProtoDeftSCpr::stateMap::Self()), |
|
164 ALegacySubConnectionActiveApiExt(this), |
|
165 TIfStaticFetcherNearestInHierarchy(this), |
|
166 iNotify(NULL), |
|
167 iControl(NULL) |
|
168 { |
|
169 LOG_NODE_CREATE(KIPProtoDeftScprTag, CIPProtoDeftSubConnectionProvider); |
|
170 } |
|
171 |
|
172 void CIPProtoDeftSubConnectionProvider::ConstructL() |
|
173 { |
|
174 ADataMonitoringProvider::ConstructL(); |
|
175 CCoreSubConnectionProvider::ConstructL(KIPProtoDeftSCPRPreallocatedActivityBufferSize); |
|
176 } |
|
177 |
|
178 |
|
179 void CIPProtoDeftSubConnectionProvider::ReceivedL(const TRuntimeCtxId& aSender, const TNodeId& aRecipient, TSignatureBase& aMessage) |
|
180 { |
|
181 TNodeContext<CIPProtoDeftSubConnectionProvider> ctx(*this, aMessage, aSender, aRecipient); |
|
182 ESOCK_DEBUG_MESSAGE_INTERCEPT(aSender, aMessage, aRecipient); |
|
183 CCoreSubConnectionProvider::ReceivedL(aSender, aRecipient, aMessage); |
|
184 User::LeaveIfError(ctx.iReturn); |
|
185 } |
|
186 |
|
187 CIPProtoDeftSubConnectionProvider* CIPProtoDeftSubConnectionProvider::NewL(ESock::CSubConnectionProviderFactoryBase& aFactory) |
|
188 { |
|
189 CIPProtoDeftSubConnectionProvider* prov = new (ELeave) CIPProtoDeftSubConnectionProvider(aFactory); |
|
190 CleanupStack::PushL(prov); |
|
191 prov->ConstructL(); |
|
192 CleanupStack::Pop(prov); |
|
193 return prov; |
|
194 } |
|
195 |
|
196 CIPProtoDeftSubConnectionProvider::~CIPProtoDeftSubConnectionProvider() |
|
197 { |
|
198 if (iControl) |
|
199 delete iControl; |
|
200 if (iNotify) |
|
201 delete iNotify; |
|
202 |
|
203 LOG_NODE_DESTROY(KIPProtoDeftScprTag, CIPProtoDeftSubConnectionProvider); |
|
204 } |
|
205 |
|
206 void CIPProtoDeftSubConnectionProvider::ReturnInterfacePtrL(ADataMonitoringProtocolReq*& aInterface) |
|
207 { |
|
208 aInterface = this; |
|
209 } |
|
210 |
|
211 void CIPProtoDeftSubConnectionProvider::ReturnInterfacePtrL(ESock::ALegacySubConnectionActiveApiExt*& aInterface) |
|
212 { |
|
213 aInterface = this; |
|
214 } |
|
215 |