author | max <max> | 2002-11-23 20:33:08 (UTC) |
---|---|---|
committer | max <max> | 2002-11-23 20:33:08 (UTC) |
commit | f673a2924c8d3495a99e0eba7073a3419dd937bf (patch) (side-by-side diff) | |
tree | fdd5e641fef00d8e087bbec5a741a24ec2f80f62 | |
parent | 2f11392ab9292df21a6e1374800954a6b405ee9b (diff) | |
download | opie-f673a2924c8d3495a99e0eba7073a3419dd937bf.zip opie-f673a2924c8d3495a99e0eba7073a3419dd937bf.tar.gz opie-f673a2924c8d3495a99e0eba7073a3419dd937bf.tar.bz2 |
Sniffer changed to pcap_next
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/sniffer.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/sniffer.cc b/noncore/net/wellenreiter/daemon/source/sniffer.cc index 65c8579..be64d67 100644 --- a/noncore/net/wellenreiter/daemon/source/sniffer.cc +++ b/noncore/net/wellenreiter/daemon/source/sniffer.cc @@ -23,19 +23,30 @@ int main(void) int start_sniffing (char * device) { - pcap_t *handletopcap; - char errbuf[PCAP_ERRBUF_SIZE]; + pcap_t *handletopcap; /* The handle to the libpcap */ + char errbuf[PCAP_ERRBUF_SIZE]; /* The errorbuffer of libpacap */ + struct pcap_pkthdr header; /* The packet header from pcap*/ + const u_char *packet; /* The actual packet content*/ /* opening the pcap for sniffing */ handletopcap = pcap_open_live(device, BUFSIZ, 1, 1000, errbuf); #ifdef HAVE_PCAP_NONBLOCK pcap_setnonblock(handletopcap, 1, errstr); #endif /*start scanning */ - pcap_loop(handletopcap,-1,process_packets,NULL); +// pcap_loop(handletopcap,-1,process_packets,NULL); + /* Loope endless */ + while(1) + { + /* Grab one single packet */ + packet = pcap_next(handletopcap, &header); + + /* process the packet */ + process_packets(NULL,&header,*&packet); + } printf("\nDone processing packets... wheew!\n"); return 1; } @@ -97,9 +108,8 @@ void process_packets(u_char *useless,const struct pcap_pkthdr* pkthdr,const u_ch { /* Is it a beacon frame? */ case ST_BEACON: if (handle_beacon(fc, packet,pinfoptr) ==0) { - printf ("\n\tOn network : %s",pinfoptr->ssid); if (!strcmp(pinfoptr->desthwaddr,"ff:ff:ff:ff:ff:ff") == 0) { /* Every beacon must have the broadcast as destination so it must be a shitti packet */ |