summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-06-10 00:15:02 +0000
committerMarcel Holtmann <marcel@holtmann.org>2008-06-10 00:15:02 +0000
commit4103ac9db0092c4bffbc18dec5e72c683040de5a (patch)
tree4c0db26f82a5268a907c502354aa445739a14aed /hcid
parent2b742d9f7a637b713bf77c52523dfee30922a080 (diff)
Use common UUID string helpers
Diffstat (limited to 'hcid')
-rw-r--r--hcid/dbus-common.c53
-rw-r--r--hcid/dbus-sdp.c5
2 files changed, 3 insertions, 55 deletions
diff --git a/hcid/dbus-common.c b/hcid/dbus-common.c
index 2ce4e25e..99585d0a 100644
--- a/hcid/dbus-common.c
+++ b/hcid/dbus-common.c
@@ -35,8 +35,6 @@
#include <fcntl.h>
#include <sys/ioctl.h>
-#include <arpa/inet.h>
-
#include <bluetooth/bluetooth.h>
#include <bluetooth/l2cap.h>
#include <bluetooth/sdp.h>
@@ -62,57 +60,6 @@
static int experimental = 0;
-int str2uuid(uuid_t *uuid, const char *string)
-{
- uint16_t svclass, data1, data2, data3, data5;
- uint32_t data0, data4;
- uint8_t val[16];
-
- svclass = sdp_str2svclass(string);
- if (svclass) {
- sdp_uuid16_create(uuid, svclass);
- return 0;
- }
-
- if (strlen(string) != 36)
- return -1;
-
- if (string[8] != '-' || string[13] != '-' ||
- string[18] != '-' || string[23] != '-')
- return -1;
-
- if (sscanf(string, "%08x-%04hx-%04hx-%04hx-%08x%04hx",
- &data0, &data1, &data2, &data3, &data4, &data5) != 6)
- return -1;
-
- /* Base UUID is 00001203-0000-1000-8000-00805F9B34FB */
- if (data1 == 0x0000 && data2 == 0x1000 && data3 == 0x8000 &&
- data4 == 0x00805F9B && data5 == 0x34FB) {
- if ((data0 & 0xffff0000) > 0)
- sdp_uuid32_create(uuid, data0);
- else
- sdp_uuid16_create(uuid, data0);
- return 0;
- }
-
- data0 = htonl(data0);
- data1 = htons(data1);
- data2 = htons(data2);
- data3 = htons(data3);
- data4 = htonl(data4);
- data5 = htons(data5);
-
- memcpy(&val[0], &data0, 4);
- memcpy(&val[4], &data1, 2);
- memcpy(&val[6], &data2, 2);
- memcpy(&val[8], &data3, 2);
- memcpy(&val[10], &data4, 4);
- memcpy(&val[14], &data5, 2);
-
- sdp_uuid128_create(uuid, val);
- return 0;
-}
-
int l2raw_connect(const char *local, const bdaddr_t *remote)
{
struct sockaddr_l2 addr;
diff --git a/hcid/dbus-sdp.c b/hcid/dbus-sdp.c
index e9f130f8..cf018f1e 100644
--- a/hcid/dbus-sdp.c
+++ b/hcid/dbus-sdp.c
@@ -58,6 +58,7 @@
#include "error.h"
#include "dbus-sdp.h"
#include "sdp-xml.h"
+#include "glib-helper.h"
#define SESSION_TIMEOUT 2000
#define DEFAULT_XML_BUF_SIZE 1024
@@ -1044,7 +1045,7 @@ static int remote_svc_handles_conn_cb(struct transaction_context *ctxt)
DBUS_TYPE_INVALID);
if (strlen(svc) > 0)
- str2uuid(&ctxt->uuid, svc);
+ bt_string2uuid(&ctxt->uuid, svc);
else
sdp_uuid16_create(&ctxt->uuid, PUBLIC_BROWSE_GROUP);
@@ -1090,7 +1091,7 @@ DBusMessage *get_remote_svc_handles(DBusConnection *conn,
if (strlen(svc) > 0) {
/* Check if it is a service name string */
- if (str2uuid(&uuid, svc) < 0) {
+ if (bt_string2uuid(&uuid, svc) < 0) {
error("Invalid service class name");
return invalid_args(msg);
}