Some fixes thanks to Bart Mertens (nethogs Debian maintainer)

This commit is contained in:
Arnout Engelen
2008-06-08 21:24:30 +00:00
parent 1c776beb68
commit 384581c9a9
3 changed files with 11 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ Changelog
strings 'const' strings 'const'
- set view mode to 'kbps' by default, - set view mode to 'kbps' by default,
instead of the 'grand total' number of bytes instead of the 'grand total' number of bytes
- some fixes thanks to Bart Martens
27/08/05 (Arnout) 27/08/05 (Arnout)
- giving all unknown connections their own - giving all unknown connections their own

View File

@@ -2,6 +2,7 @@
#include <string> #include <string>
#include <pwd.h> #include <pwd.h>
#include <sys/types.h> #include <sys/types.h>
#include <algorithm>
#include <ncurses.h> #include <ncurses.h>
#include "nethogs.h" #include "nethogs.h"

View File

@@ -338,12 +338,13 @@ int main (int argc, char** argv)
} }
dp_handle * newhandle = dp_open_live(current_dev->name, BUFSIZ, promisc, 100, errbuf); dp_handle * newhandle = dp_open_live(current_dev->name, BUFSIZ, promisc, 100, errbuf);
if (newhandle != NULL)
{
dp_addcb (newhandle, dp_packet_ip, process_ip); dp_addcb (newhandle, dp_packet_ip, process_ip);
dp_addcb (newhandle, dp_packet_ip6, process_ip6); dp_addcb (newhandle, dp_packet_ip6, process_ip6);
dp_addcb (newhandle, dp_packet_tcp, process_tcp); dp_addcb (newhandle, dp_packet_tcp, process_tcp);
dp_addcb (newhandle, dp_packet_udp, process_udp); dp_addcb (newhandle, dp_packet_udp, process_udp);
if (newhandle != NULL)
{
/* The following code solves sf.net bug 1019381, but is only available /* The following code solves sf.net bug 1019381, but is only available
* in newer versions (from 0.8 it seems) of libpcap * in newer versions (from 0.8 it seems) of libpcap
* *
@@ -356,6 +357,10 @@ int main (int argc, char** argv)
} }
handles = new handle (newhandle, current_dev->name, handles); handles = new handle (newhandle, current_dev->name, handles);
} }
else
{
fprintf(stderr, "Error opening handler for device %s\n", current_dev->name);
}
current_dev = current_dev->next; current_dev = current_dev->next;
} }