author | mjm <mjm> | 2002-11-23 21:42:41 (UTC) |
---|---|---|
committer | mjm <mjm> | 2002-11-23 21:42:41 (UTC) |
commit | c93ded2c1256817b9c974c792cd143315b98fff7 (patch) (unidiff) | |
tree | 7de5b3fc8eee930f72c4e3ef662f48948a60d935 /noncore/net/wellenreiter/daemon/source/sniffer.cc | |
parent | 4e24ece4607d3b2f9e3252fa561fabaa9cdddd63 (diff) | |
download | opie-c93ded2c1256817b9c974c792cd143315b98fff7.zip opie-c93ded2c1256817b9c974c792cd143315b98fff7.tar.gz opie-c93ded2c1256817b9c974c792cd143315b98fff7.tar.bz2 |
implemented sniffer function in daemon.cc
Diffstat (limited to 'noncore/net/wellenreiter/daemon/source/sniffer.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/sniffer.cc | 41 |
1 files changed, 1 insertions, 40 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/sniffer.cc b/noncore/net/wellenreiter/daemon/source/sniffer.cc index be64d67..66d5b6f 100644 --- a/noncore/net/wellenreiter/daemon/source/sniffer.cc +++ b/noncore/net/wellenreiter/daemon/source/sniffer.cc | |||
@@ -12,45 +12,6 @@ | |||
12 | #include "ieee802_11.hh" | 12 | #include "ieee802_11.hh" |
13 | #include "extract.hh" | 13 | #include "extract.hh" |
14 | 14 | ||
15 | int main(void) | ||
16 | { | ||
17 | if(card_into_monitormode (SNIFFER_DEVICE, CARD_TYPE_NG) < 0) | ||
18 | return 0; | ||
19 | start_sniffing (SNIFFER_DEVICE); | ||
20 | |||
21 | return 1; | ||
22 | } | ||
23 | |||
24 | int start_sniffing (char * device) | ||
25 | { | ||
26 | |||
27 | pcap_t *handletopcap; /* The handle to the libpcap */ | ||
28 | char errbuf[PCAP_ERRBUF_SIZE]; /* The errorbuffer of libpacap */ | ||
29 | struct pcap_pkthdr header; /* The packet header from pcap*/ | ||
30 | const u_char *packet; /* The actual packet content*/ | ||
31 | |||
32 | /* opening the pcap for sniffing */ | ||
33 | handletopcap = pcap_open_live(device, BUFSIZ, 1, 1000, errbuf); | ||
34 | |||
35 | #ifdef HAVE_PCAP_NONBLOCK | ||
36 | pcap_setnonblock(handletopcap, 1, errstr); | ||
37 | #endif | ||
38 | /*start scanning */ | ||
39 | //pcap_loop(handletopcap,-1,process_packets,NULL); | ||
40 | /* Loope endless */ | ||
41 | while(1) | ||
42 | { | ||
43 | /* Grab one single packet */ | ||
44 | packet = pcap_next(handletopcap, &header); | ||
45 | |||
46 | /* process the packet */ | ||
47 | process_packets(NULL,&header,*&packet); | ||
48 | } | ||
49 | |||
50 | printf("\nDone processing packets... wheew!\n"); | ||
51 | return 1; | ||
52 | } | ||
53 | |||
54 | void process_packets(u_char *useless,const struct pcap_pkthdr* pkthdr,const u_char* packet) | 15 | void process_packets(u_char *useless,const struct pcap_pkthdr* pkthdr,const u_char* packet) |
55 | { | 16 | { |
56 | u_int caplen = pkthdr->caplen; | 17 | u_int caplen = pkthdr->caplen; |
@@ -298,7 +259,7 @@ int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) | |||
298 | } /* End of handle_beacon */ | 259 | } /* End of handle_beacon */ |
299 | 260 | ||
300 | 261 | ||
301 | static int GetHeaderLength(u_int16_t fc) | 262 | int GetHeaderLength(u_int16_t fc) |
302 | { | 263 | { |
303 | int iLength=0; | 264 | int iLength=0; |
304 | 265 | ||