EpcTools
An event based multi-threaded C++ development framework.
|
Go to the documentation of this file.
39 class QueryProcessorThread;
46 typedef std::shared_ptr<Query>
QueryPtr;
48 typedef std::map<QueryCacheKey, QueryPtr> QueryCache;
49 extern "C" typedef Void(*CachedDNSQueryCallback)(
QueryPtr q, Bool cacheHit,
const Void *data);
59 QueryCacheKey( ns_type rtype,
const std::string &domain )
65 QueryCacheKey(
const QueryCacheKey &other )
67 m_type = other.m_type;
68 m_domain = other.m_domain;
71 const QueryCacheKey& operator=(
const QueryCacheKey &r )
74 m_domain = r.m_domain;
78 Bool operator<(
const QueryCacheKey &r )
const
81 this->m_type < r.m_type ? true :
82 this->m_type > r.m_type ? false :
83 this->m_domain < r.m_domain ? true :
false;
86 const ns_type getType() {
return m_type; }
87 const EString &getDomain() {
return m_domain; }
102 friend QueryProcessor;
103 friend QueryProcessorThread;
109 Query( ns_type rtype,
const std::string &domain )
117 m_expires( LONG_MAX ),
118 m_ignorecache( false )
131 m_question.push_back( q );
139 if ( m_expires == 0 || a->
getTTL() != 0 )
149 m_answer.push_back( a );
158 if ( m_expires == 0 || a->
getTTL() != 0 )
168 m_authority.push_back( a );
177 if ( m_expires == 0 || a->
getTTL() != 0 )
187 m_additional.push_back( a );
227 std::cout <<
"QUERY type=" <<
getType() <<
" domain=" <<
getDomain() << std::endl;
228 std::cout <<
"QUESTION:" << std::endl;
229 for (QuestionList::const_iterator it =
getQuestions().begin();
236 std::cout <<
"ANSWER:" << std::endl;
237 for (ResourceRecordList::const_iterator it =
getAnswers().begin();
244 std::cout <<
"AUTHORITY:" << std::endl;
245 for (ResourceRecordList::const_iterator it =
getAuthorities().begin();
252 std::cout <<
"ADDITIONAL:" << std::endl;
253 for (ResourceRecordList::const_iterator it =
getAdditional().begin();
273 CachedDNSQueryCallback
setCallback(CachedDNSQueryCallback cb) {
return m_cb = cb; }
303 QueryProcessor *getQueryProcessor() {
return m_qp; }
304 QueryProcessor *setQueryProcessor(QueryProcessor *qp) {
return m_qp = qp; }
306 const Void *getData() {
return m_data; }
307 const Void *setData(
const Void *data) {
return m_data = data; }
311 QueryProcessor *m_qp;
312 CachedDNSQueryCallback m_cb;
318 QuestionList m_question;
319 ResourceRecordList m_answer;
320 ResourceRecordList m_authority;
321 ResourceRecordList m_additional;
331 #endif // #ifndef __DNSQUERY_H
EString & getErrorMsg()
Retrieves the error message associated with this DNS query.
Definition: dnsquery.h:285
ns_type getType()
Retrieves the named service type associated with this query.
Definition: dnsquery.h:193
const ResourceRecordList & getAnswers()
Retrieves the collection of query result answer records.
Definition: dnsquery.h:216
An object that can be waited on to be set in another thread.
Definition: esynch.h:616
CachedDNSQueryCallback getCallback()
Retrieves the query completion callback function.
Definition: dnsquery.h:270
time_t getExpires()
Retrieves the expiration time of this resource record.
Definition: dnsrecord.h:145
time_t getExpires()
retrieves the expiration time associated with the query results.
Definition: dnsquery.h:203
const ResourceRecordList & getAuthorities()
Retrieves the collection of query result authority records.
Definition: dnsquery.h:219
uint32_t getTTL()
Retrieves the time to live (TTL) value associated with the query results.
Definition: dnsquery.h:200
uint32_t getTTL()
Retrieves the time interval (in seconds) that the resource record may be cached before it should be d...
Definition: dnsrecord.h:142
Void addAdditional(ResourceRecord *a)
Adds an additional record to the query results.
Definition: dnsquery.h:173
Bool getIgnoreCache()
Retrieves the current ignore cache value.
Definition: dnsquery.h:295
EEvent * setCompletionEvent(EEvent *event)
Assigns the query completion event.
Definition: dnsquery.h:266
Bool setError(Bool err)
Assigns the error indication.
Definition: dnsquery.h:281
CachedDNSQueryCallback setCallback(CachedDNSQueryCallback cb)
Assigns the query completion callback function for this DNS query.
Definition: dnsquery.h:273
Contains definitions for synchronization objects.
Represents a DNS Resource Record.
Definition: dnsrecord.h:106
const std::list< Question * > & getQuestions()
Retrieves the collection of query result question records.
Definition: dnsquery.h:213
const EString & getDomain()
Retrieves the domain associated with this query.
Definition: dnsquery.h:196
Query(ns_type rtype, const std::string &domain)
Class constructor.
Definition: dnsquery.h:109
Defines the functionality associated with a DNS cache.
Definition: dnscache.h:184
Defines the classes related to DNS records.
Defines a DNS query.
Definition: dnsquery.h:99
Void addAnswer(ResourceRecord *a)
Adds an answer record to the query results.
Definition: dnsquery.h:135
~Query()
Class destructor.
Definition: dnsquery.h:122
const ResourceRecordList & getAdditional()
Retrieves the collection of query result additional records.
Definition: dnsquery.h:222
Bool setIgnoreCache(Bool ignorecache)
Assigns the ignore cache value.
Definition: dnsquery.h:299
EString & setErrorMsg(const std::string &errmsg)
Assigns the error message associated with this DNS query.
Definition: dnsquery.h:291
Void dump()
Prints the information associated with this DNS query object.
Definition: dnsquery.h:225
Definition: dnscache.h:33
String class.
Definition: estring.h:30
Void addAuthority(ResourceRecord *a)
Adds an authority record to the query results.
Definition: dnsquery.h:154
Represents the question for the name server.
Definition: dnsrecord.h:40
Bool ignoreCache()
Retrieves an indication if the DNS cache for this query should be ignored.
Definition: dnsquery.h:209
EString & setErrorMsg(const char *errmsg)
Assigns the error message associated with this DNS query.
Definition: dnsquery.h:289
std::shared_ptr< Query > QueryPtr
A typedef to std::shared_ptr<Query>.
Definition: dnsquery.h:40
Bool getError()
Retrieves the error indication.
Definition: dnsquery.h:277
Bool isExpired()
Retrieves an indication if the query results have expired.
Definition: dnsquery.h:206
Encapsulates and extends a std::string object.
Void addQuestion(Question *q)
Adds a question record to a query results.
Definition: dnsquery.h:128
EEvent * getCompletionEvent()
Retrieves the completion event associated with this query.
Definition: dnsquery.h:263