Diff between 1d70b7326fb8167b72d20f27314eef0950df3741 and be130b5f60477a353898fb2927ac76654f43c175

Changed Files

File Additions Deletions Status
profiles/network/bnep.c +0 -25 modified
profiles/network/bnep.h +0 -1 modified
profiles/network/connection.c +14 -6 modified

Full Patch

diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c
index 7d78575..0493260 100644
--- a/profiles/network/bnep.c
+++ b/profiles/network/bnep.c
@@ -85,31 +85,6 @@ struct bnep {
 	void	*disconn_data;
 };
 
-uint16_t bnep_service_id(const char *svc)
-{
-	int i;
-	uint16_t id;
-
-	/* Friendly service name */
-	for (i = 0; __svc[i].name; i++) {
-		if (!strcasecmp(svc, __svc[i].name))
-			return __svc[i].id;
-	}
-
-	/* UUID 128 string */
-	for (i = 0; __svc[i].uuid128; i++) {
-		if (!strcasecmp(svc, __svc[i].uuid128))
-			return __svc[i].id;
-	}
-
-	/* Try convert to HEX */
-	id = strtol(svc, NULL, 16);
-	if ((id < BNEP_SVC_PANU) || (id > BNEP_SVC_GN))
-		return 0;
-
-	return id;
-}
-
 const char *bnep_uuid(uint16_t id)
 {
 	int i;
diff --git a/profiles/network/bnep.h b/profiles/network/bnep.h
index 5aedf38..b0a91e5 100644
--- a/profiles/network/bnep.h
+++ b/profiles/network/bnep.h
@@ -26,7 +26,6 @@ struct bnep;
 int bnep_init(void);
 int bnep_cleanup(void);
 
-uint16_t bnep_service_id(const char *svc);
 const char *bnep_uuid(uint16_t id);
 const char *bnep_name(uint16_t id);
 
diff --git a/profiles/network/connection.c b/profiles/network/connection.c
index ecb8441..4311cc9 100644
--- a/profiles/network/connection.c
+++ b/profiles/network/connection.c
@@ -47,6 +47,7 @@
 #include "src/profile.h"
 #include "src/service.h"
 #include "src/error.h"
+#include "lib/uuid.h"
 
 #include "bnep.h"
 #include "connection.h"
@@ -79,9 +80,16 @@ struct network_conn {
 
 static GSList *peers = NULL;
 
-static uint16_t get_service_id(struct btd_service *svc)
+static uint16_t get_pan_srv_id(const char *svc)
 {
-	return bnep_service_id(btd_service_get_profile(svc)->remote_uuid);
+	if (!strcasecmp(svc, "panu") || !strcasecmp(svc, PANU_UUID))
+		return BNEP_SVC_PANU;
+	if (!strcasecmp(svc, "nap") || !strcasecmp(svc, NAP_UUID))
+		return BNEP_SVC_NAP;
+	if (!strcasecmp(svc, "gn") || !strcasecmp(svc, GN_UUID))
+		return BNEP_SVC_GN;
+
+	return 0;
 }
 
 static struct network_peer *find_peer(GSList *list, struct btd_device *device)
@@ -284,7 +292,7 @@ static DBusMessage *local_connect(DBusConnection *conn,
 						DBUS_TYPE_INVALID) == FALSE)
 		return btd_error_invalid_args(msg);
 
-	id = bnep_service_id(svc);
+	id = get_pan_srv_id(svc);
 	uuid = bnep_uuid(id);
 
 	if (uuid == NULL)
@@ -313,7 +321,7 @@ int connection_connect(struct btd_service *svc)
 {
 	struct network_conn *nc = btd_service_get_user_data(svc);
 	struct network_peer *peer = nc->peer;
-	uint16_t id = get_service_id(svc);
+	uint16_t id = get_pan_srv_id(btd_service_get_profile(svc)->remote_uuid);
 	GError *err = NULL;
 	const bdaddr_t *src;
 	const bdaddr_t *dst;
@@ -502,7 +510,7 @@ void connection_unregister(struct btd_service *svc)
 	struct btd_device *device = btd_service_get_device(svc);
 	struct network_conn *conn = btd_service_get_user_data(svc);
 	struct network_peer *peer = conn->peer;
-	uint16_t id = get_service_id(svc);
+	uint16_t id = get_pan_srv_id(btd_service_get_profile(svc)->remote_uuid);
 
 	DBG("%s id %u", device_get_path(device), id);
 
@@ -549,7 +557,7 @@ int connection_register(struct btd_service *svc)
 	struct btd_device *device = btd_service_get_device(svc);
 	struct network_peer *peer;
 	struct network_conn *nc;
-	uint16_t id = get_service_id(svc);
+	uint16_t id = get_pan_srv_id(btd_service_get_profile(svc)->remote_uuid);
 
 	DBG("%s id %u", device_get_path(device), id);