author | max <max> | 2003-02-07 17:17:35 (UTC) |
---|---|---|
committer | max <max> | 2003-02-07 17:17:35 (UTC) |
commit | 014608882b23343473c5d0e7dca3ea09cf02dcfb (patch) (side-by-side diff) | |
tree | 90eac99cbb0faca581cc9b5cc37a9fd460548050 | |
parent | a14c5974339f5beef433754d52c952cb99834619 (diff) | |
download | opie-014608882b23343473c5d0e7dca3ea09cf02dcfb.zip opie-014608882b23343473c5d0e7dca3ea09cf02dcfb.tar.gz opie-014608882b23343473c5d0e7dca3ea09cf02dcfb.tar.bz2 |
Chanswitch
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/daemon.cc | 26 | ||||
-rw-r--r-- | noncore/net/wellenreiter/daemon/source/daemon.hh | 1 | ||||
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc | 9 |
3 files changed, 25 insertions, 11 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.cc b/noncore/net/wellenreiter/daemon/source/daemon.cc index d6e8f6b..b57e6a0 100644 --- a/noncore/net/wellenreiter/daemon/source/daemon.cc +++ b/noncore/net/wellenreiter/daemon/source/daemon.cc @@ -1,63 +1,71 @@ /* * Startup functions of wellenreiter * * $Id$ */ #include "config.hh" #include "daemon.hh" // temporary solution, will be removed soon #define MAXCHANNEL 13 +int card_type; char sniffer_device[6]; int channel=0; int timedout=1; -static int chanswitch() +void chanswitch(int blah) { if(channel >= MAXCHANNEL) - channel=1 + { + channel=1; + } + else + { + channel++; + } card_set_channel(sniffer_device, channel, card_type); timedout=0; + alarm(1); } /* Main function of wellenreiterd */ int main(int argc, char **argv) { - int sock, maxfd, retval, card_type; + int sock, maxfd, retval; char buffer[WL_SOCKBUF]; struct pcap_pkthdr header; struct sockaddr_in saddr; pcap_t *handletopcap; 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(); // removed soon, see above - SIGNAL(SIGALRM, chanswitch); - + signal(SIGALRM, chanswitch); + alarm(1); /* Set sniffer device */ memset(sniffer_device, 0, sizeof(sniffer_device)); strncpy(sniffer_device, (char *)argv[1], sizeof(sniffer_device) - 1); /* Set card type */ card_type = atoi(argv[2]); - if(card_type < 1 || card_type > 3) + if(card_type < 1 || card_type > 4) usage(); if(!card_into_monitormode(&handletopcap, sniffer_device, card_type)) { wl_logerr("Cannot initialize the wireless-card, aborting"); exit(-1); } wl_loginfo("Set card into monitor mode"); /////// following line will be moved to lib as soon as possible //////////// if((handletopcap = pcap_open_live(sniffer_device, BUFSIZ, 1, 0, NULL)) == NULL) { @@ -82,25 +90,24 @@ int main(int argc, char **argv) FD_ZERO(&rset); /* Start main loop */ wl_loginfo("Starting main loop"); while(1) { 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 && timedout) { wl_logerr("Error calling select: %s", strerror(errno)); break; } /* Got data on local socket from GUI */ if(FD_ISSET(sock, &rset)) @@ -141,17 +148,18 @@ int main(int argc, char **argv) } } /* while(1) */ close(sock); exit(0); } void usage(void) { fprintf(stderr, "Usage: wellenreiter <device> <cardtype>\n" \ "\t<device> = Wirelessdevice (e.g. wlan0)\n" \ - "\t<cardtype> = Cardtype:\t Cisco\t= 1\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\tHOSTAP\t= 3\n" \ + "\t\t\t\tLUCENT\t= 4\n"); exit(-1); } diff --git a/noncore/net/wellenreiter/daemon/source/daemon.hh b/noncore/net/wellenreiter/daemon/source/daemon.hh index 1cc3c7c..d50487a 100644 --- a/noncore/net/wellenreiter/daemon/source/daemon.hh +++ b/noncore/net/wellenreiter/daemon/source/daemon.hh @@ -3,23 +3,24 @@ #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 <unistd.h> #include <errno.h> +#include <signal.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); #endif /* DAEMON_HH */ diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc index 697d182..0c23922 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc +++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc @@ -64,24 +64,28 @@ int card_into_monitormode (pcap_t **orighandle, char *device, int cardtype) return 0; } } else if (cardtype == CARD_TYPE_ORINOCCO) { char lucentcmd[62]; snprintf(lucentcmd, sizeof(lucentcmd) - 1, "$(which iwpriv) %s monitor 2 %d", device, 1); if (system(lucentcmd) != 0) { wl_logerr("Could not set %s in raw mode, check cardtype", device); return 0; } + else + { + wl_loginfo("Successfully set %s into raw mode",device); + } } /* Setting the promiscous and up flag to the interface */ if (!card_check_rfmon_datalink(device)) { wl_logerr("Cannot set interface to rfmon mode"); return 0; } else { wl_loginfo("Interface set to rfmon mode"); } @@ -147,41 +151,42 @@ int card_set_promisc_up (const char *device) return 1; } else { printf("%s flags could not be set", device); return 0; } } /* Set channel (Wireless frequency) of the device */ int card_set_channel (const char *device, int channel, int cardtype) { - if (cardtype == CARD_TYPE_CISCO) { /* Cisco cards don't need channelswitching */ return 1; } /* If it is a lucent orinocco card */ else if (cardtype == CARD_TYPE_ORINOCCO) { char lucentreset[63]; char lucentcmd[62]; - snprintf(lucentreset, sizeof(lucentreset) -1,"$(which iwpriv) %s card_reset", device); + snprintf(lucentreset, sizeof(lucentreset) -1,"$(which iwpriv) %s force_reset", device); if (system(lucentreset) != 0) { wl_logerr("Could not reset the card %s",device); return 0; } snprintf(lucentcmd, sizeof(lucentcmd) - 1, "$(which iwpriv) %s monitor 2 %d", device, channel); if (system(lucentcmd) != 0) { wl_logerr("Could not set %s in raw mode, check cardtype", device); return 0; } + wl_loginfo("Channel %d set on interface %s",channel,device); + return 1; } /* For undefined situations */ return 0; } |