return r;
}
-void DNSPacket::spoofQuestion(const string &qd)
+void DNSPacket::spoofQuestion(const DNSPacket *qd)
{
- string label=simpleCompress(qd);
d_wrapped=true; // if we do this, don't later on wrapup
- if(label.size() + sizeof(d) > d_rawpacket.size()) { // probably superfluous
- return;
+ int labellen;
+ string::size_type i=sizeof(d);
+
+ for(;;) {
+ labellen = qd->d_rawpacket[i];
+ if(!labellen) break;
+ i++;
+ d_rawpacket.replace(i, labellen, qd->d_rawpacket, i, labellen);
+ i = i + labellen;
}
-
- for(string::size_type i=0; i < label.size(); ++i)
- d_rawpacket[i+sizeof(d)]=label[i];
-
}
int DNSPacket::noparse(const char *mesg, int length)
DTime d_dt; //!< the time this packet was created. replyPacket() copies this in for you, so d_dt becomes the time spent processing the question+answer
void wrapup(); // writes out queued rrs, and generates the binary packet. also shuffles. also rectifies dnsheader 'd', and copies it to the stringbuffer
- void spoofQuestion(const string &qd); //!< paste in the exact right case of the question. Useful for PacketCache
+ void spoofQuestion(const DNSPacket *qd); //!< paste in the exact right case of the question. Useful for PacketCache
unsigned int getMinTTL(); //!< returns lowest TTL of any record in the packet
vector<DNSResourceRecord*> getAPRecords(); //!< get a vector with DNSResourceRecords that need additional processing
if(cached->noparse(value.c_str(), value.size()) < 0) {
return 0;
}
- cached->spoofQuestion(p->qdomain); // for correct case
+ cached->spoofQuestion(p); // for correct case
return 1;
}