diff options
-rw-r--r-- | input/device.c | 5 | ||||
-rw-r--r-- | src/device.c | 13 | ||||
-rw-r--r-- | src/storage.c | 36 | ||||
-rw-r--r-- | src/storage.h | 10 |
4 files changed, 41 insertions, 23 deletions
diff --git a/input/device.c b/input/device.c index 8391326e..388fe9e2 100644 --- a/input/device.c +++ b/input/device.c @@ -606,6 +606,7 @@ static int hidp_add_connection(const struct input_device *idev, struct fake_hid *fake_hid; struct fake_input *fake; sdp_record_t *rec; + uint16_t source; char src_addr[18], dst_addr[18]; int err; @@ -628,8 +629,8 @@ static int hidp_add_connection(const struct input_device *idev, extract_hid_record(rec, req); sdp_record_free(rec); - read_pnp(src_addr, dst_addr, &req->vendor, &req->product, - &req->version); + read_device_id(src_addr, dst_addr, &source, + &req->vendor, &req->product, &req->version); fake_hid = get_fake_hid(req->vendor, req->product); if (fake_hid) { diff --git a/src/device.c b/src/device.c index eadc9d51..c9d1d310 100644 --- a/src/device.c +++ b/src/device.c @@ -831,9 +831,12 @@ static void update_services(struct browse_req *req, sdp_list_t *recs) continue; if (!strcasecmp(uuid_str, PNP_UUID)) { - uint16_t vendor, product, version; + uint16_t source, vendor, product, version; sdp_data_t *pdlist; + pdlist = sdp_data_get(rec, SDP_ATTR_VENDOR_ID_SOURCE); + source = pdlist ? pdlist->val.uint16 : 0x0000; + pdlist = sdp_data_get(rec, SDP_ATTR_VENDOR_ID); vendor = pdlist ? pdlist->val.uint16 : 0x0000; @@ -843,12 +846,12 @@ static void update_services(struct browse_req *req, sdp_list_t *recs) pdlist = sdp_data_get(rec, SDP_ATTR_VERSION); version = pdlist ? pdlist->val.uint16 : 0x0000; - if (vendor || product || version) - store_pnp(srcaddr, dstaddr, vendor, product, - version); + if (source || vendor || product || version) + store_device_id(srcaddr, dstaddr, source, + vendor, product, version); } - /* Driver uuid found */ + /* Driver UUID found */ l = g_slist_find_custom(req->uuids, uuid_str, (GCompareFunc) strcasecmp); if (l) { diff --git a/src/storage.c b/src/storage.c index 559c3b12..22a2eb78 100644 --- a/src/storage.c +++ b/src/storage.c @@ -779,7 +779,6 @@ sdp_record_t *fetch_record(const gchar *src, const gchar *dst, const uint32_t ha snprintf(key, sizeof(key), "%17s#%08X", dst, handle); str = textfile_get(filename, key); - if (!str) return NULL; @@ -811,34 +810,43 @@ int delete_record(const gchar *src, const gchar *dst, const uint32_t handle) return textfile_del(filename, key); } -int store_pnp(const gchar *src, const gchar *dst, const uint16_t vendor, - const uint16_t product, const uint16_t version) +int store_device_id(const gchar *src, const gchar *dst, + const uint16_t source, const uint16_t vendor, + const uint16_t product, const uint16_t version) { char filename[PATH_MAX + 1], str[15]; - create_name(filename, PATH_MAX, STORAGEDIR, src, "pnp"); + create_name(filename, PATH_MAX, STORAGEDIR, src, "did"); create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - snprintf(str, sizeof(str), "%04X %04X %04X", vendor, product, version); + snprintf(str, sizeof(str), "%04X %04X %04X %04X", source, + vendor, product, version); return textfile_put(filename, dst, str); } -int read_pnp(const gchar *src, const gchar *dst, uint32_t *vendor, - uint16_t *product, uint16_t *version) +int read_device_id(const gchar *src, const gchar *dst, + uint16_t *source, uint16_t *vendor, + uint16_t *product, uint16_t *version) { char filename[PATH_MAX + 1]; - char *str, *product_str, *version_str; + char *str, *vendor_str, *product_str, *version_str; - create_name(filename, PATH_MAX, STORAGEDIR, src, "pnp"); + create_name(filename, PATH_MAX, STORAGEDIR, src, "did"); str = textfile_get(filename, dst); - if (!str) return -ENOENT; - product_str = strchr(str, ' '); + vendor_str = strchr(str, ' '); + if (!vendor_str) { + free(str); + return -ENOENT; + } + *(vendor_str++) = 0; + + product_str = strchr(vendor_str, ' '); if (!product_str) { free(str); return -ENOENT; @@ -852,8 +860,11 @@ int read_pnp(const gchar *src, const gchar *dst, uint32_t *vendor, } *(version_str++) = 0; + if (source) + *source = (uint16_t) strtol(str, NULL, 16); + if (vendor) - *vendor = (uint16_t) strtol(str, NULL, 16); + *vendor = (uint16_t) strtol(vendor_str, NULL, 16); if (product) *product = (uint16_t) strtol(product_str, NULL, 16); @@ -862,5 +873,6 @@ int read_pnp(const gchar *src, const gchar *dst, uint32_t *vendor, *version = (uint16_t) strtol(version_str, NULL, 16); free(str); + return 0; } diff --git a/src/storage.h b/src/storage.h index a4eb82da..85c9398c 100644 --- a/src/storage.h +++ b/src/storage.h @@ -60,7 +60,9 @@ int store_record(const gchar *src, const gchar *dst, sdp_record_t *rec); sdp_record_t *fetch_record(const gchar *src, const gchar *dst, const uint32_t handle); int delete_record(const gchar *src, const gchar *dst, const uint32_t handle); -int store_pnp(const gchar *src, const gchar *dst, const uint16_t vendor, - const uint16_t product, const uint16_t version); -int read_pnp(const gchar *src, const gchar *dst, uint32_t *vendor, - uint16_t *product, uint16_t *version); +int store_device_id(const gchar *src, const gchar *dst, + const uint16_t source, const uint16_t vendor, + const uint16_t product, const uint16_t version); +int read_device_id(const gchar *src, const gchar *dst, + uint16_t *source, uint16_t *vendor, + uint16_t *product, uint16_t *version); |