38#include <sys/kernel.h>
39#include <sys/endian.h>
40#include <sys/malloc.h>
74"%s: %s - unit is not ready, state=%#x\n",
84"%s: %s - invalid LP_ConnectReq message size=%d\n",
97 if (hook != unit->
sco ) {
99 "%s: %s - LP_ConnectReq for SCO connection came from wrong hook=%p\n",
112 panic(
"%s: link_type invalid.", __func__);
126 ng_hci_cmd_pkt_t hdr;
127 ng_hci_create_con_cp cp;
132 struct mbuf *m = NULL;
166 switch (con->
state) {
172 if (hook == unit->
acl)
208"%s: %s - Source hook is not valid, hook=%p\n",
215"%s: %s - Invalid connection state=%d\n",
241 MGETHDR(m, M_NOWAIT, MT_DATA);
248 m->m_pkthdr.len = m->m_len =
sizeof(*req);
249 req = mtod(m,
struct acl_con_req *);
251 req->hdr.length =
sizeof(req->cp);
255 bcopy(&ep->
bdaddr, &req->cp.bdaddr,
sizeof(req->cp.bdaddr));
269 req->cp.pkt_type = htole16(req->cp.pkt_type);
272 req->cp.accept_role_switch = 1;
274 req->cp.accept_role_switch = 0;
283 req->cp.page_scan_rep_mode = 0;
284 req->cp.page_scan_mode = 0;
285 req->cp.clock_offset = 0;
296 if (hook == unit->
acl)
326 ng_hci_cmd_pkt_t hdr;
327 ng_hci_add_sco_con_cp cp;
331 struct mbuf *m = NULL;
343 LIST_FOREACH(acl_con, &unit->con_list, next)
346 bcmp(&acl_con->
bdaddr, &ep->
bdaddr,
sizeof(bdaddr_t)) == 0)
349 if (acl_con == NULL) {
351"%s: %s - No open ACL connection to bdaddr=%x:%x:%x:%x:%x:%x\n",
389 LIST_FOREACH(sco_con, &unit->con_list, next)
393 bcmp(&sco_con->bdaddr, &ep->
bdaddr,
sizeof(bdaddr_t)) == 0)
396 if (sco_con != NULL) {
397 switch (sco_con->state) {
408"%s: %s - Invalid connection state=%d\n",
423 if (sco_con == NULL) {
428 bcopy(&ep->
bdaddr, &sco_con->bdaddr,
sizeof(sco_con->bdaddr));
434 MGETHDR(m, M_NOWAIT, MT_DATA);
441 m->m_pkthdr.len = m->m_len =
sizeof(*req);
442 req = mtod(m,
struct sco_con_req *);
444 req->hdr.length =
sizeof(req->cp);
448 req->cp.con_handle = htole16(acl_con->
con_handle);
462 req->cp.pkt_type = htole16(req->cp.pkt_type);
490 ng_hci_cmd_pkt_t hdr;
491 ng_hci_le_create_connection_cp cp;
495 struct mbuf *m = NULL;
501 printf(
"%s: Link type %d Cannot be here \n", __func__,
533 switch (con->
state) {
539 if (hook != unit->
sco)
575"%s: %s - Source hook is not valid, hook=%p\n",
582"%s: %s - Invalid connection state=%d\n",
608 MGETHDR(m, M_NOWAIT, MT_DATA);
615 m->m_pkthdr.len = m->m_len =
sizeof(*req);
616 req = mtod(m,
struct acl_con_req *);
618 req->hdr.length =
sizeof(req->cp);
622 bcopy(&ep->
bdaddr, &req->cp.peer_addr,
sizeof(req->cp.peer_addr));
623 req->cp.own_address_type = 0;
625 req->cp.scan_interval = htole16(4);
626 req->cp.scan_window = htole16(4);
627 req->cp.filter_policy = 0;
628 req->cp.conn_interval_min = htole16(0xf);
629 req->cp.conn_interval_max = htole16(0xf);
630 req->cp.conn_latency = htole16(0);
631 req->cp.supervision_timeout = htole16(0xc80);
632 req->cp.min_ce_length = htole16(1);
633 req->cp.max_ce_length = htole16(1);
638 if (hook != unit->
sco)
668 ng_hci_cmd_pkt_t hdr;
673 struct mbuf *m = NULL;
679"%s: %s - unit is not ready, state=%#x\n",
688"%s: %s - invalid LP_DisconnectReq message size=%d\n",
701"%s: %s - invalid connection handle=%d\n",
710"%s: %s - invalid connection state=%d, handle=%d\n",
722 MGETHDR(m, M_NOWAIT, MT_DATA);
728 m->m_pkthdr.len = m->m_len =
sizeof(*req);
729 req = mtod(m,
struct discon_req *);
731 req->hdr.length =
sizeof(req->cp);
736 req->cp.reason = ep->
reason;
773 sizeof(*ep), M_NOWAIT);
787"%s: %s - ACL hook not valid, hook=%p\n",
790 con->
flags &= ~NG_HCI_CON_NOTIFY_ACL;
796 sizeof(*ep), M_NOWAIT);
810"%s: %s - SCO hook not valid, hook=%p\n",
813 con->
flags &= ~NG_HCI_CON_NOTIFY_SCO;
830 sizeof(*ep), M_NOWAIT);
842"%s: %s - ACL hook not valid, hook=%p\n",
873 sizeof(*ep), M_NOWAIT);
885"%s: %s - Upstream hook is not connected or not valid, hook=%p\n",
902 ng_hci_cmd_pkt_t hdr;
904 ng_hci_accept_con_cp acc;
905 ng_hci_reject_con_cp rej;
910 struct mbuf *m = NULL;
916"%s: %s - unit is not ready, state=%#x\n",
925"%s: %s - invalid LP_ConnectRsp message size=%d\n",
967 LIST_FOREACH(con, &unit->con_list, next)
976 error = (ep->
status == 0)? ENOENT : 0;
989 switch (con->
state) {
996 MGETHDR(m, M_NOWAIT, MT_DATA);
1002 req = mtod(m,
struct con_rsp_req *);
1006 req->hdr.length =
sizeof(req->cp.acc);
1011 bcopy(&ep->
bdaddr, &req->cp.acc.bdaddr,
1012 sizeof(req->cp.acc.bdaddr));
1032 if (hook == unit->
acl)
1040 req->hdr.length =
sizeof(req->cp.rej);
1045 bcopy(&ep->
bdaddr, &req->cp.rej.bdaddr,
1046 sizeof(req->cp.rej.bdaddr));
1048 req->cp.rej.reason = ep->
status;
1058 m->m_pkthdr.len = m->m_len =
sizeof(req->hdr) + req->hdr.length;
1068 if (hook == unit->
acl)
1078"%s: %s - Invalid connection state=%d\n",
1122"%s: %s - ACL hook is not connected or not valid, hook=%p\n",
1128 sizeof(*ep), M_NOWAIT);
1140"%s: %s - SCO hook is not connected or not valid, hook=%p\n",
1153 struct qos_setup_req {
1154 ng_hci_cmd_pkt_t hdr;
1155 ng_hci_qos_setup_cp cp;
1159 struct mbuf *m = NULL;
1165"%s: %s - unit is not ready, state=%#x\n",
1174"%s: %s - invalid LP_QoSSetupReq message size=%d\n",
1187"%s: %s - invalid connection handle=%d\n",
1195 NG_HCI_ERR(
"%s: %s - invalid link type=%d\n",
1204"%s: %s - invalid connection state=%d, handle=%d\n",
1216 MGETHDR(m, M_NOWAIT, MT_DATA);
1222 m->m_pkthdr.len = m->m_len =
sizeof(*req);
1223 req = mtod(m,
struct qos_setup_req *);
1225 req->hdr.length =
sizeof(req->cp);
1229 req->cp.con_handle = htole16(ep->
con_handle);
1230 req->cp.flags = ep->
flags;
1232 req->cp.token_rate = htole32(ep->
token_rate);
1234 req->cp.latency = htole32(ep->
latency);
1241 if (hook == unit->
acl)
1274 sizeof(*ep), M_NOWAIT);
1285"%s: %s - ACL hook not valid, hook=%p\n",
1288 con->
flags &= ~NG_HCI_CON_NOTIFY_ACL;
1294 sizeof(*ep), M_NOWAIT);
1305"%s: %s - SCO hook not valid, hook=%p\n",
1308 con->
flags &= ~NG_HCI_CON_NOTIFY_SCO;
1333 sizeof(*ep), M_NOWAIT);
1343"%s: %s - ACL hook is not connected or not valid, hook=%p\n",
1348 sizeof(*ep), M_NOWAIT);
1358"%s: %s - SCO hook is not connected or not valid, hook=%p\n",
1375 printf(
"%s: Netgraph node is not valid\n", __func__);
1384"%s: %s - could not find connection, handle=%d\n",
1391"%s: %s - no pending connection timeout, handle=%d, state=%d, flags=%#x\n",
1397 con->
flags &= ~NG_HCI_CON_TIMEOUT_PENDING;
1412 switch (con->
state) {
1422"%s: %s - Invalid connection state=%d\n",
#define NG_NODE_NOT_VALID(node)
#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 NGI_GET_MSG(i, m)
#define NG_NODE_PRIVATE(node)
#define NG_SEND_MSG_HOOK(error, here, msg, hook, retaddr)
#define NG_BT_MBUFQ_ENQUEUE(q, i)
#define NG_HCI_OCF_DISCON
#define NG_HCI_OCF_ACCEPT_CON
#define NGM_HCI_LP_QOS_IND
#define NGM_HCI_LP_CON_IND
#define NG_HCI_OCF_REJECT_CON
#define NG_HCI_CON_W4_LP_CON_RSP
#define NG_HCI_LINK_LE_RANDOM
#define NG_HCI_OGF_LINK_POLICY
#define NG_HCI_LMP_SWITCH
#define NG_HCI_OCF_ADD_SCO_CON
#define NG_HCI_OCF_CREATE_CON
#define NG_HCI_OCF_LE_CREATE_CONNECTION
#define NGM_HCI_LP_CON_CFM
#define NG_HCI_UNIT_READY
#define NGM_HCI_LP_ENC_CHG
#define NG_HCI_OGF_LINK_CONTROL
#define NG_HCI_LMP_HV3_PKT
#define NGM_HCI_LP_DISCON_IND
#define NG_HCI_UNIT_COMMAND_PENDING
#define NGM_HCI_LP_QOS_CFM
#define NG_HCI_ROLE_MASTER
#define NG_HCI_LMP_HV2_PKT
#define NG_HCI_ROLE_SLAVE
#define NG_HCI_OCF_QOS_SETUP
#define NG_HCI_CON_W4_CONN_COMPLETE
#define NG_HCI_LINK_LE_PUBLIC
#define NG_HCI_OPCODE(gf, cf)
int ng_hci_send_command(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)
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_qos_req(ng_hci_unit_p unit, item_p item, hook_p hook)
static int ng_hci_lp_sco_con_req(ng_hci_unit_p, item_p, hook_p)
static int ng_hci_lp_acl_con_req(ng_hci_unit_p, item_p, hook_p)
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)
void ng_hci_process_con_timeout(node_p node, hook_p hook, void *arg1, int con_handle)
int ng_hci_lp_con_rsp(ng_hci_unit_p unit, item_p item, hook_p hook)
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_discon_req(ng_hci_unit_p unit, item_p item, hook_p hook)
static int ng_hci_lp_le_con_req(ng_hci_unit_p, item_p, hook_p, int)
int ng_hci_lp_qos_cfm(ng_hci_unit_con_p con, int status)
int ng_hci_lp_con_req(ng_hci_unit_p unit, item_p item, hook_p hook)
#define NG_HCI_CON_NOTIFY_ACL
#define NG_HCI_CON_NOTIFY_SCO
#define NG_HCI_CON_TIMEOUT_PENDING
ng_hci_unit_t * ng_hci_unit_p
#define NG_MKMESSAGE(msg, cookie, cmdid, len, how)
struct ubt_hci_evhdr header
struct ubt_softc __attribute__
u_int8_t uclass[NG_HCI_CLASS_SIZE]
u_int32_t delay_variation
u_int8_t page_scan_rep_mode
ng_hci_node_role_switch_ep role_switch
ng_hci_node_state_ep state
ng_hci_node_packet_mask_ep packet_mask
u_int8_t features[NG_HCI_FEATURES_SIZE]