|
1 // Copyright (c) 2004-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 // engine.h - name resolver core engine header |
|
15 // |
|
16 |
|
17 #ifndef __ENGINE_H |
|
18 #define __ENGINE_H |
|
19 #include <s32file.h> |
|
20 #include <es_sock.h> |
|
21 #include <in_sock.h> |
|
22 |
|
23 /** |
|
24 @file engine.h |
|
25 Engine component |
|
26 @internalComponent Domain Name Resolver |
|
27 */ |
|
28 |
|
29 #include "demon.h" |
|
30 #include "hosts.h" |
|
31 |
|
32 const TUint KQueryOrder_PreferA = 0x1; //< if set, send A first, and then AAAA (preferred query) |
|
33 const TUint KQueryOrder_Parallel = 0x2; //< if set, activate both queries without waiting the first to complete. |
|
34 const TUint KQueryOrder_OneQuery = 0x4; //< if set, send only the preferred query (either A or AAAA) |
|
35 /** |
|
36 // Configuration parameter which are extracted from the [resolver] sections |
|
37 */ |
|
38 class TDndConfigParameters |
|
39 { |
|
40 public: |
|
41 TUint iRetries; //< # of query retransmissions (not counting the first) |
|
42 TUint iMinTime; //< Minimum time for retransmit |
|
43 TUint iMaxTime; //< Maximum time for the total query to complete or fail (when server is known) |
|
44 TUint iSetupTime; //< Maximum time to wait for DNS server to become known |
|
45 TUint iSetupPoll; //< While waiting DNS server, interval for rechecking status (even if no monitor events) |
|
46 TUint iSprayMode:1; //< Each query is sent to all servers with iMinTime interval (on each try) |
|
47 TUint iSkipNotFound:1; //< Ignore "Name not found" answers from server and try another server. |
|
48 TUint iQueryHack:1; //< Enable "QUERYTYPE?Name" special queries |
|
49 TUint iQueryOrder:3; //< Define how A and AAAA queries are to be used. |
|
50 TUint iFlushOnConfig:1; //< Flush DNS cache on intereface configuration change. |
|
51 #ifdef LLMNR_ENABLED |
|
52 TUint iLlmnrLlOnly:1; //< Accept only link-local replies to LLMNR queries |
|
53 TUint iLlmnrPort; //< Default port of the Linklocal Multicast Name Resolver |
|
54 TUint iLlmnrRetries; //< # of LLMNR query retransmissions (not counting the first) |
|
55 TUint iLlmnrMinTime; //< Minimum time to retransmit the LLMNR query |
|
56 TUint iLlmnrMaxTime; //< Maximum time to do LLMNR query |
|
57 TInt iLlmnrHoplimit; //< The IP Hoplimit (TTL) to be used in LLMR/MDNS packets. |
|
58 TIp6Addr iLlmnrIpv4; //< The IPv4 multicast address |
|
59 TIp6Addr iLlmnrIpv6; //< The IPv6 multicast address |
|
60 #endif |
|
61 TUint iEDNS0; //< Enable EDNS0, if >= KDnsMaxMessage, value is receive payload size. |
|
62 }; |
|
63 |
|
64 class MTimeoutManager; |
|
65 class MDndListener; |
|
66 class CESockIniData; |
|
67 /** |
|
68 // Engine part of the DND implementation. |
|
69 // |
|
70 // Function |
|
71 // |
|
72 // @li The engine (there will be only one instantiation) acts as the controller. |
|
73 // @li Creates and owns the CdndListener. |
|
74 // @li Maintains the communication between the other componens and the console. |
|
75 // |
|
76 // Contains |
|
77 // |
|
78 // @li CDndListener object - to accept socket connection from the applications requiring service |
|
79 // @li A view - to show error and log messages |
|
80 // @li A File Server handle |
|
81 // @li A Socket Server handle |
|
82 // @li A timeout manager instance for other components to use |
|
83 */ |
|
84 class CDndEngine : public CBase, public MDemonEngine |
|
85 { |
|
86 public: |
|
87 CDndEngine(MDemonMain &aMain) : iMain(aMain), iHostsFile(iFS) {} |
|
88 ~CDndEngine(); |
|
89 void ConstructL(); |
|
90 void HandleCommandL(TInt aCommand); |
|
91 |
|
92 MDemonMain &iMain; //< The reference to the main application |
|
93 public: |
|
94 RFs iFS; //< A File Server session (opened/closed by engine) |
|
95 RSocketServ iSS; //< A Socket Server session (opened/opened by engine) |
|
96 RHostsFile iHostsFile; //< The hosts file source |
|
97 RSocket iSocket; //< And Open UDP socket,for all to use for SetOpt/GetOpt only. |
|
98 |
|
99 // @brief If aResult < 0 (= error), output message and leave |
|
100 void CheckResultL(const TDesC &aText, TInt aResult); |
|
101 // @brief If aResult < 0 (= error), output messsage |
|
102 TInt CheckResult(const TDesC &aText, TInt aResult); |
|
103 // @brief Output text message (line) |
|
104 void ShowText(const TDesC &aText); |
|
105 // @brief Oupput text message using format (line) |
|
106 void ShowTextf(TRefByValue<const TDesC> aFmt, ...); |
|
107 // |
|
108 // Access to the configuration file |
|
109 // |
|
110 // @brief Find integer value from configuration with automatic min/max and default checking. |
|
111 TInt GetIniValue(const TDesC &aSection, const TDesC &aName, TInt aDefault = 0, TInt aMin = 0, TInt aMax = 1); |
|
112 // @brief Find IP address value from configuration. |
|
113 void GetIniAddress(const TDesC &aSection, const TDesC &aName, const TDesC &aDefault, TIp6Addr &aAddr); |
|
114 // @brief Find string value from configuration |
|
115 TBool FindVar(const TDesC &aSection, const TDesC &aVarName,TPtrC &aResult); |
|
116 // @brief Find integer value from configuration |
|
117 TBool FindVar(const TDesC &aSection, const TDesC &aVarName,TInt &aResult); |
|
118 // @brief Release Configuration data |
|
119 void UnloadConfigurationFile(); |
|
120 // @return parsed configuration parameters |
|
121 inline const TDndConfigParameters &GetConfig() const { return iParams; } |
|
122 // @return handle for the Timeout manager |
|
123 MTimeoutManager &Timer() { return *iTimer; } |
|
124 |
|
125 private: |
|
126 // @brief Called implicitly by FindVar methods |
|
127 TBool LoadConfigurationFile(); |
|
128 |
|
129 CESockIniData *iConfig; //< Configuration data |
|
130 TInt iConfigErr; //< Non-zero, if configuration file is not available |
|
131 TDndConfigParameters iParams; //< Parsed configuration parameters |
|
132 |
|
133 MTimeoutManager *iTimer; //< Generic timer handler (made available for all components) |
|
134 MDndListener *iListener; //< The listener instance |
|
135 }; |
|
136 |
|
137 #endif |