Diffstat (limited to 'noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc index 0c23922..9e0a772 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc +++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc | |||
@@ -37,47 +37,45 @@ int card_into_monitormode (pcap_t **orighandle, char *device, int cardtype) | |||
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, "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=true", device, 1); |
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, "$(which iwpriv) %s monitor 2 %d", device,1); |
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 | else if (cardtype == CARD_TYPE_ORINOCCO) | 67 | else if (cardtype == CARD_TYPE_ORINOCCO || cardtype == CARD_TYPE_HOSTAP) |
68 | { | 68 | { |
69 | char lucentcmd[62]; | 69 | if (!card_set_channel (device, 1, CARD_TYPE_ORINOCCO)) |
70 | snprintf(lucentcmd, sizeof(lucentcmd) - 1, "$(which iwpriv) %s monitor 2 %d", device, 1); | ||
71 | if (system(lucentcmd) != 0) | ||
72 | { | 70 | { |
73 | wl_logerr("Could not set %s in raw mode, check cardtype", device); | 71 | wl_logerr("Could not set %s in raw mode, check cardtype", device); |
74 | return 0; | 72 | return 0; |
75 | } | 73 | } |
76 | else | 74 | else |
77 | { | 75 | { |
78 | wl_loginfo("Successfully set %s into raw mode",device); | 76 | wl_loginfo("Successfully set %s into raw mode",device); |
79 | } | 77 | } |
80 | } | 78 | } |
81 | 79 | ||
82 | /* Setting the promiscous and up flag to the interface */ | 80 | /* Setting the promiscous and up flag to the interface */ |
83 | if (!card_check_rfmon_datalink(device)) | 81 | if (!card_check_rfmon_datalink(device)) |
@@ -157,36 +155,56 @@ int card_set_promisc_up (const char *device) | |||
157 | } | 155 | } |
158 | } | 156 | } |
159 | 157 | ||
160 | /* Set channel (Wireless frequency) of the device */ | 158 | /* Set channel (Wireless frequency) of the device */ |
161 | int card_set_channel (const char *device, int channel, int cardtype) | 159 | int card_set_channel (const char *device, int channel, int cardtype) |
162 | { | 160 | { |
163 | if (cardtype == CARD_TYPE_CISCO) | 161 | if (cardtype == CARD_TYPE_CISCO) |
164 | { | 162 | { |
165 | /* Cisco cards don't need channelswitching */ | 163 | /* Cisco cards don't need channelswitching */ |
166 | return 1; | 164 | return 1; |
167 | } | 165 | } |
168 | /* If it is a lucent orinocco card */ | 166 | /* If it is a lucent orinocco card */ |
169 | else if (cardtype == CARD_TYPE_ORINOCCO) | 167 | else if (cardtype == CARD_TYPE_ORINOCCO || cardtype == CARD_TYPE_HOSTAP) |
170 | { | 168 | { |
171 | char lucentreset[63]; | 169 | int fd; |
172 | char lucentcmd[62]; | 170 | //Wireless tools structure for the iocalls |
173 | snprintf(lucentreset, sizeof(lucentreset) -1,"$(which iwpriv) %s force_reset", device); | 171 | struct iwreq ireq; |
174 | if (system(lucentreset) != 0) | 172 | int *ptr; |
175 | { | 173 | /* Socket needed to use the iocall to */ |
176 | wl_logerr("Could not reset the card %s",device); | 174 | fd = socket(AF_INET, SOCK_STREAM, 0); |
175 | if ( fd == -1 ) { | ||
176 | return -1; | ||
177 | } | ||
178 | ptr = (int *) ireq.u.name; | ||
179 | // This is the monitor mode for 802.11 non-prism header | ||
180 | ptr[0] = 2; | ||
181 | ptr[1] = channel; | ||
182 | strcpy(ireq.ifr_ifrn.ifrn_name, device); | ||
183 | if (ioctl( fd, SIOCIWFIRSTPRIV + 0x8, &ireq)==0) | ||
184 | { | ||
185 | /* All was fine... */ | ||
186 | // close(fd); | ||
187 | wl_loginfo("Set channel %d on interface %s",channel, device); | ||
188 | return 1; | ||
189 | } | ||
190 | else | ||
191 | { /* iocall does not work */ | ||
192 | wl_logerr("Could not set channel %d on %s, check cardtype",channel, device); | ||
177 | return 0; | 193 | return 0; |
178 | } | 194 | } |
179 | snprintf(lucentcmd, sizeof(lucentcmd) - 1, "$(which iwpriv) %s monitor 2 %d", device, channel); | 195 | } |
180 | if (system(lucentcmd) != 0) | 196 | else if (cardtype == CARD_TYPE_NG) |
181 | { | 197 | { |
182 | wl_logerr("Could not set %s in raw mode, check cardtype", device); | 198 | char wlanngcmd[62]; |
199 | snprintf(wlanngcmd, sizeof(wlanngcmd) - 1, "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=true", device, channel); | ||
200 | if (system(wlanngcmd) != 0) | ||
201 | { | ||
202 | wl_logerr("Could not set channel %d on %s, check cardtype",channel, device); | ||
183 | return 0; | 203 | return 0; |
184 | } | 204 | } |
185 | wl_loginfo("Channel %d set on interface %s",channel,device); | ||
186 | return 1; | ||
187 | } | ||
188 | 205 | ||
206 | } | ||
189 | /* For undefined situations */ | 207 | /* For undefined situations */ |
190 | return 0; | 208 | return 0; |
191 | } | 209 | } |
192 | 210 | ||