|
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 // servers.cpp - server manager module |
|
15 // |
|
16 |
|
17 #ifndef __SERVERS_H__ |
|
18 #define __SERVERS_H__ |
|
19 |
|
20 /** |
|
21 @file servers.h |
|
22 DNS server list maintenance |
|
23 @internalComponent Domain Name Resolver |
|
24 */ |
|
25 |
|
26 #include <in_sock.h> |
|
27 |
|
28 /** |
|
29 // @brief The name resolution scope level and type (multicast or unicast) |
|
30 // |
|
31 // The server scope defines the scope level [1..16] which is |
|
32 // served by the server. Additionally, the scope is stored |
|
33 // either as positive integer (if resolution is based on |
|
34 // multicast strategy), or negative number if resolution is |
|
35 // based on traditional DNS server. |
|
36 // |
|
37 // Currently only two server scopes are used: |
|
38 // @li Link Local Scope, using multicast resolution (LLMNR) |
|
39 // @li Global Scope, using unicast resolution (the traditional DNS) |
|
40 */ |
|
41 typedef enum |
|
42 { |
|
43 // Node local hosts file Resolution |
|
44 EDnsServerScope_HOSTFILE = 0, |
|
45 // Globan Unicast Resolution |
|
46 EDnsServerScope_UC_GLOBAL = -KIp6AddrScopeGlobal, |
|
47 // Link Local Multicast Resolution |
|
48 EDnsServerScope_MC_LOCAL = KIp6AddrScopeLinkLocal |
|
49 } TDnsServerScope; |
|
50 |
|
51 |
|
52 // Select a virtual sublist of currently known servers |
|
53 class TDnsServerFilter |
|
54 { |
|
55 public: |
|
56 inline TBool IsUnicast() const { return iServerScope < 0; } |
|
57 inline TBool IsMulticast() const { return iServerScope > 0; } |
|
58 TInt iServerId; //< Current default server (0 = first matching server) |
|
59 TUint32 iLockId; //< Eligible severs must be from "locked" scope |
|
60 TUint8 iLockType; //< Locked scope level [1,,16] |
|
61 TDnsServerScope iServerScope:8; //< Server scope and type |
|
62 }; |
|
63 |
|
64 class MDnsServerListNotify |
|
65 { |
|
66 public: |
|
67 // Called when the requested server list has become known (if request was pending) |
|
68 virtual void ServerListComplete(const TDnsServerFilter &aList, TInt aResult) = 0; |
|
69 }; |
|
70 |
|
71 class MDnsServerManager |
|
72 { |
|
73 public: |
|
74 /** |
|
75 // @brief Virtual desctructor. |
|
76 // |
|
77 // The actual server manager object can be deleted by a delete of this mixin class. |
|
78 */ |
|
79 virtual ~MDnsServerManager() {} |
|
80 /** |
|
81 // @brief Informs that the system configuration has changed. |
|
82 // This triggers the rescanning of the interfaces and |
|
83 // availabla name server addresses. |
|
84 */ |
|
85 virtual void ConfigurationChanged() = 0; |
|
86 /** |
|
87 // @brief Open the server list (if not already open) |
|
88 // @param aFilter the server filter |
|
89 // @param aNotify the callback, which is used only if server list is not yet available |
|
90 // @returns |
|
91 // @li < 0, fatal error (notify callback is not installed) |
|
92 // @li = 0, server list is available (notify callback is not installed) |
|
93 // @li > 0, server list is not available, the notify callback will be called later |
|
94 */ |
|
95 virtual TInt OpenList(const TDnsServerFilter &aFilter, MDnsServerListNotify *aNotify) = 0; |
|
96 /** |
|
97 // @brief Count the number of servers matching the filter |
|
98 // @param aFilter the server filter |
|
99 // @returns the number of servers matching the filter |
|
100 */ |
|
101 virtual TInt Count(const TDnsServerFilter &aFilter) const = 0; |
|
102 /** |
|
103 // @brief Return id of the next matching server after the specified server |
|
104 // @param aFilter the server filter |
|
105 // @param aServerId id of the current server (if = 0, the first matching server is returned) |
|
106 // @returns |
|
107 // @li < 0, error [does not happen currently] |
|
108 // @li = 0, there is no next server (server list is empty or only had the single server) |
|
109 // @li > 0, is the id of the next server ( != aServerId) |
|
110 */ |
|
111 virtual TInt Next(const TDnsServerFilter &aFilter, TInt aServerId) const = 0; |
|
112 /** |
|
113 // @brief Request is not using the serverlist anymore |
|
114 // @param aFilter the server filter (cancel notify callback for this) |
|
115 */ |
|
116 virtual void CloseList(const TDnsServerFilter &aFilter) = 0; |
|
117 /** |
|
118 // @brief Return the IP addres of the server |
|
119 // @param aServerId identify the server |
|
120 // @retval aAddr the server address corresponding to the server id, if return OK |
|
121 // @returns |
|
122 // @li KErrNone (OK), if a server with the specified ID exist and address returned |
|
123 // @li KErrNotFound, if there is no server corresponding the specified id |
|
124 */ |
|
125 virtual TInt Address(TInt aServerId, TInetAddr &aAddr) const = 0; |
|
126 /** |
|
127 // @brief Assuming addr came from the server, return the matching scope id |
|
128 // @param aServerId identify the server |
|
129 // @param aAddr the address to examine |
|
130 // @returns |
|
131 // @li = 0, cannot find scope id for the address (probably no server matching the id) |
|
132 // @li != 0, is the scope id for the address assuming it originated from the specified server |
|
133 */ |
|
134 virtual TUint32 Scope(TInt aServerId, const TInetAddr &aAddr) = 0; |
|
135 /** |
|
136 // @brief Search server id by server address |
|
137 // @param aAddr a address of the server to be looked (must be KAfInet6) |
|
138 // @returns the corresponding server id (> 0), if the list contained a |
|
139 // matching server |
|
140 */ |
|
141 virtual TInt ServerId(const TInetAddr &aAddr) const = 0; |
|
142 /** |
|
143 // @brief Return the name space id matching the filter |
|
144 // @param aFilter the server filter |
|
145 // @param aServerId the specific server, if non-zero |
|
146 // @returns |
|
147 // @li = 0, cannot find the name space id |
|
148 // @li != 0, is the name space id corresponding the filter |
|
149 */ |
|
150 virtual TUint32 NameSpace(const TDnsServerFilter &aFilter, TInt aServerId) const = 0; |
|
151 /** |
|
152 // @brief Rebuild interface and server lists |
|
153 // @returns |
|
154 // @li KErrNone, if list rebuilt successfully (list can be empty!) |
|
155 // @li < 0, if there are some fatal socket errors |
|
156 */ |
|
157 virtual TInt BuildServerList() = 0; |
|
158 /** |
|
159 // @brief Add DNS server address for a interface |
|
160 // |
|
161 // The specified address will be included into the server list when the |
|
162 // named interface is active. |
|
163 // |
|
164 // @param aInterface is the name of the interface |
|
165 // @param aAddr DNS server address |
|
166 // |
|
167 */ |
|
168 virtual void AddServerAddress(const TName &aInterface, const TInetAddr &aAddr) = 0; |
|
169 /** |
|
170 // @brief Lock filter scope by address |
|
171 // @param aAddr the address |
|
172 // @param aNetwork the network id |
|
173 // @param aFilter the server filter to modify |
|
174 */ |
|
175 virtual void LockByAddress(const TInetAddr &aAddr, TUint32 aNid, TDnsServerFilter &aFilter) = 0; |
|
176 }; |
|
177 |
|
178 class CDndEngine; |
|
179 class DnsServerManager |
|
180 { |
|
181 public: |
|
182 // Create a new server manager instance |
|
183 static MDnsServerManager *NewL(CDndEngine &aControl); |
|
184 }; |
|
185 |
|
186 #endif |