diff options
| -rw-r--r-- | common/glib-helper.c | 40 | ||||
| -rw-r--r-- | common/glib-helper.h | 1 | ||||
| -rw-r--r-- | hcid/dbus-sdp.c | 32 | ||||
| -rw-r--r-- | hcid/dbus-sdp.h | 2 | ||||
| -rw-r--r-- | hcid/device.c | 3 | 
5 files changed, 41 insertions, 37 deletions
| diff --git a/common/glib-helper.c b/common/glib-helper.c index 931b99a5..f0435aca 100644 --- a/common/glib-helper.c +++ b/common/glib-helper.c @@ -386,10 +386,42 @@ char *bt_uuid2string(uuid_t *uuid)  	return str;  } +static struct { +	const char	*name; +	uint16_t	class; +} bt_services[] = { +	{ "vcp",	VIDEO_CONF_SVCLASS_ID		}, +	{ "pbap",	PBAP_SVCLASS_ID			}, +	{ "sap",	SAP_SVCLASS_ID			}, +	{ "ftp",	OBEX_FILETRANS_SVCLASS_ID	}, +	{ "bpp",	BASIC_PRINTING_SVCLASS_ID	}, +	{ "bip",	IMAGING_SVCLASS_ID		}, +	{ "synch",	IRMC_SYNC_SVCLASS_ID		}, +	{ "dun",	DIALUP_NET_SVCLASS_ID		}, +	{ "opp",	OBEX_OBJPUSH_SVCLASS_ID		}, +	{ "fax",	FAX_SVCLASS_ID			}, +	{ "spp",	SERIAL_PORT_SVCLASS_ID		}, +	{ "hsp",	HEADSET_SVCLASS_ID		}, +	{ "hfp",	HANDSFREE_SVCLASS_ID		}, +	{ } +}; + +uint16_t bt_string2class(const char *pattern) +{ +	int i; + +	for (i = 0; bt_services[i].name; i++) { +		if (strcasecmp(bt_services[i].name, pattern) == 0) +			return bt_services[i].class; +	} + +	return 0; +} +  int bt_string2uuid(uuid_t *uuid, const char *string)  { -	uint16_t data1, data2, data3, data5;  	uint32_t data0, data4; +	uint16_t data1, data2, data3, data5;  	if (strlen(string) == 36 &&  			string[8] == '-' && @@ -417,6 +449,12 @@ int bt_string2uuid(uuid_t *uuid, const char *string)  		sdp_uuid128_create(uuid, val);  		return 0; +	} else { +		uint16_t class = bt_string2class(string); +		if (class) { +			sdp_uuid16_create(uuid, class); +			return 0; +		}  	}  	return -1; diff --git a/common/glib-helper.h b/common/glib-helper.h index 8bb6b284..6b188f7f 100644 --- a/common/glib-helper.h +++ b/common/glib-helper.h @@ -37,6 +37,7 @@ int bt_search_service(const bdaddr_t *src, const bdaddr_t *dst,  int bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst);  gchar *bt_uuid2string(uuid_t *uuid); +uint16_t bt_string2class(const char *string);  int bt_string2uuid(uuid_t *uuid, const char *string);  gchar *bt_list2string(GSList *list);  GSList *bt_string2list(const gchar *str); diff --git a/hcid/dbus-sdp.c b/hcid/dbus-sdp.c index 441e8233..12de5edd 100644 --- a/hcid/dbus-sdp.c +++ b/hcid/dbus-sdp.c @@ -281,38 +281,6 @@ void append_and_grow_string(void *data, const char *str)  	buff->data_size += len;  } -/* FIXME:  move to a common file */ -sdp_service_t sdp_service[] = { -	{ "vcp",	VIDEO_CONF_SVCLASS_ID,		"Video Conference"	}, -	{ "map",	0,				NULL			}, -	{ "pbap",	PBAP_SVCLASS_ID,		"Phone Book Access"	}, -	{ "sap",	SAP_SVCLASS_ID,			"SIM Access"		}, -	{ "ftp",	OBEX_FILETRANS_SVCLASS_ID,	"OBEX File Transfer"	}, -	{ "bpp",	BASIC_PRINTING_SVCLASS_ID,	"Printing"		}, -	{ "bip",	IMAGING_SVCLASS_ID,		"Imaging"		}, -	{ "synch",	IRMC_SYNC_SVCLASS_ID,		"Synchronization"	}, -	{ "dun",	DIALUP_NET_SVCLASS_ID,		"Dial-Up Networking"	}, -	{ "opp",	OBEX_OBJPUSH_SVCLASS_ID,	"OBEX Object Push"	}, -	{ "fax",	FAX_SVCLASS_ID,			"Fax"			}, -	{ "spp",	SERIAL_PORT_SVCLASS_ID,		"Serial Port"		}, -	{ "hsp",	HEADSET_SVCLASS_ID,		"Headset"		}, -	{ "hfp",	HANDSFREE_SVCLASS_ID,		"Handsfree"		}, -	{ NULL } -}; - -/* FIXME:  move to a common file */ -uint16_t sdp_str2svclass(const char *str) -{ -	sdp_service_t *s; - -	for (s = sdp_service; s->name; s++) { -		if (strcasecmp(s->name, str) == 0) -			return s->class; -	} - -	return 0; -} -  /* list of remote and local service records */  static GSList *pending_connects  = NULL; diff --git a/hcid/dbus-sdp.h b/hcid/dbus-sdp.h index dd7bd1c8..06484bbc 100644 --- a/hcid/dbus-sdp.h +++ b/hcid/dbus-sdp.h @@ -39,6 +39,4 @@ DBusMessage *get_remote_svc_rec(DBusConnection *conn, DBusMessage *msg,  DBusMessage *finish_remote_svc_transact(DBusConnection *conn,  					DBusMessage *msg, void *data); -uint16_t sdp_str2svclass(const char *str); -  void append_and_grow_string(void *data, const char *str); diff --git a/hcid/device.c b/hcid/device.c index 43ccd4e8..706dcc1d 100644 --- a/hcid/device.c +++ b/hcid/device.c @@ -1062,8 +1062,7 @@ static DBusMessage *discover_services(DBusConnection *conn,  		if (err < 0)  			goto fail;  	} else { - -		search = sdp_str2svclass(pattern); +		search = bt_string2class(pattern);  		if (!search)  			return invalid_args(msg); | 
