summaryrefslogtreecommitdiffstats
path: root/hcid/dbus-database.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-01-22 01:35:23 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-01-22 01:35:23 +0000
commit493ec449cf22b725252c86863f801a191afdbde8 (patch)
tree017aca9f36a5a210a7d209ad107581187f207b1c /hcid/dbus-database.c
parent512e954ad4c9ac938a0f1302a92b36d532725ff3 (diff)
Update binary record handling for database interface
Diffstat (limited to 'hcid/dbus-database.c')
-rw-r--r--hcid/dbus-database.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/hcid/dbus-database.c b/hcid/dbus-database.c
index d2268878..1e0cee3e 100644
--- a/hcid/dbus-database.c
+++ b/hcid/dbus-database.c
@@ -91,8 +91,9 @@ static DBusHandlerResult add_service_record(DBusConnection *conn,
DBusMessageIter iter, array;
const char *sender;
struct record_data *user_record;
+ sdp_record_t *sdp_record;
const uint8_t *record;
- int len = -1;
+ int scanned, len = -1;
dbus_message_iter_init(msg, &iter);
dbus_message_iter_recurse(&iter, &array);
@@ -108,7 +109,28 @@ static DBusHandlerResult add_service_record(DBusConnection *conn,
memset(user_record, 0, sizeof(*user_record));
if (sdp_server_enable) {
- return error_failed(conn, msg, EIO);
+ sdp_record = sdp_extract_pdu(record, &scanned);
+ if (!sdp_record) {
+ error("Parsing of service record failed");
+ free(user_record);
+ return error_failed(conn, msg, EIO);
+ }
+
+ if (scanned != len) {
+ error("Size mismatch of service record");
+ free(user_record);
+ sdp_record_free(sdp_record);
+ return error_failed(conn, msg, EIO);
+ }
+
+ if (add_record_to_server(sdp_record) < 0) {
+ error("Failed to register service record");
+ free(user_record);
+ sdp_record_free(sdp_record);
+ return error_failed(conn, msg, EIO);
+ }
+
+ user_record->handle = sdp_record->handle;
} else {
uint32_t size = len;
@@ -170,6 +192,8 @@ static DBusHandlerResult add_service_record_from_xml(DBusConnection *conn,
sdp_record_free(sdp_record);
return error_failed(conn, msg, EIO);
}
+
+ user_record->handle = sdp_record->handle;
} else {
if (register_sdp_record(sdp_record) < 0) {
error("Failed to register service record");
@@ -177,12 +201,14 @@ static DBusHandlerResult add_service_record_from_xml(DBusConnection *conn,
sdp_record_free(sdp_record);
return error_failed(conn, msg, EIO);
}
+
+ user_record->handle = sdp_record->handle;
+
sdp_record_free(sdp_record);
}
sender = dbus_message_get_sender(msg);
- user_record->handle = sdp_record->handle;
user_record->sender = strdup(sender);
records = g_slist_append(records, user_record);