|
1 // Copyright (c) 2003-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 // tunnelnif.h |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #if (!defined TUNNELFLOW_H__) |
|
24 #define TUNNELFLOW_H__ |
|
25 |
|
26 #include <comms-infras/nifif.h> |
|
27 #include <nifutl.h> |
|
28 #include <in6_if.h> |
|
29 #include <eui_addr.h> // TE64Addr |
|
30 #include <comms-infras/ss_subconnflow.h> |
|
31 #include <comms-infras/ss_flowbinders.h> |
|
32 #include "tunnelProvision.h" |
|
33 #include "TunnelAgentHandler.h" |
|
34 |
|
35 enum TTunnelPanic |
|
36 { |
|
37 ETunnelPanic_ObjectNotDeleted, |
|
38 ETunnelPanic_BadState, |
|
39 ETunnelPanic_UnexpectedMessage, |
|
40 ETunnelPanic_BadBind, |
|
41 ETunnelPanic_BadUnbind |
|
42 }; |
|
43 |
|
44 void Panic(TTunnelPanic aPanic); |
|
45 |
|
46 class CTunnelNcp4; |
|
47 class CTunnelNcp6; |
|
48 struct TTunnelInfo; |
|
49 |
|
50 /** |
|
51 * The link controller. |
|
52 * The purpose of this class in our case is to communicate with |
|
53 * the agent. |
|
54 * It is also responsible for creating and maintaining the NCP |
|
55 */ |
|
56 NONSHARABLE_CLASS(CTunnelFlow) : public ESock::CSubConnectionFlowBase, public ESock::MFlowBinderControl |
|
57 { |
|
58 |
|
59 public: |
|
60 CTunnelFlow(ESock::CSubConnectionFlowFactoryBase& aFactory, const Messages::TNodeId& aSubConnId, ESock::CProtocolIntfBase* aProtocolIntf); |
|
61 ~CTunnelFlow(); |
|
62 |
|
63 // |
|
64 // from CSubConnectionFlowBase |
|
65 // |
|
66 virtual ESock::MFlowBinderControl* DoGetBinderControlL(); |
|
67 |
|
68 // |
|
69 // from MFlowBinderControl |
|
70 // |
|
71 virtual ESock::MLowerControl* GetControlL(const TDesC8& aProtocol); |
|
72 virtual ESock::MLowerDataSender* BindL(const TDesC8& aProtocol, ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl); |
|
73 virtual void Unbind( ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl); |
|
74 virtual ESock::CSubConnectionFlowBase* Flow(); |
|
75 |
|
76 // |
|
77 // Other Utility functions |
|
78 // |
|
79 inline const TTunnelInfo* Info(); |
|
80 |
|
81 protected: |
|
82 // |
|
83 // from CSubConnectionFlowBase |
|
84 // |
|
85 virtual void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage); |
|
86 |
|
87 private: |
|
88 // |
|
89 // Utility functions for processing incoming SCPR messages |
|
90 // |
|
91 void StartFlowL(); |
|
92 void StopFlow(TInt aError); |
|
93 void ProvisionConfig(const ESock::RMetaExtensionContainerC& aConfigData); |
|
94 void Destroy(); |
|
95 TInt Notification(TTunnelAgentMessage::TTunnelSetAddress& aMessage); |
|
96 |
|
97 // |
|
98 // Utility functions for sending messages to SCPR |
|
99 // |
|
100 void PostProgressMessage(TInt aStage, TInt aError); |
|
101 inline void PostDataClientStartedMessage(); // inline as only used once |
|
102 inline void PostFlowDownMessage(TInt aError); // inline as only used once |
|
103 void MaybePostDataClientIdle(); |
|
104 |
|
105 private: |
|
106 CTunnelNcp4* iNifIf4; // IP4 binder |
|
107 CTunnelNcp6* iNifIf6; // IP6 binder |
|
108 enum TMeshMachineFlowState |
|
109 { |
|
110 EStopped, |
|
111 EStarting, |
|
112 EStarted, |
|
113 EStopping, |
|
114 }; |
|
115 TMeshMachineFlowState iMMState; |
|
116 |
|
117 // Provisioning information |
|
118 const TTunnelInfo* iProvisionInfo; // pointer to Tunnel provisioning information in AccessPointConfig |
|
119 |
|
120 TInt iSavedError; // an errors saved from processing ProvisionConfig message (until StartFlow) |
|
121 }; |
|
122 |
|
123 // =========================================================================================== |
|
124 // |
|
125 // Inline functions |
|
126 // |
|
127 |
|
128 inline void CTunnelFlow::PostDataClientStartedMessage() |
|
129 /** |
|
130 Post a FlowUp message to the SCPR |
|
131 */ |
|
132 { |
|
133 iSubConnectionProvider.PostMessage(Id(), ESock::TCFDataClient::TStarted().CRef()); |
|
134 } |
|
135 |
|
136 inline void CTunnelFlow::PostFlowDownMessage(TInt aError) |
|
137 /** |
|
138 Post a FlowDown message to the SCPR |
|
139 */ |
|
140 { |
|
141 iSubConnectionProvider.PostMessage(Id(), ESock::TCFDataClient::TStopped(aError).CRef()); |
|
142 iMMState = EStopped; |
|
143 } |
|
144 |
|
145 inline const TTunnelInfo* CTunnelFlow::Info() |
|
146 /** |
|
147 Retrieve the provisioning information |
|
148 */ |
|
149 { |
|
150 ASSERT(iProvisionInfo); |
|
151 return iProvisionInfo; |
|
152 } |
|
153 |
|
154 #endif |