summaryrefslogtreecommitdiff
authormax <max>2003-02-07 17:17:35 (UTC)
committer max <max>2003-02-07 17:17:35 (UTC)
commit014608882b23343473c5d0e7dca3ea09cf02dcfb (patch) (unidiff)
tree90eac99cbb0faca581cc9b5cc37a9fd460548050
parenta14c5974339f5beef433754d52c952cb99834619 (diff)
downloadopie-014608882b23343473c5d0e7dca3ea09cf02dcfb.zip
opie-014608882b23343473c5d0e7dca3ea09cf02dcfb.tar.gz
opie-014608882b23343473c5d0e7dca3ea09cf02dcfb.tar.bz2
Chanswitch
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/daemon/source/daemon.cc26
-rw-r--r--noncore/net/wellenreiter/daemon/source/daemon.hh1
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc9
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
@@ -8,24 +8,32 @@
8#include "daemon.hh" 8#include "daemon.hh"
9 9
10// temporary solution, will be removed soon 10// temporary solution, will be removed soon
11#define MAXCHANNEL 13 11#define MAXCHANNEL 13
12int card_type;
12char sniffer_device[6]; 13char sniffer_device[6];
13int channel=0; 14int channel=0;
14int timedout=1; 15int timedout=1;
15 16
16static int chanswitch() 17void chanswitch(int blah)
17{ 18{
18 if(channel >= MAXCHANNEL) 19 if(channel >= MAXCHANNEL)
19 channel=1 20 {
21 channel=1;
22 }
23 else
24 {
25 channel++;
26 }
20 card_set_channel(sniffer_device, channel, card_type); 27 card_set_channel(sniffer_device, channel, card_type);
21 timedout=0; 28 timedout=0;
29 alarm(1);
22} 30}
23 31
24/* Main function of wellenreiterd */ 32/* Main function of wellenreiterd */
25int main(int argc, char **argv) 33int main(int argc, char **argv)
26{ 34{
27 int sock, maxfd, retval, card_type; 35 int sock, maxfd, retval;
28 char buffer[WL_SOCKBUF]; 36 char buffer[WL_SOCKBUF];
29 struct pcap_pkthdr header; 37 struct pcap_pkthdr header;
30 struct sockaddr_in saddr; 38 struct sockaddr_in saddr;
31 pcap_t *handletopcap; 39 pcap_t *handletopcap;
@@ -39,17 +47,17 @@ int main(int argc, char **argv)
39 if(argc < 3) 47 if(argc < 3)
40 usage(); 48 usage();
41 49
42 // removed soon, see above 50 // removed soon, see above
43 SIGNAL(SIGALRM, chanswitch); 51 signal(SIGALRM, chanswitch);
44 52 alarm(1);
45 /* Set sniffer device */ 53 /* Set sniffer device */
46 memset(sniffer_device, 0, sizeof(sniffer_device)); 54 memset(sniffer_device, 0, sizeof(sniffer_device));
47 strncpy(sniffer_device, (char *)argv[1], sizeof(sniffer_device) - 1); 55 strncpy(sniffer_device, (char *)argv[1], sizeof(sniffer_device) - 1);
48 56
49 /* Set card type */ 57 /* Set card type */
50 card_type = atoi(argv[2]); 58 card_type = atoi(argv[2]);
51 if(card_type < 1 || card_type > 3) 59 if(card_type < 1 || card_type > 4)
52 usage(); 60 usage();
53 61
54 if(!card_into_monitormode(&handletopcap, sniffer_device, card_type)) 62 if(!card_into_monitormode(&handletopcap, sniffer_device, card_type))
55 { 63 {
@@ -90,9 +98,8 @@ int main(int argc, char **argv)
90 FD_SET(pcap_fileno(handletopcap), &rset); 98 FD_SET(pcap_fileno(handletopcap), &rset);
91 99
92 // blah 100 // blah
93 timedout=1; 101 timedout=1;
94 alarm(1);
95 102
96 /* socket or pcap handle bigger? Will be cleaned up, have to check pcap */ 103 /* socket or pcap handle bigger? Will be cleaned up, have to check pcap */
97 maxfd = (sock > pcap_fileno(handletopcap) ? sock : pcap_fileno(handletopcap)) + 1; 104 maxfd = (sock > pcap_fileno(handletopcap) ? sock : pcap_fileno(handletopcap)) + 1;
98 105
@@ -149,9 +156,10 @@ int main(int argc, char **argv)
149void usage(void) 156void usage(void)
150{ 157{
151 fprintf(stderr, "Usage: wellenreiter <device> <cardtype>\n" \ 158 fprintf(stderr, "Usage: wellenreiter <device> <cardtype>\n" \
152 "\t<device> = Wirelessdevice (e.g. wlan0)\n" \ 159 "\t<device> = Wirelessdevice (e.g. wlan0)\n" \
153 "\t<cardtype> = Cardtype:\t Cisco\t= 1\n" \ 160 "\t<cardtype> = Cardtype:\tCisco\t= 1\n" \
154 "\t\t\t\tNG\t= 2\n" \ 161 "\t\t\t\tNG\t= 2\n" \
155 "\t\t\t\tHOSTAP\t= 3\n"); 162 "\t\t\t\tHOSTAP\t= 3\n" \
163 "\t\t\t\tLUCENT\t= 4\n");
156 exit(-1); 164 exit(-1);
157} 165}
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
@@ -11,8 +11,9 @@
11#include <netinet/in.h> 11#include <netinet/in.h>
12#include <arpa/inet.h> 12#include <arpa/inet.h>
13#include <unistd.h> 13#include <unistd.h>
14#include <errno.h> 14#include <errno.h>
15#include <signal.h>
15 16
16#include <libwellenreiter/source/wl_sock.hh> 17#include <libwellenreiter/source/wl_sock.hh>
17#include <libwellenreiter/source/wl_log.hh> 18#include <libwellenreiter/source/wl_log.hh>
18#include <libwellenreiter/source/wl_types.hh> 19#include <libwellenreiter/source/wl_types.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
@@ -72,8 +72,12 @@ int card_into_monitormode (pcap_t **orighandle, char *device, int cardtype)
72 { 72 {
73 wl_logerr("Could not set %s in raw mode, check cardtype", device); 73 wl_logerr("Could not set %s in raw mode, check cardtype", device);
74 return 0; 74 return 0;
75 } 75 }
76 else
77 {
78 wl_loginfo("Successfully set %s into raw mode",device);
79 }
76 } 80 }
77 81
78 /* Setting the promiscous and up flag to the interface */ 82 /* Setting the promiscous and up flag to the interface */
79 if (!card_check_rfmon_datalink(device)) 83 if (!card_check_rfmon_datalink(device))
@@ -155,9 +159,8 @@ int card_set_promisc_up (const char *device)
155 159
156/* Set channel (Wireless frequency) of the device */ 160/* Set channel (Wireless frequency) of the device */
157int card_set_channel (const char *device, int channel, int cardtype) 161int card_set_channel (const char *device, int channel, int cardtype)
158{ 162{
159
160 if (cardtype == CARD_TYPE_CISCO) 163 if (cardtype == CARD_TYPE_CISCO)
161 { 164 {
162 /* Cisco cards don't need channelswitching */ 165 /* Cisco cards don't need channelswitching */
163 return 1; 166 return 1;
@@ -166,9 +169,9 @@ int card_set_channel (const char *device, int channel, int cardtype)
166 else if (cardtype == CARD_TYPE_ORINOCCO) 169 else if (cardtype == CARD_TYPE_ORINOCCO)
167 { 170 {
168 char lucentreset[63]; 171 char lucentreset[63];
169 char lucentcmd[62]; 172 char lucentcmd[62];
170 snprintf(lucentreset, sizeof(lucentreset) -1,"$(which iwpriv) %s card_reset", device); 173 snprintf(lucentreset, sizeof(lucentreset) -1,"$(which iwpriv) %s force_reset", device);
171 if (system(lucentreset) != 0) 174 if (system(lucentreset) != 0)
172 { 175 {
173 wl_logerr("Could not reset the card %s",device); 176 wl_logerr("Could not reset the card %s",device);
174 return 0; 177 return 0;
@@ -178,8 +181,10 @@ int card_set_channel (const char *device, int channel, int cardtype)
178 { 181 {
179 wl_logerr("Could not set %s in raw mode, check cardtype", device); 182 wl_logerr("Could not set %s in raw mode, check cardtype", device);
180 return 0; 183 return 0;
181 } 184 }
185 wl_loginfo("Channel %d set on interface %s",channel,device);
186 return 1;
182 } 187 }
183 188
184 /* For undefined situations */ 189 /* For undefined situations */
185 return 0; 190 return 0;