bluetooth/filter: add more OGF into ble blacklist

Change-Id: I4f1b98dc63ab2d9eeb523b8040aae88ea285bb9a
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an
2021-04-24 12:22:09 +08:00
committed by anchao
parent 438774a560
commit df71da9450
3 changed files with 55 additions and 14 deletions
+2 -2
View File
@@ -39,7 +39,7 @@
* Pre-processor Definitions
****************************************************************************/
#define HCI_RECVBUF_SIZE 4096
#define HCI_RECVBUF_SIZE 8192
#define HCI_SENDBUF_SIZE 1024
#define HCI_NPOLLWAITERS 2
@@ -76,7 +76,7 @@ struct bt_uart_bridge_s
sem_t sendlock;
struct file filep;
char tmpbuf[HCI_RECVBUF_SIZE];
char tmpbuf[1024];
};
/****************************************************************************
+50 -12
View File
@@ -251,13 +251,49 @@ bool bt_uart_filter_forward_recv(FAR struct bt_uart_filter_s *filter,
case BT_HCI_EVT_CMD_COMPLETE:
{
FAR struct hci_evt_cmd_complete_s *evt;
uint8_t ogf;
evt = (FAR void *)&buffer[3];
ogf = evt->opcode >> 10;
if (BT_OGF_BASEBAND == (evt->opcode >> 10))
if (BT_OGF_BASEBAND == ogf ||
BT_OGF_LINK_CTRL == ogf ||
BT_OGF_INFO == ogf)
{
return bt_uart_filter_free_opcode(filter, evt->opcode);
}
else if (BT_OGF_LINK_POLICY == ogf ||
BT_OGF_STATUS == ogf)
{
if (filter->type == BT_UART_FILTER_TYPE_BLE)
{
return false;
}
}
}
break;
case BT_HCI_EVT_CMD_STATUS:
{
FAR struct bt_hci_evt_cmd_status_s *stat;
uint8_t ogf;
stat = (FAR void *)&buffer[3];
ogf = stat->opcode >> 10;
if (BT_OGF_BASEBAND == ogf ||
BT_OGF_LINK_CTRL == ogf ||
BT_OGF_INFO == ogf)
{
return bt_uart_filter_free_opcode(filter, stat->opcode);
}
if (BT_OGF_LINK_POLICY == ogf ||
BT_OGF_STATUS == ogf)
{
if (filter->type == BT_UART_FILTER_TYPE_BLE)
{
return false;
}
}
}
break;
default:
@@ -284,6 +320,7 @@ bool bt_uart_filter_forward_send(FAR struct bt_uart_filter_s *filter,
if (buffer[0] == H4_CMD)
{
opcode = (uint16_t)buffer[2] << 8 | (uint16_t)buffer[1];
ogf = buffer[2] >> 2;
switch (opcode)
{
@@ -302,22 +339,23 @@ bool bt_uart_filter_forward_send(FAR struct bt_uart_filter_s *filter,
break;
}
ogf = buffer[2] >> 2;
if (BT_OGF_BASEBAND == ogf)
if (BT_OGF_BASEBAND == ogf ||
BT_OGF_LINK_CTRL == ogf ||
BT_OGF_INFO == ogf)
{
if (!bt_uart_filter_alloc_opcode(filter, opcode))
{
nerr("Unable to set opcode 0x%04x.\n", opcode);
{
nerr("Unable to set opcode 0x%04x.\n", opcode);
for (i = 0; i < BT_UART_FILTER_OPCODE_COUNT; i++)
{
nerr("PENDING opcode: %04x.\n", filter->opcode[i]);
}
for (i = 0; i < BT_UART_FILTER_OPCODE_COUNT; i++)
{
nerr("PENDING opcode: %04x.\n", filter->opcode[i]);
}
memset(filter->opcode, 0, sizeof(filter->opcode));
memset(filter->opcode, 0, sizeof(filter->opcode));
bt_uart_filter_alloc_opcode(filter, opcode);
}
bt_uart_filter_alloc_opcode(filter, opcode);
}
}
}
@@ -115,8 +115,10 @@
/* OpCode Group Fields */
#define BT_OGF_LINK_CTRL 0x01
#define BT_OGF_LINK_POLICY 0x02
#define BT_OGF_BASEBAND 0x03
#define BT_OGF_INFO 0x04
#define BT_OGF_STATUS 0x05
#define BT_OGF_LE 0x08
/* Construct OpCode from OGF and OCF */
@@ -127,6 +129,7 @@
#define BT_OP(ogf, ocf) ((ocf) | ((ogf) << 10))
#define BT_HCI_OP_DISCONNECT BT_OP(BT_OGF_LINK_CTRL, 0x0006)
#define BT_HCI_OP_READ_REMOTE_VERSION_INFO BT_OP(BT_OGF_LINK_CTRL, 0x001d)
#define BT_HCI_OP_SET_EVENT_MASK BT_OP(BT_OGF_BASEBAND, 0x0001)
#define BT_HCI_OP_RESET BT_OP(BT_OGF_BASEBAND, 0x0003)
#define BT_HCI_OP_SET_CTL_TO_HOST_FLOW BT_OP(BT_OGF_BASEBAND, 0x0031)