PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
27 #ifndef PTLIB_ENUM_H
28 #define PTLIB_ENUM_H
29 
30 #ifdef P_USE_PRAGMA
31 #pragma interface
32 #endif
33 
34 #include <ptclib/pdns.h>
35 
36 #if P_DNS_RESOLVER && P_URL
37 
38 namespace PDNS {
39 
40 #ifndef NAPTR_SRV
41 #define NAPTR_SRV 35
42 #endif
43 
45 
46 class NAPTRRecord : public PObject
47 {
48  PCLASSINFO(NAPTRRecord, PObject);
49  public:
50  Comparison Compare(const PObject & obj) const;
51  void PrintOn(ostream & strm) const;
52 
53  WORD order;
54  WORD preference;
59 };
60 
62  public:
63  void PrintOn(ostream & strm) const;
64 
65  NAPTRRecord * GetFirst(const char * service = NULL);
66  NAPTRRecord * GetNext(const char * service = NULL);
67 
68  PDNS::NAPTRRecord * HandleDNSRecord(PDNS_RECORD dnsRecord, PDNS_RECORD results);
69 
70  void UnlockOrder()
71  { orderLocked = false; }
72 
73  protected:
74  PINDEX currentPos;
75  int lastOrder;
77 };
78 
79 inline PBoolean GetRecords(const PString & domain, NAPTRRecordList & recordList)
80 { return Lookup<NAPTR_SRV, NAPTRRecordList, NAPTRRecord>(domain, recordList); }
81 
85 void SetENUMServers(const PStringArray & serverlist);
86 
94  const PString & dn,
95  const PString & service,
96  const PStringArray & domains,
97  PString & URL
98 );
99 
108 PBoolean ENUMLookup(const PString & dn,
109  const PString & service,
110  PString & URL
111 );
112 
113 
115 /* Uniform Resource Name Resolver Discovery System URN RDS
116  This can be used to Host URI domains on hosting servers.
117  This implementation follows RFC 2915 sect 7.1 Example 2:
118  Example
119  Question: find h323:me@a.com by looking up mydomain.com
120  Query the top most NAPTR record of mydomain.com for h323:me@a.com
121  IN NAPTR 100 10 "" "" ^h323:(.+)@([a-z0-9\-\.]*);*(.*)$/\2.subs.mydomain.com/i
122  this converts a.com to a.com.subs.mydomain.com
123  Query H323+D2U NAPTR record for a.com.subs.mydomain.com
124  IN NAPTR 100 50 "s" "H323+D2U" "" _h323ls._udp.host.com
125  Query SRV records for host.com
126  _h323ls._udp.host.com 172800 IN SRV 0 0 1719 gk.host.com
127 
128  Answer: find h323:me@a.com by LRQ to gk.host.com:1719
129 */
130 
134 void SetRDSServers(const PStringArray & servers);
135 
145 PBoolean RDSLookup(const PURL & url,
146  const PString & service,
147  PStringList & dn
148 );
149 
158 PBoolean RDSLookup(const PURL & url,
159  const PString & service,
160  const PStringArray & naptrSpaces,
161  PStringList & returnStr
162 );
163 
164 }; // namespace PDNS
165 
166 #endif // P_DNS_RESOLVER && P_URL
167 
168 #endif // PTLIB_ENUM_H
169 
170 
171 // End Of File ///////////////////////////////////////////////////////////////
PString service
Definition: enum.h:56
PString replacement
Definition: enum.h:58
void SetRDSServers(const PStringArray &servers)
Set the Default NAPTR server to lookup.
PBoolean orderLocked
Definition: enum.h:76
WORD preference
Definition: enum.h:54
void SetENUMServers(const PStringArray &serverlist)
Set the default ENUM domain search list.
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:2251
int lastOrder
Definition: enum.h:75
This is an array collection class of PString objects.
Definition: pstring.h:2365
void UnlockOrder()
Definition: enum.h:70
PINDEX currentPos
Definition: enum.h:74
PString flags
Definition: enum.h:55
WORD order
Definition: enum.h:53
bool PBoolean
Definition: object.h:174
The character string class.
Definition: pstring.h:108
Definition: pdns.h:148
PString regex
Definition: enum.h:57
NAPTRRecord * GetNext(const char *service=NULL)
void PrintOn(ostream &strm) const
This is a list collection class of PString objects.
Definition: pstring.h:2562
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:79
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:2204
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:56
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:46
#define PDECLARE_SORTED_LIST(cls, T)
Begin declaration of a sorted list class.
Definition: lists.h:1131