Add class to handle all code values to be sent in the ports

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34024 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes 2009-11-13 22:03:33 +00:00
parent faf42dfe78
commit 02d67528b5
2 changed files with 73 additions and 2 deletions

View File

@ -0,0 +1,64 @@
#ifndef _CODEHANDLER_H_
#define _CODEHANDLER_H_
#include <bluetooth/HCI/btHCI.h>
namespace Bluetooth
{
class CodeHandler {
public:
/*
* TODO: Handler and protocol could be fit in 16 bits 12
* for handler and 4 for the protocol
*/
/*
* Used:
* - From HCI layer to send events to bluetooth server.
* - L2cap lower to dispatch TX packets to HCI Layer informing about connection handle
* - Transport drivers dispatch its data to HCI layer
*
*/
static inline hci_id Device(uint32 code)
{
return ((code & 0xFF) >> 24);
}
static inline void SetDevice(uint32* code, hci_id device)
{
*code = *code | ((device & 0xFF) << 24);
}
static inline uint16 Handler(uint32 code)
{
return ((code & 0xFFFF) >> 0);
}
static void SetHandler(uint32* code, uint16 handler)
{
*code = *code | ((handler & 0xFFFF) << 0);
}
static bt_packet_t Protocol(uint32 code)
{
return (bt_packet_t)((code && 0xFF) >> 16);
}
static void SetProtocol(uint32* code, bt_packet_t protocol)
{
*code = *code | ((protocol & 0xFF) << 16);
}
};
} // namespace
#endif

View File

@ -6,6 +6,7 @@
#define _BTCOREDATA_H
#include <module.h>
#include <lock.h>
#include <util/DoublyLinkedList.h>
#include <util/DoublyLinkedQueue.h>
@ -30,6 +31,9 @@ typedef enum _connection_status {
#ifdef __cplusplus
struct HciConnection : DoublyLinkedListLinkImpl<HciConnection> {
HciConnection();
virtual ~HciConnection();
hci_id Hid;
struct net_device* ndevice;
net_buffer* currentRxPacket;
@ -44,6 +48,8 @@ struct HciConnection : DoublyLinkedListLinkImpl<HciConnection> {
DoublyLinkedList<L2capChannel> ChannelList;
DoublyLinkedList<L2capFrame> ExpectedResponses;
DoublyLinkedList<L2capFrame> OutGoingFrames;
mutex fLock;
mutex fLockExpected;
};
#else
@ -84,7 +90,7 @@ struct L2capChannel : DoublyLinkedListLinkImpl<L2capChannel> {
uint16 psm;
uint8 ident;
uint8 cfgState;
channel_status state;
ChannelConfiguration* configuration;
L2capEndpoint* endpoint;
@ -154,9 +160,10 @@ struct bluetooth_core_data_module_info {
struct L2capFrame* (*SignalByIdent)(struct HciConnection* conn, uint8 ident);
status_t (*TimeoutSignal)(struct L2capFrame* frame, uint32 timeo);
status_t (*UnTimeoutSignal)(struct L2capFrame* frame);
struct L2capFrame* (*SpawnFrame)(struct HciConnection* conn, net_buffer* buffer, frame_type frame);
struct L2capFrame* (*SpawnFrame)(struct HciConnection* conn, struct L2capChannel* channel, net_buffer* buffer, frame_type frame);
struct L2capFrame* (*SpawnSignal)(struct HciConnection* conn, struct L2capChannel* channel, net_buffer* buffer, uint8 ident, uint8 code);
status_t (*AcknowledgeSignal)(struct L2capFrame* frame);
status_t (*QueueSignal)(struct L2capFrame* frame);
};