38#include <sys/kernel.h>
39#include <sys/malloc.h>
66 struct mbuf *m = NULL;
70 m = m_dup(m0, M_NOWAIT);
76"%s: %s - Could not forward packet, error=%d\n",
101 if (hook != unit->
acl && hook != unit->
sco)
108 if (hook == unit->
acl) {
124"%s: %s - failed to send NODE_UP message to hook \"%s\", error=%d\n",
146 while (!LIST_EMPTY(&unit->con_list)) {
185 LIST_INSERT_HEAD(&unit->neighbors, n, next);
198 LIST_REMOVE(n, next);
199 bzero(n,
sizeof(*n));
210 while (!LIST_EMPTY(&unit->neighbors))
223 for (n = LIST_FIRST(&unit->neighbors); n != NULL; ) {
228 bcmp(&n->
bdaddr, bdaddr,
sizeof(*bdaddr)) == 0)
262 static int fake_con_handle = 0x0f00;
285 if (fake_con_handle > 0x0fff)
286 fake_con_handle = 0x0f00;
299 LIST_INSERT_HEAD(&unit->con_list, con, next);
312 LIST_REMOVE(con, next);
326 bzero(con,
sizeof(*con));
339 LIST_FOREACH(con, &unit->con_list, next)
355 LIST_FOREACH(con, &unit->con_list, next)
357 bcmp(&con->
bdaddr, bdaddr,
sizeof(bdaddr_t)) == 0)
373"%s: %s - Duplicated command timeout!\n", __func__,
NG_NODE_NAME(unit->
node));
397 unit->
state &= ~NG_HCI_UNIT_COMMAND_PENDING;
412"%s: %s - Duplicated connection timeout!\n",
438 con->
flags &= ~NG_HCI_CON_TIMEOUT_PENDING;
449ng_hci_str_error(u_int16_t code)
451#define LAST_ERROR_CODE ((sizeof(s)/sizeof(s[0]))-1)
452 static char const *
const s[] = {
454 "Unknown HCI command",
458 "Authentication failure",
461 "Connection timeout",
462 "Max number of connections",
463 "Max number of SCO connections to a unit",
464 "ACL connection already exists",
465 "Command disallowed",
466 "Host rejected due to limited resources",
467 "Host rejected due to securiity reasons",
468 "Host rejected due to remote unit is a personal unit",
470 "Unsupported feature or parameter value",
471 "Invalid HCI command parameter",
472 "Other end terminated connection: User ended connection",
473 "Other end terminated connection: Low resources",
474 "Other end terminated connection: About to power off",
475 "Connection terminated by local host",
477 "Pairing not allowed",
479 "Unsupported remote feature",
480 "SCO offset rejected",
481 "SCO interval rejected",
482 "SCO air mode rejected",
483 "Invalid LMP parameters",
485 "Unsupported LMP parameter value",
486 "Role change not allowed",
487 "LMP response timeout",
488 "LMP error transaction collision",
489 "LMP PSU not allowed",
490 "Encryption mode not acceptable",
492 "QoS is not supported",
494 "Pairing with unit key not supported",
495 "Different Transaction Collision",
496 "Unknown error (Reserved for future use)",
497 "QoS Unacceptable Parameter",
499 "Channel Classification Not Supported",
500 "Insufficient Security",
501 "Parameter Out Of Mandatory Range",
502 "Unknown error (Reserved for future use)",
503 "Role Switch Pending",
504 "Unknown error (Reserved for future use)",
505 "Reserved Slot Violation",
506 "Role Switch Failed",
507 "Extended Inquiry Response Too Large",
508 "Secure Simple Pairing Not Supported By Host",
509 "Host Busy - Pairing",
510 "Connection Rejected due to No Suitable Channel Found",
512 "Unacceptable Connection Parameters",
513 "Advertising Timeout",
514 "Connection Terminated due to MIC Failure",
515 "Connection Failed to be Established / Synchronization Timeout",
516 "MAC Connection Failed",
517 "Coarse Clock Adjustment Rejected but Will Try to Adjust Using Clock Dragging",
518 "Type0 Submap Not Defined",
519 "Unknown Advertising Identifier",
521 "Operation Cancelled by Host",
526 return ((code >= LAST_ERROR_CODE)? s[LAST_ERROR_CODE] : s[code]);
#define NG_HOOK_NOT_VALID(hook)
#define NG_NODE_NOT_VALID(node)
#define NG_NODE_NAME(node)
#define ng_callout_init(c)
#define NG_SEND_DATA_ONLY(error, hook, m)
int ng_uncallout(struct callout *c, node_p node)
#define NG_HOOK_NAME(hook)
#define NG_HOOK_IS_VALID(hook)
#define NG_NODE_PRIVATE(node)
#define NG_SEND_MSG_HOOK(error, here, msg, hook, retaddr)
int ng_callout(struct callout *c, node_p node, hook_p hook, int ticks, ng_item_fn *fn, void *arg1, int arg2)
u_int32_t bluetooth_hci_connect_timeout(void)
u_int32_t bluetooth_hci_max_neighbor_age(void)
u_int32_t bluetooth_hci_command_timeout(void)
#define NG_BT_MBUFQ_DRAIN(q)
#define NG_BT_ITEMQ_DESTROY(q)
#define NG_BT_ITEMQ_INIT(q, _maxlen)
#define NG_HCI_CON_CLOSED
#define NG_HCI_UNIT_READY
#define NG_HCI_UNIT_COMMAND_PENDING
void ng_hci_process_command_timeout(node_p node, hook_p hook, void *arg1, int arg2)
ng_hci_neighbor_p ng_hci_new_neighbor(ng_hci_unit_p unit)
int ng_hci_con_timeout(ng_hci_unit_con_p con)
int ng_hci_command_timeout(ng_hci_unit_p unit)
ng_hci_unit_con_p ng_hci_con_by_handle(ng_hci_unit_p unit, int con_handle)
void ng_hci_free_neighbor(ng_hci_neighbor_p n)
void ng_hci_unit_clean(ng_hci_unit_p unit, int reason)
void ng_hci_node_is_up(node_p node, hook_p hook, void *arg1, int arg2)
int ng_hci_neighbor_stale(ng_hci_neighbor_p n)
void ng_hci_flush_neighbor_cache(ng_hci_unit_p unit)
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)
int ng_hci_command_untimeout(ng_hci_unit_p unit)
ng_hci_neighbor_p ng_hci_get_neighbor(ng_hci_unit_p unit, bdaddr_p bdaddr, int link_type)
int ng_hci_lp_discon_ind(ng_hci_unit_con_p con, int reason)
void ng_hci_process_con_timeout(node_p node, hook_p hook, void *arg1, int con_handle)
#define NG_HCI_BUFF_ACL_TOTAL(b, v)
#define NG_HCI_BUFF_SCO_TOTAL(b, v)
#define NG_HCI_BUFF_CMD_SET(b, v)
#define NG_HCI_BUFF_ACL_SIZE(b, v)
#define NG_HCI_CON_TIMEOUT_PENDING
#define NG_HCI_BUFF_SCO_FREE(b, v)
ng_hci_unit_t * ng_hci_unit_p
#define NG_HCI_BUFF_ACL_FREE(b, v)
#define NG_HCI_BUFF_SCO_SIZE(b, v)
#define NG_MKMESSAGE(msg, cookie, cmdid, len, how)
ng_hci_node_state_ep state
ng_hci_unit_buff_t buffer