summaryrefslogtreecommitdiff
authormax <max>2003-02-18 09:31:47 (UTC)
committer max <max>2003-02-18 09:31:47 (UTC)
commit065f26b161f6df269cfbf9c75751c09453350995 (patch) (unidiff)
tree0d242028eadc37ecc9afa38af676906998d92329
parent3d8495ee454395e95190693af9baa9420f90431f (diff)
downloadopie-065f26b161f6df269cfbf9c75751c09453350995.zip
opie-065f26b161f6df269cfbf9c75751c09453350995.tar.gz
opie-065f26b161f6df269cfbf9c75751c09453350995.tar.bz2
Remove-promisc-flag
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
@@ -201,4 +201,74 @@ int card_set_promisc_up (const char *device)
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)
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
@@ -49,5 +49,6 @@ extern "C"
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);