|
From: Mats F. <ma...@us...> - 2001-02-27 14:59:08
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.82 1.83=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added l2cap_register_default_upper function, to be used by TCI
The diff of the modified file(s):
--- l2cap.c 2001/02/16 14:25:59 1.82
+++ l2cap.c 2001/02/27 15:00:16 1.83
@@ -322,6 +322,12 @@
prot->next_layer =3D NULL;
}
=20
+void=20
+l2cap_register_default_upper(struct protocol_layer *prot)
+{
+ memcpy(&default_protocol, prot, sizeof(protocol_layer));
+}
+
s32=20
l2cap_shutdown(void)
{
@@ -341,6 +347,8 @@
}
=20
/* is called with a struct of functions to handle incoming data */
+
+
s32=20
l2cap_register_upper(u16 psm, struct protocol_layer *prot)=20
{
@@ -1456,6 +1464,7 @@
return;
}=20
=20
+=09
get_upper(con->psm)->receive_data(con, data, len);
}
=20
@@ -2428,8 +2437,6 @@
layers add header data */
return hci_send_data(tx);
}
-
-
=20=20
/*******************************************************************/
/* (A3) l2cap to l2cap data transmission */
|
|
From: Peter K. <pk...@us...> - 2001-03-05 16:37:58
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.89 1.90=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Made user stack version compile without CONFIG_BLUETOOTH_L2CAP_USE_TIMERS.
The diff of the modified file(s):
--- l2cap.c 2001/03/05 15:52:52 1.89
+++ l2cap.c 2001/03/05 16:39:35 1.90
@@ -2768,6 +2768,7 @@
}
=20
=20
+#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
#ifdef __KERNEL__
void
l2cap_rtx_timeout(unsigned long ptr)
@@ -2808,7 +2809,6 @@
=20=20=20
/* FIXME -- send l2ca_timeoutind() */
=20
-#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
if (MAX_NO_RTX =3D=3D 0)
{
/* no retransmissions, shutdown connection */
@@ -2832,7 +2832,6 @@
delete_con(con);
return;
}
-#endif
=20
/* now resend command */
switch(con->last_cmd.type) {
@@ -2917,7 +2916,7 @@
timer_cancelled =3D 0;
#endif
}
-#endif
+#endif /* __KERNEL__ */
=20
void
disable_rtx(l2cap_con *con)
@@ -2931,7 +2930,6 @@
#endif
}
=20
-
void
l2cap_ertx_timeout(unsigned long ptr)
{
@@ -2950,8 +2948,6 @@
/* if sending new request start RTX again */
=20
/* terminate for now */
-=09
-=09
}
=20
void
@@ -2965,8 +2961,7 @@
{
D_TIM("Disabling ERTX timer\n");
}
-
-
+#endif /* CONFIG_BLUETOOTH_L2CAP_USE_TIMERS */
=20
/***************************************************************/
/*--------------------- MISCELLANEOUS ------------------------ */
|
|
From: Peter K. <pk...@us...> - 2001-03-12 16:07:41
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- l2cap.c 1.92 1.93=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Needed to include sysdep-2.1.h to get le16_to_cpu() defined on 2.0.x The diff of the modified file(s): --- l2cap.c 2001/03/12 15:54:35 1.92 +++ l2cap.c 2001/03/12 16:09:37 1.93 @@ -47,6 +47,7 @@ #ifdef __KERNEL__ #include <linux/malloc.h> =20 +#include <linux/bluetooth/sysdep-2.1.h> #include <linux/bluetooth/l2cap.h> #include <linux/bluetooth/hci.h> #include <linux/bluetooth/rfcomm.h> |
|
From: Mattias A. <mat...@us...> - 2001-03-30 11:59:23
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.94 1.95=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* added usage of l2ca_wait / l2ca_wakeup which blocks on a=20
connection until a response is received or the connection times out.
* removed do_cmd_backup, use blocking calls in calling function instead
* fixed l2cap_config_rsp with options / pending response /=20
not accepted config options
* fixed bug when sending back responses and con->hci_hdl not yet set
* added flags in l2cap_con struct to handle blocking calls and signalling/
result codes to upper layers.=20
* now handles conf resp flag (fragmented options)
* fixed RTX/ERTX timer handling
* removed l2cap_disconnect_wq
* added l2ca_timeoutind
* lots of minor changes and cleanup
The diff of the modified file(s):
--- l2cap.c 2001/03/27 19:32:28 1.94
+++ l2cap.c 2001/03/30 11:59:20 1.95
@@ -57,6 +57,7 @@
#include <linux/bluetooth/l2cap_internal.h>
#include <linux/bluetooth/l2cap_con.h>
#include <linux/bluetooth/l2cap_sec.h>
+#include <linux/bluetooth/bt_errno.h>
#else /* user mode */
#include <stdlib.h>
#include <string.h>
@@ -72,6 +73,7 @@
#include "include/test.h"
#include "include/btmem.h"
#include "include/local.h"
+#include "include/bt_errno.h"
#endif
=20
/****************** DEBUG CONSTANT AND MACRO SECTION *********************=
***/
@@ -208,28 +210,21 @@
=20
static s32 parse_options(l2cap_con* con, u8 *data, u32 len);
static void print_flow(flow *f);
-static s32 l2cap_echo_rsp(s32 hci_hdl, s32 id, u8 *opt_data, s32 opt_len);
static s32 l2cap_cmdrej(s32 hci_hdl, u8 reason, u8 *opt_data, s32 opt_len);
=20
void insert_upper(protocol_layer *upper_layer);
protocol_layer* get_upper(u32 psm);
void remove_all_upper(void);
=20
-#ifdef __KERNEL__
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
-static struct wait_queue *l2cap_disconnect_wq =3D NULL;
-#else
-static wait_queue_head_t l2cap_disconnect_wq;
-#endif /* LINUX_VERSION_CODE */
-#endif /* __KERNEL__ */
-
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
-#define MAX_NO_RTX 0
-#define RTX_TIMEOUT 5 /* sec */
+
+/* fixme -- calculate this using flush timeout */
+#define MAX_NO_RTX 3
+#define RTX_TIMEOUT 2 /* sec */
#define ERTX_TIMEOUT 60 /* sec */
=20
#ifdef __KERNEL__
-void start_rtx(l2cap_con *con, unsigned short timeout);
+void start_rtx(l2cap_con *con, unsigned short timeout, unsigned short acti=
on);
void disable_rtx(l2cap_con *con);
void start_ertx(l2cap_con *con, unsigned short timeout);
void disable_ertx(l2cap_con *con);
@@ -240,15 +235,11 @@
=20
l2cap_con *timeout_con =3D NULL;
s32 timer_cancelled =3D 0;
-void start_rtx(l2cap_con *con, s32 timeout);
+void start_rtx(l2cap_con *con, s32 timeout, u16 action);
void disable_rtx(l2cap_con *con);
void l2cap_rtx_timeout(void);
#endif
=20
-/* used to resend lost l2cap commands */
-void do_cmd_backup(l2cap_con *con, u8 type, u16 in_mtu,=20
- flow *outflow, u16 flush_timeout, u16 link_to,
- u16 info_type);
#endif
=20
/****************** GLOBAL VARIABLE DECLARATION SECTION ******************=
***/
@@ -308,13 +299,6 @@
DSYS("Local bd [%s]\n", bd_name);
}
=20
- /* Initialize the l2cap_disconnect_wq */
-#ifdef __KERNEL__
-#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
- init_waitqueue_head(&l2cap_disconnect_wq);
-#endif /* LINUX_VERSION_CODE */
-#endif /* __KERNEL__ */
-
#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER
/* Initialize security */
l2cap_sec_man_init();
@@ -358,15 +342,23 @@
s32=20
l2cap_shutdown(void)
{
+ //l2cap_con *con =3D get_first_con();
+=20=20
DSYS("Shutting down L2CAP\n");
if (!l2cap->initiated)
{
D_ERR("L2CAP not initiated\n");
return -1;
}
-=09
- /* FIXME - Disconnect all open connections */
=20
+#if 0
+ /* Notify upper users, don't have time for real disconnect... */
+ while (con!=3D NULL) {
+ l2ca_disconnect_ind(con);
+ con =3D get_next_con(con);
+ }
+#endif
+ /* necessary ? */
free_list();
remove_all_upper();
=20
@@ -474,6 +466,7 @@
tmp_layer =3D l2cap->upper_layers;
l2cap->upper_layers =3D tmp_layer->next_layer;
kfree(tmp_layer);
+ tmp_layer =3D NULL;
}
}
=20
@@ -655,7 +648,6 @@
if (pos < len){
cmd =3D (struct sig_cmd *)(data + pos);
cmd->len =3D le16_to_cpu(cmd->len);
- printk("pos %d, len %d\n", pos, len);
DSYS("another command in same packet...(%d bytes)\n",
cmd->len);
}
@@ -767,13 +759,17 @@
req->len-4);
}
=20
+ /* Are we expecting more config requests ? */
+ con->remote_flags =3D confreq->flags;
+
if (result !=3D CONF_SUCCESS) {
/* we didn't like the options... */
DSYS("parse_options failed, send neg rsp\n");
=20
/* send back negative response */
- if (l2ca_config_rsp(con, result, STAT_NOINFO, 0) < 0) {
- D_ERR("Couldnt send conf rsp\n");
+ if (l2ca_config_rsp(con, result, STAT_NOINFO,=20
+ CONF_FAILURE) < 0) {
+ D_ERR("Couldn't send conf rsp\n");
}
return;
}
@@ -805,12 +801,17 @@
return;
}
=20=09=09=09
+ /* Are we expecting more config requests ? */
+ con->remote_flags =3D confreq->flags;
+
if (result !=3D RES_SUCCESS) {
=20=09=09=09=09
/* we didn't like the options... */
=20=09=09=09=09
/* send back negative response */
- if (l2ca_config_rsp(con, result, STAT_NOINFO, 0) < 0) {
+ if (l2ca_config_rsp(con, result,=20
+ STAT_NOINFO,=20
+ CONF_FAILURE) < 0) {
D_ERR("Couldnt send conf rsp\n");
}
return;
@@ -869,7 +870,7 @@
=20=20=20=20=20=20=20=20
case SIG_ECHOREQ: {
sig_echo_pkt* echo;
- D_STATE(FNC"echo request\n");
+ D_STATE(FNC"Echo request\n");
=20=09=09
echo =3D (sig_echo_pkt *)(req->data);=09=09
=20
@@ -881,7 +882,7 @@
case SIG_INFOREQ: {
/* Implementation specific */
sig_info_req *info;
- D_STATE(FNC"info request\n");
+ D_STATE(FNC"Info request\n");
=20=09=09
info =3D (sig_info_req*)(req->data);
info->type =3D le16_to_cpu(info->type);
@@ -896,7 +897,7 @@
=20
default:
D_ERR("Unknown info request : type 0x%x\n", info->type);
- l2cap_cmdrej(con->hci_hdl, CMDREJ_NOTUNDERSTOOD,
+ l2cap_cmdrej(hci_handle, CMDREJ_NOTUNDERSTOOD,
NULL, 0);
break;=09=09
}
@@ -910,7 +911,7 @@
default:
/* Not a valid command */
DSYS(FNC"Invalid command (code 0x%x)s\n", req->code);
- l2cap_cmdrej(con->hci_hdl, CMDREJ_NOTUNDERSTOOD, NULL, 0);
+ l2cap_cmdrej(hci_handle, CMDREJ_NOTUNDERSTOOD, NULL, 0);
break;
}
#undef FNC
@@ -939,7 +940,7 @@
switch (rsp->code) {
case SIG_CMDREJECT:
D_STATE(FNC"Command reject - \n");
-=20=20=20=20=20=20=20=20=20
+ DSYS("Got command reject\n");
cmdreject =3D (sig_cmdreject*)rsp->data;
cmdreject->reason =3D le16_to_cpu(cmdreject->reason);
opt_len =3D rsp->len - sizeof(sig_cmdreject);
@@ -964,6 +965,15 @@
if (opt_len > 0)
print_data(FNC"optional data : ",=20
cmdreject->data, rsp->len-2);
+
+ /* fixme -- set 'real' reason code */
+ con->c_status =3D CSTATUS_CMDREJECT;
+=09=09
+ l2ca_wakeup("l2cap cmd reject", con);
+
+#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS=09=09
+ disable_rtx(con);
+#endif
break;
=20=20=20=20=20=20=20=20
case SIG_CONRSP:
@@ -989,41 +999,40 @@
return;
}
=20=20=20=20=20=20=20=20=20=20
-#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
- disable_rtx(con);
-#endif
+ con->c_status =3D conrsp->result;=09=09
=20
switch (conrsp->result) {
case RES_SUCCESS:
+ l2ca_wakeup("l2cap_connect_rsp", con);
ENTERSTATE(con, CONFIG);
PRINTSTATE(con);
l2ca_connect_cfm(con, conrsp->result);
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case RES_PENDING:
+
+ /* wake up when real con resp comes */
l2ca_connect_pnd(con, conrsp->status);
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
/* Disable RTX timer and start ERTX */
- //start_ertx();
+ disable_rtx(con);
+ start_ertx(con, ERTX_TIMEOUT);
#endif
- D_STATE(FNC"connection pending (fixme)\n");
+ D_STATE(FNC"connection pending\n");
break;
=20
case RES_PSMNEG:
- /* FIXME */
DSYS(FNC"connection refused, psm 0x%x not supp\n",=20
con->psm);
failure =3D 1;
break;
=20
case RES_SECNEG:
- /* FIXME */
DSYS(FNC"connection refused, security block\n");
failure =3D 1;
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case RES_NOSRC:
- /* FIXME */
DSYS(FNC"connection refused, no resources\n");
failure =3D 1;
break;
@@ -1034,18 +1043,16 @@
}
=20=20=20=20=20=20=20=20=20=20
if (failure) {
- /* Connection refused=20
- FIXME -
- Disable RTX/ERTX timers
- (New state : CLOSED)
- */
+
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
disable_rtx(con);
- //disable_ertx(con);
+ disable_ertx(con);
#endif
=20
l2ca_connect_cfm(con, MSGCODE(MSG_LAYER_L2CAP, conrsp->result));
=20=09=09=09
+ l2ca_wakeup("Got connect rsp neg", con);
+=09=09=09
ENTERSTATE(con, CLOSED);
delete_con(con);
}
@@ -1079,19 +1086,15 @@
=20
switch (confrsp->result) {
case CONF_SUCCESS:
+
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
disable_rtx(con);
#endif
-
- /* FIXME - should check that we have received=20
- l2cap_config_req & replied pos. If we are server=20
- we can now proceed to OPEN (will do for now) */
-=20=20=20=20=20=20=20=20=20=20=20
con->conf_req_ready =3D TRUE;
=20
if (!con->conf_rsp_ready) {
/* Upper layers still haven't replied pos */
- DSYS("Still haven't replied pos on other sides conf req\n");
+ D_STATE("Still haven't replied pos on other sides conf req\n");
return ;
} else {=09=09=09=09
ENTERSTATE(con, OPEN);
@@ -1103,19 +1106,25 @@
/* notify upper layers that we successfully
opened a connection ! */
l2ca_config_cfm(con, confrsp->result);
- }
- return;
+ } return;
=20=09=09=09
case CONF_FAILURE:
+
+ /* store remote side configuration */
+ parse_options(con, confrsp->options, opt_len);
+
D_STATE(FNC"config failure, unacceptable params\n");
+ l2ca_config_cfm(con, confrsp->result);
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case CONF_REJ:
D_STATE(FNC"connection refused, no reason\n");
+ l2ca_config_cfm(con, confrsp->result);
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case CONF_UNKNOWN:
D_STATE(FNC"connection refused, unknown options\n");
+ l2ca_config_cfm(con, confrsp->result);
break;
=20=20=20=20=20=20=20=20=20=20=20=20=20
default:
@@ -1133,17 +1142,11 @@
D_ERR(FNC"SIG_CONFRSP invalid state\n");
PRINTSTATE(con);
=20
- /* FIXME - should stay in CONFIG state and renegotiate=20
- according to spec */
- printk("FIXME -- CONFIG failed, remain in CONFIG and renegotiate\n");
/* print failed options */
if (opt_len > 0)
print_data("Options not accepted\n", confrsp->options,=20
rsp->len - sizeof(sig_confrsp));
=20
- /* For now we simply disconnect if params failed */
- l2ca_config_cfm(con, confrsp->result);
- l2ca_disconnect_req(con);
break;
=20=20=20=20=20=20=20=20=20
case SIG_DISCRSP:
@@ -1165,15 +1168,17 @@
=20=09=20=20=20=20=20=20=20=09=20=20=20=20=20=20=20
/* match id with request */
if (!id_matched(con, rsp->id)) {
- D_ERR(FNC"ID doesn't match ! [%d:%d]\n", con->sig_id_sent, rsp->id);=09=
=09=09
+ D_ERR(FNC"ID doesn't match ! [%d:%d]\n",=20
+ con->sig_id_sent, rsp->id);
return;
}
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
disable_rtx(con);
#endif=09
-
l2ca_disconnect_cfm(con);
+ con->c_result =3D RES_SUCCESS;
+ l2ca_wakeup("l2cap_disconnect_rsp", con);
break;
=20=20=20=20=20=20=20=20
case SIG_ECHORSP: {
@@ -1193,31 +1198,47 @@
PRINTPKT(FNC"optional data ",=20
echo->data, rsp->len-sizeof(sig_echo_pkt));
=20
- l2ca_ping_rsp(echo->data,=20=20
- rsp->len-sizeof(sig_echo_pkt),
- tempcon->remote_bd);
+#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
+ disable_rtx(tempcon);
+#endif
+ /* now wake up l2ca_ping */
=20
- /* for now we disconnect every time a successful=20
- ping was made if no others are using this handle */
+ tempcon->c_status =3D CSTATUS_SUCCESS;
+ tempcon->c_result =3D RES_SUCCESS;
+ l2ca_wakeup("echo resp received", tempcon);
=20=09=09
- if (count_con(hci_handle) =3D=3D 1) {
- printk("DO NOT disconnect after doing ping...\n");
- //lp_disconnect(hci_handle);
- }
break;
}=20=20=20=20
=20=20=20=20=20=20=20=20
- case SIG_INFORSP:
+ case SIG_INFORSP: {
+ l2cap_con *tempcon;
+
+ if ((tempcon =3D get_con_hcihdl(hci_handle))=3D=3DNULL) {
+ D_STATE("Echo rsp : could not find connection\n");
+ return;
+ }
+
info =3D (sig_info_rsp *)(rsp->data);
info->type =3D le16_to_cpu(info->type);
info->result =3D le16_to_cpu(info->result);
+=09=09
D_STATE(FNC"Got info response : result %d\n", info->result);
+
+#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
+ disable_rtx(tempcon);
+#endif
+ /* now wake up l2ca_ping */
+=09=09
+ tempcon->c_status =3D RES_SUCCESS;
+ l2ca_wakeup("info resp received", tempcon);
+=09=09
break;
+ }
=20=20=20=20=20=20=20=20
default:
/* Not a valid command */
DSYS(FNC"Invalid command 0x%x\n", rsp->code);
- l2cap_cmdrej(con->hci_hdl, CMDREJ_NOTUNDERSTOOD, NULL, 0);
+ l2cap_cmdrej(hci_handle, CMDREJ_NOTUNDERSTOOD, NULL, 0);
break;
}
=20=09
@@ -1305,17 +1326,16 @@
Confirms the request to establish a baseband connection
*/
=20
-/* FIXME - add passing authentication challenge if auth is required=20
- to establish the physical link */
-=20=20
void=20
lp_connect_cfm(u8 *bd_addr, u32 status, u16 con_hdl)
{
l2cap_con *con;
D_STATE("lp_connect_cfm: %s (hci_handle : %d)\n",=20
get_err_msg(status), con_hdl);
+ print_data("lp_connect_cfm BD", bd_addr, 6);
=20
- /* FIXME -- use bt session list to notify upper layers that con failed !!=
! */
+ /* FIXME -- use bt session list to notify upper layers that=20
+ con failed !!! */
=20
/* search for the corresponding l2cap connection */
if ((con =3D get_con(bd_addr, CLOSED)) =3D=3D NULL) {
@@ -1323,75 +1343,57 @@
return;
}
=20=09
+ con->c_status =3D status;
+=09
if (status =3D=3D 0) {
/* pos cfm */
con->hci_hdl =3D con_hdl;
con->link_up =3D TRUE;
=20
+ /* see if there is someone to wakeup */
+ l2ca_wakeup("lp_connect_cfm", con);
+=09=09
+ if (con->c_flags & FLAG_RETURNNOW)
+ {
+ printk("Return NOW\n");
+ /* clear flag & set status */
+ con->c_flags &=3D ~FLAG_RETURNNOW;
+ return;
+ }
#ifdef __CRIS__
bt_connections++;
#endif
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
- /* Check if a ping is to be sent */
- if (con->ping_sent) {
- D_STATE("baseband up, now send ping\n");
- l2cap_echo_req(con, NULL, 0);
- con->ping_sent=3D0; /* only send one / request */
- return; /* don't try to connect l2cap... */
- }
-
- /* Check if a info req is to be sent */
- if (con->inforeq_sent) {
- D_STATE("baseband up, now send info req\n");
- printk("info type %d\n", con->last_cmd.inforeq_type);
- l2cap_info_req(con, con->last_cmd.inforeq_type);
- con->inforeq_sent=3D0; /* only send one / request */
- return; /* don't try to connect l2cap... */
- }
-=09=09
if (!(con->initiator)) {=09=09
- D_STATE("we are server\n");
+ D_STATE("We are server\n");
/* now wait for a connection request */
} else {
- D_STATE("we are client\n");
+ D_STATE("We are client\n");
PRINTPKT("lp_connect_cfm : HCI connected to ",=20
bd_addr,6);
=20=20=20=20=20=20=20
ENTERSTATE(con, W4_L2CAP_CONNECT_RSP);
PRINTSTATE(con);
=20=09=09=09
-#ifdef BTD_USERSTACK
- /* wait for 3coms HW while they are doing=20
- write_link_policy ?!? */
- printk("sleeping 3 sec... (3com fix)\n");=09
- sleep(3);
-#endif
-
-#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
- do_cmd_backup(con, SIG_CONREQ, 0, NULL, 0, 0, 0);
-#endif
- /* baseband is up, now initiate l2cap */
- l2cap_connect_req(con, con->psm);
+ l2ca_wakeup("lp_connect_cfm", con);
}
} else {
/* neg cfm */
D_STATE("lp_connect_cfm : (neg) %s\n",get_err_msg(status));
con->link_up =3D FALSE;
=20=09=09
- /* don't notify upper layers if cfm originated from a ping */
- if (con->ping_sent=3D=3D1) {
- /* Remove connection object */
- delete_con(con);
+ l2ca_wakeup("lp_connect_cfm (neg)", con);
+=09=09
+ if (con->c_flags & FLAG_RETURNNOW)
+ {
+ con->c_flags &=3D ~FLAG_RETURNNOW;
return;
}
=20
/* only notify upper layers if we are initiator */
if (con->initiator)
- l2ca_connect_cfm(con, MSGCODE(MSG_LAYER_HCI, status));
-
- DSYS("ACL link failed for some reason, remove con object\n");
- /* Always remove connection object */
- delete_con(con);
+ l2ca_connect_cfm(con, MSGCODE(MSG_LAYER_HCI,=20
+ status));
}
}
=20=20
@@ -1422,7 +1424,7 @@
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
/* cancel any outstanding timers */
disable_rtx(con);
- //disable_ertx(con);
+ disable_ertx(con);
#endif
=20
/* if not connected yet simply remove it */
@@ -1560,20 +1562,46 @@
con->link_up =3D 1;
ENTERSTATE(con, W4_L2CAP_CONNECT_RSP);
PRINTSTATE(con);
-#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
- do_cmd_backup(con, SIG_CONREQ, 0, NULL, 0, 0, 0);
-#endif
+
l2cap_connect_req(con, psm);
=20
return 0;
} else {
D_STATE("l2ca_connect_req : create new baseband link\n");
- /* create baseband connection, l2cap_connect_req is called=20
- from lp_connect_cfm */
- return lp_connect_req(con->remote_bd);=20=20
+ lp_connect_req(con->remote_bd);=20=20
+
+ /* wait here until we received a lp_connect_cfm */
+ l2ca_wait("l2ca_connect_req : wait baseband", con);
+=09=09
+ if (con->c_status !=3D RES_SUCCESS) {
+ D_ERR("l2cap_connect_req failed !\n");
+ delete_con(con);
+ return -1;
}
}
=20
+ /* Now send connect req */
+ con->c_status =3D CSTATUS_RTX_TIMEOUT;
+
+ /* Leave loop when either status failed or success */
+ while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT)
+ {
+ /* baseband is up, now initiate send connect req */
+ l2cap_connect_req(con, con->psm);
+
+ /* wait until we received a response or after timeout */
+
+#ifdef BTD_USERSTACK
+ printk("Sleeping 2 sec\n");=09
+ sleep(2);
+#else
+ l2ca_wait("l2cap_connect_req : wait rsp", con);
+#endif
+ }
+
+ return con->c_result;
+}
+
/* params determines how we would like to receive data */
s32=20
l2ca_config_req(l2cap_con *con, u16 in_mtu, flow *outflow,=20
@@ -1592,10 +1620,6 @@
if (con->current_state =3D=3D CONFIG) {=20=20
/* local mtu is set in l2cap_config_req */
=20
-#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
- do_cmd_backup(con, SIG_CONFREQ, in_mtu, outflow,=20
- flush_timeout, link_to, 0);
-#endif=09=09
return l2cap_config_req(con, in_mtu, outflow,=20
flush_timeout, link_to);=20=20
=20
@@ -1616,10 +1640,7 @@
=20
con->conf_req_ready =3D FALSE;
con->conf_rsp_ready =3D FALSE;
-#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS=09=09
- do_cmd_backup(con, SIG_CONFREQ, in_mtu, outflow,=20
- flush_timeout, link_to, 0);
-#endif
+
return l2cap_config_req(con, in_mtu, outflow,=20
flush_timeout, link_to);=20=20
return -1;
@@ -1644,9 +1665,6 @@
=20
if (con->current_state =3D=3D OPEN || con->current_state =3D=3D CONFIG) {
=20
-#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
- do_cmd_backup(con, SIG_DISCREQ, 0, NULL,0, 0, 0);
-#endif
result =3D l2cap_disconnect_req(con);
=20
ENTERSTATE(con, W4_L2CAP_DISCONNECT_RSP);
@@ -1655,10 +1673,11 @@
D_ERR("l2ca_disconnect_req : Invalid state !\n");
return -1;=20=20=20=20
}
-#ifdef __KERNEL__
- interruptible_sleep_on(&l2cap_disconnect_wq);
-#endif
- return result;
+=09
+ /* wait here until we get a confirm */
+ l2ca_wait("l2ca_disconnect_req", con);
+
+ return con->c_result;
}
=20
=20
@@ -1691,7 +1710,7 @@
PRINTSTATE(con);
}=20
else if (response =3D=3D RES_PENDING) {
- /* remain in */
+ /* remain in same state */
}
else if (response >=3D RES_PSMNEG) {
/* 'l2ca_connect_rsp_neg()' */
@@ -1704,13 +1723,11 @@
return result;
}
=20
-
-/* fixme -- use inparams... */
s32=20
-l2ca_config_rsp(l2cap_con* con, u32 out_mtu, flow *in_flow, s32 ok)
+l2ca_config_rsp(l2cap_con* con, u32 out_mtu, flow *in_flow, s32 result)
{
#define FNC "l2ca_config_rsp : "
- s32 result;
+ s32 ret_val =3D -1;
=20
if (PARANOIA_CHECKCON(con)) {
D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
@@ -1726,14 +1743,14 @@
return -1;
}
=20
- if (ok) {
+ if (result =3D=3D CONF_SUCCESS) {
/* upper layers responded OK */
con->conf_rsp_ready =3D TRUE;
=20
- result =3D l2cap_config_rsp(con, out_mtu, in_flow);
+ ret_val =3D l2cap_config_rsp(con, out_mtu, in_flow, result);
=20
/* check if we have sent a configure request yet */
- if (con->conf_req_ready) {
+ if (con->conf_req_ready && !con->remote_flags) {
/* all done, proceed to OPEN */
ENTERSTATE(con, OPEN);
PRINTSTATE(con);
@@ -1745,19 +1762,14 @@
l2ca_config_cfm(con, RES_SUCCESS);
=20
} else {
- DSYS(FNC"Not yet a pos rsp on config_req\n");
+ D_STATE(FNC"Conf not done or flags set\n");
}
} else {
- /* FIXME - send l2cap_config_rsp_neg */
- D_STATE(FNC"params not accepted by us (FIXME !!) !\n");
-=09=09
- /* add result parameter in l2cap_config_rsp (for neg rsp) */
-=09=09
- l2cap_config_rsp(con, out_mtu, in_flow);
- //l2ca_config_cfm(con, result);
- return -1;
+ D_STATE("We don't accepted remote options\n");
+ ret_val =3D l2cap_config_rsp(con, out_mtu, in_flow, result);
}
- return result;
+
+ return ret_val;
#undef FNC
}
=20
@@ -1809,10 +1821,114 @@
/* (E5) Timer events */
/********************/
=20
-/* FIXME !*/
-/* RTX */
-/* ERTX */
+#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
+
+void l2ca_timeoutind(l2cap_con *con)
+{
+ printk("l2ca_timeoutind\n");
+ con->c_status =3D CSTATUS_RTX_TIMEOUT;=09
+ l2ca_wakeup("l2ca_timeoutind ", con);
+}
+
+#ifdef __KERNEL__
+void
+l2cap_rtx_timeout(unsigned long ptr)
+{
+ l2cap_con *con =3D (l2cap_con*)ptr;
+#else /* usermode timer */
+void
+l2cap_rtx_timeout(void)
+{
+ l2cap_con *con =3D timeout_con;
+
+ if (timer_cancelled) {
+ D_TIM("RTX timer already cancelled\n");
+ return;
+ }
+#endif
+ /* do some paranoia checks */
+
+ if (PARANOIA_CHECKCON(con)) {
+ D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
+ return;
+ }
+
+ D_TIM("l2cap_rtx_timeout (current no rtx : %d)\n",=20
+ con->timer.rtx_no);
+=20=20=20=20=20=20
+ con->timer.rtx_inuse =3D 0;
+=20=20
+ if (con->timer.rtx_no =3D=3D MAX_NO_RTX)
+ {
+ con->c_status =3D CSTATUS_MAX_NO_RTX;
+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
+ D_TIM("Connection unresponsive\n");
+=09=09
+ show_con("Connection unresponsive\n", con);
+=09=09
+ con->c_result =3D MSGCODE(MSG_LAYER_L2CAP,=20
+ L2CAP_CON_UNRESPONSIVE);
+=09=09
+ l2ca_wakeup("rtx_timeout", con);
+
+ /* reset rtx counter */
+ con->timer.rtx_no =3D 0;
+
+ if (con->timer.rtx_action =3D=3D RTX_ACTION_START_ERTX) {
+ /* start ertx timer */
+ D_TIM("Starting ERTX\n");
+ start_ertx(con, ERTX_TIMEOUT);
+ }
+ else if (con->timer.rtx_action =3D=3D RTX_ACTION_TERMINATE){
+ D_TIM("Removing connection\n");
+ l2ca_disconnect_ind(con);
+ ENTERSTATE(con, CLOSED);
+ delete_con(con);
+ }
+ }
+ else
+ {=20=20
+ con->timer.rtx_no++;
+ l2ca_timeoutind(con);=09
+ }
+=09
+=09
+#ifndef __KERNEL__
+ timeout_con =3D NULL;
+#endif
+}
=20
+void
+l2cap_ertx_timeout(unsigned long ptr)
+{
+ l2cap_con *con;
+ D_TIM("l2cap_ertx_timeout\n");
+ con =3D (l2cap_con*)ptr;
+
+ /* do paranoia check */
+ if (PARANOIA_CHECKCON(con)) {
+ D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
+ return;
+ }
+
+ if (con->timer.ertx_action =3D=3D ERTX_ACTION_TERMINATE) {
+ D_TIM("Removing connection\n");
+ l2ca_disconnect_ind(con);
+ ENTERSTATE(con, CLOSED);
+ delete_con(con);
+ } else if (con->timer.ertx_action =3D=3D ERTX_ACTION_DISCONNECT) {
+=09=09
+ D_TIM("Disconnect connection\n");
+ /* set dont sleep flag so that we wont do sleep=20
+ when not running in usermode context */
+ con->c_flags |=3D FLAG_DONTSLEEP;
+ ENTERSTATE(con, CONFIG); /* CERT HACK ! */
+ l2ca_disconnect_req(con);
+ }
+}
+
+#endif /* CONFIG_BLUETOOTH_L2CAP_USE_TIMERS */
+
/*******************************************************************/
/*-------------------------- ACTIONS ------------------------------*/
/*******************************************************************/
@@ -1890,7 +2006,7 @@
=20=09
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
/* start retransmission timer */
- start_rtx(con, RTX_TIMEOUT);
+ start_rtx(con, RTX_TIMEOUT, RTX_ACTION_START_ERTX);
#endif
return hci_send_data(tx);
}
@@ -1951,14 +2067,13 @@
req =3D (sig_confreq*)(l2cap_buf->frame + L2CAP_HDRSIZE + SIGCMD_HDRSIZE);
=20=09
if (opt_len > 0) {
- printk("sending options...\n");
/* if the negotiated mtu differs from the current, send it */
=20=20=20=20=20=20=20=20=20=20=20
opt =3D (struct l2cap_option*)(l2cap_buf->frame+L2CAP_HDRSIZE +=20
SIGCMD_HDRSIZE + CONF_REQSIZE);
=20=20
if (in_mtu !=3D 0) {
- printk("sending in_mtu %d\n", in_mtu);
+ printk("Sending in_mtu %d\n", in_mtu);
opt->type =3D OPT_MTU;
opt->len =3D 2;
*(opt->option_data) =3D (u8)(in_mtu & 0x00ff);
@@ -1969,7 +2084,7 @@
}
=20=09=09
if (flush_timeout !=3D 0) {
- printk("sending flush_timeout %d\n", flush_timeout);
+ printk("Sending flush_timeout %d\n", flush_timeout);
opt->type =3D OPT_FLUSH;
opt->len =3D 2;
*(opt->option_data) =3D (u8)(flush_timeout & 0x00ff);
@@ -1980,7 +2095,7 @@
}
=20=09=09
if (outflow !=3D NULL){=20
- printk("sending conf req outflow %d\n", flush_timeout);
+ printk("Sending conf req outflow\n");
print_flow(outflow);
opt->type =3D OPT_QOS;
opt->len =3D sizeof(flow);
@@ -2011,7 +2126,7 @@
print_data("l2cap options : ", (char*)opt , opt_len);
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
/* start retransmission timer */
- start_rtx(con, RTX_TIMEOUT);
+ start_rtx(con, RTX_TIMEOUT, RTX_ACTION_START_ERTX);
#endif
return hci_send_data(tx);
}
@@ -2055,13 +2170,13 @@
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
/* start retransmission timer */
- start_rtx(con, RTX_TIMEOUT);
+ start_rtx(con, RTX_TIMEOUT, RTX_ACTION_TERMINATE);
#endif
return hci_send_data(tx);
}
=20
s32=20
-l2cap_echo_req(l2cap_con *con, u8 *opt_data, s32 opt_len)
+l2cap_echo_req(l2cap_con *con, u8 *opt_data, u16 opt_len)
{
bt_tx_buf *tx;=20
l2cap_tx_buf *l2cap_buf; /* Entire l2cap frame + lower layer hdrs */
@@ -2098,16 +2213,18 @@
/* pb_flag is set from hci_send_data */
tx->hci_hdl =3D hci_hdl;
tx->bc_flag =3D NO_BROADCAST;
- tx->cur_len =3D L2CAP_HDRSIZE + payload_len; /* Increased when lower
- layers add header data */
+
+ /* Increased when lower layers add header data */
+ tx->cur_len =3D L2CAP_HDRSIZE + payload_len;
+
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
- start_rtx(con, RTX_TIMEOUT);
+ start_rtx(con, RTX_TIMEOUT, RTX_ACTION_DISCONNECT);
#endif
return hci_send_data(tx);
}
=20
s32=20
-l2cap_echo_rsp(s32 hci_hdl, s32 id, u8 *opt_data, s32 opt_len)
+l2cap_echo_rsp(s32 hci_hdl, s32 id, u8 *opt_data, u16 opt_len)
{
bt_tx_buf *tx;=20
l2cap_tx_buf *l2cap_buf; /* Entire l2cap frame + lower layer hdrs */
@@ -2186,7 +2303,7 @@
tx->cur_len =3D L2CAP_HDRSIZE + payload_len; /* Increased when lower
layers add header data */
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
- start_rtx(con, RTX_TIMEOUT);
+ start_rtx(con, RTX_TIMEOUT, RTX_ACTION_TERMINATE);
#endif
return hci_send_data(tx);
}
@@ -2320,7 +2437,6 @@
if ((rsp->result =3D cpu_to_le16(response)) =3D=3D RES_PENDING)
rsp->status =3D cpu_to_le16(status);
else {
- printk("Result not pending, force status =3D no further info\n");
rsp->status =3D cpu_to_le16(STAT_NOINFO);
}
=20=09
@@ -2338,27 +2454,40 @@
return hci_send_data(tx);=20=20
}
=20=20
+
s32=20
-l2cap_config_rsp(l2cap_con* con, u32 out_mtu, flow *in_flow)
+l2cap_config_rsp(l2cap_con* con, u32 out_mtu, flow *in_flow, s32 result)
{
bt_tx_buf *tx;=20
l2cap_tx_buf *l2cap_buf; /* Entire l2cap frame + lower layer hdrs */
sig_cmd *cmd;
sig_confrsp *rsp;
u16 payload_len;
+ int opt_len =3D 0;
+ struct l2cap_option *opt;
=20
D_XMIT("l2cap_config_rsp : rcid : %d, out_mtu: %d \n",=20
con->remote_cid, out_mtu);
-#if 0
+
+ /* If negative, the accepted options are sent back */
if (result !=3D RES_SUCCESS) {
- /* FIXME -- send back negative response */
- DSYS("FIXME !!!!!!!!!!!!!!!!!!!!!!!! neg config rsp\n");
+
+ DSYS("Neg config rsp !\n");
+
+ if (out_mtu !=3D 0) {
+ con->remote_mtu =3D out_mtu;
+ opt_len+=3D4;
}
-#endif
+ if (in_flow !=3D NULL){
+ /* The accepted settings for incoming traffic */
+ opt_len +=3Dsizeof(flow);
+ }
+ }
=20
- payload_len =3D SIGCMD_HDRSIZE + CONF_RSPSIZE;
+ payload_len =3D SIGCMD_HDRSIZE + CONF_RSPSIZE + opt_len;
=20=20=20
- tx =3D subscribe_bt_buf(sizeof(l2cap_tx_buf) + L2CAP_HDRSIZE+payload_len);
+ tx =3D subscribe_bt_buf(sizeof(l2cap_tx_buf) +=20
+ L2CAP_HDRSIZE+payload_len);
if (!tx) {
D_ERR("l2cap_config_rsp : didn't get a valid tx buf\n");
return -1;
@@ -2367,29 +2496,57 @@
l2cap_buf =3D (l2cap_tx_buf *)(tx->data);
=20
cmd =3D (sig_cmd*)(l2cap_buf->frame + L2CAP_HDRSIZE);
- rsp =3D (sig_confrsp*)(l2cap_buf->frame + L2CAP_HDRSIZE + SIGCMD_HDRSIZE);
+ rsp =3D (sig_confrsp*)(l2cap_buf->frame + L2CAP_HDRSIZE +=20
+ SIGCMD_HDRSIZE);
=20=20=20
/* Now fill in header fields */=20=20
rsp->src_cid =3D cpu_to_le16(con->remote_cid);
+ rsp->flags =3D con->remote_flags;
+ rsp->result =3D cpu_to_le16((u16)result);
=20
- /* FIXME - WHERE ARE THIS DETERMINED ??? */
- rsp->flags =3D 0; /* No more config responses to follow */
+ /* Include unaccepted options if any */
+ if (opt_len)
+ {
+ opt =3D (struct l2cap_option*)(rsp + CONF_RSPSIZE);
=20
- rsp->result =3D cpu_to_le16(CONF_SUCCESS);
+ if (out_mtu !=3D 0) {
+ printk("Sending out_mtu %d\n", out_mtu);
+ opt->type =3D OPT_MTU;
+ opt->len =3D 2;
+ *(opt->option_data) =3D (u8)(out_mtu & 0x00ff);
+ *(opt->option_data+1) =3D (u8)(out_mtu>>8) & 0x00ff;
=20=20=20
+ /* forward pointer for other options */
+ opt =3D (struct l2cap_option*)((char *)opt + 4);
+ }
+=09=09
+ if (in_flow !=3D NULL){=20
+ printk("Sending conf req in_flow\n");
+ print_f...
[truncated message content] |
|
From: Mattias A. <mat...@us...> - 2001-03-31 16:36:00
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.95 1.96=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
don't do cfm to upper layers before setting c_result
The diff of the modified file(s):
--- l2cap.c 2001/03/30 11:59:20 1.95
+++ l2cap.c 2001/03/31 16:35:58 1.96
@@ -1176,8 +1176,8 @@
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
disable_rtx(con);
#endif
- l2ca_disconnect_cfm(con);
con->c_result =3D RES_SUCCESS;
+ l2ca_disconnect_cfm(con);
l2ca_wakeup("l2cap_disconnect_rsp", con);
break;
=20=20=20=20=20=20=20=20
|
|
From: Peter K. <pk...@us...> - 2001-04-11 11:16:31
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.97 1.98=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Do not dereference con if it is NULL in process_request()
(thanks to Eric Muehlhausen).
The diff of the modified file(s):
--- l2cap.c 2001/04/10 12:27:10 1.97
+++ l2cap.c 2001/04/11 11:16:30 1.98
@@ -696,7 +696,7 @@
if ((con =3D check_remote_cid(hci_handle,=20
conreq->src_cid)) =3D=3D NULL) {
D_ERR(FNC"couldn't find l2cap connection\n");
- l2cap_cmdrej(con->hci_hdl, CMDREJ_INVALIDCID,
+ l2cap_cmdrej(hci_handle, CMDREJ_INVALIDCID,
"Invalid CID", 13);
return;
}
@@ -740,7 +740,7 @@
if ((con =3D get_lcon(confreq->dst_cid)) =3D=3D NULL) {
D_ERR("Couldn't find local CID\n");
/* send back response ? */
- l2cap_cmdrej(con->hci_hdl, CMDREJ_INVALIDCID, NULL, 0);
+ l2cap_cmdrej(hci_handle, CMDREJ_INVALIDCID, NULL, 0);
return;
}
=20=09=09
@@ -1246,8 +1246,6 @@
}
=20
=20
-
-
/*******************************************************************/
/*-------------------------- EVENTS -------------------------------*/
/*******************************************************************/
@@ -1478,8 +1476,7 @@
if (len > (con->local_mtu)) {
DSYS("l2cap process_frame : len > local_mtu (%d/%d)\n",=20
len- L2CAP_HDRSIZE, con->local_mtu);
- l2cap_cmdrej(con->hci_hdl, CMDREJ_MTUEXCEEDED,
- NULL, 0);
+ l2cap_cmdrej(con->hci_hdl, CMDREJ_MTUEXCEEDED, NULL, 0);
return;
}=20
=20
|
|
From: Mattias A. <mat...@us...> - 2001-04-12 15:10:02
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.98 1.99=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* fixed return code when waking up wait queue (SIG_CONRSP)
* added conf_req_sent
* fixed auto shutdown of l2cap cons (currently not used)
* added l2ca_wait after l2cap_connect_req when baseband exists
* fixed bug when calculating new timer interval
* fixed usermode problems with timer
* cleanup & minor changes
The diff of the modified file(s):
--- l2cap.c 2001/04/11 11:16:30 1.98
+++ l2cap.c 2001/04/12 15:10:01 1.99
@@ -223,23 +223,23 @@
#define RTX_TIMEOUT 2 /* sec */
#define ERTX_TIMEOUT 60 /* sec */
=20
+
#ifdef __KERNEL__
-void start_rtx(l2cap_con *con, unsigned short timeout, unsigned short acti=
on);
-void disable_rtx(l2cap_con *con);
-void start_ertx(l2cap_con *con, unsigned short timeout);
-void disable_ertx(l2cap_con *con);
void l2cap_rtx_timeout(unsigned long ptr);
void l2cap_ertx_timeout(unsigned long ptr);
-
#else /* usermode stack */
-
l2cap_con *timeout_con =3D NULL;
s32 timer_cancelled =3D 0;
-void start_rtx(l2cap_con *con, s32 timeout, u16 action);
-void disable_rtx(l2cap_con *con);
void l2cap_rtx_timeout(void);
+void l2cap_ertx_timeout(unsigned long ptr);
#endif
=20
+void start_rtx(l2cap_con *con, unsigned short timeout, unsigned short acti=
on);
+void disable_rtx(l2cap_con *con);
+
+void start_ertx(l2cap_con *con, unsigned short timeout);
+void disable_ertx(l2cap_con *con);
+
#endif
=20
/****************** GLOBAL VARIABLE DECLARATION SECTION ******************=
***/
@@ -342,8 +342,6 @@
s32=20
l2cap_shutdown(void)
{
- //l2cap_con *con =3D get_first_con();
-=20=20
DSYS("Shutting down L2CAP\n");
if (!l2cap->initiated)
{
@@ -351,21 +349,25 @@
return -1;
}
=20=09
+/* experimental */
#if 0
- /* Notify upper users, don't have time for real disconnect... */
+ {=20=20
+ l2cap_con *con;
+ con =3D get_first_con();
while (con!=3D NULL) {
- l2ca_disconnect_ind(con);
- con =3D get_next_con(con);
+ if (l2ca_disconnect_req(con) !=3D 0)
+ break;
+ con =3D get_first_con();
}
+ }
#endif
- /* necessary ? */
+
free_list();
remove_all_upper();
=20
#ifdef __CRIS__
bt_connections =3D 0;
#endif
-
/*ALWAYS SUCCESS*/
return 0;
}
@@ -1003,7 +1005,9 @@
=20
switch (conrsp->result) {
case RES_SUCCESS:
- l2ca_wakeup("l2cap_connect_rsp", con);
+
+ con->c_result =3D RES_SUCCESS;
+ l2ca_wakeup("l2cap connect rsp", con);
ENTERSTATE(con, CONFIG);
PRINTSTATE(con);
l2ca_connect_cfm(con, conrsp->result);
@@ -1106,7 +1110,11 @@
/* notify upper layers that we successfully
opened a connection ! */
l2ca_config_cfm(con, confrsp->result);
- } return;
+
+ /* reset */
+ con->conf_req_sent =3D 0;
+ return;
+ }
=20=09=09=09
case CONF_FAILURE:
=20
@@ -1330,8 +1338,9 @@
l2cap_con *con;
D_STATE("lp_connect_cfm: %s (hci_handle : %d)\n",=20
get_err_msg(status), con_hdl);
- print_data("lp_connect_cfm BD", bd_addr, 6);
=20
+ D_STATE("lp_connect_cfm : bd %s\n", bd2str(bd_addr));
+
/* FIXME -- use bt session list to notify upper layers that=20
con failed !!! */
=20
@@ -1349,7 +1358,7 @@
con->link_up =3D TRUE;
=20
/* see if there is someone to wakeup */
- l2ca_wakeup("lp_connect_cfm", con);
+ l2ca_wakeup("lp_connect_cfm (pos)", con);
=20=09=09
if (con->c_flags & FLAG_RETURNNOW)
{
@@ -1496,7 +1505,7 @@
s32 i;
u8 rev_bd[6];
=20
- D_RCV("l2cap_connect_req\n");
+ D_RCV("l2ca_connect_req\n");
PRINTPKT("l2ca_connect_req : sent to bd ",bd, 6);
=20
/* Check bd_addr */
@@ -1562,6 +1571,9 @@
=20
l2cap_connect_req(con, psm);
=20
+ l2ca_wait("l2cap_connect_req : wait rsp", con);
+
+ /* fixme -- use con->c_status */
return 0;
} else {
D_STATE("l2ca_connect_req : create new baseband link\n");
@@ -1588,12 +1600,8 @@
=20
/* wait until we received a response or after timeout */
=20
-#ifdef BTD_USERSTACK
- printk("Sleeping 2 sec\n");=09
- sleep(2);
-#else
l2ca_wait("l2cap_connect_req : wait rsp", con);
-#endif
+
}
=20
return con->c_result;
@@ -1616,7 +1624,7 @@
=20
if (con->current_state =3D=3D CONFIG) {=20=20
/* local mtu is set in l2cap_config_req */
-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
+ con->conf_req_sent =3D 1;
return l2cap_config_req(con, in_mtu, outflow,=20
flush_timeout, link_to);=20=20
=20
@@ -1668,6 +1676,7 @@
PRINTSTATE(con);
} else {
D_ERR("l2ca_disconnect_req : Invalid state !\n");
+ PRINTSTATE(con);
return -1;=20=20=20=20
}
=20=09
@@ -1755,6 +1764,9 @@
con->local_cid, con->remote_cid,=20
psm2str(con->psm));
=20=09=09=09
+ /* reset */
+ con->conf_req_sent =3D 0;
+
/* notify upper layers that we are opened */
l2ca_config_cfm(con, RES_SUCCESS);
=20
@@ -1991,6 +2003,7 @@
=20=20=20
cmd->code =3D SIG_CONREQ;
cmd->id =3D set_id(con); /* Sets sig_id_sent in l2cap_con */
+
cmd->len =3D cpu_to_le16(CON_REQSIZE);
=20
SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
@@ -2602,6 +2615,7 @@
=20=09
if (PARANOIA_CHECKCON(con)) {
D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
+ tx->flushed =3D 1; /* flush this buffer */
return -1;
}
=20
@@ -2913,15 +2927,15 @@
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
=20
-#ifdef __KERNEL__
-
/* Action is used when the sending function doesn't want
to handle the action it self */
void
start_rtx(l2cap_con *con, unsigned short timeout, u16 action)
{
/* multiply by 2 each rtx */
- timeout *=3D (2<<(con->timer.rtx_no));
+
+ if (con->timer.rtx_no > 0)
+ timeout =3D timeout*(2<<(con->timer.rtx_no - 1));
=20
/* FIXME -- use flush timeout to calculate number of
retransmissions */
@@ -2935,6 +2949,7 @@
return;
}
=20=09
+#ifdef __KERNEL__=09
init_timer(&con->timer.rtx);
con->timer.rtx.function =3D l2cap_rtx_timeout;
con->timer.rtx.data =3D (unsigned long)con;
@@ -2942,20 +2957,13 @@
con->timer.rtx_inuse =3D 1;
con->timer.rtx_action =3D action;
add_timer(&con->timer.rtx);=20=20
-}
=20
-
-#else /* USERSTACK */
+#else /* Usermode stack */
=20
-/* FIXME -- Currently usermode stack and signal() doesn't work=20
- since we are using threads */
-void=20
-start_rtx(l2cap_con *con, s32 timeout)
-{
-#if 1
- printk("use NO timer...\n");
+ /* FIXME */
+ printk("Use NO timer in usermode stack yet...\n");
return;
-#else
+#if 0
struct itimerval t =3D {{0,0},{timeout, 0}};
=20
D_TIM("Starting RTX timer (%d sec)\n", timeout);
@@ -2972,9 +2980,10 @@
=20
timer_cancelled =3D 0;
#endif
-}
+
#endif /* __KERNEL__ */
=20
+}
=20
void
disable_rtx(l2cap_con *con)
@@ -2984,6 +2993,8 @@
if (con->timer.rtx_inuse) {
del_timer(&con->timer.rtx);
con->timer.rtx_inuse =3D 0;
+ con->timer.rtx_no =3D 0;
+ con->timer.rtx_action =3D RTX_ACTION_DISCONNECT;
}
else
D_TIM("RTX never started\n");
@@ -3005,12 +3016,17 @@
return;
}
=20
+#ifdef __KERNEL__
init_timer(&con->timer.ertx);
con->timer.ertx.function =3D l2cap_ertx_timeout;
con->timer.ertx.data =3D (unsigned long)con;
con->timer.ertx.expires =3D jiffies + timeout*HZ;
con->timer.ertx_inuse =3D 1;
add_timer(&con->timer.ertx);
+#else
+ /* fixme */
+ con->timer.ertx_inuse =3D 1;
+#endif
}
=20
void
@@ -3018,15 +3034,18 @@
{
D_TIM("Disabling ERTX timer\n");
#ifdef __KERNEL__
- if (con->timer.rtx_inuse){
+ if (con->timer.ertx_inuse){
del_timer(&con->timer.ertx);
- con->timer.rtx_inuse =3D 0;
+ con->timer.ertx_inuse =3D 0;
+ con->timer.ertx_action =3D ERTX_ACTION_DISCONNECT;
}
else
D_TIM("ERTX never started\n");
-#else
+#else /* Usermode stack */
/* FIXME */
printk("disable_ertx FIXME\n");
+ con->timer.ertx_inuse =3D 0;
+ con->timer.ertx_action =3D ERTX_ACTION_DISCONNECT;
#endif
}
#endif /* CONFIG_BLUETOOTH_L2CAP_USE_TIMERS */
@@ -3070,13 +3089,6 @@
con->remote_mtu =3D *(opt->option_data) |=20
(*(opt->option_data + 1) << 8);
=20
- if ((con->remote_mtu < MTU_MIN) &&=20
- ((con->remote_mtu + L2CAP_HDRSIZE) > HCI_IN_SIZE)) {
- D_WARN("Remote side tries to use nonvalid MTU [%d]\n",
- con->remote_mtu);
- return CONF_FAILURE;
- }
-=09=09=09=20=20=20=20
D_RCV("Setting remote mtu (%d:%d) to %d bytes\n",
con->local_cid, con->remote_cid,=20
con->remote_mtu);
@@ -3189,14 +3201,13 @@
return;
} else {
printk(" flow:\n");
- printk(" flags:%d service:%d token_rate:%d\n",
- f->flags, f->service, (int) f->token_rate);
+ printk(" flags:%d service: 0x%x token_rate: 0x%d\n",
+ f->flags, f->service, (unsigned int) f->token_rate);
printk(" bucket_size:%d bytes peak:%d bps latency:%d ms delay:%d ms\n",
- (int)f->bucket_size, (int)f->peak, (int)f->latency,=20
- (int)f->delay);
+ (unsigned int)f->bucket_size, (unsigned int)f->peak,=20
+ (unsigned int)f->latency, (unsigned int)f->delay);
}
}
-
/* Returns a free cid in range 0x0040 - 0xffff */
/* FIXME - search from MIN_CID every time ? */
u16 get_cid(void)
|
|
From: Peter K. <pk...@us...> - 2001-04-18 14:25:31
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.99 1.100=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Made local functions static.
* insert_upper() now returns -ENOMEM if memory allocation failed.
* Changed a number of "return -1;" to return something more appropriate.
* Replaced all FNC and function names in strings with __FUNCTION__.
The diff of the modified file(s):
--- l2cap.c 2001/04/12 15:10:01 1.99
+++ l2cap.c 2001/04/18 14:25:30 1.100
@@ -63,6 +63,7 @@
#include <string.h>
#include <sys/time.h>
#include <signal.h>
+#include <errno.h>
#include "include/l2cap.h"
#include "include/hci.h"
#include "include/l2cap_internal.h"
@@ -212,9 +213,9 @@
static void print_flow(flow *f);
static s32 l2cap_cmdrej(s32 hci_hdl, u8 reason, u8 *opt_data, s32 opt_len);
=20
-void insert_upper(protocol_layer *upper_layer);
-protocol_layer* get_upper(u32 psm);
-void remove_all_upper(void);
+static s32 insert_upper(protocol_layer *upper_layer);
+static protocol_layer* get_upper(u32 psm);
+static void remove_all_upper(void);
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
=20
@@ -225,20 +226,20 @@
=20
=20
#ifdef __KERNEL__
-void l2cap_rtx_timeout(unsigned long ptr);
-void l2cap_ertx_timeout(unsigned long ptr);
+static void l2cap_rtx_timeout(unsigned long ptr);
+static void l2cap_ertx_timeout(unsigned long ptr);
#else /* usermode stack */
-l2cap_con *timeout_con =3D NULL;
-s32 timer_cancelled =3D 0;
-void l2cap_rtx_timeout(void);
-void l2cap_ertx_timeout(unsigned long ptr);
+static l2cap_con *timeout_con =3D NULL;
+static s32 timer_cancelled =3D 0;
+static void l2cap_rtx_timeout(void);
+static void l2cap_ertx_timeout(unsigned long ptr);
#endif
=20
-void start_rtx(l2cap_con *con, unsigned short timeout, unsigned short acti=
on);
-void disable_rtx(l2cap_con *con);
+static void start_rtx(l2cap_con *con, unsigned short timeout, unsigned sho=
rt action);
+static void disable_rtx(l2cap_con *con);
=20
-void start_ertx(l2cap_con *con, unsigned short timeout);
-void disable_ertx(l2cap_con *con);
+static void start_ertx(l2cap_con *con, unsigned short timeout);
+static void disable_ertx(l2cap_con *con);
=20
#endif
=20
@@ -292,8 +293,7 @@
(l2cap->my_bd[2] =3D=3D 0) && (l2cap->my_bd[3] =3D=3D 0) &&
(l2cap->my_bd[4] =3D=3D 0) && (l2cap->my_bd[5] =3D=3D 0))
D_ERR("Failed to get local BD addr\n");
- else
- {
+ else {
i =3D l2cap_sprint_bd(bd_name, l2cap->my_bd);
bd_name[i] =3D 0;
DSYS("Local bd [%s]\n", bd_name);
@@ -336,15 +336,14 @@
void=20
l2cap_register_default_upper(struct protocol_layer *prot)
{
- memcpy(&default_protocol, prot, sizeof(protocol_layer));
+ memcpy(&default_protocol, prot, sizeof default_protocol);
}
=20
s32=20
l2cap_shutdown(void)
{
DSYS("Shutting down L2CAP\n");
- if (!l2cap->initiated)
- {
+ if (!l2cap->initiated) {
D_ERR("L2CAP not initiated\n");
return -1;
}
@@ -368,6 +367,7 @@
#ifdef __CRIS__
bt_connections =3D 0;
#endif
+
/*ALWAYS SUCCESS*/
return 0;
}
@@ -379,49 +379,44 @@
l2cap_register_upper(u16 psm, struct protocol_layer *prot)=20
{
if (((psm % 2) =3D=3D 0) || (prot =3D=3D NULL)) {
- D_ERR("l2cap_register_upper : incorrect parameters\n");
- return -1;
+ D_ERR(__FUNCTION__ ": incorrect parameters\n");
+ return -EINVAL;
}
=20=20=20=20=20
- D_MISC("l2cap_register_upper : psm 0x%x\n", psm);
+ D_MISC(__FUNCTION__ ": psm 0x%x\n", psm);
=20
if ((psm > MAX_PSM) && (psm < MIN_DYNAMIC_PSM)) {
- D_ERR("l2cap_register_upper : value of psm reserved\n");
- return -1;
+ D_ERR(__FUNCTION__ ": value of psm reserved\n");
+ return -EINVAL;
}
=20
if (psm > MAX_DYNAMIC_PSM) {
- D_ERR("l2cap_register_upper : psm not valid!\n");
- return -1;
+ D_ERR(__FUNCTION__ ": psm not valid!\n");
+ return -EINVAL;
}
=20
prot->psm =3D psm;
- insert_upper(prot);
- return 1;
+ return insert_upper(prot);
}
=20
/* Inserts the function pointers to a new upper layer in the list */
=20
-void
+s32
insert_upper(protocol_layer *upper_layer)
{
- protocol_layer *tmp_layer, *new_layer;
- D_MISC("insert_upper: Inserting layer psm:0x%x\n",upper_layer->psm);
+ protocol_layer *new_layer;
+ D_MISC(__FUNCTION__ ": Inserting layer psm:0x%x\n", upper_layer->psm);
=20=09
- new_layer =3D (protocol_layer*) kmalloc(sizeof(protocol_layer),
- GFP_ATOMIC);
- memcpy(new_layer, upper_layer, sizeof(protocol_layer));
- new_layer->next_layer =3D NULL;
+ if (!(new_layer =3D kmalloc(sizeof *new_layer, GFP_ATOMIC)))
+ return -ENOMEM;
=20=09
- tmp_layer =3D l2cap->upper_layers;
- if (tmp_layer !=3D NULL) {
- while (tmp_layer->next_layer !=3D NULL) {
- tmp_layer =3D tmp_layer->next_layer;
- }
- tmp_layer->next_layer =3D new_layer;
- } else {
+ memcpy(new_layer, upper_layer, sizeof *new_layer);
+
+ /* Add to head of list of upper layers */
+ new_layer->next_layer =3D l2cap->upper_layers;
l2cap->upper_layers =3D new_layer;
- }
+
+ return 0;
}
=20=20
protocol_layer*
@@ -431,29 +426,29 @@
=20=09
/* Check PSM value */
if((psm % 2) =3D=3D 0) {
- D_ERR("get_upper : incorrect psm\n");
+ D_ERR(__FUNCTION__ ": incorrect psm\n");
return &default_protocol;
}
if((psm > MAX_PSM) && (psm < MIN_DYNAMIC_PSM)) {
- D_ERR("get_upper : value of psm reserved\n");
+ D_ERR(__FUNCTION__ ": value of psm reserved\n");
return &default_protocol;
}
if(psm > MAX_DYNAMIC_PSM) {
- D_ERR("get_upper : psm not valid!\n");
+ D_ERR(__FUNCTION__ ": psm not valid!\n");
return &default_protocol;
}
=20
- D_MISC("get_upper: Try to retrieve psm 0x%x\n",psm);
+ D_MISC(__FUNCTION__ ": Try to retrieve psm 0x%x\n",psm);
tmp_layer =3D l2cap->upper_layers;
while (tmp_layer !=3D NULL) {
if (tmp_layer->psm =3D=3D psm) {
- D_MISC("get_upper: Actually got psm:0x%x\n",
+ D_MISC(__FUNCTION__ ": Actually got psm:0x%x\n",
tmp_layer->psm);
return tmp_layer;
}
tmp_layer =3D tmp_layer->next_layer;
}
- D_MISC("get_upper: Didn't get any layer, returning default\n");
+ D_MISC(__FUNCTION__ ": Didn't get any layer, returning default\n");
return &default_protocol;
}
=20
@@ -462,13 +457,12 @@
{
protocol_layer *tmp_layer;
=20
- D_MISC("remove_all_upper: Freeing all upper layers\n");
+ D_MISC(__FUNCTION__ ": Freeing all upper layers\n");
=20
while (l2cap->upper_layers !=3D NULL) {
tmp_layer =3D l2cap->upper_layers;
l2cap->upper_layers =3D tmp_layer->next_layer;
kfree(tmp_layer);
- tmp_layer =3D NULL;
}
}
=20
@@ -516,21 +510,20 @@
l2cap_receive_data(u8 *data, u32 len, u16 hci_handle, /*u8 pb_flag,*/=20=
=20
/*u8 bc_flag,*/ u32 *l2cap_len)
{
-#define FNC "l2cap_receive_data : "
l2cap_packet *pkt =3D NULL;
l2cap_con *con;
u16 pkt_len;
CID pkt_cid;
=20
- D_RCV(FNC" got %d bytes on hci_handle : %d\n", len, hci_handle);
- PRINTPKT("l2cap_receive_data : ", data, len);
+ D_RCV(__FUNCTION__ ": got %d bytes on hci_handle : %d\n", len, hci_handl=
e);
+ PRINTPKT(__FUNCTION__ ": ", data, len);
=20
if (*l2cap_len =3D=3D 0) {
/* Start of a new frame received,=20
parse header and set l2cap_len */
=20=09=09
if (len < 4) {
- D_RCV(FNC"Incomplete frame header!\n");
+ D_RCV(__FUNCTION__ ": Incomplete frame header!\n");
return;
}
=20
@@ -543,7 +536,7 @@
has been received in hci this function is called again */
*l2cap_len =3D pkt_len + L2CAP_HDRSIZE;
=20=20=20=20=20
- D_RCV(FNC"New frame len:%d cid:%d\n", pkt_len, pkt_cid);
+ D_RCV(__FUNCTION__ ": New frame len:%d cid:%d\n", pkt_len, pkt_cid);
=20
/* check length */
if (!(pkt_len =3D=3D (len - L2CAP_HDRSIZE)))
@@ -552,7 +545,7 @@
/* Not recieved full frame yet or BIG packet */
=20=09=09
if (len > *l2cap_len) {
- DSYS(FNC"BIG PACKET ! (%d bytes) discard\n", len);
+ DSYS(__FUNCTION__ ": BIG PACKET ! (%d bytes) discard\n", len);
hci_clear_buffer(hci_handle);
}
return;
@@ -566,7 +559,7 @@
switch (pkt_cid) {
case CIDSIG:
/* Signalling channel */
- D_RCV("l2cap_receive_data : Signal data !\n");
+ D_RCV(__FUNCTION__ ": Signal data !\n");
=20=09=09
signal_handler(hci_handle, data + L2CAP_HDRSIZE,=20
len-L2CAP_HDRSIZE);
@@ -578,7 +571,7 @@
return;
}
=20=09=09
- D_RCV("l2cap_receive_data: Connectionless data\n");
+ D_RCV(__FUNCTION__ ": Connectionless data\n");
=20
/* FIXME: Move data 2 bytes ahead since there is a psm value
in the connection less packet */
@@ -598,14 +591,13 @@
if (con->current_state =3D=3D OPEN ) {=20=20=20=20=20=20
process_frame(con, pkt->data, pkt_len);
} else {
- D_ERR("l2cap_receive_data : not OPEN yet, discard data\n");
+ D_ERR(__FUNCTION__ ": not OPEN yet, discard data\n");
}
break;
}
=20
/* free hci inbuffer */
hci_clear_buffer(hci_handle);=20
-#undef FNC
}
=20
/* Signalling between two l2cap entities on remote devices */
@@ -614,7 +606,6 @@
signal_handler(u16 hci_handle, u8 *data,=20
u32 len)
{
-#define FNC "signal_handler : "=20=20=20=20=20=20=20
sig_cmd *cmd;
s32 pos =3D 0; /* position in packet */
=20
@@ -622,20 +613,20 @@
=20=20=20
cmd->len =3D le16_to_cpu(cmd->len);
=20
- D_RCV(FNC"received %d bytes\n", len);
- PRINTPKT(FNC"data", data, len);
+ D_RCV(__FUNCTION__ ": received %d bytes\n", len);
+ PRINTPKT(__FUNCTION__ ": data", data, len);
=20
if (len < (cmd->len + 4)) {
- D_ERR(FNC"Length doesn't match\n");
+ D_ERR(__FUNCTION__ ": Length doesn't match\n");
return;=20
} else if (len > (cmd->len + 4)) {=20=20
- D_RCV(FNC"Multiple commands !\n");=20=20
+ D_RCV(__FUNCTION__ ": Multiple commands !\n");=20=20
} else {
- D_RCV(FNC"Single command\n");
+ D_RCV(__FUNCTION__ ": Single command\n");
}=20=20
=20
while (pos < len) {
- D_RCV(FNC"got packet (%d bytes) with ID : %d\n",
+ D_RCV(__FUNCTION__ ": got packet (%d bytes) with ID : %d\n",
cmd->len, cmd->id);
=20=20=20=20=20
if (ISREQUEST(cmd->code)) {=20
@@ -654,19 +645,16 @@
cmd->len);
}
}=20
-#undef FNC=09=09
}
=20
=20
void process_request(u16 hci_handle, struct sig_cmd *req)
{
-#define FNC "process_request : "
-=20
sig_conreq *conreq;
sig_confreq *confreq;
sig_discreq *discreq;
l2cap_con *con =3D NULL;
- D_STATE(FNC"Got request : 0x%x id:%d\n", req->code, req->id);
+ D_STATE(__FUNCTION__ ": Got request : 0x%x id:%d\n", req->code, req->id);
=20=09
/* FIXME -- Add check for cmd len in each request type=20
(used to detect corrupt packets) */
@@ -678,8 +666,8 @@
conreq->psm =3D le16_to_cpu(conreq->psm);
conreq->src_cid =3D le16_to_cpu(conreq->src_cid);
=20=09=09
- D_STATE(FNC"Connection request\n");
- D_STATE(FNC"id:%d len:%d PSM 0x%x src_cid:%d\n",
+ D_STATE(__FUNCTION__ ": Connection request\n");
+ D_STATE(__FUNCTION__ ": id:%d len:%d PSM 0x%x src_cid:%d\n",
req->id, req->len, conreq->psm, conreq->src_cid);
/*=20
Two cases :
@@ -697,15 +685,14 @@
=20=09=09
if ((con =3D check_remote_cid(hci_handle,=20
conreq->src_cid)) =3D=3D NULL) {
- D_ERR(FNC"couldn't find l2cap connection\n");
+ D_ERR(__FUNCTION__ ": couldn't find l2cap connection\n");
l2cap_cmdrej(hci_handle, CMDREJ_INVALIDCID,
"Invalid CID", 13);
return;
}
=20=09=09
if (PARANOIA_CHECKCON(con)) {
- D_ERR("%s l.%d NULL/magic failed\n",=20
- __FILE__, __LINE__);
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
return;
}
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
@@ -736,7 +723,7 @@
confreq->dst_cid =3D le16_to_cpu(confreq->dst_cid);
confreq->flags =3D le16_to_cpu(confreq->flags);
=20=09=09
- D_STATE(FNC"config request cid:%d flags: 0x%x\n",=20
+ D_STATE(__FUNCTION__ ": config request cid:%d flags: 0x%x\n",=20
confreq->dst_cid, confreq->flags);
=20=09=09
if ((con =3D get_lcon(confreq->dst_cid)) =3D=3D NULL) {
@@ -844,7 +831,7 @@
discreq->dst_cid =3D le16_to_cpu(discreq->dst_cid);
discreq->src_cid =3D le16_to_cpu(discreq->src_cid);
=20
- D_STATE(FNC"disconnection request id %d\n",=20
+ D_STATE(__FUNCTION__ ": disconnection request id %d\n",=20
req->id);
=20
if ((con =3D get_rcon(discreq->src_cid)) =3D=3D NULL) {
@@ -858,7 +845,7 @@
=20
/* if already closed, simply acknowledge */
if ((con->current_state =3D=3D CLOSED)) {
- D_STATE(FNC"connection closed, send disc rsp\n");
+ D_STATE(__FUNCTION__ ": connection closed, send disc rsp\n");
l2cap_disconnect_rsp(con);
return;
}
@@ -872,7 +859,7 @@
=20=20=20=20=20=20=20=20
case SIG_ECHOREQ: {
sig_echo_pkt* echo;
- D_STATE(FNC"Echo request\n");
+ D_STATE(__FUNCTION__ ": Echo request\n");
=20=09=09
echo =3D (sig_echo_pkt *)(req->data);=09=09
=20
@@ -884,7 +871,7 @@
case SIG_INFOREQ: {
/* Implementation specific */
sig_info_req *info;
- D_STATE(FNC"Info request\n");
+ D_STATE(__FUNCTION__ ": Info request\n");
=20=09=09
info =3D (sig_info_req*)(req->data);
info->type =3D le16_to_cpu(info->type);
@@ -907,22 +894,19 @@
}=20=20=20=20
=20=20=20=20=20=20=20=20
case SIG_RESERVED:
- D_STATE(FNC"Reserved !\n");
+ D_STATE(__FUNCTION__ ": Reserved!\n");
break;
=20=20=20=20=20=20=20=20=20
default:
/* Not a valid command */
- DSYS(FNC"Invalid command (code 0x%x)s\n", req->code);
+ DSYS(__FUNCTION__ ": Invalid command (code 0x%x)s\n", req->code);
l2cap_cmdrej(hci_handle, CMDREJ_NOTUNDERSTOOD, NULL, 0);
break;
}
-#undef FNC
}
=20
void process_response(u16 hci_handle, struct sig_cmd *rsp)
{
-#define FNC "process_response :"
-
sig_conrsp *conrsp;
sig_confrsp *confrsp;
sig_discrsp *discrsp;
@@ -933,7 +917,7 @@
s32 failure =3D 0;
u16 opt_len =3D 0;
=20
- D_STATE(FNC"Got response : 0x%x id:%d\n",=20
+ D_STATE(__FUNCTION__ ": Got response: 0x%x id:%d\n",
rsp->code, rsp->id);
=20
/* FIXME -- Add check for cmd len in each response type=20
@@ -941,31 +925,31 @@
=20
switch (rsp->code) {
case SIG_CMDREJECT:
- D_STATE(FNC"Command reject - \n");
+ D_STATE(__FUNCTION__ ": Command reject - \n");
DSYS("Got command reject\n");
cmdreject =3D (sig_cmdreject*)rsp->data;
cmdreject->reason =3D le16_to_cpu(cmdreject->reason);
opt_len =3D rsp->len - sizeof(sig_cmdreject);
switch (cmdreject->reason) {
case 0:
- D_STATE(FNC"Command not understood\n");=20
+ D_STATE(__FUNCTION__ ": Command not understood\n");=20
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case 1:
- D_STATE(FNC"Signalling MTU exceeded\n");
+ D_STATE(__FUNCTION__ ": Signalling MTU exceeded\n");
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case 2:
- D_STATE(FNC"Invalid CID in request\n");
+ D_STATE(__FUNCTION__ ": Invalid CID in request\n");
break;
=20=20=20=20=20=20=20=20=20=20=20=20
default:
- D_STATE(FNC"Not recognized cmd reject reason\n");
+ D_STATE(__FUNCTION__ ": Not recognized cmd reject reason\n");
break;
}
=20=09=09
if (opt_len > 0)
- print_data(FNC"optional data : ",=20
+ print_data(__FUNCTION__ ": optional data : ",=20
cmdreject->data, rsp->len-2);
=20
/* fixme -- set 'real' reason code */
@@ -980,7 +964,7 @@
=20=20=20=20=20=20=20=20
case SIG_CONRSP:
/* client */
- D_STATE(FNC"Got connection response\n");
+ D_STATE(__FUNCTION__ ": Got connection response\n");
conrsp =3D (sig_conrsp *)rsp->data;
conrsp->src_cid =3D le16_to_cpu(conrsp->src_cid);
conrsp->dst_cid =3D le16_to_cpu(conrsp->dst_cid);
@@ -989,7 +973,7 @@
=20
/* find connection */
if ((con =3D get_lcon(conrsp->src_cid)) =3D=3D NULL) {
- D_ERR(FNC"con rsp, NO CONNECTION FOUND\n");
+ D_ERR(__FUNCTION__ ": con rsp, NO CONNECTION FOUND\n");
return;
}
=20
@@ -997,7 +981,7 @@
=20
/* match id with request */
if (!id_matched(con, rsp->id)) {
- D_ERR(FNC"ID doesn't match ! [%d:%d]\n", con->sig_id_sent, rsp->id);
+ D_ERR(__FUNCTION__ ": ID doesn't match ! [%d:%d]\n", con->sig_id_sent, =
rsp->id);
return;
}
=20=20=20=20=20=20=20=20=20=20
@@ -1022,27 +1006,27 @@
disable_rtx(con);
start_ertx(con, ERTX_TIMEOUT);
#endif
- D_STATE(FNC"connection pending\n");
+ D_STATE(__FUNCTION__ ": connection pending\n");
break;
=20
case RES_PSMNEG:
- DSYS(FNC"connection refused, psm 0x%x not supp\n",=20
+ DSYS(__FUNCTION__ ": connection refused, psm 0x%x not supp\n",=20
con->psm);
failure =3D 1;
break;
=20
case RES_SECNEG:
- DSYS(FNC"connection refused, security block\n");
+ DSYS(__FUNCTION__ ": connection refused, security block\n");
failure =3D 1;
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case RES_NOSRC:
- DSYS(FNC"connection refused, no resources\n");
+ DSYS(__FUNCTION__ ": connection refused, no resources\n");
failure =3D 1;
break;
=20=20=20=20=20=20=20=20=20=20=20=20
default:
- D_ERR(FNC"SIG_CONRSP\n");
+ D_ERR(__FUNCTION__ ": SIG_CONRSP\n");
break;
}
=20=20=20=20=20=20=20=20=20=20
@@ -1063,28 +1047,28 @@
break;
=20=20=20=20=20=20=20=20
case SIG_CONFRSP:
- D_STATE(FNC"Got configuration response\n");
+ D_STATE(__FUNCTION__ ": Got configuration response\n");
confrsp =3D (sig_confrsp *)rsp->data;
confrsp->src_cid =3D le16_to_cpu(confrsp->src_cid);
confrsp->flags =3D le16_to_cpu(confrsp->flags);
confrsp->result =3D le16_to_cpu(confrsp->result);
opt_len =3D rsp->len - sizeof(sig_confrsp);
=20
- PRINTPKT(FNC"config response", rsp->data, rsp->len);
+ PRINTPKT(__FUNCTION__ ": config response", rsp->data, rsp->len);
=20
/* check that remote CID is in list */
if ((con =3D get_lcon(confrsp->src_cid)) =3D=3D NULL)
return;
=20
if (con->current_state !=3D CONFIG) {
- D_ERR(FNC"SIG_CONFRSP invalid state\n");
+ D_ERR(__FUNCTION__ ": SIG_CONFRSP invalid state\n");
PRINTSTATE(con);
return;=20
}
=20=09=09=09=20=20=20=20=20=20=20
/* match id with request */
if (!id_matched(con, rsp->id)) {
- D_ERR(FNC"ID doesn't match ! [%d:%d]\n", con->sig_id_sent, rsp->id);=09=
=09=09
+ D_ERR(__FUNCTION__ ": ID doesn't match ! [%d:%d]\n", con->sig_id_sent, =
rsp->id);=09=09=09
return;
}
=20
@@ -1121,22 +1105,22 @@
/* store remote side configuration */
parse_options(con, confrsp->options, opt_len);
=20
- D_STATE(FNC"config failure, unacceptable params\n");
+ D_STATE(__FUNCTION__ ": config failure, unacceptable params\n");
l2ca_config_cfm(con, confrsp->result);
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case CONF_REJ:
- D_STATE(FNC"connection refused, no reason\n");
+ D_STATE(__FUNCTION__ ": connection refused, no reason\n");
l2ca_config_cfm(con, confrsp->result);
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case CONF_UNKNOWN:
- D_STATE(FNC"connection refused, unknown options\n");
+ D_STATE(__FUNCTION__ ": connection refused, unknown options\n");
l2ca_config_cfm(con, confrsp->result);
break;
=20=20=20=20=20=20=20=20=20=20=20=20=20
default:
- D_ERR(FNC"SIG_CONFRSP\n");
+ D_ERR(__FUNCTION__ ": SIG_CONFRSP\n");
break;
}
=20=20=20=20=20=20
@@ -1147,7 +1131,7 @@
#endif
=20
if (con->current_state !=3D CONFIG)
- D_ERR(FNC"SIG_CONFRSP invalid state\n");
+ D_ERR(__FUNCTION__ ": SIG_CONFRSP invalid state\n");
PRINTSTATE(con);
=20
/* print failed options */
@@ -1158,25 +1142,25 @@
break;
=20=20=20=20=20=20=20=20=20
case SIG_DISCRSP:
- D_STATE(FNC"Got disconnect response\n");
+ D_STATE(__FUNCTION__ ": Got disconnect response\n");
discrsp =3D (sig_discrsp *)rsp->data;
discrsp->dst_cid =3D le16_to_cpu(discrsp->dst_cid);
discrsp->src_cid =3D le16_to_cpu(discrsp->src_cid);
- PRINTPKT(FNC"disconnect response", rsp->data, rsp->len);
+ PRINTPKT(__FUNCTION__ ": disconnect response", rsp->data, rsp->len);
=20
/* find connection */
if ((con =3D get_lcon(discrsp->src_cid)) =3D=3D NULL)
return;
=20=20=20=20=20=20=20=20=20=20
if (con->current_state !=3D W4_L2CAP_DISCONNECT_RSP) {
- D_ERR(FNC"SIG_DISCRSP invalid state\n");
+ D_ERR(__FUNCTION__ ": SIG_DISCRSP invalid state\n");
PRINTSTATE(con);
return;=20
}
=20=09=20=20=20=20=20=20=20=09=20=20=20=20=20=20=20
/* match id with request */
if (!id_matched(con, rsp->id)) {
- D_ERR(FNC"ID doesn't match ! [%d:%d]\n",=20
+ D_ERR(__FUNCTION__ ": ID doesn't match ! [%d:%d]\n",=20
con->sig_id_sent, rsp->id);
return;
}
@@ -1192,7 +1176,7 @@
case SIG_ECHORSP: {
l2cap_con *tempcon;
=20=09=09
- D_STATE(FNC"Got echo response\n");=09=09
+ D_STATE(__FUNCTION__ ": Got echo response\n");=09=09
=20
if ((tempcon =3D get_con_hcihdl(hci_handle))=3D=3DNULL) {
D_STATE("Echo rsp : could not find connection\n");
@@ -1203,7 +1187,7 @@
opt_len =3D rsp->len;
=20=09=09=09
if (opt_len > 0)
- PRINTPKT(FNC"optional data ",=20
+ PRINTPKT(__FUNCTION__ ": optional data ",=20
echo->data, rsp->len-sizeof(sig_echo_pkt));
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
@@ -1230,7 +1214,7 @@
info->type =3D le16_to_cpu(info->type);
info->result =3D le16_to_cpu(info->result);
=20=09=09
- D_STATE(FNC"Got info response : result %d\n", info->result);
+ D_STATE(__FUNCTION__ ": Got info response: result %d\n", info->result);
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
disable_rtx(tempcon);
@@ -1245,12 +1229,10 @@
=20=09
default:
/* Not a valid command */
- DSYS(FNC"Invalid command 0x%x\n", rsp->code);
+ DSYS(__FUNCTION__ ": Invalid command 0x%x\n", rsp->code);
l2cap_cmdrej(hci_handle, CMDREJ_NOTUNDERSTOOD, NULL, 0);
break;
}
-=09
-#undef FNC
}
=20
=20
@@ -1278,12 +1260,12 @@
void=20
lp_connect_ind(BD_ADDR bd_addr)
{
- PRINTPKT("lp_connect_ind from :",bd_addr, 6);
+ PRINTPKT(__FUNCTION__ ": from: ", bd_addr, 6);
=20
/* Check BD_ADDR */
if ((bd_addr[0]=3D=3D0) && (bd_addr[1]=3D=3D0) && (bd_addr[2]=3D=
=3D0) &&
(bd_addr[3]=3D=3D0) && (bd_addr[4]=3D=3D0) && (bd_addr[5]=3D=
=3D0)) {
- D_ERR("lp_connect_ind : no BD addr\n");
+ D_ERR(__FUNCTION__ ": no BD addr\n");
return;
}
=20=20
@@ -1292,7 +1274,7 @@
/* We are server and creates an l2cap connection object=20
which we set hci handle when we received lp_connect_cfm */
=20=20=20
- D_CON("lp_connect_ind: Accepting connection\n");
+ D_CON(__FUNCTION__ ": Accepting connection\n");
l2cap_create_con(bd_addr);
lp_connect_rsp(bd_addr,1);
}
@@ -1302,8 +1284,8 @@
l2cap_create_con(BD_ADDR bd)
{
l2cap_con *con;
- D_RCV("l2cap_create_con\n");=09
- PRINTPKT("l2cap_create_con : bd ", bd, 6);
+ D_RCV(__FUNCTION__ "\n");=09
+ PRINTPKT(__FUNCTION__ ": bd ", bd, 6);
=20
/* create a new l2cap connection obj and insert it in list */
=20
@@ -1314,7 +1296,7 @@
=20=09
/* Check connection */
if (con =3D=3D NULL) {
- D_ERR("l2cap_create_con : no connection created");
+ D_ERR(__FUNCTION__ ": no connection created");
return;
}
=20=20=20=20=20=20=20=20=20
@@ -1336,17 +1318,17 @@
lp_connect_cfm(u8 *bd_addr, u32 status, u16 con_hdl)
{
l2cap_con *con;
- D_STATE("lp_connect_cfm: %s (hci_handle : %d)\n",=20
+ D_STATE(__FUNCTION__ ": %s (hci_handle : %d)\n",=20
get_err_msg(status), con_hdl);
=20
- D_STATE("lp_connect_cfm : bd %s\n", bd2str(bd_addr));
+ D_STATE(__FUNCTION__ ": bd %s\n", bd2str(bd_addr));
=20
/* FIXME -- use bt session list to notify upper layers that=20
con failed !!! */
=20
/* search for the corresponding l2cap connection */
if ((con =3D get_con(bd_addr, CLOSED)) =3D=3D NULL) {
- D_ERR("lp_connect_cfm : couldn't find l2cap con!\n");
+ D_ERR(__FUNCTION__ ": couldn't find l2cap con!\n");
return;
}
=20
@@ -1360,8 +1342,7 @@
/* see if there is someone to wakeup */
l2ca_wakeup("lp_connect_cfm (pos)", con);
=20=09=09
- if (con->c_flags & FLAG_RETURNNOW)
- {
+ if (con->c_flags & FLAG_RETURNNOW) {
printk("Return NOW\n");
/* clear flag & set status */
con->c_flags &=3D ~FLAG_RETURNNOW;
@@ -1376,23 +1357,22 @@
/* now wait for a connection request */
} else {
D_STATE("We are client\n");
- PRINTPKT("lp_connect_cfm : HCI connected to ",=20
+ PRINTPKT(__FUNCTION__ ": HCI connected to ",=20
bd_addr,6);
=20=20=20=20=20=20=20
ENTERSTATE(con, W4_L2CAP_CONNECT_RSP);
PRINTSTATE(con);
=20=09=09=09
- l2ca_wakeup("lp_connect_cfm", con);
+ l2ca_wakeup(__FUNCTION__, con);
}
} else {
/* neg cfm */
- D_STATE("lp_connect_cfm : (neg) %s\n",get_err_msg(status));
+ D_STATE(__FUNCTION__ ": (neg) %s\n",get_err_msg(status));
con->link_up =3D FALSE;
=20
- l2ca_wakeup("lp_connect_cfm (neg)", con);
+ l2ca_wakeup(__FUNCTION__ " (neg)", con);
=20=09=09
- if (con->c_flags & FLAG_RETURNNOW)
- {
+ if (con->c_flags & FLAG_RETURNNOW) {
con->c_flags &=3D ~FLAG_RETURNNOW;
return;
}
@@ -1448,7 +1428,7 @@
}
}
=20=20=20=20
- D_CON("lp_disconnect_ind : no more l2cap cons on this handle\n");
+ D_CON(__FUNCTION__ ": no more l2cap cons on this handle\n");
=20
/* flush old buffers waiting to be sent on this handle */
btmem_flushhandle((u16)con_hdl);
@@ -1480,11 +1460,11 @@
void=20
process_frame(l2cap_con *con, u8 *data, u32 len)
{=20=20
- PRINTPKT("process_frame : ", data, len);
+ PRINTPKT(__FUNCTION__ ": ", data, len);
=20
if (len > (con->local_mtu)) {
- DSYS("l2cap process_frame : len > local_mtu (%d/%d)\n",=20
- len- L2CAP_HDRSIZE, con->local_mtu);
+ DSYS("l2cap process_frame : len > local_mtu (%ld/%d)\n",=20
+ (long)(len - L2CAP_HDRSIZE), con->local_mtu);
l2cap_cmdrej(con->hci_hdl, CMDREJ_MTUEXCEEDED, NULL, 0);
return;
}=20
@@ -1505,28 +1485,28 @@
s32 i;
u8 rev_bd[6];
=20
- D_RCV("l2ca_connect_req\n");
- PRINTPKT("l2ca_connect_req : sent to bd ",bd, 6);
+ D_RCV(__FUNCTION__ "\n");
+ PRINTPKT(__FUNCTION__ ": sent to bd ",bd, 6);
=20
/* Check bd_addr */
if ((bd[0]=3D=3D0) && (bd[1]=3D=3D0) && (bd[2]=3D=3D0) && (bd[3]=3D=3D0) =
&&
(bd[4]=3D=3D0) && (bd[5]=3D=3D0)) {
- D_ERR("l2ca_connect req : No BD-addr\n");
- return -1;
+ D_ERR(__FUNCTION__ ": No BD-addr\n");
+ return -EINVAL;
}
=20
/* Check PSM */
if ((psm % 2) =3D=3D 0) {
- D_ERR("l2ca_connect_req : incorrect PSM value\n");
- return -1;
+ D_ERR(__FUNCTION__ ": incorrect PSM value\n");
+ return -EINVAL;
}
if ((psm > MAX_PSM) && (psm < MIN_DYNAMIC_PSM)) {
- D_ERR("l2ca_connect_req : value of PSM preserved\n");
- return -1;
+ D_ERR(__FUNCTION__ ": value of PSM preserved\n");
+ return -EINVAL;
}
if (psm > MAX_DYNAMIC_PSM) {
- D_ERR("l2ca_connect_req : PSM value not valid\n");
- return -1;
+ D_ERR(__FUNCTION__ ": PSM value not valid\n");
+ return -EINVAL;
}
=20=09
/* bd is big endian, reverse byte order to little endian */
@@ -1540,8 +1520,8 @@
con =3D create_con(0/* not yet set */, get_cid(), 0/* not yet set */);
/* Check connection */
if (con =3D=3D NULL) {
- D_ERR("l2ca_connect_req : no connection created\n");
- return -1;
+ D_ERR(__FUNCTION__ ": no connection created\n");
+ return -ENOMEM;
}
=20
memcpy(con->remote_bd, rev_bd, 6);
@@ -1563,7 +1543,7 @@
=20
/* if this physical bd link exist for another l2cap con, use that!*/
if (tmpcon) {
- D_STATE("l2ca_connect_req : hci handle already exist.\n");
+ D_STATE(__FUNCTION__ ": hci handle already exist.\n");
con->hci_hdl =3D tmpcon->hci_hdl;
con->link_up =3D 1;
ENTERSTATE(con, W4_L2CAP_CONNECT_RSP);
@@ -1571,19 +1551,19 @@
=20
l2cap_connect_req(con, psm);
=20
- l2ca_wait("l2cap_connect_req : wait rsp", con);
+ l2ca_wait(__FUNCTION__ ": wait rsp", con);
=20
/* fixme -- use con->c_status */
return 0;
} else {
- D_STATE("l2ca_connect_req : create new baseband link\n");
+ D_STATE(__FUNCTION__ ": create new baseband link\n");
lp_connect_req(con->remote_bd);=20=20
=20
/* wait here until we received a lp_connect_cfm */
- l2ca_wait("l2ca_connect_req : wait baseband", con);
+ l2ca_wait(__FUNCTION__ ": wait baseband", con);
=20=09=09
if (con->c_status !=3D RES_SUCCESS) {
- D_ERR("l2cap_connect_req failed !\n");
+ D_ERR(__FUNCTION__ ": failed !\n");
delete_con(con);
return -1;
}
@@ -1593,15 +1573,13 @@
con->c_status =3D CSTATUS_RTX_TIMEOUT;
=20
/* Leave loop when either status failed or success */
- while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT)
- {
+ while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT) {
/* baseband is up, now initiate send connect req */
l2cap_connect_req(con, con->psm);
=20
/* wait until we received a response or after timeout */
=20
- l2ca_wait("l2cap_connect_req : wait rsp", con);
-
+ l2ca_wait(__FUNCTION__ ": wait rsp", con);
}
=20
return con->c_result;
@@ -1613,8 +1591,8 @@
u16 flush_timeout, u16 link_to)
{=20=20
if (PARANOIA_CHECKCON(con)) {
- D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
- return -1;
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
+ return -EINVAL;
}
=20
D_STATE("l2ca_config_req remote cid %d, in_mtu %d\n",=20
@@ -1648,9 +1626,8 @@
=20
return l2cap_config_req(con, in_mtu, outflow,=20
flush_timeout, link_to);=20=20
- return -1;
} else {
- D_ERR("l2cap_config_req : invalid state\n");
+ D_ERR(__FUNCTION__ ": invalid state\n");
PRINTSTATE(con);
return -1;
}
@@ -1662,11 +1639,11 @@
s32 result =3D -1;
=20
if (PARANOIA_CHECKCON(con)) {
- D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
- return -1;
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
+ return -EINVAL;
}
=20
- D_STATE("l2ca_disconnect_req remote cid : %d\n", con->remote_cid);
+ D_STATE(__FUNCTION__ ": remote cid : %d\n", con->remote_cid);
=20
if (con->current_state =3D=3D OPEN || con->current_state =3D=3D CONFIG) {
=20
@@ -1675,13 +1652,13 @@
ENTERSTATE(con, W4_L2CAP_DISCONNECT_RSP);
PRINTSTATE(con);
} else {
- D_ERR("l2ca_disconnect_req : Invalid state !\n");
+ D_ERR(__FUNCTION__ ": Invalid state!\n");
PRINTSTATE(con);
return -1;=20=20=20=20
}
=20=09
/* wait here until we get a confirm */
- l2ca_wait("l2ca_disconnect_req", con);
+ l2ca_wait(__FUNCTION__, con);
=20
return con->c_result;
}
@@ -1694,17 +1671,17 @@
{
s32 result;
=20
- D_STATE("l2ca_connect_rsp\n");
+ D_STATE(__FUNCTION__ "\n");
=20
if (PARANOIA_CHECKCON(con)) {
- D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
- return -1;
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
+ return -EINVAL;
}
=20
/* optionally send l2cap_connect_rsp_pnd() */=20=20
=20
...
[truncated message content] |
|
From: Gordon M. <gm...@us...> - 2001-04-19 14:37:56
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.101 1.102=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
--Checked in a temporary fix to the null pointer dereference in process_req=
uest. Eric Muehlhausen pointed this bug out. Mattias Agren said he'd check =
in a permanent fix when he brings in some other changes.
The diff of the modified file(s):
--- l2cap.c 2001/04/19 10:31:34 1.101
+++ l2cap.c 2001/04/19 14:37:33 1.102
@@ -952,6 +952,22 @@
print_data(__FUNCTION__ ": optional data : ",=20
cmdreject->data, rsp->len-2);
=20
+ /* Find connection -- note that I'm not sure this is the right thing
+ to do here. I just wanted to make sure we don't try to dereference
+ a null 'con' pointer like we used to do. Mattias Agren promised
+ to check in a real fix when he brings some other changes in.
+ --gmcnutt (4/19/01)
+ */
+ if ((conrsp =3D (sig_conrsp *)rsp->data) =3D=3D NULL) {
+ D_ERR(__FUNCTION__ ": no response data\n");
+ return;
+ }
+
+ if ((con =3D get_lcon(conrsp->src_cid)) =3D=3D NULL) {
+ D_ERR(__FUNCTION__ ": no connection\n");
+ return;
+ }
+
/* fixme -- set 'real' reason code */
con->c_status =3D CSTATUS_CMDREJECT;
=20=09=09
|
|
From: Gordon M. <gm...@us...> - 2001-04-20 17:19:07
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.102 1.103=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
--Mattias Agren's REAL fix for the NULL pointer dereference in process_event
The diff of the modified file(s):
--- l2cap.c 2001/04/19 14:37:33 1.102
+++ l2cap.c 2001/04/20 17:19:06 1.103
@@ -932,19 +932,20 @@
opt_len =3D rsp->len - sizeof(sig_cmdreject);
switch (cmdreject->reason) {
case 0:
- D_STATE(__FUNCTION__ ": Command not understood\n");=20
+ D_ERR(__FUNCTION__ ": Command not understood\n");=20
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case 1:
- D_STATE(__FUNCTION__ ": Signalling MTU exceeded\n");
+ D_ERR(__FUNCTION__ ": Signalling MTU exceeded\n");
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case 2:
- D_STATE(__FUNCTION__ ": Invalid CID in request\n");
+ D_ERR(__FUNCTION__ ": Invalid CID in request\n");
break;
=20=20=20=20=20=20=20=20=20=20=20=20
default:
- D_STATE(__FUNCTION__ ": Not recognized cmd reject reason\n");
+ D_ERR(__FUNCTION__ ": Unrecognized cmd reject "\
+ "reason\n");
break;
}
=20=09=09
@@ -952,22 +953,14 @@
print_data(__FUNCTION__ ": optional data : ",=20
cmdreject->data, rsp->len-2);
=20
- /* Find connection -- note that I'm not sure this is the right thing
- to do here. I just wanted to make sure we don't try to dereference
- a null 'con' pointer like we used to do. Mattias Agren promised
- to check in a real fix when he brings some other changes in.
- --gmcnutt (4/19/01)
- */
- if ((conrsp =3D (sig_conrsp *)rsp->data) =3D=3D NULL) {
- D_ERR(__FUNCTION__ ": no response data\n");
- return;
- }
+ /* find connection object using id field */
=20
- if ((con =3D get_lcon(conrsp->src_cid)) =3D=3D NULL) {
- D_ERR(__FUNCTION__ ": no connection\n");
- return;
- }
+ con =3D get_first_con();
+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
+ while (con && (con->sig_id_sent !=3D rsp->id))
+ con =3D get_next_con(con);
=20
+ if (con) {=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20
/* fixme -- set 'real' reason code */
con->c_status =3D CSTATUS_CMDREJECT;
=20=09=09
@@ -976,6 +969,9 @@
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS=09=09
disable_rtx(con);
#endif
+ } else
+ D_ERR(__FUNCTION__ ": Could not find an l2cap "\
+ "connection for this ID\n");
break;
=20=20=20=20=20=20=20=20
case SIG_CONRSP:
|
|
From: Peter K. <pk...@us...> - 2001-04-20 17:52:09
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- l2cap.c 1.103 1.104=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Indentation fix. |
|
From: Mattias A. <mat...@us...> - 2001-04-25 16:58:25
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.104 1.105=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* add deletion of failed l2cap con in lp_connect_cfm if non-initiator
* added ifdefs around disable_rtx
* l2ca_disconnect_req is now responsible of deleting disconnected l2cap=20
cons and shutting down baseband if nbr of l2cap cons are 0 on this handle.
(Used to be done in l2ca_connect_cfm)
* don't increment ID if retransmission
* cleanup & minor changes
The diff of the modified file(s):
--- l2cap.c 2001/04/20 17:52:08 1.104
+++ l2cap.c 2001/04/25 16:58:24 1.105
@@ -292,7 +292,7 @@
if ((l2cap->my_bd[0] =3D=3D 0) && (l2cap->my_bd[1] =3D=3D 0) &&=20
(l2cap->my_bd[2] =3D=3D 0) && (l2cap->my_bd[3] =3D=3D 0) &&
(l2cap->my_bd[4] =3D=3D 0) && (l2cap->my_bd[5] =3D=3D 0))
- D_ERR("Failed to get local BD addr\n");
+ D_ERR(__FUNCTION__ ": Failed to get local BD addr\n");
else {
i =3D l2cap_sprint_bd(bd_name, l2cap->my_bd);
bd_name[i] =3D 0;
@@ -344,11 +344,11 @@
{
DSYS("Shutting down L2CAP\n");
if (!l2cap->initiated) {
- D_ERR("L2CAP not initiated\n");
+ D_ERR(__FUNCTION__ ": L2CAP not initiated\n");
return -1;
}
=20
-/* experimental */
+ /* fixme -- experimental */
#if 0
{
l2cap_con *con;
@@ -727,7 +727,7 @@
confreq->dst_cid, confreq->flags);
=20=09=09
if ((con =3D get_lcon(confreq->dst_cid)) =3D=3D NULL) {
- D_ERR("Couldn't find local CID\n");
+ D_ERR(__FUNCTION__ ": Couldn't find local CID\n");
/* send back response ? */
l2cap_cmdrej(hci_handle, CMDREJ_INVALIDCID, NULL, 0);
return;
@@ -758,7 +758,7 @@
/* send back negative response */
if (l2ca_config_rsp(con, result, STAT_NOINFO,=20
CONF_FAILURE) < 0) {
- D_ERR("Couldn't send conf rsp\n");
+ D_ERR(__FUNCTION__ ": Couldn't send conf rsp\n");
}
return;
}
@@ -777,7 +777,7 @@
convenient point=20
*/
=20=09=09=09
- D_STATE("Got conf req in OPEN, renegotiate !\n");
+ D_STATE(__FUNCTION__ "Got conf req in OPEN, renegotiate !\n");
=20
ENTERSTATE(con, CONFIG);
PRINTSTATE(con);
@@ -786,7 +786,7 @@
result =3D parse_options(con, confreq->options,
req->len-4);
} else {
- D_ERR("Remote peer tried to renegotiate but cinf req contained no opti=
ons !\n");
+ D_ERR(__FUNCTION__": Remote peer tried to renegotiate but cinf req con=
tained no options !\n");
return;
}
=20=09=09=09
@@ -801,7 +801,7 @@
if (l2ca_config_rsp(con, result,=20
STAT_NOINFO,=20
CONF_FAILURE) < 0) {
- D_ERR("Couldnt send conf rsp\n");
+ D_ERR(__FUNCTION__": Couldnt send conf rsp\n");
}
return;
}
@@ -819,7 +819,7 @@
}
=20=20=20=20=20=20=20=20=20=20=20=20
default:
- D_ERR("Got config req in invalid state! [%s]\n",
+ D_ERR(__FUNCTION__": Got config req in invalid state! [%s]\n",
state_name[con->current_state]);
PRINTSTATE(con);
break;
@@ -885,7 +885,7 @@
break;
=20
default:
- D_ERR("Unknown info request: type 0x%x\n", info->type);
+ D_ERR(__FUNCTION__ ": Unknown info request: type 0x%x\n", info->type);
l2cap_cmdrej(hci_handle, CMDREJ_NOTUNDERSTOOD,
NULL, 0);
break;=09=09
@@ -1003,7 +1003,11 @@
case RES_SUCCESS:
=20
con->c_result =3D RES_SUCCESS;
- l2ca_wakeup("l2cap connect rsp", con);
+ l2ca_wakeup("l2cap con rsp", con);
+
+#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
+ disable_rtx(con);
+#endif
ENTERSTATE(con, CONFIG);
PRINTSTATE(con);
l2ca_connect_cfm(con, conrsp->result);
@@ -1094,7 +1098,7 @@
=20
if (!con->conf_rsp_ready) {
/* Upper layers still haven't replied pos */
- D_STATE("Still haven't replied pos on other sides conf req\n");
+ D_STATE(__FUNCTION__": Still haven't replied pos on other sides conf r=
eq\n");
return ;
} else {=09=09=09=09
ENTERSTATE(con, OPEN);
@@ -1107,7 +1111,7 @@
opened a connection ! */
l2ca_config_cfm(con, confrsp->result);
=20
- /* reset */
+ /* reset variable */
con->conf_req_sent =3D 0;
return;
}
@@ -1182,7 +1186,7 @@
#endif
con->c_result =3D RES_SUCCESS;
l2ca_disconnect_cfm(con);
- l2ca_wakeup("l2cap_disconnect_rsp", con);
+ l2ca_wakeup("l2cap disc rsp", con);
break;
=20=20=20=20=20=20=20=20
case SIG_ECHORSP: {
@@ -1191,7 +1195,7 @@
D_STATE(__FUNCTION__ ": Got echo response\n");=09=09
=20
if ((tempcon =3D get_con_hcihdl(hci_handle))=3D=3DNULL) {
- D_STATE("Echo rsp: could not find connection\n");
+ D_STATE(__FUNCTION__": Echo rsp, could not find connection\n");
return;
}
=20=09=09
@@ -1218,7 +1222,7 @@
l2cap_con *tempcon;
=20
if ((tempcon =3D get_con_hcihdl(hci_handle))=3D=3DNULL) {
- D_STATE("Echo rsp: could not find connection\n");
+ D_STATE(__FUNCTION__": Echo rsp, could not find connection\n");
return;
}
=20
@@ -1330,11 +1334,18 @@
lp_connect_cfm(u8 *bd_addr, u32 status, u16 con_hdl)
{
l2cap_con *con;
+ u8 rev_bd[6];
+=09
D_STATE(__FUNCTION__ ": %s (hci_handle : %d)\n",=20
get_err_msg(status), con_hdl);
=20
- D_STATE(__FUNCTION__ ": bd %s\n", bd2str(bd_addr));
+ /* reverse byte order */
+ for (i =3D 0; i < 6; i++) {
+ rev_bd[5-i] =3D bd_addr[i];
+ }
=20
+ D_STATE(__FUNCTION__ ": bd %s\n", bd2str(rev_bd));
+
/* FIXME -- use bt session list to notify upper layers that=20
con failed !!! */
=20
@@ -1355,7 +1366,7 @@
l2ca_wakeup("lp_connect_cfm (pos)", con);
=20=09=09
if (con->c_flags & FLAG_RETURNNOW) {
- printk("Return NOW\n");
+ D_STATE(__FUNCTION__" Return NOW\n");
/* clear flag & set status */
con->c_flags &=3D ~FLAG_RETURNNOW;
return;
@@ -1389,10 +1400,15 @@
return;
}
=20
+ if (con->initiator) {
/* only notify upper layers if we are initiator */
- if (con->initiator)
l2ca_connect_cfm(con, MSGCODE(MSG_LAYER_HCI,=20
status));
+ } else {
+ /* delete connection if non-initiator */
+ delete_con(con);
+ }=20
+=09=09
}
}
=20=20
@@ -1444,7 +1460,6 @@
=20
/* flush old buffers waiting to be sent on this handle */
btmem_flushhandle((u16)con_hdl);
- //btmem_reset();
=20
#ifdef __CRIS__
if (bt_connections > 0)
@@ -1590,7 +1605,6 @@
l2cap_connect_req(con, con->psm);
=20
/* wait until we received a response or after timeout */
-
l2ca_wait(__FUNCTION__ ": wait rsp", con);
}
=20
@@ -1614,7 +1628,9 @@
=20
if (con->current_state =3D=3D CONFIG) {=20=20
/* local mtu is set in l2cap_config_req */
+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
con->conf_req_sent =3D 1;
+
return l2cap_config_req(con, in_mtu, outflow,=20
flush_timeout, link_to);=20=20
=20
@@ -1622,7 +1638,7 @@
l2ca_config_cfm(con, CONF_REJ);
return -1;
} else if (con->current_state =3D=3D OPEN) {
- printk("l2ca_config_req: state OPEN, reconfiguration !\n");
+ DSYS("l2ca_config_req: state OPEN, reconfiguration !\n");
=20
/* FIXME -=20
Is data automatically suspended while reconfiguring ?
@@ -1649,6 +1665,7 @@
l2ca_disconnect_req(l2cap_con *con)
{
s32 result =3D -1;
+ u16 tmp_hdl =3D con->hci_hdl;
=20
if (PARANOIA_CHECKCON(con)) {
D_ERR(__FUNCTION__ ": Paranoia check failed\n");
@@ -1672,10 +1689,30 @@
/* wait here until we get a confirm */
l2ca_wait(__FUNCTION__, con);
=20
- return con->c_result;
+ result =3D con->c_result;
+
+ if (con->current_state =3D=3D CLOSED) {=09
+ /* remove l2cap connection */
+ delete_con(con);
+ } else {
+ D_ERR("L2CAP Disconnect failed\n");
+ PRINTSTATE(con);
}
=20
+ /* fixme -- if we want to keep baseband connection we must=20
+ leave the l2cap connection which holds the hci handle=20
+ simply just clear l2cap params but keep hci handle ! */
=20
+ 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);
+ }
+
+ return result;
+}
+
+
/* Response from upper layer to the indication of a channel to a remote=20
device */
s32=20
@@ -1750,7 +1787,7 @@
con->local_cid, con->remote_cid,=20
psm2str(con->psm));
=20
- /* reset */
+ /* reset variable */
con->conf_req_sent =3D 0;
=20
/* notify upper layers that we are opened */
@@ -1802,8 +1839,6 @@
if (count_con(con->hci_hdl) > 1) {
delete_con(con);=20=20=20=20=20
}
- /* If this con is the last with this hci_hdl, it is deleted=20
- when the baseband link goes down */
} else {
D_ERR(__FUNCTION__ ": invalid state !\n\n");
PRINTSTATE(con);
@@ -1819,7 +1854,7 @@
=20
void l2ca_timeoutind(l2cap_con *con)
{
- printk("l2ca_timeoutind\n");
+ DSYS("l2ca_timeoutind\n");
con->c_status =3D CSTATUS_RTX_TIMEOUT;=09
l2ca_wakeup("l2ca_timeoutind ", con);
}
@@ -1981,7 +2016,12 @@
req->src_cid =3D cpu_to_le16(con->local_cid);
=20=20=20
cmd->code =3D SIG_CONREQ;
+
+ /* Don't increment ID if retransmission */
+ if (con->timer.rtx_no =3D=3D 0)
cmd->id =3D set_id(con); /* Sets sig_id_sent in l2cap_con */
+ else
+ DSYS("RTX, use same ID\n");
=20
cmd->len =3D cpu_to_le16(CON_REQSIZE);
=20
@@ -2062,7 +2102,7 @@
SIGCMD_HDRSIZE + CONF_REQSIZE);
=20=20
if (in_mtu !=3D 0) {
- printk("Sending in_mtu %d\n", in_mtu);
+ DSYS("Sending in_mtu %d\n", in_mtu);
opt->type =3D OPT_MTU;
opt->len =3D 2;
*(opt->option_data) =3D (u8)(in_mtu & 0x00ff);
@@ -2073,7 +2113,7 @@
}
=20=09=09
if (flush_timeout !=3D 0) {
- printk("Sending flush_timeout %d\n", flush_timeout);
+ DSYS("Sending flush_timeout %d\n", flush_timeout);
opt->type =3D OPT_FLUSH;
opt->len =3D 2;
*(opt->option_data) =3D (u8)(flush_timeout & 0x00ff);
@@ -2084,7 +2124,7 @@
}
=20=09=09
if (outflow !=3D NULL) {=20
- printk("Sending conf req outflow\n");
+ DSYS("Sending conf req outflow\n");
print_flow(outflow);
opt->type =3D OPT_QOS;
opt->len =3D sizeof *outflow;
@@ -2098,7 +2138,15 @@
=20
/* Signalling header */
cmd->code =3D SIG_CONFREQ;
+
+ /* Don't increment ID if retransmission */
+ if (con->timer.rtx_no =3D=3D 0)
cmd->id =3D set_id(con); /* Sets sig_id_sent in l2cap_con */
+ else
+ DSYS("RTX, use same ID\n");
+
+ /* fixme -- wrong len field should be 2 more */
+
cmd->len =3D cpu_to_le16(CONF_REQSIZE + opt_len);
=20
SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
@@ -2149,7 +2197,13 @@
req->src_cid =3D cpu_to_le16(con->local_cid);
=20
cmd->code =3D SIG_DISCREQ;
+=20=20=20=20=20=20=20=20
+ /* Don't increment ID if retransmission */
+ if (con->timer.rtx_no =3D=3D 0)
cmd->id =3D set_id(con); /* Sets sig_id_sent in l2cap_con */
+ else
+ DSYS("RTX, use same ID\n");
+=20=20=20=20=20=20=20=20
cmd->len =3D cpu_to_le16(DISC_REQSIZE);
=20
SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
@@ -2498,7 +2552,7 @@
opt =3D (struct l2cap_option*)(rsp + CONF_RSPSIZE);
=20
if (out_mtu !=3D 0) {
- printk("Sending out_mtu %d\n", out_mtu);
+ DSYS("Sending out_mtu %d\n", out_mtu);
opt->type =3D OPT_MTU;
opt->len =3D 2;
*(opt->option_data) =3D (u8)(out_mtu & 0x00ff);
@@ -2509,7 +2563,7 @@
}
=20=09=09
if (in_flow !=3D NULL) {=20
- printk("Sending conf req in_flow\n");
+ DSYS("Sending conf req in_flow\n");
print_flow(in_flow);
opt->type =3D OPT_QOS;
opt->len =3D sizeof *in_flow;
@@ -2600,8 +2654,7 @@
if (tx->cur_len > con->remote_mtu) {
D_ERR("%s tries to send more than remote mtu, ignore\n",=20
psm2str(con->psm));
-
- D_ERR("SETTING FLUSHED ON THIS BUFFER !!!\n");
+ D_ERR(__FUNCTION__ ": Flushing this buffer\n");
tx->flushed =3D 1;
return -1;
}
@@ -2609,7 +2662,7 @@
/* Only send on an OPEN channel */
if (con->current_state !=3D OPEN) {
D_ERR(__FUNCTION__ ": not in open state\n");
- D_ERR("SETTING FLUSHED ON THIS BUFFER !!!\n");
+ D_ERR(__FUNCTION__ ": Flushing this buffer\n");
tx->flushed =3D 1;
return -1;
}
@@ -2657,7 +2710,7 @@
con->remote_cid, status);
=20=09
if (!con->initiator) {=20
- D_ERR(__FUNCTION__": server is not initiator !!!\n");=20
+ D_ERR(__FUNCTION__": server is not initiator !\n");=20
return;
}
=20=09
@@ -2673,7 +2726,7 @@
con->remote_cid, result);
=20=09
if (!con->initiator) {=20
- D_ERR(__FUNCTION__ ": server is not initiator !!!\n");=20
+ D_ERR(__FUNCTION__ ": server is not initiator !\n");=20
return;
}
=20
@@ -2719,30 +2772,11 @@
/* tell upper layers that connection is down */
get_upper(con->psm)->disc_cfm(con);
=20
- tmp_hdl =3D con->hci_hdl;
-
ENTERSTATE(con, CLOSED);
PRINTSTATE(con);
=20
DSYS("l2cap channel (%d,%d) [%s] disconnected\n",=20
con->local_cid, con->remote_cid, psm2str(con->psm));
-
- /* remove l2cap connection */
- delete_con(con);
-
-#ifdef __KERNEL__
- l2ca_wakeup(__FUNCTION__, con);
-#endif
-
- /* fixme -- if we want to keep baseband connection we must=20
- leave the l2cap connection which holds the hci handle=20
- simply just clear l2cap params but keep hci handle ! */
-=09
- if (count_con(tmp_hdl) =3D=3D 0) {
- DSYS(__FUNCTION__ ": (C) no more l2cap connections\n");
- DSYS("Shutdown baseband\n");
- lp_disconnect(tmp_hdl);
- }
}
=20
s32 l2ca_ping(BD_ADDR bd, u8 *opt_data, u16 len)
@@ -2787,9 +2821,9 @@
=20
if (con->c_status =3D=3D RES_SUCCESS) {
/* check status */
- printk("Now we got baseband, send echo req !\n");
+ D_XMIT("Now we got baseband, send echo req !\n");
} else {
- printk("Ping failed !\n");
+ D_ERR(__FUNCTION__ ": Ping failed !\n");
delete_con(con);
return -1;
}
@@ -2801,15 +2835,13 @@
=20
/* leave loop when either status failed or success */
while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT) {
- printk("Sending echo req...\n");
+ D_XMIT("Sending echo req...\n");
l2cap_echo_req(con, opt_data, len);=09
/* wait until we received a response or after timeout */
=20
- printk("Waiting for response or timeout\n");
+ D_XMIT("Waiting for response or timeout\n");
=20
l2ca_wait(__FUNCTION__ ": wait echo resp", con);
-
- printk("Woke up after sending echo req\n");
}
=20
if (con->c_status =3D=3D CSTATUS_MAX_NO_RTX) {
@@ -2861,9 +2893,9 @@
=20=09=09
if (con->c_status =3D=3D RES_SUCCESS) {
/* check status */
- printk("Now we got baseband, send info req !\n");
+ D_XMIT("Now we got baseband, send info req !\n");
} else {
- printk("GetInfo failed ! [cstatus %d]\n",=20
+ D_ERR(__FUNCTION__": GetInfo failed ! [cstatus %d]\n",=20
con->c_status);
delete_con(con);
return -1;
@@ -2876,15 +2908,11 @@
=20
/* leave loop when either status failed or success */
while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT) {
- printk("Sending info req...\n");
+ D_XMIT("Sending info req...\n");
l2cap_info_req(con, infotype);=09
- /* wait until we received a response or after timeout */
-=09=09
- printk("Waiting for response or timeout\n");
=20
+ /* wait until we received a response or after timeout */
l2ca_wait(__FUNCTION__ ": wait echo resp", con);
-
- printk("Woke up after sending info req\n");
}
=20
return con->c_result;
@@ -2931,7 +2959,7 @@
#else /* Usermode stack */
=20
/* FIXME */
- printk("Use NO timer in usermode stack yet...\n");
+ D_ERR("Use NO timer in usermode stack yet...\n");
return;
#if 0
struct itimerval t =3D {{0,0},{timeout, 0}};
@@ -3010,7 +3038,7 @@
D_TIM("ERTX never started\n");
#else /* Usermode stack */
/* FIXME */
- printk("disable_ertx FIXME\n");
+ D_ERR("disable_ertx FIXME\n");
con->timer.ertx_inuse =3D 0;
con->timer.ertx_action =3D ERTX_ACTION_DISCONNECT;
#endif
|
|
From: Mattias A. <mat...@us...> - 2001-04-25 17:12:49
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.105 1.106=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
added missing declaration
The diff of the modified file(s):
--- l2cap.c 2001/04/25 16:58:24 1.105
+++ l2cap.c 2001/04/25 17:12:48 1.106
@@ -1335,6 +1335,7 @@
{
l2cap_con *con;
u8 rev_bd[6];
+ s32 i;
=20=09
D_STATE(__FUNCTION__ ": %s (hci_handle : %d)\n",=20
get_err_msg(status), con_hdl);
|
|
From: Mattias A. <mat...@us...> - 2001-05-21 07:32:51
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.107 1.108=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* added sanity checks in l2cap_receive_data
* corrected flow option length in config req
The diff of the modified file(s):
--- l2cap.c 2001/04/26 13:33:26 1.107
+++ l2cap.c 2001/05/21 07:32:50 1.108
@@ -532,6 +532,25 @@
pkt_len =3D le16_to_cpu(pkt->len);
pkt_cid =3D le16_to_cpu(pkt->cid);
=20
+ /* Do some sanity checks */
+ if (pkt_len > HCI_IN_SIZE)
+ {
+ /* Packet won't fit in inbuffers */
+ D_ERR(__FUNCTION__": packet too big [%d], discard packet=
\n",=20
+ pkt_len);
+ hci_clear_buffer(hci_handle);
+ return;
+ }
+
+ if ((pkt_cid !=3D 1) && (pkt_cid !=3D 2) &&
+ ((pkt_cid < 0x0040) || (pkt_cid > 0xffff)))
+ {
+ D_ERR(__FUNCTION__": invalid CID [%d], discard packet\n"=
,=20
+ pkt_cid);
+ hci_clear_buffer(hci_handle);
+ return;
+ }
+
/* l2cap_len is checked in hci, when l2cap_len bytes=20
has been received in hci this function is called again */
*l2cap_len =3D pkt_len + L2CAP_HDRSIZE;
@@ -2117,7 +2136,7 @@
=20=09
if (outflow !=3D NULL) {
/* We inform peer about our QOS settings */
- opt_len +=3D sizeof *outflow;
+ opt_len +=3D sizeof *outflow + 2; /* include type/len */
}
=20=09
payload_len =3D SIGCMD_HDRSIZE + CONF_REQSIZE + opt_len;=20=20
@@ -2680,15 +2699,15 @@
{
l2cap_tx_buf *l2cap_buf;
=20
- D_XMIT(__FUNCTION__ ": hdl : %d, rcid : %d, len:%d \n",
- con->hci_hdl, con->remote_cid, tx->cur_len);
-
if (PARANOIA_CHECKCON(con)) {
D_ERR(__FUNCTION__ ": Paranoia check failed\n");
tx->flushed =3D 1; /* flush this buffer */
return -EINVAL;
}
=20
+ D_XMIT(__FUNCTION__ ": hdl : %d, rcid : %d, len:%d \n",
+ con->hci_hdl, con->remote_cid, tx->cur_len);
+
if (tx->cur_len > con->remote_mtu) {
D_ERR("%s tries to send more than remote mtu, ignore\n",=20
psm2str(con->psm));
@@ -2803,8 +2822,6 @@
void
l2ca_disconnect_cfm(l2cap_con *con)
{
- s32 tmp_hdl;
-
D_STATE(__FUNCTION__ ": remote cid : %d\n", con->remote_cid);
=20
/* tell upper layers that connection is down */
|
|
From: Mats F. <ma...@us...> - 2001-06-18 12:49:32
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.109 1.110=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Use get_lcon instead of get_rcon, since remote cid isn't unik
The diff of the modified file(s):
--- l2cap.c 2001/06/14 10:52:14 1.109
+++ l2cap.c 2001/06/18 12:49:31 1.110
@@ -857,8 +857,8 @@
D_STATE(__FUNCTION__ ": disconnection request id %d\n",=20
req->id);
=20
- if ((con =3D get_rcon(discreq->src_cid)) =3D=3D NULL) {
- D_STATE("not connected... discard!\n");
+ if ((con =3D get_lcon(discreq->dst_cid)) =3D=3D NULL) {
+ DSYS(__FUNCTION__"Disconnecting NULL object!\n");
return;
}
=20
@@ -1443,7 +1443,7 @@
l2cap_con *con;=20
=20
/* temp link down */
- DSYS("lp_disconnect_ind : Connection handle %d disconnected\n",
+ DSYS(__FUNCTION__": Connection handle %d disconnected\n",
con_hdl);
=20
/* find & notify/remove l2cap connection(s) on this hci handle */
|
|
From: Olov H. <ol...@us...> - 2001-07-10 12:52:56
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.110 1.111=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added support for max number of BT connections
The diff of the modified file(s):
--- l2cap.c 2001/06/18 12:49:31 1.110
+++ l2cap.c 2001/07/10 12:52:55 1.111
@@ -50,6 +50,7 @@
#include <linux/malloc.h>
#include <linux/bluetooth/l2cap.h>
#include <linux/bluetooth/hci.h>
+#include <linux/bluetooth/hci_internal.h>
#include <linux/bluetooth/rfcomm.h>
#include <linux/bluetooth/sdp.h>
#include <linux/bluetooth/test.h>
@@ -254,6 +255,8 @@
static l2cap_layer l2capmain; /* Main structure */
static l2cap_layer* l2cap;
static struct protocol_layer default_protocol;
+extern int bt_max_connections;
+extern hci_controller hci_ctrl;
=20
/****************** FUNCTION DEFINITION SECTION **************************=
***/
=20=20=20
@@ -1312,11 +1315,20 @@
=20
/* We are server and creates an l2cap connection object=20
which we set hci handle when we received lp_connect_cfm */
+ /* Denying a connection at this state does not allow
+ SDP queries when max amount of connections is reached*/
=20=20=20
+ if (hci_ctrl.nbr_of_connections < bt_max_connections){
D_CON(__FUNCTION__ ": Accepting connection\n");
l2cap_create_con(bd_addr);
lp_connect_rsp(bd_addr,1);
}
+ else{
+ D_CON(__FUNCTION__ ": Denying connection. Current connections: %d,=20
+ max connections: %d\n", bt_connections, bt_max_connections=
);
+ lp_connect_rsp(bd_addr,0);
+ }
+}
=20
/* is called when we accept a _new_ baseband connection */
void=20
|
|
From: Mattias A. <mat...@us...> - 2001-07-18 10:07:03
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- l2cap.c 1.111 1.112=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * added include when compiling for usermode stack The diff of the modified file(s): --- l2cap.c 2001/07/10 12:52:55 1.111 +++ l2cap.c 2001/07/18 10:07:02 1.112 @@ -67,6 +67,7 @@ #include <errno.h> #include "include/l2cap.h" #include "include/hci.h" +#include "include/hci_internal.h" #include "include/l2cap_internal.h" #include "include/l2cap_con.h" #include "include/l2cap_sec.h" |
|
From: Peter K. <pk...@us...> - 2001-08-30 05:37:17
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.112 1.113=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Fixed a typo.
The diff of the modified file(s):
--- l2cap.c 2001/07/18 10:07:02 1.112
+++ l2cap.c 2001/08/30 05:37:17 1.113
@@ -1326,7 +1326,7 @@
}
else{
D_CON(__FUNCTION__ ": Denying connection. Current connections: %d,=20
- max connections: %d\n", bt_connections, bt_max_connections=
);
+ max connections: %d\n", hci_ctrl.nbr_of_connections, bt_ma=
x_connections);
lp_connect_rsp(bd_addr,0);
}
}
|
|
From: Anders J. <and...@us...> - 2001-09-11 09:00:30
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.113 1.114=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
*=A0Added retransmission timer on l2ca_disconnect_req.
The diff of the modified file(s):
--- l2cap.c 2001/08/30 05:37:17 1.113
+++ l2cap.c 2001/09/11 09:00:28 1.114
@@ -1208,6 +1208,8 @@
return;
}
=20
+ con->c_status =3D conrsp->result;=09
+
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
disable_rtx(con);
#endif
@@ -1712,22 +1714,23 @@
D_STATE(__FUNCTION__ ": remote cid : %d\n", con->remote_cid);
=20
if (con->current_state =3D=3D OPEN || con->current_state =3D=3D CONFIG) {
-
- result =3D l2cap_disconnect_req(con);
-
ENTERSTATE(con, W4_L2CAP_DISCONNECT_RSP);
PRINTSTATE(con);
+ do {
+ result =3D l2cap_disconnect_req(con);
+ l2ca_wait(__FUNCTION__, con);
+ PRINTSTATE(con);
+=09=09=09
+ } while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT);
} else {
D_ERR(__FUNCTION__ ": Invalid state!\n");
PRINTSTATE(con);
return -1;=20=20=20=20
}
=20=09
- /* wait here until we get a confirm */
- l2ca_wait(__FUNCTION__, con);
-
result =3D con->c_result;
=20
+ if(con->c_status !=3D CSTATUS_MAX_NO_RTX) {
if (con->current_state =3D=3D CLOSED) {=09
/* remove l2cap connection */
delete_con(con);
@@ -1735,6 +1738,8 @@
D_ERR("L2CAP Disconnect failed\n");
PRINTSTATE(con);
}
+ }
+=09
=20=09
/* fixme -- if we want to keep baseband connection we must=20
leave the l2cap connection which holds the hci handle=20
|
|
From: Anders J. <and...@us...> - 2001-09-11 10:32:29
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- l2cap.c 1.114 1.115=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * Corrected c_status flag in a disconnection response. The diff of the modified file(s): --- l2cap.c 2001/09/11 09:00:28 1.114 +++ l2cap.c 2001/09/11 10:32:28 1.115 @@ -1208,7 +1208,7 @@ return; } =20 - con->c_status =3D conrsp->result;=09 + con->c_status =3D CSTATUS_SUCCESS;=09 =20 #ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS disable_rtx(con); |
|
From: Peter K. <pk...@us...> - 2001-09-12 11:45:03
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.115 1.116=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Minor clean-up.
The diff of the modified file(s):
--- l2cap.c 2001/09/11 10:32:28 1.115
+++ l2cap.c 2001/09/12 11:45:02 1.116
@@ -293,9 +293,8 @@
hci_read_local_bd(l2cap->my_bd);
=20
/* check result... */
- if ((l2cap->my_bd[0] =3D=3D 0) && (l2cap->my_bd[1] =3D=3D 0) &&=20
- (l2cap->my_bd[2] =3D=3D 0) && (l2cap->my_bd[3] =3D=3D 0) &&
- (l2cap->my_bd[4] =3D=3D 0) && (l2cap->my_bd[5] =3D=3D 0))
+ if (!l2cap->my_bd[0] && !l2cap->my_bd[1] && !l2cap->my_bd[2] &&
+ !l2cap->my_bd[3] && !l2cap->my_bd[4] && !l2cap->my_bd[5])
D_ERR(__FUNCTION__ ": Failed to get local BD addr\n");
else {
i =3D l2cap_sprint_bd(bd_name, l2cap->my_bd);
@@ -1308,8 +1307,8 @@
PRINTPKT(__FUNCTION__ ": from: ", bd_addr, 6);
=20
/* Check BD_ADDR */
- if ((bd_addr[0]=3D=3D0) && (bd_addr[1]=3D=3D0) && (bd_addr[2]=3D=
=3D0) &&
- (bd_addr[3]=3D=3D0) && (bd_addr[4]=3D=3D0) && (bd_addr[5]=3D=
=3D0)) {
+ if (!bd_addr[0] && !bd_addr[1] && !bd_addr[2] &&
+ !bd_addr[3] && !bd_addr[4] && !bd_addr[5]) {
D_ERR(__FUNCTION__ ": no BD addr\n");
return;
}
@@ -1325,10 +1324,8 @@
D_CON(__FUNCTION__ ": Accepting connection\n");
l2cap_create_con(bd_addr);
lp_connect_rsp(bd_addr,1);
- }
- else{
- D_CON(__FUNCTION__ ": Denying connection. Current connections: %d,=20
- max connections: %d\n", hci_ctrl.nbr_of_connections, bt_ma=
x_connections);
+ } else {
+ D_CON(__FUNCTION__ ": Denying connection. Current connections: %d, max c=
onnections: %d\n", hci_ctrl.nbr_of_connections, bt_max_connections);
lp_connect_rsp(bd_addr,0);
}
}
@@ -1447,7 +1444,6 @@
/* delete connection if non-initiator */
delete_con(con);
}=20
-=09=09
}
}
=20=20
@@ -1555,8 +1551,7 @@
PRINTPKT(__FUNCTION__ ": sent to bd ",bd, 6);
=20
/* Check bd_addr */
- if ((bd[0]=3D=3D0) && (bd[1]=3D=3D0) && (bd[2]=3D=3D0) && (bd[3]=3D=3D0) =
&&
- (bd[4]=3D=3D0) && (bd[5]=3D=3D0)) {
+ if (!bd[0] && !bd[1] && !bd[2] && !bd[3] && !bd[4] && !bd[5]) {
D_ERR(__FUNCTION__ ": No BD-addr\n");
return -EINVAL;
}
@@ -2895,7 +2890,6 @@
/* wait here until we received a lp_connect_cfm */
l2ca_wait(__FUNCTION__ ": wait baseband", con);
=20=09=09
-
if (con->c_status =3D=3D RES_SUCCESS) {
/* check status */
D_XMIT("Now we got baseband, send echo req !\n");
@@ -2914,6 +2908,7 @@
while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT) {
D_XMIT("Sending echo req...\n");
l2cap_echo_req(con, opt_data, len);=09
+
/* wait until we received a response or after timeout */
=20
D_XMIT("Waiting for response or timeout\n");
@@ -2955,7 +2950,6 @@
=20
memcpy(con->remote_bd, rev_bd, 6);
con->link_up =3D 0;
-
con->initiator =3D 1;
insert_con(con);
=20
|
|
From: Anders J. <and...@us...> - 2001-10-03 12:12:37
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.119 1.120=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Corrected error in l2cap_config_rsp which wrote data at the wrong address.
The diff of the modified file(s):
--- l2cap.c 2001/09/21 12:51:06 1.119
+++ l2cap.c 2001/10/03 12:12:35 1.120
@@ -778,6 +778,7 @@
CONF_FAILURE) < 0) {
D_ERR(__FUNCTION__ ": Couldn't send conf rsp\n");
}
+=09=09=09=09
return;
}
=20=09=09=09
@@ -2614,14 +2615,14 @@
=20
/* Include unaccepted options if any */
if (opt_len) {
- opt =3D (struct l2cap_option*)(rsp + CONF_RSPSIZE);
+ opt =3D (struct l2cap_option*)((u8*)rsp + CONF_RSPSIZE);
=20
if (out_mtu !=3D 0) {
DSYS("Sending out_mtu %d\n", out_mtu);
opt->type =3D OPT_MTU;
opt->len =3D 2;
- *(opt->option_data) =3D (u8)(out_mtu & 0x00ff);
- *(opt->option_data+1) =3D (u8)(out_mtu >> 8) & 0x00ff;
+ opt->option_data[0] =3D (u8)(out_mtu & 0x00ff);
+ opt->option_data[1] =3D (u8)(out_mtu >> 8) & 0x00ff;
=20=09
/* forward pointer for other options */
opt =3D (struct l2cap_option*)((char *)opt + 4);
@@ -2632,9 +2633,9 @@
print_flow(in_flow);
opt->type =3D OPT_QOS;
opt->len =3D sizeof *in_flow;
- memcpy((char*)opt+2, in_flow, sizeof *in_flow);
+ memcpy((char*)opt->option_data, in_flow, sizeof *in_flow);
}
- print_data("options: ", (u8*)rsp, opt_len + CONF_RSPSIZE);
+ print_data("options: ", (u8*)rsp + CONF_RSPSIZE, opt_len);
}
=20=09
cmd->code =3D SIG_CONFRSP;
|
|
From: Peter K. <pk...@us...> - 2001-10-16 14:38:18
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.121 1.122=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Fixed an error message.
The diff of the modified file(s):
--- l2cap.c 2001/10/10 14:58:18 1.121
+++ l2cap.c 2001/10/16 10:51:29 1.122
@@ -2969,7 +2969,7 @@
=20
retval =3D lp_connect_req(con->remote_bd);
if(retval < 0) {
- D_ERR(__FUNCTION__, ": lp_connect_req failed (status %d)\n", retval);
+ D_ERR(__FUNCTION__ ": lp_connect_req failed (status %d)\n", retval);
delete_con(con);
return retval;
}
|
|
From: Anders J. <and...@us...> - 2001-11-15 15:52:16
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.123 1.124=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Changed timeouts to not take any action except unlocking waitqueues.
* No more use of connection objects after a deletion :).
The diff of the modified file(s):
--- l2cap.c 2001/10/22 13:25:54 1.123
+++ l2cap.c 2001/11/15 15:52:15 1.124
@@ -210,7 +210,7 @@
static void l2cap_ertx_timeout(unsigned long ptr);
#endif
=20
-static void start_rtx(l2cap_con *con, unsigned short timeout, unsigned sho=
rt action);
+static void start_rtx(l2cap_con *con, unsigned short timeout);
static void disable_rtx(l2cap_con *con);
=20
static void start_ertx(l2cap_con *con, unsigned short timeout);
@@ -1046,7 +1046,6 @@
l2ca_wakeup("Got connect rsp neg", con);
=20=09=09=09
ENTERSTATE(con, CLOSED);
- delete_con(con);
}
break;
=20=20=20=20=20=20=20=20
@@ -1381,10 +1380,10 @@
=20=20=20=20=20=20=20
ENTERSTATE(con, W4_L2CAP_CONNECT_RSP);
PRINTSTATE(con);
-=09=09=09
- l2ca_wakeup(__FUNCTION__, con);
}
=20
+=09=09
+
return 1;
} else {
/* neg cfm */
@@ -1576,6 +1575,7 @@
retval =3D lp_connect_req(con->remote_bd);
if(retval < 0) {
D_ERR(__FUNCTION__ ": failed (status %d)\n", retval);
+ delete_con(con);
return retval;
}
=20
@@ -1594,19 +1594,45 @@
con->c_status =3D CSTATUS_RTX_TIMEOUT;
=20
/* Leave loop when either status failed or success */
- while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT) {
+ do {
/* baseband is up, now initiate send connect req */
- retval =3D l2cap_connect_req(con, con->psm);
- if(retval < 0) {
+ if((retval =3D l2cap_connect_req(con, con->psm)) < 0) {=20
+ /* This can be a result of insufficient memory and it's the=20=20
+ callers responsibility to take proper action */
D_ERR(__FUNCTION__ ": failed (status %d)\n", retval);
+ if(!tmpcon) {
+ lp_disconnect(con->hci_hdl);
+ }
+ ENTERSTATE(con, CLOSED);
+ delete_con(con);
+ return retval;
}
/* wait until we received a response or after timeout */
l2ca_wait(__FUNCTION__ ": wait rsp", con);
+ } while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT);
+=09
+
+ if (con->c_status !=3D RES_SUCCESS) {
+ if(con->c_status =3D=3D CSTATUS_ERTX_TIMEOUT) {
+ l2ca_disconnect_ind(con);
}
=20
- if (con->c_status =3D=3D CSTATUS_MAX_NO_RTX && !retval) {
+ if(!tmpcon) {
+ lp_disconnect(con->hci_hdl);
+ }
+=09=09
+ switch(con->c_status) {
+ case CSTATUS_MAX_NO_RTX:
retval =3D -MSGCODE(MSG_LAYER_L2CAP, L2CAP_RTX_TIMEOUT);
+ break;
+=09=09=09
+ default:=20=20=20
+ retval =3D -MSGCODE(MSG_LAYER_L2CAP, con->c_status);
}
+=09=09
+ ENTERSTATE(con, CLOSED);
+ delete_con(con);
+ }
return retval;
}
=20
@@ -1679,10 +1705,8 @@
do {
retval =3D l2cap_disconnect_req(con);
if(retval < 0) {
- /* This will result in a timeout and we need to try again
- as the error is a result of insufficent space in our
- memorypool and we try again after a timeout */
D_ERR(__FUNCTION__ ": Failed (status %d)\n", retval);
+ return retval;
}
=20=09=09=09
l2ca_wait(__FUNCTION__, con);
@@ -1695,23 +1719,17 @@
return -MSGCODE(MSG_LAYER_L2CAP, L2CAP_INVALID_STATE);=20=20=20=20
}
=20=09
- if(con->c_status !=3D CSTATUS_MAX_NO_RTX) {
- if (con->current_state =3D=3D CLOSED) {=09
- /* remove l2cap connection */
- delete_con(con);
- } else {
- /* FIXME: If we reach here, should we delete the connection? */
- D_ERR(__FUNCTION__ ": Failed (Connection not closed)");
- PRINTSTATE(con);
- retval =3D -MSGCODE(MSG_LAYER_L2CAP, L2CAP_FAILED);
- }
- }
+ ENTERSTATE(con, CLOSED);
=20=09
+ if (con->c_status =3D=3D CSTATUS_MAX_NO_RTX) {
+ retval =3D -MSGCODE(MSG_LAYER_L2CAP, L2CAP_RTX_TIMEOUT);
+ l2ca_disconnect_cfm(con);
+ }
=20=09
- /* fixme -- if we want to keep baseband connection we must=20
- leave the l2cap connection which holds the hci handle=20
- simply just clear l2cap params but keep hci handle ! */
+ delete_con(con);
=20=09
+ /* If this is the last l2cap-session on the baseband connection we
+ disconnect the baseband as well */
if (count_con(tmp_hdl) =3D=3D 0) {
DSYS("l2ca_disconnect_req : (C) no more l2cap cons\n");
DSYS("Shutdown baseband\n");
@@ -1935,7 +1953,7 @@
if (con->timer.rtx_no =3D=3D MAX_NO_RTX) {
con->c_status =3D CSTATUS_MAX_NO_RTX;
=20
- D_TIM("Connection unresponsive\n");
+ D_TIM(__FUNCTION__ ": Max number of retransmit reached\n");
=20
show_con("Connection unresponsive\n", con);
=20
@@ -1946,17 +1964,6 @@
=20
/* reset rtx counter */
con->timer.rtx_no =3D 0;
-
- if (con->timer.rtx_action =3D=3D RTX_ACTION_START_ERTX) {
- /* start ertx timer */
- D_TIM("Starting ERTX\n");
- start_ertx(con, ERTX_TIMEOUT);
- } else if (con->timer.rtx_action =3D=3D RTX_ACTION_TERMINATE) {
- D_TIM("Removing connection\n");
- l2ca_disconnect_ind(con);
- ENTERSTATE(con, CLOSED);
- delete_con(con);
- }
} else {
con->timer.rtx_no++;
l2ca_timeoutind(con);=09
@@ -1980,20 +1987,8 @@
return;
}
=20
- if (con->timer.ertx_action =3D=3D ERTX_ACTION_TERMINATE) {
- D_TIM("Removing connection\n");
- l2ca_disconnect_ind(con);
- ENTERSTATE(con, CLOSED);
- delete_con(con);
- } else if (con->timer.ertx_action =3D=3D ERTX_ACTION_DISCONNECT) {
-=09=09
- D_TIM("Disconnect connection\n");
- /* set dont sleep flag so that we wont do sleep=20
- when not running in usermode context */
- con->c_flags |=3D FLAG_DONTSLEEP;
- ENTERSTATE(con, CONFIG); /* CERT HACK ! */
- l2ca_disconnect_req(con);
- }
+ con->c_status =3D CSTATUS_ERTX_TIMEOUT;
+ l2ca_wakeup("ertx_timeout", con);
}
=20
#endif /* CONFIG_BLUETOOTH_L2CAP_USE_TIMERS */
@@ -2082,7 +2077,7 @@
=20=09
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
/* start retransmission timer */
- start_rtx(con, RTX_TIMEOUT, RTX_ACTION_START_ERTX);
+ start_rtx(con, RTX_TIMEOUT);
#endif
return hci_send_data(tx);
}
@@ -2210,7 +2205,7 @@
print_data("l2cap options: ", (char*)opt , opt_len);
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
/* start retransmission timer */
- start_rtx(con, RTX_TIMEOUT, RTX_ACTION_START_ERTX);
+ start_rtx(con, RTX_TIMEOUT);
#endif
return hci_send_data(tx);
}
@@ -2260,7 +2255,7 @@
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
/* start retransmission timer */
- start_rtx(con, RTX_TIMEOUT, RTX_ACTION_TERMINATE);
+ start_rtx(con, RTX_TIMEOUT);
#endif
return hci_send_data(tx);
}
@@ -2308,7 +2303,7 @@
tx->cur_len =3D L2CAP_HDRSIZE + payload_len;
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
- start_rtx(con, RTX_TIMEOUT, RTX_ACTION_DISCONNECT);
+ start_rtx(con, RTX_TIMEOUT);
#endif
return hci_send_data(tx);
}
@@ -2393,7 +2388,7 @@
tx->cur_len =3D L2CAP_HDRSIZE + payload_len; /* Increased when lower
layers add header data */
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
- start_rtx(con, RTX_TIMEOUT, RTX_ACTION_TERMINATE);
+ start_rtx(con, RTX_TIMEOUT);
#endif
return hci_send_data(tx);
}
@@ -2861,6 +2856,7 @@
retval =3D lp_connect_req(con->remote_bd);
if(retval < 0) {
D_ERR(__FUNCTION__ ": lp_connect_req failed (status %d)\n", retval);
+ delete_con(con);
return retval;
}
=20
@@ -2896,7 +2892,7 @@
=20
if (con->c_status =3D=3D CSTATUS_MAX_NO_RTX) {
/* max number reached, try to disconnect */
- retval =3D l2ca_disconnect_req(con);
+ retval =3D l2cap_disconnect_req(con);
}
=20
return retval;
@@ -2951,8 +2947,9 @@
D_XMIT("Now we got baseband, send info req !\n");
} else {
D_ERR(__FUNCTION__ ": lp_connect_req failed, no connection (status %d)\=
n", con->c_status);
+ retval =3D -MSGCODE(MSG_LAYER_HCI, con->c_status);
delete_con(con);
- return -MSGCODE(MSG_LAYER_HCI, con->c_status);
+ return retval;
}
}
=20
@@ -2966,7 +2963,7 @@
retval =3D l2cap_info_req(con, infotype);
if(retval < 0) {
D_ERR(__FUNCTION__ ": l2cap_info_req failed (status %d)\n", retval);
- /* Timeout and then try again */
+ return retval;
}
=20
/* wait until we received a response or after timeout */
@@ -2991,7 +2988,7 @@
/* Action is used when the sending function doesn't want
to handle the action it self */
void
-start_rtx(l2cap_con *con, unsigned short timeout, u16 action)
+start_rtx(l2cap_con *con, unsigned short timeout)
{
/* multiply by 2 each rtx */
=20
@@ -3015,7 +3012,6 @@
con->timer.rtx.data =3D (unsigned long)con;
con->timer.rtx.expires =3D jiffies + timeout*HZ;
con->timer.rtx_inuse =3D 1;
- con->timer.rtx_action =3D action;
add_timer(&con->timer.rtx);=20=20
=20
#else /* Usermode stack */
|
|
From: Peter K. <pk...@us...> - 2001-11-30 13:08:10
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.125 1.126=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Handle receiving a disconnection request while already waiting
for a disconnection response.
The diff of the modified file(s):
--- l2cap.c 2001/11/22 14:02:41 1.125
+++ l2cap.c 2001/11/30 13:08:07 1.126
@@ -832,8 +832,20 @@
con->sig_id_rcv =3D req->id;
=20
/* if already closed, simply acknowledge */
- if ((con->current_state =3D=3D CLOSED)) {
+ if (con->current_state =3D=3D CLOSED) {
D_STATE(__FUNCTION__ ": connection closed, send disc rsp\n");
+ l2cap_disconnect_rsp(con);
+ return;
+ }
+
+ /* Special case, if we send a disconnection request to the
+ other side and receive a disconnect indication while
+ waiting for the response, we can't send the upper layers
+ a disconnect indication as it may destroy the connection
+ object before we receive the response to our disconnection
+ request. */
+ if (con->current_state =3D=3D W4_L2CAP_DISCONNECT_RSP) {
+ D_STATE(__FUNCTION__ ": Waiting for an outstanding disconnect_req, send=
disconnect_rsp\n");
l2cap_disconnect_rsp(con);
return;
}
|