# enum.h

Go to the documentation of this file.

    00001 /*
    00002  * pdns.h
    00003  *
    00004  * PWLib library for ENUM lookup
    00005  *
    00006  * Portable Windows Library
    00007  *
    00008  * Copyright (C) 2004 Post Increment
    00009  *
    00010  * The contents of this file are subject to the Mozilla Public License
    00011  * Version 1.0 (the "License"); you may not use this file except in
    00012  * compliance with the License. You may obtain a copy of the License at
    00013  * http://www.mozilla.org/MPL/
    00014  *
    00015  * Software distributed under the License is distributed on an "AS IS"
    00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
    00017  * the License for the specific language governing rights and limitations
    00018  * under the License.
    00019  *
    00020  * The Original Code is Portable Windows Library.
    00021  *
    00022  * The Initial Developer of the Original Code is Post Increment
    00023  *
    00024  * Contributor(s): ______________________________________.
    00025  *
    00026  * $Revision: 24177 $
    00027  * $Author: rjongbloed $
    00028  * $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
    00029  */
    00030
    00031 #ifndef PTLIB_ENUM_H
    00032 #define PTLIB_ENUM_H
    00033
    00034 #ifdef P_USE_PRAGMA
    00035 #pragma interface
    00036 #endif
    00037
    00038 #include <ptclib/pdns.h>
    00039
    00040 #if P_DNS
    00041
    00042 namespace PDNS {
    00043
    00044 #ifndef NAPTR_SRV
    00045 #define NAPTR_SRV 35
    00046 #endif
    00047
    00049
    00050 class NAPTRRecord : public PObject
    00051 {
    00052   PCLASSINFO(NAPTRRecord, PObject);
    00053   public:
    00054     Comparison Compare(const PObject & obj) const;
    00055     void PrintOn(ostream & strm) const;
    00056
    00057     WORD order;
    00058     WORD preference;
    00059     PString flags;
    00060     PString service;
    00061     PString regex;
    00062     PString replacement;
    00063 };
    00064
    00065 PDECLARE_SORTED_LIST(NAPTRRecordList, PDNS::NAPTRRecord)
    00066   public:
    00067     void PrintOn(ostream & strm) const;
    00068
    00069     NAPTRRecord * GetFirst(const char * service = NULL);
    00070     NAPTRRecord * GetNext(const char * service = NULL);
    00071
    00072     PDNS::NAPTRRecord * HandleDNSRecord(PDNS_RECORD dnsRecord, PDNS_RECORD results);
    00073
    00074     void UnlockOrder()
    00075     { orderLocked = false; }
    00076
    00077   protected:
    00078     PINDEX     currentPos;
    00079     int        lastOrder;
    00080     PBoolean       orderLocked;
    00081 };
    00082
    00083 inline PBoolean GetRecords(const PString & domain, NAPTRRecordList & recordList)
    00084 { return Lookup<NAPTR_SRV, NAPTRRecordList, NAPTRRecord>(domain, recordList); }
    00085
    00089 void SetENUMServers(const PStringArray & serverlist);
    00090
    00097 PBoolean ENUMLookup(
    00098                 const PString & dn,
    00099                 const PString & service,
    00100                 const PStringArray & domains,
    00101                 PString & URL
    00102 );
    00103
    00112 PBoolean ENUMLookup(const PString & dn,
    00113                 const PString & service,
    00114                 PString & URL
    00115 );
    00116
    00117
    00119 /* Uniform Resource Name Resolver Discovery System URN RDS
    00120    This can be used to Host URI domains on hosting servers.
    00121     This implementation follows RFC 2915 sect 7.1 Example 2:
    00122     Example
    00123         Question: find h323:me@a.com by looking up mydomain.com
    00124         Query the top most NAPTR record of mydomain.com for h323:me@a.com
    00125           IN NAPTR 100   10   ""  ""  ^h323:(.+)@([a-z0-9\-\.]*);*(.*)$/\2.subs.mydomain.com/i
    00126            this converts a.com to a.com.subs.mydomain.com
    00127         Query H323+D2U NAPTR record for a.com.subs.mydomain.com
    00128       IN NAPTR 100  50  "s"  "H323+D2U"     ""  _h323ls._udp.host.com
    00129     Query SRV records for host.com
    00130           _h323ls._udp.host.com         172800          IN      SRV     0       0       1719    gk.host.com
    00131
    00132         Answer: find h323:me@a.com by LRQ to gk.host.com:1719
    00133 */
    00134
    00138 void SetRDSServers(const PStringArray & servers);
    00139
    00149 PBoolean RDSLookup(const PURL & url,
    00150             const PString & service,
    00151                           PStringList & dn
    00152 );
    00153
    00162 PBoolean RDSLookup(const PURL & url,
    00163             const PString & service,
    00164        const PStringArray & naptrSpaces,
    00165               PStringList & returnStr
    00166 );
    00167
    00168 }; // namespace PDNS
    00169
    00170 #endif // P_DNS
    00171
    00172 #endif // PTLIB_ENUM_H
    00173
    00174
    00175 // End Of File ///////////////////////////////////////////////////////////////