}
uint16_t maxReplyLen = p->d_tcp ? 0xffff : p->getMaxReplyLen();
- haveSomething=getEntryLocked(p->qdomain.toString() /*FIXME*/, p->qtype, PacketCache::PACKETCACHE, value, -1, recursive, maxReplyLen, p->d_dnssecOk, p->hasEDNS(), &age);
+ haveSomething=getEntryLocked(p->qdomain, p->qtype, PacketCache::PACKETCACHE, value, -1, recursive, maxReplyLen, p->d_dnssecOk, p->hasEDNS(), &age);
}
if(haveSomething) {
(*d_statnumhit)++;
if(minttl<ourttl)
ourttl=minttl;
}
- insert(q->qdomain.toString() /*FIXME*/, q->qtype, PacketCache::PACKETCACHE, r->getString(), ourttl, -1, recursive,
+ insert(q->qdomain, q->qtype, PacketCache::PACKETCACHE, r->getString(), ourttl, -1, recursive,
maxReplyLen, q->d_dnssecOk, q->hasEDNS());
}
cmap_t::const_iterator start=iter;
for(; iter != mc.d_map.end(); ++iter) {
- if(iter->qname.toString().compare(0, zone.size(), zone) != 0) { //TODO: check if there is a nicer method for this
- break;
- }
- delcount++;
+ if(iter->qname.compare(0, zone.size(), zone) != 0) {
+ break;
+ }
+ delcount++;
}
mc.d_map.erase(start, iter);
}
}
-string PacketCache::pcReverse(const DNSName &DNcontent)
+string PacketCache::pcReverse(DNSName content)
{
- typedef vector<pair<unsigned int, unsigned int> > parts_t;
- parts_t parts;
- string content = DNcontent.toString();
- vstringtok(parts,toLower(content), ".");
- string ret;
- ret.reserve(content.size()+1);
- for(parts_t::reverse_iterator i=parts.rbegin(); i!=parts.rend(); ++i) {
- ret.append(1, (char)(i->second - i->first));
- ret.append(content.c_str() + i->first, i->second - i->first);
- }
- return ret;
+ string ret=content.labelReverse().toDNSString();
+ return ret.substr(0, ret.size()-1);
}
map<char,int> PacketCache::getCounts()
map<char,int> getCounts();
private:
- bool getEntryLocked(const DNSName &qname, const QType& qtype, CacheEntryType cet, string& entry, int zoneID=-1,
+ bool getEntryLocked(const DNSName &content, const QType& qtype, CacheEntryType cet, string& entry, int zoneID=-1,
bool meritsRecursion=false, unsigned int maxReplyLen=512, bool dnssecOk=false, bool hasEDNS=false, unsigned int *age=0);
- string pcReverse(const DNSName &content);
+ string pcReverse(DNSName content);
struct CacheEntry
{
CacheEntry() { qtype = ctype = 0; zoneID = -1; meritsRecursion=false; dnssecOk=false; hasEDNS=false;}
- DNSName qname;
+ string qname;
uint16_t qtype;
uint16_t ctype;
int zoneID;
ordered_unique<
composite_key<
CacheEntry,
- member<CacheEntry,DNSName,&CacheEntry::qname>,
+ member<CacheEntry,string,&CacheEntry::qname>,
member<CacheEntry,uint16_t,&CacheEntry::qtype>,
member<CacheEntry,uint16_t, &CacheEntry::ctype>,
member<CacheEntry,int, &CacheEntry::zoneID>,
member<CacheEntry,bool, &CacheEntry::dnssecOk>,
member<CacheEntry,bool, &CacheEntry::hasEDNS>
>,
- composite_key_compare<std::less<DNSName>, std::less<uint16_t>, std::less<uint16_t>, std::less<int>, std::less<bool>,
+ composite_key_compare<std::less<string>, std::less<uint16_t>, std::less<uint16_t>, std::less<int>, std::less<bool>,
std::less<unsigned int>, std::less<bool>, std::less<bool> >
>,
sequenced<>
};
vector<MapCombo> d_maps;
- MapCombo& getMap(const DNSName& qname)
+ MapCombo& getMap(const std::string& qname)
{
- return d_maps[burtle((const unsigned char*)qname.toString().c_str(), qname.toString().length(), 0) % d_maps.size()];
+ return d_maps[burtle((const unsigned char*)qname.c_str(), qname.length(), 0) % d_maps.size()];
}