summaryrefslogtreecommitdiffstats
path: root/sdpd
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-01-19 00:58:23 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-01-19 00:58:23 +0000
commit2006d2ff671751d0ced48827ae8a58887c404a48 (patch)
tree78327fb32eee3a940d43dd82356b053a31926eaa /sdpd
parent60ebcaad4295e24f64b5b56a9f5bf3a260862d2a (diff)
Modify the server database directly
Diffstat (limited to 'sdpd')
-rw-r--r--sdpd/sdpd.h3
-rw-r--r--sdpd/service.c46
2 files changed, 49 insertions, 0 deletions
diff --git a/sdpd/sdpd.h b/sdpd/sdpd.h
index ccdd9653..8ec47b1a 100644
--- a/sdpd/sdpd.h
+++ b/sdpd/sdpd.h
@@ -82,3 +82,6 @@ uint32_t sdp_get_time();
int start_sdp_server(uint16_t mtu, uint32_t flags);
void stop_sdp_server(void);
+
+int add_record_to_server(sdp_record_t *rec);
+void remove_record_from_server(uint32_t handle);
diff --git a/sdpd/service.c b/sdpd/service.c
index ae4a7c10..0b4b0d8e 100644
--- a/sdpd/service.c
+++ b/sdpd/service.c
@@ -207,6 +207,52 @@ void register_server_service(int public)
update_db_timestamp();
}
+int add_record_to_server(sdp_record_t *rec)
+{
+ sdp_data_t *data;
+
+ if (rec->handle == 0xffffffff) {
+ rec->handle = sdp_next_handle();
+ if (rec->handle < 0x10000)
+ return -1;
+ } else {
+ if (sdp_record_find(rec->handle))
+ return -1;
+ }
+
+ debug("Adding record with handle 0x%05x", rec->handle);
+
+ sdp_record_add(BDADDR_ANY, rec);
+
+ data = sdp_data_alloc(SDP_UINT32, &rec->handle);
+ sdp_attr_replace(rec, SDP_ATTR_RECORD_HANDLE, data);
+
+ if (sdp_data_get(rec, SDP_ATTR_BROWSE_GRP_LIST) == NULL) {
+ uuid_t uuid;
+ sdp_uuid16_create(&uuid, PUBLIC_BROWSE_GROUP);
+ sdp_pattern_add_uuid(rec, &uuid);
+ }
+
+ update_db_timestamp();
+
+ return 0;
+}
+
+void remove_record_from_server(uint32_t handle)
+{
+ sdp_record_t *rec;
+
+ debug("Removing record with handle 0x%05x", handle);
+
+ rec = sdp_record_find(handle);
+ if (rec) {
+ if (sdp_record_remove(handle) == 0)
+ update_db_timestamp();
+
+ sdp_record_free(rec);
+ }
+}
+
// FIXME: refactor for server-side
static sdp_record_t *extract_pdu_server(bdaddr_t *device, uint8_t *p, uint32_t handleExpected, int *scanned)
{