]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
massively improve dnsreplay performance
authorBert Hubert <bert.hubert@netherlabs.nl>
Sun, 14 Aug 2005 20:14:13 +0000 (20:14 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sun, 14 Aug 2005 20:14:13 +0000 (20:14 +0000)
fix timeout logic
make sure it compiles w/o threads

git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@459 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/Makefile.am
pdns/anadns.hh
pdns/dnsparser.cc
pdns/dnsparser.hh
pdns/dnsreplay.cc
pdns/misc.cc
pdns/misc.hh

index b879a387505d90a63ae9778b46b98cddc9abb53c..1676618169fcd5be2cb0fbe1d2aaa7481f20bf8c 100644 (file)
@@ -16,9 +16,9 @@ else
 sbin_PROGRAMS = pdns_server 
 endif
 
-bin_PROGRAMS = pdns_control  
+bin_PROGRAMS = pdns_control  dnswasher dnsreplay
 
-EXTRA_PROGRAMS=pdns_recursor sdig pdns_control qgen dnswasher dnsscope dnsreplay
+EXTRA_PROGRAMS=pdns_recursor sdig pdns_control qgen dnsscope 
 
 pdns_server_SOURCES=dnspacket.cc nameserver.cc tcpreceiver.hh \
 qtype.cc logger.cc arguments.cc packethandler.cc tcpreceiver.cc \
@@ -55,10 +55,12 @@ dnswasher_SOURCES=dnswasher.cc misc.cc unix_utility.cc qtype.cc \
 
 dnswasher_LDFLAGS= @THREADFLAGS@ @DYNLINKFLAGS@ 
 
-dnsreplay_SOURCES=dnsreplay.cc misc.cc unix_utility.cc qtype.cc anadns.hh \
+# unix_utility.cc
+
+dnsreplay_SOURCES=dnsreplay.cc misc.cc  qtype.cc anadns.hh \
        logger.cc statbag.cc  dnspcap.cc dnspcap.hh dnsparser.cc dnsrecords.cc dnsparser.hh 
 
-dnsreplay_LDFLAGS= @THREADFLAGS@ @DYNLINKFLAGS@ 
+dnsreplay_LDFLAGS= @DYNLINKFLAGS@ 
 
 
 dnsscope_SOURCES=dnsscope.cc misc.cc unix_utility.cc qtype.cc \
@@ -85,4 +87,3 @@ pdns_control_LDFLAGS=@THREADFLAGS@
 # binpatch_SOURCES=binpatch.cc 
 
 SUBDIRS= backends .
-
index 4277e36b078299f2b61bab00832d0052456c1a05..294e626075289bae13550e12d48a3c9cf2427a77 100644 (file)
@@ -52,7 +52,6 @@ struct QuestionIdentifier
     return ret;
   }
 
-
   uint32_t d_sourceip;
   uint32_t d_destip;
   uint16_t d_sourceport;
@@ -61,8 +60,6 @@ struct QuestionIdentifier
   string d_qname;
   uint16_t d_qtype;
   uint16_t d_id;
-
-
 };
 
 inline ostream& operator<<(ostream &s, const QuestionIdentifier& qi) 
index 65b31c11c7826765be241718ad62f70891ce77df..eb0ea832434501f6e9162bcda715dbaee83d7e05 100644 (file)
@@ -194,37 +194,36 @@ u_int8_t PacketReader::get8BitInt()
 
 string PacketReader::getLabel(unsigned int recurs)
 {
-  return getLabelFromContent(d_content, d_pos, recurs++);
+  string ret;
+  ret.reserve(40);
+  getLabelFromContent(d_content, d_pos, ret, recurs++);
+  return ret;
 }
 
 
-string PacketReader::getLabelFromContent(const vector<u_int8_t>& content, u_int16_t& frompos, int recurs) 
+void PacketReader::getLabelFromContent(const vector<u_int8_t>& content, u_int16_t& frompos, string& ret, int recurs) 
 {
   if(recurs > 10)
     throw MOADNSException("Loop");
-  
-  string ret;
+
   for(;;) {
     unsigned char labellen=content.at(frompos++);
-    
+
     // cout<<"Labellen: "<<(int)labellen<<endl;
     if(!labellen) {
       if(ret.empty())
-       ret+=".";
+       ret.append(1,'.');
       break;
     }
     if((labellen & 0xc0) == 0xc0) {
       u_int16_t offset=256*(labellen & ~0xc0) + (unsigned int)content.at(frompos++) - sizeof(dnsheader);
       //       cout<<"This is an offset, need to go to: "<<offset<<endl;
-      return ret+getLabelFromContent(content, offset, ++recurs);
+      return getLabelFromContent(content, offset, ret, ++recurs);
     }
     else {
-      for(int n=0;n<labellen;++n) {
-       ret+=content.at(frompos++);
-      }
-      ret+=".";
+      ret.append(&content.at(frompos), &content.at(frompos+labellen));
+      frompos+=labellen;
+      ret.append(1,'.');
     }
   }
-  
-  return ret;
 }
index c310b15a7aea511374a183abcd6c0d315ea07e1e..ff390947edc27fb8ed146133742863413fe432df 100644 (file)
@@ -44,7 +44,7 @@ public:
   u_int32_t get32BitInt();
   u_int16_t get16BitInt();
   static u_int16_t get16BitInt(const vector<unsigned char>&content, u_int16_t& pos);
-  static string getLabelFromContent(const vector<u_int8_t>& content, u_int16_t& frompos, int recurs);
+  static void getLabelFromContent(const vector<u_int8_t>& content, u_int16_t& frompos, string& ret, int recurs);
   u_int8_t get8BitInt();
   void getDnsrecordheader(struct dnsrecordheader &ah);
   void copyRecord(vector<unsigned char>& dest, u_int16_t len);
index 704bb75ea042db855e8719a89bb705dc56aa7ec0..e4cf19a20006bcf31686c4cb6f79c6a670471f97 100644 (file)
@@ -73,19 +73,25 @@ private:
 
 struct QuestionData
 {
-  QuestionData() : d_assignedID(-1), d_origRcode(-1), d_newRcode(-1), d_norecursionavailable(false)
-  {}
+  QuestionData() : d_assignedID(-1), d_origRcode(-1), d_newRcode(-1), d_norecursionavailable(false), d_origlate(false), d_newlate(false)
+  {
+  }
   int d_assignedID;
   MOADNSParser::answers_t d_origAnswers, d_newAnswers;
   int d_origRcode, d_newRcode;
   struct timeval d_resentTime;
   bool d_norecursionavailable;
+  bool d_origlate, d_newlate;
 };
 
-typedef map<QuestionIdentifier, QuestionData> qids_t;
+typedef map<QuestionIdentifier, shared_ptr<QuestionData> > qids_t;
 qids_t qids;
 
-unsigned int s_questions, s_answers, s_timedout, s_perfect, s_mostly, s_nooriginalanswer;
+typedef map<uint16_t, struct QuestionIdentifier > id2qi_t;
+id2qi_t id2qi;
+
+unsigned int s_questions, s_answers, s_wetimedout, s_perfect, s_mostly, s_origtimedout;
+unsigned int s_wenever, s_orignever;
 unsigned int s_webetter, s_origbetter, s_norecursionavailable;
 unsigned int s_weunmatched, s_origunmatched;
 unsigned int s_wednserrors, s_origdnserrors;
@@ -104,45 +110,34 @@ double DiffTime(const struct timeval& first, const struct timeval& second)
 }
 
 
-pair<unsigned int, unsigned int> WeOrigSlowQueries()
+pair<unsigned int, unsigned int> WeOrigSlowQueriesDelta()
 {
   struct timeval now;
   gettimeofday(&now, 0);
 
   pair<unsigned int, unsigned int> ret=make_pair(0,0);
   for(qids_t::iterator i=qids.begin(); i!=qids.end(); ++i) {
-    double dt=DiffTime(i->second.d_resentTime, now);
-    if(dt > 2) {
-      if(i->second.d_newRcode == -1)
+    double dt=DiffTime(i->second->d_resentTime, now);
+    if(dt > 2.0) {
+      if(i->second->d_newRcode == -1) {
+       if(!i->second->d_newlate) {
+         i->second->d_newlate=true;
+         s_wetimedout++;
+       }
        ret.first++;
-      else
+      }
+      if(i->second->d_origRcode == -1) {
+       if(!i->second->d_origlate) {
+         i->second->d_origlate=true;
+         s_origtimedout++;
+       }
        ret.second++;
+      }
     }
   }
   return ret;
 }
 
-void pruneQids()
-{
-  struct timeval now;
-  gettimeofday(&now, 0);
-
-  for(qids_t::iterator i=qids.begin(); i!=qids.end(); ) {
-    if(now.tv_sec < i->second.d_resentTime.tv_sec + 4 || (now.tv_sec == i->second.d_resentTime.tv_sec &&  now.tv_usec < i->second.d_resentTime.tv_usec)) 
-      ++i;
-    else {
-      //      s_idmanager.releaseID(i->second.d_assignedID);
-      if(i->second.d_newRcode==-1)
-       s_timedout++;
-      else if(i->second.d_origRcode==-1)
-       s_nooriginalanswer++;
-      else
-       cerr<<"Impossible - finished QI in the pool"<<endl;
-      qids.erase(i++);
-    }
-  }
-}
-
 void compactAnswerSet(MOADNSParser::answers_t orig, set<DNSRecord>& compacted)
 {
   for(MOADNSParser::answers_t::const_iterator i=orig.begin(); i != orig.end(); ++i)
@@ -159,7 +154,7 @@ set<pair<string,uint16_t> > s_origbetterset;
 
 void measureResultAndClean(const QuestionIdentifier& qi)
 {
-  QuestionData qd=qids[qi];
+  QuestionData qd=*qids[qi];
 
   set<DNSRecord> canonicOrig, canonicNew;
   compactAnswerSet(qd.d_origAnswers, canonicOrig);
@@ -210,6 +205,7 @@ void measureResultAndClean(const QuestionIdentifier& qi)
       cout<<"\n";
     }
   }
+  
 
   qids.erase(qi);
   s_idmanager.releaseID(qd.d_assignedID);
@@ -218,45 +214,36 @@ void measureResultAndClean(const QuestionIdentifier& qi)
 
 Socket *s_socket;
 
-static pthread_mutex_t s_lock=PTHREAD_MUTEX_INITIALIZER;
-
-void* incomingThread(void*)
+void receiveFromReference()
 try
 {
   string packet;
   IPEndpoint remote;
 
-  for(;;) {
-    s_socket->recvFrom(packet, remote);
+  while(s_socket->recvFromAsync(packet, remote)) {
     try {
       MOADNSParser mdp(packet.c_str(), packet.length());
       if(!mdp.d_header.qr) {
        cout<<"Received a question from our reference nameserver!"<<endl;
        continue;
       }
-      
-      Lock l(&s_lock);
-      
-      qids_t::iterator i=qids.begin();
-      for(; i!=qids.end(); ++i)
-       if(i->second.d_assignedID == ntohs(mdp.d_header.id))
-         break;
-      
-      if(i==qids.end()) {
-       cout<<"Received an answer from reference nameserver with id "<<mdp.d_header.id<<" which we can't match to a question!"<<endl;
+
+      id2qi_t::iterator found=id2qi.find(ntohs(mdp.d_header.id));
+      if(found==id2qi.end()) {
+       cout<<"Received an answer ("<<mdp.d_qname<<") from reference nameserver with id "<<mdp.d_header.id<<" which we can't match to a question!"<<endl;
        s_weunmatched++;
        continue;
       }
+      QuestionIdentifier qi=found->second;
+      QuestionData& qd=*qids[qi];
       
-      //    cout<<"Matched answer from reference to a question we asked"<<endl;
-      
-      QuestionData& qd=i->second;
-      
+
       qd.d_newAnswers=mdp.d_answers;
       qd.d_newRcode=mdp.d_header.rcode;
       if(qd.d_origRcode!=-1) {
        //      cout<<"Removing entry "<<i->first<<", is done [in socket]"<<endl;
-       measureResultAndClean(i->first);
+       id2qi.erase(found);
+       measureResultAndClean(qi);
       }
     }
     catch(MOADNSException &e)
@@ -280,148 +267,184 @@ catch(...)
   exit(1);
 }
 
-int main(int argc, char** argv)
-try
+void pruneQids()
 {
-  if(argc < 2 || argc > 4) {
-    cerr<<"dnsreplay - replay DNS traffic to a reference server to compare performance"<<endl;
-    cerr<<"Syntax: dnsreplay pcapfile [target IP] [target port]\nDefaults to 127.0.0.1 and 5300"<<endl;
-    return EXIT_FAILURE;
+  struct timeval now;
+  gettimeofday(&now, 0);
+
+  for(qids_t::iterator i=qids.begin(); i!=qids.end(); ) {
+    if(DiffTime(i->second->d_resentTime, now) < 60)
+      ++i;
+    else {
+      s_idmanager.releaseID(i->second->d_assignedID);
+      if(i->second->d_newRcode==-1) {
+       s_wenever++;
+      }
+      if(i->second->d_origRcode==-1) {
+       s_orignever++;
+      }
+
+      id2qi.erase(i->second->d_assignedID);
+      qids.erase(i++);
+    }
+  }
+}
+
+
+void houseKeeping()
+{
+  pair<unsigned int, unsigned int> slows=WeOrigSlowQueriesDelta();
+    
+  int waitingFor=qids.size() - slows.first - slows.second;
+  if(waitingFor > 1000) {
+    cerr<<"Too many questions outstanding, waiting 0.25 seconds"<<endl;
+    usleep(250000);
   }
   
-  PcapPacketReader pr(argv[1]);
-  s_socket= new Socket(InterNetwork, Datagram);
+  cerr<<waitingFor<<" queries that could still come in on time, "<<qids.size()<<" outstanding"<<endl;
   
-  pthread_t tid;
-  pthread_create(&tid, 0, incomingThread, 0);
+  cerr<<"we late: "<<s_wetimedout<<", orig late: "<< s_origtimedout<<", "<<s_questions<<" questions sent, "<<s_answers
+      <<" original answers, "<<s_perfect<<" perfect, "<<s_mostly<<" mostly correct"<<", "<<s_webetter<<" we better, "<<s_origbetter<<" orig better ("<<s_origbetterset.size()<<" diff)"<<endl;
+  cerr<<"we never: "<<s_wenever<<", orig never: "<<s_orignever<<endl;
+  cerr<<"original questions from IP addresses for which recursion was not available: "<<s_norecursionavailable<<endl;
+  cerr<<"Unmatched from us: "<<s_weunmatched<<", unmatched from original: "<<s_origunmatched << " ( - decoding err: "<<s_origunmatched-s_origdnserrors<<")"<<endl;
+  cerr<<"DNS decoding errors from us: "<<s_wednserrors<<", from original: "<<s_origdnserrors<<endl<<endl;
 
-  IPEndpoint remote(argc > 2 ? argv[2] : "127.0.0.1", 
-                   argc > 3 ? atoi(argv[3]) : 5300);
-  struct timeval lastsent={0,0};
+  pruneQids();
 
-  unsigned int once=0;
-  for(;;) {
-    if(!pr.getUDPPacket())
-      break;
+}
 
-    if(!((once++)%2000)) {
-      Lock l(&s_lock);
-      pair<unsigned int, unsigned int> slows=WeOrigSlowQueries();
+void sendPacketFromPR(PcapPacketReader& pr, const IPEndpoint& remote)
+{
+  static struct timeval lastsent;
 
-      int waitingFor=qids.size() - slows.first - slows.second;
-      if(waitingFor > 1000) {
-       cerr<<"Too many questions outstanding, waiting 0.25 seconds"<<endl;
-       usleep(250000);
+  HEADER* dh=(HEADER*)pr.d_payload;
+  //                                                             non-recursive  
+  if((ntohs(pr.d_udp->uh_dport)!=53 && ntohs(pr.d_udp->uh_sport)!=53) || !dh->rd || (unsigned int)pr.d_len <= sizeof(HEADER))
+    return;
+  
+  try {
+    MOADNSParser mdp((const char*)pr.d_payload, pr.d_len);
+    QuestionIdentifier qi=QuestionIdentifier::create(pr.d_ip, pr.d_udp, mdp);
+    
+    if(!mdp.d_header.qr) {
+      s_questions++;
+      if(qids.count(qi)) {
+       if(!s_quiet)
+         cout<<"Saw an exact duplicate question, "<<qi<< endl;
+       return;
       }
-               
-      //pruneQids();
-
-      cerr<<waitingFor<<" queries that could still come in on time, "<<qids.size()<<" outstanding"<<endl;
+      
+      // new question!
+      qids[qi]=shared_ptr<QuestionData>(new QuestionData);
+      
+      QuestionData& qd=*qids[qi];
+      gettimeofday(&qd.d_resentTime,0);
+      
+      qd.d_assignedID = s_idmanager.getID();
+      
+      id2qi[qd.d_assignedID]=qi;
 
+      dh->id=htons(qd.d_assignedID);
 
-      cerr<<"we late: "<<slows.first+s_timedout<<", orig late: "<< slows.second + s_nooriginalanswer<<", "<<s_questions<<" questions sent, "<<s_answers
-         <<" original answers, "<<s_perfect<<" perfect, "<<s_mostly<<" mostly correct"<<", "<<s_webetter<<" we better, "<<s_origbetter<<" orig better ("<<s_origbetterset.size()<<" diff)"<<endl;
-      cerr<<"original questions from IP addresses for which recursion was not available: "<<s_norecursionavailable<<endl;
-      cerr<<"Unmatched from us: "<<s_weunmatched<<", unmatched from original: "<<s_origunmatched<<endl;
-      cerr<<"DNS decoding errors from us: "<<s_wednserrors<<", from original: "<<s_origdnserrors<<endl<<endl;
+      if(lastsent.tv_sec && (!(s_questions%25))) {
+       double seconds=pr.d_pheader.ts.tv_sec - lastsent.tv_sec;
+       double useconds=(pr.d_pheader.ts.tv_usec - lastsent.tv_usec);
+       
+       if(useconds < 0) {
+         seconds-=1;
+         useconds+=1000000;
+       }
+       
+       double factor=20;
+       
+       seconds/=factor;
+       useconds/=factor;
+       
+       long long nanoseconds=(long long)(1000000000ULL*seconds + useconds * 1000);
+       
+       struct timespec tosleep;
+       tosleep.tv_sec=nanoseconds/1000000000UL;
+       tosleep.tv_nsec=nanoseconds%1000000000UL;
+       
+       nanosleep(&tosleep, 0);
+       lastsent=pr.d_pheader.ts;
+      }
+      if(!lastsent.tv_sec)
+       lastsent=pr.d_pheader.ts;
+      
+      //       cout<<"sending!"<<endl;
+      s_socket->sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote);
     }
-
-    HEADER* dh=(HEADER*)pr.d_payload;
-    //                                                             non-recursive  
-    if((ntohs(pr.d_udp->uh_dport)!=53 && ntohs(pr.d_udp->uh_sport)!=53) || !dh->rd || (unsigned int)pr.d_len <= sizeof(HEADER))
-      continue;
-    
-    try {
-      MOADNSParser mdp((const char*)pr.d_payload, pr.d_len);
-      QuestionIdentifier qi=QuestionIdentifier::create(pr.d_ip, pr.d_udp, mdp);
+    else {
+      s_answers++;
       
-      if(!mdp.d_header.qr) {
-       s_questions++;
-       { 
-         Lock l(&s_lock);
-         if(qids.count(qi)) {
-           if(!s_quiet)
-             cout<<"Saw an exact duplicate question, "<<qi<< endl;
-           continue;
-         }
-          
-         // new question!
-         QuestionData& qd=qids[qi];
-         gettimeofday(&qd.d_resentTime,0);
-         
-         qd.d_assignedID = s_idmanager.getID();
-
-         dh->id=htons(qd.d_assignedID);
-       }
+      if(qids.count(qi)) {
+       QuestionData& qd=*qids[qi];
 
-       if(lastsent.tv_sec && (!(s_questions%25))) {
-         double seconds=pr.d_pheader.ts.tv_sec - lastsent.tv_sec;
-         double useconds=(pr.d_pheader.ts.tv_usec - lastsent.tv_usec);
-
-         if(useconds < 0) {
-           seconds-=1;
-           useconds+=1000000;
-         }
-
-         double factor=10;
-         
-         seconds/=factor;
-         useconds/=factor;
-         
-         long long nanoseconds=(long long)(1000000000ULL*seconds + useconds * 1000);
-         
-         struct timespec tosleep;
-         tosleep.tv_sec=nanoseconds/1000000000UL;
-         tosleep.tv_nsec=nanoseconds%1000000000UL;
-
-         nanosleep(&tosleep, 0);
-         lastsent=pr.d_pheader.ts;
+       //        cout<<"Matched answer "<<qi<<endl;
+       qd.d_origAnswers=mdp.d_answers;
+       qd.d_origRcode=mdp.d_header.rcode;
+       
+       if(!dh->ra) {
+         s_norecursionavailable++;
+         qd.d_norecursionavailable=true;
        }
-       if(!lastsent.tv_sec)
-         lastsent=pr.d_pheader.ts;
-
-       //      cout<<"sending!"<<endl;
-       s_socket->sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote);
+       
+       if(qd.d_newRcode!=-1) {
+         //        cout<<"Removing entry "<<qi<<", is done [in main loop]"<<endl;
+         id2qi.erase(qd.d_assignedID);
+         measureResultAndClean(qi);
+       }
+       
+       return;
       }
       else {
-       s_answers++;
-       Lock l(&s_lock);
-       if(qids.count(qi)) {
-         QuestionData& qd=qids[qi];
-         //      cout<<"Matched answer "<<qi<<endl;
-         qd.d_origAnswers=mdp.d_answers;
-         qd.d_origRcode=mdp.d_header.rcode;
-
-         if(!dh->ra) {
-           s_norecursionavailable++;
-           qd.d_norecursionavailable=true;
-         }
-
-         if(qd.d_newRcode!=-1) {
-           //      cout<<"Removing entry "<<qi<<", is done [in main loop]"<<endl;
-           measureResultAndClean(qi);
-         }
-
-         
-         continue;
-       }
-       else {
-         s_origunmatched++;
-         if(!s_quiet)
-           cout<<"Unmatched original answer "<<qi<<endl;
-       }
+       s_origunmatched++;
+       if(!s_quiet)
+         cout<<"Unmatched original answer "<<qi<<endl;
       }
     }
-    catch(MOADNSException &e)
-    {
-      s_origdnserrors++;
-    }
-    catch(out_of_range &e)
-    {
-      s_origdnserrors++;
-    }
   }
+  catch(MOADNSException &e)
+  {
+    s_origdnserrors++;
+  }
+  catch(out_of_range &e)
+  {
+    s_origdnserrors++;
+  }
+}
+
+int main(int argc, char** argv)
+try
+{
+  if(argc < 2 || argc > 4) {
+    cerr<<"dnsreplay - replay DNS traffic to a reference server to compare performance"<<endl;
+    cerr<<"Syntax: dnsreplay pcapfile [target IP] [target port]\nDefaults to 127.0.0.1 and 5300"<<endl;
+    return EXIT_FAILURE;
+  }
+  
+  PcapPacketReader pr(argv[1]);
+  s_socket= new Socket(InterNetwork, Datagram);
+
+  s_socket->setNonBlocking();
+  
+  IPEndpoint remote(argc > 2 ? argv[2] : "127.0.0.1", 
+                   argc > 3 ? atoi(argv[3]) : 5300);
 
+
+  unsigned int once=0;
+  for(;;) {
+    if(!((once++)%4000)) 
+      houseKeeping();
+
+    if(!pr.getUDPPacket())
+      break;
+
+    sendPacketFromPR(pr, remote);
+    receiveFromReference();
+  }
 }
 catch(exception& e)
 {
index e07a06bea171edb16cdc5baedafbf9f47f4a91ff..3983c70a1e9c32803531543cd96f5c02e7b279de 100644 (file)
@@ -125,7 +125,7 @@ int sendData(const char *buffer, int replen, int outsock)
   iov[0].iov_len=2;
   iov[1].iov_base=(char*)buffer;
   iov[1].iov_len=replen;
-  int ret=Utility::writev(outsock,iov,2);
+  int ret=writev(outsock,iov,2);
 
   if(ret<0) {
     return -1;
@@ -289,7 +289,7 @@ bool IpToU32(const string &str, u_int32_t *ip)
   }
   
   struct in_addr inp;
-  if(Utility::inet_aton(str.c_str(), &inp)) {
+  if(inet_aton(str.c_str(), &inp)) {
     *ip=inp.s_addr;
     return true;
   }
@@ -307,7 +307,7 @@ const string sockAddrToString(struct sockaddr_in *remote, Utility::socklen_t soc
   else {
     char tmp[128];
     
-    if(!Utility::inet_ntop(AF_INET6, ( const char * ) &((struct sockaddr_in6 *)remote)->sin6_addr, tmp, sizeof(tmp)))
+    if(!inet_ntop(AF_INET6, ( const char * ) &((struct sockaddr_in6 *)remote)->sin6_addr, tmp, sizeof(tmp)))
       return "IPv6 untranslateable";
 
     return tmp;
index 5dc1e961835d252329288bcbd840da31953c66ba..befc7c18649179edca126563952adccc4f25cf9d 100644 (file)
@@ -140,16 +140,17 @@ private:
 const string sockAddrToString(struct sockaddr_in *remote, Utility::socklen_t socklen);
 int sendData(const char *buffer, int replen, int outsock);
 
-
 inline void DTime::set()
 {
-  Utility::gettimeofday(&d_set,0);
+  // Utility::
+  gettimeofday(&d_set,0);
 }
 
 inline int DTime::udiff()
 {
   struct timeval now;
-  Utility::gettimeofday(&now,0);
+  // Utility::
+  gettimeofday(&now,0);
 
   return 1000000*(now.tv_sec-d_set.tv_sec)+(now.tv_usec-d_set.tv_usec);
 }