libs: remove cbi folder
[project/luci.git] / libs / iwinfo / src / iwinfo_madwifi.c
index 1fe777f..3330702 100644 (file)
@@ -435,7 +435,29 @@ int madwifi_get_assoclist(const char *ifname, char *buf, int *len)
 
 int madwifi_get_txpwrlist(const char *ifname, char *buf, int *len)
 {
-       return wext_get_txpwrlist(ifname, buf, len);
+       int rc = -1;
+       char cmd[256];
+
+       /* A wifiX device? */
+       if( madwifi_iswifi(ifname) )
+       {
+               sprintf(cmd, "wlanconfig ath-txpwr create nounit "
+                       "wlandev %s wlanmode ap >/dev/null", ifname);
+
+               if( ! WEXITSTATUS(system(cmd)) )
+               {
+                       rc = wext_get_txpwrlist("ath-txpwr", buf, len);
+                       (void) WEXITSTATUS(system("wlanconfig ath-txpwr destroy"));
+               }
+       }
+
+       /* Its an athX ... */
+       else if( madwifi_isvap(ifname, NULL) )
+       {
+               rc = wext_get_txpwrlist(ifname, buf, len);
+       }
+
+       return rc;
 }
 
 int madwifi_get_scanlist(const char *ifname, char *buf, int *len)
@@ -494,6 +516,55 @@ int madwifi_get_scanlist(const char *ifname, char *buf, int *len)
        return ret;
 }
 
+int madwifi_get_freqlist(const char *ifname, char *buf, int *len)
+{
+       int i, bl;
+       int rc = -1;
+       char cmd[256];
+       struct ieee80211req_chaninfo chans;
+       struct iwinfo_freqlist_entry entry;
+
+       /* A wifiX device? */
+       if( madwifi_iswifi(ifname) )
+       {
+               sprintf(cmd, "wlanconfig ath-channels create nounit "
+                       "wlandev %s wlanmode ap >/dev/null", ifname);
+
+               if( ! WEXITSTATUS(system(cmd)) )
+               {
+                       rc = get80211priv("ath-channels", IEEE80211_IOCTL_GETCHANINFO, &chans, sizeof(chans));
+                       (void) WEXITSTATUS(system("wlanconfig ath-channels destroy"));
+               }
+       }
+
+       /* Its an athX ... */
+       else if( madwifi_isvap(ifname, NULL) )
+       {
+               rc = get80211priv(ifname, IEEE80211_IOCTL_GETCHANINFO, &chans, sizeof(chans));
+       }
+
+
+       /* Got chaninfo? */
+       if( rc >= 0 )
+       {
+               bl = 0;
+
+               for( i = 0; i < chans.ic_nchans; i++ )
+               {
+                       entry.mhz     = chans.ic_chans[i].ic_freq;
+                       entry.channel = chans.ic_chans[i].ic_ieee;
+
+                       memcpy(&buf[bl], &entry, sizeof(struct iwinfo_freqlist_entry));
+                       bl += sizeof(struct iwinfo_freqlist_entry);
+               }
+
+               *len = bl;
+               return 0;
+       }
+
+       return -1;
+}
+
 int madwifi_get_mbssid_support(const char *ifname, int *buf)
 {
        /* We assume that multi bssid is always possible */