summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/libwellenreiter/source/sniff.cc') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/sniff.cc71
1 files changed, 71 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
index 6e512c4..0616a7e 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
@@ -12,2 +12,73 @@
12#include "wl_proto.hh" 12#include "wl_proto.hh"
13#include "cardmode.hh"
14
15int start_sniffer(const char *device, int cardtype )
16{
17
18 /* This function initialize the sniffing
19 1. Check for lo interface
20 2. bring it into promsicous mode and UP
21 3. bring device into rfmon mode
22 start the pcap sniffing process.
23 */
24
25 /* Do we have the device name ? */
26 if(device == NULL)
27 {
28 wl_logerr("start_sniffer, parameter \"device\" is empty, please check your config");
29 return 0;
30 }
31
32 /* Some Linux System does not have a loopback device lo with 127.0.0.1 so sockets could
33 not made correctly, let the proggie check that and proceed only if it exists. */
34 if (!check_loopback())
35 {
36 wl_logerr("start_sniffer, check_loopback failed, cannot continue without a loopback");
37 return 0;
38 }
39
40 /* Set the card into regulary promiscous mode first and set the UP flag, in case no ip
41 was given. It would work without the promisc flags but i dont like this */
42 if (!card_set_promisc_up(device))
43 {
44 wl_logerr("start_sniffer, card_set_promisc_up failed, cannot continue");
45 return 0;
46 }
47
48 /* Set card into the rfmon/monitoring mode */
49 if (!card_into_monitormode(device,cardtype))
50 {
51 wl_logerr("start_sniffer, cannot put wireless card into monitoring mode, aborting");
52 return 0;
53 }
54
55 /* setup pcap handle, used for the packet decoding etc. */
56 if((handletopcap = pcap_open_live((char *) device, BUFSIZ, 1, 0, NULL)) == NULL)
57 {
58 wl_logerr("pcap_open_live() failed: %s", strerror(errno));
59 return 0;
60 }
61
62#ifdef HAVE_PCAP_NONBLOCK
63 pcap_setnonblock(handletopcap, 1, NULL);
64#endif
65 return 1;
66}
67
68
69int stop_sniffer(const char *device, int cardtype)
70{
71 /* This function terminates the sniffing
72 1. get the device state
73 2. remove the rfmon state
74 3. Remove the promisc state
75 start the pcap sniffing process.
76
77 */
78
79 /* Do we really have at least a lo interface with the 127.0.0.1 ? */
80 return 0;
81
82}
83
13 84