author | max <max> | 2003-02-18 09:31:47 (UTC) |
---|---|---|
committer | max <max> | 2003-02-18 09:31:47 (UTC) |
commit | 065f26b161f6df269cfbf9c75751c09453350995 (patch) (side-by-side diff) | |
tree | 0d242028eadc37ecc9afa38af676906998d92329 | |
parent | 3d8495ee454395e95190693af9baa9420f90431f (diff) | |
download | opie-065f26b161f6df269cfbf9c75751c09453350995.zip opie-065f26b161f6df269cfbf9c75751c09453350995.tar.gz opie-065f26b161f6df269cfbf9c75751c09453350995.tar.bz2 |
Remove-promisc-flag
-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) +/* Remove card from promisc mode */ +int card_remove_promisc (const char *device) +{ + int err; + /* First generate a socket to use with iocalls */ + int fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd < 0) + { + /* In case of an error */ + perror("socket"); + return 0; + } + + /* Fill an empty an interface structure with the right flags (UP and Promsic) */ + struct ifreq ifr; +/* strncpy(ifr.ifr_name, device,10); + ifr.ifr_flags = IFF_UP + IFF_PROMISC; + err = ioctl(fd, SIOCSIFFLAGS, &ifr); + if (err < 0) + { + perror("Could not access the interface, "); + close(fd); + return 0; + } + */ + /* Get the flags from the interface*/ + strncpy(ifr.ifr_name, device,10); + err = ioctl(fd, SIOCGIFFLAGS, &ifr); + if (err < 0) + { + perror("Could not access the interface, "); + close(fd); + return 0; + } + /* Remove the IFF_PROMISC flag */ + ifr.ifr_flags = ifr.ifr_flags - IFF_PROMISC; + /*Set the new flags to the interface*/ + err = ioctl(fd, SIOCSIFFLAGS, &ifr); + if (err < 0) + { + perror("Could not access the interface, "); + close(fd); + return 0; + } + + /* Get the flags again to check if IFF_PROMISC is removed */ + err = ioctl(fd, SIOCGIFFLAGS, &ifr); + if (err < 0) + { + perror("Could not access the interface, "); + close(fd); + return 0; + } + if(ifr.ifr_flags && IFF_PROMISC) + { + wl_logerr("Could not remove the promisc flag on %d", device); + close(fd); + return 0; + } + else + { + /* Successfully removed the promisc flags */ + close(fd); + return 1; + } +} + + + + /* 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); int card_into_monitormode (pcap_t **, const char *, int); -int card_set_promisc_up (const char *); +int card_set_promisc_up (const char *device); +int card_remove_promisc (const char *device); int card_set_channel (const char *device, int channel,int cardtype); |