1#if defined(HAVE_CONFIG_H)
12# include <netinet/in.h>
13# include <arpa/nameser.h>
17#include <netinet/in.h>
53#define RESIPROCATE_SUBSYSTEM resip::Subsystem::DNS
58 mUserDefinedTTL(DEFAULT_USER_DEFINED_TTL),
61 mFactoryMap[
T_CNAME] = &mCnameRecordFactory;
62 mFactoryMap[
T_NAPTR] = &mNaptrRecordFacotry;
63 mFactoryMap[
T_SRV] = &mSrvRecordFactory;
65 mFactoryMap[
T_AAAA] = &mAAAARecordFactory;
67 mFactoryMap[
T_A] = &mHostRecordFactory;
80 RRSet::iterator lb = mRRSet.lower_bound(key);
81 if (lb != mRRSet.end() &&
82 !(mRRSet.key_comp()(key, *lb)))
84#ifdef VERBOSE_DNS_STACK_LOGS
85 StackLog(<<
"Updating cache from hostfile: target=" << record.
name() <<
", host=" << record.
host());
87 (*lb)->update(record, 3600);
92#ifdef VERBOSE_DNS_STACK_LOGS
93 StackLog(<<
"Adding to cache from hostfile: target=" << record.
name() <<
", host=" << record.
host());
109 Data domain = (*begin).domain();
110 FactoryMap::iterator it = mFactoryMap.find(rrType);
111 if (it != mFactoryMap.end())
114 RRSet::iterator lb = mRRSet.lower_bound(key);
115 if (lb != mRRSet.end() &&
116 !(mRRSet.key_comp()(key, *lb)))
118 (*lb)->update(it->second, begin, end, mUserDefinedTTL);
119 if ((*lb)->numRecords() == 0)
125#ifdef VERBOSE_DNS_STACK_LOGS
126 StackLog(<<
"Update cache failed to parse, removed entry: target=" << target <<
", type=" <<
AresDns::dnsRRTypeToString(rrType) <<
", totalCachedEntries=" << mRRSet.size());
131#ifdef VERBOSE_DNS_STACK_LOGS
140 RRList* val =
new RRList(it->second, domain, rrType, begin, end, mUserDefinedTTL);
143#ifdef VERBOSE_DNS_STACK_LOGS
154#ifdef VERBOSE_DNS_STACK_LOGS
169 int ttl = getTTL(overlay);
176 if (ttl < mUserDefinedTTL)
178 ttl = mUserDefinedTTL;
182 RRSet::iterator it = mRRSet.find(val);
183 if (it != mRRSet.end())
193#ifdef VERBOSE_DNS_STACK_LOGS
194 StackLog(<<
"Updated cache ttl: target=" << target <<
", type=" <<
AresDns::dnsRRTypeToString(rrType) <<
", status=" << status <<
", ttl=" << ttl <<
", totalCachedEntries=" << mRRSet.size());
208 RRSet::iterator it = mRRSet.find(key);
210 if (it == mRRSet.end())
212#ifdef VERBOSE_DNS_STACK_LOGS
213 StackLog(<<
"Cache lookup failed for: target=" << target <<
", type=" <<
AresDns::dnsRRTypeToString(type) <<
", protocol=" << protocol <<
", totalCachedEntries=" << mRRSet.size());
221#ifdef VERBOSE_DNS_STACK_LOGS
222 StackLog(<<
"Cache lookup found expired entry for: target=" << target <<
", type=" <<
AresDns::dnsRRTypeToString(type) <<
", protocol=" << protocol <<
", totalCachedEntries=" << mRRSet.size());
231#ifdef VERBOSE_DNS_STACK_LOGS
232 StackLog(<<
"Cache lookup success for: target=" << target <<
", type=" <<
AresDns::dnsRRTypeToString(type) <<
", protocol=" << protocol <<
", totalCachedEntries=" << mRRSet.size());
234 records = (*it)->records(protocol);
235 status = (*it)->status();
249RRCache::touch(
RRList* node)
258 for (std::set<RRList*, CompareT>::iterator it = mRRSet.begin(); it != mRRSet.end(); it++)
264#ifdef VERBOSE_DNS_STACK_LOGS
265 StackLog(<<
"Cache emptied, totalCachedEntries=" << mRRSet.size());
279 const unsigned char* pPos = overlay.
data() + len;
302 if (mRRSet.size() < mSize)
return;
304 RRSet::iterator it = mRRSet.find(lst);
305 if (it != mRRSet.end())
307#ifdef VERBOSE_DNS_STACK_LOGS
330 strm <<
"DNSCACHE: TotalEntries=" << mRRSet.size();
331 for (std::set<RRList*, CompareT>::iterator it = mRRSet.begin(); it != mRRSet.end(); )
333 if (now >= (*it)->absoluteExpiry())
342 (*it)->encodeRRList(strm);
#define WarningLog(args_)
int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, int alen, char **s, long *enclen)
static const char * dnsRRTypeToString(int rrtype)
An iostream that operates on an existing Data.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
virtual const Data & name() const
void updateCacheFromHostFile(const DnsHostRecord &)
bool lookup(const Data &target, const int type, const int proto, Result &records, int &status)
std::vector< RROverlay >::const_iterator Itr
void cacheTTL(const Data &target, const int rrType, const int status, RROverlay overlay)
void updateCache(const Data &target, const int rrType, Itr begin, Itr end)
void getCacheDump(Data &dnsCacheDump)
const unsigned char * msg() const
const unsigned char * data() const
static uint64_t getTimeSecs()
Returns the current clock time in seconds.
dcm! – add UnusedChecking(_enum) below;
unsigned long long uint64_t