summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/daemon/source/daemon.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.cc b/noncore/net/wellenreiter/daemon/source/daemon.cc
index 51c2194..d6e8f6b 100644
--- a/noncore/net/wellenreiter/daemon/source/daemon.cc
+++ b/noncore/net/wellenreiter/daemon/source/daemon.cc
@@ -7,11 +7,25 @@
7#include "config.hh" 7#include "config.hh"
8#include "daemon.hh" 8#include "daemon.hh"
9 9
10// temporary solution, will be removed soon
11#define MAXCHANNEL 13
12char sniffer_device[6];
13int channel=0;
14int timedout=1;
15
16static int chanswitch()
17{
18 if(channel >= MAXCHANNEL)
19 channel=1
20 card_set_channel(sniffer_device, channel, card_type);
21 timedout=0;
22}
23
10/* Main function of wellenreiterd */ 24/* Main function of wellenreiterd */
11int main(int argc, char **argv) 25int main(int argc, char **argv)
12{ 26{
13 int sock, maxfd, retval, card_type; 27 int sock, maxfd, retval, card_type;
14 char buffer[WL_SOCKBUF], sniffer_device[6]; 28 char buffer[WL_SOCKBUF];
15 struct pcap_pkthdr header; 29 struct pcap_pkthdr header;
16 struct sockaddr_in saddr; 30 struct sockaddr_in saddr;
17 pcap_t *handletopcap; 31 pcap_t *handletopcap;
@@ -25,6 +39,9 @@ int main(int argc, char **argv)
25 if(argc < 3) 39 if(argc < 3)
26 usage(); 40 usage();
27 41
42 // removed soon, see above
43 SIGNAL(SIGALRM, chanswitch);
44
28 /* Set sniffer device */ 45 /* Set sniffer device */
29 memset(sniffer_device, 0, sizeof(sniffer_device)); 46 memset(sniffer_device, 0, sizeof(sniffer_device));
30 strncpy(sniffer_device, (char *)argv[1], sizeof(sniffer_device) - 1); 47 strncpy(sniffer_device, (char *)argv[1], sizeof(sniffer_device) - 1);
@@ -72,10 +89,14 @@ int main(int argc, char **argv)
72 FD_SET(sock, &rset); 89 FD_SET(sock, &rset);
73 FD_SET(pcap_fileno(handletopcap), &rset); 90 FD_SET(pcap_fileno(handletopcap), &rset);
74 91
92 // blah
93 timedout=1;
94 alarm(1);
95
75 /* socket or pcap handle bigger? Will be cleaned up, have to check pcap */ 96 /* socket or pcap handle bigger? Will be cleaned up, have to check pcap */
76 maxfd = (sock > pcap_fileno(handletopcap) ? sock : pcap_fileno(handletopcap)) + 1; 97 maxfd = (sock > pcap_fileno(handletopcap) ? sock : pcap_fileno(handletopcap)) + 1;
77 98
78 if(select(maxfd, &rset, NULL, NULL, NULL) < 0) 99 if(select(maxfd, &rset, NULL, NULL, NULL) < 0 && timedout)
79 { 100 {
80 wl_logerr("Error calling select: %s", strerror(errno)); 101 wl_logerr("Error calling select: %s", strerror(errno));
81 break; 102 break;
@@ -85,7 +106,7 @@ int main(int argc, char **argv)
85 if(FD_ISSET(sock, &rset)) 106 if(FD_ISSET(sock, &rset))
86 { 107 {
87 /* Receive data from socket */ 108 /* Receive data from socket */
88 if((retval=wl_recv(&sock, saddr, buffer, sizeof(buffer))) < 0) 109 if((retval=wl_recv(&sock, saddr, buffer, sizeof(buffer))) < 0 && timedout)
89 { 110 {
90 wl_logerr("Error trying to read: %s", strerror(errno)); 111 wl_logerr("Error trying to read: %s", strerror(errno));
91 break; 112 break;