[package] iwinfo: add per-station rate and mcs info to assoclist op
[openwrt.git] / package / iwinfo / src / iwinfo_madwifi.c
index feb98e2..043cf53 100644 (file)
@@ -726,9 +726,29 @@ int madwifi_get_assoclist(const char *ifname, char *buf, int *len)
                do {
                        si = (struct ieee80211req_sta_info *) cp;
 
+                       memset(&entry, 0, sizeof(entry));
+
                        entry.signal = (si->isi_rssi - 95);
                        entry.noise  = noise;
                        memcpy(entry.mac, &si->isi_macaddr, 6);
+
+                       entry.inactive = si->isi_inact * 1000;
+
+                       entry.tx_packets = (si->isi_txseqs[0] & IEEE80211_SEQ_SEQ_MASK)
+                               >> IEEE80211_SEQ_SEQ_SHIFT;
+
+                       entry.rx_packets = (si->isi_rxseqs[0] & IEEE80211_SEQ_SEQ_MASK)
+                               >> IEEE80211_SEQ_SEQ_SHIFT;
+
+                       entry.tx_rate.rate =
+                               (si->isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL) * 500;
+
+                       /* XXX: this is just a guess */
+                       entry.rx_rate.rate = entry.tx_rate.rate;
+
+                       entry.rx_rate.mcs = -1;
+                       entry.tx_rate.mcs = -1;
+
                        memcpy(&buf[bl], &entry, sizeof(struct iwinfo_assoclist_entry));
 
                        bl += sizeof(struct iwinfo_assoclist_entry);
@@ -990,23 +1010,58 @@ int madwifi_get_mbssid_support(const char *ifname, int *buf)
 
 int madwifi_get_hardware_id(const char *ifname, char *buf)
 {
-       return wext_get_hardware_id(ifname, buf);
+       char vendor[64];
+       char device[64];
+       struct iwinfo_hardware_id *ids;
+       struct iwinfo_hardware_entry *e;
+
+       if (wext_get_hardware_id(ifname, buf))
+               return iwinfo_hardware_id_from_mtd((struct iwinfo_hardware_id *)buf);
+
+       return 0;
 }
 
-int madwifi_get_hardware_name(const char *ifname, char *buf)
+static const struct iwinfo_hardware_entry *
+madwifi_get_hardware_entry(const char *ifname)
 {
        struct iwinfo_hardware_id id;
-       struct iwinfo_hardware_entry *hw;
 
        if (madwifi_get_hardware_id(ifname, (char *)&id))
-               return -1;
+               return NULL;
 
-       hw = iwinfo_hardware(&id);
+       return iwinfo_hardware(&id);
+}
 
-       if (hw)
-               sprintf(buf, "%s %s", hw->vendor_name, hw->device_name);
-       else
+int madwifi_get_hardware_name(const char *ifname, char *buf)
+{
+       const struct iwinfo_hardware_entry *hw;
+
+       if (!(hw = madwifi_get_hardware_entry(ifname)))
                sprintf(buf, "Generic Atheros");
+       else
+               sprintf(buf, "%s %s", hw->vendor_name, hw->device_name);
+
+       return 0;
+}
+
+int madwifi_get_txpower_offset(const char *ifname, int *buf)
+{
+       const struct iwinfo_hardware_entry *hw;
+
+       if (!(hw = madwifi_get_hardware_entry(ifname)))
+               return -1;
+
+       *buf = hw->txpower_offset;
+       return 0;
+}
+
+int madwifi_get_frequency_offset(const char *ifname, int *buf)
+{
+       const struct iwinfo_hardware_entry *hw;
+
+       if (!(hw = madwifi_get_hardware_entry(ifname)))
+               return -1;
 
+       *buf = hw->frequency_offset;
        return 0;
 }
This page took 0.026832 seconds and 4 git commands to generate.