From: Vadim Kochan <[email protected]>

Count flows which might be showed and show this number
on the top status line.

Signed-off-by: Vadim Kochan <[email protected]>
---
 flowtop.c | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/flowtop.c b/flowtop.c
index c1c6f52..866a062 100644
--- a/flowtop.c
+++ b/flowtop.c
@@ -893,6 +893,8 @@ static inline int presenter_flow_wrong_state(struct 
flow_entry *n)
 static void presenter_screen_update(WINDOW *screen, struct flow_list *fl,
                                    int skip_lines)
 {
+       int skip_left = skip_lines;
+       unsigned int flows = 0;
        unsigned int line = 3;
        struct flow_entry *n;
        int maxy;
@@ -911,15 +913,6 @@ static void presenter_screen_update(WINDOW *screen, struct 
flow_list *fl,
        wclear(screen);
        clear();
 
-       mvwprintw(screen, 1, 2, "Kernel netfilter flows for %s%s%s%s%s%s"
-                 "[+%d]", what & INCLUDE_TCP ? "TCP, " : "" ,
-                 what & INCLUDE_UDP ? "UDP, " : "",
-                 what & INCLUDE_SCTP ? "SCTP, " : "",
-                 what & INCLUDE_DCCP ? "DCCP, " : "",
-                 what & INCLUDE_ICMP && what & INCLUDE_IPV4 ? "ICMP, " : "",
-                 what & INCLUDE_ICMP && what & INCLUDE_IPV6 ? "ICMP6, " : "",
-                 skip_lines);
-
        rcu_read_lock();
 
        n = rcu_dereference(fl->head);
@@ -928,18 +921,20 @@ static void presenter_screen_update(WINDOW *screen, 
struct flow_list *fl,
                                "Is netfilter running?)");
 
        for (; n; n = rcu_dereference(n->next)) {
-
-               if (maxy <= 0)
-                       goto skip;
-
                if (presenter_get_port(n->port_src, n->port_dst, 0) == 53)
                        goto skip;
 
                if (presenter_flow_wrong_state(n))
                        goto skip;
 
-               if (skip_lines > 0) {
-                       skip_lines--;
+               /* count only flows which might be showed */
+               flows++;
+
+               if (maxy <= 0)
+                       goto skip;
+
+               if (skip_left > 0) {
+                       skip_left--;
                        goto skip;
                }
 
@@ -954,6 +949,15 @@ skip:
                continue;
        }
 
+       mvwprintw(screen, 1, 2, "Kernel netfilter flows(%u) for %s%s%s%s%s%s"
+                 "[+%d]", flows, what & INCLUDE_TCP ? "TCP, " : "" ,
+                 what & INCLUDE_UDP ? "UDP, " : "",
+                 what & INCLUDE_SCTP ? "SCTP, " : "",
+                 what & INCLUDE_DCCP ? "DCCP, " : "",
+                 what & INCLUDE_ICMP && what & INCLUDE_IPV4 ? "ICMP, " : "",
+                 what & INCLUDE_ICMP && what & INCLUDE_IPV6 ? "ICMP6, " : "",
+                 skip_lines);
+
        rcu_read_unlock();
 
        wrefresh(screen);
-- 
2.4.2

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to