X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=iftop.c;h=f887d93316b7c0c7c050fac7ac192ed7c09721d9;hb=93280d4777ec65285ff263a4820956244fcd0004;hp=a090dcf84a18e63b7b4f74f9a1e6c6268753d7e2;hpb=ee672060787e3f7023ff0d99f9c546a034bd89bf;p=iftop.git diff --git a/iftop.c b/iftop.c index a090dcf..f887d93 100644 --- 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 */