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 @@ -6,28 +6,36 @@ #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; @@ -37,21 +45,21 @@ int main(int argc, char **argv) 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); @@ -88,13 +96,12 @@ 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 && timedout) { @@ -147,11 +154,12 @@ int main(int argc, char **argv) } 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 @@ -9,12 +9,13 @@ #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> 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 @@ -70,12 +70,16 @@ int card_into_monitormode (pcap_t **orighandle, char *device, int cardtype) 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"); @@ -153,35 +157,36 @@ int card_set_promisc_up (const char *device) } } /* 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; } |