]> granicus.if.org Git - pdns/commitdiff
do process single packet pcaps
authorBert Hubert <bert.hubert@netherlabs.nl>
Thu, 15 Nov 2012 09:32:03 +0000 (09:32 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Thu, 15 Nov 2012 09:32:03 +0000 (09:32 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2895 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/dnsreplay.cc

index 3fd049026cc8b216545244b4f31c4ad7798d373f..a9ac6a64eddb6a3665433af2805502f09a003938 100644 (file)
@@ -479,11 +479,8 @@ bool g_rdSelector;
 
 bool sendPacketFromPR(PcapPacketReader& pr, const ComboAddress& remote)
 {
-  //  static struct timeval lastsent;
-
   dnsheader* dh=(dnsheader*)pr.d_payload;
   bool sent=false;
-  //                                                             non-recursive  
   if((ntohs(pr.d_udp->uh_dport)!=53 && ntohs(pr.d_udp->uh_sport)!=53) || dh->rd != g_rdSelector || (unsigned int)pr.d_len <= sizeof(dnsheader))
     return sent;
 
@@ -624,7 +621,7 @@ try
   struct timeval mental_time;
   mental_time.tv_sec=0; mental_time.tv_usec=0;
 
-  if(!pr.getUDPPacket())
+  if(!pr.getUDPPacket()) // we do this here so we error out more cleanly on no packets
     return 0;
   unsigned int count=0;
 
@@ -635,10 +632,11 @@ try
     struct timeval packet_ts;
     packet_ts.tv_sec = 0; 
     packet_ts.tv_usec = 0; 
+    bool first = true;
     while(packet_ts < mental_time) {
-      if(!pr.getUDPPacket())
+      if(!first && !pr.getUDPPacket()) // otherwise we miss the first packet
         goto out;
-      
+      first=false;
       packet_ts.tv_sec = pr.d_pheader.ts.tv_sec;
       packet_ts.tv_usec = pr.d_pheader.ts.tv_usec;