Package: ntop
Version: 2:3.0-5
Severity: minor

When browsing to Local IP -> Active TCP Sessions, the numbers of pages are 
shown in a wrong way.
In the pages are shown only ACTIVE and established connections but the total 
number includes connections wich are not shown.
The folowing patch should fix this problem.

-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.6.8
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)

Versions of packages ntop depends on:
ii  debconf               1.4.30.13          Debian configuration management sy
ii  libc6                 2.3.2.ds1-22sarge3 GNU C Library: Shared libraries an
ii  libgd1-noxpm          1.8.4.debian-1     GD Graphics Library (old version,
ii  libgdbm3              1.8.3-2            GNU dbm database routines (runtime
ii  libgdome2-0           0.8.1-1            DOM level2 library for accessing X
ii  libglib1.2            1.2.10-9           The GLib library of C routines
ii  libglib2.0-0          2.6.4-1            The GLib library of C routines
ii  libpcap0.7            0.7.2-7            System interface for user-level pa
ii  libpng12-0            1.2.8rel-1         PNG library - runtime
ii  libssl0.9.7           0.9.7e-3sarge1     SSL shared libraries
ii  libxml2               2.6.16-7           GNOME XML library
ii  zlib1g                1:1.2.2-4.sarge.2  compression library - runtime

-- debconf information:
* ntop/user: ntop
* ntop/interfaces: eth0,eth1,eth2,eth3,eth4
--- ntop-3.0.orig/report.c      2004-03-18 12:22:32.000000000 +0200
+++ ntop-3.0/report.c   2006-04-20 15:06:28.635032600 +0300
@@ -2892,8 +2892,8 @@
 void printActiveTCPSessions(int actualDeviceId, int pageNum, HostTraffic *el) {
   int idx;
   char buf[LEN_GENERAL_WORK_BUFFER], hostLinkBuf[LEN_GENERAL_WORK_BUFFER],
-  int numSessions, printedSessions;
+  int numSessions, printedSessions, processSessions, nonprintedSessions, fakeSessions;
   char formatBuf[32], formatBuf1[32], formatBuf2[32], formatBuf3[32],
     formatBuf4[32], formatBuf5[32], formatBuf6[32];

@@ -2927,6 +2927,7 @@
       IPSession *session = myGlobals.device[myGlobals.actualReportDeviceId].tcpSession[idx];

       while((session != NULL) && (printedSessions < myGlobals.maxNumLines)) {
+       processSessions++;
 #ifndef PARM_PRINT_ALL_SESSIONS
        if(session->sessionState != FLAG_STATE_ACTIVE) {
          session = session->next;
@@ -3021,11 +3022,77 @@
                    , getSessionState(session)
 #endif
                    ) < 0) BufferTooShort();
-
        sendString(buf);
        session = session->next;
        printedSessions++;
       }
+      while((session != NULL) && (printedSessions >= myGlobals.maxNumLines)) {
+        processSessions++;
+#ifndef PARM_PRINT_ALL_SESSIONS
+        if(session->sessionState != FLAG_STATE_ACTIVE) {
+          session = session->next;
+          continue;
+        }
+#endif
+
+        if(el && (session->initiator  != el) && (session->remotePeer != el)) {
+          session = session->next;
+          continue;
+        }
+
+        if((numSessions++) < pageNum*myGlobals.maxNumLines) {
+          session = session->next;
+          continue;
+        }
+
+        if(printedSessions == 0) {
+          printH"TABLE_ON"<TABLE BORDER=1 "TABLE_DEFAULTS"><TR "TR_ON" "DARK_BG">"
+                     "<TH "TH_BG">Client</TH>"
+                     "<TH "TH_BG">Server</TH>"
+                     "<TH "TH_BG">Data&nbsp;Sent</TH>"
+                     "<TH "TH_BG">Data&nbsp;Rcvd</TH>"
+                     "<TH "TH_BG">Active&nbsp;Since</TH>"
+                     "<TH "TH_BG">Last&nbsp;Seen</TH>"
+                     "<TH "TH_BG">Duration</TH>"
+                     "<TH "TH_BG">Inactive</TH>"
+                     "<TH "TH_BG">Latency</TH>"
+#ifdef PARM_PRINT_ALL_SESSIONS
+                     "<TH "TH_BG">State</TH>"
+#endif
+                     "</TR>\n");
+        }
+
+        sport = getPortByNum(session->sport, IPPROTO_TCP);
+        dport = getPortByNum(session->dport, IPPROTO_TCP);
+        dataSent = session->bytesSent.value;
+        dataRcvd = session->bytesRcvd.value;
+
+        if(sport == NULL) {
+          static char _sport[8];
+          if(snprintf(_sport, 8, "%d", session->sport) < 0)
+            BufferTooShort();
+          sport = _sport;
+        }
+
+        if(dport == NULL) {
+          static char _dport[8];
+          if(snprintf(_dport, 8, "%d", session->dport) < 0)
+            BufferTooShort();
+          dport = _dport;
+        }
+
+        /* Sanity check */
+        if((myGlobals.actTime < session->firstSeen)
+           || (session->firstSeen == 0))
+          session->firstSeen = myGlobals.actTime;
+        if((myGlobals.actTime < session->lastSeen)
+           || (session->lastSeen == 0))
+          session->lastSeen = myGlobals.actTime;
+        session = session->next;
+        nonprintedSessions++;
+      }
     }
 #ifdef CFG_MULTITHREADED
     releaseMutex(&myGlobals.tcpSessionsMutex);
@@ -3035,11 +3102,14 @@
   if(printedSessions > 0) {
     sendString("</TABLE>"TABLE_OFF"<P>\n");
     sendString("</CENTER>\n");
-
+    nonprintedSessions = nonprintedSessions + pageNum * myGlobals.maxNumLines;
+    fakeSessions = processSessions - printedSessions - nonprintedSessions;
+    // snprintf(buf,sizeof(buf),"Afisate: %d/ Neafisate: %d/False: %d/Total: %d\n", printedSessions, nonprintedSessions, fakeSessions, myGlobals.device[actualDeviceId].numTcpSessions);
+    // sendString(buf);
     if(el == NULL)
       addPageIndicator(CONST_ACTIVE_TCP_SESSIONS_HTML, pageNum,
-                      myGlobals.device[actualDeviceId].numTcpSessions,
-                      myGlobals.maxNumLines, -1, 0);
+                       myGlobals.device[actualDeviceId].numTcpSessions - fakeSessions,
+                       myGlobals.maxNumLines, -1, 0);

     printHostColorCode(FALSE, 0);

Reply via email to