|
1 // Copyright (c) 1997-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 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #ifndef __SS_PMAN_H__ |
|
22 #define __SS_PMAN_H__ |
|
23 |
|
24 #include <es_prot.h> |
|
25 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
26 #include <es_prot_internal.h> |
|
27 #endif |
|
28 |
|
29 #include <comms-infras/api_ext_msg.h> |
|
30 |
|
31 #ifdef SYMBIAN_ZERO_COPY_NETWORKING |
|
32 #include <comms-infras/commsbufpond.h> |
|
33 #endif |
|
34 |
|
35 namespace ESock |
|
36 { |
|
37 class CSocket; |
|
38 class CHostResolver; |
|
39 class CServiceResolver; |
|
40 class CNetDatabase; |
|
41 } |
|
42 class CSocketServer; |
|
43 class CProtocolBase; |
|
44 class CMBufManager; |
|
45 class CSockSession; |
|
46 struct TProtocolDesc; |
|
47 class CProtocolRef; |
|
48 class CMBufManager; |
|
49 class CDeltaTimer; |
|
50 class CESockIniData; |
|
51 |
|
52 // |
|
53 // Housekeeping structures used internally by the Protocol manager. |
|
54 // |
|
55 class CProtocolFamilyBase; |
|
56 class CProtocolBase; |
|
57 |
|
58 typedef TSglQue<CProtocolRef> TProtocolRefList; |
|
59 NONSHARABLE_CLASS(CProtocolFamilyRef) : public CBase |
|
60 /** |
|
61 @internalComponent |
|
62 */ |
|
63 { |
|
64 #ifdef __FLOG_ACTIVE |
|
65 friend class TProtocolManagerLogger; |
|
66 #endif |
|
67 public: |
|
68 enum TManagerProtFamilyFlags |
|
69 { |
|
70 EInstalled=0x00000001, |
|
71 }; |
|
72 TSglQueLink iLink; |
|
73 public: |
|
74 ~CProtocolFamilyRef(); |
|
75 static CProtocolFamilyRef* GetProtocolFamilyL(TDesC& aName); |
|
76 void LoadL(); |
|
77 CProtocolFamilyBase& ProtocolFamilyL(TBool aInstall=ETrue); |
|
78 inline void Close(); |
|
79 inline void FamilyClosed(); |
|
80 private: |
|
81 CProtocolFamilyRef(); |
|
82 private: |
|
83 TInt iFlags; |
|
84 CProtocolFamilyBase* iProtocolFamily; |
|
85 HBufC* iLibFileName; |
|
86 }; |
|
87 |
|
88 class Nif; |
|
89 NONSHARABLE_CLASS(CProtocolRef) : public CBase |
|
90 /** |
|
91 @internalComponent |
|
92 */ |
|
93 { |
|
94 friend class Nif; |
|
95 public: |
|
96 enum TManagerProtocolFlags |
|
97 { |
|
98 EInited=0x00000001, |
|
99 EStarted=0x00000002, |
|
100 EBound=0x00000004, |
|
101 EThreePlaneCommsBased=0x00000008, |
|
102 }; |
|
103 TSglQueLink iLink; |
|
104 |
|
105 public: |
|
106 ~CProtocolRef(); |
|
107 TBool Matches(TUint anAddrFamily,TUint aSocketType,TUint aProtocol); |
|
108 static CProtocolRef* GetProtocolL(const TDesC& aName); |
|
109 static CProtocolRef* MakeRefL(const TDesC& aName,CProtocolFamilyRef* aFamily=NULL,TServerProtocolDesc* info=NULL); |
|
110 static CProtocolRef* MakeRefL(const TDesC& aName, TServerProtocolDesc* info); |
|
111 inline void LoadAndBindL(); |
|
112 CProtocolBase* Protocol(); |
|
113 inline CProtocolFamilyBase* Family(); |
|
114 TServerProtocolDesc& Info(); |
|
115 inline void ProtocolClosed(); |
|
116 inline void Close(); |
|
117 inline TPtrC Tag(); |
|
118 inline void SetFlag(TUint aFlag){iFlags=aFlag;}; |
|
119 inline TUint GetFlag(){return iFlags;}; |
|
120 |
|
121 private: |
|
122 void StartL(); |
|
123 void ResolveBindingL(); |
|
124 void LoadL(TBool aLoadForBinding); |
|
125 CProtocolRef(); |
|
126 void DoBindingL(const CESockIniData& anIniFile); |
|
127 void ProcessBindListL(TPtrC aBindList, const CESockIniData& aIniFile); |
|
128 static void Cleanup(TAny* aFamily); |
|
129 static CProtocolRef* GetProtocolNoCreate(TProtocolRefList* aProtocolList, const TDesC& aTag); |
|
130 |
|
131 private: |
|
132 TUid iUid; |
|
133 HBufC* iTag; |
|
134 TUint iFlags; |
|
135 TServerProtocolDesc iInfo; |
|
136 CProtocolBase* iProtocol; |
|
137 CProtocolFamilyRef* iFamily; |
|
138 }; |
|
139 |
|
140 class SocketServer; |
|
141 class CSocketServExtBase; |
|
142 NONSHARABLE_CLASS(CSocketServExtRef) : public CBase |
|
143 /** |
|
144 @internalComponent |
|
145 */ |
|
146 { |
|
147 friend class CSockManData; |
|
148 public: |
|
149 CSocketServExtRef(); |
|
150 virtual ~CSocketServExtRef(); |
|
151 void InstallL(const TDesC& aDllName, const TDesC& aParam); |
|
152 void Remove(); |
|
153 void Close(); |
|
154 private: |
|
155 TDblQueLink iExtLink; |
|
156 RLibrary iLibrary; |
|
157 CSocketServExtBase* iExtension; |
|
158 CAsyncCallBack* iDestructor; |
|
159 public: |
|
160 inline CSocketServExtBase* Extension() { return iExtension; } |
|
161 }; |
|
162 |
|
163 /** |
|
164 @internalComponent |
|
165 */ |
|
166 typedef CSocketServExtBase* (*TSocketServExtInstallFn)(); |
|
167 |
|
168 #if !defined (__WINS__) |
|
169 #define VERBOSE |
|
170 #endif |
|
171 |
|
172 #if defined (VERBOSE) |
|
173 #define VERBOSE_ONLY(x) x |
|
174 #else |
|
175 #define VERBOSE_ONLY(x) |
|
176 #endif |
|
177 |
|
178 class CPlayer; |
|
179 struct TServerProtocolDesc; |
|
180 |
|
181 namespace ESock |
|
182 { |
|
183 class CTransportFlowShim; |
|
184 } |
|
185 |
|
186 class CInternalSocketImpl; |
|
187 class ProtocolManager |
|
188 /** |
|
189 @internalComponent |
|
190 */ |
|
191 { |
|
192 friend class SocketServer; |
|
193 friend class ESock::CTransportFlowShim; |
|
194 friend class ESock::CSocket; |
|
195 friend class CPlayer; |
|
196 |
|
197 public: |
|
198 static void LoadProtocolL(TUint anAddrFamily, TUint aSocketType, TUint aProtocol, CPlayer* aPlayer); |
|
199 static void UnLoadProtocolL(TUint anAddrFamily, TUint aSocketType, TUint aProtocol, CPlayer* aPlayer); |
|
200 static ESock::CHostResolver* NewHostResolverL(TUint anAddrFamily, TUint aSocketType, CPlayer* aPlayer, const TSubSessionUniqueId aSubSessionUniqueId); |
|
201 static ESock::CServiceResolver* NewServiceResolverL(TUint anAddrFamily, TUint aSocketType, TUint aProtocolId, CPlayer* aPlayer, const TSubSessionUniqueId aSubSessionUniqueId); |
|
202 static ESock::CNetDatabase* NewNetDatabaseL(TUint anAddrFamily, TUint aSocketType, CPlayer* aPlayer, const TSubSessionUniqueId aSubSessionUniqueId); |
|
203 static TUint NumProtocols(void); |
|
204 static TInt ProtocolInfo(TUint anIndex,TProtocolDesc& aProtocol); |
|
205 static TInt ProtocolInfo(const TDesC& aName,TProtocolDesc& aProtocol); |
|
206 static TInt ProtocolInfo(const TDesC& aName,TServerProtocolDesc& aProtocol); |
|
207 static CProtocolBase* FindAndLoadProtocolL(const TDesC& aName, TProtocolType aType=ENormalProtocol); |
|
208 static CProtocolBase* FindAndLoadProtocolL(TUint aAddrFamily,TUint aSockType,TUint aProtocol); |
|
209 static void TransferSocketL(ESock::CSocket* aSocket, CPlayer* aPlayer); |
|
210 static TBool GetDependency(const TDesC& aTag,TPtrC& aList); |
|
211 static void ProcessIniDataL(); |
|
212 static void InitL(); |
|
213 static CInternalSocketImpl* NewInternalSocketL ( TAny* aParams, const TDesC& aName ); |
|
214 static CInternalSocketImpl* NewInternalSocketL ( TAny* aParams, TUint aAddrFamily, TUint aSockType, TUint aProtocol ); |
|
215 private: |
|
216 static void ShutDown(void); |
|
217 static CProtocolRef* FindProtocolL(TInt anAddrFamily,TUint aSocketType,TInt aProtocol); |
|
218 static void CleanupProtocol(TAny* aProtocol); |
|
219 static void AddDependencyL(const TDesC& aDependentsList, const TDesC& aModuleToLoad); |
|
220 static void SafeCleanupProtocol(TAny* aProtocolRef); |
|
221 }; |
|
222 |
|
223 class CWorkerThread; |
|
224 class SocketServer |
|
225 /** |
|
226 @internalComponent |
|
227 */ |
|
228 { |
|
229 public: |
|
230 static void InitL(CWorkerThread* aWorker); |
|
231 static void ShutDown(void); |
|
232 static RHeap* Heap(); |
|
233 #ifdef SYMBIAN_ZERO_COPY_NETWORKING |
|
234 static RCommsBufPond GetCommsBufPond(); |
|
235 #else |
|
236 static CMBufManager* GetMBufManager(); |
|
237 #endif |
|
238 static CDeltaTimer* GetTimer(); |
|
239 static CSocketServer* GetSocketServer(); |
|
240 static void NewSession(); |
|
241 static void SessionClosing(); |
|
242 static TBool IsShuttingDown(); |
|
243 static void ShutdownExtensions(); |
|
244 static void InstallExtensionL(const TDesC& aDllName, const TDesC& aArgs); |
|
245 static IMPORT_C void __DbgForceLoadMBufManagerL(); |
|
246 static IMPORT_C void __DbgForceKillMBufManager(); |
|
247 }; |
|
248 |
|
249 #ifdef __MARM__ |
|
250 //const TInt KTimerGranularity = 100000; |
|
251 |
|
252 /** |
|
253 @internalComponent |
|
254 */ |
|
255 const TInt KTimerGranularity = 15500; |
|
256 #else |
|
257 const TInt KTimerGranularity = 80000; |
|
258 #endif |
|
259 |
|
260 #ifdef __FLOG_ACTIVE |
|
261 // Dumping out the set of loaded families and protocols aids debugging shutdown hangs |
|
262 NONSHARABLE_CLASS(TProtocolManagerLogger) |
|
263 { |
|
264 public: |
|
265 static void LogLoadedInfo(); |
|
266 }; |
|
267 #endif |
|
268 |
|
269 |
|
270 #include <ss_pman.inl> |
|
271 |
|
272 #endif |