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