|
From: Anders J. <and...@us...> - 2003-04-14 08:43:54
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
bluetooth.c 1.238 1.239=20=20=20=20=20=20=20=20=20=20=20=20=20
hci.c 1.209 1.210=20=20=20=20=20=20=20=20=20=20=20=20=20
l2cap.c 1.136 1.137=20=20=20=20=20=20=20=20=20=20=20=20=20
tcs.c 1.17 1.18=20=20=20=20=20=20=20=20=20=20=20=20=20=20
test.c 1.39 1.40=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
lp_disconnect can now be used non-blocking to allow us to disconnect
remote clients in an interupt.
Added option to disconnect clients which fail to switch roles.
The diff of the modified file(s):
--- bluetooth.c 6 Mar 2003 16:04:00 -0000 1.238
+++ bluetooth.c 14 Apr 2003 08:43:46 -0000 1.239
@@ -273,6 +273,7 @@
=20
extern hci_controller hci_ctrl;
extern u8 name_request_response[BT_NAME_LENGTH + 1];
+extern u8 dont_allow_slave;
=20
/* Use global variables to store line and server channel of a new incoming=
connection */
#ifdef CONFIG_BLUETOOTH_PROC
@@ -647,7 +648,7 @@
return -MSGCODE(MSG_BT_INTERFACE, BT_NOTCONNECTED);
}
=20
- return lp_disconnect(con_str->hci_hdl);
+ return lp_disconnect(con_str->hci_hdl, 1);
}
=20
case BTWAITFORCONNECTION:
@@ -1427,6 +1428,20 @@
=20
BT_DRIVER("BTSETMSSWITCH: %d\n", enable);
hci_force_msswitch(enable);
+ return 0;
+ }
+
+ /* set dont_allow_slave flag. If set to 1 and we are
+ using the force_ms flag any client which doesn't
+ support M/S-switching will be disconnected by
+ us if we are non-initiators */
+ case BTDONTALLOWSLAVE:
+ {
+ u8 flag;
+ GET_USER(tmp, (s32*)arg);
+ flag =3D (u8)(tmp & 0xff);
+ BT_DRIVER("BTDONTALLOWSLAVE: %d\n", flag);
+ dont_allow_slave =3D flag;
return 0;
}
=20
--- hci.c 6 Mar 2003 16:03:57 -0000 1.209
+++ hci.c 14 Apr 2003 08:43:46 -0000 1.210
@@ -193,7 +193,7 @@
=20
/* Link Control Commands */
static s32 create_connection(u8 *bd, u32 pkt_type, u8 psrm, u8 psm, u32 c_=
off, u32 rol_sw);
-static s32 disconnect(u32 hdl, u8 reason);
+static s32 disconnect(u32 hdl, u8 reason, u8 block);
static s32 accept_connection_request(u8 bd_addr[], u8 role);
static s32 reject_connection_request(u8 bd_addr[], u32 reason);
static s32 change_connection_packet_type(u32 hci_hdl, u32 pkt_type);
@@ -816,6 +816,8 @@
{
u16 hci_hdl;
s32 i;
+ l2cap_con *con;
+ u8 rev_bd[6];
=20
PRINTPKT(__FUNCTION__, buf, len);
=20
@@ -1118,6 +1120,18 @@
case ROLE_CHANGED:
DSYS(__FUNCTION__ ": ROLE_CHANGED\n");
=20
+ /* Find the connection and set the role */
+ if ((con =3D get_con(buf + 1, CLOSED)) =3D=3D NULL) {
+ D_ERR(__FUNCTION__ ": couldn't find connection!\n");
+ break;
+ }
+
+ if(con->initiator) {
+ con->role =3D 0x00;
+ } else {
+ con->role =3D 0x01;
+ }
+
if (buf[0]) {
D_ERR(__FUNCTION__ ": Role changed failed due to %s\n",
get_err_msg(buf[0]));
@@ -1126,9 +1140,11 @@
} else if (buf[7]) {
DSYS(__FUNCTION__ ": Current master is 0x%04x%08x\n",
le16_to_cpuu(&buf[5]), le32_to_cpuu(&buf[1]));
+ con->role =3D 0x01;
} else {
DSYS(__FUNCTION__ ": Our role is master for BD Address 0x%04x%08x\n",
le16_to_cpuu(&buf[5]), le32_to_cpuu(&buf[1]));
+ con->role =3D 0x00;
}
break;
=20
@@ -2218,7 +2234,7 @@
disconnected. The Reason function parameter indicates the reason for en=
ding
the connection, see page 552 specification core 1.0B */
s32
-disconnect(u32 hdl, u8 reason)
+disconnect(u32 hdl, u8 reason, u8 block)
{
D_CMD(__FUNCTION__ "\n");
c_pkt.type =3D CMD_PKT;
@@ -2229,8 +2245,12 @@
c_pkt.data[2] =3D reason;
c_pkt.len =3D 3;
=20
+ if(block) {
return send_cmd_block((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN,
DEFAULT_TIMEOUT);
+ } else {
+ return send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
+ }
}
=20
/* A positive response to a previous connection request, role =3D 0 sets m=
aster,
@@ -3557,9 +3577,9 @@
=20
/* Disconnect a certain connection handler */
s32
-lp_disconnect(u32 hci_hdl)
+lp_disconnect(u32 hci_hdl, u8 block)
{
- return disconnect(hci_hdl, DISCMSG_USER_ENDED_CONNECTION);
+ return disconnect(hci_hdl, DISCMSG_USER_ENDED_CONNECTION, block);
}
=20
=20
--- l2cap.c 6 Mar 2003 16:03:59 -0000 1.136
+++ l2cap.c 14 Apr 2003 08:43:47 -0000 1.137
@@ -237,6 +237,7 @@
static struct protocol_layer default_protocol;
extern int bt_max_connections;
extern hci_controller hci_ctrl;
+u8 dont_allow_slave =3D 0;
=20
/****************** FUNCTION DEFINITION SECTION **************************=
***/
=20=20=20
@@ -1637,7 +1638,7 @@
callers responsibility to take proper action */
D_ERR(__FUNCTION__ ": failed (status %d)\n", retval);
if(!tmpcon) {
- lp_disconnect(con->hci_hdl);
+ lp_disconnect(con->hci_hdl, 1);
}
ENTERSTATE(con, CLOSED);
delete_con(con);
@@ -1654,7 +1655,7 @@
}
=20
if(!tmpcon) {
- lp_disconnect(con->hci_hdl);
+ lp_disconnect(con->hci_hdl, 1);
}
=20=09=09
switch(con->c_status) {
@@ -1769,7 +1770,7 @@
if (count_con(tmp_hdl) =3D=3D 0) {
DSYS("l2ca_disconnect_req : (C) no more l2cap cons\n");
DSYS("Shutdown baseband\n");
- lp_disconnect(tmp_hdl);
+ lp_disconnect(tmp_hdl, 1);
}
=20
return retval;
@@ -2797,6 +2798,18 @@
return;
}
=20=20=20
+ /* Check which role the device have at the moment,=20
+ if we only accept us to be the master and the=20
+ client currently is the master as a result of
+ a failure of the MS-switch we deny the connection
+ here */
+ if(dont_allow_slave && (!con->initiator) && con->role) {
+ D_ERR(__FUNCTION__ ": Remote role not allowed, the client failed to swit=
ch roles. Disconnecting.\n");
+ l2ca_connect_rsp(con, RES_SECNEG, STAT_NOINFO);
+ lp_disconnect(con->hci_hdl, 0);
+ return;
+ }
+=20=20
get_upper(con->psm)->con_ind(con);
}
=20
@@ -2954,7 +2967,7 @@
}
=20
if(first_conn) {
- lp_disconnect(con->hci_hdl);
+ lp_disconnect(con->hci_hdl, 1);
}
=20
return retval;
--- tcs.c 1 Aug 2002 16:19:29 -0000 1.17
+++ tcs.c 14 Apr 2003 08:43:50 -0000 1.18
@@ -490,7 +490,7 @@
=20=09
case RELEASE:
D_REC(FNC"Received RELEASE message\n");
- if (lp_disconnect(tcs[0].sco_hdl)) {
+ if (lp_disconnect(tcs[0].sco_hdl, 1)) {
D_ERR("lp_disconnect failed\n");
} else {
send_single_octet_msg(l2cap, RELEASE_COMPLETE, CALL_CONTROL);
--- test.c 6 Mar 2003 16:04:08 -0000 1.39
+++ test.c 14 Apr 2003 08:43:50 -0000 1.40
@@ -525,7 +525,7 @@
}
else if(!strncmp(cmd, "bb_disc ", 8)) {
int i =3D strtoul(cmd+8, NULL, 0);
- return lp_disconnect((unsigned short)i);
+ return lp_disconnect((unsigned short)i, 1);
}
else if(!strncmp(cmd, "lcid_disconnect ", 16)) {
l2cap_con *con =3D NULL;
|