epoc32/include/dns_qry.h
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/dns_qry.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,350 @@
     1.4 +/**
     1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* 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
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +* DNS queries and results definition
    1.19 +* 
    1.20 +*
    1.21 +*/
    1.22 +
    1.23 +
    1.24 +
    1.25 +
    1.26 +
    1.27 +/**
    1.28 + @file dns_qry.h
    1.29 + @publishedPartner
    1.30 + @released
    1.31 +*/
    1.32 +
    1.33 +#ifndef __DNS_QRY_H__
    1.34 +#define __DNS_QRY_H__
    1.35 +
    1.36 +#include <e32base.h>
    1.37 +#include <es_sock.h>
    1.38 +#include <in_sock.h>
    1.39 +
    1.40 +//-- DNS RR class values, see RFC 1035
    1.41 +const TUint16	KDnsRRClassIN = 1;  ///< Internet class
    1.42 +const TUint16	KDnsRRClassCS = 2;  ///< CSNET class
    1.43 +const TUint16	KDnsRRClassCH = 3;  ///< CHAOS class
    1.44 +const TUint16   KDnsRRClassHS = 4;  ///< Hesiod
    1.45 +
    1.46 +
    1.47 +//-- DNS RR and query type values, see RFC1035
    1.48 +const TUint16   KDnsRRTypeInvalid   = 0;    ///< invalid terminal value
    1.49 +const TUint16   KDnsRRTypeA         = 1;    ///< host address RR type
    1.50 +const TUint16   KDnsRRTypeNS        = 2;    ///< authoritative name server
    1.51 +const TUint16   KDnsRRTypeCNAME     = 5;    ///< canonical name
    1.52 +const TUint16   KDnsRRTypeWKS       = 11;   ///< well known service description
    1.53 +const TUint16   KDnsRRTypePTR       = 12;   ///< domain name pointer
    1.54 +const TUint16   KDnsRRTypeHINFO     = 13;   ///< host information
    1.55 +const TUint16   KDnsRRTypeMX        = 15;   ///< mail exchange
    1.56 +const TUint16   KDnsRRTypeTXT       = 16;   ///< text strings
    1.57 +
    1.58 +const TUint16   KDnsRRTypeAAAA      = 28;   ///< AAAA RR type
    1.59 +const TUint16   KDnsRRTypeSRV       = 33;   ///< SRV RR type
    1.60 +const TUint16   KDnsRRTypeNAPTR     = 35;   ///< NAPTR RR type
    1.61 +
    1.62 +//-- DNS RR query values only
    1.63 +const TUint16   KDnsQTypeAXFR       = 252;  ///< request for a transfer of an entire zone
    1.64 +const TUint16   KDnsQTypeMAILB      = 253;  ///< request for mailbox-related records (MB, MG or MR)
    1.65 +const TUint16   KDnsQTypeANY        = 255;  ///< request for all records
    1.66 +
    1.67 +/** 
    1.68 +DNS query buffer type 
    1.69 +@internalTechnology
    1.70 +*/
    1.71 +typedef TBuf8<255>  TDnsQryData;
    1.72 +
    1.73 +/**
    1.74 +representation of domain name in terms of DNS responses
    1.75 +@internalTechnology
    1.76 +*/
    1.77 +typedef TBuf8<255>  TDnsDomainName;
    1.78 +
    1.79 +/**
    1.80 +representation of a label data in terms of DNS responses 
    1.81 +@internalTechnology
    1.82 +*/
    1.83 +typedef TBuf8<63>   TDnsLabel;
    1.84 +
    1.85 +/**
    1.86 +representation of a character string in DNS responses 
    1.87 +@internalTechnology
    1.88 +*/
    1.89 +typedef TBuf8<255>  TDnsString;
    1.90 +
    1.91 +
    1.92 +class   TDnsQuery
    1.93 +/**
    1.94 +DNS query representation.
    1.95 +See RFC1035.
    1.96 +
    1.97 +@publishedPartner
    1.98 +@released
    1.99 +*/
   1.100 +    {
   1.101 +    public:    
   1.102 +        inline  TDnsQuery();    //- default constructor
   1.103 +        inline  TDnsQuery(const TDesC8& aQryDomainName, TUint16 aType, TUint16 aClass = KDnsRRClassIN);
   1.104 +
   1.105 +        inline  TUint16 Type()        const; 
   1.106 +        inline  TUint16 Class()       const; 
   1.107 +        inline  const TDesC8& Data()  const; 
   1.108 +        
   1.109 +        inline  void SetType(TUint16 aType);
   1.110 +        inline  void SetClass(TUint16 aClass);
   1.111 +        inline  void SetData(const TDesC8& aData);
   1.112 +
   1.113 +    protected:
   1.114 +
   1.115 +        TUint16     iQryType;   ///< DNS query code
   1.116 +        TUint16     iQryClass;  ///< DNS query class code
   1.117 +        TDnsQryData iQryData;   ///< DNS query data (buffer)
   1.118 +
   1.119 +    };
   1.120 +
   1.121 +typedef TPckgBuf<TDnsQuery> TDnsQueryBuf;
   1.122 +
   1.123 +
   1.124 +
   1.125 +class TDnsQryRespBase
   1.126 +/**
   1.127 +DNS query response representation.
   1.128 +This is a base class and is not intended to be instantinated.
   1.129 +See RFC1035.
   1.130 +
   1.131 +@publishedPartner
   1.132 +@released
   1.133 +*/
   1.134 +    {
   1.135 +    protected:
   1.136 +        //-- protected constructors to make instantination of this class impossible.
   1.137 +        inline  TDnsQryRespBase();
   1.138 +        inline  TDnsQryRespBase(TUint16 aRRespType, TUint16 aRRClass);
   1.139 +
   1.140 +    public:
   1.141 +
   1.142 +        inline TUint16 RRType()  const; 
   1.143 +        inline TUint16 RRClass() const; 
   1.144 +        inline TUint32 RRTtl()   const; 
   1.145 +
   1.146 +        inline void SetRRTtl  (TUint32 aRRTtl);
   1.147 +
   1.148 +    protected:
   1.149 +        //-- common data members for all DNS query results
   1.150 +        const TUint16 iRespType;     ///< RR type
   1.151 +        const TUint16 iRespClass;    ///< RR Class
   1.152 +              TUint32 iRespTtl;      ///< RR TTL
   1.153 +
   1.154 +    };
   1.155 +
   1.156 +
   1.157 +class TDnsRespSRV : public TDnsQryRespBase
   1.158 +/**
   1.159 +DNS SRV query response representation.
   1.160 +See RFC2782.
   1.161 +
   1.162 +@publishedPartner
   1.163 +@released
   1.164 +*/
   1.165 +    {
   1.166 +    public:
   1.167 +
   1.168 +        inline TDnsRespSRV();
   1.169 +
   1.170 +        inline TUint16 Priority() const;        
   1.171 +        inline TUint16 Weight() const;          
   1.172 +        inline TUint16 Port() const;            
   1.173 +        inline const TDesC8& Target() const;    
   1.174 +    
   1.175 +        inline void SetPriority(TUint16 aPriority);
   1.176 +        inline void SetWeight  (TUint16 aWeight);
   1.177 +        inline void SetPort    (TUint16 aPort);
   1.178 +        inline void SetTarget (const TDesC8& aTarget);
   1.179 +
   1.180 +    protected:
   1.181 +
   1.182 +        TUint16         iPriority;  ///< The priority of this target host
   1.183 +        TUint16         iWeight;    ///< the value of the weight field
   1.184 +        TUint16         iPort;      ///< port number
   1.185 +        TDnsDomainName  iTarget;    ///< domain name of the target host.
   1.186 +    };
   1.187 +
   1.188 +typedef TPckgBuf<TDnsRespSRV> TDnsRespSRVBuf;
   1.189 +
   1.190 +class TDnsRespA : public TDnsQryRespBase
   1.191 +/**
   1.192 +DNS Host Address query response representation.
   1.193 +See RFC1034, 1035.
   1.194 +
   1.195 +@publishedPartner
   1.196 +@released
   1.197 +*/
   1.198 +    {
   1.199 +    public:
   1.200 +
   1.201 +        TDnsRespA() : TDnsQryRespBase(KDnsRRTypeA, KDnsRRClassIN)  {}
   1.202 +
   1.203 +        inline const TInetAddr&  HostAddress() const; 
   1.204 +        inline void  SetHostAddress(const TInetAddr& aInetAddr);
   1.205 +
   1.206 +    protected:
   1.207 +        TInetAddr   iInetAddr;  ///< Host address
   1.208 +    };
   1.209 +
   1.210 +typedef TPckgBuf<TDnsRespA> TDnsRespABuf;
   1.211 +
   1.212 +
   1.213 +class TDnsRespAAAA : public TDnsQryRespBase
   1.214 +/**
   1.215 +IPv6 DNS Host Address query response representation.
   1.216 +See RFC1035, RFC1886
   1.217 +
   1.218 +@publishedPartner
   1.219 +@released
   1.220 +*/
   1.221 +    {
   1.222 +    public:
   1.223 +
   1.224 +        TDnsRespAAAA() : TDnsQryRespBase(KDnsRRTypeAAAA, KDnsRRClassIN) {}
   1.225 +
   1.226 +        inline const TInetAddr&  HostAddress() const;   
   1.227 +        inline void SetHostAddress(const TInetAddr& aInetAddr);
   1.228 +
   1.229 +    protected:
   1.230 +        TInetAddr   iInetAddr;  ///< Host address
   1.231 +    };
   1.232 +
   1.233 +typedef TPckgBuf<TDnsRespAAAA> TDnsRespAAAABuf;
   1.234 +
   1.235 +
   1.236 +class TDnsRespPTR : public TDnsQryRespBase
   1.237 +/**
   1.238 +DNS Domain Name query response representation.
   1.239 +See RFC1034.
   1.240 +
   1.241 +@publishedPartner
   1.242 +@released
   1.243 +*/
   1.244 +    {
   1.245 +    public:
   1.246 +
   1.247 +        TDnsRespPTR() : TDnsQryRespBase(KDnsRRTypePTR, KDnsRRClassIN) {}
   1.248 +
   1.249 +        inline const TDesC8& HostName() const; 
   1.250 +        inline void  SetHostName(const TDesC8& aHostName);
   1.251 +
   1.252 +    protected:
   1.253 +        TDnsDomainName    iName;  ///< domain this RR refers to.
   1.254 +    };
   1.255 +
   1.256 +typedef TPckgBuf<TDnsRespPTR> TDnsRespPTRBuf;
   1.257 +
   1.258 +
   1.259 +class TDnsRespNAPTR : public TDnsQryRespBase
   1.260 +/** 
   1.261 +DNS NAPTR query response representation.
   1.262 +See RFC2915.
   1.263 +
   1.264 +@publishedPartner
   1.265 +@released
   1.266 +*/
   1.267 +    {
   1.268 +    public:
   1.269 +
   1.270 +        inline TDnsRespNAPTR();
   1.271 +
   1.272 +        inline TUint16         Order()       const; 
   1.273 +        inline TUint16         Pref()        const; 
   1.274 +        inline const TDesC8&   Flags()       const; 
   1.275 +        inline const TDesC8&   Service()     const; 
   1.276 +        inline const TDesC8&   Regexp()      const; 
   1.277 +        inline const TDesC8&   Replacement() const; 
   1.278 +
   1.279 +        inline void SetOrder(TUint16 aOrder);
   1.280 +        inline void SetPref(TUint16 aPref);
   1.281 +        inline void SetFlags(const TDesC8& aFlags);
   1.282 +        inline void SetService(const TDesC8& aService);
   1.283 +        inline void SetRegexp(const TDesC8& aRegexp);
   1.284 +        inline void SetReplacement(const TDesC8& aReplacement);
   1.285 +
   1.286 +    protected:
   1.287 +
   1.288 +        TUint16         iOrder;      ///< RR Order field
   1.289 +        TUint16         iPref;       ///< RR Preference field
   1.290 +        TDnsString      iFlags;      ///< RR Flags string
   1.291 +        TDnsString      iService;    ///< service name(s) available
   1.292 +        TDnsString      iRegexp;     ///< RR Regexp field
   1.293 +        TDnsDomainName  iReplacement;///< RR Replacement field
   1.294 +    };
   1.295 +
   1.296 +typedef TPckgBuf<TDnsRespNAPTR> TDnsRespNAPTRBuf;
   1.297 +
   1.298 +class TDnsRespMX: public TDnsQryRespBase
   1.299 +/**
   1.300 +DNS MX query response representation.
   1.301 +See RFC1035, RFC974.
   1.302 +
   1.303 +@publishedPartner
   1.304 +@released
   1.305 +*/
   1.306 +    {
   1.307 +    public:
   1.308 +
   1.309 +        TDnsRespMX() : TDnsQryRespBase(KDnsRRTypeMX, KDnsRRClassIN) {}
   1.310 +
   1.311 +        inline TUint16         Pref()      const; 
   1.312 +        inline const TDesC8&   HostName()  const; 
   1.313 +
   1.314 +        inline void SetPref(TUint16 aPref);
   1.315 +        inline void SetHostName(const TDesC8& aHostName);
   1.316 +
   1.317 +    protected:
   1.318 +
   1.319 +        TUint16         iPref;       ///< RR Preference field.
   1.320 +        TDnsDomainName  iHostName;   ///< Host name.
   1.321 +
   1.322 +    };
   1.323 +
   1.324 +typedef TPckgBuf<TDnsRespMX> TDnsRespMXBuf;
   1.325 +
   1.326 +// -- DNS query type value, DoCoMo Cache requirement
   1.327 +// This is used in conjunction with RHostResolver::Query
   1.328 +// Example usage:
   1.329 +//
   1.330 +// 		TDnsQueryBuf dnsQryBuf;
   1.331 +//		TDnsRespABuf dummy;
   1.332 +//
   1.333 +//		dnsQryBuf().SetType(KDnsQTypeCacheClear);
   1.334 +//		resolver.Query(dnsQryBuf, dummy, status); 
   1.335 +//		User::WaitForRequest(status);
   1.336 +//
   1.337 +const TUint16   KDnsQTypeCacheClear = 99;   ///< Resolver Cache Clear type
   1.338 +// -- DNS non-recursive look up, DoCoMo requirement
   1.339 +// This is used in conjunction with RHostResolver::GetByName.
   1.340 +// Example usage:
   1.341 +//
   1.342 +//		TNameEntry nameEntry;
   1.343 +//		TBuf<256> hostName(KDnsNonrecursive);
   1.344 +//		hostName.Append(_L("www.symbian.com"));
   1.345 +//
   1.346 +//		resolver.GetByName(hostName,nameEntry, status);
   1.347 +//		User::WaitForRequest(status);
   1.348 +//
   1.349 +_LIT(KDnsNonrecursive, "NONRECURSIVE?");
   1.350 +
   1.351 +#include "dns_qry.inl"
   1.352 +
   1.353 +#endif //__DNS_QRY_H__