author | mickeyl <mickeyl> | 2003-03-30 01:51:14 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-30 01:51:14 (UTC) |
commit | d11a0154e2d9732854c9a3d598857bc20f359849 (patch) (side-by-side diff) | |
tree | af0e0273d01f4f6c64c9f230f22bb91a7a8a21d8 /noncore/net/wellenreiter/daemon/source | |
parent | 99899abc80a8aa05044eeecd8a061b0a8efaa713 (diff) | |
download | opie-d11a0154e2d9732854c9a3d598857bc20f359849.zip opie-d11a0154e2d9732854c9a3d598857bc20f359849.tar.gz opie-d11a0154e2d9732854c9a3d598857bc20f359849.tar.bz2 |
- the network work for libopie2 pays off...
- good bye to wellenreiterd, t'was fun but always too unstable and too hard to maintain
- good bye to libwellenreiter
Diffstat (limited to 'noncore/net/wellenreiter/daemon/source') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/.cvsignore | 3 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/Makefile | 25 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/config.hh | 29 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/daemon.cc | 195 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/daemon.hh | 27 |
5 files changed, 0 insertions, 279 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/.cvsignore b/noncore/net/wellenreiter/daemon/source/.cvsignore deleted file mode 100644 index ed65c71..0000000 --- a/noncore/net/wellenreiter/daemon/source/.cvsignore +++ b/dev/null @@ -1,3 +0,0 @@ -*.o -*~ -moc_* diff --git a/noncore/net/wellenreiter/daemon/source/Makefile b/noncore/net/wellenreiter/daemon/source/Makefile deleted file mode 100644 index 38d61f1..0000000 --- a/noncore/net/wellenreiter/daemon/source/Makefile +++ b/dev/null @@ -1,25 +0,0 @@ -# $Id$ - -CPP = g++ -CPPFLAGS = -g -Wall -pedantic -DDEBUG -I ../../ -LIBS = -lpthread -lpcap ../../libwellenreiter/source/libwellenreiter.a -OBJ = daemon.o - -.SUFFIXES: -.PHONY: all wellenreiterd clean distclean realclean - -%.o : %.cc - $(CPP) $(CPPFLAGS) -c $< -o $@ - -all: wellenreiterd - -wellenreiterd: $(OBJ) - $(CPP) $(CPPFLAGS) $(OBJ) $(LIBS) -o $@ - @echo Build wellenreiterd - -clean distclean realclean: - @rm -f wellenreiterd *~ *.o - @echo All dependent files have been removed. - -daemon.o: config.hh - diff --git a/noncore/net/wellenreiter/daemon/source/config.hh b/noncore/net/wellenreiter/daemon/source/config.hh deleted file mode 100644 index 0ac7eb9..0000000 --- a/noncore/net/wellenreiter/daemon/source/config.hh +++ b/dev/null @@ -1,29 +0,0 @@ -/* - * - * Global configuration for wellenreiter - * - * $Id$ - * - * Written by Martin J. Muench <mjm@codito.de> - * - */ - -#ifndef CONFIG_HH -#define CONFIG_HH - -#define PROGNAME "wellenreiter" /* Name of program (for syslog et.al.) */ -#define VERSION "0.2" /* Version of wellenreiter */ - -#define DAEMONADDR "127.0.0.1" -#define DAEMONPORT 37772 /* Port of Daemon */ - -#define GUIADDR "127.0.0.1" /* Adress of GUI, later specified in configfile */ -#define GUIPORT 37773 /* Port of GUI, " " */ - -/* Temporary cardmode stuff, will hopefully removed soon */ -#define CARD_TYPE_CISCO 1 -#define CARD_TYPE_NG 2 -#define CARD_TYPE_HOSTAP 3 -#define CARD_TYPE_ORINOCCO 4 - -#endif /* CONFIG_HH */ diff --git a/noncore/net/wellenreiter/daemon/source/daemon.cc b/noncore/net/wellenreiter/daemon/source/daemon.cc deleted file mode 100644 index b840f17..0000000 --- a/noncore/net/wellenreiter/daemon/source/daemon.cc +++ b/dev/null @@ -1,195 +0,0 @@ -/* - * Startup functions of wellenreiter - * - * $Id$ - */ - -#include "config.hh" -#include "daemon.hh" - -/* should be parsed from cfg-file */ -#define MAXCHANNEL 13 -#define CHANINTERVAL 500000 - - -/* Main function of wellenreiterd */ -int main(int argc, char **argv) -{ - int sock, maxfd, retval; - char buffer[WL_SOCKBUF]; - struct pcap_pkthdr header; - struct sockaddr_in saddr; -// pcap_t *handletopcap; - wl_cardtype_t cardtype; - pthread_t sub; - const unsigned char *packet; - - fd_set rset; - - fprintf(stderr, "wellenreiterd %s\n\n", VERSION); - fprintf(stderr, "(c) 2002 by M-M-M\n\n"); - - if(argc < 3) - usage(); - - /* Set sniffer device */ - memset(cardtype.iface, 0, sizeof(cardtype.iface)); - strncpy(cardtype.iface, (char *)argv[1], sizeof(cardtype.iface) - 1); - - /* Set card type */ - cardtype.type = atoi(argv[2]); - if(cardtype.type < 1 || cardtype.type > 4) - usage(); - - /* Until we do not act as a read daemon, it starts the sniffer - right after startup */ - if (!start_sniffer(cardtype.iface,cardtype.type)) - { - wl_logerr("daemon, start_sniff did not return proper, aborting"); - exit(EXIT_FAILURE); - } - wl_loginfo ("daemon, wireless card prepared for sniffing"); - - /* Setup socket for incoming commands */ - if((sock=wl_setupsock(DAEMONADDR, DAEMONPORT, saddr)) < 0) - { - wl_logerr("Cannot setup socket"); - exit(EXIT_FAILURE); - } - wl_loginfo("Set up socket '%d' for GUI communication", sock); - - /* Create channelswitching thread */ - if(pthread_create(&sub, NULL, channel_switcher, - (void *)&cardtype) != 0) - { - wl_logerr("Cannot create thread: %s", strerror(errno)); - close(sock); - exit(EXIT_FAILURE); - } - if(pthread_detach(sub)) - { - wl_logerr("Error detaching thread"); - close(sock); - pthread_exit((pthread_t *)sub); - exit(EXIT_FAILURE); - } - wl_loginfo("Created and detached channel switching thread"); - - FD_ZERO(&rset); - - /* Start main loop */ - wl_loginfo("Starting main loop"); - while(1) - { - - FD_SET(sock, &rset); - FD_SET(pcap_fileno(handletopcap), &rset); - - /* maxfd = biggest filefd */ - maxfd = (sock > pcap_fileno(handletopcap) ? - sock + 1 : pcap_fileno(handletopcap)) + 1; - - if(select(maxfd, &rset, NULL, NULL, NULL) < 0) - { - wl_logerr("Error calling select: %s", strerror(errno)); - break; - } - - /* Got data on local socket from GUI */ - if(FD_ISSET(sock, &rset)) - { - /* Receive data from socket */ - if((retval=wl_recv(&sock, saddr, buffer, sizeof(buffer))) < 0) - { - wl_logerr("Error trying to read: %s", strerror(errno)); - break; - } - else - { - /* check type of packet and start function according to it */ - switch(retval) - { - case STARTSNIFF: - wl_loginfo("Received STARTSNIFF command"); - if(!send_ok(GUIADDR, GUIPORT, STARTSNIFF)) - wl_logerr("Cannot set OK_CMD to GUI"); - break; - case STOPSNIFF: - wl_loginfo("Received STOPSNIFF command"); - if(!send_ok(GUIADDR, GUIPORT, STOPSNIFF)) - wl_logerr("Cannot set FAIL_CMD to GUI"); - break; - default: - wl_logerr("Received unknown command: %d", retval); - break; - } - } - } /* FD_ISSET */ - - /* Check pcap lib for packets */ - if(FD_ISSET(pcap_fileno(handletopcap), &rset)) - { - - /* Grab one single packet */ - packet = pcap_next(handletopcap, &header); - - /* process the packet */ - process_packets(&header,*&packet, GUIADDR, GUIPORT); - } - - } /* while(1) */ - - close(sock); - exit(EXIT_SUCCESS); -} - -void -usage(void) -{ - fprintf(stderr, "Usage: wellenreiter <device> <cardtype>\n" \ - "\t<device> = Wirelessdevice (e.g. wlan0)\n" \ - "\t<cardtype> = Cardtype:\tCisco\t= 1\n" \ - "\t\t\t\tNG\t= 2\n" \ - "\t\t\t\tHOSTAP\t= 3\n" \ - "\t\t\t\tLUCENT\t= 4\n"); - exit(EXIT_FAILURE); -} - -void * -channel_switcher(void *cardtypeptr) -{ - wl_cardtype_t *cardtype; - int maxchan=0; - int channel=1; - /* Get card info struct */ - cardtype = (wl_cardtype_t *)cardtypeptr; - /* Get from the wireless extension the amount of available channels - this prevents a fail in switching on us cards */ - maxchan = card_detect_channels(cardtype->iface); - - if (maxchan < MAXCHANNEL) - { - #undef MAXCHANNEL - #define MAXCHANNEL maxchan - } - - while(1) - { - - /* If channel bigger than maxchannel, set to 1 */ - if(channel > MAXCHANNEL) - channel=1; - - /* Set channel */ - if(!card_set_channel(cardtype->iface, channel, cardtype->type)) - { - wl_logerr("Cannot set channel, thread exiting"); - pthread_exit(NULL); - } - - /* sleep */ - usleep(CHANINTERVAL); - - channel++; - } /* while */ -} diff --git a/noncore/net/wellenreiter/daemon/source/daemon.hh b/noncore/net/wellenreiter/daemon/source/daemon.hh deleted file mode 100644 index f9ac45e..0000000 --- a/noncore/net/wellenreiter/daemon/source/daemon.hh +++ b/dev/null @@ -1,27 +0,0 @@ -/* $Id$ */ - -#ifndef DAEMON_HH -#define DAEMON_HH - -#include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <pthread.h> -#include <unistd.h> -#include <errno.h> - -#include <libwellenreiter/source/wl_sock.hh> -#include <libwellenreiter/source/wl_log.hh> -#include <libwellenreiter/source/wl_types.hh> -#include <libwellenreiter/source/wl_proto.hh> -#include <libwellenreiter/source/cardmode.hh> -#include <libwellenreiter/source/sniff.hh> - -void usage(void); -void *channel_switcher(void *); - -#endif /* DAEMON_HH */ |