summaryrefslogtreecommitdiffstats
path: root/sdpd
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2006-11-17 13:19:28 +0000
committerMarcel Holtmann <marcel@holtmann.org>2006-11-17 13:19:28 +0000
commit118f6f9f013b38afc5b65dd0e4de97e9baad07e6 (patch)
tree75422c1057eace635fffd7994f0a32d23b47813c /sdpd
parent569abc7679a7ba14d2d9edef7e000d28c21d955b (diff)
Remove sdp_put_unaligned and sdp_get_unaligned macros
Diffstat (limited to 'sdpd')
-rw-r--r--sdpd/request.c40
-rw-r--r--sdpd/sdpd.h3
-rw-r--r--sdpd/service.c18
3 files changed, 29 insertions, 32 deletions
diff --git a/sdpd/request.c b/sdpd/request.c
index 17aa9d99..471871d7 100644
--- a/sdpd/request.c
+++ b/sdpd/request.c
@@ -98,7 +98,7 @@ static int extract_des(uint8_t *buf, int len, sdp_list_t **svcReqSeq, uint8_t *p
p += sizeof(uint8_t);
seqlen += sizeof(uint8_t);
pElem = malloc(sizeof(uint16_t));
- sdp_put_unaligned(ntohs(sdp_get_unaligned((uint16_t *)p)), (uint16_t *)pElem);
+ bt_put_unaligned(ntohs(bt_get_unaligned((uint16_t *)p)), (uint16_t *)pElem);
p += sizeof(uint16_t);
seqlen += sizeof(uint16_t);
break;
@@ -106,7 +106,7 @@ static int extract_des(uint8_t *buf, int len, sdp_list_t **svcReqSeq, uint8_t *p
p += sizeof(uint8_t);
seqlen += sizeof(uint8_t);
pElem = malloc(sizeof(uint32_t));
- sdp_put_unaligned(ntohl(sdp_get_unaligned((uint32_t *)p)), (uint32_t *)pElem);
+ bt_put_unaligned(ntohl(bt_get_unaligned((uint32_t *)p)), (uint32_t *)pElem);
p += sizeof(uint32_t);
seqlen += sizeof(uint32_t);
break;
@@ -259,7 +259,7 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf)
goto done;
}
- expected = ntohs(sdp_get_unaligned((uint16_t *)pdata));
+ expected = ntohs(bt_get_unaligned((uint16_t *)pdata));
debug("Expected count: %d", expected);
debug("Bytes scanned : %d", scanned);
@@ -280,13 +280,13 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf)
/* total service record count = 0 */
pTotalRecordCount = (short *)pdata;
- sdp_put_unaligned(0, (uint16_t *)pdata);
+ bt_put_unaligned(0, (uint16_t *)pdata);
pdata += sizeof(uint16_t);
buf->data_size += sizeof(uint16_t);
/* current service record count = 0 */
pCurrentRecordCount = (short *)pdata;
- sdp_put_unaligned(0, (uint16_t *)pdata);
+ bt_put_unaligned(0, (uint16_t *)pdata);
pdata += sizeof(uint16_t);
buf->data_size += sizeof(uint16_t);
@@ -303,7 +303,7 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf)
if (sdp_match_uuid(pattern, rec->pattern) > 0 &&
sdp_check_access(rec->handle, &req->device)) {
rsp_count++;
- sdp_put_unaligned(htonl(rec->handle), (uint32_t *)pdata);
+ bt_put_unaligned(htonl(rec->handle), (uint32_t *)pdata);
pdata += sizeof(uint32_t);
handleSize += sizeof(uint32_t);
}
@@ -312,8 +312,8 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf)
debug("Match count: %d", rsp_count);
buf->data_size += handleSize;
- sdp_put_unaligned(htons(rsp_count), (uint16_t *)pTotalRecordCount);
- sdp_put_unaligned(htons(rsp_count), (uint16_t *)pCurrentRecordCount);
+ bt_put_unaligned(htons(rsp_count), (uint16_t *)pTotalRecordCount);
+ bt_put_unaligned(htons(rsp_count), (uint16_t *)pCurrentRecordCount);
if (rsp_count > actual) {
/* cache the rsp and generate a continuation state */
@@ -342,7 +342,7 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf)
if (pCache) {
pCacheBuffer = pCache->data;
/* get the rsp_count from the cached buffer */
- rsp_count = ntohs(sdp_get_unaligned((uint16_t *)pCacheBuffer));
+ rsp_count = ntohs(bt_get_unaligned((uint16_t *)pCacheBuffer));
/* get index of the last sdp_record_t sent */
lastIndex = cstate->cStateValue.lastIndexSent;
@@ -368,7 +368,7 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf)
if (cstate) {
handleSize = 0;
for (i = lastIndex; (i - lastIndex) < actual && i < rsp_count; i++) {
- sdp_put_unaligned(sdp_get_unaligned((uint32_t *)(pCacheBuffer + i * sizeof(uint32_t))), (uint32_t *)pdata);
+ bt_put_unaligned(bt_get_unaligned((uint32_t *)(pCacheBuffer + i * sizeof(uint32_t))), (uint32_t *)pdata);
pdata += sizeof(uint32_t);
handleSize += sizeof(uint32_t);
}
@@ -378,8 +378,8 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf)
}
buf->data_size += handleSize;
- sdp_put_unaligned(htons(rsp_count), (uint16_t *)pTotalRecordCount);
- sdp_put_unaligned(htons(i - lastIndex), (uint16_t *)pCurrentRecordCount);
+ bt_put_unaligned(htons(rsp_count), (uint16_t *)pTotalRecordCount);
+ bt_put_unaligned(htons(i - lastIndex), (uint16_t *)pCurrentRecordCount);
if (i == rsp_count) {
/* set "null" continuationState */
@@ -436,7 +436,7 @@ static int extract_attrs(sdp_record_t *rec, sdp_list_t *seq, uint8_t dtd, sdp_bu
}
if (dtd == SDP_UINT16)
for (; seq; seq = seq->next) {
- uint16_t attr = sdp_get_unaligned((uint16_t *)seq->data);
+ uint16_t attr = bt_get_unaligned((uint16_t *)seq->data);
sdp_data_t *a = (sdp_data_t *)sdp_data_get(rec, attr);
if (a)
sdp_append_to_pdu(buf, a);
@@ -445,7 +445,7 @@ static int extract_attrs(sdp_record_t *rec, sdp_list_t *seq, uint8_t dtd, sdp_bu
sdp_buf_t pdu;
sdp_gen_record_pdu(rec, &pdu);
for (; seq; seq = seq->next) {
- uint32_t range = sdp_get_unaligned((uint32_t *)seq->data);
+ uint32_t range = bt_get_unaligned((uint32_t *)seq->data);
uint16_t attr;
uint16_t low = (0xffff0000 & range) >> 16;
uint16_t high = 0x0000ffff & range;
@@ -497,10 +497,10 @@ static int service_attr_req(sdp_req_t *req, sdp_buf_t *buf)
int max_rsp_size;
int status = 0, plen, mlen;
uint8_t *pdata = req->buf + sizeof(sdp_pdu_hdr_t);
- uint32_t handle = ntohl(sdp_get_unaligned((uint32_t *)pdata));
+ uint32_t handle = ntohl(bt_get_unaligned((uint32_t *)pdata));
pdata += sizeof(uint32_t);
- max_rsp_size = ntohs(sdp_get_unaligned((uint16_t *)pdata));
+ max_rsp_size = ntohs(bt_get_unaligned((uint16_t *)pdata));
pdata += sizeof(uint16_t);
/* extract the attribute list */
@@ -596,7 +596,7 @@ done:
return status;
/* set attribute list byte count */
- sdp_put_unaligned(htons(buf->data_size - cstate_size), (uint16_t *)buf->data);
+ bt_put_unaligned(htons(buf->data_size - cstate_size), (uint16_t *)buf->data);
buf->data_size += sizeof(uint16_t);
return 0;
}
@@ -628,7 +628,7 @@ static int service_search_attr_req(sdp_req_t *req, sdp_buf_t *buf)
debug("Bytes scanned: %d", scanned);
pdata += scanned;
- max = ntohs(sdp_get_unaligned((uint16_t *)pdata));
+ max = ntohs(bt_get_unaligned((uint16_t *)pdata));
pdata += sizeof(uint16_t);
debug("Max Attr expected: %d", max);
@@ -746,7 +746,7 @@ static int service_search_attr_req(sdp_req_t *req, sdp_buf_t *buf)
if (!status) {
/* set attribute list byte count */
- sdp_put_unaligned(htons(buf->data_size - cstate_size), (uint16_t *)buf->data);
+ bt_put_unaligned(htons(buf->data_size - cstate_size), (uint16_t *)buf->data);
buf->data_size += sizeof(uint16_t);
}
@@ -831,7 +831,7 @@ void process_request(sdp_req_t *req)
send_rsp:
if (status) {
rsphdr->pdu_id = SDP_ERROR_RSP;
- sdp_put_unaligned(htons(status), (uint16_t *)rsp.data);
+ bt_put_unaligned(htons(status), (uint16_t *)rsp.data);
rsp.data_size = sizeof(uint16_t);
}
diff --git a/sdpd/sdpd.h b/sdpd/sdpd.h
index 69c1446e..67ba4e78 100644
--- a/sdpd/sdpd.h
+++ b/sdpd/sdpd.h
@@ -24,9 +24,6 @@
*
*/
-#define sdp_get_unaligned bt_get_unaligned
-#define sdp_put_unaligned bt_put_unaligned
-
typedef struct request {
bdaddr_t device;
bdaddr_t bdaddr;
diff --git a/sdpd/service.c b/sdpd/service.c
index b6ac0ac1..ce292292 100644
--- a/sdpd/service.c
+++ b/sdpd/service.c
@@ -56,12 +56,12 @@ static sdp_record_t *extract_pdu_server(bdaddr_t *device, uint8_t *p, uint32_t h
*scanned = sdp_extract_seqtype(p, &dtd, &seqlen);
p += *scanned;
- lookAheadAttrId = ntohs(sdp_get_unaligned((uint16_t *) (p + sizeof(uint8_t))));
+ lookAheadAttrId = ntohs(bt_get_unaligned((uint16_t *) (p + sizeof(uint8_t))));
debug("Look ahead attr id : %d", lookAheadAttrId);
if (lookAheadAttrId == SDP_ATTR_RECORD_HANDLE) {
- handle = ntohl(sdp_get_unaligned((uint32_t *) (p +
+ handle = ntohl(bt_get_unaligned((uint32_t *) (p +
sizeof(uint8_t) + sizeof(uint16_t) +
sizeof(uint8_t))));
debug("SvcRecHandle : 0x%x", handle);
@@ -88,7 +88,7 @@ static sdp_record_t *extract_pdu_server(bdaddr_t *device, uint8_t *p, uint32_t h
debug("Extract PDU, sequenceLength: %d localExtractedLength: %d", seqlen, localExtractedLength);
dtd = *(uint8_t *) p;
- attrId = ntohs(sdp_get_unaligned((uint16_t *) (p + attrSize)));
+ attrId = ntohs(bt_get_unaligned((uint16_t *) (p + attrSize)));
attrSize += sizeof(uint16_t);
debug("DTD of attrId : %d Attr id : 0x%x", dtd, attrId);
@@ -170,13 +170,13 @@ int service_register_req(sdp_req_t *req, sdp_buf_t *rsp)
update_db_timestamp();
/* Build a rsp buffer */
- sdp_put_unaligned(htonl(rec->handle), (uint32_t *) rsp->data);
+ bt_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);
+ bt_put_unaligned(htons(SDP_INVALID_SYNTAX), (uint16_t *) rsp->data);
rsp->data_size = sizeof(uint16_t);
return -1;
@@ -190,7 +190,7 @@ int service_update_req(sdp_req_t *req, sdp_buf_t *rsp)
sdp_record_t *orec;
int status = 0, scanned = 0;
uint8_t *p = req->buf + sizeof(sdp_pdu_hdr_t);
- uint32_t handle = ntohl(sdp_get_unaligned((uint32_t *) p));
+ uint32_t handle = ntohl(bt_get_unaligned((uint32_t *) p));
debug("Svc Rec Handle: 0x%x", handle);
@@ -219,7 +219,7 @@ int service_update_req(sdp_req_t *req, sdp_buf_t *rsp)
status = SDP_INVALID_RECORD_HANDLE;
p = rsp->data;
- sdp_put_unaligned(htons(status), (uint16_t *) p);
+ bt_put_unaligned(htons(status), (uint16_t *) p);
rsp->data_size = sizeof(uint16_t);
return status;
}
@@ -230,7 +230,7 @@ int service_update_req(sdp_req_t *req, sdp_buf_t *rsp)
int service_remove_req(sdp_req_t *req, sdp_buf_t *rsp)
{
uint8_t *p = req->buf + sizeof(sdp_pdu_hdr_t);
- uint32_t handle = ntohl(sdp_get_unaligned((uint32_t *) p));
+ uint32_t handle = ntohl(bt_get_unaligned((uint32_t *) p));
sdp_record_t *rec;
int status = 0;
@@ -250,7 +250,7 @@ int service_remove_req(sdp_req_t *req, sdp_buf_t *rsp)
}
p = rsp->data;
- sdp_put_unaligned(htons(status), (uint16_t *) p);
+ bt_put_unaligned(htons(status), (uint16_t *) p);
rsp->data_size = sizeof(uint16_t);
return status;