summaryrefslogtreecommitdiff
authormjm <mjm>2002-11-28 00:00:08 (UTC)
committer mjm <mjm>2002-11-28 00:00:08 (UTC)
commit3d3add0a024d650d6247108ed6a19c11efd63724 (patch) (unidiff)
tree312b281a110b9414253c321fd436eed1805cba24
parent6eea92f02035e62e61c8600f2e9fe52dee5a4b6c (diff)
downloadopie-3d3add0a024d650d6247108ed6a19c11efd63724.zip
opie-3d3add0a024d650d6247108ed6a19c11efd63724.tar.gz
opie-3d3add0a024d650d6247108ed6a19c11efd63724.tar.bz2
temporary moved handlesettings to daemon.cc
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/daemon/source/daemon.cc24
1 files changed, 23 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.cc b/noncore/net/wellenreiter/daemon/source/daemon.cc
index b836a31..6467af7 100644
--- a/noncore/net/wellenreiter/daemon/source/daemon.cc
+++ b/noncore/net/wellenreiter/daemon/source/daemon.cc
@@ -1,61 +1,83 @@
1/* 1/*
2 * Startup functions of wellenreiter 2 * Startup functions of wellenreiter
3 * 3 *
4 * $Id$ 4 * $Id$
5 */ 5 */
6 6
7#include "config.hh" 7#include "config.hh"
8#include "daemon.hh" 8#include "daemon.hh"
9 9
10/* Main function of wellenreiterd */ 10/* Main function of wellenreiterd */
11int main(int argc, char **argv) 11int main(int argc, char **argv)
12{ 12{
13 int sock, maxfd, retval; 13 int sock, maxfd, retval;
14 char buffer[128]; 14 char buffer[128];
15 struct pcap_pkthdr header; 15 struct pcap_pkthdr header;
16 pcap_t *handletopcap; 16 pcap_t *handletopcap;
17 const unsigned char *packet; 17 const unsigned char *packet;
18 18
19 fd_set rset; 19 fd_set rset;
20 20
21 fprintf(stderr, "wellenreiterd %s\n\n", VERSION); 21 fprintf(stderr, "wellenreiterd %s\n\n", VERSION);
22 22
23 if(!card_into_monitormode(handletopcap, SNIFFER_DEVICE, CARD_TYPE_NG)) 23 if(!card_into_monitormode(&handletopcap, SNIFFER_DEVICE, CARD_TYPE_NG))
24 { 24 {
25 wl_logerr("Cannot set card into mon mode, aborting"); 25 wl_logerr("Cannot set card into mon mode, aborting");
26 exit(-1); 26 exit(-1);
27 } 27 }
28 wl_loginfo("Set card into monitor mode"); 28 wl_loginfo("Set card into monitor mode");
29 29
30 /////// following line will be moved to lib as soon as possible ////////////
31 if((handletopcap = pcap_open_live(SNIFFER_DEVICE, BUFSIZ, 1, 0, NULL)) == NULL)
32 {
33 wl_logerr("pcap_open_live() failed: %s", strerror(errno));
34 exit(-1);
35 }
36
37#ifdef HAVE_PCAP_NONBLOCK
38 pcap_setnonblock(handletopcap, 1, NULL);
39#endif
40
41 /* getting the datalink type */
42 retval = pcap_datalink(handletopcap);
43 if (retval != DLT_IEEE802_11) /* Rawmode is IEEE802_11 */
44 {
45 wl_loginfo("Interface %s does not work in the correct 802.11 raw mode", SNIFFER_DEVICE);
46 pcap_close(handletopcap);
47 return 0;
48 }
49 wl_loginfo("Your successfully listen on %s in 802.11 raw mode", SNIFFER_DEVICE);
50 ////////////////////////////////////////
51
30 /* Setup socket for incoming commands */ 52 /* Setup socket for incoming commands */
31 if((sock=commsock(DAEMONADDR, DAEMONPORT)) < 0) 53 if((sock=commsock(DAEMONADDR, DAEMONPORT)) < 0)
32 { 54 {
33 wl_logerr("Cannot setup socket"); 55 wl_logerr("Cannot setup socket");
34 exit(-1); 56 exit(-1);
35 } 57 }
36 wl_loginfo("Set up socket '%d' for GUI communication", sock); 58 wl_loginfo("Set up socket '%d' for GUI communication", sock);
37 59
38 FD_ZERO(&rset); 60 FD_ZERO(&rset);
39 61
40 /* Start main loop */ 62 /* Start main loop */
41 wl_loginfo("Starting main loop"); 63 wl_loginfo("Starting main loop");
42 while(1) 64 while(1)
43 { 65 {
44 66
45 FD_SET(sock, &rset); 67 FD_SET(sock, &rset);
46 FD_SET(pcap_fileno(handletopcap), &rset); 68 FD_SET(pcap_fileno(handletopcap), &rset);
47 maxfd=sock + pcap_fileno(handletopcap) + 1; 69 maxfd=sock + pcap_fileno(handletopcap) + 1;
48 70
49 if(select(maxfd, &rset, NULL, NULL, NULL) < 0) 71 if(select(maxfd, &rset, NULL, NULL, NULL) < 0)
50 { 72 {
51 wl_logerr("Error calling select: %s", strerror(errno)); 73 wl_logerr("Error calling select: %s", strerror(errno));
52 break; 74 break;
53 } 75 }
54 76
55 /* Got data on local socket from GUI */ 77 /* Got data on local socket from GUI */
56 if(FD_ISSET(sock, &rset)) 78 if(FD_ISSET(sock, &rset))
57 { 79 {
58 /* Receive data from socket */ 80 /* Receive data from socket */
59 if((retval=recvcomm(&sock, buffer, sizeof(buffer))) < 0) 81 if((retval=recvcomm(&sock, buffer, sizeof(buffer))) < 0)
60 { 82 {
61 wl_logerr("Error trying to read: %s", strerror(errno)); 83 wl_logerr("Error trying to read: %s", strerror(errno));