summaryrefslogtreecommitdiff
authormax <max>2003-02-07 10:28:23 (UTC)
committer max <max>2003-02-07 10:28:23 (UTC)
commit9bbfe155d26fe42ecb31744de0525a1f854b7ca5 (patch) (unidiff)
treefefae4afc0dfcb51b8581e67f7b284ed68bc6a92
parente73acff447949c3e87da87e0749ccefac448d650 (diff)
downloadopie-9bbfe155d26fe42ecb31744de0525a1f854b7ca5.zip
opie-9bbfe155d26fe42ecb31744de0525a1f854b7ca5.tar.gz
opie-9bbfe155d26fe42ecb31744de0525a1f854b7ca5.tar.bz2
Monitor commands and set_card_channel
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc43
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh8
2 files changed, 48 insertions, 3 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
index d868438..697d182 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
@@ -61,12 +61,22 @@ int card_into_monitormode (pcap_t **orighandle, char *device, int cardtype)
61 if (system(hostapcmd) !=0) 61 if (system(hostapcmd) !=0)
62 { 62 {
63 wl_logerr("Could not set %s in raw mode, check cardtype", device); 63 wl_logerr("Could not set %s in raw mode, check cardtype", device);
64 return 0; 64 return 0;
65 } 65 }
66 } 66 }
67 else if (cardtype == CARD_TYPE_ORINOCCO)
68 {
69 char lucentcmd[62];
70 snprintf(lucentcmd, sizeof(lucentcmd) - 1, "$(which iwpriv) %s monitor 2 %d", device, 1);
71 if (system(lucentcmd) != 0)
72 {
73 wl_logerr("Could not set %s in raw mode, check cardtype", device);
74 return 0;
75 }
76 }
67 77
68 /* Setting the promiscous and up flag to the interface */ 78 /* Setting the promiscous and up flag to the interface */
69 if (!card_check_rfmon_datalink(device)) 79 if (!card_check_rfmon_datalink(device))
70 { 80 {
71 wl_logerr("Cannot set interface to rfmon mode"); 81 wl_logerr("Cannot set interface to rfmon mode");
72 return 0; 82 return 0;
@@ -139,6 +149,39 @@ int card_set_promisc_up (const char *device)
139 else 149 else
140 { 150 {
141 printf("%s flags could not be set", device); 151 printf("%s flags could not be set", device);
142 return 0; 152 return 0;
143 } 153 }
144} 154}
155
156/* Set channel (Wireless frequency) of the device */
157int card_set_channel (const char *device, int channel, int cardtype)
158{
159
160 if (cardtype == CARD_TYPE_CISCO)
161 {
162 /* Cisco cards don't need channelswitching */
163 return 1;
164 }
165 /* If it is a lucent orinocco card */
166 else if (cardtype == CARD_TYPE_ORINOCCO)
167 {
168 char lucentreset[63];
169 char lucentcmd[62];
170 snprintf(lucentreset, sizeof(lucentreset) -1,"$(which iwpriv) %s card_reset", device);
171 if (system(lucentreset) != 0)
172 {
173 wl_logerr("Could not reset the card %s",device);
174 return 0;
175 }
176 snprintf(lucentcmd, sizeof(lucentcmd) - 1, "$(which iwpriv) %s monitor 2 %d", device, channel);
177 if (system(lucentcmd) != 0)
178 {
179 wl_logerr("Could not set %s in raw mode, check cardtype", device);
180 return 0;
181 }
182 }
183
184 /* For undefined situations */
185 return 0;
186}
187
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh
index 4eec122..3a1991b 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh
+++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh
@@ -19,24 +19,26 @@ extern "C"
19#include <net/bpf.h> 19#include <net/bpf.h>
20#include <pcap.h> 20#include <pcap.h>
21} 21}
22 22
23/* Defines, used for the card setup */ 23/* Defines, used for the card setup */
24#define DEFAULT_PATH "/proc/driver/aironet/%s/Config" 24#define DEFAULT_PATH "/proc/driver/aironet/%s/Config"
25 #define CISCO_STATUS "/proc/driver/aironet/%s/Status" 25#define CISCO_STATUS "/proc/driver/aironet/%s/Status"
26 #define CARD_TYPE_CISCO1 26 #define CARD_TYPE_CISCO 1
27 #define CARD_TYPE_NG 2 27 #define CARD_TYPE_NG 2
28 #define CARD_TYPE_HOSTAP3 28 #define CARD_TYPE_HOSTAP3
29#define CARD_TYPE_ORINOCCO 4
29 30
30/* only for now, until we have the daemon running */ 31/* only for now, until we have the daemon running */
31/*the config file should provide these information */ 32/*the config file should provide these information */
32#define CARD_TYPE CARD_TYPE_HOSTAP 33#define CARD_TYPE CARD_TYPE_HOSTAP
33 #define SBIN_PATH "/sbin/ifconfig %s promisc up" 34 #define SBIN_PATH "/sbin/ifconfig %s promisc up"
34#define WLANCTL_PATH "/sbin/wlanctl-ng" 35#define WLANCTL_PATH "/sbin/wlanctl-ng"
35 #define IWPRIV_PATH "/sbin/iwpriv" 36 #define IWPRIV_PATH "/sbin/iwpriv"
36 37
37/* Prototypes */ 38/* Prototypes */
38int card_check_rfmon_datalink (char *device); 39int card_check_rfmon_datalink (char *device);
39int card_into_monitormode (pcap_t **, char *, int); 40int card_into_monitormode (pcap_t **, char *, int);
40int card_set_promisc_up (const char *); 41int card_set_promisc_up (const char *);
42int card_set_channel (const char *device, int channel,int cardtype);
41 43
42#endif /* CARDMODE_HH */ 44#endif /* CARDMODE_HH */