summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2004-10-01 11:40:15 +0000
committerMarcel Holtmann <marcel@holtmann.org>2004-10-01 11:40:15 +0000
commitc8c2b3ffa0c932033a5c666a49481122e58cec27 (patch)
treea168396ee8ffee03241b5b56a29a293f3067d51d
parent6153da844acccec9519301e3e15743643c096e09 (diff)
Change dynamic assignment of record handles to a more standard one
-rw-r--r--sdpd/main.c5
-rw-r--r--sdpd/sdpd.h1
-rw-r--r--sdpd/service.c5
-rw-r--r--sdpd/servicedb.c10
4 files changed, 19 insertions, 2 deletions
diff --git a/sdpd/main.c b/sdpd/main.c
index 8b6089d4..0efc7d50 100644
--- a/sdpd/main.c
+++ b/sdpd/main.c
@@ -106,7 +106,10 @@ static void register_public_browse_group(void)
sdp_data_t *sdpdata;
sdp_record_t *browse = sdp_record_alloc();
- browse->handle = (uint32_t)browse;
+ browse->handle = sdp_next_handle();
+ if (browse->handle < 0x10000)
+ return;
+
sdp_record_add(browse);
sdpdata = sdp_data_alloc(SDP_UINT32, &browse->handle);
sdp_attr_add(browse, SDP_ATTR_RECORD_HANDLE, sdpdata);
diff --git a/sdpd/sdpd.h b/sdpd/sdpd.h
index 30eb1de3..bc085c83 100644
--- a/sdpd/sdpd.h
+++ b/sdpd/sdpd.h
@@ -83,6 +83,7 @@ sdp_record_t *sdp_record_find(uint32_t handle);
void sdp_record_add(sdp_record_t *rec);
int sdp_record_remove(uint32_t handle);
sdp_list_t *sdp_get_record_list();
+uint32_t sdp_next_handle(void);
long sdp_get_time();
diff --git a/sdpd/service.c b/sdpd/service.c
index 0834122d..a8d93994 100644
--- a/sdpd/service.c
+++ b/sdpd/service.c
@@ -141,7 +141,10 @@ int service_register_req(sdp_req_t *req, sdp_buf_t *rsp)
return -1;
}
- rec->handle = (uint32_t)rec;
+ rec->handle = sdp_next_handle();
+ if (rec->handle < 0x10000)
+ return -1;
+
sdp_record_add(rec);
if (!(req->flags & SDP_RECORD_PERSIST))
sdp_svcdb_set_collectable(rec, req->sock);
diff --git a/sdpd/servicedb.c b/sdpd/servicedb.c
index 5a6469f5..9f87eca6 100644
--- a/sdpd/servicedb.c
+++ b/sdpd/servicedb.c
@@ -203,3 +203,13 @@ sdp_list_t *sdp_get_record_list()
{
return service_db;
}
+
+uint32_t sdp_next_handle(void)
+{
+ uint32_t handle = 0x10000;
+
+ while (sdp_record_find(handle))
+ handle++;
+
+ return handle;
+}