|
From: Anders J. <and...@us...> - 2003-02-06 15:36:53
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
bluetooth.c 1.236 1.237=20=20=20=20=20=20=20=20=20=20=20=20=20
hci.c 1.207 1.208=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
get_remote_name and get_remote_bd now uses hci_hdl to refer to a connection
as bt_ctrl.session[line] !=3D hci_ctrl[line] !!=20=20
The diff of the modified file(s):
--- bluetooth.c 13 Jan 2003 19:48:26 -0000 1.236
+++ bluetooth.c 6 Feb 2003 15:36:20 -0000 1.237
@@ -546,7 +546,7 @@
s32 err =3D 0;
s32 size =3D _IOC_SIZE(cmd);
bt_connection btcon;
- u8 bd_addr[6];
+ u8 bd_addr[6] =3D {0, 0, 0, 0, 0, 0};
#ifdef CONFIG_BLUETOOTH_SUPPORT_BCSP
static u8 dfu_data[2044];
#endif
@@ -693,13 +693,20 @@
{
BD_ADDR rev_bd;
s32 line;
- u16 i;
+ s32 i;
=20
BT_DRIVER(__FUNCTION__ ": BTREADREMOTEBDADDR\n");
=20
copy_from_user(&line, (s32*)arg, size);
=20
- err =3D get_remote_bd(line, bd_addr);
+ /* Get the session for this line */
+ i =3D bt_get_conhdl_from_line(line);
+=09=09
+ if(i >=3D 0) {
+ err =3D get_remote_bd(i, bd_addr);
+ } else {
+ err =3D -EINVAL;
+ }
=20
/* return as big endian */
for (i =3D 0; i < 6; i++) {
@@ -729,14 +736,21 @@
u8 remote_name[BT_NAME_LENGTH];
s32 line;
u32 length;
+ s32 con_hdl;
=20
BT_DRIVER(__FUNCTION__ ": BTREADREMOTENAME\n");
=20
+ memset(remote_name, 0, BT_NAME_LENGTH);
+
copy_from_user(&line, (s32*)arg, sizeof line);
copy_from_user(&length, (s32*)arg + 1, sizeof length);
=20
- err =3D get_remote_name(line, remote_name, length);
-
+ con_hdl =3D bt_get_conhdl_from_line(line);
+ if(con_hdl >=3D 0) {
+ err =3D get_remote_name(con_hdl, remote_name, length);
+ } else {
+ err =3D -EINVAL;
+ }
copy_to_user((s32*)arg, remote_name, BT_NAME_LENGTH);
return err;
}
@@ -3226,6 +3240,25 @@
=20
return pos;
}
+
+s32
+bt_get_conhdl_from_line(s32 line)=20
+{
+ rfcomm_con *con;
+=09
+ if(line >=3D BT_NBR_DATAPORTS) {
+ return -1;
+ }
+
+ con =3D bt_ctrl.session[line].rfcomm;
+=09
+ if(con && con->l2cap) {
+ return (*(con->l2cap)).hci_hdl;
+ }
+
+ return -1;
+}
+
=20
/*
* FIXME -- make this register function more general i.e
--- hci.c 13 Jan 2003 19:48:30 -0000 1.207
+++ hci.c 6 Feb 2003 15:36:20 -0000 1.208
@@ -3328,22 +3328,29 @@
/* Consider changing bd to BD_ADDR */
=20
s32
-get_remote_bd(s32 line, u8 *bd)
+get_remote_bd(u16 con_hdl, u8 *bd)
{
+ u32 i;
D_CMD(__FUNCTION__ "\n");
=20
+ for (i =3D 0 ; i < MAX_NBR_OF_CONNECTIONS ; i ++) {
+ if (hci_ctrl.con[i].con_hdl =3D=3D con_hdl) {
+ break;
+ }
+ }
+
memset(bd, 0, 6);
=20
- if (line >=3D 0 && line < MAX_NBR_OF_CONNECTIONS) {
- if (hci_ctrl.con[line].state !=3D NOT_CONNECTED) {
- memcpy(bd, hci_ctrl.con[line].bd, 6);
+ if (i >=3D 0 && i < MAX_NBR_OF_CONNECTIONS) {
+ if (hci_ctrl.con[i].state !=3D NOT_CONNECTED) {
+ memcpy(bd, hci_ctrl.con[i].bd, 6);
}
DSYS(__FUNCTION__ ": %02x:%02x:%02x:%02x:%02x:%02x\n",
bd[5], bd[4], bd[3], bd[2], bd[1], bd[0]);
return 0;
} else {
/* No connection yet */
- D_WARN(__FUNCTION__ ": Unknown line: %d!\n", line);
+ D_WARN(__FUNCTION__ ": Can't find connection with hci_hdl: %d!\n", con_h=
dl);
return -EINVAL;
}
}
@@ -3353,19 +3360,26 @@
*/
=20
s32
-get_remote_name(s32 line, u8 *name, u32 length)
+get_remote_name(u16 con_hdl, u8 *name, u32 length)
{
+ u32 i;
D_CMD(__FUNCTION__ "\n");
=20
- if (line >=3D 0 && line < MAX_NBR_OF_CONNECTIONS) {
+ for (i =3D 0 ; i < MAX_NBR_OF_CONNECTIONS ; i ++) {
+ if (hci_ctrl.con[i].con_hdl =3D=3D con_hdl) {
+ break;
+ }
+ }
+
+ if (i >=3D 0 && i < MAX_NBR_OF_CONNECTIONS) {
memset(name, '\0', min(length, BT_NAME_LENGTH));
- if (hci_ctrl.con[line].state !=3D NOT_CONNECTED) {
- strncpy(name, hci_ctrl.con[line].name, min(length, BT_NAME_LENGTH)-1);
+ if (hci_ctrl.con[i].state !=3D NOT_CONNECTED) {
+ strncpy(name, hci_ctrl.con[i].name, min(length, BT_NAME_LENGTH)-1);
}
return 0;
} else {
/* No connection yet */
- D_WARN(__FUNCTION__ ": Unknown line: %d!\n", line);
+ D_WARN(__FUNCTION__ ": Unknown hci_hdl: %d!\n", con_hdl);
return -EINVAL;
}
}
|