luci-0.10: merge r8034
[project/luci.git] / contrib / package / iwinfo / src / iwinfo_wext_scan.c
index b0c1f15..93dd887 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * iwinfo - Wireless Information Library - Linux Wireless Extension Backend
  *
- *   Copyright (C) 2009 Jo-Philipp Wich <xm@subsignal.org>
+ *   Copyright (C) 2009-2010 Jo-Philipp Wich <xm@subsignal.org>
  *
  * The iwinfo library is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 2
 #include "iwinfo_wext_scan.h"
 
 
-static int ioctl_socket = -1;
-
 static int wext_ioctl(const char *ifname, int cmd, struct iwreq *wrq)
 {
-       /* prepare socket */
-       if( ioctl_socket == -1 )
-               ioctl_socket = socket(AF_INET, SOCK_DGRAM, 0);
-
-       strncpy(wrq->ifr_name, ifname, IFNAMSIZ);
-       return ioctl(ioctl_socket, cmd, wrq);
+       strncpy(wrq->ifr_name, ifname, IFNAMSIZ);
+       return iwinfo_ioctl(cmd, wrq);
 }
 
-static double wext_freq2float(const struct iw_freq *in)
+static inline double wext_freq2float(const struct iw_freq *in)
 {
        int             i;
        double  res = (double) in->m;
@@ -43,7 +37,7 @@ static double wext_freq2float(const struct iw_freq *in)
        return res;
 }
 
-static int wext_extract_event(struct stream_descr *stream, struct iw_event *iwe, int wev)
+static inline int wext_extract_event(struct stream_descr *stream, struct iw_event *iwe, int wev)
 {
        const struct iw_ioctl_description *descr = NULL;
        int event_type = 0;
@@ -249,7 +243,7 @@ static inline void wext_fill_wpa(unsigned char *iebuf, int buflen, struct iwinfo
 
                case 0xdd:      /* WPA or else */
                        wpa_oui = wpa1_oui;
-                       /* Not all IEs that start with 0xdd are WPA. 
+                       /* Not all IEs that start with 0xdd are WPA.
                        *        * So check that the OUI is valid. */
                        if((ielen < 8) || ((memcmp(&iebuf[offset], wpa_oui, 3) != 0)
                                && (iebuf[offset+3] == 0x01)))
@@ -477,7 +471,7 @@ int wext_get_scanlist(const char *ifname, char *buf, int *len)
 
        wrq.u.data.pointer = (caddr_t) &range;
        wrq.u.data.length  = sizeof(struct iw_range);
-       wrq.u.data.flags   = 0; 
+       wrq.u.data.flags   = 0;
 
        if( wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0 )
        {
@@ -650,4 +644,3 @@ int wext_get_scanlist(const char *ifname, char *buf, int *len)
 
        return -1;
 }
-