2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * DNS queries and results definition
37 //-- DNS RR class values, see RFC 1035
38 const TUint16 KDnsRRClassIN = 1; ///< Internet class
39 const TUint16 KDnsRRClassCS = 2; ///< CSNET class
40 const TUint16 KDnsRRClassCH = 3; ///< CHAOS class
41 const TUint16 KDnsRRClassHS = 4; ///< Hesiod
44 //-- DNS RR and query type values, see RFC1035
45 const TUint16 KDnsRRTypeInvalid = 0; ///< invalid terminal value
46 const TUint16 KDnsRRTypeA = 1; ///< host address RR type
47 const TUint16 KDnsRRTypeNS = 2; ///< authoritative name server
48 const TUint16 KDnsRRTypeCNAME = 5; ///< canonical name
49 const TUint16 KDnsRRTypeWKS = 11; ///< well known service description
50 const TUint16 KDnsRRTypePTR = 12; ///< domain name pointer
51 const TUint16 KDnsRRTypeHINFO = 13; ///< host information
52 const TUint16 KDnsRRTypeMX = 15; ///< mail exchange
53 const TUint16 KDnsRRTypeTXT = 16; ///< text strings
55 const TUint16 KDnsRRTypeAAAA = 28; ///< AAAA RR type
56 const TUint16 KDnsRRTypeSRV = 33; ///< SRV RR type
57 const TUint16 KDnsRRTypeNAPTR = 35; ///< NAPTR RR type
59 //-- DNS RR query values only
60 const TUint16 KDnsQTypeAXFR = 252; ///< request for a transfer of an entire zone
61 const TUint16 KDnsQTypeMAILB = 253; ///< request for mailbox-related records (MB, MG or MR)
62 const TUint16 KDnsQTypeANY = 255; ///< request for all records
68 typedef TBuf8<255> TDnsQryData;
71 representation of domain name in terms of DNS responses
74 typedef TBuf8<255> TDnsDomainName;
77 representation of a label data in terms of DNS responses
80 typedef TBuf8<63> TDnsLabel;
83 representation of a character string in DNS responses
86 typedef TBuf8<255> TDnsString;
91 DNS query representation.
99 inline TDnsQuery(); //- default constructor
100 inline TDnsQuery(const TDesC8& aQryDomainName, TUint16 aType, TUint16 aClass = KDnsRRClassIN);
102 inline TUint16 Type() const;
103 inline TUint16 Class() const;
104 inline const TDesC8& Data() const;
106 inline void SetType(TUint16 aType);
107 inline void SetClass(TUint16 aClass);
108 inline void SetData(const TDesC8& aData);
112 TUint16 iQryType; ///< DNS query code
113 TUint16 iQryClass; ///< DNS query class code
114 TDnsQryData iQryData; ///< DNS query data (buffer)
118 typedef TPckgBuf<TDnsQuery> TDnsQueryBuf;
122 class TDnsQryRespBase
124 DNS query response representation.
125 This is a base class and is not intended to be instantinated.
133 //-- protected constructors to make instantination of this class impossible.
134 inline TDnsQryRespBase();
135 inline TDnsQryRespBase(TUint16 aRRespType, TUint16 aRRClass);
139 inline TUint16 RRType() const;
140 inline TUint16 RRClass() const;
141 inline TUint32 RRTtl() const;
143 inline void SetRRTtl (TUint32 aRRTtl);
146 //-- common data members for all DNS query results
147 const TUint16 iRespType; ///< RR type
148 const TUint16 iRespClass; ///< RR Class
149 TUint32 iRespTtl; ///< RR TTL
154 class TDnsRespSRV : public TDnsQryRespBase
156 DNS SRV query response representation.
165 inline TDnsRespSRV();
167 inline TUint16 Priority() const;
168 inline TUint16 Weight() const;
169 inline TUint16 Port() const;
170 inline const TDesC8& Target() const;
172 inline void SetPriority(TUint16 aPriority);
173 inline void SetWeight (TUint16 aWeight);
174 inline void SetPort (TUint16 aPort);
175 inline void SetTarget (const TDesC8& aTarget);
179 TUint16 iPriority; ///< The priority of this target host
180 TUint16 iWeight; ///< the value of the weight field
181 TUint16 iPort; ///< port number
182 TDnsDomainName iTarget; ///< domain name of the target host.
185 typedef TPckgBuf<TDnsRespSRV> TDnsRespSRVBuf;
187 class TDnsRespA : public TDnsQryRespBase
189 DNS Host Address query response representation.
198 TDnsRespA() : TDnsQryRespBase(KDnsRRTypeA, KDnsRRClassIN) {}
200 inline const TInetAddr& HostAddress() const;
201 inline void SetHostAddress(const TInetAddr& aInetAddr);
204 TInetAddr iInetAddr; ///< Host address
207 typedef TPckgBuf<TDnsRespA> TDnsRespABuf;
210 class TDnsRespAAAA : public TDnsQryRespBase
212 IPv6 DNS Host Address query response representation.
221 TDnsRespAAAA() : TDnsQryRespBase(KDnsRRTypeAAAA, KDnsRRClassIN) {}
223 inline const TInetAddr& HostAddress() const;
224 inline void SetHostAddress(const TInetAddr& aInetAddr);
227 TInetAddr iInetAddr; ///< Host address
230 typedef TPckgBuf<TDnsRespAAAA> TDnsRespAAAABuf;
233 class TDnsRespPTR : public TDnsQryRespBase
235 DNS Domain Name query response representation.
244 TDnsRespPTR() : TDnsQryRespBase(KDnsRRTypePTR, KDnsRRClassIN) {}
246 inline const TDesC8& HostName() const;
247 inline void SetHostName(const TDesC8& aHostName);
250 TDnsDomainName iName; ///< domain this RR refers to.
253 typedef TPckgBuf<TDnsRespPTR> TDnsRespPTRBuf;
256 class TDnsRespNAPTR : public TDnsQryRespBase
258 DNS NAPTR query response representation.
267 inline TDnsRespNAPTR();
269 inline TUint16 Order() const;
270 inline TUint16 Pref() const;
271 inline const TDesC8& Flags() const;
272 inline const TDesC8& Service() const;
273 inline const TDesC8& Regexp() const;
274 inline const TDesC8& Replacement() const;
276 inline void SetOrder(TUint16 aOrder);
277 inline void SetPref(TUint16 aPref);
278 inline void SetFlags(const TDesC8& aFlags);
279 inline void SetService(const TDesC8& aService);
280 inline void SetRegexp(const TDesC8& aRegexp);
281 inline void SetReplacement(const TDesC8& aReplacement);
285 TUint16 iOrder; ///< RR Order field
286 TUint16 iPref; ///< RR Preference field
287 TDnsString iFlags; ///< RR Flags string
288 TDnsString iService; ///< service name(s) available
289 TDnsString iRegexp; ///< RR Regexp field
290 TDnsDomainName iReplacement;///< RR Replacement field
293 typedef TPckgBuf<TDnsRespNAPTR> TDnsRespNAPTRBuf;
295 class TDnsRespMX: public TDnsQryRespBase
297 DNS MX query response representation.
306 TDnsRespMX() : TDnsQryRespBase(KDnsRRTypeMX, KDnsRRClassIN) {}
308 inline TUint16 Pref() const;
309 inline const TDesC8& HostName() const;
311 inline void SetPref(TUint16 aPref);
312 inline void SetHostName(const TDesC8& aHostName);
316 TUint16 iPref; ///< RR Preference field.
317 TDnsDomainName iHostName; ///< Host name.
321 typedef TPckgBuf<TDnsRespMX> TDnsRespMXBuf;
323 // -- DNS query type value, DoCoMo Cache requirement
324 // This is used in conjunction with RHostResolver::Query
327 // TDnsQueryBuf dnsQryBuf;
328 // TDnsRespABuf dummy;
330 // dnsQryBuf().SetType(KDnsQTypeCacheClear);
331 // resolver.Query(dnsQryBuf, dummy, status);
332 // User::WaitForRequest(status);
334 const TUint16 KDnsQTypeCacheClear = 99; ///< Resolver Cache Clear type
335 // -- DNS non-recursive look up, DoCoMo requirement
336 // This is used in conjunction with RHostResolver::GetByName.
339 // TNameEntry nameEntry;
340 // TBuf<256> hostName(KDnsNonrecursive);
341 // hostName.Append(_L("www.symbian.com"));
343 // resolver.GetByName(hostName,nameEntry, status);
344 // User::WaitForRequest(status);
346 _LIT(KDnsNonrecursive, "NONRECURSIVE?");
348 #include "dns_qry.inl"
350 #endif //__DNS_QRY_H__