diff options
-rw-r--r-- | include/dns.h | 1 | ||||
-rw-r--r-- | src/dns.cpp | 9 |
2 files changed, 6 insertions, 4 deletions
diff --git a/include/dns.h b/include/dns.h index 9d5906d3b..834f401ae 100644 --- a/include/dns.h +++ b/include/dns.h @@ -164,6 +164,7 @@ class DNS : public Extensible requestlist requests; insp_inaddr myserver; static int MasterSocket; + int currid; Resolver* Classes[MAX_REQUEST_ID]; int MakePayload(const char* name, const QueryType rr, const unsigned short rr_class, unsigned char* payload); diff --git a/src/dns.cpp b/src/dns.cpp index 425c124c4..652bd9838 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -202,7 +202,9 @@ int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryTyp /* Add a query with a predefined header, and allocate an ID for it. */ DNSRequest* DNS::AddQuery(DNSHeader *header, int &id) { - id = rand() % 65536; + id = this->currid++; + this->currid &= 0xFFFF; + DNSRequest* req = new DNSRequest(this->myserver); header->id[0] = req->id[0] = id >> 8; @@ -234,10 +236,9 @@ DNS::DNS() /* Clear the Resolver class table */ memset(Classes,0,sizeof(Classes)); - /* Seed random number generator, we use this to generate - * dns packet id's + /* Set the id of the next request to 0 */ - srand((unsigned int)time(NULL)); + currid = 0; /* Clear the namesever address */ memset(&myserver,0,sizeof(insp_inaddr)); |