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