epoc32/include/dns_qry.h
branchSymbian2
changeset 2 2fe1408b6811
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
       
     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 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".
       
     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 
       
    24 /**
       
    25  @file dns_qry.h
       
    26  @publishedPartner
       
    27  @released
       
    28 */
       
    29 
       
    30 #ifndef __DNS_QRY_H__
       
    31 #define __DNS_QRY_H__
       
    32 
       
    33 #include <e32base.h>
       
    34 #include <es_sock.h>
       
    35 #include <in_sock.h>
       
    36 
       
    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
       
    42 
       
    43 
       
    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
       
    54 
       
    55 const TUint16   KDnsRRTypeAAAA      = 28;   ///< AAAA RR type
       
    56 const TUint16   KDnsRRTypeSRV       = 33;   ///< SRV RR type
       
    57 const TUint16   KDnsRRTypeNAPTR     = 35;   ///< NAPTR RR type
       
    58 
       
    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
       
    63 
       
    64 /** 
       
    65 DNS query buffer type 
       
    66 @internalTechnology
       
    67 */
       
    68 typedef TBuf8<255>  TDnsQryData;
       
    69 
       
    70 /**
       
    71 representation of domain name in terms of DNS responses
       
    72 @internalTechnology
       
    73 */
       
    74 typedef TBuf8<255>  TDnsDomainName;
       
    75 
       
    76 /**
       
    77 representation of a label data in terms of DNS responses 
       
    78 @internalTechnology
       
    79 */
       
    80 typedef TBuf8<63>   TDnsLabel;
       
    81 
       
    82 /**
       
    83 representation of a character string in DNS responses 
       
    84 @internalTechnology
       
    85 */
       
    86 typedef TBuf8<255>  TDnsString;
       
    87 
       
    88 
       
    89 class   TDnsQuery
       
    90 /**
       
    91 DNS query representation.
       
    92 See RFC1035.
       
    93 
       
    94 @publishedPartner
       
    95 @released
       
    96 */
       
    97     {
       
    98     public:    
       
    99         inline  TDnsQuery();    //- default constructor
       
   100         inline  TDnsQuery(const TDesC8& aQryDomainName, TUint16 aType, TUint16 aClass = KDnsRRClassIN);
       
   101 
       
   102         inline  TUint16 Type()        const; 
       
   103         inline  TUint16 Class()       const; 
       
   104         inline  const TDesC8& Data()  const; 
       
   105         
       
   106         inline  void SetType(TUint16 aType);
       
   107         inline  void SetClass(TUint16 aClass);
       
   108         inline  void SetData(const TDesC8& aData);
       
   109 
       
   110     protected:
       
   111 
       
   112         TUint16     iQryType;   ///< DNS query code
       
   113         TUint16     iQryClass;  ///< DNS query class code
       
   114         TDnsQryData iQryData;   ///< DNS query data (buffer)
       
   115 
       
   116     };
       
   117 
       
   118 typedef TPckgBuf<TDnsQuery> TDnsQueryBuf;
       
   119 
       
   120 
       
   121 
       
   122 class TDnsQryRespBase
       
   123 /**
       
   124 DNS query response representation.
       
   125 This is a base class and is not intended to be instantinated.
       
   126 See RFC1035.
       
   127 
       
   128 @publishedPartner
       
   129 @released
       
   130 */
       
   131     {
       
   132     protected:
       
   133         //-- protected constructors to make instantination of this class impossible.
       
   134         inline  TDnsQryRespBase();
       
   135         inline  TDnsQryRespBase(TUint16 aRRespType, TUint16 aRRClass);
       
   136 
       
   137     public:
       
   138 
       
   139         inline TUint16 RRType()  const; 
       
   140         inline TUint16 RRClass() const; 
       
   141         inline TUint32 RRTtl()   const; 
       
   142 
       
   143         inline void SetRRTtl  (TUint32 aRRTtl);
       
   144 
       
   145     protected:
       
   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
       
   150 
       
   151     };
       
   152 
       
   153 
       
   154 class TDnsRespSRV : public TDnsQryRespBase
       
   155 /**
       
   156 DNS SRV query response representation.
       
   157 See RFC2782.
       
   158 
       
   159 @publishedPartner
       
   160 @released
       
   161 */
       
   162     {
       
   163     public:
       
   164 
       
   165         inline TDnsRespSRV();
       
   166 
       
   167         inline TUint16 Priority() const;        
       
   168         inline TUint16 Weight() const;          
       
   169         inline TUint16 Port() const;            
       
   170         inline const TDesC8& Target() const;    
       
   171     
       
   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);
       
   176 
       
   177     protected:
       
   178 
       
   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.
       
   183     };
       
   184 
       
   185 typedef TPckgBuf<TDnsRespSRV> TDnsRespSRVBuf;
       
   186 
       
   187 class TDnsRespA : public TDnsQryRespBase
       
   188 /**
       
   189 DNS Host Address query response representation.
       
   190 See RFC1034, 1035.
       
   191 
       
   192 @publishedPartner
       
   193 @released
       
   194 */
       
   195     {
       
   196     public:
       
   197 
       
   198         TDnsRespA() : TDnsQryRespBase(KDnsRRTypeA, KDnsRRClassIN)  {}
       
   199 
       
   200         inline const TInetAddr&  HostAddress() const; 
       
   201         inline void  SetHostAddress(const TInetAddr& aInetAddr);
       
   202 
       
   203     protected:
       
   204         TInetAddr   iInetAddr;  ///< Host address
       
   205     };
       
   206 
       
   207 typedef TPckgBuf<TDnsRespA> TDnsRespABuf;
       
   208 
       
   209 
       
   210 class TDnsRespAAAA : public TDnsQryRespBase
       
   211 /**
       
   212 IPv6 DNS Host Address query response representation.
       
   213 See RFC1035, RFC1886
       
   214 
       
   215 @publishedPartner
       
   216 @released
       
   217 */
       
   218     {
       
   219     public:
       
   220 
       
   221         TDnsRespAAAA() : TDnsQryRespBase(KDnsRRTypeAAAA, KDnsRRClassIN) {}
       
   222 
       
   223         inline const TInetAddr&  HostAddress() const;   
       
   224         inline void SetHostAddress(const TInetAddr& aInetAddr);
       
   225 
       
   226     protected:
       
   227         TInetAddr   iInetAddr;  ///< Host address
       
   228     };
       
   229 
       
   230 typedef TPckgBuf<TDnsRespAAAA> TDnsRespAAAABuf;
       
   231 
       
   232 
       
   233 class TDnsRespPTR : public TDnsQryRespBase
       
   234 /**
       
   235 DNS Domain Name query response representation.
       
   236 See RFC1034.
       
   237 
       
   238 @publishedPartner
       
   239 @released
       
   240 */
       
   241     {
       
   242     public:
       
   243 
       
   244         TDnsRespPTR() : TDnsQryRespBase(KDnsRRTypePTR, KDnsRRClassIN) {}
       
   245 
       
   246         inline const TDesC8& HostName() const; 
       
   247         inline void  SetHostName(const TDesC8& aHostName);
       
   248 
       
   249     protected:
       
   250         TDnsDomainName    iName;  ///< domain this RR refers to.
       
   251     };
       
   252 
       
   253 typedef TPckgBuf<TDnsRespPTR> TDnsRespPTRBuf;
       
   254 
       
   255 
       
   256 class TDnsRespNAPTR : public TDnsQryRespBase
       
   257 /** 
       
   258 DNS NAPTR query response representation.
       
   259 See RFC2915.
       
   260 
       
   261 @publishedPartner
       
   262 @released
       
   263 */
       
   264     {
       
   265     public:
       
   266 
       
   267         inline TDnsRespNAPTR();
       
   268 
       
   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; 
       
   275 
       
   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);
       
   282 
       
   283     protected:
       
   284 
       
   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
       
   291     };
       
   292 
       
   293 typedef TPckgBuf<TDnsRespNAPTR> TDnsRespNAPTRBuf;
       
   294 
       
   295 class TDnsRespMX: public TDnsQryRespBase
       
   296 /**
       
   297 DNS MX query response representation.
       
   298 See RFC1035, RFC974.
       
   299 
       
   300 @publishedPartner
       
   301 @released
       
   302 */
       
   303     {
       
   304     public:
       
   305 
       
   306         TDnsRespMX() : TDnsQryRespBase(KDnsRRTypeMX, KDnsRRClassIN) {}
       
   307 
       
   308         inline TUint16         Pref()      const; 
       
   309         inline const TDesC8&   HostName()  const; 
       
   310 
       
   311         inline void SetPref(TUint16 aPref);
       
   312         inline void SetHostName(const TDesC8& aHostName);
       
   313 
       
   314     protected:
       
   315 
       
   316         TUint16         iPref;       ///< RR Preference field.
       
   317         TDnsDomainName  iHostName;   ///< Host name.
       
   318 
       
   319     };
       
   320 
       
   321 typedef TPckgBuf<TDnsRespMX> TDnsRespMXBuf;
       
   322 
       
   323 // -- DNS query type value, DoCoMo Cache requirement
       
   324 // This is used in conjunction with RHostResolver::Query
       
   325 // Example usage:
       
   326 //
       
   327 // 		TDnsQueryBuf dnsQryBuf;
       
   328 //		TDnsRespABuf dummy;
       
   329 //
       
   330 //		dnsQryBuf().SetType(KDnsQTypeCacheClear);
       
   331 //		resolver.Query(dnsQryBuf, dummy, status); 
       
   332 //		User::WaitForRequest(status);
       
   333 //
       
   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.
       
   337 // Example usage:
       
   338 //
       
   339 //		TNameEntry nameEntry;
       
   340 //		TBuf<256> hostName(KDnsNonrecursive);
       
   341 //		hostName.Append(_L("www.symbian.com"));
       
   342 //
       
   343 //		resolver.GetByName(hostName,nameEntry, status);
       
   344 //		User::WaitForRequest(status);
       
   345 //
       
   346 _LIT(KDnsNonrecursive, "NONRECURSIVE?");
       
   347 
       
   348 #include "dns_qry.inl"
       
   349 
       
   350 #endif //__DNS_QRY_H__