[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/network/ksniffer
From:       Giovanni Venturi <gventuri73 () tiscali ! it>
Date:       2008-03-10 23:04:48
Message-ID: 1205190288.014234.15178.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 784335 by gianni:

some notes around

 M  +7 -3      ksniffer.cpp  
 M  +1 -1      sniffer.cpp  


--- trunk/playground/network/ksniffer/ksniffer.cpp #784334:784335
@@ -898,7 +898,7 @@
 // with this member we stop packets capture
 void KSniffer::slotStop()
 {
-/*  if (!m_loadFromFile)
+  if (!m_loadFromFile)
   {
     if (m_sniffProcess->normalExit())
     {
@@ -907,7 +907,7 @@
         KMessageBox::error( this, i18n("<p>A network error occurred.<br>Cannot \
continue capturing packets.</p>"));  }
     }
-  }*/
+  }
   stopSniffing();
 
   // reset continue sniffing variable
@@ -1015,12 +1015,14 @@
   {
     if (m_sniffProcess)
     {
+      //FIXME: hey but if 'ksniff' stopped by itself you don't need to kill and wait
       m_sniffProcess->kill();
       m_sniffProcess->wait();
       delete m_sniffProcess;
       m_sniffProcess = NULL;
     }
 
+    //FIXME: hey but if 'ksniff' stopped by itself you don't need to waitingToStop
     // the QThread has to be ready to stop: just a small delay
     // to be sure to read all captured packets from the tmp file
     m_sniffer->waitingToStop();
@@ -1031,7 +1033,9 @@
   if ( (!m_mustShowPacketsNow) && (m_sniffer->countPackets() > 0) )
   {
     // check just if you have to display packets after you stopped the capture
-    // and if you captured at least 1 packet (just in this case the thread starts)
+    // and if you captured at least 1 packet (just in this case you have to wait
+    // the exactly end of the thread, because you'll need to start a new Sniffer
+    // thread to read the captured packets as soon as)
     while (m_sniffer->running())
       usleep(1000);
   }
--- trunk/playground/network/ksniffer/sniffer.cpp #784334:784335
@@ -169,7 +169,6 @@
 void Sniffer::startSniffingFromFile()
 {
   // set all parameters to prepare sniffing structures
-  //struct bpf_program bpfp;
   char errbuf[PCAP_ERRBUF_SIZE];
 
 #ifdef MUST_DO_SELECT
@@ -188,6 +187,7 @@
     pcap_close( m_pcapfp );
     return;
   }
+
 #ifdef MUST_DO_SELECT
 
 #ifdef HAVE_PCAP_GET_SELECTABLE_FD


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic