|
From: Peter K. <pk...@us...> - 2002-11-19 14:13:11
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
bluetooth.c 1.234 1.235=20=20=20=20=20=20=20=20=20=20=20=20=20
hci.c 1.205 1.206=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added BTREADREMOTENAME ioctl to get the Bluetooth name of a remote client.
The diff of the modified file(s):
--- bluetooth.c 1 Nov 2002 10:30:16 -0000 1.234
+++ bluetooth.c 19 Nov 2002 14:13:10 -0000 1.235
@@ -1,7 +1,7 @@
/*
* bluetooth.c -- Linux kernel integration code for bluetooth stack
*
- * Copyright (C) 2000, 2001 Axis Communications AB
+ * Copyright (C) 2000, 2001, 2002 Axis Communications AB
*
* Author: Mattias Agren <mat...@ax...>
*
@@ -631,9 +631,8 @@
=20
case BTDISCONNECT_BB:
{
- /* Disconnect the BB connection (Consafe)=20
- The bd_addr is reversed=20
- */
+ /* Disconnect the BB connection
+ The bd_addr is reversed */
u8 bd_addr[6];
l2cap_con *con_str;
=20
@@ -643,8 +642,7 @@
bd_addr[0], bd_addr[1], bd_addr[2],
bd_addr[3], bd_addr[4], bd_addr[5]);
=20=09=09
- if ((con_str =3D get_con(bd_addr, ANY_STATE))=3D=3D NULL)=20
- {
+ if (!(con_str =3D get_con(bd_addr, ANY_STATE))) {
D_ERR(__FUNCTION__ ": couldn't find l2cap con!\n");
return -MSGCODE(MSG_BT_INTERFACE, BT_NOTCONNECTED);
}
@@ -701,14 +699,31 @@
=20
copy_from_user(&line, (s32*)arg, size);
=20
- get_remote_bd(line, bd_addr);
+ err =3D get_remote_bd(line, bd_addr);
=20
/* return as big endian */
for (i =3D 0; i < 6; i++) {
rev_bd[5-i] =3D bd_addr[i];
}
copy_to_user((s32*)arg, rev_bd, 6);
- break;
+ return err;
+ }
+
+ case BTREADREMOTENAME:
+ {
+ u8 remote_name[BT_NAME_LENGTH];
+ s32 line;
+ u32 length;
+
+ BT_DRIVER(__FUNCTION__ ": BTREADREMOTENAME\n");
+
+ copy_from_user(&line, (s32*)arg, sizeof line);
+ copy_from_user(&length, (s32*)arg + 1, sizeof length);
+
+ err =3D get_remote_name(line, remote_name, length);
+
+ copy_to_user((s32*)arg, remote_name, BT_NAME_LENGTH);
+ return err;
}
=20
case BTRESETPHYSICALHW:
@@ -729,8 +744,8 @@
break;
=20
case BTSENDTESTDATA:
- copy_from_user(&tmp, (s32*)arg, 4);
- copy_from_user(&utmp, (s32*)arg + 1, 4);
+ copy_from_user(&tmp, (s32*)arg, sizeof tmp);
+ copy_from_user(&utmp, (s32*)arg + 1, sizeof utmp);
rfcomm_send_testdata(tmp, utmp);
break;
=20
--- hci.c 15 Nov 2002 12:13:29 -0000 1.205
+++ hci.c 19 Nov 2002 14:13:10 -0000 1.206
@@ -3335,14 +3335,38 @@
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);
+ }
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);
- return -1;
+ return -EINVAL;
+ }
+}
+
+/*
+ * This function will return the remote name for a specific line
+ */
+
+s32
+get_remote_name(s32 line, u8 *name, u32 length)
+{
+ D_CMD(__FUNCTION__ "\n");
+
+ if (line >=3D 0 && line < 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);
+ }
+ return 0;
+ } else {
+ /* No connection yet */
+ D_WARN(__FUNCTION__ ": Unknown line: %d!\n", line);
+ return -EINVAL;
}
}
=20
|