#include <stdio.h>
#include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
#include "l2cdefs.h"
#include "hcidefs.h"
#include "hcimsgs.h"
/* Safety check in case we go crazy */
#define MAX_NEST_LEVELS 5
+extern fixed_queue_t *btu_general_alarm_queue;
/*******************************************************************************
**
static void sdp_snd_service_search_req(tCONN_CB *p_ccb, UINT8 cont_len, UINT8 * p_cont)
{
UINT8 *p, *p_start, *p_param_len;
- BT_HDR *p_cmd;
+ BT_HDR *p_cmd = (BT_HDR *) osi_malloc(SDP_DATA_BUF_SIZE);
UINT16 param_len;
- /* Get a buffer to send the packet to L2CAP */
- if ((p_cmd = (BT_HDR *) GKI_getpoolbuf (SDP_POOL_ID)) == NULL)
- {
- sdp_disconnect (p_ccb, SDP_NO_RESOURCES);
- return;
- }
-
+ /* Prepare the buffer for sending the packet to L2CAP */
p_cmd->offset = L2CAP_MIN_OFFSET;
p = p_start = (UINT8 *)(p_cmd + 1) + L2CAP_MIN_OFFSET;
L2CA_DataWrite (p_ccb->connection_id, p_cmd);
/* Start inactivity timer */
- btu_start_timer (&p_ccb->timer_entry, BTU_TTYPE_SDP, SDP_INACT_TIMEOUT);
-
+ alarm_set_on_queue(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS,
+ sdp_conn_timer_timeout, p_ccb, btu_general_alarm_queue);
}
/*******************************************************************************
#endif
/* stop inactivity timer when we receive a response */
- btu_stop_timer (&p_ccb->timer_entry);
+ alarm_cancel(p_ccb->sdp_conn_timer);
/* Got a reply!! Check what we got back */
p = (UINT8 *)(p_msg + 1) + p_msg->offset;
#if (SDP_RAW_DATA_INCLUDED == TRUE)
static void sdp_copy_raw_data (tCONN_CB *p_ccb, BOOLEAN offset)
{
- unsigned int cpy_len;
+ unsigned int cpy_len, rem_len;
UINT32 list_len;
UINT8 *p;
UINT8 type;
if(offset)
{
+ cpy_len -= 1;
type = *p++;
+ uint8_t* old_p = p;
p = sdpu_get_len_from_type (p, type, &list_len);
+ if ((int)cpy_len < (p - old_p)) {
+ SDP_TRACE_WARNING("%s: no bytes left for data", __func__);
+ return;
+ }
+ cpy_len -= (p - old_p);
}
- if(list_len && list_len < cpy_len )
+ if(list_len < cpy_len )
{
cpy_len = list_len;
}
+ rem_len = SDP_MAX_LIST_BYTE_COUNT - (unsigned int)(p - &p_ccb->rsp_list[0]);
+ if (cpy_len > rem_len) {
+ SDP_TRACE_WARNING("rem_len :%d less than cpy_len:%d", rem_len, cpy_len);
+ cpy_len = rem_len;
+ }
#if (SDP_DEBUG_RAW == TRUE)
SDP_TRACE_WARNING("list_len :%d cpy_len:%d raw_size:%d raw_used:%d",
list_len, cpy_len, p_ccb->p_db->raw_size, p_ccb->p_db->raw_used);
p_ccb->list_len, list_byte_count);
#endif
if (p_ccb->rsp_list == NULL)
- {
- p_ccb->rsp_list = (UINT8 *)GKI_getbuf (SDP_MAX_LIST_BYTE_COUNT);
- if (p_ccb->rsp_list == NULL)
- {
- SDP_TRACE_ERROR ("SDP - no gki buf to save rsp");
- sdp_disconnect (p_ccb, SDP_NO_RESOURCES);
- return;
- }
- }
- memcpy (&p_ccb->rsp_list[p_ccb->list_len], p_reply, list_byte_count);
+ p_ccb->rsp_list = (UINT8 *)osi_malloc(SDP_MAX_LIST_BYTE_COUNT);
+ memcpy(&p_ccb->rsp_list[p_ccb->list_len], p_reply, list_byte_count);
p_ccb->list_len += list_byte_count;
p_reply += list_byte_count;
#if (SDP_DEBUG_RAW == TRUE)
/* Now, ask for the next handle. Re-use the buffer we just got. */
if (p_ccb->cur_handle < p_ccb->num_handles)
{
- BT_HDR *p_msg = (BT_HDR *) GKI_getpoolbuf (SDP_POOL_ID);
+ BT_HDR *p_msg = (BT_HDR *)osi_malloc(SDP_DATA_BUF_SIZE);
UINT8 *p;
- if (!p_msg)
- {
- sdp_disconnect (p_ccb, SDP_NO_RESOURCES);
- return;
- }
-
p_msg->offset = L2CAP_MIN_OFFSET;
p = p_start = (UINT8 *)(p_msg + 1) + L2CAP_MIN_OFFSET;
L2CA_DataWrite (p_ccb->connection_id, p_msg);
/* Start inactivity timer */
- btu_start_timer (&p_ccb->timer_entry, BTU_TTYPE_SDP, SDP_INACT_TIMEOUT);
+ alarm_set_on_queue(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS,
+ sdp_conn_timer_timeout, p_ccb,
+ btu_general_alarm_queue);
}
else
{
}
if (p_ccb->rsp_list == NULL)
- {
- p_ccb->rsp_list = (UINT8 *)GKI_getbuf (SDP_MAX_LIST_BYTE_COUNT);
- if (p_ccb->rsp_list == NULL)
- {
- SDP_TRACE_ERROR ("SDP - no gki buf to save rsp");
- sdp_disconnect (p_ccb, SDP_NO_RESOURCES);
- return;
- }
- }
+ p_ccb->rsp_list = (UINT8 *)osi_malloc(SDP_MAX_LIST_BYTE_COUNT);
memcpy (&p_ccb->rsp_list[p_ccb->list_len], p_reply, lists_byte_count);
p_ccb->list_len += lists_byte_count;
p_reply += lists_byte_count;
/* If continuation request (or first time request) */
if ((cont_request_needed) || (!p_reply))
{
- BT_HDR *p_msg = (BT_HDR *) GKI_getpoolbuf (SDP_POOL_ID);
+ BT_HDR *p_msg = (BT_HDR *)osi_malloc(SDP_DATA_BUF_SIZE);
UINT8 *p;
- if (!p_msg)
- {
- sdp_disconnect (p_ccb, SDP_NO_RESOURCES);
- return;
- }
-
p_msg->offset = L2CAP_MIN_OFFSET;
p = p_start = (UINT8 *)(p_msg + 1) + L2CAP_MIN_OFFSET;
L2CA_DataWrite (p_ccb->connection_id, p_msg);
/* Start inactivity timer */
- btu_start_timer (&p_ccb->timer_entry, BTU_TTYPE_SDP, SDP_INACT_TIMEOUT);
+ alarm_set_on_queue(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS,
+ sdp_conn_timer_timeout, p_ccb,
+ btu_general_alarm_queue);
return;
}