38#include <sys/kernel.h>
39#include <sys/endian.h>
40#include <sys/malloc.h>
90 ng_hci_event_pkt_t *hdr = NULL;
98 hdr = mtod(
event, ng_hci_event_pkt_t *);
101"%s: %s - got HCI event=%#x, length=%d\n",
105 m_adj(
event,
sizeof(*hdr));
107 switch (hdr->event) {
225"%s: %s - sending ACL data packets, count=%d\n",
238"%s: %s - sending SCO data packets, count=%d\n",
258 int min_pending, total_sent, sent, error, v;
260 for (total_sent = 0; limit > 0; ) {
261 min_pending = 0x0fffffff;
269 LIST_FOREACH(con, &unit->con_list, next) {
272 if (reallink_type != link_type){
278 if (con->
pending < min_pending) {
293 for (sent = 0; limit > 0; limit --, total_sent ++, sent ++) {
299"%s: %s - sending data packet, handle=%d, len=%d\n",
301 winner->con_handle,
NGI_M(item)->m_pkthdr.len);
308"%s: %s - could not send data. Hook \"%s\" is %svalid, state=%#x\n",
316 v =
NGI_M(item)->m_pkthdr.len;
327"%s: %s - could not send data packet, handle=%d, error=%d\n",
329 winner->con_handle, error);
363 sizeof(*
state), M_NOWAIT);
369 state->completed = completed;
380 ng_hci_le_advertising_report_ep *ep = NULL;
392 ep = mtod(
event, ng_hci_le_advertising_report_ep *);
393 num_reports = ep->num_reports;
394 m_adj(
event,
sizeof(*ep));
397 for (; num_reports > 0; num_reports --) {
400 event_type = *mtod(
event, u_int8_t *);
401 m_adj(
event,
sizeof(u_int8_t));
403 addr_type = *mtod(
event, u_int8_t *);
404 m_adj(
event,
sizeof(u_int8_t));
406 m_copydata(
event, 0,
sizeof(bdaddr), (caddr_t) &bdaddr);
407 m_adj(
event,
sizeof(bdaddr));
430 u_int8_t length_data;
432 event = m_pullup(
event,
sizeof(u_int8_t));
434 NG_HCI_WARN(
"%s: Event datasize Pullup Failed\n", __func__);
437 length_data = *mtod(
event, u_int8_t *);
438 m_adj(
event,
sizeof(u_int8_t));
445 NG_HCI_WARN(
"%s: Event data pullup Failed\n", __func__);
450 event = m_pullup(
event,
sizeof(
char ));
453 NG_HCI_WARN(
"%s: Event rssi pull up Failed\n", __func__);
458 m_adj(
event,
sizeof(u_int8_t));
471 ng_hci_le_connection_complete_ep *ep = NULL;
474 uint8_t uclass[3] = {0,0,0};
480 ep = mtod(
event, ng_hci_le_connection_complete_ep *);
490 LIST_FOREACH(con, &unit->con_list, next)
493 bcmp(&con->
bdaddr, &ep->address,
sizeof(bdaddr_t)) == 0)
586 lep = mtod(
event, ng_hci_le_ep *);
587 m_adj(
event,
sizeof(*lep));
588 switch(lep->subevent_code){
614 ng_hci_inquiry_result_ep *ep = NULL;
623 ep = mtod(
event, ng_hci_inquiry_result_ep *);
624 m_adj(
event,
sizeof(*ep));
626 for (; ep->num_responses > 0; ep->num_responses --) {
628 m_copydata(
event, 0,
sizeof(bdaddr), (caddr_t) &bdaddr);
629 m_adj(
event,
sizeof(bdaddr));
649 m_adj(
event,
sizeof(u_int8_t));
652 m_adj(
event,
sizeof(u_int8_t));
655 m_adj(
event,
sizeof(u_int8_t));
675 ng_hci_con_compl_ep *ep = NULL;
683 ep = mtod(
event, ng_hci_con_compl_ep *);
693 LIST_FOREACH(con, &unit->con_list, next)
696 bcmp(&con->
bdaddr, &ep->bdaddr,
sizeof(bdaddr_t)) == 0)
752 struct __link_policy {
753 ng_hci_cmd_pkt_t hdr;
754 ng_hci_write_link_policy_settings_cp cp;
758 MGETHDR(m, M_NOWAIT, MT_DATA);
760 m->m_pkthdr.len = m->m_len =
sizeof(*lp);
761 lp = mtod(m,
struct __link_policy *);
767 lp->hdr.length =
sizeof(lp->cp);
769 lp->cp.con_handle = ep->con_handle;
774 lp->cp.settings |= 0x1;
776 lp->cp.settings |= 0x2;
778 lp->cp.settings |= 0x4;
780 lp->cp.settings |= 0x8;
783 lp->cp.settings = htole16(lp->cp.settings);
801 ng_hci_con_req_ep *ep = NULL;
809 ep = mtod(
event, ng_hci_con_req_ep *);
853 LIST_FOREACH(con, &unit->con_list, next)
857 bcmp(&con->
bdaddr, &ep->bdaddr,
sizeof(bdaddr_t)) == 0)
886 ng_hci_discon_compl_ep *ep = NULL;
895 ep = mtod(
event, ng_hci_discon_compl_ep *);
904 if (ep->status == 0) {
917"%s: %s - invalid connection handle=%d\n",
932 ng_hci_encryption_change_ep *ep = NULL;
941 ep = mtod(
event, ng_hci_encryption_change_ep *);
945 if (ep->status == 0) {
948"%s: %s - invalid connection handle=%d\n",
953"%s: %s - invalid link type=%d\n",
957 }
else if (ep->encryption_enable)
964"%s: %s - failed to change encryption mode, status=%d\n",
979 ng_hci_read_remote_features_compl_ep *ep = NULL;
989 ep = mtod(
event, ng_hci_read_remote_features_compl_ep *);
991 if (ep->status == 0) {
997"%s: %s - invalid connection handle=%d\n",
1020"%s: %s - failed to read remote unit features, status=%d\n",
1032 ng_hci_qos_setup_compl_ep *ep = NULL;
1041 ep = mtod(
event, ng_hci_qos_setup_compl_ep *);
1048"%s: %s - invalid connection handle=%d\n",
1053"%s: %s - invalid link type=%d, handle=%d\n",
1058"%s: %s - invalid connection state=%d, handle=%d\n",
1075"%s: %s - hardware error %#x\n",
1087 ng_hci_role_change_ep *ep = NULL;
1094 ep = mtod(
event, ng_hci_role_change_ep *);
1096 if (ep->status == 0) {
1100 con->
role = ep->role;
1103"%s: %s - ACL connection does not exist, bdaddr=%x:%x:%x:%x:%x:%x\n",
1105 ep->bdaddr.b[5], ep->bdaddr.b[4],
1106 ep->bdaddr.b[3], ep->bdaddr.b[2],
1107 ep->bdaddr.b[1], ep->bdaddr.b[0]);
1110"%s: %s - failed to change role, status=%d, bdaddr=%x:%x:%x:%x:%x:%x\n",
1112 ep->bdaddr.b[5], ep->bdaddr.b[4], ep->bdaddr.b[3],
1113 ep->bdaddr.b[2], ep->bdaddr.b[1], ep->bdaddr.b[0]);
1124 ng_hci_num_compl_pkts_ep *ep = NULL;
1132 ep = mtod(
event, ng_hci_num_compl_pkts_ep *);
1133 m_adj(
event,
sizeof(*ep));
1135 for (; ep->num_con_handles > 0; ep->num_con_handles --) {
1137 m_copydata(
event, 0,
sizeof(h), (caddr_t) &h);
1138 m_adj(
event,
sizeof(h));
1142 m_copydata(
event, 0,
sizeof(p), (caddr_t) &p);
1143 m_adj(
event,
sizeof(p));
1152"%s: %s - pending packet counter is out of sync! " \
1166"%s: %s - invalid connection handle=%d\n",
1182 ng_hci_mode_change_ep *ep = NULL;
1190 ep = mtod(
event, ng_hci_mode_change_ep *);
1192 if (ep->status == 0) {
1198"%s: %s - invalid connection handle=%d\n",
1203"%s: %s - invalid link type=%d\n",
1208 con->
mode = ep->unit_mode;
1211"%s: %s - failed to change mode, status=%d\n",
1224"%s: %s - %s data buffer overflow\n",
1237 ng_hci_read_clock_offset_compl_ep *ep = NULL;
1246 ep = mtod(
event, ng_hci_read_clock_offset_compl_ep *);
1248 if (ep->status == 0) {
1254"%s: %s - invalid connection handle=%d\n",
1277"%s: %s - failed to Read Remote Clock Offset, status=%d\n",
1289 ng_hci_qos_violation_ep *ep = NULL;
1298 ep = mtod(
event, ng_hci_qos_violation_ep *);
1305"%s: %s - invalid connection handle=%d\n",
1310"%s: %s - invalid link type=%d\n",
1315"%s: %s - invalid connection state=%d, handle=%d\n",
1330 ng_hci_page_scan_mode_change_ep *ep = NULL;
1338 ep = mtod(
event, ng_hci_page_scan_mode_change_ep *);
1365 ng_hci_page_scan_rep_mode_change_ep *ep = NULL;
1373 ep = mtod(
event, ng_hci_page_scan_rep_mode_change_ep *);
#define NG_HOOK_NOT_VALID(hook)
#define NG_FWD_ITEM_HOOK(error, item, hook)
#define NG_NODE_NAME(node)
#define NG_FREE_ITEM(item)
#define NG_HOOK_IS_VALID(hook)
#define NG_SEND_MSG_HOOK(error, here, msg, hook, retaddr)
#define NG_BT_MBUFQ_ENQUEUE(q, i)
#define NG_BT_ITEMQ_DEQUEUE(q, i)
#define NG_BT_ITEMQ_LEN(q)
#define NG_HCI_CLASS_SIZE
#define NG_HCI_LMP_SNIFF_MODE
#define NG_HCI_EVENT_CHANGE_CON_LINK_KEY_COMPL
#define NG_HCI_OCF_WRITE_LINK_POLICY_SETTINGS
#define NG_HCI_EVENT_COMMAND_STATUS
#define NG_HCI_LMP_PARK_MODE
#define NG_HCI_EVENT_HARDWARE_ERROR
#define NG_HCI_EVENT_BT_LOGO
#define NG_HCI_LEEV_READ_REMOTE_FEATURES_COMPL
#define NG_HCI_EVENT_QOS_SETUP_COMPL
#define NG_HCI_EVENT_QOS_VIOLATION
#define NG_HCI_EVENT_MASTER_LINK_KEY_COMPL
#define NG_HCI_EVENT_COMMAND_COMPL
#define NG_HCI_EVENT_LOOPBACK_COMMAND
#define NG_HCI_EXTINQ_MAX
#define NGM_HCI_SYNC_CON_QUEUE
#define NG_HCI_CON_W4_LP_CON_RSP
#define NG_HCI_LINK_LE_RANDOM
#define NG_HCI_EVENT_CON_COMPL
#define NG_HCI_OGF_LINK_POLICY
#define NG_HCI_EVENT_NUM_COMPL_PKTS
#define NG_HCI_LMP_SWITCH
#define NG_HCI_EVENT_AUTH_COMPL
#define NG_HCI_EVENT_READ_REMOTE_VER_INFO_COMPL
#define NG_HCI_EVENT_VENDOR
#define NG_HCI_EVENT_PIN_CODE_REQ
#define NG_HCI_LEEV_LONG_TERM_KEY_REQUEST
#define NG_HCI_EVENT_LINK_KEY_REQ
#define NG_HCI_ENCRYPTION_MODE_P2P
#define NG_HCI_UNIT_READY
#define NG_HCI_EVENT_INQUIRY_COMPL
#define NG_HCI_EVENT_DATA_BUFFER_OVERFLOW
#define NG_HCI_LMP_HOLD_MODE
#define NG_HCI_EVENT_READ_REMOTE_FEATURES_COMPL
#define NG_HCI_EVENT_CON_PKT_TYPE_CHANGED
#define NG_HCI_EVENT_READ_CLOCK_OFFSET_COMPL
#define NG_HCI_EVENT_PAGE_SCAN_MODE_CHANGE
#define NG_HCI_EVENT_CON_REQ
#define NG_HCI_EVENT_FLUSH_OCCUR
#define NG_HCI_EVENT_DISCON_COMPL
#define NG_HCI_UNIT_COMMAND_PENDING
#define NG_HCI_EVENT_RETURN_LINK_KEYS
#define NG_HCI_EVENT_LINK_KEY_NOTIFICATION
#define NG_HCI_EVENT_MAX_SLOT_CHANGE
#define NG_HCI_LEEV_CON_COMPL
#define NG_HCI_EVENT_ROLE_CHANGE
#define NG_HCI_EVENT_MODE_CHANGE
#define NG_HCI_ENCRYPTION_MODE_NONE
#define NG_HCI_LEEV_ADVREP
#define NG_HCI_EVENT_ENCRYPTION_CHANGE
#define NG_HCI_LEEV_CON_UPDATE_COMPL
#define NG_HCI_CON_HANDLE(h)
#define NG_HCI_EVENT_INQUIRY_RESULT
#define NG_HCI_CON_W4_CONN_COMPLETE
#define NG_HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE
#define NG_HCI_EVENT_REMOTE_NAME_REQ_COMPL
#define NG_HCI_LINK_LE_PUBLIC
#define NG_HCI_OPCODE(gf, cf)
int ng_hci_process_command_status(ng_hci_unit_p unit, struct mbuf *e)
int ng_hci_process_command_complete(ng_hci_unit_p unit, struct mbuf *e)
int ng_hci_send_command(ng_hci_unit_p unit)
static int page_scan_rep_mode_change(ng_hci_unit_p, struct mbuf *)
static int mode_change(ng_hci_unit_p, struct mbuf *)
static int discon_compl(ng_hci_unit_p, struct mbuf *)
static int send_data_packets(ng_hci_unit_p, int, int)
static int qos_violation(ng_hci_unit_p, struct mbuf *)
void ng_hci_send_data(ng_hci_unit_p unit)
static int role_change(ng_hci_unit_p, struct mbuf *)
static int read_clock_offset_compl(ng_hci_unit_p, struct mbuf *)
int ng_hci_process_event(ng_hci_unit_p unit, struct mbuf *event)
static int data_buffer_overflow(ng_hci_unit_p, struct mbuf *)
static int con_req(ng_hci_unit_p, struct mbuf *)
static int hardware_error(ng_hci_unit_p, struct mbuf *)
static int num_compl_pkts(ng_hci_unit_p, struct mbuf *)
static int sync_con_queue(ng_hci_unit_p, ng_hci_unit_con_p, int)
static int qos_setup_compl(ng_hci_unit_p, struct mbuf *)
static int con_compl(ng_hci_unit_p, struct mbuf *)
static int encryption_change(ng_hci_unit_p, struct mbuf *)
static int le_advertizing_report(ng_hci_unit_p unit, struct mbuf *event)
static int le_connection_update(ng_hci_unit_p unit, struct mbuf *event)
static int le_connection_complete(ng_hci_unit_p unit, struct mbuf *event)
static int inquiry_result(ng_hci_unit_p, struct mbuf *)
static int read_remote_features_compl(ng_hci_unit_p, struct mbuf *)
static int page_scan_mode_change(ng_hci_unit_p, struct mbuf *)
static int le_event(ng_hci_unit_p, struct mbuf *)
ng_hci_neighbor_p ng_hci_new_neighbor(ng_hci_unit_p unit)
int ng_hci_con_timeout(ng_hci_unit_con_p con)
ng_hci_unit_con_p ng_hci_con_by_handle(ng_hci_unit_p unit, int con_handle)
ng_hci_unit_con_p ng_hci_new_con(ng_hci_unit_p unit, int link_type)
void ng_hci_mtap(ng_hci_unit_p unit, struct mbuf *m0)
ng_hci_unit_con_p ng_hci_con_by_bdaddr(ng_hci_unit_p unit, bdaddr_p bdaddr, int link_type)
int ng_hci_con_untimeout(ng_hci_unit_con_p con)
void ng_hci_free_con(ng_hci_unit_con_p con)
ng_hci_neighbor_p ng_hci_get_neighbor(ng_hci_unit_p unit, bdaddr_p bdaddr, int link_type)
int ng_hci_lp_con_ind(ng_hci_unit_con_p con, u_int8_t *uclass)
int ng_hci_lp_discon_ind(ng_hci_unit_con_p con, int reason)
int ng_hci_lp_con_cfm(ng_hci_unit_con_p con, int status)
int ng_hci_lp_enc_change(ng_hci_unit_con_p con, int status)
int ng_hci_lp_qos_ind(ng_hci_unit_con_p con)
int ng_hci_lp_qos_cfm(ng_hci_unit_con_p con, int status)
#define NG_HCI_BUFF_SCO_USE(b, v)
#define NG_HCI_STAT_ACL_SENT(s, n)
#define NG_HCI_BUFF_ACL_USE(b, v)
#define NG_HCI_M_PULLUP(m, s)
#define NG_HCI_STAT_SCO_SENT(s, n)
#define NG_HCI_BUFF_SCO_AVAIL(b, v)
#define NG_HCI_BUFF_ACL_AVAIL(b, v)
#define NG_HCI_STAT_BYTES_SENT(s, b)
#define NG_HCI_CON_TIMEOUT_PENDING
#define NG_HCI_BUFF_SCO_FREE(b, v)
#define NG_HCI_BUFF_ACL_FREE(b, v)
#define NG_MKMESSAGE(msg, cookie, cmdid, len, how)
struct ubt_softc __attribute__
uint8_t extinq_data[NG_HCI_EXTINQ_MAX]
u_int8_t features[NG_HCI_FEATURES_SIZE]
u_int8_t page_scan_rep_mode
ng_hci_node_role_switch_ep role_switch
ng_hci_node_state_ep state
u_int8_t features[NG_HCI_FEATURES_SIZE]
ng_hci_node_link_policy_mask_ep link_policy_mask
ng_hci_unit_buff_t buffer