summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
Side-by-side diff
Diffstat (limited to 'noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc59
1 files changed, 47 insertions, 12 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
index 7c9fbc4..4f187c0 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
@@ -3,15 +3,15 @@
*
* $Id$
*/
#include "cardmode.hh"
#include "wl_log.hh"
-
+pcap_t *handletopcap;
/* main card into monitor function */
-int card_into_monitormode (pcap_t **orighandle, const char *device, int cardtype)
+int card_into_monitormode (const char *device, int cardtype)
{
char CiscoRFMON[35] = "/proc/driver/aironet/";
FILE *CISCO_CONFIG_FILE;
/* Checks if we have a device to sniff on */
if(device == NULL)
@@ -149,12 +149,57 @@ int card_check_rfmon_datalink (const char *device)
{
wl_loginfo("Your successfully listen on %s in 802.11 raw mode", device);
return 1;
}
}
+/* Ipaq running familiar does not have a loopback device, we need one */
+int check_loopback()
+{
+ /* Checking for a loopback interface with 127.0.0.1, otherwise the other stuff seems to fail on
+ familiar linux on ipaq's */
+ 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 */
+ wl_logerr("check_loopback, generation of a socket failed, cannot continue");
+ return 0;
+ }
+ /* Fill an empty an interface structure with the right flags (UP and Promsic) */
+ struct ifreq ifr;
+ strncpy(ifr.ifr_name, "lo",3);
+
+ /* Get the interface flags, loopback interfaces can be detected that way */
+ err = ioctl(fd, SIOCGIFFLAGS, &ifr);
+ if (err < 0)
+ {
+ wl_logerr("check_loopback, could not get the flags of lo, check if you got a lo loopback interface, cannot continue");
+ close(fd);
+ return 0;
+ }
+ /* Checking the flags for IFF_LOOPBACK flags */
+ if(ifr.ifr_flags && IFF_LOOPBACK)
+ {
+ /* Yes, we do have a loopback interface....sup! */
+ close(fd);
+ wl_loginfo ("check_loopback, check for loopback interface lo successful");
+ return 1;
+ }
+ else
+ {
+ wl_logerr("check_loopback, did not found an interface lo with the IFF_LOOPBACK flag set, cannot continue");
+ close(fd);
+ return 0;
+ }
+ /* Should never be reached */
+ return 0;
+} /*check_loopback */
+
+
/* Set card into promisc mode */
int card_set_promisc_up (const char *device)
{
int err;
/* First generate a socket to use with iocalls */
int fd = socket(AF_INET, SOCK_DGRAM, 0);
@@ -212,22 +257,12 @@ int card_remove_promisc (const char *device)
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, ");