|
1 /* |
|
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Name : 6to4_tunnel.h |
|
16 * Part of : 6to4 plugin / 6to4.prt |
|
17 * Implements 6to4 automatic and configured tunnels, see |
|
18 * RFC 3056 & RFC 2893 |
|
19 * Version : 0.2 |
|
20 * |
|
21 */ |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 /** |
|
27 @internalComponent |
|
28 */ |
|
29 |
|
30 #ifndef __6TO4_TUNNEL_H |
|
31 #define __6TO4_TUNNEL_H |
|
32 |
|
33 // INCLUDES |
|
34 #include <e32base.h> |
|
35 #include <in_sock.h> |
|
36 |
|
37 // CONSTANTS |
|
38 // MACROS |
|
39 // DATA TYPES |
|
40 class CTunnel; // This forward declaration is needed already here. |
|
41 typedef TDblQue < CTunnel > TTunnelQueue; |
|
42 typedef TDblQueIter < CTunnel > TTunnelQueueIter; |
|
43 |
|
44 // FUNCTION PROTOTYPES |
|
45 // FORWARD DECLARATIONS |
|
46 |
|
47 // CLASS DECLARATION |
|
48 |
|
49 /** |
|
50 * Parser class for configured tunnels initialization file |
|
51 * Parses and generates the tunnels requested in the initialization file. |
|
52 * |
|
53 * @lib |
|
54 * @since |
|
55 */ |
|
56 class TTunnelParser : public TLex |
|
57 { |
|
58 public: // Constructors and destructor |
|
59 TTunnelParser (); |
|
60 |
|
61 // Destructor |
|
62 ~TTunnelParser (); |
|
63 |
|
64 public: // New functions |
|
65 |
|
66 /** |
|
67 * Parse tunnel configuration file |
|
68 * @since |
|
69 * @param |
|
70 * @return TInt KErrNone if success |
|
71 */ |
|
72 TInt ParseL (const TDesC & aTunnelData); |
|
73 |
|
74 /** |
|
75 * Private data access |
|
76 * @since |
|
77 * @param |
|
78 * @return TTunnelQueue& Queue |
|
79 */ |
|
80 inline TTunnelQueue& TunnelQueue() { return iTunnelQueue; } |
|
81 |
|
82 private: |
|
83 |
|
84 typedef enum |
|
85 { |
|
86 ETokenTypeString, |
|
87 ETokenTypeInt, |
|
88 ETokenTypeEqual, |
|
89 ETokenTypeComma, |
|
90 ETokenTypeBraceLeft, |
|
91 ETokenTypeBraceRight, |
|
92 ETokenTypeParLeft, |
|
93 ETokenTypeParRight, |
|
94 ETokenTypeComment, |
|
95 ETokenTypeError, |
|
96 ETokenTypeEof |
|
97 } |
|
98 TTokenType; |
|
99 |
|
100 /** |
|
101 * Get next token from the stream |
|
102 * @since |
|
103 * @param |
|
104 * @return TTokenType Type of token encountered. |
|
105 */ |
|
106 TTokenType NextToken (); |
|
107 |
|
108 private: // Data |
|
109 |
|
110 // Token value (string) |
|
111 TPtrC iToken; |
|
112 |
|
113 // Token value (Integer) |
|
114 TInt iTokenVal; |
|
115 |
|
116 // List for tunnels parsed from the configuration file |
|
117 TTunnelQueue iTunnelQueue; |
|
118 }; |
|
119 |
|
120 |
|
121 // CLASS DECLARATION |
|
122 |
|
123 /** |
|
124 * TIpAddress. |
|
125 * Raw IPv6 address with zone id. |
|
126 */ |
|
127 class TIpAddress: public TIp6Addr |
|
128 { |
|
129 public: // Constructors |
|
130 |
|
131 TIpAddress() {} |
|
132 |
|
133 TIpAddress(const TIp6Addr &aAddr, const TUint32 aScope) : iScope(aScope) {(TIp6Addr &)*this = aAddr; } |
|
134 |
|
135 |
|
136 public: // New functions |
|
137 |
|
138 /** |
|
139 * Returns the address without the scope. |
|
140 */ |
|
141 inline const TIp6Addr &Address() const { return *this; } |
|
142 |
|
143 /** |
|
144 * Returns TRUE, if addresses and scope match. |
|
145 * The ZERO scope id acts as wild card. |
|
146 */ |
|
147 inline TInt operator==(const TIpAddress &aAddr) const |
|
148 { return IsEqual(aAddr) && (iScope == aAddr.iScope || iScope == 0 || aAddr.iScope == 0); } |
|
149 |
|
150 /** |
|
151 * Returns TRUE, if address and scope does not match |
|
152 */ |
|
153 inline TInt operator!=(const TIpAddress &aAddr) const { return ! (*this == aAddr); } |
|
154 |
|
155 /** |
|
156 * Set address and scope. |
|
157 * @param aAddr The bare address |
|
158 * @param aScope The zone id. |
|
159 */ |
|
160 inline void SetAddress(const TIp6Addr &aAddr, const TUint32 aScope) |
|
161 { |
|
162 (TIp6Addr &)*this = aAddr; |
|
163 iScope = aScope; |
|
164 } |
|
165 |
|
166 public: // Data |
|
167 |
|
168 TUint32 iScope; |
|
169 }; |
|
170 |
|
171 |
|
172 // CLASS DECLARATION |
|
173 |
|
174 /** |
|
175 * Configured tunnel |
|
176 * Keeps inside all information needed for a configured tunnel. |
|
177 * |
|
178 * @lib |
|
179 * @since |
|
180 */ |
|
181 class CTunnel : public CBase |
|
182 { |
|
183 public: // Constructors and destructor |
|
184 |
|
185 CTunnel (); |
|
186 |
|
187 /** |
|
188 * Destructor. |
|
189 */ |
|
190 virtual ~CTunnel(); |
|
191 |
|
192 public: // New functions |
|
193 |
|
194 /** |
|
195 * Sets a name for a tunnel. Used also as a virtual interface name. |
|
196 * @since |
|
197 * @param aName |
|
198 * @return void |
|
199 */ |
|
200 void SetNameL (const TDesC & aName); |
|
201 |
|
202 /** |
|
203 * Private member access |
|
204 * @since |
|
205 * @param |
|
206 * @return Name |
|
207 */ |
|
208 inline const TDesC &Name() const { return *iName; } |
|
209 |
|
210 /** |
|
211 * Private member access |
|
212 * @since |
|
213 * @param |
|
214 * @return Endpoint address |
|
215 */ |
|
216 inline TIpAddress &EndpointAddr() { return iEndpointAddr; } |
|
217 |
|
218 /** |
|
219 * Private member access |
|
220 * @since |
|
221 * @param |
|
222 * @return TUint32 Interface index |
|
223 */ |
|
224 inline TUint32 InterfaceIndex() { return iInterfaceIndex; } |
|
225 |
|
226 /** |
|
227 * Private member access |
|
228 * @since |
|
229 * @param |
|
230 * @return Virtual interface address |
|
231 */ |
|
232 inline TIpAddress& VirtualIfAddr() { return iVirtualIfAddr; } |
|
233 |
|
234 /** |
|
235 * Private member access |
|
236 * @since |
|
237 * @param |
|
238 * @return Route address (what is routed to this tunnel) |
|
239 */ |
|
240 inline TIp6Addr& RouteAddr() { return iRouteAddr; } |
|
241 |
|
242 /** |
|
243 * Private member access |
|
244 * @since |
|
245 * @param |
|
246 * @return TUint Route address prefix length |
|
247 */ |
|
248 inline TUint RoutePrefixLength() { return iRoutePrefixLength; } |
|
249 |
|
250 /** |
|
251 * Private member access |
|
252 * @since |
|
253 * @param aInterfaceIndex Interface index |
|
254 * @return void |
|
255 */ |
|
256 inline void SetInterfaceIndex(TUint32 aInterfaceIndex) |
|
257 { iInterfaceIndex = aInterfaceIndex; } |
|
258 |
|
259 /** |
|
260 * Private member access |
|
261 * @since |
|
262 * @param aRoutePrefixLength |
|
263 * @return void |
|
264 */ |
|
265 inline void SetRoutePrefixLength(TUint aRoutePrefixLength) |
|
266 { iRoutePrefixLength = aRoutePrefixLength; } |
|
267 |
|
268 |
|
269 public: // Data |
|
270 // Link for double linked list |
|
271 TDblQueLink iDLink; |
|
272 |
|
273 private: // Data |
|
274 |
|
275 // IP header id |
|
276 |
|
277 |
|
278 // Name of the tunnel |
|
279 HBufC *iName; |
|
280 |
|
281 // Endpoint IPv4 address |
|
282 TIpAddress iEndpointAddr; |
|
283 |
|
284 // Local IPv4 address |
|
285 // TInetAddr iLocalAddr; |
|
286 |
|
287 // Virtual interface index |
|
288 TUint32 iInterfaceIndex; |
|
289 |
|
290 // IPv6 address for the tunnel virtual interface |
|
291 TIpAddress iVirtualIfAddr; |
|
292 |
|
293 // IPv6 route address |
|
294 TIp6Addr iRouteAddr; |
|
295 |
|
296 // IPv6 route prefix length |
|
297 TUint iRoutePrefixLength; |
|
298 }; |
|
299 |
|
300 #endif // __6TO4_TUNNEL_H |
|
301 |
|
302 // End of File |