|
1 /** |
|
2 * Copyright (c) 1997-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 * DNS queries and results definition |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file dns_qry.h |
|
24 @publishedPartner |
|
25 @released |
|
26 */ |
|
27 |
|
28 #ifndef __DNS_QRY_H__ |
|
29 #define __DNS_QRY_H__ |
|
30 |
|
31 #include <e32base.h> |
|
32 #include <es_sock.h> |
|
33 #include <in_sock.h> |
|
34 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
35 #include <dns_qry_internal.h> |
|
36 #endif |
|
37 |
|
38 |
|
39 /** |
|
40 DNS query buffer type |
|
41 */ |
|
42 typedef TBuf8<255> TDnsQryData; |
|
43 |
|
44 /** |
|
45 representation of domain name in terms of DNS responses |
|
46 */ |
|
47 typedef TBuf8<255> TDnsDomainName; |
|
48 |
|
49 /** |
|
50 representation of a character string in DNS responses |
|
51 */ |
|
52 typedef TBuf8<255> TDnsString; |
|
53 |
|
54 //-- DNS RR class values, see RFC 1035 |
|
55 const TUint16 KDnsRRClassIN = 1; ///< Internet class |
|
56 const TUint16 KDnsRRClassCS = 2; ///< CSNET class |
|
57 const TUint16 KDnsRRClassCH = 3; ///< CHAOS class |
|
58 const TUint16 KDnsRRClassHS = 4; ///< Hesiod |
|
59 |
|
60 |
|
61 //-- DNS RR and query type values, see RFC1035 |
|
62 const TUint16 KDnsRRTypeInvalid = 0; ///< invalid terminal value |
|
63 const TUint16 KDnsRRTypeA = 1; ///< host address RR type |
|
64 const TUint16 KDnsRRTypeNS = 2; ///< authoritative name server |
|
65 const TUint16 KDnsRRTypeCNAME = 5; ///< canonical name |
|
66 const TUint16 KDnsRRTypeWKS = 11; ///< well known service description |
|
67 const TUint16 KDnsRRTypePTR = 12; ///< domain name pointer |
|
68 const TUint16 KDnsRRTypeHINFO = 13; ///< host information |
|
69 const TUint16 KDnsRRTypeMX = 15; ///< mail exchange |
|
70 const TUint16 KDnsRRTypeTXT = 16; ///< text strings |
|
71 |
|
72 const TUint16 KDnsRRTypeAAAA = 28; ///< AAAA RR type |
|
73 const TUint16 KDnsRRTypeSRV = 33; ///< SRV RR type |
|
74 const TUint16 KDnsRRTypeNAPTR = 35; ///< NAPTR RR type |
|
75 |
|
76 //-- DNS RR query values only |
|
77 const TUint16 KDnsQTypeAXFR = 252; ///< request for a transfer of an entire zone |
|
78 const TUint16 KDnsQTypeMAILB = 253; ///< request for mailbox-related records (MB, MG or MR) |
|
79 const TUint16 KDnsQTypeANY = 255; ///< request for all records |
|
80 |
|
81 |
|
82 class TDnsQuery |
|
83 /** |
|
84 DNS query representation. |
|
85 See RFC1035. |
|
86 |
|
87 @publishedPartner |
|
88 @released |
|
89 */ |
|
90 { |
|
91 public: |
|
92 inline TDnsQuery(); //- default constructor |
|
93 inline TDnsQuery(const TDesC8& aQryDomainName, TUint16 aType, TUint16 aClass = KDnsRRClassIN); |
|
94 |
|
95 inline TUint16 Type() const; |
|
96 inline TUint16 Class() const; |
|
97 inline const TDesC8& Data() const; |
|
98 |
|
99 inline void SetType(TUint16 aType); |
|
100 inline void SetClass(TUint16 aClass); |
|
101 inline void SetData(const TDesC8& aData); |
|
102 |
|
103 protected: |
|
104 |
|
105 TUint16 iQryType; ///< DNS query code |
|
106 TUint16 iQryClass; ///< DNS query class code |
|
107 TDnsQryData iQryData; ///< DNS query data (buffer) |
|
108 |
|
109 }; |
|
110 |
|
111 typedef TPckgBuf<TDnsQuery> TDnsQueryBuf; |
|
112 |
|
113 |
|
114 |
|
115 class TDnsQryRespBase |
|
116 /** |
|
117 DNS query response representation. |
|
118 This is a base class and is not intended to be instantinated. |
|
119 See RFC1035. |
|
120 |
|
121 @publishedPartner |
|
122 @released |
|
123 */ |
|
124 { |
|
125 protected: |
|
126 //-- protected constructors to make instantination of this class impossible. |
|
127 inline TDnsQryRespBase(); |
|
128 inline TDnsQryRespBase(TUint16 aRRespType, TUint16 aRRClass); |
|
129 |
|
130 public: |
|
131 |
|
132 inline TUint16 RRType() const; |
|
133 inline TUint16 RRClass() const; |
|
134 inline TUint32 RRTtl() const; |
|
135 |
|
136 inline void SetRRTtl (TUint32 aRRTtl); |
|
137 |
|
138 protected: |
|
139 //-- common data members for all DNS query results |
|
140 const TUint16 iRespType; ///< RR type |
|
141 const TUint16 iRespClass; ///< RR Class |
|
142 TUint32 iRespTtl; ///< RR TTL |
|
143 |
|
144 }; |
|
145 |
|
146 |
|
147 class TDnsRespSRV : public TDnsQryRespBase |
|
148 /** |
|
149 DNS SRV query response representation. |
|
150 See RFC2782. |
|
151 |
|
152 @publishedPartner |
|
153 @released |
|
154 */ |
|
155 { |
|
156 public: |
|
157 |
|
158 inline TDnsRespSRV(); |
|
159 |
|
160 inline TUint16 Priority() const; |
|
161 inline TUint16 Weight() const; |
|
162 inline TUint16 Port() const; |
|
163 inline const TDesC8& Target() const; |
|
164 |
|
165 inline void SetPriority(TUint16 aPriority); |
|
166 inline void SetWeight (TUint16 aWeight); |
|
167 inline void SetPort (TUint16 aPort); |
|
168 inline void SetTarget (const TDesC8& aTarget); |
|
169 |
|
170 protected: |
|
171 |
|
172 TUint16 iPriority; ///< The priority of this target host |
|
173 TUint16 iWeight; ///< the value of the weight field |
|
174 TUint16 iPort; ///< port number |
|
175 TDnsDomainName iTarget; ///< domain name of the target host. |
|
176 }; |
|
177 |
|
178 typedef TPckgBuf<TDnsRespSRV> TDnsRespSRVBuf; |
|
179 |
|
180 class TDnsRespA : public TDnsQryRespBase |
|
181 /** |
|
182 DNS Host Address query response representation. |
|
183 See RFC1034, 1035. |
|
184 |
|
185 @publishedPartner |
|
186 @released |
|
187 */ |
|
188 { |
|
189 public: |
|
190 |
|
191 TDnsRespA() : TDnsQryRespBase(KDnsRRTypeA, KDnsRRClassIN) {} |
|
192 |
|
193 inline const TInetAddr& HostAddress() const; |
|
194 inline void SetHostAddress(const TInetAddr& aInetAddr); |
|
195 |
|
196 protected: |
|
197 TInetAddr iInetAddr; ///< Host address |
|
198 }; |
|
199 |
|
200 typedef TPckgBuf<TDnsRespA> TDnsRespABuf; |
|
201 |
|
202 |
|
203 class TDnsRespAAAA : public TDnsQryRespBase |
|
204 /** |
|
205 IPv6 DNS Host Address query response representation. |
|
206 See RFC1035, RFC1886 |
|
207 |
|
208 @publishedPartner |
|
209 @released |
|
210 */ |
|
211 { |
|
212 public: |
|
213 |
|
214 TDnsRespAAAA() : TDnsQryRespBase(KDnsRRTypeAAAA, KDnsRRClassIN) {} |
|
215 |
|
216 inline const TInetAddr& HostAddress() const; |
|
217 inline void SetHostAddress(const TInetAddr& aInetAddr); |
|
218 |
|
219 protected: |
|
220 TInetAddr iInetAddr; ///< Host address |
|
221 }; |
|
222 |
|
223 typedef TPckgBuf<TDnsRespAAAA> TDnsRespAAAABuf; |
|
224 |
|
225 |
|
226 class TDnsRespPTR : public TDnsQryRespBase |
|
227 /** |
|
228 DNS Domain Name query response representation. |
|
229 See RFC1034. |
|
230 |
|
231 @publishedPartner |
|
232 @released |
|
233 */ |
|
234 { |
|
235 public: |
|
236 |
|
237 TDnsRespPTR() : TDnsQryRespBase(KDnsRRTypePTR, KDnsRRClassIN) {} |
|
238 |
|
239 inline const TDesC8& HostName() const; |
|
240 inline void SetHostName(const TDesC8& aHostName); |
|
241 |
|
242 protected: |
|
243 TDnsDomainName iName; ///< domain this RR refers to. |
|
244 }; |
|
245 |
|
246 typedef TPckgBuf<TDnsRespPTR> TDnsRespPTRBuf; |
|
247 |
|
248 |
|
249 class TDnsRespNAPTR : public TDnsQryRespBase |
|
250 /** |
|
251 DNS NAPTR query response representation. |
|
252 See RFC2915. |
|
253 |
|
254 @publishedPartner |
|
255 @released |
|
256 */ |
|
257 { |
|
258 public: |
|
259 |
|
260 inline TDnsRespNAPTR(); |
|
261 |
|
262 inline TUint16 Order() const; |
|
263 inline TUint16 Pref() const; |
|
264 inline const TDesC8& Flags() const; |
|
265 inline const TDesC8& Service() const; |
|
266 inline const TDesC8& Regexp() const; |
|
267 inline const TDesC8& Replacement() const; |
|
268 |
|
269 inline void SetOrder(TUint16 aOrder); |
|
270 inline void SetPref(TUint16 aPref); |
|
271 inline void SetFlags(const TDesC8& aFlags); |
|
272 inline void SetService(const TDesC8& aService); |
|
273 inline void SetRegexp(const TDesC8& aRegexp); |
|
274 inline void SetReplacement(const TDesC8& aReplacement); |
|
275 |
|
276 protected: |
|
277 |
|
278 TUint16 iOrder; ///< RR Order field |
|
279 TUint16 iPref; ///< RR Preference field |
|
280 TDnsString iFlags; ///< RR Flags string |
|
281 TDnsString iService; ///< service name(s) available |
|
282 TDnsString iRegexp; ///< RR Regexp field |
|
283 TDnsDomainName iReplacement;///< RR Replacement field |
|
284 }; |
|
285 |
|
286 typedef TPckgBuf<TDnsRespNAPTR> TDnsRespNAPTRBuf; |
|
287 |
|
288 class TDnsRespMX: public TDnsQryRespBase |
|
289 /** |
|
290 DNS MX query response representation. |
|
291 See RFC1035, RFC974. |
|
292 |
|
293 @publishedPartner |
|
294 @released |
|
295 */ |
|
296 { |
|
297 public: |
|
298 |
|
299 TDnsRespMX() : TDnsQryRespBase(KDnsRRTypeMX, KDnsRRClassIN) {} |
|
300 |
|
301 inline TUint16 Pref() const; |
|
302 inline const TDesC8& HostName() const; |
|
303 |
|
304 inline void SetPref(TUint16 aPref); |
|
305 inline void SetHostName(const TDesC8& aHostName); |
|
306 |
|
307 protected: |
|
308 |
|
309 TUint16 iPref; ///< RR Preference field. |
|
310 TDnsDomainName iHostName; ///< Host name. |
|
311 |
|
312 }; |
|
313 |
|
314 typedef TPckgBuf<TDnsRespMX> TDnsRespMXBuf; |
|
315 |
|
316 // -- DNS query type value, DoCoMo Cache requirement |
|
317 // This is used in conjunction with RHostResolver::Query |
|
318 // Example usage: |
|
319 // |
|
320 // TDnsQueryBuf dnsQryBuf; |
|
321 // TDnsRespABuf dummy; |
|
322 // |
|
323 // dnsQryBuf().SetType(KDnsQTypeCacheClear); |
|
324 // resolver.Query(dnsQryBuf, dummy, status); |
|
325 // User::WaitForRequest(status); |
|
326 // |
|
327 const TUint16 KDnsQTypeCacheClear = 99; ///< Resolver Cache Clear type |
|
328 // -- DNS non-recursive look up, DoCoMo requirement |
|
329 // This is used in conjunction with RHostResolver::GetByName. |
|
330 // Example usage: |
|
331 // |
|
332 // TNameEntry nameEntry; |
|
333 // TBuf<256> hostName(KDnsNonrecursive); |
|
334 // hostName.Append(_L("www.symbian.com")); |
|
335 // |
|
336 // resolver.GetByName(hostName,nameEntry, status); |
|
337 // User::WaitForRequest(status); |
|
338 // |
|
339 _LIT(KDnsNonrecursive, "NONRECURSIVE?"); |
|
340 |
|
341 #include "dns_qry.inl" |
|
342 |
|
343 #endif //__DNS_QRY_H__ |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |