#include <config.h>
#endif
+#include <stdio.h>
#include <string.h>
#include "hwdb.h"
return result;
}
+
+bool hwdb_get_company(const uint8_t *bdaddr, char **company)
+{
+ struct udev *udev;
+ struct udev_hwdb *hwdb;
+ struct udev_list_entry *head, *entry;
+ char modalias[11];
+ bool result;
+
+ sprintf(modalias, "OUI:%2.2X%2.2X%2.2X",
+ bdaddr[5], bdaddr[4], bdaddr[3]);
+
+ udev = udev_new();
+ if (!udev)
+ return false;
+
+ hwdb = udev_hwdb_new(udev);
+ if (!hwdb) {
+ result = false;
+ goto done;
+ }
+
+ *company = NULL;
+
+ head = udev_hwdb_get_properties_list_entry(hwdb, modalias, 0);
+
+ udev_list_entry_foreach(entry, head) {
+ const char *name = udev_list_entry_get_name(entry);
+
+ if (name && !strcmp(name, "ID_OUI_FROM_DATABASE")) {
+ *company = strdup(udev_list_entry_get_value(entry));
+ break;
+ }
+ }
+
+ hwdb = udev_hwdb_unref(hwdb);
+
+ result = true;
+
+done:
+ udev = udev_unref(udev);
+
+ return result;
+}
#else
bool hwdb_get_vendor_model(const char *modalias, char **vendor, char **model)
{
return false;
}
+
+bool hwdb_get_company(const uint8_t *bdaddr, char **company)
+{
+ return false;
+}
#endif
print_error("Reason", reason);
}
-static void print_bdaddr(const uint8_t *bdaddr)
-{
- print_field("Address: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
- " (OUI %2.2X-%2.2X-%2.2X)",
- bdaddr[5], bdaddr[4], bdaddr[3],
- bdaddr[2], bdaddr[1], bdaddr[0],
- bdaddr[5], bdaddr[4], bdaddr[3]);
-}
-
static void print_addr(const char *label, const uint8_t *addr,
uint8_t addr_type)
{
const char *str;
+ char *company;
switch (addr_type) {
case 0x00:
- print_field("%s: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
- " (OUI %2.2X-%2.2X-%2.2X)", label,
- addr[5], addr[4], addr[3],
- addr[2], addr[1], addr[0],
- addr[5], addr[4], addr[3]);
+ if (!hwdb_get_company(addr, &company))
+ company = NULL;
+
+ if (company)
+ print_field("%s: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
+ " (%s)", label, addr[5], addr[4],
+ addr[3], addr[2],
+ addr[1], addr[0],
+ company);
+ else
+ print_field("%s: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
+ " (OUI %2.2X-%2.2X-%2.2X)", label,
+ addr[5], addr[4], addr[3],
+ addr[2], addr[1], addr[0],
+ addr[5], addr[4], addr[3]);
break;
case 0x01:
switch ((addr[5] & 0xc0) >> 6) {
print_field("%s: %s (0x%2.2x)", label, str, addr_type);
}
+static void print_bdaddr(const uint8_t *bdaddr)
+{
+ print_addr("Address", bdaddr, 0x00);
+}
+
static void print_lt_addr(uint8_t lt_addr)
{
print_field("LT address: %d", lt_addr);