Commit 3a4088bc authored by pdw's avatar pdw
Browse files

Added support for Linux cooked sockets.

Updated CHANGES file
0.6
parent 3acd6b39
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
......
......@@ -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
......
......@@ -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"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment