PTLib  Version 2.10.10
enum.h
Go to the documentation of this file.
1 /*
2  * pdns.h
3  *
4  * PWLib library for ENUM lookup
5  *
6  * Portable Windows Library
7  *
8  * Copyright (C) 2004 Post Increment
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Post Increment
23  *
24  * Contributor(s): ______________________________________.
25  *
26  * $Revision: 24177 $
27  * $Author: rjongbloed $
28  * $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
29  */
30 
31 #ifndef PTLIB_ENUM_H
32 #define PTLIB_ENUM_H
33 
34 #ifdef P_USE_PRAGMA
35 #pragma interface
36 #endif
37 
38 #include <ptclib/pdns.h>
39 
40 #if P_DNS
41 
42 namespace PDNS {
43 
44 #ifndef NAPTR_SRV
45 #define NAPTR_SRV 35
46 #endif
47 
49 
50 class NAPTRRecord : public PObject
51 {
52  PCLASSINFO(NAPTRRecord, PObject);
53  public:
54  Comparison Compare(const PObject & obj) const;
55  void PrintOn(ostream & strm) const;
56 
57  WORD order;
58  WORD preference;
63 };
64 
66  public:
67  void PrintOn(ostream & strm) const;
68 
69  NAPTRRecord * GetFirst(const char * service = NULL);
70  NAPTRRecord * GetNext(const char * service = NULL);
71 
73 
74  void UnlockOrder()
75  { orderLocked = false; }
76 
77  protected:
78  PINDEX currentPos;
79  int lastOrder;
81 };
82 
83 inline PBoolean GetRecords(const PString & domain, NAPTRRecordList & recordList)
84 { return Lookup<NAPTR_SRV, NAPTRRecordList, NAPTRRecord>(domain, recordList); }
85 
89 void SetENUMServers(const PStringArray & serverlist);
90 
98  const PString & dn,
99  const PString & service,
100  const PStringArray & domains,
101  PString & URL
102 );
103 
112 PBoolean ENUMLookup(const PString & dn,
113  const PString & service,
114  PString & URL
115 );
116 
117 
119 /* Uniform Resource Name Resolver Discovery System URN RDS
120  This can be used to Host URI domains on hosting servers.
121  This implementation follows RFC 2915 sect 7.1 Example 2:
122  Example
123  Question: find h323:me@a.com by looking up mydomain.com
124  Query the top most NAPTR record of mydomain.com for h323:me@a.com
125  IN NAPTR 100 10 "" "" ^h323:(.+)@([a-z0-9\-\.]*);*(.*)$/\2.subs.mydomain.com/i
126  this converts a.com to a.com.subs.mydomain.com
127  Query H323+D2U NAPTR record for a.com.subs.mydomain.com
128  IN NAPTR 100 50 "s" "H323+D2U" "" _h323ls._udp.host.com
129  Query SRV records for host.com
130  _h323ls._udp.host.com 172800 IN SRV 0 0 1719 gk.host.com
131 
132  Answer: find h323:me@a.com by LRQ to gk.host.com:1719
133 */
134 
138 void SetRDSServers(const PStringArray & servers);
139 
149 PBoolean RDSLookup(const PURL & url,
150  const PString & service,
151  PStringList & dn
152 );
153 
162 PBoolean RDSLookup(const PURL & url,
163  const PString & service,
164  const PStringArray & naptrSpaces,
165  PStringList & returnStr
166 );
167 
168 }; // namespace PDNS
169 
170 #endif // P_DNS
171 
172 #endif // PTLIB_ENUM_H
173 
174 
175 // End Of File ///////////////////////////////////////////////////////////////
PString service
Definition: enum.h:60
PString replacement
Definition: enum.h:62
void SetRDSServers(const PStringArray &servers)
Set the Default NAPTR server to lookup.
PBoolean orderLocked
Definition: enum.h:80
WORD preference
Definition: enum.h:58
void SetENUMServers(const PStringArray &serverlist)
Set the default ENUM domain search list.
Definition: enum.h:42
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:1184
int lastOrder
Definition: enum.h:79
This is an array collection class of PString objects.
Definition: pstring.h:2024
void UnlockOrder()
Definition: enum.h:74
BOOL PBoolean
Definition: object.h:102
PINDEX currentPos
Definition: enum.h:78
PString flags
Definition: enum.h:59
WORD order
Definition: enum.h:57
The character string class.
Definition: pstring.h:108
Definition: pdns.h:152
PString regex
Definition: enum.h:61
NAPTRRecord * GetNext(const char *service=NULL)
void PrintOn(ostream &strm) const
This is a list collection class of PString objects.
Definition: pstring.h:2184
NAPTRRecord * GetFirst(const char *service=NULL)
PDNS::NAPTRRecord * HandleDNSRecord(PDNS_RECORD dnsRecord, PDNS_RECORD results)
void PrintOn(ostream &strm) const
Output the contents of the object to the stream.
PBoolean GetRecords(const PString &domain, NAPTRRecordList &recordList)
Definition: enum.h:83
Comparison Compare(const PObject &obj) const
Compare the two objects and return their relative rank.
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
PBoolean RDSLookup(const PURL &url, const PString &service, PStringList &dn)
Perform a lookup of the specified url on the NAPTR server list (set by SetNAPTRServers) that uses the...
This class describes a Universal Resource Locator.
Definition: url.h:54
PBoolean ENUMLookup(const PString &dn, const PString &service, const PStringArray &domains, PString &URL)
Perform a lookup of the specified DN using the specified service and domain list. ...
Definition: enum.h:50
#define PDECLARE_SORTED_LIST(cls, T)
Begin declaration of a sorted list class.
Definition: lists.h:1028