aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/utils/iwinfo/src
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2013-04-26 13:20:15 +0000
committerJo-Philipp Wich <jow@openwrt.org>2013-04-26 13:20:15 +0000
commite02d373f9011fbcc8c928d82d14d8937ef29b07a (patch)
treed6272a857ff7249adf2d3839a7a1f2542b6d5016 /package/network/utils/iwinfo/src
parentaccc6e309e9f9ce94ce34c7b2cdf60e16c78d1e1 (diff)
downloadupstream-e02d373f9011fbcc8c928d82d14d8937ef29b07a.tar.gz
upstream-e02d373f9011fbcc8c928d82d14d8937ef29b07a.tar.bz2
upstream-e02d373f9011fbcc8c928d82d14d8937ef29b07a.zip
iwinfo: move builtin hardware database to /usr/share/libiwinfo/hardware.txt
SVN-Revision: 36449
Diffstat (limited to 'package/network/utils/iwinfo/src')
-rw-r--r--package/network/utils/iwinfo/src/include/iwinfo.h7
-rw-r--r--package/network/utils/iwinfo/src/iwinfo_lib.c70
-rw-r--r--package/network/utils/iwinfo/src/iwinfo_utils.c37
3 files changed, 32 insertions, 82 deletions
diff --git a/package/network/utils/iwinfo/src/include/iwinfo.h b/package/network/utils/iwinfo/src/include/iwinfo.h
index bf7d618964..0d92d8db1e 100644
--- a/package/network/utils/iwinfo/src/include/iwinfo.h
+++ b/package/network/utils/iwinfo/src/include/iwinfo.h
@@ -132,8 +132,8 @@ struct iwinfo_hardware_id {
};
struct iwinfo_hardware_entry {
- const char *vendor_name;
- const char *device_name;
+ char vendor_name[64];
+ char device_name[64];
uint16_t vendor_id;
uint16_t device_id;
uint16_t subsystem_vendor_id;
@@ -143,7 +143,8 @@ struct iwinfo_hardware_entry {
};
extern const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[];
-extern const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[];
+
+#define IWINFO_HARDWARE_FILE "/usr/share/libiwinfo/hardware.txt"
struct iwinfo_ops {
diff --git a/package/network/utils/iwinfo/src/iwinfo_lib.c b/package/network/utils/iwinfo/src/iwinfo_lib.c
index 368f0cf312..df1f450cc5 100644
--- a/package/network/utils/iwinfo/src/iwinfo_lib.c
+++ b/package/network/utils/iwinfo/src/iwinfo_lib.c
@@ -313,76 +313,6 @@ const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[] = {
{ 0, "" }
};
-/*
- * hardware database
- */
-
-const char VENDOR_UBNT[] = "Ubiquiti";
-const char VENDOR_ATH[] = "Atheros";
-const char VENDOR_RALINK[] = "RaLink";
-
-const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[] = {
-/* { vendor, model, vendorid, deviceid, subsys vendorid, subsys deviceid, poweroff, freqoff } */
-#if defined(USE_MADWIFI) || defined(USE_NL80211)
- { VENDOR_UBNT, "PowerStation2 (18V)", 0xffff, 0xffff, 0xffff, 0xb102, 0, 0 },
- { VENDOR_UBNT, "PowerStation2 (16D)", 0xffff, 0xffff, 0xffff, 0xb202, 0, 0 },
- { VENDOR_UBNT, "PowerStation2 (EXT)", 0xffff, 0xffff, 0xffff, 0xb302, 0, 0 },
- { VENDOR_UBNT, "PowerStation5 (22V)", 0xffff, 0xffff, 0xffff, 0xb105, 0, 0 },
- { VENDOR_UBNT, "PowerStation5 (EXT)", 0xffff, 0xffff, 0xffff, 0xb305, 0, 0 },
- { VENDOR_UBNT, "PicoStation2", 0xffff, 0xffff, 0xffff, 0xc302, 0, 0 },
- { VENDOR_UBNT, "PicoStation2 HP", 0xffff, 0xffff, 0xffff, 0xc3a2, 10, 0 },
- { VENDOR_UBNT, "WispStation5", 0xffff, 0xffff, 0xffff, 0xa105, 0, 0 },
- { VENDOR_UBNT, "LiteStation2", 0xffff, 0xffff, 0xffff, 0xa002, 10, 0 },
- { VENDOR_UBNT, "LiteStation5", 0xffff, 0xffff, 0xffff, 0xa005, 5, 0 },
- { VENDOR_UBNT, "NanoStation2", 0xffff, 0xffff, 0xffff, 0xc002, 10, 0 },
- { VENDOR_UBNT, "NanoStation5", 0xffff, 0xffff, 0xffff, 0xc005, 5, 0 },
- { VENDOR_UBNT, "NanoStation Loco2", 0xffff, 0xffff, 0xffff, 0xc102, 10, 0 },
- { VENDOR_UBNT, "NanoStation Loco5", 0xffff, 0xffff, 0xffff, 0xc105, 5, 0 },
- { VENDOR_UBNT, "Bullet2", 0xffff, 0xffff, 0xffff, 0xc202, 10, 0 },
- { VENDOR_UBNT, "Bullet5", 0xffff, 0xffff, 0xffff, 0xc205, 5, 0 },
- { VENDOR_UBNT, "XR2", 0x168c, 0x001b, 0x0777, 0x3002, 10, 0 },
- { VENDOR_UBNT, "XR2", 0x168c, 0x001b, 0x7777, 0x3002, 10, 0 },
- { VENDOR_UBNT, "XR2.3", 0x168c, 0x001b, 0x0777, 0x3b02, 10, 0 },
- { VENDOR_UBNT, "XR2.6", 0x168c, 0x001b, 0x0777, 0x3c02, 10, 0 },
- { VENDOR_UBNT, "XR3-2.8", 0x168c, 0x001b, 0x0777, 0x3b03, 10, 0 },
- { VENDOR_UBNT, "XR3-3.6", 0x168c, 0x001b, 0x0777, 0x3c03, 10, 0 },
- { VENDOR_UBNT, "XR3", 0x168c, 0x001b, 0x0777, 0x3003, 10, 0 },
- { VENDOR_UBNT, "XR4", 0x168c, 0x001b, 0x0777, 0x3004, 10, 0 },
- { VENDOR_UBNT, "XR5", 0x168c, 0x001b, 0x0777, 0x3005, 10, 0 },
- { VENDOR_UBNT, "XR5", 0x168c, 0x001b, 0x7777, 0x3005, 10, 0 },
- { VENDOR_UBNT, "XR7", 0x168c, 0x001b, 0x0777, 0x3007, 10, 0 },
- { VENDOR_UBNT, "XR9", 0x168c, 0x001b, 0x0777, 0x3009, 10, -1520 },
- { VENDOR_ATH, "AR5413", 0x168c, 0x001b, 0x168c, 0x2063, 0, 0 },
- { VENDOR_UBNT, "SRC", 0x168c, 0x0013, 0x168c, 0x1042, 1, 0 },
- { VENDOR_UBNT, "SR2", 0x168c, 0x0013, 0x0777, 0x2041, 10, 0 },
- { VENDOR_UBNT, "SR4", 0x168c, 0x0013, 0x0777, 0x2004, 6, 0 },
- { VENDOR_UBNT, "SR4", 0x168c, 0x0013, 0x7777, 0x2004, 6, 0 },
- { VENDOR_UBNT, "SR4C", 0x168c, 0x0013, 0x0777, 0x1004, 6, 0 },
- { VENDOR_UBNT, "SR4C", 0x168c, 0x0013, 0x7777, 0x1004, 6, 0 },
- { VENDOR_UBNT, "SR5", 0x168c, 0x0013, 0x168c, 0x2042, 7, 0 },
- { VENDOR_UBNT, "SR9", 0x168c, 0x0013, 0x7777, 0x2009, 12, -1500 },
- { VENDOR_UBNT, "SR71A", 0x168c, 0x0027, 0x168c, 0x2082, 7, 0 },
- { VENDOR_UBNT, "SR71", 0x168c, 0x0027, 0x0777, 0x4082, 7, 0 },
- { VENDOR_UBNT, "SR71-15", 0x168c, 0x0029, 0x0777, 0x4005, 7, 0 },
-#endif
-#ifdef USE_NL80211
- { VENDOR_UBNT, "PicoStation M2", 0x168c, 0x002a, 0x0777, 0xe302, 12, 0 }, /* ToDo: confirm offset */
- { VENDOR_UBNT, "NanoStation M2", 0x168c, 0x002a, 0x0777, 0xe012, 12, 0 }, /* ToDo: confirm offset */
- { VENDOR_UBNT, "NanoStation M5", 0x168c, 0x002a, 0x0777, 0xe005, 5, 0 }, /* ToDo: confirm offset */
- { VENDOR_UBNT, "Bullet M2", 0x168c, 0x002a, 0x0777, 0xe202, 12, 0 },
- { VENDOR_UBNT, "Bullet M5", 0x168c, 0x002a, 0x0777, 0xe805, 5, 0 },
-
- { VENDOR_ATH, "AR9220", 0x168c, 0x0029, 0x168c, 0xa094, 0, 0 },
- { VENDOR_ATH, "AR9223", 0x168c, 0x0029, 0x168c, 0xa095, 0, 0 },
- { VENDOR_ATH, "AR9280", 0x168c, 0x002a, 0x168c, 0xa093, 0, 0 },
- { VENDOR_ATH, "AR9285", 0x168c, 0x002b, 0x168c, 0xa091, 0, 0 },
- { VENDOR_RALINK, "Rt3050", 0x1814, 0x3050, 0x1814, 0x0005, 0, 0 },
- { VENDOR_RALINK, "Rt3052", 0x1814, 0x3052, 0x1814, 0x0008, 0, 0 },
- { VENDOR_RALINK, "Rt3352", 0x1814, 0x3352, 0x1814, 0x000c, 0, 0 },
-#endif
- { NULL }
-};
-
const char * iwinfo_type(const char *ifname)
{
diff --git a/package/network/utils/iwinfo/src/iwinfo_utils.c b/package/network/utils/iwinfo/src/iwinfo_utils.c
index 6616f1489f..b6760c3486 100644
--- a/package/network/utils/iwinfo/src/iwinfo_utils.c
+++ b/package/network/utils/iwinfo/src/iwinfo_utils.c
@@ -129,27 +129,46 @@ void iwinfo_close(void)
struct iwinfo_hardware_entry * iwinfo_hardware(struct iwinfo_hardware_id *id)
{
- const struct iwinfo_hardware_entry *e;
+ FILE *db;
+ char buf[256] = { 0 };
+ static struct iwinfo_hardware_entry e;
- for (e = IWINFO_HARDWARE_ENTRIES; e->vendor_name; e++)
+ if (!(db = fopen(IWINFO_HARDWARE_FILE, "r")))
+ return NULL;
+
+ while (fgets(buf, sizeof(buf) - 1, db) != NULL)
{
- if ((e->vendor_id != 0xffff) && (e->vendor_id != id->vendor_id))
+ 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)
+ continue;
+
+ if ((e.vendor_id != 0xffff) && (e.vendor_id != id->vendor_id))
continue;
- if ((e->device_id != 0xffff) && (e->device_id != id->device_id))
+ if ((e.device_id != 0xffff) && (e.device_id != id->device_id))
continue;
- if ((e->subsystem_vendor_id != 0xffff) &&
- (e->subsystem_vendor_id != id->subsystem_vendor_id))
+ if ((e.subsystem_vendor_id != 0xffff) &&
+ (e.subsystem_vendor_id != id->subsystem_vendor_id))
continue;
- if ((e->subsystem_device_id != 0xffff) &&
- (e->subsystem_device_id != id->subsystem_device_id))
+ if ((e.subsystem_device_id != 0xffff) &&
+ (e.subsystem_device_id != id->subsystem_device_id))
continue;
- return (struct iwinfo_hardware_entry *)e;
+ break;
}
+ fclose(db);
+
+ if (e.device_name[0])
+ return &e;
+
return NULL;
}