|
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 // Core CPR Implementation |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #include <comms-infras/corecpr.h> |
|
24 #include <comms-infras/corecprstates.h> |
|
25 #include <comms-infras/corecpractivities.h> |
|
26 |
|
27 #include <comms-infras/ss_nodemessages_factory.h> |
|
28 #include <comms-infras/ss_log.h> |
|
29 #include <comms-infras/ss_nodeinterfaces.h> |
|
30 #include <elements/sm_statetriple.h> |
|
31 #include <elements/nm_signatures.h> |
|
32 |
|
33 _LIT(KPanicCategory, "corecpr"); |
|
34 |
|
35 #if defined(__CFLOG_ACTIVE) || defined(SYMBIAN_TRACE_ENABLE) |
|
36 _LIT8(KCoreCprSubTag, "corecpr"); |
|
37 #endif |
|
38 |
|
39 //We reserve space for two preallocated activities that may start concurrently on the CPR |
|
40 //node: destroy and data client stop. |
|
41 static const TUint KDefaultMaxPreallocatedActivityCount = 2; |
|
42 static const TUint KMaxPreallocatedActivitySize = sizeof(MeshMachine::CNodeRetryParallelActivity) + sizeof(MeshMachine::APreallocatedOriginators<4>); |
|
43 static const TUint KCPRPreallocatedActivityBufferSize = KDefaultMaxPreallocatedActivityCount * KMaxPreallocatedActivitySize; |
|
44 |
|
45 using namespace ESock; |
|
46 using namespace NetStateMachine; |
|
47 using namespace Messages; |
|
48 using namespace MeshMachine; |
|
49 |
|
50 |
|
51 EXPORT_C CCoreConnectionProvider::CCoreConnectionProvider(CConnectionProviderFactoryBase& aFactory, |
|
52 const MeshMachine::TNodeActivityMap& aActivityMap) |
|
53 : CConnectionProviderBase(aFactory,aActivityMap) |
|
54 { |
|
55 LOG_NODE_CREATE(KCoreCprSubTag, CCoreConnectionProvider); |
|
56 } |
|
57 |
|
58 EXPORT_C CCoreConnectionProvider* CCoreConnectionProvider::NewL(CConnectionProviderFactoryBase& aFactory) |
|
59 { |
|
60 CCoreConnectionProvider* provider = new (ELeave) CCoreConnectionProvider(aFactory,CprActivities::coreCprActivities::Self()); |
|
61 CleanupStack::PushL(provider); |
|
62 provider->ConstructL(KCPRPreallocatedActivityBufferSize); |
|
63 CleanupStack::Pop(provider); |
|
64 return provider; |
|
65 } |
|
66 |
|
67 EXPORT_C CCoreConnectionProvider::~CCoreConnectionProvider() |
|
68 { |
|
69 LOG_NODE_DESTROY(KCoreCprSubTag, CCoreConnectionProvider); |
|
70 } |
|
71 |
|
72 |
|
73 EXPORT_C void CCoreConnectionProvider::Received(TNodeContextBase& aContext) |
|
74 { |
|
75 Messages::TNodeSignal::TMessageId noPeerIds[] = { |
|
76 TCFFactory::TPeerFoundOrCreated::Id(), |
|
77 TCFPeer::TJoinRequest::Id(), |
|
78 TEBase::TError::Id(), |
|
79 Messages::TNodeSignal::TMessageId() |
|
80 }; |
|
81 MeshMachine::AMMNodeBase::Received(noPeerIds, aContext); |
|
82 MeshMachine::AMMNodeBase::PostReceived(aContext); |
|
83 } |
|
84 |
|
85 EXPORT_C void CCoreConnectionProvider::ReceivedL(const TRuntimeCtxId& aSender, const TNodeId& aRecipient, TSignatureBase& aMessage) |
|
86 { |
|
87 TNodeContext<CCoreConnectionProvider> ctx(*this, aMessage, aSender, aRecipient); |
|
88 CCoreConnectionProvider::Received(ctx); |
|
89 User::LeaveIfError(ctx.iReturn); |
|
90 } |
|
91 |
|
92 |
|
93 TUint CCoreConnectionProvider::Priority() const |
|
94 { |
|
95 TUint currentPriority = KMaxTUint; |
|
96 |
|
97 const TAccessPointPriority* apPriorityExt = static_cast<const TAccessPointPriority*>(AccessPointConfig().FindExtension( |
|
98 STypeId::CreateSTypeId(TAccessPointPriority::EUid, TAccessPointPriority::ETypeId))); |
|
99 __ASSERT_DEBUG(apPriorityExt, User::Panic(KPanicCategory, CorePanics::KPanicUnexpectedExecutionPath)); |
|
100 |
|
101 TClientIter<TDefaultClientMatchPolicy> iter = GetClientIter<TDefaultClientMatchPolicy>(TClientType(TCFClientType::ECtrl)); |
|
102 RCFNodePriorityInterface* ctrlClient = static_cast<RCFNodePriorityInterface*>(iter++); |
|
103 |
|
104 while (ctrlClient) |
|
105 { |
|
106 if (ctrlClient->Priority() < currentPriority) |
|
107 { |
|
108 currentPriority = ctrlClient->Priority(); |
|
109 } |
|
110 ctrlClient = static_cast<RCFNodePriorityInterface*>(iter++); |
|
111 } |
|
112 |
|
113 if (apPriorityExt && apPriorityExt->Priority() < currentPriority) |
|
114 { |
|
115 currentPriority = apPriorityExt->Priority(); |
|
116 } |
|
117 |
|
118 return currentPriority; |
|
119 } |
|
120 |
|
121 |