libiwinfo: implement hwmodelist()
[project/luci.git] / contrib / package / iwinfo / src / iwinfo_madwifi.c
index daecf5d..aad4b42 100644 (file)
@@ -292,6 +292,12 @@ int madwifi_probe(const char *ifname)
        return ( !!madwifi_isvap(ifname, NULL) || madwifi_iswifi(ifname) );
 }
 
+void madwifi_close(void)
+{
+       if( ioctl_socket > -1 )
+               close(ioctl_socket);
+}
+
 int madwifi_get_mode(const char *ifname, char *buf)
 {
        return wext_get_mode(ifname, buf);
@@ -799,8 +805,9 @@ int madwifi_get_freqlist(const char *ifname, char *buf, int *len)
 
                for( i = 0; i < chans.ic_nchans; i++ )
                {
-                       entry.mhz     = chans.ic_chans[i].ic_freq;
-                       entry.channel = chans.ic_chans[i].ic_ieee;
+                       entry.mhz        = chans.ic_chans[i].ic_freq;
+                       entry.channel    = chans.ic_chans[i].ic_ieee;
+                       entry.restricted = 0;
 
                        memcpy(&buf[bl], &entry, sizeof(struct iwinfo_freqlist_entry));
                        bl += sizeof(struct iwinfo_freqlist_entry);
@@ -879,6 +886,33 @@ int madwifi_get_countrylist(const char *ifname, char *buf, int *len)
        return 0;
 }
 
+int madwifi_get_hwmodelist(const char *ifname, int *buf)
+{
+       char chans[IWINFO_BUFSIZE] = { 0 };
+       struct iwinfo_freqlist_entry *e = NULL;
+       int len = 0;
+
+       if( !madwifi_get_freqlist(ifname, &chans, &len) )
+       {
+               for( e = (struct iwinfo_freqlist_entry *)chans; e->channel; e++ )
+               {
+                       if( e->channel <= 14 )
+                       {
+                               *buf |= IWINFO_80211_B;
+                               *buf |= IWINFO_80211_G;
+                       }
+                       else
+                       {
+                               *buf |= IWINFO_80211_A;
+                       }
+               }
+
+               return 0;
+       }
+
+       return -1;
+}
+
 int madwifi_get_mbssid_support(const char *ifname, int *buf)
 {
        /* We assume that multi bssid is always possible */