From efb6667488daba105941610b8ec63935c9831c2e Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Fri, 17 Sep 2004 23:31:56 +0000 Subject: [PATCH] debugcode --- Makefile | 2 +- decpcap.c | 17 +++++++++++++++++ nethogs.h | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a694067..2d8d3cd 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ connection.o: connection.cpp connection.h nethogs.h hashtbl.o: hashtbl.cpp hashtbl.h nethogs.h $(GCC) $(CFLAGS) -c hashtbl.cpp decpcap.o: decpcap.c decpcap.h - gcc $(CFLAGS) -c decpcap.c + gcc-3.3 $(CFLAGS) -c decpcap.c cui.o: cui.cpp cui.h nethogs.h $(GCC) $(CFLAGS) -c cui.cpp -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\" diff --git a/decpcap.c b/decpcap.c index 21edbf0..4ec911a 100644 --- a/decpcap.c +++ b/decpcap.c @@ -30,6 +30,19 @@ struct dp_handle * dp_open_live(char * device, int snaplen, int promisc, int to_ retval->linktype = pcap_datalink(retval->pcap_handle); + switch (retval->linktype) { + case (DLT_EN10MB): + std::cout << 'Ethernet link detected\n"; + break; + case (DLT_PPP): + std::cout << 'PPP link detected\n"; + break; + default: + std::cout << 'No PPP or Ethernet link: " << retval->linktype << std::endl; + // TODO maybe error? or 'other' callback? + break; + } + return retval; } @@ -76,6 +89,7 @@ void dp_parse_ip (struct dp_handle * handle, const dp_header * header, const u_c break; default: // TODO + break; } } @@ -98,6 +112,7 @@ void dp_parse_ip6 (struct dp_handle * handle, const dp_header * header, const u_ break; default: // TODO + break; } } @@ -128,6 +143,7 @@ void dp_parse_ethernet (struct dp_handle * handle, const dp_header * header, con break; default: // TODO + break; } } @@ -173,6 +189,7 @@ void dp_parse_ppp (struct dp_handle * handle, const dp_header * header, const u_ break; default: // TODO + break; } } diff --git a/nethogs.h b/nethogs.h index cd27223..ac0bd62 100644 --- a/nethogs.h +++ b/nethogs.h @@ -30,7 +30,7 @@ #define NEEDROOT 1 #endif -#define DEBUG 0 +#define DEBUG 1 // if '0', do extra checks and // assertions. good for finding bugs