diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/device.c | 18 | ||||
| -rw-r--r-- | src/device.h | 2 | ||||
| -rw-r--r-- | src/storage.c | 54 | ||||
| -rw-r--r-- | src/storage.h | 5 | 
4 files changed, 79 insertions, 0 deletions
diff --git a/src/device.c b/src/device.c index a1d1575e..eadc9d51 100644 --- a/src/device.c +++ b/src/device.c @@ -830,6 +830,24 @@ static void update_services(struct browse_req *req, sdp_list_t *recs)  		if (!uuid_str)  			continue; +		if (!strcasecmp(uuid_str, PNP_UUID)) { +			uint16_t vendor, product, version; +			sdp_data_t *pdlist; + +			pdlist = sdp_data_get(rec, SDP_ATTR_VENDOR_ID); +			vendor = pdlist ? pdlist->val.uint16 : 0x0000; + +			pdlist = sdp_data_get(rec, SDP_ATTR_PRODUCT_ID); +			product = pdlist ? pdlist->val.uint16 : 0x0000; + +			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); +		} +  		/* Driver uuid found */  		l = g_slist_find_custom(req->uuids, uuid_str,  				(GCompareFunc) strcasecmp); diff --git a/src/device.h b/src/device.h index d2331173..21f7ffaa 100644 --- a/src/device.h +++ b/src/device.h @@ -45,6 +45,8 @@ uint8_t device_get_auth(struct btd_device *device);  #define BTD_UUIDS(args...) ((const char *[]) { args, NULL } ) +#define PNP_UUID		"00001200-0000-1000-8000-00805f9b34fb" +  struct btd_device_driver {  	const char *name;  	const char **uuids; diff --git a/src/storage.c b/src/storage.c index 0690fc1a..559c3b12 100644 --- a/src/storage.c +++ b/src/storage.c @@ -810,3 +810,57 @@ 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) +{ +	char filename[PATH_MAX + 1], str[15]; + +	create_name(filename, PATH_MAX, STORAGEDIR, src, "pnp"); + +	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + +	snprintf(str, sizeof(str), "%04X %04X %04X", 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) +{ +	char filename[PATH_MAX + 1]; +	char *str, *product_str, *version_str; + +	create_name(filename, PATH_MAX, STORAGEDIR, src, "pnp"); + +	str = textfile_get(filename, dst); + +	if (!str) +		return -ENOENT; + +	product_str = strchr(str, ' '); +	if (!product_str) { +		free(str); +		return -ENOENT; +	} +	*(product_str++) = 0; + +	version_str = strchr(product_str, ' '); +	if (!version_str) { +		free(str); +		return -ENOENT; +	} +	*(version_str++) = 0; + +	if (vendor) +		*vendor = (uint16_t) strtol(str, NULL, 16); + +	if (product) +		*product = (uint16_t) strtol(product_str, NULL, 16); + +	if (version) +		*version = (uint16_t) strtol(version_str, NULL, 16); + +	free(str); +	return 0; +} diff --git a/src/storage.h b/src/storage.h index 7f89ef19..a4eb82da 100644 --- a/src/storage.h +++ b/src/storage.h @@ -59,3 +59,8 @@ int delete_entry(bdaddr_t *src, const char *storage, const char *key);  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);  | 
