summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
authormjm <mjm>2002-12-27 16:35:28 (UTC)
committer mjm <mjm>2002-12-27 16:35:28 (UTC)
commit3cb928900ffb1d2799bd7e8e1871aaf8d89b56cf (patch) (unidiff)
tree180016a8feae9e40c3e6b8be62b518bdf8ef18fc /noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
parente6aaae74f39e3aed4dc3c186c56f92cef8c7da09 (diff)
downloadopie-3cb928900ffb1d2799bd7e8e1871aaf8d89b56cf.zip
opie-3cb928900ffb1d2799bd7e8e1871aaf8d89b56cf.tar.gz
opie-3cb928900ffb1d2799bd7e8e1871aaf8d89b56cf.tar.bz2
cleanup, new protocol, renaming of some functions, GUI has to update!
Diffstat (limited to 'noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
index 3aaa4a7..c29f4d0 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
@@ -1,78 +1,77 @@
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 "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, char *device, int cardtype) 11int card_into_monitormode (pcap_t **orighandle, 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 pcap_t *handle = (pcap_t*)orighandle;
16 15
17 /* Checks if we have a device to sniff on */ 16 /* Checks if we have a device to sniff on */
18 if(device == NULL) 17 if(device == NULL)
19 { 18 {
20 wl_logerr("No device given"); 19 wl_logerr("No device given");
21 return 0; 20 return 0;
22 } 21 }
23 22
24 /* Setting the prmiscous and up flag to the interface */ 23 /* Setting the prmiscous and up flag to the interface */
25 if (!card_set_promisc_up(device)) 24 if (!card_set_promisc_up(device))
26 { 25 {
27 wl_logerr("Cannot set interface to promisc mode: %s", strerror(errno)); 26 wl_logerr("Cannot set interface to promisc mode: %s", strerror(errno));
28 return 0; 27 return 0;
29 } 28 }
30 wl_loginfo("Interface set to promisc mode"); 29 wl_loginfo("Interface set to promisc mode");
31 30
32 /* 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 */
33 if (cardtype == CARD_TYPE_CISCO) 32 if (cardtype == CARD_TYPE_CISCO)
34 { 33 {
35 /* bring the sniffer into rfmon mode */ 34 /* bring the sniffer into rfmon mode */
36 snprintf(CiscoRFMON, sizeof(CiscoRFMON), DEFAULT_PATH, device); 35 snprintf(CiscoRFMON, sizeof(CiscoRFMON) - 1, DEFAULT_PATH, device);
37 if((CISCO_CONFIG_FILE = fopen(CiscoRFMON,"w")) == NULL) 36 if((CISCO_CONFIG_FILE = fopen(CiscoRFMON,"w")) == NULL)
38 { 37 {
39 wl_logerr("Cannot open config file: %s", strerror(errno)); 38 wl_logerr("Cannot open config file: %s", strerror(errno));
40 return 0; 39 return 0;
41 } 40 }
42 fputs ("Mode: r",CISCO_CONFIG_FILE); 41 fputs ("Mode: r",CISCO_CONFIG_FILE);
43 fputs ("Mode: y",CISCO_CONFIG_FILE); 42 fputs ("Mode: y",CISCO_CONFIG_FILE);
44 fputs ("XmitPower: 1",CISCO_CONFIG_FILE); 43 fputs ("XmitPower: 1",CISCO_CONFIG_FILE);
45 fclose(CISCO_CONFIG_FILE); 44 fclose(CISCO_CONFIG_FILE);
46 } 45 }
47 else if (cardtype == CARD_TYPE_NG) 46 else if (cardtype == CARD_TYPE_NG)
48 { 47 {
49 char wlanngcmd[62]; 48 char wlanngcmd[62];
50 snprintf(wlanngcmd, sizeof(wlanngcmd), "%s %s lnxreq_wlansniff channel=1 enable=true", WLANCTL_PATH, device); 49 snprintf(wlanngcmd, sizeof(wlanngcmd) - 1, "%s %s lnxreq_wlansniff channel=1 enable=true", WLANCTL_PATH, device);
51 if (system(wlanngcmd) != 0) 50 if (system(wlanngcmd) != 0)
52 { 51 {
53 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);
54 return 0; 53 return 0;
55 } 54 }
56 } 55 }
57 else if (cardtype == CARD_TYPE_HOSTAP) 56 else if (cardtype == CARD_TYPE_HOSTAP)
58 { 57 {
59 wl_logerr("Got a host-ap card, nothing is implemented now"); 58 wl_logerr("Got a host-ap card, nothing is implemented now");
60 } 59 }
61 60
62 return 1; 61 return 1;
63} 62}
64 63
65/* Set card into promisc mode */ 64/* Set card into promisc mode */
66int card_set_promisc_up (const char *device) 65int card_set_promisc_up (const char *device)
67{ 66{
68 char ifconfigcmd[32]; 67 char ifconfigcmd[32];
69 int retval=0; 68 int retval=0;
70 69
71 snprintf(ifconfigcmd, sizeof(ifconfigcmd), SBIN_PATH, device); 70 snprintf(ifconfigcmd, sizeof(ifconfigcmd) - 1, SBIN_PATH, device);
72 retval = system(ifconfigcmd); 71 retval = system(ifconfigcmd);
73 72
74 if(retval != 0) 73 if(retval != 0)
75 return 0; 74 return 0;
76 75
77return 1; 76return 1;
78} 77}