|
From: Mattias A. <mat...@us...> - 2001-03-30 12:04:11
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
rfcomm.c 1.95 1.96=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* fixed blocking connect / disconnect
* lots of minor changes & cleanup
The diff of the modified file(s):
--- rfcomm.c 2001/03/12 15:54:35 1.95
+++ rfcomm.c 2001/03/30 12:03:25 1.96
@@ -132,7 +132,6 @@
#define NBROFCREDITS 6
=20
#define DEF_RFCOMM_MTU 127
-//#define DEF_RFCOMM_MTU 330
=20
/* The values in the control field when sending ordinary rfcomm packets */
#define SABM 0x2f
@@ -545,11 +544,16 @@
/* One RFCOMM connection for each bt_tty 0 to 6 */
=20
#ifdef __KERNEL__
+
+static struct timer_list rfcomm_timer;
+#define RFCOMM_CON_TIMEOUT (5*HZ)
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
static struct wait_queue *rfcomm_disconnect_wq =3D NULL;
#else
static wait_queue_head_t rfcomm_disconnect_wq;
#endif /* LINUX_VERSION_CODE */
+
#endif /* __KERNEL__ */
=20
void send_send_data(unsigned long ptr);
@@ -715,8 +719,6 @@
=20=09
if (!(rfcomm->l2cap)) {
=20
- printk("we don't have l2cap ch yet for this rfcomm ch\n");
-
rfcomm->dlci[0].state =3D CONNECTING;=20=20=20=20
=20
/* we don't have a l2cap connection yet */
@@ -779,12 +781,19 @@
=20=09=09
send_disc(rfcomm, tmp);
=20
- /* fixme -- do this block from bluetooth.c x*/
-
#ifdef __KERNEL__
+ start_wq_timer(&rfcomm_timer, RFCOMM_CON_TIMEOUT,
+ &rfcomm_disconnect_wq);
+
+ /* FIXME -- check that we haven't already received=20
+ disconnect 'acknowledge' */
interruptible_sleep_on(&rfcomm_disconnect_wq);
+
+ /* Now rfcomm is disconnected, disconnect l2cap */
+
l2ca_disconnect_req(rfcomm->l2cap);
- bt_unregister_rfcomm(line);
+
+ /* Now l2cap ch for RFCOMM is disconnected */
#endif
}
else
@@ -822,8 +831,6 @@
void rfcomm_connect_pnd(l2cap_con *l2cap, s32 status)
{
printk("rfcomm_connect_pnd : reason %d\n", status);=09
- //PRINTPSM(l2cap);
-
}
=20
void=20
@@ -892,12 +899,14 @@
Check whether the received params are acceptable,=20
accept all for now
*/
+
D_CTRL("rfcomm_config_ind : remote cid %d\n", l2cap->remote_cid);
/* check if we have sent a pos response yet */
if (!l2ca_remote_conf_done(l2cap)){
/* still haven't sent a pos configure response*/
=20=09=09
- if (l2ca_config_rsp(l2cap, l2cap->remote_mtu,NULL,1)) {
+ if (l2ca_config_rsp(l2cap, l2cap->remote_mtu,=20
+ NULL, CONF_SUCCESS)) {
D_ERR(FNC"l2ca_config_rsp failed\n");
}
} else=20
@@ -970,7 +979,7 @@
}
=20
/* The lower protocol layer, L2CAP, indicates that the lower layer=20
- connection is disconnected. */
+ connection is about to disconnect */
=20
void=20
rfcomm_disconnect_ind(l2cap_con *l2cap)
@@ -982,23 +991,21 @@
=20
rfcomm =3D ((rfcomm_con*) l2cap->upper_con);
=20
+
+ /* FIXME -- disconnect all rfcomm cons on this l2cap con=20
+ if any */
+
if (l2ca_disconnect_rsp(l2cap)) {
D_ERR(FNC"l2ca_disconnect_rsp failed\n");
return;
}
=20
#ifdef __KERNEL__
-
- bt_unregister_rfcomm(rfcomm->line);
-
/* notify upper tty that this rfcomm connection is down */
bt_hangupline(rfcomm->line);
#else
bt_disconnect_ind(CREATE_RFCOMM_ID(rfcomm->line, 0));
#endif
-=09
- rfcomm_reset_con(rfcomm->line);
-=09
#undef FNC
}
=20
@@ -1013,7 +1020,16 @@
=20
rfcomm =3D (rfcomm_con*) l2cap->upper_con;
=20
+ /* fixme -- should we indicate to bt interface when rfcomm is=20
+ down or when l2cap for rfcomm is down ? */
bt_disconnect_ind(CREATE_RFCOMM_ID(rfcomm->line, 0));
+#ifdef __KERNEL__
+ bt_unregister_rfcomm(rfcomm->line);
+
+ /* wake up bt line */
+ bt_disconnect_cfm(CREATE_RFCOMM_ID(rfcomm->line, 0),=20
+ l2cap->c_result);
+#endif
=20=09
rfcomm_reset_con(rfcomm->line);
=20=09
@@ -1155,14 +1171,17 @@
} else if (rfcomm->dlci[tmp_dlci].state =3D=3D DISCONNECTING) {
if (tmp_dlci =3D=3D 0) {
#ifdef __KERNEL__=20=20
+ release_wq_timer(&rfcomm_timer);
+ /* this will take down l2cap aswell */
wake_up_interruptible(&rfcomm_disconnect_wq);
+
#else
+ /* usermode stack */
l2ca_disconnect_req(rfcomm->l2cap);
#endif
=20=20=20=20=20=20=20=20=20
} else {
s32 tmp;
-=09=09=09=09
rfcomm->dlci[tmp_dlci].state =3D DISCONNECTED;
tmp =3D get_connected_dlci(rfcomm);
rfcomm->dlci[tmp].state =3D DISCONNECTING;
@@ -1175,6 +1194,7 @@
}=20=20=20=20
break;
=20=20=20=20=20
+ /* Disconnect mode, 'NAK on SABM/DISC' */
case DM:
D_CTRL(FNC"DM packet received\n");
rfcomm =3D ((rfcomm_con*) l2cap->upper_con);
@@ -1195,12 +1215,14 @@
rfcomm->dlci[0].state =3D DISCONNECTED;
/* FIXME:
Tell the tty that the link is down */
+ printk("RFCOMM control ch disconnected\n");
send_ua(rfcomm, tmp_dlci);
- bt_disconnect_ind(CREATE_RFCOMM_ID(rfcomm->line, 0));
} else {
rfcomm->dlci[tmp_dlci].state =3D DISCONNECTED;
send_ua(rfcomm, tmp_dlci);
- bt_disconnect_ind(CREATE_RFCOMM_ID(rfcomm->line, tmp_dlci));
+ D_CTRL("dlci %d was disconnected\n", tmp_dlci);
+ bt_disconnect_ind(CREATE_RFCOMM_ID(rfcomm->line,=20
+ tmp_dlci));
}
D_CTRL(FNC"DISC, sending back UA\n");
=20=20=20=20=20
@@ -1236,7 +1258,8 @@
}
=20
if (GET_PF(short_pkt->h.control)) {
- printk(FNC" %d more credits on dlci:%d...\n", *uih_data_start, tmp_dlci=
);
+ printk(FNC" %d more credits on dlci:%d...\n",=20
+ *uih_data_start, tmp_dlci);
if (crc_check(data, SHORT_CRC_CHECK,=20
uih_data_start[1])) {
break;
@@ -1390,7 +1413,6 @@
}
=20
/* Parses a multiplexer control channel packet */
-
void=20
process_mcc(u8* data, u32 len, rfcomm_con *rfcomm, s32 longpkt)
{
|