if((P->d.opcode != Opcode::Notify) && P->couldBeCached() && PC.get(P, &cached)) { // short circuit - does the PacketCache recognize this question?
cached.setRemote(&P->remote); // inlined
cached.setSocket(P->getSocket()); // inlined
- cached.spoofID(P->d.id); // inlined
cached.setMaxReplyLen(P->getMaxReplyLen());
cached.d.rd=P->d.rd; // copy in recursion desired bit
+ cached.d.id=P->d.id;
cached.commitD(); // commit d to the packet inlined
N->send(&cached); // answer it then inlined
remote=*s;
}
-void DNSPacket::spoofID(uint16_t id)
-{
- stringbuffer[1]=(id>>8)&0xff;
- stringbuffer[0]=id&0xff;
- d.id=id;
-}
-
void DNSPacket::setSocket(Utility::sock_t sock)
{
d_socket=sock;
const char *getData(void); //!< get binary representation of packet, will call 'wrapup' for you
const char *getRaw(void); //!< provides access to the raw packet, possibly on a packet that has never been 'wrapped'
- void spoofID(uint16_t id); //!< change the ID of an existing packet. Useful for fixing up packets returned from the PacketCache
void spoofQuestion(const string &qd); //!< paste in the exact right case of the question. Useful for PacketCache
void truncate(int new_length); // has documentation in source
d_conntrack[id]=ce;
}
- p->spoofID(id^d_xor);
-
+ p->d.id=id^d_xor;
+ p->commitD();
char *buffer=const_cast<char *>(p->getRaw());
int len=p->len;
if(send(d_sock,buffer,len,0)<0) { // zoom
if(!packet->d.rd && (PC.get(packet.get(), cached.get()))) { // short circuit - does the PacketCache recognize this question?
cached->setRemote(&packet->remote);
- cached->spoofID(packet->d.id);
+ cached->d.id=packet->d.id;
+ cached->d.rd=packet->d.rd; // copy in recursion desired bit
+ cached->commitD(); // commit d to the packet inlined
+
sendPacket(cached, fd);
S.inc("tcp-answers");
continue;