From 014608882b23343473c5d0e7dca3ea09cf02dcfb Mon Sep 17 00:00:00 2001 From: max Date: Fri, 07 Feb 2003 17:17:35 +0000 Subject: Chanswitch --- (limited to 'noncore') 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 @@ -9,22 +9,30 @@ // 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; @@ -40,15 +48,15 @@ int main(int argc, char **argv) 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)) @@ -91,7 +99,6 @@ int main(int argc, char **argv) // 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; @@ -150,8 +157,9 @@ void usage(void) { fprintf(stderr, "Usage: wellenreiter \n" \ "\t = Wirelessdevice (e.g. wlan0)\n" \ - "\t = Cardtype:\t Cisco\t= 1\n" \ + "\t = 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 @@ -12,6 +12,7 @@ #include #include #include +#include #include #include 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 @@ -73,6 +73,10 @@ int card_into_monitormode (pcap_t **orighandle, char *device, int cardtype) 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 */ @@ -156,7 +160,6 @@ 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 */ @@ -167,7 +170,7 @@ int card_set_channel (const char *device, int channel, int cardtype) { 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); @@ -179,6 +182,8 @@ int card_set_channel (const char *device, int channel, int cardtype) 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 */ -- cgit v0.9.0.2