summaryrefslogtreecommitdiffstats
path: root/sdpd
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2006-01-16 15:08:42 +0000
committerMarcel Holtmann <marcel@holtmann.org>2006-01-16 15:08:42 +0000
commitea30752670dc9a522c0ef29c431c3a4cefd9cc83 (patch)
treec915536c7622dbf321771e36e81d067ddcbcbb66 /sdpd
parent88e399ec1d771872d9ee895875218a3d3aa2f6ec (diff)
Fix service record registration
Diffstat (limited to 'sdpd')
-rw-r--r--sdpd/service.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/sdpd/service.c b/sdpd/service.c
index 0bdc87fb..cd40541b 100644
--- a/sdpd/service.c
+++ b/sdpd/service.c
@@ -137,21 +137,25 @@ int service_register_req(sdp_req_t *req, sdp_buf_t *rsp)
// save image of PDU: we need it when clients request this attribute
rec = extract_pdu_server(&req->device, p, 0xffffffff, &scanned);
- if (!rec) {
- sdp_put_unaligned(htons(SDP_INVALID_SYNTAX), (uint16_t *)rsp->data);
- rsp->data_size = sizeof(uint16_t);
- return -1;
- }
+ if (!rec)
+ goto invalid;
- rec->handle = sdp_next_handle();
- if (rec->handle < 0x10000)
- return -1;
+ if (rec->handle == 0xffffffff) {
+ rec->handle = sdp_next_handle();
+ if (rec->handle < 0x10000)
+ goto invalid;
+ } else {
+ if (sdp_record_find(rec->handle))
+ goto invalid;
+ }
sdp_record_add(&req->device, rec);
if (!(req->flags & SDP_RECORD_PERSIST))
sdp_svcdb_set_collectable(rec, req->sock);
+
handle = sdp_data_alloc(SDP_UINT32, &rec->handle);
sdp_attr_replace(rec, SDP_ATTR_RECORD_HANDLE, handle);
+
/*
* if the browse group descriptor is NULL,
* ensure that the record belongs to the ROOT group
@@ -161,12 +165,20 @@ int service_register_req(sdp_req_t *req, sdp_buf_t *rsp)
sdp_uuid16_create(&uuid, PUBLIC_BROWSE_GROUP);
sdp_pattern_add_uuid(rec, &uuid);
}
+
update_db_timestamp();
/* Build a rsp buffer */
sdp_put_unaligned(htonl(rec->handle), (uint32_t *)rsp->data);
rsp->data_size = sizeof(uint32_t);
+
return 0;
+
+invalid:
+ sdp_put_unaligned(htons(SDP_INVALID_SYNTAX), (uint16_t *) rsp->data);
+ rsp->data_size = sizeof(uint16_t);
+
+ return -1;
}
/*