summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc7
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh1
2 files changed, 8 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
index 7362f14..d462488 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
@@ -11,64 +11,71 @@
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 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: %s", strerror(errno)); 26 wl_logerr("Cannot set interface to promisc mode: %s", strerror(errno));
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[62]; 48 char wlanngcmd[62];
49 snprintf(wlanngcmd, sizeof(wlanngcmd) - 1, "%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);
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 wl_logerr("Got a host-ap card, nothing is implemented now"); 58 wl_logerr("Got a host-ap card, nothing is implemented now");
59 char hostapcmd[250];
60 snprintf(hostapcmd, sizeof(hostapcmd) -1, "%s %s monitor 2", IWPRIV_PATH, device);
61 if (system(hostapcmd) !=0)
62 {
63 wl_logerr("Could not set %s in raw mode, check cardtype", device);
64 return 0;
65 }
59 } 66 }
60 67
61 return 1; 68 return 1;
62} 69}
63 70
64/* Set card into promisc mode */ 71/* Set card into promisc mode */
65int card_set_promisc_up (const char *device) 72int card_set_promisc_up (const char *device)
66{ 73{
67 char ifconfigcmd[48]; 74 char ifconfigcmd[48];
68 int retval=0; 75 int retval=0;
69 76
70 snprintf(ifconfigcmd, sizeof(ifconfigcmd) - 1, SBIN_PATH, device); 77 snprintf(ifconfigcmd, sizeof(ifconfigcmd) - 1, SBIN_PATH, device);
71 retval = system(ifconfigcmd); 78 retval = system(ifconfigcmd);
72 79
73 return (retval ? 0 : 1); 80 return (retval ? 0 : 1);
74} 81}
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh
index b85b7b7..9721b39 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh
+++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh
@@ -1,36 +1,37 @@
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 13
14extern "C" 14extern "C"
15{ 15{
16#include <net/bpf.h> 16#include <net/bpf.h>
17#include <pcap.h> 17#include <pcap.h>
18} 18}
19 19
20/* Defines, used for the card setup */ 20/* Defines, used for the card setup */
21#define DEFAULT_PATH "/proc/driver/aironet/%s/Config" 21#define DEFAULT_PATH "/proc/driver/aironet/%s/Config"
22 #define CARD_TYPE_CISCO1 22 #define CARD_TYPE_CISCO1
23 #define CARD_TYPE_NG 2 23 #define CARD_TYPE_NG 2
24 #define CARD_TYPE_HOSTAP3 24 #define CARD_TYPE_HOSTAP3
25 25
26/* only for now, until we have the daemon running */ 26/* only for now, until we have the daemon running */
27/*the config file should provide these information */ 27/*the config file should provide these information */
28#define CARD_TYPE CARD_TYPE_HOSTAP 28#define CARD_TYPE CARD_TYPE_HOSTAP
29 #define SBIN_PATH "/sbin/ifconfig %s promisc up" 29 #define SBIN_PATH "/sbin/ifconfig %s promisc up"
30#define WLANCTL_PATH "/sbin/wlanctl-ng" 30#define WLANCTL_PATH "/sbin/wlanctl-ng"
31 #define IWPRIV_PATH "/sbin/iwpriv"
31 32
32/* Prototypes */ 33/* Prototypes */
33int card_into_monitormode (pcap_t **, char *, int); 34int card_into_monitormode (pcap_t **, char *, int);
34int card_set_promisc_up (const char *); 35int card_set_promisc_up (const char *);
35 36
36#endif /* CARDMODE_HH */ 37#endif /* CARDMODE_HH */