author | max <max> | 2003-02-07 03:34:48 (UTC) |
---|---|---|
committer | max <max> | 2003-02-07 03:34:48 (UTC) |
commit | de1deba3a6c3a2e470f73db93f83aea3098516ba (patch) (unidiff) | |
tree | 87f859fc749156273181247a9166400c8670f9b3 | |
parent | 2e7e176817b5d162b054f97ed6650e659730f4ae (diff) | |
download | opie-de1deba3a6c3a2e470f73db93f83aea3098516ba.zip opie-de1deba3a6c3a2e470f73db93f83aea3098516ba.tar.gz opie-de1deba3a6c3a2e470f73db93f83aea3098516ba.tar.bz2 |
*** empty log message ***
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc | 1 | ||||
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh | 1 |
2 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc index 1add34c..d868438 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc +++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc | |||
@@ -24,120 +24,121 @@ int card_into_monitormode (pcap_t **orighandle, char *device, int cardtype) | |||
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[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]; | 59 | char hostapcmd[250]; |
60 | snprintf(hostapcmd, sizeof(hostapcmd) -1, "%s %s monitor 2", IWPRIV_PATH, device); | 60 | snprintf(hostapcmd, sizeof(hostapcmd) -1, "%s %s monitor 2", IWPRIV_PATH, device); |
61 | if (system(hostapcmd) !=0) | 61 | if (system(hostapcmd) !=0) |
62 | { | 62 | { |
63 | wl_logerr("Could not set %s in raw mode, check cardtype", device); | 63 | wl_logerr("Could not set %s in raw mode, check cardtype", device); |
64 | return 0; | 64 | return 0; |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | /* Setting the promiscous and up flag to the interface */ | 68 | /* Setting the promiscous and up flag to the interface */ |
69 | if (!card_check_rfmon_datalink(device)) | 69 | if (!card_check_rfmon_datalink(device)) |
70 | { | 70 | { |
71 | wl_logerr("Cannot set interface to rfmon mode"); | 71 | wl_logerr("Cannot set interface to rfmon mode"); |
72 | return 0; | 72 | return 0; |
73 | } | 73 | } |
74 | else | 74 | else |
75 | { | 75 | { |
76 | wl_loginfo("Interface set to rfmon mode"); | 76 | wl_loginfo("Interface set to rfmon mode"); |
77 | } | 77 | } |
78 | return 1; | 78 | return 1; |
79 | } | 79 | } |
80 | 80 | ||
81 | /* Check card is in the rfmon mode */ | 81 | /* Check card is in the rfmon mode */ |
82 | int card_check_rfmon_datalink (char *device) | 82 | int card_check_rfmon_datalink (char *device) |
83 | { | 83 | { |
84 | int datalinktype=0; | 84 | int datalinktype=0; |
85 | pcap_t *phandle; | 85 | pcap_t *phandle; |
86 | phandle = pcap_open_live(device, 65,0,0,NULL); | 86 | phandle = pcap_open_live(device, 65,0,0,NULL); |
87 | datalinktype = pcap_datalink (phandle); | 87 | datalinktype = pcap_datalink (phandle); |
88 | pcap_close(phandle); | ||
88 | 89 | ||
89 | if (datalinktype != DLT_IEEE802_11) /* Rawmode is IEEE802_11 */ | 90 | if (datalinktype != DLT_IEEE802_11) /* Rawmode is IEEE802_11 */ |
90 | { | 91 | { |
91 | return 0; | 92 | return 0; |
92 | } | 93 | } |
93 | else | 94 | else |
94 | { | 95 | { |
95 | wl_loginfo("Your successfully listen on %s in 802.11 raw mode", device); | 96 | wl_loginfo("Your successfully listen on %s in 802.11 raw mode", device); |
96 | return 1; | 97 | return 1; |
97 | } | 98 | } |
98 | } | 99 | } |
99 | 100 | ||
100 | /* Set card into promisc mode */ | 101 | /* Set card into promisc mode */ |
101 | int card_set_promisc_up (const char *device) | 102 | int card_set_promisc_up (const char *device) |
102 | { | 103 | { |
103 | int err; | 104 | int err; |
104 | /* First generate a socket to use with iocalls */ | 105 | /* First generate a socket to use with iocalls */ |
105 | int fd = socket(AF_INET, SOCK_DGRAM, 0); | 106 | int fd = socket(AF_INET, SOCK_DGRAM, 0); |
106 | if (fd < 0) | 107 | if (fd < 0) |
107 | { | 108 | { |
108 | /* In case of an error */ | 109 | /* In case of an error */ |
109 | perror("socket"); | 110 | perror("socket"); |
110 | return 0; | 111 | return 0; |
111 | } | 112 | } |
112 | 113 | ||
113 | /* Fill an empty an interface structure with the right flags (UP and Promsic) */ | 114 | /* Fill an empty an interface structure with the right flags (UP and Promsic) */ |
114 | struct ifreq ifr; | 115 | struct ifreq ifr; |
115 | strncpy(ifr.ifr_name, device,10); | 116 | strncpy(ifr.ifr_name, device,10); |
116 | ifr.ifr_flags = IFF_UP + IFF_PROMISC; | 117 | ifr.ifr_flags = IFF_UP + IFF_PROMISC; |
117 | err = ioctl(fd, SIOCSIFFLAGS, &ifr); | 118 | err = ioctl(fd, SIOCSIFFLAGS, &ifr); |
118 | if (err < 0) | 119 | if (err < 0) |
119 | { | 120 | { |
120 | perror("Could not access the interface, "); | 121 | perror("Could not access the interface, "); |
121 | return 0; | 122 | return 0; |
122 | } | 123 | } |
123 | 124 | ||
124 | /* Get the informations back from the interface to check if the flags are correct */ | 125 | /* Get the informations back from the interface to check if the flags are correct */ |
125 | strncpy(ifr.ifr_name, device,10); | 126 | strncpy(ifr.ifr_name, device,10); |
126 | ioctl(fd, SIOCGIFFLAGS, &ifr); | 127 | ioctl(fd, SIOCGIFFLAGS, &ifr); |
127 | if (err < 0) | 128 | if (err < 0) |
128 | { | 129 | { |
129 | perror("Could not access the interface, "); | 130 | perror("Could not access the interface, "); |
130 | return 0; | 131 | return 0; |
131 | } | 132 | } |
132 | 133 | ||
133 | if(ifr.ifr_flags && IFF_UP) | 134 | if(ifr.ifr_flags && IFF_UP) |
134 | { | 135 | { |
135 | printf("%s is ok\n", device); | 136 | printf("%s is ok\n", device); |
136 | return 1; | 137 | return 1; |
137 | } | 138 | } |
138 | else | 139 | else |
139 | { | 140 | { |
140 | printf("%s flags could not be set", device); | 141 | printf("%s flags could not be set", device); |
141 | return 0; | 142 | return 0; |
142 | } | 143 | } |
143 | } | 144 | } |
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh index babb109..4eec122 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh +++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh | |||
@@ -1,43 +1,42 @@ | |||
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 <linux/if.h> | 15 | #include <linux/if.h> |
16 | 16 | ||
17 | |||
18 | extern "C" | 17 | extern "C" |
19 | { | 18 | { |
20 | #include <net/bpf.h> | 19 | #include <net/bpf.h> |
21 | #include <pcap.h> | 20 | #include <pcap.h> |
22 | } | 21 | } |
23 | 22 | ||
24 | /* Defines, used for the card setup */ | 23 | /* Defines, used for the card setup */ |
25 | #define DEFAULT_PATH "/proc/driver/aironet/%s/Config" | 24 | #define DEFAULT_PATH "/proc/driver/aironet/%s/Config" |
26 | #define CISCO_STATUS "/proc/driver/aironet/%s/Status" | 25 | #define CISCO_STATUS "/proc/driver/aironet/%s/Status" |
27 | #define CARD_TYPE_CISCO1 | 26 | #define CARD_TYPE_CISCO1 |
28 | #define CARD_TYPE_NG 2 | 27 | #define CARD_TYPE_NG 2 |
29 | #define CARD_TYPE_HOSTAP3 | 28 | #define CARD_TYPE_HOSTAP3 |
30 | 29 | ||
31 | /* only for now, until we have the daemon running */ | 30 | /* only for now, until we have the daemon running */ |
32 | /*the config file should provide these information */ | 31 | /*the config file should provide these information */ |
33 | #define CARD_TYPE CARD_TYPE_HOSTAP | 32 | #define CARD_TYPE CARD_TYPE_HOSTAP |
34 | #define SBIN_PATH "/sbin/ifconfig %s promisc up" | 33 | #define SBIN_PATH "/sbin/ifconfig %s promisc up" |
35 | #define WLANCTL_PATH "/sbin/wlanctl-ng" | 34 | #define WLANCTL_PATH "/sbin/wlanctl-ng" |
36 | #define IWPRIV_PATH "/sbin/iwpriv" | 35 | #define IWPRIV_PATH "/sbin/iwpriv" |
37 | 36 | ||
38 | /* Prototypes */ | 37 | /* Prototypes */ |
39 | int card_check_rfmon_datalink (char *device); | 38 | int card_check_rfmon_datalink (char *device); |
40 | int card_into_monitormode (pcap_t **, char *, int); | 39 | int card_into_monitormode (pcap_t **, char *, int); |
41 | int card_set_promisc_up (const char *); | 40 | int card_set_promisc_up (const char *); |
42 | 41 | ||
43 | #endif /* CARDMODE_HH */ | 42 | #endif /* CARDMODE_HH */ |