summaryrefslogtreecommitdiff
authormax <max>2002-11-23 21:20:13 (UTC)
committer max <max>2002-11-23 21:20:13 (UTC)
commit4e24ece4607d3b2f9e3252fa561fabaa9cdddd63 (patch) (unidiff)
tree96d3f4b07d3e352307f8f46eadf584156cfee86d
parent33320c654a5a7627dfa1a31d9b3a78fd8c03d363 (diff)
downloadopie-4e24ece4607d3b2f9e3252fa561fabaa9cdddd63.zip
opie-4e24ece4607d3b2f9e3252fa561fabaa9cdddd63.tar.gz
opie-4e24ece4607d3b2f9e3252fa561fabaa9cdddd63.tar.bz2
*** empty log message ***
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/daemon/source/cardmode.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/cardmode.cc b/noncore/net/wellenreiter/daemon/source/cardmode.cc
index ae32af4..f84ce23 100644
--- a/noncore/net/wellenreiter/daemon/source/cardmode.cc
+++ b/noncore/net/wellenreiter/daemon/source/cardmode.cc
@@ -1,89 +1,89 @@
1/* $Id$ */ 1/* $Id$ */
2 2
3#include "cardmode.hh" 3#include "cardmode.hh"
4 4
5int card_into_monitormode (char *device, int cardtype) 5int card_into_monitormode (char *device, int cardtype)
6{ 6{
7 7
8 int datalink; /* used for getting the pcap datalink type */ 8 int datalink; /* used for getting the pcap datalink type */
9 char CiscoRFMON[35] = "/proc/driver/aironet/"; 9 char CiscoRFMON[35] = "/proc/driver/aironet/";
10 FILE *CISCO_CONFIG_FILE; 10 FILE *CISCO_CONFIG_FILE;
11 char errbuf[PCAP_ERRBUF_SIZE]; 11 char errbuf[PCAP_ERRBUF_SIZE];
12 pcap_t *handle; 12 pcap_t *handle;
13 13
14 /* Checks if we have a device to sniff on */ 14 /* Checks if we have a device to sniff on */
15 if(device == NULL) 15 if(device == NULL)
16 { 16 {
17 printf ("Fatal error i did not have any interfaces to sniff on\n"); 17 printf ("Fatal error i did not have any interfaces to sniff on\n");
18 return 0; 18 return 0;
19 } 19 }
20 20
21 /* Setting the prmiscous and up flag to the interface */ 21 /* Setting the prmiscous and up flag to the interface */
22 if (card_set_promisc_up (device) == 0) 22 if (card_set_promisc_up (device) == 0)
23 { 23 {
24 printf ("Interface flags correctly set using ifconfig\n"); 24 printf ("Interface flags correctly set using ifconfig\n");
25 } 25 }
26 26
27 /* Check the cardtype and executes the commands to go into monitor mode */ 27 /* Check the cardtype and executes the commands to go into monitor mode */
28 if (cardtype == CARD_TYPE_CISCO) /* I got a cisco card */ 28 if (cardtype == CARD_TYPE_CISCO) /* I got a cisco card */
29 { 29 {
30 /* bring the sniffer into rfmon mode */ 30 /* bring the sniffer into rfmon mode */
31 snprintf(CiscoRFMON, sizeof(CiscoRFMON),DEFAULT_PATH, device); 31 snprintf(CiscoRFMON, sizeof(CiscoRFMON),DEFAULT_PATH, device);
32 CISCO_CONFIG_FILE = fopen(CiscoRFMON,"w"); 32 CISCO_CONFIG_FILE = fopen(CiscoRFMON,"w");
33 fputs ("Mode: r",CISCO_CONFIG_FILE); 33 fputs ("Mode: r",CISCO_CONFIG_FILE);
34 fputs ("Mode: y",CISCO_CONFIG_FILE); 34 fputs ("Mode: y",CISCO_CONFIG_FILE);
35 fputs ("XmitPower: 1",CISCO_CONFIG_FILE); 35 fputs ("XmitPower: 1",CISCO_CONFIG_FILE);
36 fclose(CISCO_CONFIG_FILE); 36 fclose(CISCO_CONFIG_FILE);
37 } 37 }
38 else if (cardtype == CARD_TYPE_NG) 38 else if (cardtype == CARD_TYPE_NG)
39 { 39 {
40 char wlanngcmd[62]; 40 char wlanngcmd[62];
41 snprintf(wlanngcmd, sizeof(wlanngcmd),"%s %s lnxreq_wlansniff channel=1 enable=true",WLANCTL_PATH,device); 41 snprintf(wlanngcmd, sizeof(wlanngcmd),"%s %s lnxreq_wlansniff channel=1 enable=true",WLANCTL_PATH,device);
42 if (system (wlanngcmd) != 0) 42 if (system (wlanngcmd) != 0)
43 { 43 {
44 printf ("\n Fatal error could not set %s in raw mode, check cardtype\n",device); 44 printf ("\n Fatal error could not set %s in raw mode, check cardtype\n\n\tterminating now...\n\n",device);
45 return 0; 45 exit(1);
46 } 46 }
47 } 47 }
48 else if (cardtype == CARD_TYPE_HOSTAP) 48 else if (cardtype == CARD_TYPE_HOSTAP)
49 { 49 {
50 printf ("Got a host-ap card, nothing is implemented now\n"); 50 printf ("Got a host-ap card, nothing is implemented now\n");
51 } 51 }
52 52
53 53
54 /* Check the interface if it is in the correct raw mode */ 54 /* Check the interface if it is in the correct raw mode */
55 handle = pcap_open_live(device, BUFSIZ, 1, 0, errbuf); 55 handle = pcap_open_live(device, BUFSIZ, 1, 0, errbuf);
56 56
57 /* getting the datalink type */ 57 /* getting the datalink type */
58 datalink = pcap_datalink(handle); 58 datalink = pcap_datalink(handle);
59 59
60 if (datalink == DLT_IEEE802_11) /* Rawmode is IEEE802_11 */ 60 if (datalink == DLT_IEEE802_11) /* Rawmode is IEEE802_11 */
61 { 61 {
62 printf ("Your successfully listen on %s in 802.11 raw mode\n",device); 62 printf ("Your successfully listen on %s in 802.11 raw mode\n",device);
63 pcap_close(handle); 63 pcap_close(handle);
64 return 0; 64 return 0;
65 65
66 } 66 }
67 else 67 else
68 { 68 {
69 printf ("Fatal error, cannot continue, your interface %s does not work in the correct 802.11 raw mode, check you driver please\n",device); 69 printf ("Fatal error, cannot continue, your interface %s does not work in the correct 802.11 raw mode, check you driver please\n\tterminating now",device);
70 pcap_close(handle); 70 pcap_close(handle);
71 return 0; 71 exit(1);
72 } 72 }
73} 73}
74 74
75 75
76 76
77int card_set_promisc_up (char * device) 77int card_set_promisc_up (char * device)
78{ 78{
79 int ret; 79 int ret;
80 char ifconfigcmd[32]; 80 char ifconfigcmd[32];
81 snprintf(ifconfigcmd,sizeof(ifconfigcmd),SBIN_PATH, device); 81 snprintf(ifconfigcmd,sizeof(ifconfigcmd),SBIN_PATH, device);
82 ret = system (ifconfigcmd); 82 ret = system (ifconfigcmd);
83 if (ret > 0) 83 if (ret > 0)
84 { 84 {
85 printf ("\nFatal error, could not execute %s please check your card,binary location and permission\n",ifconfigcmd); 85 printf ("\nFatal error, could not execute %s please check your card,binary location and permission\n",ifconfigcmd);
86 return 0; 86 return 0;
87 } 87 }
88 return 1; 88 return 1;
89} 89}