Added support for Linux cooked sockets.

Updated CHANGES file
0.6
This commit is contained in:
pdw
2002-08-28 22:47:14 +00:00
parent 3acd6b390c
commit 3a4088bc02
3 changed files with 31 additions and 1 deletions

View File

@@ -1,6 +1,12 @@
Change log for iftop
$Id$
0.6 28/08/02
Fixed segfault bug affecting some systems
Added support for Linux cooked sockets
Michael Bergbauer <michael@noname.franken.de>
0.5 26/08/02
Added support for monitoring PPP interfaces

View File

@@ -27,7 +27,7 @@ MANDIR = man
#MANDIR = share/man # FHS-ish
# You shouldn't need to change anything below this point.
VERSION = 0.5
VERSION = 0.6
CFLAGS += -g -Wall "-DIFTOP_VERSION=\"$(VERSION)\""
LDFLAGS += -g
LDLIBS += -lpcap -lpthread -lcurses -lm

24
iftop.c
View File

@@ -22,6 +22,7 @@
#include "resolver.h"
#include "ui.h"
#include "options.h"
#include "sll.h"
unsigned char if_hw_addr[6]; /* ethernet address of interface. */
@@ -214,6 +215,26 @@ static void handle_raw_packet(unsigned char* args, const struct pcap_pkthdr* pkt
handle_ip_packet((struct ip*)packet, -1);
}
static void handle_cooked_packet(unsigned char *args, const struct pcap_pkthdr * thdr, const unsigned char * packet)
{
struct sll_header *sptr;
int dir = -1;
sptr = (struct sll_header *) packet;
switch (ntohs(sptr->sll_pkttype))
{
case LINUX_SLL_HOST:
/*entering this interface*/
dir = 0;
break;
case LINUX_SLL_OUTGOING:
/*leaving this interface */
dir=1;
break;
}
handle_ip_packet((struct ip*)(packet+SLL_HDR_LEN), dir);
}
static void handle_eth_packet(unsigned char* args, const struct pcap_pkthdr* pkthdr, const unsigned char* packet)
{
struct ether_header *eptr;
@@ -290,6 +311,9 @@ void packet_init() {
else if(dlt == DLT_RAW) {
packet_handler = handle_raw_packet;
}
else if(dlt == DLT_LINUX_SLL) {
packet_handler = handle_cooked_packet;
}
else {
fprintf(stderr, "Unsupported datalink type: %d\n"
"Please email pdw@ex-parrot.com, quoting the datalink type and what you were\n"