-rw-r--r-- | noncore/net/wellenreiter/daemon/source/daemon.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.cc b/noncore/net/wellenreiter/daemon/source/daemon.cc index 46a50ed..d77d987 100644 --- a/noncore/net/wellenreiter/daemon/source/daemon.cc +++ b/noncore/net/wellenreiter/daemon/source/daemon.cc @@ -137,57 +137,66 @@ int main(int argc, char **argv) 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 */ } |