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