|
From: Anders J. <and...@us...> - 2003-03-06 16:12:22
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
bluetooth.c 1.237 1.238=20=20=20=20=20=20=20=20=20=20=20=20=20
hci.c 1.208 1.209=20=20=20=20=20=20=20=20=20=20=20=20=20
l2cap.c 1.135 1.136=20=20=20=20=20=20=20=20=20=20=20=20=20
rfcomm.c 1.138 1.139=20=20=20=20=20=20=20=20=20=20=20=20=20
test.c 1.38 1.39=20=20=20=20=20=20=20=20=20=20=20=20=20=20
unplug_test.c 1.14 1.15=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Added some testcases.
* Added more command to testlayer.
* Improved errorhandling when receiving corrupt headers in l2cap.
* Corrected usage of some bits in rpn-messages in rfcomm.
* Corrected read_remote_name, it now uses the length specified correclty (t=
hanks to Ed Orchard).
The diff of the modified file(s):
--- bluetooth.c 6 Feb 2003 15:36:20 -0000 1.237
+++ bluetooth.c 6 Mar 2003 16:04:00 -0000 1.238
@@ -746,12 +746,16 @@
copy_from_user(&length, (s32*)arg + 1, sizeof length);
=20=09=09
con_hdl =3D bt_get_conhdl_from_line(line);
+
if(con_hdl >=3D 0) {
+ /* get_remote_name will set max BT_NAME_LENGTH chars
+ in remote_name if specified length happend to be
+ more than that */
err =3D get_remote_name(con_hdl, remote_name, length);
} else {
err =3D -EINVAL;
}
- copy_to_user((s32*)arg, remote_name, BT_NAME_LENGTH);
+ copy_to_user((s32*)arg, remote_name, length);
return err;
}
=20
--- hci.c 6 Feb 2003 15:36:20 -0000 1.208
+++ hci.c 6 Mar 2003 16:03:57 -0000 1.209
@@ -511,7 +511,8 @@
header and we silently discard the previous packet */
=20
if(get_inbuffer(hci_hdl)) {
- D_ERR(__FUNCTION__ ": Discarding data in previous buffer\n");
+ D_ERR(__FUNCTION__ ": Received new frame while waiting for a continu=
ation frame"
+ ", channel unreliable\n");
hci_clear_buffer(hci_hdl);
}
=20
--- l2cap.c 13 Jan 2003 19:48:32 -0000 1.135
+++ l2cap.c 6 Mar 2003 16:03:59 -0000 1.136
@@ -222,6 +222,12 @@
=20
#endif
=20
+#if CONFIG_BLUETOOTH_UNPLUG_TEST
+extern s32 add_value;
+extern u16 contflag;
+#endif
+
+
/****************** GLOBAL VARIABLE DECLARATION SECTION ******************=
***/
=20
/****************** LOCAL VARIABLE DECLARATION SECTION *******************=
***/
@@ -525,6 +531,14 @@
=20=20=20=20=20
D_RCV(__FUNCTION__ ": New frame len:%d cid:%d\n", pkt_len, pkt_cid);
=20
+ if(len > *l2cap_len) {
+ /* We have received more data than the l2cap header
+ specified, discard this buffer */
+ DSYS(__FUNCTION__ ": Received %d bytes, expected %d bytes, channel unre=
liable\n", len, *l2cap_len);
+ hci_clear_buffer(hci_handle);
+ return;
+ }
+=09=09
/* check length */
if (!(pkt_len =3D=3D (len - L2CAP_HDRSIZE)))
return;
@@ -532,7 +546,7 @@
/* Not recieved full frame yet or BIG packet */
=20=09=09
if (len > *l2cap_len) {
- DSYS(__FUNCTION__ ": BIG PACKET ! (%d bytes) discard\n", len);
+ DSYS(__FUNCTION__ ": Received %d bytes, expected %d bytes, channel unre=
liable\n", len, *l2cap_len);
hci_clear_buffer(hci_handle);
}
return;
@@ -2203,7 +2217,11 @@
=20
/* Request header */
req->dst_cid =3D cpu_to_le16(con->remote_cid); /* Sending end */
- req->flags =3D 0; /* Negotiate same as remote */
+#ifdef CONFIG_BLUETOOTH_UNPLUG_TEST
+ req->flags =3D cpu_to_le16(contflag); /* Negotiate same as remote */
+#else
+ req->flags =3D 0;
+#endif
=20
/* Signalling header */
cmd->code =3D SIG_CONFREQ;
@@ -2743,7 +2761,12 @@
=20
l2cap_buf =3D (l2cap_tx_buf *)(tx->data);
=20
+#ifdef CONFIG_BLUETOOTH_UNPLUG_TEST
+ /* Used to send packets with incorrect header */
+ SET_L2CAP_HDR(l2cap_buf->frame, tx->cur_len + add_value, con->remote_cid);
+#else
SET_L2CAP_HDR(l2cap_buf->frame, tx->cur_len, con->remote_cid);
+#endif
=20
/* pb_flag is set from hci_send_data */
tx->hci_hdl =3D con->hci_hdl;
--- rfcomm.c 1 Nov 2002 10:30:16 -0000 1.138
+++ rfcomm.c 6 Mar 2003 16:04:05 -0000 1.139
@@ -138,6 +138,8 @@
=20
#define RFCOMM_MAX_HDR_SIZE 5
=20
+/* Set to 0 if you intend to initiate connections with no credit based flo=
w control */
+#define CL_BITS 0xf
#define MAX_CREDITS 30
#define START_CREDITS 7
#define MIN_CREDITS 6
@@ -756,8 +758,8 @@
/* must fit i l2cap mtu */
D_CTRL(FNC"negotiate mtu : %d bytes\n",
rfcomm->l2cap->remote_mtu - 5);
- return send_pn_msg(rfcomm, 7, rfcomm->dlci[tmp_dlci].mtu, 0, 0,
- tmp_dlci, TRUE);
+ return send_pn_msg(rfcomm, 7, rfcomm->dlci[tmp_dlci].mtu, CL_BITS, START=
_CREDITS,
+ tmp_dlci, FALSE);
}
=20
return 0;
@@ -1143,8 +1145,8 @@
((~rfcomm->initiator) & 0x1));
=20
/* must fit in l2cap mtu incl rfcomm hdrs */
- send_pn_msg(rfcomm, 7, rfcomm->dlci[tmp_dlci].mtu, 0,
- 0, tmp_dlci, TRUE);
+ send_pn_msg(rfcomm, 7, rfcomm->dlci[tmp_dlci].mtu, CL_BITS,
+ START_CREDITS, tmp_dlci, TRUE);
rfcomm->dlci[tmp_dlci].state =3D NEGOTIATING;
=20
} else if (rfcomm->dlci[tmp_dlci].state =3D=3D NEGOTIATING) {
@@ -1577,6 +1579,7 @@
for now) */
D_CTRL(FNC"Received Remote port negotiation respons\n");
memcpy(&rpn_val, &mcc_short_pkt->value[1], 8);
+ memset(&rpn_val.pm, 0xff, 2);
rfcomm_rpn_msg(rfcomm, MCC_RSP, tmp_dlci, 0);
/* Zero the parametermask after respons */
memset(&rpn_val.pm, 0, 2);
@@ -2182,6 +2185,7 @@
rpn_msg* rpn_pkt;
u32 rfcomm_frame_size;
u32 rfcomm_payload_size;
+ s32 retval;
=20
rfcomm_frame_size =3D sizeof(rpn_msg);
=20
@@ -2218,17 +2222,20 @@
rpn_pkt->dlci.d =3D dlci & 1;
rpn_pkt->dlci.server_chn =3D (dlci >> 1);
=20
+ memset(&rpn_val.pm, 0xff, 2);
+
if (req) {
rpn_pkt->mcc_s_head.length.len =3D 1;
/* Fix, since the packet is ends here when it is a request */
rpn_pkt->rpn_val.bit_rate =3D rpn_pkt->fcs;
- return l2cap_send_data(tx_buf, rfcomm->l2cap);
} else {
rpn_pkt->mcc_s_head.length.len =3D 8;
memcpy(&(rpn_pkt->rpn_val), &rpn_val, sizeof(rpn_values));
- //print_data("",(u8*) rpn_pkt, rfcomm_frame_size);
- return l2cap_send_data(tx_buf, rfcomm->l2cap);
}
+
+ retval =3D l2cap_send_data(tx_buf, rfcomm->l2cap);
+ memset(&rpn_val.pm, 0, 2);
+ return retval;
}
=20
s32
--- test.c 14 Jan 2003 15:19:03 -0000 1.38
+++ test.c 6 Mar 2003 16:04:08 -0000 1.39
@@ -158,6 +158,7 @@
void test_init(void)
{
protocol_layer this_layer;
+ int i;
=20
DSYS("Initialising TEST\n");
=20
@@ -176,6 +177,9 @@
l2cap_register_upper(L2CAP_TEST_LAYER, &this_layer);
l2cap_register_upper(L2CAP_TEST2_LAYER, &this_layer);
l2cap_register_upper(L2CAP_TEST3_LAYER, &this_layer);
+ for(i =3D 0 ; i < UPTEST_DATA_LEN ; i ++) {
+ testdata[i] =3D (unsigned char)i;
+ }
}
=20
void test_shutdown(void)
@@ -354,15 +358,7 @@
D_STATE("test_config_ind : remote cid : %d remote_mtu : %d\n",
con->remote_cid, con->remote_mtu);
=20
- if(dont_accept_mtu) {
- if (l2ca_config_rsp(con, 640, NULL, CONF_FAILURE)) {
- D_ERR("test_config_ind : Configuration response failed\n");
- }
- dont_accept_mtu =3D 0;
- }
- else if (l2ca_config_rsp(con, 0, NULL, CONF_SUCCESS)) {
- D_ERR("test_config_ind : Configuration response failed\n");
- }
+=09
=20
/* Are we ready with our sides configuration */
if (!l2ca_local_conf_done(con) && !con->conf_req_sent) {
@@ -397,13 +393,23 @@
=20
} else
D_RCV("already ready with config req\n");
+
+ if(dont_accept_mtu) {
+ if (l2ca_config_rsp(con, 640, NULL, CONF_FAILURE)) {
+ D_ERR("test_config_ind : Configuration response failed\n");
+ }
+ dont_accept_mtu =3D 0;
+ }
+ else if (l2ca_config_rsp(con, 0, NULL, CONF_SUCCESS)) {
+ D_ERR("test_config_ind : Configuration response failed\n");
+ }
}
=20
void test_config_cfm(l2cap_con *con, s32 status)
{
D_STATE("test_config_cfm : remote cid : %d\n", con->remote_cid);
if(status) {
- if(l2ca_config_req(con, con->remote_mtu, &con->remote_qos, con->flush_ti=
meout, 0)) {
+ if(l2ca_config_req(con, con->remote_mtu, NULL, 0, 0)) {
D_ERR("test_config_cfm : Configuration request failed\n");
}
return;
@@ -586,6 +592,27 @@
} else if(!strncmp(cmd, "dont_send_connect_response ", 27)) {
dont_send_connect_response =3D strtoul(cmd+27, NULL, 0);
return 0;
+ } else if(!strcmp(cmd, "test_case_use_cont_flag")) {
+ use_contflag =3D 1;
+ return 0;
+ } else if(!strcmp(cmd, "test_case_emulate_pending")) {
+ emulate_pending =3D 1;
+ return 0;
+ } else if(!strncmp(cmd, "configure_mtu ", 8)) {
+ int lcid, mtu;
+ char *p =3D cmd+14;
+ l2cap_con *con;
+ lcid =3D strtoul(p, &p, 0);
+ mtu =3D strtoul(p+1, &p, 0);
+
+ /* first find connection based on local cid */
+ con =3D get_lcon(lcid);
+ if (!con) {
+ printk("Found no connection with lcid : %d\n", lcid);
+ return -1;
+ }
+
+ return l2ca_config_req(con, mtu, NULL, 0, 0);
} else {
printk("Unknown test cmd!\n");
return -1;
--- unplug_test.c 1 Aug 2002 16:19:29 -0000 1.14
+++ unplug_test.c 6 Mar 2003 16:04:07 -0000 1.15
@@ -166,6 +166,35 @@
=20
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
=20
+/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D SPP =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
+unsigned char spp_data_53111[] =3D { 0x02, 0x77, 0x77, 0x00, 0x08,
+ 0x35, 0x03, 0x19, 0x00, 0x03, 0x00, 0xff,
+ 0x00 };
+
+unsigned char spp_data_53112[] =3D { 0x04, 0x88, 0x91, 0x00, 0x12,
+ 0x00, 0x10, 0x00, 0x09,=20
+ 0x00, 0xff,=20
+ 0x35, 0x09,=20
+ 0x09, 0x00, 0x01,=20
+ 0x09, 0x00, 0x04,
+ 0x09, 0x01, 0x00,
+ 0x00 };
+
+unsigned char spp_data_53113[] =3D { 0x06, 0x88, 0x88, 0x00, 0x13,
+ 0x35, 0x03,=20
+ 0x19, 0x00, 0x03,=20
+ 0x00, 0xff,
+ 0x35, 0x09,=20
+ 0x09, 0x00, 0x01,=20
+ 0x09, 0x00, 0x04,
+ 0x09, 0x01, 0x00,
+ 0x00 };
+
+
+/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
+
+
+
=20
/* UUID 16 */
unsigned char sdp_data_52111_1[] =3D { 0x02, 0x77, 0x77, 0x00, 0x08,
@@ -1773,7 +1802,22 @@
/*
* Serial Port Profile Stuff
*/
+static s32 spp_test_53111(void)
+{
+ return sdp_send_data(&sdp_con_list[0], spp_data_53111, spp_data_53111[4] =
+ 5);
+}
+
+static s32 spp_test_53112(void)
+{
+ return sdp_send_data(&sdp_con_list[0], spp_data_53112, spp_data_53112[4] =
+ 5);
+}
+
+static s32 spp_test_53113(void)
+{
+ return sdp_send_data(&sdp_con_list[0], spp_data_53113, spp_data_53113[4] =
+ 5);
+}
=20
+#if 0
static s32 spp_test_52211(void)
{
static int t =3D 0;
@@ -1963,11 +2007,12 @@
switch (t) {
case 0:
retval =3D rfcomm_pn_msg(&rfcomm_con_list[0], 2, 0, 1000);
- t++;
+ t =3D 1;
break;
=20
case 1:
retval =3D rfcomm_pn_msg(&rfcomm_con_list[0], 2, 0, 667);
+ t =3D 0;
break;
}
return retval;
@@ -2036,6 +2081,8 @@
return 0;
}
=20
+#endif
+
/*
* RFCOMM stuff
*/
@@ -2509,7 +2556,7 @@
case 54122: return sdp_test_54122();
case 55111: return sdp_test_55111();
case 55112: return sdp_test_55112();
-
+#if 0
case 62211: return spp_test_52211();
=20
case 62311: return spp_test_52311();
@@ -2530,6 +2577,12 @@
case 631111: return spp_test_531111();
case 631112: return spp_test_531112();
case 66211: return spp_test_56211();
+#endif
+=20=20=20=20=20=20=20=20=20
+ case 653111: return spp_test_53111();
+ case 653112: return spp_test_53112();
+ case 653113: return spp_test_53113();
+=20=20=20=20=20=20=20=20=20=20
=20
case 41: return test_4_1();
case 421: return test_4_2_1();
|