author | max <max> | 2003-02-09 21:00:55 (UTC) |
---|---|---|
committer | max <max> | 2003-02-09 21:00:55 (UTC) |
commit | 79ff87a73cda535e21eb124e1918dd32f7b6e078 (patch) (side-by-side diff) | |
tree | 3b3bcdb119b0b8d9a9b0f022bf77803ca3594de6 | |
parent | 38b97c504a4ee1e0b82fd2e4604c815d9ba3b440 (diff) | |
download | opie-79ff87a73cda535e21eb124e1918dd32f7b6e078.zip opie-79ff87a73cda535e21eb124e1918dd32f7b6e078.tar.gz opie-79ff87a73cda535e21eb124e1918dd32f7b6e078.tar.bz2 |
fd close
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc | 18 | ||||
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh | 1 |
2 files changed, 13 insertions, 6 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc index 9e0a772..29dcc75 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc +++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc @@ -126,37 +126,40 @@ int card_set_promisc_up (const char *device) /* 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 informations back from the interface to check if the flags are correct */ strncpy(ifr.ifr_name, device,10); ioctl(fd, SIOCGIFFLAGS, &ifr); if (err < 0) { perror("Could not access the interface, "); + close(fd); return 0; } if(ifr.ifr_flags && IFF_UP) { - printf("%s is ok\n", device); - return 1; + close(fd); + return 1; } else { - printf("%s flags could not be set", device); - return 0; + wl_logerr("Could not set promisc flag on %d", device); + close(fd); + return 0; } } /* Set channel (Wireless frequency) of the device */ int card_set_channel (const char *device, int channel, int cardtype) { if (cardtype == CARD_TYPE_CISCO) { @@ -167,33 +170,36 @@ int card_set_channel (const char *device, int channel, int cardtype) else if (cardtype == CARD_TYPE_ORINOCCO || cardtype == CARD_TYPE_HOSTAP) { int fd; //Wireless tools structure for the iocalls struct iwreq ireq; int *ptr; /* Socket needed to use the iocall to */ fd = socket(AF_INET, SOCK_STREAM, 0); + if ( fd == -1 ) { return -1; } ptr = (int *) ireq.u.name; // This is the monitor mode for 802.11 non-prism header ptr[0] = 2; ptr[1] = channel; strcpy(ireq.ifr_ifrn.ifrn_name, device); if (ioctl( fd, SIOCIWFIRSTPRIV + 0x8, &ireq)==0) { /* All was fine... */ - // close(fd); + close(fd); wl_loginfo("Set channel %d on interface %s",channel, device); return 1; } else - { /* iocall does not work */ + { + /* iocall does not work */ + close(fd); wl_logerr("Could not set channel %d on %s, check cardtype",channel, device); return 0; } } else if (cardtype == CARD_TYPE_NG) { char wlanngcmd[62]; snprintf(wlanngcmd, sizeof(wlanngcmd) - 1, "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=true", device, channel); diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh index 242d8c5..4a95956 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh +++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh @@ -7,16 +7,17 @@ #include <stdlib.h> #include <errno.h> #include <sys/types.h> #include <sys/time.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <sys/ioctl.h> +#include <unistd.h> #include <linux/if.h> #include <linux/wireless.h> #ifndef SIOCIWFIRSTPRIV #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE #endif |