]> gitweb.fperrin.net Git - iftop.git/blobdiff - iftop.c
Do traffic accounting in pps
[iftop.git] / iftop.c
diff --git a/iftop.c b/iftop.c
index a090dcf84a18e63b7b4f74f9a1e6c6268753d7e2..f887d93316b7c0c7c050fac7ac192ed7c09721d9 100644 (file)
--- a/iftop.c
+++ b/iftop.c
@@ -431,14 +431,22 @@ static void handle_ip_packet(struct ip* iptr, int hw_dir)
     }
 
     /* Do accounting. */
-    switch (IP_V(iptr)) {
-      case 4:
-          len = ntohs(iptr->ip_len);
-          break;
-      case 6:
-          len = ntohs(ip6tr->ip6_plen) + 40;
-      default:
-          break;
+    switch (options.bandwidth_unit) {
+      case OPTION_BW_BITS:
+      case OPTION_BW_BYTES:
+         switch (IP_V(iptr)) {
+           case 4:
+               len = ntohs(iptr->ip_len);
+               break;
+           case 6:
+               len = ntohs(ip6tr->ip6_plen) + 40;
+           default:
+               break;
+         }
+         break;
+      case OPTION_BW_PKTS:
+         len = 1;
+         break;
     }
 
     /* Update record */