X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=iwinfo_utils.c;h=d96cbb345e68fb9b9a4d6edcc3067b5a192afd23;hb=HEAD;hp=83f049a5a4b28a1995a8d1691b4a70cabe18dcaf;hpb=e084781afc99075c4154614b49d99d3308d8c8ee;p=project%2Fiwinfo.git diff --git a/iwinfo_utils.c b/iwinfo_utils.c index 83f049a..d96cbb3 100644 --- a/iwinfo_utils.c +++ b/iwinfo_utils.c @@ -115,6 +115,40 @@ const char * const iwinfo_htmode_name(int mask) return iwinfo_name(mask, IWINFO_HTMODE_COUNT, IWINFO_HTMODE_NAMES); } +uint32_t iwinfo_band2ghz(uint8_t band) +{ + switch (band) + { + case IWINFO_BAND_24: + return 2; + case IWINFO_BAND_5: + return 5; + case IWINFO_BAND_6: + return 6; + case IWINFO_BAND_60: + return 60; + } + + return 0; +} + +uint8_t iwinfo_ghz2band(uint32_t ghz) +{ + switch (ghz) + { + case 2: + return IWINFO_BAND_24; + case 5: + return IWINFO_BAND_5; + case 6: + return IWINFO_BAND_6; + case 60: + return IWINFO_BAND_60; + } + + return 0; +} + size_t iwinfo_format_hwmodes(int modes, char *buf, size_t len) { // bit numbers as per IWINFO_80211_*: ad ac ax a b g n @@ -246,13 +280,19 @@ struct iwinfo_hardware_entry * iwinfo_hardware(struct iwinfo_hardware_id *id) while (fgets(buf, sizeof(buf) - 1, db) != NULL) { + if (buf[0] == '#') + continue; + memset(&e, 0, sizeof(e)); if (sscanf(buf, "%hx %hx %hx %hx %hd %hd \"%63[^\"]\" \"%63[^\"]\"", &e.vendor_id, &e.device_id, &e.subsystem_vendor_id, &e.subsystem_device_id, &e.txpower_offset, &e.frequency_offset, - e.vendor_name, e.device_name) < 8) + e.vendor_name, e.device_name) != 8 && + sscanf(buf, "\"%127[^\"]\" %hd %hd \"%63[^\"]\" \"%63[^\"]\"", + e.compatible, &e.txpower_offset, &e.frequency_offset, + e.vendor_name, e.device_name) != 5) continue; if ((e.vendor_id != 0xffff) && (e.vendor_id != id->vendor_id)) @@ -269,6 +309,9 @@ struct iwinfo_hardware_entry * iwinfo_hardware(struct iwinfo_hardware_id *id) (e.subsystem_device_id != id->subsystem_device_id)) continue; + if (strcmp(e.compatible, id->compatible)) + continue; + rv = &e; break; }