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  * $Log: enum.h,v $
00027  * Revision 1.6  2007/06/27 15:26:35  shorne
00028  * added Uniform Resource Name Resolver Discovery System (URN RDS) lookups
00029  *
00030  * Revision 1.5  2005/11/30 12:47:37  csoutheren
00031  * Removed tabs, reformatted some code, and changed tags for Doxygen
00032  *
00033  * Revision 1.4  2005/08/31 23:55:48  csoutheren
00034  * Fixed typo
00035  *
00036  * Revision 1.3  2005/08/31 05:55:03  shorne
00037  * Reworked ENUM to craigs' exacting requirements
00038  *
00039  * Revision 1.2  2005/08/31 04:07:52  shorne
00040  * added ability to set ENUM Servers at runtime
00041  *
00042  * Revision 1.1  2004/05/31 13:56:37  csoutheren
00043  * Added implementation of ENUM resolution of E.164 numbers by DNS
00044  *
00045  */
00046 
00047 #if P_DNS
00048 
00049 #ifndef _PENUM_H
00050 #define _PENUM_H
00051 
00052 #ifdef P_USE_PRAGMA
00053 #pragma interface
00054 #endif
00055 
00056 #include <ptclib/pdns.h>
00057 
00058 namespace PDNS {
00059 
00060 #ifndef NAPTR_SRV
00061 #define NAPTR_SRV 35
00062 #endif
00063 
00065 
00066 class NAPTRRecord : public PObject
00067 {
00068   PCLASSINFO(NAPTRRecord, PObject);
00069   public:
00070     Comparison Compare(const PObject & obj) const;
00071     void PrintOn(ostream & strm) const;
00072 
00073     WORD order;
00074     WORD preference;
00075     PString flags;
00076     PString service;
00077     PString regex;
00078     PString replacement;
00079 };
00080 
00081 PDECLARE_SORTED_LIST(NAPTRRecordList, PDNS::NAPTRRecord)
00082   public:
00083     void PrintOn(ostream & strm) const;
00084 
00085     NAPTRRecord * GetFirst(const char * service = NULL);
00086     NAPTRRecord * GetNext(const char * service = NULL);
00087 
00088     PDNS::NAPTRRecord * HandleDNSRecord(PDNS_RECORD dnsRecord, PDNS_RECORD results);
00089 
00090     void UnlockOrder()
00091     { orderLocked = FALSE; }
00092 
00093   protected:
00094     PINDEX     currentPos;
00095     int        lastOrder;
00096     BOOL       orderLocked;
00097 };
00098 
00099 inline BOOL GetRecords(const PString & domain, NAPTRRecordList & recordList)
00100 { return Lookup<NAPTR_SRV, NAPTRRecordList, NAPTRRecord>(domain, recordList); }
00101 
00105 void SetENUMServers(const PStringArray & serverlist);
00106 
00113 BOOL ENUMLookup(
00114                 const PString & dn,             
00115                 const PString & service,        
00116                 const PStringArray & domains,   
00117                 PString & URL                   
00118 );
00119 
00128 BOOL ENUMLookup(const PString & dn,             
00129                 const PString & service,        
00130                 PString & URL                   
00131 );   
00132 
00133 
00135 /* Uniform Resource Name Resolver Discovery System URN RDS
00136    This can be used to Host URI domains on hosting servers.
00137     This implementation follows RFC 2915 sect 7.1 Example 2:
00138     Example
00139         Question: find h323:me@a.com by looking up mydomain.com
00140         Query the top most NAPTR record of mydomain.com for h323:me@a.com
00141           IN NAPTR 100   10   ""  ""  ^h323:(.+)@([a-z0-9\-\.]*);*(.*)$/\2.subs.mydomain.com/i 
00142            this converts a.com to a.com.subs.mydomain.com
00143         Query H323+D2U NAPTR record for a.com.subs.mydomain.com
00144       IN NAPTR 100  50  "s"  "H323+D2U"     ""  _h323ls._udp.host.com
00145     Query SRV records for host.com
00146           _h323ls._udp.host.com         172800          IN      SRV     0       0       1719    gk.host.com
00147 
00148         Answer: find h323:me@a.com by LRQ to gk.host.com:1719
00149 */
00150 
00154 void SetRDSServers(const PStringArray & servers);
00155 
00165 BOOL RDSLookup(const PURL & url,           
00166             const PString & service,       
00167                           PStringList & dn             
00168 );
00169 
00178 BOOL RDSLookup(const PURL & url,            
00179             const PString & service,        
00180        const PStringArray & naptrSpaces,    
00181               PStringList & returnStr       
00182 );
00183 
00184 }; // namespace PDNS
00185 
00186 #endif // _PENUM_H
00187 #endif // P_DNS
00188 
00189 // End Of File ///////////////////////////////////////////////////////////////

Generated on Fri Mar 7 06:25:02 2008 for PTLib by  doxygen 1.5.1