ainfix.com>
* Copyright (C) 2011 Mathieu Desnoyers
*
* SPDX-License-Identifier: GPL-2.0-only
*
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "hci.h"
#include "btm_hci_if.h"
#include "packet.h"
#include "hci_lib.h"
#include "hci_event.h"
#include "pkt_rndis.h"
#include "event_hrt.h"
#include "hci_utils.h"
#include "l2cap.h"
#include "hci_cmd.h"
#include "btm_l2cap_trans.h"
#include "l2cap_packet.h"
#include "rndis_packet.h"
#include "netdev.h"
#include "qos_utils.h"
#include "per_connection_data.h"
#include "acl_provider.h"
#include "sys_info.h"
#include "event_rndis.h"
#include "event_gap_bridge.h"
static uint16_t cmd_id;
static uint32_t param1;
static uint32_t param2;
static uint32_t param3;
static uint32_t param4;
static uint32_t param5;
static uint16_t payload_len;
static uint8_t trans_id;
static struct l2cap_hdr *l2cap;
static struct net_buf *b;
static int rx_event_handle;
static uint32_t event_time_stamp;
static uint16_t event_delay_count;
static uint8_t rndis_dev_class;
static int rndis_handle;
static int init_rndis(void);
#define DEBUG_PRINTF(fmt, ...) do { \
if (rndis_dev_class == RNDIS_REAL_DEVICE) { \
char buf[256]; \
snprintf(buf, sizeof(buf), fmt "\n", ##__VA_ARGS__); \
pr_info("DBG[%s] - %s", __func__, buf); \
} \
} while (0)
#define LOG_LEVEL LOG_DEBUG
#include
static int logger_level = LOG_DEBUG;
#define LOG(level, fmt, ...) do { \
if ((level >= logger_level)) { \
fprintf(stderr, "DBG[%s] - %s: " fmt "\n", \
__func__, __FILE__, ##__VA_ARGS__); \
} \
} while (0)
#define ERR(fmt, ...) do { \
pr_err("ERR[%s] - %s: " fmt "\n", __func__, __FILE__, ##__VA_ARGS__); \
} while (0)
#define CRIT(fmt, ...) do { \
printk(KERN_WARNING "CRIT[%s] - %s: " fmt "\n", \
__func__, __FILE__, ##__VA_ARGS__); \
} while (0)
static int pkt_to_buf(char *pkt_data, int pkt_len, struct net_buf *pkt)
{
int len = 0;
if (pkt) {
pkt->p = pkt_data;
pkt->len = pkt_len;
pkt->tot_len = pkt_len;
}
if (pkt && pkt->tot_len > pkt_len) {
memset(pkt->data + pkt_len, 0, pkt->tot_len - pkt_len);
len = pkt->len;
pkt->tot_len = pkt->len;
}
return len;
}
static void rx_ev_log(struct rte_mbuf *m, int len, int err, uint32_t eid, uint16_t event_size, uint16_t event_type)
{
uint16_t err_status;
uint16_t event_status;
uint16_t event_data[EVENT_DATA_SIZE];
uint8_t event[8];
RTE_LOG(DEBUG, RX_PROG, "Rx Event size %d\n", event_size);
switch (event_type) {
case EVENT_RNDIS_PACKET:
err_status = check_rndis_pkt(m, event_data, event_size);
if (err_status != 0) {
rte_errno = -err_status;
RTE_LOG(ERR, RX_PROG,
"RNDIS_Packet error %d\n",
rte_errno);
} else {
memcpy(event, event_data, event_size);
(void)rte_event_eth_rx_adapter(event_data, event_size, eid, event, event_size, &event_status);
}
break;
case EVENT_ETH_PACKET:
err = rte_event_eth_rx_adapter(event_data, event_size, eid, event, event_size, &event_status);
if (err != 0) {
rte_errno = -err;
RTE_LOG(ERR, RX_PROG,
"Eth_Rx_adapter error %d\n",
rte_errno);
}
break;
case EVENT_IP_RX_DROP:
err = rte_event_ip_rx_adapter(event_data, event_size, eid, event, event_size, &event_status);
if (err != 0) {
rte_errno = -err;
RTE_LOG(ERR, RX_PROG,
"IP Rx Adapter error %d\n",
rte_errno);
}
break;
case EVENT_IPV6_RX_DROP:
err = rte_event_ipv6_rx_adapter(event_data, event_size, eid, event, event_size, &event_status);
if (err != 0) {
rte_errno = -err;
RTE_LOG(ERR, RX_PROG,
"IPv6 Rx Adapter error %d\n",
rte_errno);
}
break;
case EVENT_BTM_RX_DROP:
err = rte_event_btm_rx_adapter(event_data, event_size, eid, event, event_size, &event_status);
if (err != 0) {
rte_errno = -err;
RTE_LOG(ERR, RX_PROG,
"B