author | max <max> | 2003-03-04 14:04:52 (UTC) |
---|---|---|
committer | max <max> | 2003-03-04 14:04:52 (UTC) |
commit | 3adca473d5440b00e15781627e00465350e9118b (patch) (unidiff) | |
tree | e60e57f10c8297eee39f9e31974f9199013c4930 /noncore/net/wellenreiter/daemon | |
parent | 7cf53b4030437bdbd405b8b16684ba9f68e2891d (diff) | |
download | opie-3adca473d5440b00e15781627e00465350e9118b.zip opie-3adca473d5440b00e15781627e00465350e9118b.tar.gz opie-3adca473d5440b00e15781627e00465350e9118b.tar.bz2 |
start_sniff
Diffstat (limited to 'noncore/net/wellenreiter/daemon') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/daemon.cc | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.cc b/noncore/net/wellenreiter/daemon/source/daemon.cc index 3a28217..b840f17 100644 --- a/noncore/net/wellenreiter/daemon/source/daemon.cc +++ b/noncore/net/wellenreiter/daemon/source/daemon.cc | |||
@@ -8,20 +8,21 @@ | |||
8 | #include "daemon.hh" | 8 | #include "daemon.hh" |
9 | 9 | ||
10 | /* should be parsed from cfg-file */ | 10 | /* should be parsed from cfg-file */ |
11 | #define MAXCHANNEL 13 | 11 | #define MAXCHANNEL 13 |
12 | #define CHANINTERVAL 500000 | 12 | #define CHANINTERVAL 500000 |
13 | 13 | ||
14 | |||
14 | /* Main function of wellenreiterd */ | 15 | /* Main function of wellenreiterd */ |
15 | int main(int argc, char **argv) | 16 | int main(int argc, char **argv) |
16 | { | 17 | { |
17 | int sock, maxfd, retval; | 18 | int sock, maxfd, retval; |
18 | char buffer[WL_SOCKBUF]; | 19 | char buffer[WL_SOCKBUF]; |
19 | struct pcap_pkthdr header; | 20 | struct pcap_pkthdr header; |
20 | struct sockaddr_in saddr; | 21 | struct sockaddr_in saddr; |
21 | pcap_t *handletopcap; | 22 | // pcap_t *handletopcap; |
22 | wl_cardtype_t cardtype; | 23 | wl_cardtype_t cardtype; |
23 | pthread_t sub; | 24 | pthread_t sub; |
24 | const unsigned char *packet; | 25 | const unsigned char *packet; |
25 | 26 | ||
26 | fd_set rset; | 27 | fd_set rset; |
27 | 28 | ||
@@ -37,32 +38,20 @@ int main(int argc, char **argv) | |||
37 | 38 | ||
38 | /* Set card type */ | 39 | /* Set card type */ |
39 | cardtype.type = atoi(argv[2]); | 40 | cardtype.type = atoi(argv[2]); |
40 | if(cardtype.type < 1 || cardtype.type > 4) | 41 | if(cardtype.type < 1 || cardtype.type > 4) |
41 | usage(); | 42 | usage(); |
42 | 43 | ||
43 | /* set card into monitor mode */ | 44 | /* Until we do not act as a read daemon, it starts the sniffer |
44 | if(!card_into_monitormode(&handletopcap, cardtype.iface, | 45 | right after startup */ |
45 | cardtype.type)) | 46 | if (!start_sniffer(cardtype.iface,cardtype.type)) |
46 | { | 47 | { |
47 | wl_logerr("Cannot initialize the wireless-card, aborting"); | 48 | wl_logerr("daemon, start_sniff did not return proper, aborting"); |
48 | exit(EXIT_FAILURE); | 49 | exit(EXIT_FAILURE); |
49 | } | 50 | } |
50 | wl_loginfo("Set card into monitor mode"); | 51 | wl_loginfo ("daemon, wireless card prepared for sniffing"); |
51 | |||
52 | /* setup pcap */ | ||
53 | if((handletopcap = pcap_open_live(cardtype.iface, | ||
54 | BUFSIZ, 1, 0, NULL)) == NULL) | ||
55 | { | ||
56 | wl_logerr("pcap_open_live() failed: %s", strerror(errno)); | ||
57 | exit(EXIT_FAILURE); | ||
58 | } | ||
59 | |||
60 | #ifdef HAVE_PCAP_NONBLOCK | ||
61 | pcap_setnonblock(handletopcap, 1, NULL); | ||
62 | #endif | ||
63 | 52 | ||
64 | /* Setup socket for incoming commands */ | 53 | /* Setup socket for incoming commands */ |
65 | if((sock=wl_setupsock(DAEMONADDR, DAEMONPORT, saddr)) < 0) | 54 | if((sock=wl_setupsock(DAEMONADDR, DAEMONPORT, saddr)) < 0) |
66 | { | 55 | { |
67 | wl_logerr("Cannot setup socket"); | 56 | wl_logerr("Cannot setup socket"); |
68 | exit(EXIT_FAILURE); | 57 | exit(EXIT_FAILURE); |