-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc | 70 | ||||
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh | 3 |
2 files changed, 72 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc index d385df4..7c9fbc4 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc +++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc | |||
@@ -202,2 +202,72 @@ int card_set_promisc_up (const char *device) | |||
202 | 202 | ||
203 | /* Remove card from promisc mode */ | ||
204 | int card_remove_promisc (const char *device) | ||
205 | { | ||
206 | int err; | ||
207 | /* First generate a socket to use with iocalls */ | ||
208 | int fd = socket(AF_INET, SOCK_DGRAM, 0); | ||
209 | if (fd < 0) | ||
210 | { | ||
211 | /* In case of an error */ | ||
212 | perror("socket"); | ||
213 | return 0; | ||
214 | } | ||
215 | |||
216 | /* Fill an empty an interface structure with the right flags (UP and Promsic) */ | ||
217 | struct ifreq ifr; | ||
218 | /* strncpy(ifr.ifr_name, device,10); | ||
219 | ifr.ifr_flags = IFF_UP + IFF_PROMISC; | ||
220 | err = ioctl(fd, SIOCSIFFLAGS, &ifr); | ||
221 | if (err < 0) | ||
222 | { | ||
223 | perror("Could not access the interface, "); | ||
224 | close(fd); | ||
225 | return 0; | ||
226 | } | ||
227 | */ | ||
228 | /* Get the flags from the interface*/ | ||
229 | strncpy(ifr.ifr_name, device,10); | ||
230 | err = ioctl(fd, SIOCGIFFLAGS, &ifr); | ||
231 | if (err < 0) | ||
232 | { | ||
233 | perror("Could not access the interface, "); | ||
234 | close(fd); | ||
235 | return 0; | ||
236 | } | ||
237 | /* Remove the IFF_PROMISC flag */ | ||
238 | ifr.ifr_flags = ifr.ifr_flags - IFF_PROMISC; | ||
239 | /*Set the new flags to the interface*/ | ||
240 | err = ioctl(fd, SIOCSIFFLAGS, &ifr); | ||
241 | if (err < 0) | ||
242 | { | ||
243 | perror("Could not access the interface, "); | ||
244 | close(fd); | ||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | /* Get the flags again to check if IFF_PROMISC is removed */ | ||
249 | err = ioctl(fd, SIOCGIFFLAGS, &ifr); | ||
250 | if (err < 0) | ||
251 | { | ||
252 | perror("Could not access the interface, "); | ||
253 | close(fd); | ||
254 | return 0; | ||
255 | } | ||
256 | if(ifr.ifr_flags && IFF_PROMISC) | ||
257 | { | ||
258 | wl_logerr("Could not remove the promisc flag on %d", device); | ||
259 | close(fd); | ||
260 | return 0; | ||
261 | } | ||
262 | else | ||
263 | { | ||
264 | /* Successfully removed the promisc flags */ | ||
265 | close(fd); | ||
266 | return 1; | ||
267 | } | ||
268 | } | ||
269 | |||
270 | |||
271 | |||
272 | |||
203 | /* Set channel (Wireless frequency) of the device */ | 273 | /* Set channel (Wireless frequency) of the device */ |
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh index b35dddd..652b3ed 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh +++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh | |||
@@ -50,3 +50,4 @@ int card_check_rfmon_datalink (const char *device); | |||
50 | int card_into_monitormode (pcap_t **, const char *, int); | 50 | int card_into_monitormode (pcap_t **, const char *, int); |
51 | int card_set_promisc_up (const char *); | 51 | int card_set_promisc_up (const char *device); |
52 | int card_remove_promisc (const char *device); | ||
52 | int card_set_channel (const char *device, int channel,int cardtype); | 53 | int card_set_channel (const char *device, int channel,int cardtype); |