summaryrefslogtreecommitdiff
authormax <max>2003-02-18 09:31:47 (UTC)
committer max <max>2003-02-18 09:31:47 (UTC)
commit065f26b161f6df269cfbf9c75751c09453350995 (patch) (unidiff)
tree0d242028eadc37ecc9afa38af676906998d92329
parent3d8495ee454395e95190693af9baa9420f90431f (diff)
downloadopie-065f26b161f6df269cfbf9c75751c09453350995.zip
opie-065f26b161f6df269cfbf9c75751c09453350995.tar.gz
opie-065f26b161f6df269cfbf9c75751c09453350995.tar.bz2
Remove-promisc-flag
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc70
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh3
2 files changed, 72 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
index d385df4..7c9fbc4 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
@@ -1,346 +1,416 @@
1/* 1/*
2 * Set card modes for sniffing 2 * Set card modes for sniffing
3 * 3 *
4 * $Id$ 4 * $Id$
5 */ 5 */
6 6
7#include "cardmode.hh" 7#include "cardmode.hh"
8#include "wl_log.hh" 8#include "wl_log.hh"
9 9
10/* main card into monitor function */ 10/* main card into monitor function */
11int card_into_monitormode (pcap_t **orighandle, const char *device, int cardtype) 11int card_into_monitormode (pcap_t **orighandle, const char *device, int cardtype)
12{ 12{
13 char CiscoRFMON[35] = "/proc/driver/aironet/"; 13 char CiscoRFMON[35] = "/proc/driver/aironet/";
14 FILE *CISCO_CONFIG_FILE; 14 FILE *CISCO_CONFIG_FILE;
15 15
16 /* Checks if we have a device to sniff on */ 16 /* Checks if we have a device to sniff on */
17 if(device == NULL) 17 if(device == NULL)
18 { 18 {
19 wl_logerr("No device given"); 19 wl_logerr("No device given");
20 return 0; 20 return 0;
21 } 21 }
22 22
23 /* Setting the promiscous and up flag to the interface */ 23 /* Setting the promiscous and up flag to the interface */
24 if (!card_set_promisc_up(device)) 24 if (!card_set_promisc_up(device))
25 { 25 {
26 wl_logerr("Cannot set interface to promisc mode"); 26 wl_logerr("Cannot set interface to promisc mode");
27 return 0; 27 return 0;
28 } 28 }
29 wl_loginfo("Interface set to promisc mode"); 29 wl_loginfo("Interface set to promisc mode");
30 30
31 /* Check the cardtype and executes the commands to go into monitor mode */ 31 /* Check the cardtype and executes the commands to go into monitor mode */
32 if (cardtype == CARD_TYPE_CISCO) 32 if (cardtype == CARD_TYPE_CISCO)
33 { 33 {
34 /* bring the sniffer into rfmon mode */ 34 /* bring the sniffer into rfmon mode */
35 snprintf(CiscoRFMON, sizeof(CiscoRFMON) - 1, DEFAULT_PATH, device); 35 snprintf(CiscoRFMON, sizeof(CiscoRFMON) - 1, DEFAULT_PATH, device);
36 if((CISCO_CONFIG_FILE = fopen(CiscoRFMON,"w")) == NULL) 36 if((CISCO_CONFIG_FILE = fopen(CiscoRFMON,"w")) == NULL)
37 { 37 {
38 wl_logerr("Cannot open config file: %s", strerror(errno)); 38 wl_logerr("Cannot open config file: %s", strerror(errno));
39 return 0; 39 return 0;
40 } 40 }
41 fputs ("Mode: r",CISCO_CONFIG_FILE); 41 fputs ("Mode: r",CISCO_CONFIG_FILE);
42 fputs ("Mode: y",CISCO_CONFIG_FILE); 42 fputs ("Mode: y",CISCO_CONFIG_FILE);
43 fputs ("XmitPower: 1",CISCO_CONFIG_FILE); 43 fputs ("XmitPower: 1",CISCO_CONFIG_FILE);
44 fclose(CISCO_CONFIG_FILE); 44 fclose(CISCO_CONFIG_FILE);
45 } 45 }
46 else if (cardtype == CARD_TYPE_NG) 46 else if (cardtype == CARD_TYPE_NG)
47 { 47 {
48 char wlanngcmd[80]; 48 char wlanngcmd[80];
49 snprintf(wlanngcmd, sizeof(wlanngcmd) - 1, "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=true", device, 1); 49 snprintf(wlanngcmd, sizeof(wlanngcmd) - 1, "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=true", device, 1);
50 if (system(wlanngcmd) != 0) 50 if (system(wlanngcmd) != 0)
51 { 51 {
52 wl_logerr("Could not set %s in raw mode, check cardtype", device); 52 wl_logerr("Could not set %s in raw mode, check cardtype", device);
53 return 0; 53 return 0;
54 } 54 }
55 } 55 }
56 else if (cardtype == CARD_TYPE_HOSTAP) 56 else if (cardtype == CARD_TYPE_HOSTAP)
57 { 57 {
58#if WIRELESS_EXT > 14 58#if WIRELESS_EXT > 14
59 // IW_MODE_MONITOR was implemented in Wireless Extensions Version 15 59 // IW_MODE_MONITOR was implemented in Wireless Extensions Version 15
60 int skfd; 60 int skfd;
61 skfd = socket(AF_INET, SOCK_STREAM, 0); 61 skfd = socket(AF_INET, SOCK_STREAM, 0);
62 struct iwreq wrq; 62 struct iwreq wrq;
63 wrq.u.mode = IW_MODE_MONITOR; 63 wrq.u.mode = IW_MODE_MONITOR;
64 64
65 if(iw_set_ext(skfd,(char *) device,SIOCSIWMODE,&wrq)<0) 65 if(iw_set_ext(skfd,(char *) device,SIOCSIWMODE,&wrq)<0)
66 { 66 {
67 wl_logerr("Could not set hostap card %s to raw mode, check cardtype", device); 67 wl_logerr("Could not set hostap card %s to raw mode, check cardtype", device);
68 return 0; 68 return 0;
69 } 69 }
70 else 70 else
71 { 71 {
72 wl_loginfo("Successfully set hostap card %s into raw mode",device); 72 wl_loginfo("Successfully set hostap card %s into raw mode",device);
73 return 1; 73 return 1;
74 } 74 }
75 return 1; 75 return 1;
76#else 76#else
77 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring 77 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring
78 int fd; 78 int fd;
79 //Wireless tools structure for the iocalls 79 //Wireless tools structure for the iocalls
80 struct iwreq ireq; 80 struct iwreq ireq;
81 int *ptr; 81 int *ptr;
82 /* Socket needed to use the iocall to */ 82 /* Socket needed to use the iocall to */
83 fd = socket(AF_INET, SOCK_STREAM, 0); 83 fd = socket(AF_INET, SOCK_STREAM, 0);
84 84
85 if ( fd == -1 ) { 85 if ( fd == -1 ) {
86 return -1; 86 return -1;
87 } 87 }
88 88
89 ptr = (int *) ireq.u.name; 89 ptr = (int *) ireq.u.name;
90 // This is the monitor mode for 802.11 non-prism header 90 // This is the monitor mode for 802.11 non-prism header
91 ptr[0] = 2; 91 ptr[0] = 2;
92 strcpy(ireq.ifr_ifrn.ifrn_name, device); 92 strcpy(ireq.ifr_ifrn.ifrn_name, device);
93 if (ioctl( fd, SIOCDEVPRIVATE, &ireq)==0) 93 if (ioctl( fd, SIOCDEVPRIVATE, &ireq)==0)
94 { 94 {
95 /* All was fine... */ 95 /* All was fine... */
96 close(fd); 96 close(fd);
97 wl_loginfo("Set hostap card %s into monitormode",device); 97 wl_loginfo("Set hostap card %s into monitormode",device);
98 return 1; 98 return 1;
99 } 99 }
100 else 100 else
101 { 101 {
102 /* iocall does not work */ 102 /* iocall does not work */
103 close(fd); 103 close(fd);
104 wl_logerr("Could not set hostap card %s into monitormode, check cardtype",device); 104 wl_logerr("Could not set hostap card %s into monitormode, check cardtype",device);
105 return 0; 105 return 0;
106 } 106 }
107#endif 107#endif
108 } 108 }
109 else if (cardtype == CARD_TYPE_ORINOCCO ) 109 else if (cardtype == CARD_TYPE_ORINOCCO )
110 { 110 {
111 if (!card_set_channel (device, 1, CARD_TYPE_ORINOCCO)) 111 if (!card_set_channel (device, 1, CARD_TYPE_ORINOCCO))
112 { 112 {
113 wl_logerr("Could not set %s in raw mode, check cardtype", device); 113 wl_logerr("Could not set %s in raw mode, check cardtype", device);
114 return 0; 114 return 0;
115 } 115 }
116 else 116 else
117 { 117 {
118 wl_loginfo("Successfully set %s into raw mode",device); 118 wl_loginfo("Successfully set %s into raw mode",device);
119 } 119 }
120 } 120 }
121 121
122 /* Setting the promiscous and up flag to the interface */ 122 /* Setting the promiscous and up flag to the interface */
123 if (!card_check_rfmon_datalink(device)) 123 if (!card_check_rfmon_datalink(device))
124 { 124 {
125 wl_logerr("Cannot set interface to rfmon mode"); 125 wl_logerr("Cannot set interface to rfmon mode");
126 return 0; 126 return 0;
127 } 127 }
128 else 128 else
129 { 129 {
130 wl_loginfo("Interface set to rfmon mode"); 130 wl_loginfo("Interface set to rfmon mode");
131 } 131 }
132 return 1; 132 return 1;
133} 133}
134 134
135/* Check card is in the rfmon mode */ 135/* Check card is in the rfmon mode */
136int card_check_rfmon_datalink (const char *device) 136int card_check_rfmon_datalink (const char *device)
137{ 137{
138 int datalinktype=0; 138 int datalinktype=0;
139 pcap_t *phandle; 139 pcap_t *phandle;
140 phandle = pcap_open_live((char *)device, 65,0,0,NULL); 140 phandle = pcap_open_live((char *)device, 65,0,0,NULL);
141 datalinktype = pcap_datalink (phandle); 141 datalinktype = pcap_datalink (phandle);
142 pcap_close(phandle); 142 pcap_close(phandle);
143 143
144 if (datalinktype != DLT_IEEE802_11) /* Rawmode is IEEE802_11 */ 144 if (datalinktype != DLT_IEEE802_11) /* Rawmode is IEEE802_11 */
145 { 145 {
146 return 0; 146 return 0;
147 } 147 }
148 else 148 else
149 { 149 {
150 wl_loginfo("Your successfully listen on %s in 802.11 raw mode", device); 150 wl_loginfo("Your successfully listen on %s in 802.11 raw mode", device);
151 return 1; 151 return 1;
152 } 152 }
153} 153}
154 154
155/* Set card into promisc mode */ 155/* Set card into promisc mode */
156int card_set_promisc_up (const char *device) 156int card_set_promisc_up (const char *device)
157{ 157{
158 int err; 158 int err;
159 /* First generate a socket to use with iocalls */ 159 /* First generate a socket to use with iocalls */
160 int fd = socket(AF_INET, SOCK_DGRAM, 0); 160 int fd = socket(AF_INET, SOCK_DGRAM, 0);
161 if (fd < 0) 161 if (fd < 0)
162 { 162 {
163 /* In case of an error */ 163 /* In case of an error */
164 perror("socket"); 164 perror("socket");
165 return 0; 165 return 0;
166 } 166 }
167 167
168 /* Fill an empty an interface structure with the right flags (UP and Promsic) */ 168 /* Fill an empty an interface structure with the right flags (UP and Promsic) */
169 struct ifreq ifr; 169 struct ifreq ifr;
170 strncpy(ifr.ifr_name, device,10); 170 strncpy(ifr.ifr_name, device,10);
171 ifr.ifr_flags = IFF_UP + IFF_PROMISC; 171 ifr.ifr_flags = IFF_UP + IFF_PROMISC;
172 err = ioctl(fd, SIOCSIFFLAGS, &ifr); 172 err = ioctl(fd, SIOCSIFFLAGS, &ifr);
173 if (err < 0) 173 if (err < 0)
174 { 174 {
175 perror("Could not access the interface, "); 175 perror("Could not access the interface, ");
176 close(fd); 176 close(fd);
177 return 0; 177 return 0;
178 } 178 }
179 179
180 /* Get the informations back from the interface to check if the flags are correct */ 180 /* Get the informations back from the interface to check if the flags are correct */
181 strncpy(ifr.ifr_name, device,10); 181 strncpy(ifr.ifr_name, device,10);
182 err = ioctl(fd, SIOCGIFFLAGS, &ifr); 182 err = ioctl(fd, SIOCGIFFLAGS, &ifr);
183 if (err < 0) 183 if (err < 0)
184 { 184 {
185 perror("Could not access the interface, "); 185 perror("Could not access the interface, ");
186 close(fd); 186 close(fd);
187 return 0; 187 return 0;
188 } 188 }
189 189
190 if(ifr.ifr_flags && IFF_UP) 190 if(ifr.ifr_flags && IFF_UP)
191 { 191 {
192 close(fd); 192 close(fd);
193 return 1; 193 return 1;
194 } 194 }
195 else 195 else
196 { 196 {
197 wl_logerr("Could not set promisc flag on %d", device); 197 wl_logerr("Could not set promisc flag on %d", device);
198 close(fd); 198 close(fd);
199 return 0; 199 return 0;
200 } 200 }
201} 201}
202 202
203/* Remove card from promisc mode */
204int card_remove_promisc (const char *device)
205{
206 int err;
207 /* First generate a socket to use with iocalls */
208 int fd = socket(AF_INET, SOCK_DGRAM, 0);
209 if (fd < 0)
210 {
211 /* In case of an error */
212 perror("socket");
213 return 0;
214 }
215
216 /* Fill an empty an interface structure with the right flags (UP and Promsic) */
217 struct ifreq ifr;
218/* strncpy(ifr.ifr_name, device,10);
219 ifr.ifr_flags = IFF_UP + IFF_PROMISC;
220 err = ioctl(fd, SIOCSIFFLAGS, &ifr);
221 if (err < 0)
222 {
223 perror("Could not access the interface, ");
224 close(fd);
225 return 0;
226 }
227 */
228 /* Get the flags from the interface*/
229 strncpy(ifr.ifr_name, device,10);
230 err = ioctl(fd, SIOCGIFFLAGS, &ifr);
231 if (err < 0)
232 {
233 perror("Could not access the interface, ");
234 close(fd);
235 return 0;
236 }
237 /* Remove the IFF_PROMISC flag */
238 ifr.ifr_flags = ifr.ifr_flags - IFF_PROMISC;
239 /*Set the new flags to the interface*/
240 err = ioctl(fd, SIOCSIFFLAGS, &ifr);
241 if (err < 0)
242 {
243 perror("Could not access the interface, ");
244 close(fd);
245 return 0;
246 }
247
248 /* Get the flags again to check if IFF_PROMISC is removed */
249 err = ioctl(fd, SIOCGIFFLAGS, &ifr);
250 if (err < 0)
251 {
252 perror("Could not access the interface, ");
253 close(fd);
254 return 0;
255 }
256 if(ifr.ifr_flags && IFF_PROMISC)
257 {
258 wl_logerr("Could not remove the promisc flag on %d", device);
259 close(fd);
260 return 0;
261 }
262 else
263 {
264 /* Successfully removed the promisc flags */
265 close(fd);
266 return 1;
267 }
268}
269
270
271
272
203/* Set channel (Wireless frequency) of the device */ 273/* Set channel (Wireless frequency) of the device */
204int card_set_channel (const char *device, int channel, int cardtype) 274int card_set_channel (const char *device, int channel, int cardtype)
205{ 275{
206 if (cardtype == CARD_TYPE_CISCO || cardtype == CARD_TYPE_NG) 276 if (cardtype == CARD_TYPE_CISCO || cardtype == CARD_TYPE_NG)
207 { 277 {
208 /* Cisco and wlan-ng drivers don't need channelswitching */ 278 /* Cisco and wlan-ng drivers don't need channelswitching */
209 return 1; 279 return 1;
210 } 280 }
211 /* If it is a lucent orinocco card */ 281 /* If it is a lucent orinocco card */
212 else if (cardtype == CARD_TYPE_ORINOCCO) 282 else if (cardtype == CARD_TYPE_ORINOCCO)
213 { 283 {
214 int fd; 284 int fd;
215 //Wireless tools structure for the iocalls 285 //Wireless tools structure for the iocalls
216 struct iwreq ireq; 286 struct iwreq ireq;
217 int *ptr; 287 int *ptr;
218 /* Socket needed to use the iocall to */ 288 /* Socket needed to use the iocall to */
219 fd = socket(AF_INET, SOCK_STREAM, 0); 289 fd = socket(AF_INET, SOCK_STREAM, 0);
220 290
221 if ( fd == -1 ) { 291 if ( fd == -1 ) {
222 return -1; 292 return -1;
223 } 293 }
224 294
225 ptr = (int *) ireq.u.name; 295 ptr = (int *) ireq.u.name;
226 // This is the monitor mode for 802.11 non-prism header 296 // This is the monitor mode for 802.11 non-prism header
227 ptr[0] = 2; 297 ptr[0] = 2;
228 ptr[1] = channel; 298 ptr[1] = channel;
229 strcpy(ireq.ifr_ifrn.ifrn_name, device); 299 strcpy(ireq.ifr_ifrn.ifrn_name, device);
230 if (ioctl( fd, SIOCIWFIRSTPRIV + 0x8, &ireq)==0) 300 if (ioctl( fd, SIOCIWFIRSTPRIV + 0x8, &ireq)==0)
231 { 301 {
232 /* All was fine... */ 302 /* All was fine... */
233 close(fd); 303 close(fd);
234 wl_loginfo("Set channel %d on interface %s",channel, device); 304 wl_loginfo("Set channel %d on interface %s",channel, device);
235 return 1; 305 return 1;
236 } 306 }
237 else 307 else
238 { 308 {
239 /* iocall does not work */ 309 /* iocall does not work */
240 close(fd); 310 close(fd);
241 wl_logerr("Could not set channel %d on %s, check cardtype",channel, device); 311 wl_logerr("Could not set channel %d on %s, check cardtype",channel, device);
242 return 0; 312 return 0;
243 } 313 }
244 } 314 }
245 /* when it is an hostap card you need another iocall for channel switching */ 315 /* when it is an hostap card you need another iocall for channel switching */
246 else if (cardtype == CARD_TYPE_HOSTAP) 316 else if (cardtype == CARD_TYPE_HOSTAP)
247 { 317 {
248 int skfd; 318 int skfd;
249 skfd = socket(AF_INET, SOCK_STREAM, 0); 319 skfd = socket(AF_INET, SOCK_STREAM, 0);
250 struct iwreq wrq; 320 struct iwreq wrq;
251 iw_float2freq((double) channel, &wrq.u.freq); 321 iw_float2freq((double) channel, &wrq.u.freq);
252 322
253 if(iw_set_ext(skfd,(char *) device,SIOCSIWFREQ,&wrq)<0) 323 if(iw_set_ext(skfd,(char *) device,SIOCSIWFREQ,&wrq)<0)
254 { 324 {
255 wl_logerr("Could not set hostap card %s to channel %d", device, channel); 325 wl_logerr("Could not set hostap card %s to channel %d", device, channel);
256 return 0; 326 return 0;
257 } 327 }
258 else 328 else
259 { 329 {
260 wl_loginfo("Successfully set hostap card %s to channel %d", device, channel); 330 wl_loginfo("Successfully set hostap card %s to channel %d", device, channel);
261 return 1; 331 return 1;
262 } 332 }
263 } 333 }
264 /* For undefined situations */ 334 /* For undefined situations */
265 return 0; 335 return 0;
266} 336}
267 337
268 338
269int card_detect_channels (char * device) 339int card_detect_channels (char * device)
270{ 340{
271 int skfd; 341 int skfd;
272 skfd = socket(AF_INET, SOCK_STREAM, 0); 342 skfd = socket(AF_INET, SOCK_STREAM, 0);
273 struct iw_rangerange; 343 struct iw_rangerange;
274 /* Get list of frequencies / channels */ 344 /* Get list of frequencies / channels */
275 printf ("\n hostap card get the frequencies"); 345 printf ("\n hostap card get the frequencies");
276 /* Get list of frequencies / channels */ 346 /* Get list of frequencies / channels */
277 if(iw_get_range_info(skfd, device, &range) < 0) 347 if(iw_get_range_info(skfd, device, &range) < 0)
278 { /* We are failsave if something went wrong, asume only 11 channels */ 348 { /* We are failsave if something went wrong, asume only 11 channels */
279 return 11; 349 return 11;
280 } 350 }
281 else 351 else
282 { 352 {
283 if(range.num_frequency > 0) 353 if(range.num_frequency > 0)
284 { 354 {
285 return range.num_frequency; 355 return range.num_frequency;
286 } 356 }
287 else 357 else
288 { /* We are failsave asume only 11 channels */ 358 { /* We are failsave asume only 11 channels */
289 return 11; 359 return 11;
290 } 360 }
291 } 361 }
292 362
293} /* End of card_detect_channels */ 363} /* End of card_detect_channels */
294 364
295int iw_get_range_info(int skfd, const char * ifname, iw_range * range) 365int iw_get_range_info(int skfd, const char * ifname, iw_range * range)
296{ 366{
297 struct iwreq wrq2; 367 struct iwreq wrq2;
298 char buffer[sizeof(iw_range) * 2];/* Large enough */ 368 char buffer[sizeof(iw_range) * 2];/* Large enough */
299 369
300 /* Cleanup */ 370 /* Cleanup */
301 memset(buffer, 0, sizeof(buffer)); 371 memset(buffer, 0, sizeof(buffer));
302 wrq2.u.data.pointer = (caddr_t) buffer; 372 wrq2.u.data.pointer = (caddr_t) buffer;
303 wrq2.u.data.length = sizeof(buffer); 373 wrq2.u.data.length = sizeof(buffer);
304 wrq2.u.data.flags = 0; 374 wrq2.u.data.flags = 0;
305 375
306 if(iw_get_ext(skfd, (char *)ifname, SIOCGIWRANGE, &wrq2) < 0) 376 if(iw_get_ext(skfd, (char *)ifname, SIOCGIWRANGE, &wrq2) < 0)
307 { 377 {
308 wl_logerr("Could not get the range from the interface"); 378 wl_logerr("Could not get the range from the interface");
309 return(-1); 379 return(-1);
310 } 380 }
311 else 381 else
312 { 382 {
313 /* Copy stuff at the right place, ignore extra */ 383 /* Copy stuff at the right place, ignore extra */
314 memcpy((char *) range, buffer, sizeof(iw_range)); 384 memcpy((char *) range, buffer, sizeof(iw_range));
315 return 0; 385 return 0;
316 } 386 }
317} 387}
318 388
319/*------------------------------------------------------------------*/ 389/*------------------------------------------------------------------*/
320/* 390/*
321 * Convert our internal representation of frequencies to a floating point. 391 * Convert our internal representation of frequencies to a floating point.
322 */ 392 */
323double iw_freq2float(iw_freq * in) 393double iw_freq2float(iw_freq * in)
324{ 394{
325 int i; 395 int i;
326 double res = (double) in->m; 396 double res = (double) in->m;
327 for(i = 0; i < in->e; i++) 397 for(i = 0; i < in->e; i++)
328 res *= 10; 398 res *= 10;
329 return(res); 399 return(res);
330} 400}
331 401
332 402
333 void iw_float2freq(double in, iw_freq *out) 403 void iw_float2freq(double in, iw_freq *out)
334{ 404{
335 /* Version without libm : slower */ 405 /* Version without libm : slower */
336 out->e = 0; 406 out->e = 0;
337 while(in > 1e9) 407 while(in > 1e9)
338 { 408 {
339 in /= 10; 409 in /= 10;
340 out->e++; 410 out->e++;
341 } 411 }
342 out->m = (long) in; 412 out->m = (long) in;
343} 413}
344 414
345 415
346 416
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh
index b35dddd..652b3ed 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh
+++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh
@@ -1,93 +1,94 @@
1/* $Id$ */ 1/* $Id$ */
2 2
3#ifndef CARDMODE_HH 3#ifndef CARDMODE_HH
4#define CARDMODE_HH 4#define CARDMODE_HH
5 5
6#include <string.h> 6#include <string.h>
7#include <stdlib.h> 7#include <stdlib.h>
8#include <errno.h> 8#include <errno.h>
9#include <sys/types.h> 9#include <sys/types.h>
10#include <sys/time.h> 10#include <sys/time.h>
11#include <sys/socket.h> 11#include <sys/socket.h>
12#include <netinet/in.h> 12#include <netinet/in.h>
13#include <arpa/inet.h> 13#include <arpa/inet.h>
14#include <sys/ioctl.h> 14#include <sys/ioctl.h>
15#include <unistd.h> 15#include <unistd.h>
16#include <linux/if.h> 16#include <linux/if.h>
17#include <linux/wireless.h> 17#include <linux/wireless.h>
18 18
19#ifndef SIOCIWFIRSTPRIV 19#ifndef SIOCIWFIRSTPRIV
20#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE 20#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
21#endif 21#endif
22 22
23 23
24extern "C" 24extern "C"
25{ 25{
26#include <net/bpf.h> 26#include <net/bpf.h>
27#include <pcap.h> 27#include <pcap.h>
28} 28}
29 29
30/* Defines, used for the card setup */ 30/* Defines, used for the card setup */
31#define DEFAULT_PATH "/proc/driver/aironet/%s/Config" 31#define DEFAULT_PATH "/proc/driver/aironet/%s/Config"
32#define CISCO_STATUS "/proc/driver/aironet/%s/Status" 32#define CISCO_STATUS "/proc/driver/aironet/%s/Status"
33 #define CARD_TYPE_CISCO 1 33 #define CARD_TYPE_CISCO 1
34 #define CARD_TYPE_NG 2 34 #define CARD_TYPE_NG 2
35 #define CARD_TYPE_HOSTAP3 35 #define CARD_TYPE_HOSTAP3
36#define CARD_TYPE_ORINOCCO 4 36#define CARD_TYPE_ORINOCCO 4
37 37
38/* Some usefull constants for frequencies */ 38/* Some usefull constants for frequencies */
39#define KILO 1e3 39#define KILO 1e3
40#define MEGA 1e6 40#define MEGA 1e6
41#define GIGA 1e9 41#define GIGA 1e9
42 42
43 43
44/* only for now, until we have the daemon running */ 44/* only for now, until we have the daemon running */
45/*the config file should provide these information */ 45/*the config file should provide these information */
46#define CARD_TYPE CARD_TYPE_HOSTAP 46#define CARD_TYPE CARD_TYPE_HOSTAP
47 47
48/* Prototypes */ 48/* Prototypes */
49int card_check_rfmon_datalink (const char *device); 49int card_check_rfmon_datalink (const char *device);
50int card_into_monitormode (pcap_t **, const char *, int); 50int card_into_monitormode (pcap_t **, const char *, int);
51int card_set_promisc_up (const char *); 51int card_set_promisc_up (const char *device);
52int card_remove_promisc (const char *device);
52int card_set_channel (const char *device, int channel,int cardtype); 53int card_set_channel (const char *device, int channel,int cardtype);
53int iw_get_range_info(int skfd, const char * ifname, struct iw_range * range); 54int iw_get_range_info(int skfd, const char * ifname, struct iw_range * range);
54double iw_freq2float(iw_freq * in); 55double iw_freq2float(iw_freq * in);
55 void iw_float2freq(double in, iw_freq *out); 56 void iw_float2freq(double in, iw_freq *out);
56int card_detect_channels (char * device); 57int card_detect_channels (char * device);
57 58
58 59
59/*------------------------------------------------------------------*/ 60/*------------------------------------------------------------------*/
60/* 61/*
61 * Wrapper to push some Wireless Parameter in the driver 62 * Wrapper to push some Wireless Parameter in the driver
62 */ 63 */
63static inline int 64static inline int
64 iw_set_ext(int skfd, /* Socket to the kernel */ 65 iw_set_ext(int skfd, /* Socket to the kernel */
65 char * ifname, /* Device name */ 66 char * ifname, /* Device name */
66 int request,/* WE ID */ 67 int request,/* WE ID */
67 struct iwreq * pwrq) /* Fixed part of the request */ 68 struct iwreq * pwrq) /* Fixed part of the request */
68{ 69{
69 /* Set device name */ 70 /* Set device name */
70 strncpy(pwrq->ifr_name, ifname, IFNAMSIZ); 71 strncpy(pwrq->ifr_name, ifname, IFNAMSIZ);
71 /* Do the request */ 72 /* Do the request */
72 return(ioctl(skfd, request, pwrq)); 73 return(ioctl(skfd, request, pwrq));
73} 74}
74 75
75/*------------------------------------------------------------------*/ 76/*------------------------------------------------------------------*/
76/* 77/*
77 * Wrapper to extract some Wireless Parameter out of the driver 78 * Wrapper to extract some Wireless Parameter out of the driver
78 */ 79 */
79static inline int 80static inline int
80 iw_get_ext(int skfd, /* Socket to the kernel */ 81 iw_get_ext(int skfd, /* Socket to the kernel */
81 char * ifname, /* Device name */ 82 char * ifname, /* Device name */
82 int request,/* WE ID */ 83 int request,/* WE ID */
83 struct iwreq * pwrq) /* Fixed part of the request */ 84 struct iwreq * pwrq) /* Fixed part of the request */
84{ 85{
85 /* Set device name */ 86 /* Set device name */
86 strncpy(pwrq->ifr_name, ifname, IFNAMSIZ); 87 strncpy(pwrq->ifr_name, ifname, IFNAMSIZ);
87 /* Do the request */ 88 /* Do the request */
88 return(ioctl(skfd, request, pwrq)); 89 return(ioctl(skfd, request, pwrq));
89} 90}
90 91
91 92
92 93
93#endif /* CARDMODE_HH */ 94#endif /* CARDMODE_HH */