added sdp_service_attr_async function

This commit is contained in:
Claudio Takahasi 2006-08-30 21:34:20 +00:00
parent adff4cad15
commit ef1fe5feaa

View File

@ -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: