2010-01-17 15:46:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
|
|
|
* All rights reserved. Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _BTCOREDATA_H
|
|
|
|
#define _BTCOREDATA_H
|
|
|
|
|
2010-08-19 15:29:02 +00:00
|
|
|
|
2010-01-17 15:46:36 +00:00
|
|
|
#include <module.h>
|
|
|
|
#include <lock.h>
|
|
|
|
#include <util/DoublyLinkedList.h>
|
2024-04-26 16:22:39 -04:00
|
|
|
#include <util/VectorMap.h>
|
|
|
|
#include <net_datalink.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
|
2010-01-17 15:46:36 +00:00
|
|
|
|
|
|
|
#include <net_buffer.h>
|
|
|
|
#include <net_device.h>
|
|
|
|
|
|
|
|
#include <bluetooth/bluetooth.h>
|
|
|
|
#include <bluetooth/HCI/btHCI.h>
|
|
|
|
#include <bluetooth/HCI/btHCI_transport.h>
|
|
|
|
#include <l2cap.h>
|
|
|
|
|
2010-08-19 15:29:02 +00:00
|
|
|
|
2010-01-17 15:46:36 +00:00
|
|
|
#define BT_CORE_DATA_MODULE_NAME "bluetooth/btCoreData/v1"
|
|
|
|
|
2010-08-19 15:29:02 +00:00
|
|
|
|
2010-01-17 15:46:36 +00:00
|
|
|
typedef enum _connection_status {
|
|
|
|
HCI_CONN_CLOSED,
|
|
|
|
HCI_CONN_OPEN,
|
|
|
|
} connection_status;
|
|
|
|
|
2010-08-19 15:29:02 +00:00
|
|
|
|
2010-01-17 15:46:36 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
|
|
struct HciConnection : DoublyLinkedListLinkImpl<HciConnection> {
|
2024-04-26 16:22:39 -04:00
|
|
|
HciConnection(hci_id hid);
|
2010-01-17 15:46:36 +00:00
|
|
|
virtual ~HciConnection();
|
|
|
|
|
|
|
|
hci_id Hid;
|
|
|
|
bluetooth_device* ndevice;
|
|
|
|
bdaddr_t destination;
|
|
|
|
uint16 handle;
|
|
|
|
int type;
|
|
|
|
uint16 mtu;
|
|
|
|
connection_status status;
|
|
|
|
|
2024-04-26 16:22:39 -04:00
|
|
|
net_buffer* currentRxPacket;
|
|
|
|
ssize_t currentRxExpectedLength;
|
2010-01-17 15:46:36 +00:00
|
|
|
|
2024-04-26 16:22:39 -04:00
|
|
|
struct net_interface_address interface_address;
|
|
|
|
struct sockaddr_dl address_dl;
|
|
|
|
struct sockaddr_storage address_dest;
|
2010-01-17 15:46:36 +00:00
|
|
|
|
2024-04-26 16:22:39 -04:00
|
|
|
void (*disconnect_hook)(HciConnection*);
|
2010-01-17 15:46:36 +00:00
|
|
|
|
2024-04-26 16:22:39 -04:00
|
|
|
public:
|
|
|
|
mutex fLock;
|
|
|
|
uint8 fNextIdent;
|
|
|
|
VectorMap<uint8, void*> fInUseIdents;
|
2010-01-17 15:46:36 +00:00
|
|
|
};
|
|
|
|
|
2024-04-26 16:22:39 -04:00
|
|
|
#else
|
2010-01-17 15:46:36 +00:00
|
|
|
|
2024-04-26 16:22:39 -04:00
|
|
|
struct HciConnection;
|
2010-01-17 15:46:36 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
struct bluetooth_core_data_module_info {
|
|
|
|
module_info info;
|
|
|
|
|
|
|
|
status_t (*PostEvent)(bluetooth_device* ndev, void* event,
|
|
|
|
size_t size);
|
2024-04-26 16:22:39 -04:00
|
|
|
|
|
|
|
// FIXME: We really shouldn't be passing out connection pointers at all...
|
2010-01-17 15:46:36 +00:00
|
|
|
struct HciConnection* (*AddConnection)(uint16 handle, int type,
|
2010-08-19 15:29:02 +00:00
|
|
|
const bdaddr_t& dst, hci_id hid);
|
2010-01-17 15:46:36 +00:00
|
|
|
|
|
|
|
// status_t (*RemoveConnection)(bdaddr_t destination, hci_id hid);
|
|
|
|
status_t (*RemoveConnection)(uint16 handle, hci_id hid);
|
|
|
|
|
2010-08-19 15:29:02 +00:00
|
|
|
hci_id (*RouteConnection)(const bdaddr_t& destination);
|
2010-01-17 15:46:36 +00:00
|
|
|
|
|
|
|
struct HciConnection* (*ConnectionByHandle)(uint16 handle, hci_id hid);
|
2010-08-19 15:29:02 +00:00
|
|
|
struct HciConnection* (*ConnectionByDestination)(
|
|
|
|
const bdaddr_t& destination, hci_id hid);
|
2010-01-17 15:46:36 +00:00
|
|
|
|
2024-04-26 16:22:39 -04:00
|
|
|
uint8 (*allocate_command_ident)(struct HciConnection* conn, void* associated);
|
|
|
|
void* (*lookup_command_ident)(struct HciConnection* conn, uint8 ident);
|
|
|
|
void (*free_command_ident)(struct HciConnection* conn, uint8 ident);
|
2010-01-17 15:46:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-08-19 15:29:02 +00:00
|
|
|
inline bool ExistConnectionByDestination(const bdaddr_t& destination,
|
|
|
|
hci_id hid);
|
2010-01-17 15:46:36 +00:00
|
|
|
inline bool ExistConnectionByHandle(uint16 handle, hci_id hid);
|
|
|
|
|
2010-08-19 15:29:02 +00:00
|
|
|
|
2010-01-17 15:46:36 +00:00
|
|
|
#endif // _BTCOREDATA_H
|