Fixed dependency handling.

Added cumulative totals.
Added option to turn bars on/off.
This commit is contained in:
pdw
2002-04-01 19:46:20 +00:00
parent a248b6046e
commit bb3619b3fc
6 changed files with 73 additions and 59 deletions

11
iftop.c
View File

@@ -121,6 +121,7 @@ static void handle_packet(char* args, const struct pcap_pkthdr* pkthdr,const cha
struct ip* iptr;
history_type* ht;
addr_pair ap;
int len;
iptr = (struct ip*)(packet + sizeof(struct ether_header)); /* alignment? */
if(options.netfilter == 0) {
@@ -181,21 +182,27 @@ static void handle_packet(char* args, const struct pcap_pkthdr* pkthdr,const cha
hash_insert(history, &ap, ht);
}
len = ntohs(iptr->ip_len);
/* Update record */
ht->last_write = history_pos;
if(iptr->ip_src.s_addr == ap.src.s_addr) {
ht->sent[history_pos] += ntohs(iptr->ip_len);
ht->sent[history_pos] += len;
ht->total_sent += len;
}
else {
ht->recv[history_pos] += ntohs(iptr->ip_len);
ht->recv[history_pos] += len;
ht->total_recv += len;
}
if(direction == 0) {
/* incoming */
history_totals.recv[history_pos] += ntohs(iptr->ip_len);
history_totals.total_recv += len;
}
else {
history_totals.sent[history_pos] += ntohs(iptr->ip_len);
history_totals.total_sent += len;
}
}