diff options
author | pdw <> | 2010-03-01 22:10:09 +0000 |
---|---|---|
committer | pdw <> | 2010-03-01 22:10:09 +0000 |
commit | cc31a604f302b58723f29ff74df3ef9ae7a75629 (patch) | |
tree | c4d641037ca38b0973dad54cac5ed5a7927e8a9f /iftop.c | |
parent | 06a6479ca24351d247720880daad6f4d304fc835 (diff) | |
download | iftop-cc31a604f302b58723f29ff74df3ef9ae7a75629.zip |
Applied patch from Richard Tóth <risko@iklub.sk> to support PFLOG interfaces.
Diffstat (limited to 'iftop.c')
-rw-r--r-- | iftop.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -19,6 +19,7 @@ #include <sys/ioctl.h> #include <sys/socket.h> #include <net/if.h> +#include <net/bpf.h> #include <pthread.h> #include <curses.h> @@ -301,6 +302,19 @@ static void handle_raw_packet(unsigned char* args, const struct pcap_pkthdr* pkt handle_ip_packet((struct ip*)packet, -1); } +static void handle_pflog_packet(unsigned char* args, const struct pcap_pkthdr* pkthdr, const unsigned char* packet) +{ + register u_int length = pkthdr->len; + u_int hdrlen; + const struct pfloghdr *hdr; + + hdr = (struct pfloghdr *)packet; + hdrlen = BPF_WORDALIGN(hdr->length); + length -= hdrlen; + packet += hdrlen; + handle_ip_packet((struct ip*)packet, length); +} + static void handle_llc_packet(const struct llc* llc, int dir) { struct ip* ip = (struct ip*)((void*)llc + sizeof(struct llc)); @@ -519,6 +533,9 @@ void packet_init() { if(dlt == DLT_EN10MB) { packet_handler = handle_eth_packet; } + else if (dlt == DLT_PFLOG) { + packet_handler = handle_pflog_packet; + } else if(dlt == DLT_RAW || dlt == DLT_NULL) { packet_handler = handle_raw_packet; } |