summaryrefslogtreecommitdiffstats
path: root/src/sdpd-request.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdpd-request.c')
-rw-r--r--src/sdpd-request.c94
1 files changed, 47 insertions, 47 deletions
diff --git a/src/sdpd-request.c b/src/sdpd-request.c
index 3ddf25ce..3d82d51d 100644
--- a/src/sdpd-request.c
+++ b/src/sdpd-request.c
@@ -108,7 +108,7 @@ static int extract_des(uint8_t *buf, int len, sdp_list_t **svcReqSeq, uint8_t *p
scanned = sdp_extract_seqtype(buf, len, &seqType, &data_size);
- debug("Seq type : %d", seqType);
+ SDPDBG("Seq type : %d", seqType);
if (!scanned || (seqType != SDP_SEQ8 && seqType != SDP_SEQ16)) {
error("Unknown seq type");
return -1;
@@ -116,27 +116,27 @@ static int extract_des(uint8_t *buf, int len, sdp_list_t **svcReqSeq, uint8_t *p
p = buf + scanned;
bufsize = len - scanned;
- debug("Data size : %d", data_size);
+ SDPDBG("Data size : %d", data_size);
for (;;) {
char *pElem = NULL;
int localSeqLength = 0;
if (bufsize < sizeof(uint8_t)) {
- debug("->Unexpected end of buffer");
+ SDPDBG("->Unexpected end of buffer");
return -1;
}
dataType = *(uint8_t *)p;
- debug("Data type: 0x%02x", dataType);
+ SDPDBG("Data type: 0x%02x", dataType);
if (expectedType == SDP_TYPE_UUID) {
if (dataType != SDP_UUID16 && dataType != SDP_UUID32 && dataType != SDP_UUID128) {
- debug("->Unexpected Data type (expected UUID_ANY)");
+ SDPDBG("->Unexpected Data type (expected UUID_ANY)");
return -1;
}
} else if (expectedType != SDP_TYPE_ANY && dataType != expectedType) {
- debug("->Unexpected Data type (expected 0x%02x)", expectedType);
+ SDPDBG("->Unexpected Data type (expected 0x%02x)", expectedType);
return -1;
}
@@ -146,7 +146,7 @@ static int extract_des(uint8_t *buf, int len, sdp_list_t **svcReqSeq, uint8_t *p
seqlen += sizeof(uint8_t);
bufsize -= sizeof(uint8_t);
if (bufsize < sizeof(uint16_t)) {
- debug("->Unexpected end of buffer");
+ SDPDBG("->Unexpected end of buffer");
return -1;
}
@@ -161,7 +161,7 @@ static int extract_des(uint8_t *buf, int len, sdp_list_t **svcReqSeq, uint8_t *p
seqlen += sizeof(uint8_t);
bufsize -= sizeof(uint8_t);
if (bufsize < (int)sizeof(uint32_t)) {
- debug("->Unexpected end of buffer");
+ SDPDBG("->Unexpected end of buffer");
return -1;
}
@@ -188,7 +188,7 @@ static int extract_des(uint8_t *buf, int len, sdp_list_t **svcReqSeq, uint8_t *p
if (status == 0) {
pSeq = sdp_list_append(pSeq, pElem);
numberOfElements++;
- debug("No of elements : %d", numberOfElements);
+ SDPDBG("No of elements : %d", numberOfElements);
if (seqlen == data_size)
break;
@@ -209,7 +209,7 @@ static int sdp_set_cstate_pdu(sdp_buf_t *buf, sdp_cont_state_t *cstate)
int length = 0;
if (cstate) {
- debug("Non null sdp_cstate_t id : 0x%lx", cstate->timestamp);
+ SDPDBG("Non null sdp_cstate_t id : 0x%lx", cstate->timestamp);
*(uint8_t *)pdata = sizeof(sdp_cont_state_t);
pdata += sizeof(uint8_t);
length += sizeof(uint8_t);
@@ -234,7 +234,7 @@ static sdp_cont_state_t *sdp_cstate_get(uint8_t *buffer)
* Check if continuation state exists, if yes attempt
* to get response remainder from cache, else send error
*/
- debug("Continuation State size : %d", cStateSize);
+ SDPDBG("Continuation State size : %d", cStateSize);
pdata += sizeof(uint8_t);
if (cStateSize != 0) {
@@ -242,8 +242,8 @@ static sdp_cont_state_t *sdp_cstate_get(uint8_t *buffer)
if (!cstate)
return NULL;
memcpy(cstate, (sdp_cont_state_t *)pdata, sizeof(sdp_cont_state_t));
- debug("Cstate TS : 0x%lx", cstate->timestamp);
- debug("Bytes sent : %d", cstate->cStateValue.maxBytesSent);
+ SDPDBG("Cstate TS : 0x%lx", cstate->timestamp);
+ SDPDBG("Bytes sent : %d", cstate->cStateValue.maxBytesSent);
return cstate;
}
return NULL;
@@ -325,8 +325,8 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf)
expected = ntohs(bt_get_unaligned((uint16_t *)pdata));
- debug("Expected count: %d", expected);
- debug("Bytes scanned : %d", scanned);
+ SDPDBG("Expected count: %d", expected);
+ SDPDBG("Bytes scanned : %d", scanned);
pdata += sizeof(uint16_t);
@@ -362,7 +362,7 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf)
for (; list && rsp_count < expected; list = list->next) {
sdp_record_t *rec = (sdp_record_t *) list->data;
- debug("Checking svcRec : 0x%x", rec->handle);
+ SDPDBG("Checking svcRec : 0x%x", rec->handle);
if (sdp_match_uuid(pattern, rec->pattern) > 0 &&
sdp_check_access(rec->handle, &req->device)) {
@@ -373,7 +373,7 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf)
}
}
- debug("Match count: %d", rsp_count);
+ SDPDBG("Match count: %d", rsp_count);
buf->data_size += handleSize;
bt_put_unaligned(htons(rsp_count), (uint16_t *)pTotalRecordCount);
@@ -455,7 +455,7 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf)
*/
sdp_cont_state_t newState;
- debug("Setting non-NULL sdp_cstate_t");
+ SDPDBG("Setting non-NULL sdp_cstate_t");
if (cstate)
memcpy((char *)&newState, cstate, sizeof(sdp_cont_state_t));
@@ -490,14 +490,14 @@ static int extract_attrs(sdp_record_t *rec, sdp_list_t *seq, uint8_t dtd, sdp_bu
return SDP_INVALID_RECORD_HANDLE;
if (seq)
- debug("Entries in attr seq : %d", sdp_list_len(seq));
+ SDPDBG("Entries in attr seq : %d", sdp_list_len(seq));
else
- debug("NULL attribute descriptor");
+ SDPDBG("NULL attribute descriptor");
- debug("AttrDataType : %d", dtd);
+ SDPDBG("AttrDataType : %d", dtd);
if (seq == NULL) {
- debug("Attribute sequence is NULL");
+ SDPDBG("Attribute sequence is NULL");
return 0;
}
if (dtd == SDP_UINT16)
@@ -517,9 +517,9 @@ static int extract_attrs(sdp_record_t *rec, sdp_list_t *seq, uint8_t dtd, sdp_bu
uint16_t high = 0x0000ffff & range;
sdp_data_t *data;
- debug("attr range : 0x%x", range);
- debug("Low id : 0x%x", low);
- debug("High id : 0x%x", high);
+ SDPDBG("attr range : 0x%x", range);
+ SDPDBG("Low id : 0x%x", low);
+ SDPDBG("High id : 0x%x", high);
if (low == 0x0000 && high == 0xffff && pdu.data_size <= buf->buf_size) {
/* copy it */
@@ -592,8 +592,8 @@ static int service_attr_req(sdp_req_t *req, sdp_buf_t *buf)
*/
cstate = sdp_cstate_get(pdata);
- debug("SvcRecHandle : 0x%x", handle);
- debug("max_rsp_size : %d", max_rsp_size);
+ SDPDBG("SvcRecHandle : 0x%x", handle);
+ SDPDBG("max_rsp_size : %d", max_rsp_size);
/*
* Calculate Attribute size acording to MTU
@@ -609,7 +609,7 @@ static int service_attr_req(sdp_req_t *req, sdp_buf_t *buf)
if (cstate) {
sdp_buf_t *pCache = sdp_get_cached_rsp(cstate);
- debug("Obtained cached rsp : %p", pCache);
+ SDPDBG("Obtained cached rsp : %p", pCache);
if (pCache) {
short sent = MIN(max_rsp_size, pCache->data_size - cstate->cStateValue.maxBytesSent);
@@ -618,7 +618,7 @@ static int service_attr_req(sdp_req_t *req, sdp_buf_t *buf)
buf->data_size += sent;
cstate->cStateValue.maxBytesSent += sent;
- debug("Response size : %d sending now : %d bytes sent so far : %d",
+ SDPDBG("Response size : %d sending now : %d bytes sent so far : %d",
pCache->data_size, sent, cstate->cStateValue.maxBytesSent);
if (cstate->cStateValue.maxBytesSent == pCache->data_size)
cstate_size = sdp_set_cstate_pdu(buf, NULL);
@@ -640,7 +640,7 @@ static int service_attr_req(sdp_req_t *req, sdp_buf_t *buf)
* Reset the buffer size to the maximum expected and
* set the sdp_cont_state_t
*/
- debug("Creating continuation state of size : %d", buf->data_size);
+ SDPDBG("Creating continuation state of size : %d", buf->data_size);
buf->data_size = max_rsp_size;
newState.cStateValue.maxBytesSent = max_rsp_size;
cstate_size = sdp_set_cstate_pdu(buf, &newState);
@@ -659,7 +659,7 @@ done:
if (cstate)
free(cstate);
if (seq)
- sdp_list_free(seq, free);
+ sdp_list_free(seq, free);
if (status)
return status;
@@ -688,18 +688,18 @@ static int service_search_attr_req(sdp_req_t *req, sdp_buf_t *buf)
scanned = extract_des(pdata, req->len - sizeof(sdp_pdu_hdr_t),
&pattern, &dtd, SDP_TYPE_UUID);
if (scanned == -1) {
- status = SDP_INVALID_SYNTAX;
+ status = SDP_INVALID_SYNTAX;
goto done;
}
totscanned = scanned;
- debug("Bytes scanned: %d", scanned);
+ SDPDBG("Bytes scanned: %d", scanned);
pdata += scanned;
max = ntohs(bt_get_unaligned((uint16_t *)pdata));
pdata += sizeof(uint16_t);
- debug("Max Attr expected: %d", max);
+ SDPDBG("Max Attr expected: %d", max);
/* extract the attribute list */
scanned = extract_des(pdata, req->len - sizeof(sdp_pdu_hdr_t),
@@ -750,10 +750,10 @@ static int service_search_attr_req(sdp_req_t *req, sdp_buf_t *buf)
rsp_count++;
status = extract_attrs(rec, seq, dtd, &tmpbuf);
- debug("Response count : %d", rsp_count);
- debug("Local PDU size : %d", tmpbuf.data_size);
+ SDPDBG("Response count : %d", rsp_count);
+ SDPDBG("Local PDU size : %d", tmpbuf.data_size);
if (status) {
- debug("Extract attr from record returns err");
+ SDPDBG("Extract attr from record returns err");
break;
}
if (buf->data_size + tmpbuf.data_size < buf->buf_size) {
@@ -765,7 +765,7 @@ static int service_search_attr_req(sdp_req_t *req, sdp_buf_t *buf)
error("Relocation needed");
break;
}
- debug("Net PDU size : %d", buf->data_size);
+ SDPDBG("Net PDU size : %d", buf->data_size);
}
}
if (buf->data_size > max) {
@@ -797,7 +797,7 @@ static int service_search_attr_req(sdp_req_t *req, sdp_buf_t *buf)
cstate_size = sdp_set_cstate_pdu(buf, cstate);
} else {
status = SDP_INVALID_CSTATE;
- debug("Non-null continuation state, but null cache buffer");
+ SDPDBG("Non-null continuation state, but null cache buffer");
}
}
@@ -856,37 +856,37 @@ static void process_request(sdp_req_t *req)
}
switch (reqhdr->pdu_id) {
case SDP_SVC_SEARCH_REQ:
- debug("Got a svc srch req");
+ SDPDBG("Got a svc srch req");
status = service_search_req(req, &rsp);
rsphdr->pdu_id = SDP_SVC_SEARCH_RSP;
break;
case SDP_SVC_ATTR_REQ:
- debug("Got a svc attr req");
+ SDPDBG("Got a svc attr req");
status = service_attr_req(req, &rsp);
rsphdr->pdu_id = SDP_SVC_ATTR_RSP;
break;
case SDP_SVC_SEARCH_ATTR_REQ:
- debug("Got a svc srch attr req");
+ SDPDBG("Got a svc srch attr req");
status = service_search_attr_req(req, &rsp);
rsphdr->pdu_id = SDP_SVC_SEARCH_ATTR_RSP;
break;
/* Following requests are allowed only for local connections */
case SDP_SVC_REGISTER_REQ:
- debug("Service register request");
+ SDPDBG("Service register request");
if (req->local) {
status = service_register_req(req, &rsp);
rsphdr->pdu_id = SDP_SVC_REGISTER_RSP;
}
break;
case SDP_SVC_UPDATE_REQ:
- debug("Service update request");
+ SDPDBG("Service update request");
if (req->local) {
status = service_update_req(req, &rsp);
rsphdr->pdu_id = SDP_SVC_UPDATE_RSP;
}
break;
case SDP_SVC_REMOVE_REQ:
- debug("Service removal request");
+ SDPDBG("Service removal request");
if (req->local) {
status = service_remove_req(req, &rsp);
rsphdr->pdu_id = SDP_SVC_REMOVE_RSP;
@@ -905,7 +905,7 @@ send_rsp:
rsp.data_size = sizeof(uint16_t);
}
- debug("Sending rsp. status %d", status);
+ SDPDBG("Sending rsp. status %d", status);
rsphdr->tid = reqhdr->tid;
rsphdr->plen = htons(rsp.data_size);
@@ -917,7 +917,7 @@ send_rsp:
/* stream the rsp PDU */
sent = send(req->sock, rsp.data, rsp.data_size, 0);
- debug("Bytes Sent : %d", sent);
+ SDPDBG("Bytes Sent : %d", sent);
free(rsp.data);
free(req->buf);