static constexpr bool l_verbose=false;
+static constexpr uint16_t maxCompressionOffset=16384;
uint16_t DNSPacketWriter::lookupName(const DNSName& name, uint16_t* matchLen)
{
// iterate over the written labels, see if we find a match
if(!c)
break;
auto offset = iter - d_content.cbegin();
- if (offset >= 16384) break; // compression pointers cannot point here
+ if (offset >= maxCompressionOffset) break; // compression pointers cannot point here
pvect.push_back(offset);
iter+=*iter+1;
}
uint16_t li=0;
uint16_t matchlen=0;
- if(d_compress && compress && (li=lookupName(name, &matchlen)) && li < 16384) {
+ if(d_compress && compress && (li=lookupName(name, &matchlen)) && li < maxCompressionOffset) {
const auto& dns=name.getStorage();
if(l_verbose)
cout<<"Found a substring of "<<matchlen<<" bytes from the back, offset: "<<li<<", dnslen: "<<dns.size()<<endl;
// found a substring, if www.powerdns.com matched powerdns.com, we get back matchlen = 13
unsigned int pos=d_content.size();
- if(pos < 16384 && matchlen != dns.size()) {
+ if(pos < maxCompressionOffset && matchlen != dns.size()) {
if(l_verbose)
cout<<"Inserting pos "<<pos<<" for "<<name<<" for compressed case"<<endl;
d_namepositions.push_back(pos);
unsigned int pos=d_content.size();
if(l_verbose)
cout<<"Found nothing, we are at pos "<<pos<<", inserting whole name"<<endl;
- if(pos < 16384) {
+ if(pos < maxCompressionOffset) {
if(l_verbose)
cout<<"Inserting pos "<<pos<<" for "<<name<<" for uncompressed case"<<endl;
d_namepositions.push_back(pos);