|
1 // Copyright (c) 2007-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 // |
|
15 |
|
16 #include <comms-infras/ss_metaconnprov.h> |
|
17 #include <comms-infras/ss_nodeinterfaces.h> |
|
18 #include <elements/nm_messages_errorrecovery.h> |
|
19 #include <comms-infras/ss_mcprnodemessages.h> |
|
20 #include "pdpmcpr.h" |
|
21 #include "pdpmcprstates.h" |
|
22 |
|
23 using namespace ESock; |
|
24 using namespace NetStateMachine; |
|
25 using namespace Messages; |
|
26 |
|
27 namespace PdpMCprStates |
|
28 { |
|
29 } |
|
30 |
|
31 namespace PdpMCprErrorRecoveryActivity |
|
32 { |
|
33 |
|
34 DEFINE_SMELEMENT(CPdpErrorRecoveryActivity::TAwaitingContentionResult, NetStateMachine::MState, PdpMCprStates::TContext) |
|
35 TBool CPdpErrorRecoveryActivity::TAwaitingContentionResult::Accept() |
|
36 { |
|
37 TPdpContentionMessages::TPdpContentionResultMessage* msg = message_cast<TPdpContentionMessages::TPdpContentionResultMessage>(&iContext.iMessage); |
|
38 CPdpErrorRecoveryActivity& activity = static_cast<CPdpErrorRecoveryActivity&>(*iContext.iNodeActivity); |
|
39 if(msg && msg->iNodeId == activity.iPendingCprId) |
|
40 { |
|
41 return ETrue; |
|
42 } |
|
43 return EFalse; |
|
44 } |
|
45 |
|
46 |
|
47 DEFINE_SMELEMENT(CPdpErrorRecoveryActivity::TPdpContentionNoTagOrError, NetStateMachine::MStateFork, PdpMCprStates::TContext) |
|
48 TInt CPdpErrorRecoveryActivity::TPdpContentionNoTagOrError::TransitionTag() |
|
49 { |
|
50 CPdpErrorRecoveryActivity& activity = static_cast<CPdpErrorRecoveryActivity&>(*iContext.iNodeActivity); |
|
51 |
|
52 if (activity.iPendingCprId == Messages::TNodeId::NullId()) |
|
53 { |
|
54 return MeshMachine::KErrorTag; |
|
55 } |
|
56 else |
|
57 { |
|
58 return MeshMachine::KNoTag; |
|
59 } |
|
60 } |
|
61 |
|
62 DEFINE_SMELEMENT(CPdpErrorRecoveryActivity::TProcessErrorRecoveryReq, NetStateMachine::MStateTransition, PdpMCprStates::TContext) |
|
63 void CPdpErrorRecoveryActivity::TProcessErrorRecoveryReq::DoL() |
|
64 { |
|
65 TEErrorRecovery::TErrorRecoveryRequest& req = message_cast<TEErrorRecovery::TErrorRecoveryRequest>(iContext.iMessage); |
|
66 TInt error = req.iErrContext.iStateChange.iError; |
|
67 |
|
68 #ifdef SYMBIAN_NETWORKING_CONTENTION_MANAGEMENT |
|
69 if (req.iErrContext.iStateChange.iError == KErrUmtsMaxNumOfContextExceededByNetwork || |
|
70 req.iErrContext.iStateChange.iError == KErrUmtsMaxNumOfContextExceededByPhone) |
|
71 { |
|
72 // Get sender's priority |
|
73 TClientIter<TDefaultClientMatchPolicy> iter = iContext.Node().GetClientIter<TDefaultClientMatchPolicy>(TCFClientType(TCFClientType::EData)); |
|
74 ESock::RCFNodePriorityInterface* dataClient; |
|
75 TBool wasFound = EFalse; |
|
76 TUint cprPriority = KMaxTUint; |
|
77 while ((dataClient = static_cast<RCFNodePriorityInterface*>(iter++)) != NULL) |
|
78 { |
|
79 if (dataClient->RecipientId() == req.iErrContext.iOriginator) |
|
80 { |
|
81 cprPriority = dataClient->Priority(); |
|
82 wasFound = ETrue; |
|
83 } |
|
84 } |
|
85 if (wasFound) |
|
86 { |
|
87 TInt err = KErrNone; |
|
88 TBool result = EFalse; |
|
89 TRAP(err, result = iContext.Node().GetTierManager()->HandleContentionL(&iContext.Node(), req.iErrContext.iOriginator, cprPriority)); |
|
90 if (err == KErrNone && result) |
|
91 { |
|
92 CPdpErrorRecoveryActivity& activity = static_cast<CPdpErrorRecoveryActivity&>(*iContext.iNodeActivity); |
|
93 activity.iPendingCprId = req.iErrContext.iOriginator; |
|
94 activity.iCprActivity = req.iErrContext.iActivitySigId; |
|
95 activity.iCprMessageId = req.iErrContext.iMessageId; |
|
96 activity.iErrorCode = error; |
|
97 // The contention request has been added into query, Reset message error code. |
|
98 // TErrResponse will be send from Mcpr's ContentionResolved function. |
|
99 error = KErrNone; |
|
100 } |
|
101 } |
|
102 } |
|
103 #endif |
|
104 |
|
105 if (error != KErrNone) |
|
106 { |
|
107 TErrResponse propagateResp(TErrResponse::EPropagate, error, req.iErrContext.iMessageId); |
|
108 TEErrorRecovery::TErrorRecoveryResponse rawResp (propagateResp); |
|
109 |
|
110 TCFSafeMessage::TResponseCarrierWest<TEErrorRecovery::TErrorRecoveryResponse> resp(rawResp, iContext.iSender); |
|
111 iContext.PostToSender(resp); |
|
112 } |
|
113 } |
|
114 |
|
115 DEFINE_SMELEMENT(CPdpErrorRecoveryActivity::TProcessContentionResult, NetStateMachine::MStateTransition, PdpMCprStates::TContext) |
|
116 void CPdpErrorRecoveryActivity::TProcessContentionResult::DoL() |
|
117 { |
|
118 TPdpContentionMessages::TPdpContentionResultMessage* msg = message_cast<TPdpContentionMessages::TPdpContentionResultMessage>(&iContext.iMessage); |
|
119 CPdpErrorRecoveryActivity& activity = static_cast<CPdpErrorRecoveryActivity&>(*iContext.iNodeActivity); |
|
120 if (msg->iValue != 0) |
|
121 { |
|
122 TErrResponse retryResp(TErrResponse::ERetry, 0, activity.iCprMessageId); |
|
123 TEErrorRecovery::TErrorRecoveryResponse rawResp (retryResp); |
|
124 TCFSafeMessage::TResponseCarrierWest<TEErrorRecovery::TErrorRecoveryResponse> resp(rawResp, activity.iOriginators[0].RecipientId()); |
|
125 iContext.PostToSender(resp); |
|
126 } |
|
127 else |
|
128 { |
|
129 TErrResponse propagateResp(TErrResponse::EPropagate, activity.iErrorCode, activity.iCprMessageId); |
|
130 TEErrorRecovery::TErrorRecoveryResponse rawResp (propagateResp); |
|
131 TCFSafeMessage::TResponseCarrierWest<TEErrorRecovery::TErrorRecoveryResponse> resp(rawResp, activity.iOriginators[0].RecipientId()); |
|
132 iContext.PostToSender(resp); |
|
133 } |
|
134 } |
|
135 } |
|
136 |