summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2006-08-30 21:34:20 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2006-08-30 21:34:20 +0000
commitef1fe5feaa0dde16562723bcb36343c7bc4c31be (patch)
tree30975bc96178d597c09396d494a7b9bfd65990af
parentadff4cad15e4e13bb9847a0ff62b355caddf89e3 (diff)
added sdp_service_attr_async function
-rw-r--r--src/sdp.c73
1 files changed, 70 insertions, 3 deletions
diff --git a/src/sdp.c b/src/sdp.c
index 27a895f4..014fc4c8 100644
--- a/src/sdp.c
+++ b/src/sdp.c
@@ -3188,8 +3188,77 @@ int sdp_service_search_async(sdp_session_t *session, const sdp_list_t *search_li
int sdp_service_attr_async(sdp_session_t *session, uint32_t handle, sdp_attrreq_type_t reqtype, const sdp_list_t *attrid_list)
{
- /* FIXME: implement! */
+ struct sdp_transaction *t;
+ sdp_pdu_hdr_t *reqhdr;
+ uint8_t *pdata;
+ int seqlen = 0;
+
+ if (!session || !session->priv) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ t = session->priv;
+ t->reqbuf = malloc(SDP_REQ_BUFFER_SIZE);
+ if (!t->reqbuf) {
+ errno = ENOMEM;
+ goto end;
+ }
+
+ memset(t->reqbuf, 0, SDP_REQ_BUFFER_SIZE);
+ memset((char *)&t->rsp_concat_buf, 0, sizeof(sdp_buf_t));
+
+ reqhdr = (sdp_pdu_hdr_t *) t->reqbuf;
+ reqhdr->tid = htons(sdp_gen_tid(session));
+ reqhdr->pdu_id = SDP_SVC_ATTR_REQ;
+
+ // generate PDU
+ pdata = t->reqbuf + sizeof(sdp_pdu_hdr_t);
+ t->reqsize = sizeof(sdp_pdu_hdr_t);
+
+ // add the service record handle
+ bt_put_unaligned(htonl(handle), (uint32_t *) pdata);
+ t->reqsize += sizeof(uint32_t);
+ pdata += sizeof(uint32_t);
+
+ // specify the response limit
+ bt_put_unaligned(htons(65535), (uint16_t *) pdata);
+ t->reqsize += sizeof(uint16_t);
+ pdata += sizeof(uint16_t);
+
+ // get attr seq PDU form
+ seqlen = gen_attridseq_pdu(pdata, attrid_list,
+ reqtype == SDP_ATTR_REQ_INDIVIDUAL? SDP_UINT16 : SDP_UINT32);
+ if (seqlen == -1) {
+ errno = EINVAL;
+ goto end;
+ }
+
+ // now set the length and increment the pointer
+ t->reqsize += seqlen;
+ pdata += seqlen;
+ SDPDBG("Attr list length : %d\n", seqlen);
+
+ // set the request header's param length
+ t->cstate_len = copy_cstate(pdata, t->cstate);
+
+ reqhdr->plen = htons((t->reqsize + t->cstate_len) - sizeof(sdp_pdu_hdr_t));
+
+ if (sdp_send_req(session, t->reqbuf, t->reqsize + t->cstate_len) < 0) {
+ SDPERR("Error sendind data:%s", strerror(errno));
+ goto end;
+ }
+
return 0;
+end:
+
+ if (t) {
+ if (t->reqbuf)
+ free(t->reqbuf);
+ free(t);
+ }
+
+ return -1;
}
/*
@@ -3296,8 +3365,6 @@ int sdp_service_search_attr_async(sdp_session_t *session, const sdp_list_t *sear
goto end;
}
- session->priv = t;
-
return 0;
end: