|
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 // hookdef.h |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 @prototype |
|
22 */ |
|
23 |
|
24 #ifndef __HOOKDEFS_H__ |
|
25 #define __HOOKDEFS_H__ |
|
26 |
|
27 #include <ip6_hook.h> |
|
28 #include <in_bind.h> |
|
29 #include <in6_event.h> |
|
30 #include "family.h" |
|
31 #include <in_sock.h> |
|
32 #include "translationtable.h" |
|
33 #include <posthook.h> |
|
34 #include <es_ini.h> |
|
35 #include "panic.h" |
|
36 #include "naptinterface.h" |
|
37 #include "naptconfigtable.h" |
|
38 |
|
39 |
|
40 /* |
|
41 ------------------------------------------------------------------------------------ |
|
42 INCOMING PACKETS FROM PUBLIC INTERFACE TO PRIVATE |
|
43 |
|
44 |
|
45 ip stack |
|
46 |
|
47 / \ |
|
48 / \ |
|
49 / \ |
|
50 |forward hook to change route| |Inbound Hook napt hook| |
|
51 / \ |
|
52 / \ |
|
53 / \ |
|
54 / \ |
|
55 / \ |
|
56 ---------- ------------- |
|
57 private interface public interface |
|
58 ------------------------------------------------------------------------------------- |
|
59 |
|
60 */ |
|
61 |
|
62 /* |
|
63 ------------------------------------------------------------------------------------ |
|
64 OUTCOMING PACKETS FROM PRIVATE INTERFACE TO PUBLIC |
|
65 |
|
66 |
|
67 ip stack |
|
68 |
|
69 / \ |
|
70 / \ |
|
71 / \ |
|
72 |forward hook napt hook| \ |
|
73 / \ |
|
74 / \ |
|
75 / \ |
|
76 / \ |
|
77 / \ |
|
78 ---------- ------------- |
|
79 private interface public interface |
|
80 ------------------------------------------------------------------------------------- |
|
81 |
|
82 */ |
|
83 |
|
84 //Definitions of ICMP messages. These messages are not supported by stack therefore |
|
85 //defining them in this file.Since NAPT will forward packets which are coming there is |
|
86 //no good reason to support only icmp messages which are supported by Stack. |
|
87 |
|
88 const TUint8 KInetICMP_Information_Request= 15; |
|
89 const TUint8 KInetICMP_Information_Reply= 16; |
|
90 const TUint8 KInet4ICMP_AddressMask_Request= 17; |
|
91 const TUint8 KInet4ICMP_AddressMask_Reply= 18; |
|
92 const TUint8 KInet4ICMP_DNS_Request= 37; |
|
93 const TUint8 KInet4ICMP_DNS_Reply= 38; |
|
94 |
|
95 //ICMP CODES |
|
96 const TUint8 KInet4ICMP_CODE_DF = 4; |
|
97 |
|
98 const TUint KProtocolNAPT = 1000; |
|
99 |
|
100 //Number of Service access points allowed |
|
101 const TUint16 KMaxNumSap = 5; |
|
102 |
|
103 class CProtocolNapt; |
|
104 class CNaptTimer; |
|
105 |
|
106 |
|
107 NONSHARABLE_CLASS(CSapNapt) : public CServProviderBase |
|
108 /** |
|
109 * Class Derived from CServProviderBase. |
|
110 * Inherit virtual functions from CServProviderBase.This Class is socket support for this |
|
111 * Hook (protocol).Protocol or Hook could be manipulated by the Socket using socket options. |
|
112 * This class will be used to take downlink information from the private client.The SAP will |
|
113 * called for all the Socket opened by the socket. SAP is 1 to 1 with Socket. |
|
114 **/ |
|
115 { |
|
116 |
|
117 public: |
|
118 friend class CProtocolNapt; |
|
119 CSapNapt(); |
|
120 ~CSapNapt(); |
|
121 void Ioctl(TUint /*level*/,TUint /* name*/,TDes8* /* anOption*/); |
|
122 |
|
123 void Start(); |
|
124 void Shutdown(TCloseType option); |
|
125 void LocalName(TSockAddr& anAddr) const; |
|
126 TInt SetLocalName(TSockAddr& anAddr); |
|
127 void RemName(TSockAddr& anAddr) const; |
|
128 TInt SetRemName(TSockAddr& anAddr); |
|
129 TInt GetOption(TUint /*level*/,TUint /*name*/,TDes8& /*anOption*/)const; |
|
130 void CancelIoctl(TUint /*aLevel*/,TUint /*aName*/); |
|
131 TInt SetOption(TUint aLevel,TUint aName,const TDesC8& anOption); |
|
132 void ActiveOpen(); |
|
133 void ActiveOpen(const TDesC8& /*aConnectionData*/); |
|
134 TInt PassiveOpen(TUint /*aQueSize*/); |
|
135 TInt PassiveOpen(TUint /*aQueSize*/,const TDesC8& /*aConnectionData*/); |
|
136 void Shutdown(TCloseType /*option*/,const TDesC8& /*aDisconnectionData*/); |
|
137 void AutoBind(); |
|
138 TInt SecurityCheck(MProvdSecurityChecker* aChecker); |
|
139 TNaptConfigInfo* GetConfigInfo(); |
|
140 void SetConfigInfo(TNaptConfigInfo *cinfo); |
|
141 |
|
142 private: |
|
143 void DoBindToL(TInt aStatus); |
|
144 CProtocolNapt* iProtocol; |
|
145 CNaptClientConfigMgr* iConfigMgr; |
|
146 TNaptConfigInfo* iConfigInfo; |
|
147 }; //End Class CProtocolSap |
|
148 |
|
149 |
|
150 class CProtocolNaptIn; |
|
151 |
|
152 NONSHARABLE_CLASS(CProtocolNapt) : public CProtocolPosthook |
|
153 /** |
|
154 * Class Derived from CIp6Hook. |
|
155 * The class will implement all the virtual functions of Base class CIp6Hook (ApplyL). |
|
156 * The class object will be the Protocol instance will open service access point for that |
|
157 * Protocol.Service access point will be used to manipulate Protocol using socket option. |
|
158 * This will Open interested flows for manipulation. |
|
159 **/ |
|
160 |
|
161 { |
|
162 public: |
|
163 friend class CProtocolNaptIn; |
|
164 static CProtocolNapt* NewL(); |
|
165 ~CProtocolNapt(); |
|
166 void Identify(TServerProtocolDesc* aProtocolDesc)const; |
|
167 TInt ApplyL(RMBufHookPacket& aPacket, RMBufRecvInfo& aInfo); |
|
168 void BindL(CProtocolBase* protocol, TUint id); |
|
169 void BindToL(CProtocolBase* aProtocol); |
|
170 CServProviderBase* NewSAPL(TUint aProtocol); |
|
171 void ForwardManipulation(RMBufHookPacket& aPacket,RMBufRecvInfo& aInfo); |
|
172 void IcmpHandlerForward(RMBufHookPacket& aPacket, RMBufRecvInfo& aInfo); |
|
173 static void Describe(TServerProtocolDesc& anEntry); |
|
174 void NetworkAttachedL(); |
|
175 virtual MNetworkService *NetworkService() |
|
176 { |
|
177 return CProtocolPosthook::NetworkService(); |
|
178 } |
|
179 |
|
180 void ReadConfigurationFile(); |
|
181 void ConfigInfo(); |
|
182 TInt GetIniValue(const TDesC& aSection, const TDesC& aName, TInt aDefault, TInt aMin, TInt aMax); |
|
183 TNaptTableMapMgr iNaptMapMgr; |
|
184 void CancelSap(CSapNapt *aSap); |
|
185 private: |
|
186 void CreateL(); |
|
187 MInterfaceManager* iManager; |
|
188 |
|
189 //table related information |
|
190 CNaptTimer* iTimer; |
|
191 CProtocolNaptIn* iProtInbound; |
|
192 RPointerArray<CSapNapt> iSapList; |
|
193 CNaptClientConfigMgr* iConfigMgr; |
|
194 TNaptConfigInfo* iCurConfigInfo; |
|
195 |
|
196 public: |
|
197 TBool iBoundFlag; |
|
198 CProtocolBase* iProtBase; |
|
199 |
|
200 }; //End class CProtocolNapt |
|
201 |
|
202 NONSHARABLE_CLASS(CProtocolNaptIn) : public CIp6Hook |
|
203 /** |
|
204 * Class Derived from CIp6Hook. |
|
205 * The class will implement all the virtual functions of Base class CIp6Hook (ApplyL). |
|
206 * The class object will be the Protocol instance will open service access point for that |
|
207 * Protocol.Service access point will be used to manipulate Protocol using socket option. |
|
208 * This will Open interested flows for manipulation. |
|
209 **/ |
|
210 { |
|
211 public: |
|
212 CProtocolNaptIn(CProtocolNapt* aNapt); |
|
213 ~CProtocolNaptIn(); |
|
214 TInt IncomingPacketManipulation(RMBufHookPacket& aPacket, RMBufRecvInfo& aInfo); |
|
215 TInt ApplyL(RMBufHookPacket& aPacket, RMBufRecvInfo& aInfo); |
|
216 TInt IcmpHandler(RMBufHookPacket& aPacket, RMBufRecvInfo& aInfo) ; |
|
217 TInt IcmpHandlerTracert(RMBufHookPacket& aPacket, RMBufRecvInfo& aInfo, TNaptConfigInfo** aConfigInfo); |
|
218 |
|
219 private: |
|
220 CProtocolNapt* iNapt; |
|
221 CNaptClientConfigMgr *iConfigMgr; |
|
222 |
|
223 }; |
|
224 |
|
225 NONSHARABLE_CLASS(CNaptTimer) : public CTimer |
|
226 /** |
|
227 * Class CNaptTimer deriver from CTimer. |
|
228 * Timer instance is created during hook attach time. |
|
229 * It will be started only when a first packet needs NAPT translation. |
|
230 * Timer will be stopped only when there are no packets. |
|
231 */ |
|
232 { |
|
233 |
|
234 public: |
|
235 static CNaptTimer* NewL(CProtocolNapt* aNaptProtcol); |
|
236 ~CNaptTimer(); |
|
237 |
|
238 void StartTimer(); |
|
239 void Cancel(); |
|
240 void RunL(); |
|
241 |
|
242 TInt iNaptTableScanInterval; |
|
243 TInt iNaptTcpIdleTimeout; |
|
244 TInt iNaptUdpIdleTimeout; |
|
245 TInt iNaptIcmpIdleTimeout; |
|
246 TInt iNaptTcpOpenTimeout; |
|
247 TInt iNaptTcpCloseTimeout; |
|
248 |
|
249 private: |
|
250 CNaptTimer(); |
|
251 CProtocolNapt* iNaptProtocol; |
|
252 TNaptTableMapMgr* iMapMgrPtr; |
|
253 |
|
254 |
|
255 |
|
256 }; |
|
257 |
|
258 inline CNaptTimer::CNaptTimer() : CTimer(EPriorityStandard) |
|
259 { |
|
260 } |
|
261 |
|
262 |
|
263 |
|
264 #endif //__HOOKDEFS_H__ |