- Prepending l2cap header in a separate function to not play with c++ contexts
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36026 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -101,6 +101,33 @@ struct bt_hci_module_info* btDevices = NULL;
|
|||||||
static thread_id sConnectionThread;
|
static thread_id sConnectionThread;
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
AddL2capHeader(L2capFrame* frame)
|
||||||
|
{
|
||||||
|
NetBufferPrepend<l2cap_hdr_t> bufferHeader(frame->buffer);
|
||||||
|
status_t status = bufferHeader.Status();
|
||||||
|
|
||||||
|
if (status < B_OK) {
|
||||||
|
debugf("header could not be prepended! code=%d\n", frame->code);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fill
|
||||||
|
bufferHeader->length = htole16(frame->buffer->size - sizeof(l2cap_hdr_t));
|
||||||
|
switch (frame->type) {
|
||||||
|
case L2CAP_C_FRAME:
|
||||||
|
bufferHeader->dcid = L2CAP_SIGNAL_CID;
|
||||||
|
break;
|
||||||
|
case L2CAP_G_FRAME:
|
||||||
|
bufferHeader->dcid = L2CAP_CLT_CID;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
bufferHeader->dcid = frame->channel->dcid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
purge_connection(HciConnection* conn)
|
purge_connection(HciConnection* conn)
|
||||||
{
|
{
|
||||||
@@ -130,30 +157,7 @@ purge_connection(HciConnection* conn)
|
|||||||
if (frame->buffer == NULL)
|
if (frame->buffer == NULL)
|
||||||
panic("Malformed frame in ongoing queue");
|
panic("Malformed frame in ongoing queue");
|
||||||
|
|
||||||
{
|
AddL2capHeader(frame);
|
||||||
NetBufferPrepend<l2cap_hdr_t> bufferHeader(frame->buffer);
|
|
||||||
status_t status = bufferHeader.Status();
|
|
||||||
if (status < B_OK) {
|
|
||||||
debugf("header could not be prepended! code=%d\n", frame->code);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// fill
|
|
||||||
bufferHeader->length = htole16(frame->buffer->size - sizeof(l2cap_hdr_t));
|
|
||||||
switch (frame->type) {
|
|
||||||
case L2CAP_C_FRAME:
|
|
||||||
bufferHeader->dcid = L2CAP_SIGNAL_CID;
|
|
||||||
break;
|
|
||||||
case L2CAP_G_FRAME:
|
|
||||||
bufferHeader->dcid = L2CAP_CLT_CID;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
bufferHeader->dcid = frame->channel->dcid;
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (btDevices == NULL)
|
if (btDevices == NULL)
|
||||||
if (get_module(BT_HCI_MODULE_NAME, (module_info**)&btDevices) != B_OK) {
|
if (get_module(BT_HCI_MODULE_NAME, (module_info**)&btDevices) != B_OK) {
|
||||||
|
|||||||
Reference in New Issue
Block a user