summaryrefslogtreecommitdiff
path: root/noncore/net
Side-by-side diff
Diffstat (limited to 'noncore/net') (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 @@
#include "config.hh"
#include "daemon.hh"
+// temporary solution, will be removed soon
+#define MAXCHANNEL 13
+char sniffer_device[6];
+int channel=0;
+int timedout=1;
+
+static int chanswitch()
+{
+ if(channel >= MAXCHANNEL)
+ channel=1
+ card_set_channel(sniffer_device, channel, card_type);
+ timedout=0;
+}
+
/* Main function of wellenreiterd */
int main(int argc, char **argv)
{
int sock, maxfd, retval, card_type;
- char buffer[WL_SOCKBUF], sniffer_device[6];
+ char buffer[WL_SOCKBUF];
struct pcap_pkthdr header;
struct sockaddr_in saddr;
pcap_t *handletopcap;
@@ -25,6 +39,9 @@ int main(int argc, char **argv)
if(argc < 3)
usage();
+ // removed soon, see above
+ SIGNAL(SIGALRM, chanswitch);
+
/* Set sniffer device */
memset(sniffer_device, 0, sizeof(sniffer_device));
strncpy(sniffer_device, (char *)argv[1], sizeof(sniffer_device) - 1);
@@ -72,10 +89,14 @@ int main(int argc, char **argv)
FD_SET(sock, &rset);
FD_SET(pcap_fileno(handletopcap), &rset);
+ // blah
+ timedout=1;
+ alarm(1);
+
/* socket or pcap handle bigger? Will be cleaned up, have to check pcap */
maxfd = (sock > pcap_fileno(handletopcap) ? sock : pcap_fileno(handletopcap)) + 1;
- if(select(maxfd, &rset, NULL, NULL, NULL) < 0)
+ if(select(maxfd, &rset, NULL, NULL, NULL) < 0 && timedout)
{
wl_logerr("Error calling select: %s", strerror(errno));
break;
@@ -85,7 +106,7 @@ int main(int argc, char **argv)
if(FD_ISSET(sock, &rset))
{
/* Receive data from socket */
- if((retval=wl_recv(&sock, saddr, buffer, sizeof(buffer))) < 0)
+ if((retval=wl_recv(&sock, saddr, buffer, sizeof(buffer))) < 0 && timedout)
{
wl_logerr("Error trying to read: %s", strerror(errno));
break;