|
From: Anders J. <and...@us...> - 2001-10-12 12:03:23
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bluetooth.c 1.203 1.204=20=20=20=20=20=20=20=20=20=20=20
rfcomm.c 1.123 1.124=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Corrected bug in RFCOMM, now using correct length when determine if there=
are any data in the ACL packet.
* Changed returnvalues to use bt_err-errorcodes and standard defines.
The diff of the modified file(s):
--- bluetooth.c 2001/10/10 14:58:18 1.203
+++ bluetooth.c 2001/10/12 12:03:22 1.204
@@ -1855,6 +1855,7 @@
case RFCOMM_LAYER:
{
u8 srv_ch;
+ s32 retval =3D 0;
=20
CHECK_RFCOMM(con_id);
srv_ch =3D GET_RFCOMMSRVCH(con_id);=20
@@ -1865,9 +1866,9 @@
srv_ch, line);
BT_DATADUMP("Remote BD: ", bd_addr, 6);
=20
- if (rfcomm_connect_req(bd_addr, srv_ch, line) < 0) {
+ if ((retval =3D rfcomm_connect_req(bd_addr, srv_ch, line)) < 0) {
BT_DRIVER(__FUNCTION__ ": Failed\n");
- return bt_ctrl.session[line].connect_status;
+ return retval;
}
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
/* sleep if not yet connected */
--- rfcomm.c 2001/10/10 14:58:18 1.123
+++ rfcomm.c 2001/10/12 12:03:22 1.124
@@ -58,6 +58,7 @@
#include <linux/bluetooth/l2cap.h>
#include <linux/bluetooth/bluetooth.h>
#include <linux/bluetooth/btconfig.h>
+#include <linux/bluetooth/bt_errno.h>
#else
#include <stdlib.h>
#include <string.h>
@@ -68,6 +69,7 @@
#include "include/l2cap.h"
#include "include/bluetooth.h"
#include "include/local.h"
+#include "include/bt_errno.h"
#endif
=20
/****************** DEBUG CONSTANT AND MACRO SECTION *********************=
***/
@@ -671,13 +673,14 @@
{
rfcomm_con *rfcomm;
u8 tmp_dlci;
+ s32 retval =3D 0;
=20=20=20
D_CTRL(FNC"server channel:%d, line:%d\n",
server_chn, line);
=20
if (!(rfcomm =3D get_rfcomm_con(line))) {
D_ERR(FNC"%d is an invalid line\n", line);
- return 0;
+ return -MSGCODE(MSG_LAYER_RFCOMM, RFCOMM_INVALID_LINE);
}
=20
if (rfcomm->dlci[0].state =3D=3D DISCONNECTED) {
@@ -693,13 +696,14 @@
rfcomm->dlci[0].state =3D CONNECTING;=20=20=20=20
=20
/* we don't have a l2cap connection yet */
- if (l2ca_connect_req(bd_addr, RFCOMM_LAYER)) {
+ if ((retval =3D l2ca_connect_req(bd_addr, RFCOMM_LAYER)) < 0) {
D_ERR(FNC"l2ca_connect_req failed\n");
- return -1;
+ return retval;
}
} else if (!((rfcomm->l2cap)->current_state =3D=3D OPEN)) {
=20
D_ERR(FNC"L2CAP_CON exists but is not in OPEN state (yet?)\n");
+ /* FIXME: Should we really return no error here? */
return 0;
} else if (rfcomm->dlci[0].state !=3D CONNECTED) {
=20
@@ -713,19 +717,19 @@
} else {
rfcomm->dlci[0].state =3D CONNECTING;
/* Establish the control channel */
- send_sabm(rfcomm, 0);
+ return send_sabm(rfcomm, 0);
}
} else if (rfcomm->dlci[tmp_dlci].state !=3D DISCONNECTED) {
=20
D_ERR(FNC"trying to connect a non DISCONNECTED server channel (%d)\n",se=
rver_chn);
- return 0;
+ return -MSGCODE(MSG_LAYER_RFCOMM, RFCOMM_SRVCHN_CONNECTED);
} else {
D_CTRL(FNC"We are negotiating rfcomm (pn msg)\n");
rfcomm->dlci[tmp_dlci].state =3D NEGOTIATING;
/* must fit i l2cap mtu */
D_CTRL(FNC"negotiate mtu : %d bytes\n",
rfcomm->l2cap->remote_mtu - 5);
- send_pn_msg(rfcomm, 7, rfcomm->dlci[tmp_dlci].mtu, 0, 0,
+ return send_pn_msg(rfcomm, 7, rfcomm->dlci[tmp_dlci].mtu, 0, 0,
tmp_dlci, TRUE);
}
=20
@@ -742,6 +746,11 @@
s32 tmp;
=20
D_CTRL("rfcomm_disconnect_req %d\n", line);
+ if(line >=3D BT_NBR_DATAPORTS) {
+ D_ERR("rfcomm_disconnect_req : Invalid line\n");
+ return -MSGCODE(MSG_LAYER_RFCOMM, RFCOMM_INVALID_LINE);
+ }
+=09
if (!(rfcomm =3D &rfcomm_con_list[line]))
{
D_ERR("rfcomm_disconnect_req : no rfcomm con\n");
@@ -1268,7 +1277,7 @@
#endif
D_REC(FNC"Local_credits:%d\n", rfcomm->dlci[tmp_dlci].local_credits);=
=20
uih_data_start++;
- if (short_pkt->h.length.len =3D=3D 0) {
+ if (uih_len =3D=3D 0) {
break;
}
=20=09=09=09
@@ -1330,7 +1339,7 @@
=20=09
if (dlci =3D=3D 0) {
D_ERR(FNC"Not allowed to send data on DLCI 0\n");
- return -1;
+ return -MSGCODE(MSG_LAYER_RFCOMM, RFCOMM_NO_DATA_ALLOWED);
}
=20=09
rfcomm =3D &rfcomm_con_list[line];
@@ -1338,17 +1347,15 @@
=20
if (rfcomm =3D=3D NULL) {
D_ERR(FNC" ERROR rfcomm_con =3D=3D NULL\n");
- return -1;
+ return -MSGCODE(MSG_LAYER_RFCOMM, RFCOMM_NO_CONNECTION);
} else if (rfcomm->magic !=3D RFCOMM_MAGIC) {
D_ERR(FNC"ERROR magic test failed\n");
- return -1;
+ return -MSGCODE(MSG_LAYER_RFCOMM, RFCOMM_BAD_MAGIC_NUMBER);
} else if(rfcomm->dlci[0].state =3D=3D FLOW_STOPPED) {
D_SND(FNC"Flow stopped on all channels, returning zero\n");
- /* FIXME: We need to buffer the incoming data here... */
return 0;
} else if (rfcomm->dlci[dlci].state =3D=3D FLOW_STOPPED) {
D_SND(FNC"Flow stopped, returning zero\n");
- /* FIXME: We need to buffer the incoming data here... */
return 0;
}
/* Check whether there are any data channels connected */
@@ -1665,7 +1672,7 @@
=20=09
if (!tx_buf) {
D_ERR("send_ua : didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
=20=09
tx_buf->cur_len =3D rfcomm_frame_size;
@@ -1706,7 +1713,7 @@
=20
if (!tx_buf) {
D_ERR("send_dm : didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
=20
tx_buf->cur_len =3D rfcomm_frame_size;
@@ -1745,7 +1752,7 @@
=20=09
if (!tx_buf) {
D_ERR("send_sabm : didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
=20
tx_buf->cur_len =3D rfcomm_frame_size;
@@ -1784,7 +1791,7 @@
=20
if (!tx_buf) {
D_ERR("send_disc : didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
=20
tx_buf->cur_len =3D rfcomm_frame_size;
@@ -1819,6 +1826,7 @@
bt_tx_buf *tx_buf;
u32 rfcomm_frame_size;
u8 send_credit =3D 0;
+ s32 retval =3D 0;
=20=09=09
D_CTRL(FNC"Creating UIH packet with %d bytes data to DLCI %d\n",
len, dlci);
@@ -1853,7 +1861,7 @@
+ rfcomm_frame_size);=20=20=20=20
if (!tx_buf) {
D_ERR(FNC"didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
tx_buf->cur_len =3D rfcomm_frame_size;
=20=20=20=20=20
@@ -1885,7 +1893,7 @@
+ rfcomm_frame_size);
if (!tx_buf) {
D_ERR(FNC"didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
tx_buf->cur_len =3D rfcomm_frame_size;
=20=20=20=20=20
@@ -1909,7 +1917,10 @@
/* FIXME - How should we propagate result up to higher layers ?
through len or success/no success? */
tx_buf->line =3D rfcomm->line;
- l2cap_send_data(tx_buf, rfcomm->l2cap);
+ if((retval =3D l2cap_send_data(tx_buf, rfcomm->l2cap)) < 0) {
+ return retval;
+ }
+=09
return len;
}
=20
@@ -1927,7 +1938,7 @@
=20
if (!tx_buf) {
D_ERR("rfcomm_fcon_msg : didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
=20
tx_buf->cur_len =3D rfcomm_frame_size;
@@ -1964,7 +1975,7 @@
+ rfcomm_frame_size);
if (!tx_buf) {
D_ERR("rfcomm_test_msg : didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
tx_buf->cur_len =3D rfcomm_frame_size;
uih_pkt =3D (long_frame*) (tx_buf->data + sizeof(rfcomm_tx_buf));
@@ -1996,7 +2007,7 @@
+ rfcomm_frame_size);
if (!tx_buf) {
D_ERR("rfcomm_test_msg : didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
=20=09=09
tx_buf->cur_len =3D rfcomm_frame_size;
@@ -2029,7 +2040,7 @@
+ rfcomm_frame_size);
if (!tx_buf) {
D_ERR("rfcomm_test_msg : didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
=20=09=09
tx_buf->cur_len =3D rfcomm_frame_size;
@@ -2071,7 +2082,7 @@
=20
if (!tx_buf) {
D_ERR("rfcomm_fcon_msg : didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
=20
tx_buf->cur_len =3D rfcomm_frame_size;
@@ -2108,7 +2119,7 @@
=20
if (!tx_buf) {
D_ERR("rfcomm_fcoff_msg : didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
=20
tx_buf->cur_len =3D rfcomm_frame_size;
@@ -2149,7 +2160,7 @@
=20
if (!tx_buf) {
D_ERR("rfcomm_rpn_msg : didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
=20
tx_buf->cur_len =3D rfcomm_frame_size;
@@ -2198,7 +2209,7 @@
=20
if (!tx_buf) {
D_ERR("rfcomm_rls_msg : didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
=20
tx_buf->cur_len =3D rfcomm_frame_size;
@@ -2242,7 +2253,7 @@
=20
if (!tx_buf) {
D_ERR("send_pn_msg : didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
=20
tx_buf->cur_len =3D rfcomm_frame_size;
@@ -2292,7 +2303,7 @@
=20
if (!tx_buf) {
D_ERR("send_nsc_msg : didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
=20
tx_buf->cur_len =3D rfcomm_frame_size;
@@ -2330,7 +2341,7 @@
=20
if (!tx_buf) {
D_ERR(FNC"didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
=20
tx_buf->cur_len =3D rfcomm_frame_size;
@@ -2398,6 +2409,9 @@
rfcomm_con*=20
get_rfcomm_con(u8 line)
{
+ if(line >=3D BT_NBR_DATAPORTS) {
+ return NULL;
+ }
return &rfcomm_con_list[line];
}
=20
@@ -2553,7 +2567,7 @@
=20
if (!tx_buf) {
D_ERR(FNC"didn't get a valid tx_buf\n");
- return -1;
+ return -ENOMEM;
}
=20
tx_buf->cur_len =3D rfcomm_frame_size;
|