summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc70
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh3
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
@@ -200,6 +200,76 @@ int card_set_promisc_up (const char *device)
200 } 200 }
201} 201}
202 202
203/* Remove card from promisc mode */
204int 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 */
204int card_set_channel (const char *device, int channel, int cardtype) 274int card_set_channel (const char *device, int channel, int cardtype)
205{ 275{
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
@@ -48,7 +48,8 @@ extern "C"
48/* Prototypes */ 48/* Prototypes */
49int card_check_rfmon_datalink (const char *device); 49int card_check_rfmon_datalink (const char *device);
50int card_into_monitormode (pcap_t **, const char *, int); 50int card_into_monitormode (pcap_t **, const char *, int);
51int card_set_promisc_up (const char *); 51int card_set_promisc_up (const char *device);
52int card_remove_promisc (const char *device);
52int card_set_channel (const char *device, int channel,int cardtype); 53int card_set_channel (const char *device, int channel,int cardtype);
53int iw_get_range_info(int skfd, const char * ifname, struct iw_range * range); 54int iw_get_range_info(int skfd, const char * ifname, struct iw_range * range);
54double iw_freq2float(iw_freq * in); 55double iw_freq2float(iw_freq * in);