summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/bluetooth/hci
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netgraph/bluetooth/hci')
-rw-r--r--sys/netgraph/bluetooth/hci/TODO23
-rw-r--r--sys/netgraph/bluetooth/hci/ng_hci_cmds.c2
-rw-r--r--sys/netgraph/bluetooth/hci/ng_hci_cmds.h2
-rw-r--r--sys/netgraph/bluetooth/hci/ng_hci_evnt.c57
-rw-r--r--sys/netgraph/bluetooth/hci/ng_hci_evnt.h2
-rw-r--r--sys/netgraph/bluetooth/hci/ng_hci_main.c29
-rw-r--r--sys/netgraph/bluetooth/hci/ng_hci_misc.c60
-rw-r--r--sys/netgraph/bluetooth/hci/ng_hci_misc.h4
-rw-r--r--sys/netgraph/bluetooth/hci/ng_hci_prse.h16
-rw-r--r--sys/netgraph/bluetooth/hci/ng_hci_ulpi.c126
-rw-r--r--sys/netgraph/bluetooth/hci/ng_hci_ulpi.h3
-rw-r--r--sys/netgraph/bluetooth/hci/ng_hci_var.h9
12 files changed, 128 insertions, 205 deletions
diff --git a/sys/netgraph/bluetooth/hci/TODO b/sys/netgraph/bluetooth/hci/TODO
index f277e7e..6f66d7b 100644
--- a/sys/netgraph/bluetooth/hci/TODO
+++ b/sys/netgraph/bluetooth/hci/TODO
@@ -1,6 +1,5 @@
-# $FreeBSD$
-
-$Id: TODO,v 1.10 2002/09/06 21:03:57 max Exp $
+$Id: TODO,v 1.2 2003/04/26 22:36:29 max Exp $
+$FreeBSD$
FIXME/TODO list
@@ -12,30 +11,18 @@ This is a list of open issues for HCI node
it should be fine as long as Netgraph is SMP safe. Just need to
verify it.
-3) HCI QoS handling
+2) HCI QoS handling
Some code exists, but i have no idea how it should work. Will
understand and fix later. I only have CSR based hardware and
it does not support QoS.
-4) Add proper handling for some HCI commands
+3) Add proper handling for some HCI commands
HCI testing commands is one example. Also might implement Host to
Host Controller flow control (not sure if it is required).
-5) Link security
-
- Manage link keys and PINs. Options:
-
- 1) manage keys inside HCI node/unit itself
- 2) use user space daemon.
- 3) Mix option 1 and option 2.
-
-6) Implement watchdog routine for HCI connections
-
- Some code exists, but it is not used
-
-7) Code cleanup
+4) Code cleanup
Verify return codes from functions
Remove some waringns/errors
diff --git a/sys/netgraph/bluetooth/hci/ng_hci_cmds.c b/sys/netgraph/bluetooth/hci/ng_hci_cmds.c
index 5769ee5..83b640b 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_cmds.c
+++ b/sys/netgraph/bluetooth/hci/ng_hci_cmds.c
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ng_hci_cmds.c,v 1.22 2002/10/30 00:18:18 max Exp $
+ * $Id: ng_hci_cmds.c,v 1.3 2003/04/01 18:15:25 max Exp $
* $FreeBSD$
*/
diff --git a/sys/netgraph/bluetooth/hci/ng_hci_cmds.h b/sys/netgraph/bluetooth/hci/ng_hci_cmds.h
index 1123802..6cf75d6 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_cmds.h
+++ b/sys/netgraph/bluetooth/hci/ng_hci_cmds.h
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ng_hci_cmds.h,v 1.6 2002/09/04 21:36:51 max Exp $
+ * $Id: ng_hci_cmds.h,v 1.1 2002/11/24 19:46:58 max Exp $
* $FreeBSD$
*/
diff --git a/sys/netgraph/bluetooth/hci/ng_hci_evnt.c b/sys/netgraph/bluetooth/hci/ng_hci_evnt.c
index 9d81380..1f1c74a 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_evnt.c
+++ b/sys/netgraph/bluetooth/hci/ng_hci_evnt.c
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ng_hci_evnt.c,v 1.18 2002/11/12 22:35:39 max Exp $
+ * $Id: ng_hci_evnt.c,v 1.5 2003/04/01 18:15:25 max Exp $
* $FreeBSD$
*/
@@ -60,6 +60,7 @@ static int inquiry_result (ng_hci_unit_p, struct mbuf *);
static int con_compl (ng_hci_unit_p, struct mbuf *);
static int con_req (ng_hci_unit_p, struct mbuf *);
static int discon_compl (ng_hci_unit_p, struct mbuf *);
+static int encryption_change (ng_hci_unit_p, struct mbuf *);
static int read_remote_features_compl (ng_hci_unit_p, struct mbuf *);
static int qos_setup_compl (ng_hci_unit_p, struct mbuf *);
static int hardware_error (ng_hci_unit_p, struct mbuf *);
@@ -100,18 +101,15 @@ ng_hci_process_event(ng_hci_unit_p unit, struct mbuf *event)
switch (hdr->event) {
case NG_HCI_EVENT_INQUIRY_COMPL:
-/* case NG_HCI_EVENT_MODE_CHANGE: */
case NG_HCI_EVENT_RETURN_LINK_KEYS:
case NG_HCI_EVENT_PIN_CODE_REQ:
case NG_HCI_EVENT_LINK_KEY_REQ:
case NG_HCI_EVENT_LINK_KEY_NOTIFICATION:
case NG_HCI_EVENT_LOOPBACK_COMMAND:
case NG_HCI_EVENT_AUTH_COMPL:
- case NG_HCI_EVENT_ENCRYPTION_CHANGE:
case NG_HCI_EVENT_CHANGE_CON_LINK_KEY_COMPL:
case NG_HCI_EVENT_MASTER_LINK_KEY_COMPL:
case NG_HCI_EVENT_FLUSH_OCCUR: /* XXX Do we have to handle it? */
-/* case NG_HCI_EVENT_ROLE_CHANGE: */
case NG_HCI_EVENT_MAX_SLOT_CHANGE:
case NG_HCI_EVENT_CON_PKT_TYPE_CHANGED:
case NG_HCI_EVENT_BT_LOGO:
@@ -138,6 +136,10 @@ ng_hci_process_event(ng_hci_unit_p unit, struct mbuf *event)
error = discon_compl(unit, event);
break;
+ case NG_HCI_EVENT_ENCRYPTION_CHANGE:
+ error = encryption_change(unit, event);
+ break;
+
case NG_HCI_EVENT_READ_REMOTE_FEATURES_COMPL:
error = read_remote_features_compl(unit, event);
break;
@@ -518,7 +520,8 @@ con_compl(ng_hci_unit_p unit, struct mbuf *event)
lp->cp.con_handle = ep->con_handle;
lp->cp.settings = 0;
- if (unit->features[0] & NG_HCI_LMP_SWITCH)
+ if ((unit->features[0] & NG_HCI_LMP_SWITCH) &&
+ unit->role_switch)
lp->cp.settings |= 0x1;
if (unit->features[0] & NG_HCI_LMP_HOLD_MODE)
lp->cp.settings |= 0x2;
@@ -666,6 +669,50 @@ discon_compl(ng_hci_unit_p unit, struct mbuf *event)
return (error);
} /* discon_compl */
+/* Encryption change event */
+static int
+encryption_change(ng_hci_unit_p unit, struct mbuf *event)
+{
+ ng_hci_encryption_change_ep *ep = NULL;
+ ng_hci_unit_con_p con = NULL;
+ int error = 0;
+
+ NG_HCI_M_PULLUP(event, sizeof(*ep));
+ if (event == NULL)
+ return (ENOBUFS);
+
+ ep = mtod(event, ng_hci_encryption_change_ep *);
+
+ if (ep->status == 0) {
+ u_int16_t h = NG_HCI_CON_HANDLE(le16toh(ep->con_handle));
+
+ con = ng_hci_con_by_handle(unit, h);
+ if (con == NULL) {
+ NG_HCI_ALERT(
+"%s: %s - invalid connection handle=%d\n",
+ __func__, NG_NODE_NAME(unit->node), h);
+ error = ENOENT;
+ } else if (con->link_type != NG_HCI_LINK_ACL) {
+ NG_HCI_ALERT(
+"%s: %s - invalid link type=%d\n",
+ __func__, NG_NODE_NAME(unit->node),
+ con->link_type);
+ error = EINVAL;
+ } else if (ep->encryption_enable)
+ /* XXX is that true? */
+ con->encryption_mode = NG_HCI_ENCRYPTION_MODE_P2P;
+ else
+ con->encryption_mode = NG_HCI_ENCRYPTION_MODE_NONE;
+ } else
+ NG_HCI_ERR(
+"%s: %s - failed to change encryption mode, status=%d\n",
+ __func__, NG_NODE_NAME(unit->node), ep->status);
+
+ NG_FREE_M(event);
+
+ return (error);
+} /* encryption_change */
+
/* Read remote feature complete event */
static int
read_remote_features_compl(ng_hci_unit_p unit, struct mbuf *event)
diff --git a/sys/netgraph/bluetooth/hci/ng_hci_evnt.h b/sys/netgraph/bluetooth/hci/ng_hci_evnt.h
index 706d7b0..497dda0 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_evnt.h
+++ b/sys/netgraph/bluetooth/hci/ng_hci_evnt.h
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ng_hci_evnt.h,v 1.4 2002/09/04 21:36:51 max Exp $
+ * $Id: ng_hci_evnt.h,v 1.1 2002/11/24 19:46:58 max Exp $
* $FreeBSD$
*/
diff --git a/sys/netgraph/bluetooth/hci/ng_hci_main.c b/sys/netgraph/bluetooth/hci/ng_hci_main.c
index c3c77fc..4a6a62d 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_main.c
+++ b/sys/netgraph/bluetooth/hci/ng_hci_main.c
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ng_hci_main.c,v 1.28 2002/11/12 22:35:40 max Exp $
+ * $Id: ng_hci_main.c,v 1.2 2003/03/18 00:09:36 max Exp $
* $FreeBSD$
*/
@@ -119,6 +119,7 @@ ng_hci_constructor(node_p node)
unit->link_policy_mask = 0xffff; /* Enable all supported modes */
unit->packet_mask = 0xffff; /* Enable all packet types */
+ unit->role_switch = 1; /* Enable role switch (if device supports it) */
/*
* Set default buffer info
@@ -535,7 +536,6 @@ ng_hci_default_rcvmsg(node_p node, item_p item, hook_p lasthook)
bcopy(&c->bdaddr, &e2->bdaddr,
sizeof(e2->bdaddr));
-
e2 ++;
if (--s <= 0)
break;
@@ -593,6 +593,31 @@ ng_hci_default_rcvmsg(node_p node, item_p item, hook_p lasthook)
*((ng_hci_node_packet_mask_ep *)(msg->data));
break;
+ /* Get role switch */
+ case NGM_HCI_NODE_GET_ROLE_SWITCH:
+ NG_MKRESPONSE(rsp, msg, sizeof(unit->role_switch),
+ M_NOWAIT);
+ if (rsp == NULL) {
+ error = ENOMEM;
+ break;
+ }
+
+ *((ng_hci_node_role_switch_ep *)(rsp->data)) =
+ unit->role_switch;
+ break;
+
+ /* Set role switch */
+ case NGM_HCI_NODE_SET_ROLE_SWITCH:
+ if (msg->header.arglen !=
+ sizeof(ng_hci_node_role_switch_ep)) {
+ error = EMSGSIZE;
+ break;
+ }
+
+ unit->role_switch =
+ *((ng_hci_node_role_switch_ep *)(msg->data));
+ break;
+
default:
error = EINVAL;
break;
diff --git a/sys/netgraph/bluetooth/hci/ng_hci_misc.c b/sys/netgraph/bluetooth/hci/ng_hci_misc.c
index ba92f89..fb7c661 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_misc.c
+++ b/sys/netgraph/bluetooth/hci/ng_hci_misc.c
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ng_hci_misc.c,v 1.18 2002/10/30 00:18:19 max Exp $
+ * $Id: ng_hci_misc.c,v 1.4 2003/04/26 22:35:21 max Exp $
* $FreeBSD$
*/
@@ -53,7 +53,6 @@
static void ng_hci_command_queue_timeout (void *);
static void ng_hci_con_queue_timeout (void *);
-static void ng_hci_con_queue_watchdog_timeout (void *);
/*
* Give packet to RAW hook
@@ -270,7 +269,6 @@ ng_hci_new_con(ng_hci_unit_p unit, int link_type)
NG_BT_ITEMQ_INIT(&con->conq, num_pkts);
callout_handle_init(&con->con_timo);
- callout_handle_init(&con->watchdog_timo);
LIST_INSERT_HEAD(&unit->con_list, con, next);
}
@@ -291,9 +289,6 @@ ng_hci_free_con(ng_hci_unit_con_p con)
if (con->flags & NG_HCI_CON_TIMEOUT_PENDING)
ng_hci_con_untimeout(con);
- if (con->flags & NG_HCI_CON_WATCHDOG_TIMEOUT_PENDING)
- ng_hci_con_watchdog_untimeout(con);
-
/*
* If we have pending packets then assume that Host Controller has
* flushed these packets and we can free them too
@@ -442,59 +437,6 @@ ng_hci_con_queue_timeout(void *context)
NG_NODE_UNREF(node);
} /* ng_hci_con_queue_timeout */
-/*
- * Set HCI connection watchdog timeout
- */
-
-void
-ng_hci_con_watchdog_timeout(ng_hci_unit_con_p con)
-{
- if (!(con->flags & NG_HCI_CON_WATCHDOG_TIMEOUT_PENDING)) {
- NG_NODE_REF(con->unit->node);
- con->flags |= NG_HCI_CON_WATCHDOG_TIMEOUT_PENDING;
- con->watchdog_timo = timeout(ng_hci_con_queue_watchdog_timeout,
- con, bluetooth_hci_watchdog_timeout());
- } else
- KASSERT(0,
-("%s: %s - Duplicated connection watchdog timeout!\n",
- __func__, NG_NODE_NAME(con->unit->node)));
-} /* ng_hci_con_watchdog_timeout */
-
-/*
- * Unset HCI connection watchdog timeout
- */
-
-void
-ng_hci_con_watchdog_untimeout(ng_hci_unit_con_p con)
-{
- if (con->flags & NG_HCI_CON_WATCHDOG_TIMEOUT_PENDING) {
- con->flags &= ~NG_HCI_CON_WATCHDOG_TIMEOUT_PENDING;
- untimeout(ng_hci_con_queue_watchdog_timeout, con,
- con->watchdog_timo);
- NG_NODE_UNREF(con->unit->node);
- } else
- KASSERT(0,
-("%s: %s - No connection watchdog timeout!\n",
- __func__, NG_NODE_NAME(con->unit->node)));
-} /* ng_hci_con_watchdog_untimeout */
-
-/*
- * OK timeout has happend, so queue timeout processing function
- */
-
-static void
-ng_hci_con_queue_watchdog_timeout(void *context)
-{
- ng_hci_unit_con_p con = (ng_hci_unit_con_p) context;
- node_p node = con->unit->node;
-
- if (NG_NODE_IS_VALID(node))
- ng_send_fn(node, NULL, &ng_hci_process_con_watchdog_timeout,
- con, 0);
-
- NG_NODE_UNREF(node);
-} /* ng_hci_con_queue_watchdog_timeout */
-
#if 0
/*
* Convert numeric error code/reason to a string
diff --git a/sys/netgraph/bluetooth/hci/ng_hci_misc.h b/sys/netgraph/bluetooth/hci/ng_hci_misc.h
index 862d7db..b9f29cd 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_misc.h
+++ b/sys/netgraph/bluetooth/hci/ng_hci_misc.h
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ng_hci_misc.h,v 1.8 2002/09/04 21:36:52 max Exp $
+ * $Id: ng_hci_misc.h,v 1.2 2003/04/26 22:35:21 max Exp $
* $FreeBSD$
*/
@@ -51,8 +51,6 @@ void ng_hci_command_timeout (ng_hci_unit_p);
void ng_hci_command_untimeout (ng_hci_unit_p);
void ng_hci_con_timeout (ng_hci_unit_con_p);
void ng_hci_con_untimeout (ng_hci_unit_con_p);
-void ng_hci_con_watchdog_timeout (ng_hci_unit_con_p);
-void ng_hci_con_watchdog_untimeout (ng_hci_unit_con_p);
#endif /* ndef _NETGRAPH_HCI_MISC_H_ */
diff --git a/sys/netgraph/bluetooth/hci/ng_hci_prse.h b/sys/netgraph/bluetooth/hci/ng_hci_prse.h
index 4c4bd6e..dd8ff06 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_prse.h
+++ b/sys/netgraph/bluetooth/hci/ng_hci_prse.h
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ng_hci_prse.h,v 1.9 2002/11/12 22:35:40 max Exp $
+ * $Id: ng_hci_prse.h,v 1.2 2003/03/18 00:09:36 max Exp $
* $FreeBSD$
*/
@@ -196,6 +196,20 @@ static const struct ng_cmdlist ng_hci_cmdlist[] = {
&ng_parse_uint16_type,
NULL
},
+ {
+ NGM_HCI_COOKIE,
+ NGM_HCI_NODE_GET_ROLE_SWITCH,
+ "get_role_sw",
+ NULL,
+ &ng_parse_uint16_type
+ },
+ {
+ NGM_HCI_COOKIE,
+ NGM_HCI_NODE_SET_ROLE_SWITCH,
+ "set_role_sw",
+ &ng_parse_uint16_type,
+ NULL
+ },
{ 0, }
};
diff --git a/sys/netgraph/bluetooth/hci/ng_hci_ulpi.c b/sys/netgraph/bluetooth/hci/ng_hci_ulpi.c
index 97a0ea8..927cfe1 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_ulpi.c
+++ b/sys/netgraph/bluetooth/hci/ng_hci_ulpi.c
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ng_hci_ulpi.c,v 1.14 2002/11/12 22:35:40 max Exp $
+ * $Id: ng_hci_ulpi.c,v 1.6 2003/04/26 22:35:21 max Exp $
* $FreeBSD$
*/
@@ -132,30 +132,22 @@ ng_hci_lp_acl_con_req(ng_hci_unit_p unit, item_p item, hook_p hook)
* 2) We do have connection descriptor. We need to check connection
* state:
*
- * 2.1) NG_HCI_CON_CLOSED mean we are in the process of closing
- * connection to the remote unit. We will reject connection
- * request until connection is closed.
- *
- * 2.2) NG_HCI_CON_W4_LP_CON_RSP means that we are in the middle of
+ * 2.1) NG_HCI_CON_W4_LP_CON_RSP means that we are in the middle of
* accepting connection from the remote unit. This is a race
* condition. We will ignore this message.
*
- * 2.3) NG_HCI_CON_W4_CONN_COMPLETE means that upper layer already
+ * 2.2) NG_HCI_CON_W4_CONN_COMPLETE means that upper layer already
* requested connection or we just accepted it. In any case
* all we need to do here is set appropriate notification bit
* and wait.
*
- * 2.4) NG_HCI_CON_OPEN means connection is open. Just reply back
+ * 2.3) NG_HCI_CON_OPEN means connection is open. Just reply back
* and let upper layer know that we have connection already.
*/
con = ng_hci_con_by_bdaddr(unit, &ep->bdaddr, NG_HCI_LINK_ACL);
if (con != NULL) {
switch (con->state) {
- case NG_HCI_CON_CLOSED:
- error = EBUSY;
- break;
-
case NG_HCI_CON_W4_LP_CON_RSP: /* XXX */
error = EALREADY;
break;
@@ -255,12 +247,14 @@ ng_hci_lp_acl_con_req(ng_hci_unit_p unit, item_p item, hook_p hook)
req->cp.pkt_type |= (NG_HCI_PKT_DM5|NG_HCI_PKT_DH5);
req->cp.pkt_type &= unit->packet_mask;
- if (req->cp.pkt_type == 0)
+ if ((req->cp.pkt_type & (NG_HCI_PKT_DM1|NG_HCI_PKT_DH1|
+ NG_HCI_PKT_DM3|NG_HCI_PKT_DH3|
+ NG_HCI_PKT_DM5|NG_HCI_PKT_DH5)) == 0)
req->cp.pkt_type = (NG_HCI_PKT_DM1|NG_HCI_PKT_DH1);
req->cp.pkt_type = htole16(req->cp.pkt_type);
- if (unit->features[0] & NG_HCI_LMP_SWITCH)
+ if ((unit->features[0] & NG_HCI_LMP_SWITCH) && unit->role_switch)
req->cp.accept_role_switch = 1;
else
req->cp.accept_role_switch = 0;
@@ -376,8 +370,6 @@ ng_hci_lp_sco_con_req(ng_hci_unit_p unit, item_p item, hook_p hook)
*
* 2.2) NG_HCI_CON_W4_CONN_COMPLETE means upper layer already requested
* connection or we just accepted it.
- *
- * XXX FIXME what to do with connection(s) in CLOSED state?
*/
LIST_FOREACH(sco_con, &unit->con_list, next)
@@ -450,7 +442,9 @@ ng_hci_lp_sco_con_req(ng_hci_unit_p unit, item_p item, hook_p hook)
req->cp.pkt_type |= NG_HCI_PKT_HV3;
req->cp.pkt_type &= unit->packet_mask;
- if (req->cp.pkt_type == 0)
+ if ((req->cp.pkt_type & (NG_HCI_PKT_HV1|
+ NG_HCI_PKT_HV2|
+ NG_HCI_PKT_HV3)) == 0)
req->cp.pkt_type = NG_HCI_PKT_HV1;
req->cp.pkt_type = htole16(req->cp.pkt_type);
@@ -479,12 +473,6 @@ out:
/*
* Process LP_DisconnectReq event from the upper layer protocol
- *
- * XXX XXX XXX
- *
- * NOTE: This is NOT defined by Bluetooth specification (why?) But i think
- * this might be useful (at least for testing), so please do not depend on
- * this interface.
*/
int
@@ -562,13 +550,6 @@ ng_hci_lp_discon_req(ng_hci_unit_p unit, item_p item, hook_p hook)
req->cp.reason = ep->reason;
/*
- * Adjust connection state
- */
-
- con->state = NG_HCI_CON_CLOSED;
- ng_hci_con_timeout(con);
-
- /*
* Queue and send HCI command
*/
@@ -813,16 +794,15 @@ ng_hci_lp_con_rsp(ng_hci_unit_p unit, item_p item, hook_p hook)
sizeof(req->cp.acc.bdaddr));
/*
- * XXX should be configurable?
- *
* We are accepting connection, so if we support role
- * switch then set role to NG_HCI_ROLE_MASTER and let
- * LM peform role switch. Otherwise it is probably
- * makes sense to remain slave. In this case LM WILL
- * NOT perform role switch.
+ * switch and role switch was enabled then set role to
+ * NG_HCI_ROLE_MASTER and let LM peform role switch.
+ * Otherwise we remain slave. In this case LM WILL NOT
+ * perform role switch.
*/
- if (unit->features[0] & NG_HCI_LMP_SWITCH)
+ if ((unit->features[0] & NG_HCI_LMP_SWITCH) &&
+ unit->role_switch)
req->cp.acc.role = NG_HCI_ROLE_MASTER;
else
req->cp.acc.role = NG_HCI_ROLE_SLAVE;
@@ -1183,24 +1163,16 @@ ng_hci_process_con_timeout(node_p node, hook_p hook, void *arg1, int arg2)
* We expect to receive connection timeout in one of the following
* states:
*
- * 1) NG_HCI_CON_CLOSED means that upper layer has requested disconnect
- * via LP_DISCON_REQ and we have not received Disconnect_Complete
- * event. In this case we will send LP_DISCON_IND to upper layer.
- *
- * 2) NG_HCI_CON_W4_LP_CON_RSP means that upper layer has not responded
+ * 1) NG_HCI_CON_W4_LP_CON_RSP means that upper layer has not responded
* to our LP_CON_IND. Do nothing and destroy connection. Remote peer
* most likely already gave up on us.
*
- * 3) NG_HCI_CON_W4_CONN_COMPLETE means upper layer requested connection
+ * 2) NG_HCI_CON_W4_CONN_COMPLETE means upper layer requested connection
* (or we in the process of accepting it) and baseband has timedout
* on us. Inform upper layers and send LP_CON_CFM.
*/
switch (con->state) {
- case NG_HCI_CON_CLOSED:
- ng_hci_lp_discon_ind(con, 0x16);
- break;
-
case NG_HCI_CON_W4_LP_CON_RSP:
break;
@@ -1218,63 +1190,3 @@ ng_hci_process_con_timeout(node_p node, hook_p hook, void *arg1, int arg2)
ng_hci_free_con(con);
} /* ng_hci_process_con_timeout */
-/*
- * Process connection watchdog timeout
- */
-
-void
-ng_hci_process_con_watchdog_timeout(node_p node, hook_p hook,
- void *arg1, int arg2)
-{
- ng_hci_unit_con_p con = (ng_hci_unit_con_p) arg1;
- struct discon_req {
- ng_hci_cmd_pkt_t hdr;
- ng_hci_discon_cp cp;
- } __attribute__ ((packed)) *req = NULL;
- struct mbuf *m = NULL;
-
- KASSERT((con->state == NG_HCI_CON_OPEN),
-("%s: %s - invalid connection state=%d, handle=%d\n",
- __func__, NG_NODE_NAME(node), con->state, con->con_handle));
-
- KASSERT((con->flags & NG_HCI_CON_WATCHDOG_TIMEOUT_PENDING),
-("%s: %s - No connection watchdog timeout!\n",
- __func__, NG_NODE_NAME(node)));
-
- con->flags &= ~NG_HCI_CON_WATCHDOG_TIMEOUT_PENDING;
-
- /*
- * Create HCI command
- */
-
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL)
- return; /* XXX this is bad */
-
- m->m_pkthdr.len = m->m_len = sizeof(*req);
- req = mtod(m, struct discon_req *);
- req->hdr.type = NG_HCI_CMD_PKT;
- req->hdr.length = sizeof(req->cp);
- req->hdr.opcode = htole16(NG_HCI_OPCODE(NG_HCI_OGF_LINK_CONTROL,
- NG_HCI_OCF_DISCON));
-
- req->cp.con_handle = htole16(con->con_handle);
- req->cp.reason = 0x13; /* User ended connection */
-
- /*
- * Queue and send HCI command
- */
-
- NG_BT_MBUFQ_ENQUEUE(&con->unit->cmdq, m);
- if (!(con->unit->state & NG_HCI_UNIT_COMMAND_PENDING))
- ng_hci_send_command(con->unit);
-
- /*
- * Send LP_DISCON_IND to the upper layers
- * Connection terminated by local host
- */
-
- ng_hci_lp_discon_ind(con, 0x16);
- ng_hci_free_con(con);
-} /* ng_hci_process_con_watchdog_timeout */
-
diff --git a/sys/netgraph/bluetooth/hci/ng_hci_ulpi.h b/sys/netgraph/bluetooth/hci/ng_hci_ulpi.h
index 9f4e0ef..28c3ade 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_ulpi.h
+++ b/sys/netgraph/bluetooth/hci/ng_hci_ulpi.h
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ng_hci_ulpi.h,v 1.4 2002/09/04 21:36:52 max Exp $
+ * $Id: ng_hci_ulpi.h,v 1.2 2003/04/26 22:35:21 max Exp $
* $FreeBSD$
*/
@@ -47,7 +47,6 @@ int ng_hci_lp_qos_cfm (ng_hci_unit_con_p, int);
int ng_hci_lp_qos_ind (ng_hci_unit_con_p);
void ng_hci_process_con_timeout (node_p, hook_p, void *, int);
-void ng_hci_process_con_watchdog_timeout (node_p, hook_p, void *, int);
#endif /* ndef _NETGRAPH_HCI_ULPI_H_ */
diff --git a/sys/netgraph/bluetooth/hci/ng_hci_var.h b/sys/netgraph/bluetooth/hci/ng_hci_var.h
index 43940a9..c0adccc 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_var.h
+++ b/sys/netgraph/bluetooth/hci/ng_hci_var.h
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ng_hci_var.h,v 1.14 2002/11/12 22:35:40 max Exp $
+ * $Id: ng_hci_var.h,v 1.3 2003/04/26 22:35:21 max Exp $
* $FreeBSD$
*/
@@ -133,6 +133,7 @@ typedef struct ng_hci_unit {
ng_hci_node_link_policy_mask_ep link_policy_mask; /* link policy mask */
ng_hci_node_packet_mask_ep packet_mask; /* packet mask */
+ ng_hci_node_role_switch_ep role_switch; /* role switch */
ng_hci_node_stat_ep stat; /* statistic */
#define NG_HCI_STAT_CMD_SENT(s) (s).cmd_sent ++
@@ -171,9 +172,8 @@ typedef struct ng_hci_unit_con {
u_int16_t state; /* con. state */
u_int16_t flags; /* con. flags */
#define NG_HCI_CON_TIMEOUT_PENDING (1 << 0)
-#define NG_HCI_CON_WATCHDOG_TIMEOUT_PENDING (1 << 1)
-#define NG_HCI_CON_NOTIFY_ACL (1 << 2)
-#define NG_HCI_CON_NOTIFY_SCO (1 << 3)
+#define NG_HCI_CON_NOTIFY_ACL (1 << 1)
+#define NG_HCI_CON_NOTIFY_SCO (1 << 2)
bdaddr_t bdaddr; /* remote address */
u_int16_t con_handle; /* con. handle */
@@ -184,7 +184,6 @@ typedef struct ng_hci_unit_con {
u_int8_t role; /* MASTER/SLAVE */
struct callout_handle con_timo; /* con. timeout */
- struct callout_handle watchdog_timo; /* watch dog */
int pending; /* # of data pkts */
ng_bt_itemq_t conq; /* con. queue */
OpenPOWER on IntegriCloud