|
From: Peter K. <pk...@us...> - 2001-03-06 10:12:10
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bluetooth.c 1.138 1.139=20=20=20=20=20=20=20=20=20=20=20
sdp.c 1.64 1.65=20=20=20=20=20=20=20=20=20=20=20=20
sec_client.c 1.13 1.14=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Removed checks to see if KERNEL_VERSION() is defined, as it is now
guaranteed to be available.
The diff of the modified file(s):
--- bluetooth.c 2001/03/05 23:08:39 1.138
+++ bluetooth.c 2001/03/06 10:13:49 1.139
@@ -1926,7 +1926,6 @@
#ifdef CONFIG_BLUETOOTH_PROC
DSYS("Registering BT proc files\n");
=20=20
-#ifdef KERNEL_VERSION /* Not defined for kernel 2.0.x */
#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
{
procfs_status =3D -1;
@@ -1941,17 +1940,12 @@
#else
procfs_status =3D proc_register_dynamic(&proc_root, &bt_status);
#endif /* LINUX_VERSION_CODE */
-#else /* KERNEL_VERSION */
=20
- procfs_status =3D proc_register_dynamic(&proc_root, &bt_status);
-#endif/* KERNEL_VERSION */
-
if (procfs_status < 0) {
D_ERR("Couldn't register proc file bt_status %d\n",=20
procfs_status);
}
=20=09
-#ifdef KERNEL_VERSION /* Not defined for kernel 2.0.x */
#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
{
procfs_status =3D -1;
@@ -1966,16 +1960,12 @@
#else
procfs_status =3D proc_register_dynamic(&proc_root, &bt_internal_info);
#endif /* LINUX_VERSION_CODE */
-#else /* KERNEL_VERSION */
- procfs_status =3D proc_register_dynamic(&proc_root, &bt_internal_info);
-#endif/* KERNEL_VERSION */
=20
if (procfs_status < 0) {
D_ERR("Couldn't register proc file bt_internal_info %d\n",
procfs_status);
}
=20
-#ifdef KERNEL_VERSION /* Not defined for kernel 2.0.x */
#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
{
struct proc_dir_entry *entry;
@@ -1997,9 +1987,6 @@
#else
procfs_status =3D proc_register_dynamic(&proc_root, &sdp_proc_entry);
#endif /* LINUX_VERSION_CODE */
-#else /* KERNEL_VERSION */
- procfs_status =3D proc_register_dynamic(&proc_root, &sdp_proc_entry);
-#endif/* KERNEL_VERSION */
=20
if (procfs_status < 0) {
D_ERR("Couldn't register proc file for sdp database %d\n",
@@ -2007,7 +1994,6 @@
}
=20
#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER
-#ifdef KERNEL_VERSION /* Not defined for kernel 2.0.x */
#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
{
struct proc_dir_entry *entry;
@@ -2030,9 +2016,6 @@
#else
procfs_status =3D proc_register_dynamic(&proc_root, &sec_man_proc_entry);
#endif /* LINUX_VERSION_CODE */
-#else /* KERNEL_VERSION */
- procfs_status =3D proc_register_dynamic(&proc_root, &sec_man_proc_entry);
-#endif/* KERNEL_VERSION */
=20
if (procfs_status < 0) {
D_ERR("Couldn't register proc file for security manager %d\n",
@@ -2040,7 +2023,6 @@
}
#endif /* CONFIG_BLUETOOTH_USE_SECURITY_MANAGER */
=20
-#ifdef KERNEL_VERSION /* Not defined for kernel 2.0.x */
#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
{
procfs_status =3D -1;
@@ -2055,18 +2037,13 @@
#else
procfs_status =3D proc_register_dynamic(&proc_root, &bt_proc_doit);
#endif /* LINUX_VERSION_CODE */
-#else /* KERNEL_VERSION */
=20
- procfs_status =3D proc_register_dynamic(&proc_root, &bt_proc_doit);
-#endif/* KERNEL_VERSION */
-
if (procfs_status < 0) {
D_ERR("Couldn't register proc file bt_status %d\n",=20
procfs_status);
}
=20
#ifdef CONFIG_BLUETOOTH_USE_TCI
-#ifdef KERNEL_VERSION /* Not defined for kernel 2.0.x */
#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
{
procfs_status =3D -1;
@@ -2081,9 +2058,6 @@
#else
procfs_status =3D proc_register_dynamic(&proc_root, &tci_proc_entry);
#endif /* LINUX_VERSION_CODE */
-#else /* KERNEL_VERSION */
- procfs_status =3D proc_register_dynamic(&proc_root, &tci_proc_entry);
-#endif/* KERNEL_VERSION */
=20
if (procfs_status < 0) {
D_ERR("Couldn't register proc file for tci database %d\n",
--- sdp.c 2001/03/04 15:56:54 1.64
+++ sdp.c 2001/03/06 10:13:49 1.65
@@ -99,10 +99,8 @@
=20
/****************** CONSTANT AND MACRO SECTION ***************************=
***/
=20
-#ifdef KERNEL_VERSION /* Not defined for kernel 2.0.x */
#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,2,14)
#define USE_NEW_PROC
-#endif
#endif
=20
#ifndef __KERNEL__
--- sec_client.c 2001/03/05 15:52:52 1.13
+++ sec_client.c 2001/03/06 10:13:49 1.14
@@ -88,10 +88,8 @@
=20
/****************** CONSTANT AND MACRO SECTION ***************************=
***/
=20
-#ifdef KERNEL_VERSION /* Not defined for kernel 2.0.x */
#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,2,14)
#define USE_NEW_PROC
-#endif
#endif
=20
#ifndef __KERNEL__
|
|
From: Peter K. <pk...@us...> - 2001-03-06 11:02:37
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bluetooth.c 1.139 1.140=20=20=20=20=20=20=20=20=20=20=20
sdp.c 1.65 1.66=20=20=20=20=20=20=20=20=20=20=20=20
sec_client.c 1.14 1.15=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Moved creation of the sdp_srv and the sec_srv proc-files to
sdp.c and sec_client.c. Also made sure they are always created
independent of CONFIG_BLUETOOTH_PROC.
* Initialise the wait queues for the sdp_srv and the sec_srv proc-files
before the files are created.
The diff of the modified file(s):
--- bluetooth.c 2001/03/06 10:13:49 1.139
+++ bluetooth.c 2001/03/06 11:04:15 1.140
@@ -1923,9 +1923,9 @@
=20=09
sertty =3D NULL;
=20
-#ifdef CONFIG_BLUETOOTH_PROC
DSYS("Registering BT proc files\n");
=20=20
+#ifdef CONFIG_BLUETOOTH_PROC
#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
{
procfs_status =3D -1;
@@ -1968,64 +1968,7 @@
=20
#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
{
- struct proc_dir_entry *entry;
- procfs_status =3D -1;
- if ((entry =3D create_proc_entry(sdp_proc_entry.name,
- sdp_proc_entry.mode,
- &proc_root))) {
- /*---------------------------------------------------*/
- /* If the proc entry was registered successfully, */
- /* then set all the necessary structure information. */
- /*---------------------------------------------------*/
- entry->proc_iops =3D sdp_proc_entry.proc_iops;
- entry->proc_fops =3D sdp_proc_entry.proc_fops;
- procfs_status =3D 1;
- }
- }
-#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,2,0)
- procfs_status =3D proc_register(&proc_root, &sdp_proc_entry);
-#else
- procfs_status =3D proc_register_dynamic(&proc_root, &sdp_proc_entry);
-#endif /* LINUX_VERSION_CODE */
-
- if (procfs_status < 0) {
- D_ERR("Couldn't register proc file for sdp database %d\n",
- procfs_status);
- }
-
-#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER
-#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
- {
- struct proc_dir_entry *entry;
procfs_status =3D -1;
- if ((entry =3D create_proc_entry(sec_man_proc_entry.name,
- sec_man_proc_entry.mode,
- &proc_root))) {
- /*---------------------------------------------------*/
- /* If the proc entry was registered successfully, */
- /* then set all the necessary structure information. */
- /*---------------------------------------------------*/
- entry->proc_iops =3D sec_man_proc_entry.proc_iops;
- entry->proc_fops =3D sec_man_proc_entry.proc_fops;
- entry->get_info =3D sec_man_proc_entry.get_info;
- procfs_status =3D 1;
- }
- }
-#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,2,0)
- procfs_status =3D proc_register(&proc_root, &sec_man_proc_entry);
-#else
- procfs_status =3D proc_register_dynamic(&proc_root, &sec_man_proc_entry);
-#endif /* LINUX_VERSION_CODE */
-
- if (procfs_status < 0) {
- D_ERR("Couldn't register proc file for security manager %d\n",
- procfs_status);
- }
-#endif /* CONFIG_BLUETOOTH_USE_SECURITY_MANAGER */
-
-#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
- {
- procfs_status =3D -1;
if (create_proc_info_entry(bt_proc_doit.name,
bt_proc_doit.mode,
&proc_root,
@@ -2042,6 +1985,7 @@
D_ERR("Couldn't register proc file bt_status %d\n",=20
procfs_status);
}
+#endif /* CONFIG_BLUETOOTH_PROC */
=20
#ifdef CONFIG_BLUETOOTH_USE_TCI
#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
@@ -2065,7 +2009,11 @@
}
#endif /* CONFIG_BLUETOOTH_USE_TCI */
=20=09
-#endif /* CONFIG_BLUETOOTH_PROC */
+ sdp_create_proc_file();
+
+#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER
+ sec_man_create_proc_file();
+#endif
=20
DSYS("Bluetooth Driver Using ttyBT[0-%d] (data), ttyBTC (ctrl [%d])\n",
BT_NBR_DATAPORTS-1, BT_NBR_PORTS-1);
@@ -2618,26 +2566,23 @@
if (bt_stack_initiated)
bt_shutdown();
=20=09
+#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER
+ sec_man_remove_proc_file();
+#endif
+ sdp_remove_proc_file();
+=09
#ifdef CONFIG_BLUETOOTH_PROC
#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
remove_proc_entry(bt_status.name, &proc_root);
remove_proc_entry(bt_internal_info.name, &proc_root);
- remove_proc_entry(sdp_proc_entry.name, &proc_root);
remove_proc_entry(bt_proc_doit.name, &proc_root);
-#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER
- remove_proc_entry(sec_man_proc_entry.name, &proc_root);
-#endif /* CONFIG_BLUETOOTH_USE_SECURITY_MANAGER */
#ifdef CONFIG_BLUETOOTH_USE_TCI
remove_proc_entry(tci_proc_entry.name, &proc_root);
#endif /* CONFIG_BLUETOOTH_USE_TCI */
#else
proc_unregister(&proc_root, bt_status.low_ino);
proc_unregister(&proc_root, bt_internal_info.low_ino);
- proc_unregister(&proc_root, sdp_proc_entry.low_ino);
proc_unregister(&proc_root, bt_proc_doit.low_ino);
-#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER
- proc_unregister(&proc_root, sec_man_proc_entry.low_ino);
-#endif /* CONFIG_BLUETOOTH_USE_SECURITY_MANAGER */
#ifdef CONFIG_BLUETOOTH_USE_TCI
proc_unregister(&proc_root, tci_proc_entry.low_ino);
#endif /* CONFIG_BLUETOOTH_USE_TCI */
--- sdp.c 2001/03/06 10:13:49 1.65
+++ sdp.c 2001/03/06 11:04:15 1.66
@@ -225,7 +225,7 @@
* proc directories can do almost nothing..
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
-struct inode_operations sdp_proc_inode_operations =3D {
+static struct inode_operations sdp_proc_inode_operations =3D {
&sdp_procfile_operation, /* default net file-ops */
NULL, /* create */
NULL, /* lookup */
@@ -245,7 +245,7 @@
NULL /* permission */
};
#else
-struct inode_operations sdp_proc_inode_operations =3D {
+static struct inode_operations sdp_proc_inode_operations =3D {
NULL, /* create */
NULL, /* lookup */
NULL, /* link */
@@ -266,7 +266,7 @@
#endif
=20
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
-struct proc_dir_entry sdp_proc_entry =3D {
+static struct proc_dir_entry sdp_proc_entry =3D {
0,
7, "sdp_srv",
S_IFREG | S_IRUGO | S_IWUSR,
@@ -276,7 +276,7 @@
sdp_proc_dir_entry_read,
};
#else
-struct proc_dir_entry sdp_proc_entry =3D {
+static struct proc_dir_entry sdp_proc_entry =3D {
0,
7, "sdp_srv",
S_IFREG | S_IRUGO | S_IWUSR,
@@ -348,7 +348,7 @@
printf("Socket connected to %s\n", server_address.sun_path);
return client_sockfd;
}
-#endif
+#endif /* !__KERNEL__ */
=20
void=20
sdp_init(s32 srv)
@@ -393,16 +393,6 @@
DSYS(__FUNCTION__ ", Init sdp as client\n");
role =3D 0;
}
-
-#ifdef __KERNEL__
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
- database_wq =3D NULL;
- sdp_disc_wq =3D NULL;
-#else
- init_waitqueue_head(&database_wq);
- init_waitqueue_head(&sdp_disc_wq);
-#endif /* LINUX_VERSION_CODE */
-#endif /* __KERNEL__ */
}
=20
void=20
@@ -417,6 +407,62 @@
}
}=20=20
}
+
+#ifdef __KERNEL__
+s32
+sdp_create_proc_file()
+{
+ s32 procfs_status =3D -ENOENT;
+
+ /* The database_wq wait queue must be initialised before anyone tries
+ to read from the /proc/sdp_srv file, so we initialise the wait
+ queues here */
+#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
+ init_waitqueue_head(&database_wq);
+ init_waitqueue_head(&sdp_disc_wq);
+#endif /* LINUX_VERSION_CODE */
+
+#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
+ {
+ struct proc_dir_entry *entry;
+
+ if ((entry =3D create_proc_entry(sdp_proc_entry.name,
+ sdp_proc_entry.mode,
+ &proc_root))) {
+ /*---------------------------------------------------*/
+ /* If the proc entry was registered successfully, */
+ /* then set all the necessary structure information. */
+ /*---------------------------------------------------*/
+ entry->proc_iops =3D sdp_proc_entry.proc_iops;
+ entry->proc_fops =3D sdp_proc_entry.proc_fops;
+ procfs_status =3D 0;
+ }
+ }
+#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,2,0)
+ procfs_status =3D proc_register(&proc_root, &sdp_proc_entry);
+#else
+ procfs_status =3D proc_register_dynamic(&proc_root, &sdp_proc_entry);
+#endif /* LINUX_VERSION_CODE */
+
+ if (procfs_status < 0) {
+ D_ERR("Couldn't register proc file for sdp database %d\n",
+ procfs_status);
+ }
+
+ return procfs_status;
+}
+
+s32
+sdp_remove_proc_file()
+{
+#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
+ remove_proc_entry(sdp_proc_entry.name, &proc_root);
+#else
+ proc_unregister(&proc_root, sdp_proc_entry.low_ino);
+#endif
+ return 0;
+}
+#endif /* __KERNEL__ */
=20
s32=20
sdp_connect_req(u8* bd_addr, u8 line)
--- sec_client.c 2001/03/06 10:13:49 1.14
+++ sec_client.c 2001/03/06 11:04:15 1.15
@@ -167,7 +167,7 @@
*/
=20
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
-struct inode_operations sec_man_proc_inode_operations =3D {
+static struct inode_operations sec_man_proc_inode_operations =3D {
&sec_man_procfile_operation, /* default net file-ops */
NULL, /* create */
NULL, /* lookup */
@@ -187,7 +187,7 @@
NULL /* permission */
};
#else
-struct inode_operations sec_man_proc_inode_operations =3D {
+static struct inode_operations sec_man_proc_inode_operations =3D {
NULL, /* create */
NULL, /* lookup */
NULL, /* link */
@@ -208,7 +208,7 @@
#endif
=20
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
-struct proc_dir_entry sec_man_proc_entry =3D {
+static struct proc_dir_entry sec_man_proc_entry =3D {
0,
7, "sec_srv",
S_IFREG | S_IRUGO | S_IWUSR,
@@ -218,7 +218,7 @@
sec_man_proc_dir_entry_read,
};
#else
-struct proc_dir_entry sec_man_proc_entry =3D {
+static struct proc_dir_entry sec_man_proc_entry =3D {
0,
7, "sec_srv",
S_IFREG | S_IRUGO | S_IWUSR,
@@ -263,6 +263,62 @@
/* To indicate that nothing is ready */
security_query.originator =3D SEC_CLIENT;=20
}
+
+#ifdef __KERNEL__
+s32
+sec_man_create_proc_file()
+{
+ s32 procfs_status =3D -ENOENT;
+
+ /* The sec_man_wq wait queue must be initialised before anyone tries
+ to read from the /proc/sec_srv file, so we initialise the wait
+ queue here */
+#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
+ init_waitqueue_head(&sec_man_wq);
+#endif /* LINUX_VERSION_CODE */
+
+#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
+ {
+ struct proc_dir_entry *entry;
+ procfs_status =3D -1;
+ if ((entry =3D create_proc_entry(sec_man_proc_entry.name,
+ sec_man_proc_entry.mode,
+ &proc_root))) {
+ /*---------------------------------------------------*/
+ /* If the proc entry was registered successfully, */
+ /* then set all the necessary structure information. */
+ /*---------------------------------------------------*/
+ entry->proc_iops =3D sec_man_proc_entry.proc_iops;
+ entry->proc_fops =3D sec_man_proc_entry.proc_fops;
+ entry->get_info =3D sec_man_proc_entry.get_info;
+ procfs_status =3D 0;
+ }
+ }
+#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,2,0)
+ procfs_status =3D proc_register(&proc_root, &sec_man_proc_entry);
+#else
+ procfs_status =3D proc_register_dynamic(&proc_root, &sec_man_proc_entry);
+#endif /* LINUX_VERSION_CODE */
+
+ if (procfs_status < 0) {
+ D_ERR("Couldn't register proc file for security manager %d\n",
+ procfs_status);
+ }
+
+ return procfs_status;
+}
+
+s32
+sec_man_remove_proc_file()
+{
+#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
+ remove_proc_entry(sec_man_proc_entry.name, &proc_root);
+#else
+ proc_unregister(&proc_root, sec_man_proc_entry.low_ino);
+#endif
+ return 0;
+}
+#endif /* __KERNEL__ */
=20
/* fixme -- add return value for calling functions to indicate status of=
=20
check */
|
|
From: Mattias A. <mat...@us...> - 2001-04-17 10:00:26
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
hci_vendor.c 1.21 1.22=20=20=20=20=20=20=20=20=20=20=20=20
rfcomm.c 1.100 1.101=20=20=20=20=20=20=20=20=20=20=20
sdp.c 1.73 1.74=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
use kernel wait queue structs when doing busywait in usermode stack
(emulates blocking calls with usermode stack define of interuptible_sleep_on
and wake_up_interruptible in btcommon.h)
The diff of the modified file(s):
--- hci_vendor.c 2001/04/10 13:04:24 1.21
+++ hci_vendor.c 2001/04/17 10:00:26 1.22
@@ -88,7 +88,6 @@
/* These are declared in hci.c */
extern cmd_pkt c_pkt;
=20
-#if __KERNEL__
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
extern struct wait_queue *hci_wq;
extern struct wait_queue *set_baudrate_wq;
@@ -96,7 +95,6 @@
extern wait_queue_head_t hci_wq;
extern wait_queue_head_t set_baudrate_wq;
#endif /* LINUX_VERSION_CODE */
-#endif /* __KERNEL__ */
=20
extern hci_controller hci_ctrl;
=20
--- rfcomm.c 2001/04/12 16:25:58 1.100
+++ rfcomm.c 2001/04/17 10:00:26 1.101
@@ -544,8 +544,8 @@
/* One RFCOMM connection for each bt_tty 0 to 6 */
=20
#ifdef __KERNEL__
-
static struct timer_list rfcomm_timer;
+#endif
#define RFCOMM_CON_TIMEOUT (5*HZ)
=20
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
@@ -554,9 +554,6 @@
static wait_queue_head_t rfcomm_disconnect_wq;
#endif /* LINUX_VERSION_CODE */
=20
-#else
-static int rfcomm_disconnect_wq;
-#endif /* __KERNEL__ */
=20
void send_send_data(unsigned long ptr);
=20
@@ -687,7 +684,17 @@
=20=20=20
DSYS("Shutting down RFCOMM\n");
=20
- /* Reset rfcomm lines */
+#if 0
+ /* First try disconnecting */
+ for (i =3D 0; i < BT_NBR_DATAPORTS; i++) {
+ rfcomm_con *rfcomm =3D get_rfcomm_con(i);
+ if (get_connected_dlci(rfcomm) !=3D -1) {
+ DSYS("Now disconnecting rfcomm line %d\n", i);
+ rfcomm_disconnect_req(i);
+ }=09=09
+ }
+#endif
+ /* If still connections left, terminate them */
for (i =3D 0; i < BT_NBR_DATAPORTS; i++) {
rfcomm_reset_con(i);
}
--- sdp.c 2001/04/17 07:00:49 1.73
+++ sdp.c 2001/04/17 10:00:26 1.74
@@ -307,13 +307,11 @@
/* Transaction id used for request */
//static u16 req_trans_id =3D 0xaabb;
=20
-#ifdef __KERNEL__
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
static struct wait_queue *sdp_disc_wq =3D NULL;
#else
static wait_queue_head_t sdp_disc_wq;
#endif /* LINUX_VERSION_CODE */
-#endif /* __KERNEL__ */
=20
#ifdef __KERNEL__
static bt_tx_buf *db_write_tx_buf;
|
|
From: Peter K. <pk...@us...> - 2001-04-17 16:05:12
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bluetooth.c 1.164 1.165=20=20=20=20=20=20=20=20=20=20=20
bt_proc.c 1.20 1.21=20=20=20=20=20=20=20=20=20=20=20=20
hci_vendor.c 1.22 1.23=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Clean-up of functions to get HW vendor and firmware version.
The diff of the modified file(s):
--- bluetooth.c 2001/04/17 12:07:57 1.164
+++ bluetooth.c 2001/04/17 16:05:11 1.165
@@ -183,6 +183,7 @@
static void bt_handle_indata(const __u8 *data, s32 count);
#endif
=20
+static void bt_show_version(void);
static void bt_init_stack(void);
static s32 bt_ctrl_init(void);
static s32 bt_connect(u8 *bd_addr, u32 con_id);
@@ -272,6 +273,7 @@
static struct termios *bt_termios[BT_NBR_PORTS];=20
static struct termios *bt_termios_locked[BT_NBR_PORTS];
=20
+#ifdef BT_USELINEBUF
/* temp buffer used to store data received at upper tty when line is not=
=20
active yet */
=20
@@ -286,6 +288,7 @@
} tty_linebuffer;
=20
static tty_linebuffer tty_linebuf;
+#endif /* BT_USELINEBUF */
=20
static struct timer_list bt_timer;
=20
@@ -703,7 +706,7 @@
extern void test_process_cmd(unsigned char *cmd, s32 size);
u8 cmd[size];
copy_from_user(cmd, (s32*)arg, size);
- printk("TEST_COMMAND ", cmd, size);
+ printk("TEST_COMMAND %d %d\n", cmd, size);
test_process_cmd(cmd, size);
}
=20
@@ -1977,7 +1980,7 @@
s32 procfs_status =3D -1;
#endif
=20
- show_bt_version();
+ bt_show_version();
=20
/* Initialize the tty_driver structure */
=20=09
@@ -2170,6 +2173,12 @@
return 0; /*success*/
}
=20
+static void
+bt_show_version(void)
+{
+ printk("Bluetooth Driver v1.3, Copyright (c) 2000, 2001 Axis Communicatio=
ns AB\n");
+}
+
s32
bt_initiated()
{
@@ -2205,7 +2214,7 @@
=20=09
DSYS("Initialising Bluetooth Stack\n");
=20
- show_bt_vendor();
+ bt_show_vendor();
hci_init();
l2cap_init();
=20
@@ -2317,12 +2326,6 @@
bt_ctrl.session[line].rfcomm =3D NULL;
bt_ctrl.session[line].dlci =3D 0;=20
bt_ctrl.session[line].state =3D BT_INACTIVE;
-}
-
-void
-show_bt_version(void)
-{
- printk("Bluetooth Driver v1.2, Copyright (c) 2000 Axis Communications AB\=
n");
}
=20
u8 *statename(s32 state)
--- bt_proc.c 2001/03/02 21:52:15 1.20
+++ bt_proc.c 2001/04/17 16:05:11 1.21
@@ -151,11 +151,8 @@
=20
/* HW Info */
len +=3D sprintf(buf + len, "\n[Hardware]\n");
- len +=3D sprintf(buf + len, " %s ",
- get_hw_name());
-=09
- len +=3D sprintf(buf + len, "firmware info: %s\n",=20
- (char*)&bt_hw_firmware_info);
+ len +=3D sprintf(buf + len, "Vendor: %s\n", bt_hw_vendor());
+ len +=3D sprintf(buf + len, "Firmware info: %s\n", bt_hw_firmware());
=20=09
/* print all active sessions */
=20
--- hci_vendor.c 2001/04/17 10:00:26 1.22
+++ hci_vendor.c 2001/04/17 16:05:11 1.23
@@ -83,6 +83,8 @@
/* Digianswer defines */
#endif
=20
+#define BT_HW_INFO_MAX 255
+
/****************** LOCAL VARIABLE DECLARATION SECTION *******************=
***/
=20
/* These are declared in hci.c */
@@ -98,7 +100,7 @@
=20
extern hci_controller hci_ctrl;
=20
-u8 bt_hw_firmware_info[255];
+static u8 bt_hw_firmware_info[BT_HW_INFO_MAX+1];
=20
/****************** FUNCTION DEFINITION SECTION **************************=
***/
=20
@@ -214,12 +216,11 @@
=20=20=20=20=20
case ERICSSON_READ_REVISION_INFORMATION:
release_cmd_timer();
- printk("Ericsson HW revision info: %s\n\n",
- (r_val + 1));
+ printk("Ericsson HW revision info: %s\n\n", r_val + 1);
=20=20=20=20=20
/* Store this for later retrieval */
- memcpy(&bt_hw_firmware_info, r_val + 1, strlen(r_val+1));
- bt_hw_firmware_info[strlen(r_val+1)]=3D0;
+ strncpy(bt_hw_firmware_info, r_val + 1, BT_HW_INFO_MAX);
+ bt_hw_firmware_info[BT_HW_INFO_MAX] =3D '\0';
=20
wake_up_interruptible(&hci_wq);
break;
@@ -265,7 +266,7 @@
}
=20
char*
-get_hw_name(void)
+bt_hw_vendor(void)
{
return "Ericsson";
}
@@ -379,7 +380,7 @@
}
=20
char*
-get_hw_name(void)
+bt_hw_vendor(void)
{
return "Digianswer";
}
@@ -445,7 +446,7 @@
}
=20
char*
-get_hw_name(void)
+bt_hw_vendor(void)
{
return "CSR";
}
@@ -455,6 +456,8 @@
/************************* HW_NOINIT and HW_GENERIC **********************=
****/
/*************************************************************************=
****/
=20
+#define VENDOR " [Generic]"
+
s32=20
hci_set_bd_addr(u8 bd[6])
{
@@ -489,14 +492,20 @@
}
=20
char*
-get_hw_name(void)
+bt_hw_vendor(void)
{
return "Unknown hardware";
}
#endif
=20
+char*
+bt_hw_firmware(void)
+{
+ return bt_hw_firmware_info;
+}
+
void
-show_bt_vendor()
+bt_show_vendor()
{
DSYS("Current HW: %s\n", VENDOR);
}
|
|
From: Mats F. <ma...@us...> - 2001-05-18 09:14:51
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bcsp.c 1.4 1.5=20=20=20=20=20=20=20=20=20=20=20=20=20
bcsp_sequence.c 1.4 1.5=20=20=20=20=20=20=20=20=20=20=20=20=20
bluetooth.c 1.174 1.175=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added shutdown function for BCSP
The diff of the modified file(s):
--- bcsp.c 2001/05/17 15:37:03 1.4
+++ bcsp.c 2001/05/18 09:14:20 1.5
@@ -112,7 +112,7 @@
void
bcsp_init(void)
{
- printk(__FUNCTION__ ": Initializing BCSP\n");
+ BCSP_SYS(__FUNCTION__ ": Initializing BCSP\n");
sequence_init();
send_sync();
cli();
@@ -123,12 +123,19 @@
}
=20
void
+bcsp_shutdown(void)
+{
+ BCSP_SYS(__FUNCTION__": Shuting down BCSP\n");
+ sequence_shutdown();
+}
+
+void
bcsp_syncronized(void)
{
cli();
bcsp_sync =3D TRUE;
sti();
- printk(__FUNCTION__ ": BCSP initialized and syncronized\n");
+ BCSP_SYS(__FUNCTION__ ": BCSP initialized and syncronized\n");
wake_up_interruptible(&bcsp_sync_wq);
}
=20
--- bcsp_sequence.c 2001/05/18 07:05:03 1.4
+++ bcsp_sequence.c 2001/05/18 09:14:20 1.5
@@ -101,13 +101,20 @@
=20
/****************** FUNCTION DEFINITION SECTION **************************=
***/
=20
-void sequence_init(void)
+void
+sequence_init(void)
{
resend_data_task.routine =3D (void*)sequence_resend;
resend_data_task.data =3D NULL;
=20
send_ack_task.routine =3D (void*)send_ack;
send_ack_task.data =3D NULL;
+}
+
+void
+sequence_shutdown(void)
+{
+ release_resend_timer();
}
=20
s32
--- bluetooth.c 2001/05/15 14:44:50 1.174
+++ bluetooth.c 2001/05/18 09:14:20 1.175
@@ -2715,6 +2715,10 @@
btmem_shutdown();
bt_stack_initiated =3D 0;
=20
+#ifdef CONFIG_BLUETOOTH_USE_BCSP
+ bcsp_shutdown();
+#endif
+=09
if (tmp_bt_buf) {
free_page((unsigned long) tmp_bt_buf);
tmp_bt_buf =3D NULL;
|
|
From: Mats F. <ma...@us...> - 2001-06-19 06:13:32
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bluetooth.c 1.183 1.184=20=20=20=20=20=20=20=20=20=20=20
btmem.c 1.42 1.43=20=20=20=20=20=20=20=20=20=20=20=20
rfcomm.c 1.113 1.114=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
We need to keep track of how many bytes there are in the BT-buf for each li=
ne
The diff of the modified file(s):
--- bluetooth.c 2001/06/15 12:30:03 1.183
+++ bluetooth.c 2001/06/19 06:13:01 1.184
@@ -470,12 +470,7 @@
static s32
bt_chars_in_buffer(struct tty_struct *tty)
{
- u16 n =3D buf_byte_count();
- /* what if multiple pppd are running and one pppd=20
- ends, then this won't be zero.... */
-
- /* fixme -- we must find number bytes belonging to=20
- this line */
+ u16 n =3D buf_byte_count(GET_TTYLINE(tty));
=20
BT_DRIVER("bt_chars_in_buffer : %d\n", n);=20=20
return n;
@@ -1578,7 +1573,7 @@
=20
/* If buffer usage is less than BTMEM_UNTHROTTLE_SIZE check if we=20
should wake up ldisc */
- if (buf_byte_count() >=3D BTMEM_UNTHROTTLE_SIZE) {
+ if (buf_byte_count(-1) >=3D BTMEM_UNTHROTTLE_SIZE) {
return;
}=09
=20=09
@@ -2624,7 +2619,7 @@
statename(SESSIONSTATE(line)), NBR_CTRL_FDS);
=20
pos +=3D sprintf(buf+pos, "\n[BTMEM]\n");
- pos +=3D sprintf(buf+pos, "Buffer holds : %d\n", buf_byte_count());
+ pos +=3D sprintf(buf+pos, "Buffer holds : %d\n", buf_byte_count(-1));
pos +=3D sprintf(buf+pos, "Bytes left : %d\n", buf_write_room());
=20
return pos;
--- btmem.c 2001/06/06 14:57:44 1.42
+++ btmem.c 2001/06/19 06:13:01 1.43
@@ -327,6 +327,7 @@
tx->magic =3D 0x4321;
tx->subscr_len =3D send_len;
tx->flushed =3D 0;
+ tx->line =3D -1;
=20
sti();
return tx;
@@ -341,9 +342,52 @@
=20
/* Returns total number of bytes in buffer (fragmented) */
=20
-s32 buf_byte_count()
+s32 buf_byte_count(s32 line)
{
+ u8 *pos =3D bt_buf.head;
+ bt_tx_buf *tx;
+ u32 sum =3D 0;
+
+ if (line < 0) {
+ //printk(__FUNCTION__": Total bytes in buffer %d\n", bt_buf.count);
return bt_buf.count;
+ } else {
+ if (bt_buf.free > bt_buf.send) {
+ /* read from send -> free */
+ pos =3D bt_buf.send;
+ while (pos < bt_buf.free) {
+ tx =3D (bt_tx_buf *)(pos);
+ if (tx->line =3D=3D line) {
+ sum +=3D tx->subscr_len;
+ }
+ pos +=3D BT_TX_HDRSIZE + tx->subscr_len;
+ }
+ } else if (bt_buf.free < bt_buf.send) {
+ /* read send -> toss_tail + read from head -> free */
+ pos =3D bt_buf.send;
+ while (pos < bt_buf.toss_tail) {
+ tx =3D (bt_tx_buf *)(pos);
+ if (tx->line =3D=3D line) {
+ sum +=3D tx->subscr_len;
+ }
+ pos +=3D BT_TX_HDRSIZE + tx->subscr_len;
+ }
+=09=09=09
+ pos =3D bt_buf.head;=20
+ while (pos < bt_buf.free) {
+ tx =3D (bt_tx_buf*)(pos);
+ if (tx->line =3D=3D line) {
+ sum +=3D tx->subscr_len;
+ }
+ pos +=3D BT_TX_HDRSIZE + tx->subscr_len;
+ }
+ } else {
+ /* Buffer empty */
+ sum =3D 0;
+ }
+ //printk(__FUNCTION__": %d chars in buf for line:%d, total:%d\n", sum, l=
ine, bt_buf.count);
+ return sum;
+ }
}
=20
/* Returns unfragmented buffer space */=20
--- rfcomm.c 2001/06/14 10:45:24 1.113
+++ rfcomm.c 2001/06/19 06:13:01 1.114
@@ -1926,6 +1926,7 @@
=20
/* 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);
return len;
}
|
|
From: Anders J. <and...@us...> - 2001-07-31 09:04:14
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
Config.in 1.18 1.19=20=20=20=20=20=20=20=20=20=20=20=20
Makefile 1.23 1.24=20=20=20=20=20=20=20=20=20=20=20=20
test.c 1.17 1.18=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Changed #INCLUDE_UNPLUG_TEST -> #CONFIG_BLUETOOTH_UNPLUG_TEST
The diff of the modified file(s):
--- Config.in 2001/07/30 16:54:06 1.18
+++ Config.in 2001/07/31 09:04:13 1.19
@@ -36,7 +36,7 @@
bool ' Allow connectionless L2CAP' CONFIG_BLUETOOTH_L2CAP_CONNECTIONLESS
bool ' Enable TCI' CONFIG_BLUETOOTH_USE_TCI
bool ' Enable M/S Switch' CONFIG_BLUETOOTH_ENABLE_MSSWITCH
- bool ' Enable Unplug Test Code' INCLUDE_UNPLUG_TEST
+ bool ' Enable Unplug Test Code' CONFIG_BLUETOOTH_UNPLUG_TEST
=20
if [ "$CONFIG_BLUETOOTH_ENABLE_MSSWITCH" =3D "y" ]; then
# CSR can't do scatternet yet, so we need to do M/S switch=20
--- Makefile 2001/07/30 15:45:28 1.23
+++ Makefile 2001/07/31 09:04:13 1.24
@@ -11,7 +11,7 @@
=20
# Uncomment this line to enable the unplugged testcases. If you
# don't know what this is just leave it commented.
-#INCLUDE_UNPLUG_TEST =3D 1
+INCLUDE_UNPLUG_TEST =3D 1
=20
ifeq ($(TOPDIR)/Rules.make,$(wildcard $(TOPDIR)/Rules.make))
=20
@@ -60,7 +60,7 @@
=20
ifdef INCLUDE_UNPLUG_TEST
OBJS +=3D unplug_test.o
-CFLAGS +=3D -DINCLUDE_UNPLUG_TEST
+CFLAGS +=3D -DCONFIG_BLUETOOTH_UNPLUG_TEST
endif
=20
all: $(O_TARGET)
--- test.c 2001/07/30 13:48:49 1.17
+++ test.c 2001/07/31 09:04:13 1.18
@@ -449,13 +449,7 @@
=20
void test_process_cmd(unsigned char *cmd, s32 size)
{
- /* FIXME: To allow the testcommand to be processed we need to=20
- link unplug_test.c with the code. This file is=20
- currently located in apps/bluetooth/userstack.
- Make a link in this directory to that file and
- include it in the build (add it to the Makefile)
- if you are going to use this feature. */
-#ifdef INCLUDE_UNPLUG_TEST=20
+#ifdef CONFIG_BLUETOOTH_UNPLUG_TEST=20
int testcase =3D my_atoi(cmd+2);
=20
if (testcase > 0)
|
|
From: Peter K. <pk...@us...> - 2001-09-21 12:51:37
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
hci.c 1.180 1.181=20=20=20=20=20=20=20=20=20=20=20
l2cap.c 1.118 1.119=20=20=20=20=20=20=20=20=20=20=20
sdp.c 1.79 1.80=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Replaces CHAR2INTx() macros with get_unaligned() and leXX_to_cpu().
The diff of the modified file(s):
--- hci.c 2001/09/12 12:42:19 1.180
+++ hci.c 2001/09/21 12:51:06 1.181
@@ -61,11 +61,16 @@
#include <linux/interrupt.h>
#include <linux/bluetooth/sec_client.h>
#include <asm/io.h>
+#include <asm/byteorder.h>
+#include <asm/unaligned.h>
=20
#else /* user mode */
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+
+#include <asm/unaligned.h>
+
#include "include/bluetooth.h"
#include "include/hci.h"
#include "include/hci_internal.h"
@@ -79,23 +84,11 @@
#endif
=20
/****************** CONSTANT AND MACRO SECTION ***************************=
***/
-
-
-#define SET_UART(x1,x2,x3,x4) (((((x4)&7)<<5) + (((x3)&1)<<4) + \
- (((x2)&1)<<3) + (((x1)&1)<<2)) & 0xfc)
-
-#define SET_BAUD_RATE(x) (27648000/(x))
-
-
-#define SET_PROTOCOL_MODE(x1,x2,x3,x4,x5,x6) ((((x6)&7)<<5) + (((x5)&1)<<4=
) + \
- (((x4)&1)<<3) + (((x3)&1)<<2) + \
- (((x2)&1)<<1) + ((x1)&1))
-
=20
-#define MAKE_ACL_HDR(hci_hdl,pb,bc,len) (cpu_to_le32(((len & 0xffff) << 16=
) + \
- ((bc & 0x3) << 14) + \
- ((pb & 0x3) << 12) + \
- (hci_hdl & 0xfff)))
+/* These two macros are the same as le16_to_cpup() and le32_to_cpup()
+ only that they work with unaligned addresses */
+#define le16_to_cpuu(addr) (le16_to_cpu(get_unaligned((u16 *)addr)))
+#define le32_to_cpuu(addr) (le32_to_cpu(get_unaligned((u32 *)addr)))
=20
#define ACL_LINK 1
#define SCO_LINK 0
@@ -140,7 +133,6 @@
#define USE_NCPTIMER=20
#define NCP_TIMEOUT (2*HZ)
=20
-
/****************** TYPE DEFINITION SECTION ******************************=
***/
=20
/* cmd_t and cmd_buf are structures used to handle the queue of commands
@@ -156,9 +148,9 @@
u32 next_to_send; /* index in cmd_buf */
u8 count;
cmd_t buf[NBR_CMD_BUFS];
-} cmd_buf;
+};
=20
-/* This is the states the state machine in hci_receive_data can be in */
+/* These are the states the state machine in hci_receive_data can be in */
enum states{WAIT_FOR_PACKET_TYPE, WAIT_FOR_EVENT_TYPE, WAIT_FOR_EVENT_LENG=
TH,
WAIT_FOR_EVENT_PARAM, WAIT_FOR_ACL_HDR, WAIT_FOR_ACL_DATA,=20
WAIT_FOR_SCO_HDR, WAIT_FOR_SCO_DATA, WAIT_FOR_TIMEOUT};
@@ -170,11 +162,11 @@
description of the HCI event packet. */
=20
typedef struct event_struct {
- u32 pkt_type:8;
- u32 event_type:8;
- u32 len:8;
+ u8 pkt_type;
+ u8 event_type;
+ u8 len;
u8 data[0];
-} event_struct;
+} __attribute__ ((packed)) event_struct;
#endif
=20
/****************** LOCAL FUNCTION DECLARATION SECTION *******************=
***/
@@ -187,6 +179,7 @@
static hci_in_buffer* get_free_inbuffer(void);
static u32 send_acl_packet(bt_tx_buf *tx_buf);
static void set_acl_hdr(u8 *data, u32 len, u8 pb, u8 bc, u32 hci_hdl);
+static u16 hci_handle(void *data);
static cmd_t* get_next_cmd(void);=20
static s32 insert_cmd(u8* cmd, u8 len);=20
static void init_cmd_buf(void);
@@ -261,6 +254,8 @@
=20
/****************** LOCAL VARIABLE DECLARATION SECTION *******************=
***/
=20
+static struct cmd_buf cmd_buf;
+
/* Struct used for sending command packets */
cmd_pkt c_pkt;
=20
@@ -346,7 +341,6 @@
* parse_sco_packet or the parse_event_packet, depending on the packet type
*/
=20
-
void
hci_receive_data(u8* data, u32 count)
{
@@ -473,10 +467,11 @@
buf +=3D c;
count -=3D c;
if (tmp_pos =3D=3D ACL_HDR_LEN) {
- hci_hdl =3D CHAR2INT12(hdr[1],hdr[0]);
- pb_flag =3D (((u32) hdr[1]) & 0x30) >> 4;
- bc_flag =3D (((u32) hdr[1]) & 0xc0) >> 6;
- data_len =3D CHAR2INT16(hdr[3],hdr[2]);
+ u32 tmp_hdr =3D le32_to_cpuu(hdr);
+ hci_hdl =3D GET_BITS(tmp_hdr, 0, 12);
+ pb_flag =3D GET_BITS(tmp_hdr, 12, 2);
+ bc_flag =3D GET_BITS(tmp_hdr, 14, 2);
+ data_len =3D GET_BITS(tmp_hdr, 16, 16);
=20
/* Check the length to make sure we won't=20
overrun in_buf->buf_ptr in a memcpy later.
@@ -562,7 +557,7 @@
buf +=3D c;
count -=3D c;
if (tmp_pos =3D=3D SCO_HDR_LEN) {
- hci_hdl =3D CHAR2INT12(hdr[1],hdr[0]);
+ hci_hdl =3D hci_handle(hdr);
data_len =3D hdr[2];
tmp_pos =3D 0;
state =3D WAIT_FOR_SCO_DATA;
@@ -606,8 +601,8 @@
while (count > 0) {
event_type =3D tmp_buf[0];
event_len =3D tmp_buf[1];
- tmp_buf +=3D 2;
- count -=3D 2;
+ tmp_buf +=3D EVENT_HDR_LEN;
+ count -=3D EVENT_HDR_LEN;
=20
D_REC(__FUNCTION__ ": Received event 0x%02x with len:%d\n", event_type, =
event_len);
=20=09=09
@@ -630,14 +625,17 @@
tmp_buf =3D data;
=20
while (count > 0) {
- /* Parse the HCI header */
- hci_hdl =3D CHAR2INT12(tmp_buf[1],tmp_buf[0]);
- pb_flag =3D (((u32) tmp_buf[1]) & 0x30) >> 4;
- bc_flag =3D (((u32) tmp_buf[1]) & 0xc0) >> 6;
- data_len =3D CHAR2INT16(tmp_buf[3],tmp_buf[2]);
- tmp_buf +=3D 4;
- count -=3D 4;
+ u32 tmp_hdr =3D le32_to_cpuu(tmp_buf);
=20=09=09
+ /* Parse the ACL header */
+ hci_hdl =3D GET_BITS(tmp_hdr, 0, 12);
+ pb_flag =3D GET_BITS(tmp_hdr, 12, 2);
+ bc_flag =3D GET_BITS(tmp_hdr, 14, 2);
+ data_len =3D GET_BITS(tmp_hdr, 16, 16);
+
+ tmp_buf +=3D ACL_HDR_LEN;
+ count -=3D ACL_HDR_LEN;
+=09=09
/* Check the length to make sure we won't=20
overrun in_buf->buf_ptr in a memcpy later.
--gmcnutt
@@ -727,7 +725,7 @@
that have been sent */
=20
for (i =3D 0; i < 4 * nbr_of_hdl; i +=3D 4) {
- hci_ctrl.hc_buf.acl_num +=3D CHAR2INT16(pkt[i+3], pkt[i+2]);
+ hci_ctrl.hc_buf.acl_num +=3D le16_to_cpuu(&pkt[i+2]);
}
=20=09
D_QUEUE("<NCP:%d>\n", hci_ctrl.hc_buf.acl_num);
@@ -824,7 +822,7 @@
get_err_msg(buf[0]));
=20
link_type =3D buf[9];
- hci_hdl =3D CHAR2INT12(buf[2], buf[1]);
+ hci_hdl =3D hci_handle(&buf[1]);
test_hci_hdl =3D hci_hdl;
=20
if (link_type =3D=3D ACL_LINK) {
@@ -898,7 +896,7 @@
release_cmd_timer();
wake_up_interruptible(&hci_wq);
=20
- if (lp_disconnect_ind(CHAR2INT12(buf[2], buf[1])))
+ if (lp_disconnect_ind(hci_handle(&buf[1])))
if (hci_ctrl.nbr_of_connections > 0) {
hci_ctrl.nbr_of_connections--;
hci_update_load_factor();
@@ -909,7 +907,7 @@
connections we can acl_num by reading the buffersizes again,
but this will not work in a multipoint connection. */
=20
- reset_hci_con_bd(CHAR2INT12(buf[2], buf[1]));
+ reset_hci_con_bd(hci_handle(&buf[1]));
=20=09=09
if (hci_ctrl.nbr_of_connections <=3D 0) {
hci_read_buffer_size(HCI_NON_BLOCK);
@@ -926,7 +924,7 @@
=20=09=09=09
}
=20=09=09
- sec_man_event(HCI, get_bd(CHAR2INT12(buf[2], buf[1])), AUTHENTICATION_CO=
MPLETE, buf, 1);
+ sec_man_event(HCI, get_bd(hci_handle(&buf[1])), AUTHENTICATION_COMPLETE,=
buf, 1);
#endif
wake_up_interruptible(&hci_wq);
break;
@@ -958,7 +956,7 @@
tmp[0] =3D buf[0];
tmp[1] =3D buf[3];
=20=09=09
- sec_man_event(HCI, get_bd(CHAR2INT12(buf[2], buf[1=
])), ENCRYPTION_CHANGE, tmp, 2);
+ sec_man_event(HCI, get_bd(hci_handle(&buf[1])), EN=
CRYPTION_CHANGE, tmp, 2);
}
#endif
wake_up_interruptible(&hci_wq);
@@ -1022,12 +1020,13 @@
=20
case FLUSH_OCCURRED:
D_CMD(__FUNCTION__ ": FLUSH_OCCURRED on hci_hdl %d\n",
- CHAR2INT12(buf[1],buf[0]));
- btmem_flushhandle(CHAR2INT12(buf[1],buf[0]));
+ hci_handle(buf));
+ btmem_flushhandle(hci_handle(buf));
break;
=20
case HARDWARE_ERROR:
- D_ERR(__FUNCTION__ ": An hardware error with error code 0x%02x occurred\=
n Please refer to your bluetooth module manual\n", buf[0]);
+ D_ERR(__FUNCTION__ ": A hardware error with error code 0x%02X occurred.\=
n", buf[0]);
+ D_ERR(__FUNCTION__ ": Please refer to your Bluetooth module's manual.\n"=
);
break;
=20
case ROLE_CHANGED:
@@ -1041,10 +1040,10 @@
=20=09=09=09
} else if (buf[7]) {
DSYS(__FUNCTION__ ": Current master is 0x%04x%08x\n",=20
- CHAR2INT16(buf[6], buf[5]),=20
- CHAR2INT32(buf[4], buf[3], buf[2], buf[1]));
+ le16_to_cpuu(&buf[5]), le32_to_cpuu(&buf[1]));
} else {
- DSYS(__FUNCTION__ ": Our role is master for BD Address 0x%04x%08x\n", C=
HAR2INT16(buf[6], buf[5]), CHAR2INT32(buf[4], buf[3], buf[2], buf[1]));
+ DSYS(__FUNCTION__ ": Our role is master for BD Address 0x%04x%08x\n",
+ le16_to_cpuu(&buf[5]), le32_to_cpuu(&buf[1]));
}
break;
=20
@@ -1058,7 +1057,7 @@
=20
case MODE_CHANGE:
D_CMD(__FUNCTION__ ": MODE_CHANGE on hci_hdl %d\n",
- CHAR2INT12(buf[2],buf[1]));
+ hci_handle(&buf[1]));
break;
=20
case RETURN_LINK_KEYS:
@@ -1162,13 +1161,11 @@
the command complete event */
=20
ogf =3D (u32) buf[2] >> 2;
- ocf =3D CHAR2INT10(buf[2],buf[1]);
+ ocf =3D le16_to_cpuu(&buf[1]) & 0x03FF;
r_val =3D buf + 3;
=20
switch (ogf) {
-
case HCI_LC:
-=20=20=20=20=20=20=20=20=20=20
switch (ocf) {
case LINK_KEY_REQUEST_REPLY:
release_cmd_timer();
@@ -1239,16 +1236,13 @@
D_CMD(__FUNCTION__ ": HCI_LC, ocf %d not recognised!\n", ocf);
break;
}
-
break;
=20=20=20=20=20=20=20=20=20=20=20
case HCI_HC: /* Host Controller commands */
-=09=09
release_cmd_timer();
/* FIXME -- correct timer should be released */
=20=20=20=20=20=20=20=20=20=20=20
switch (ocf) {
-=09=09=09
case CREATE_NEW_UNIT_KEY:
D_CMD(__FUNCTION__ ": CREATE_NEW_UNIT_KEY\n");
if (r_val[0]) {
@@ -1268,13 +1262,12 @@
result_param =3D - r_val[0];
} else {
D_CMD(__FUNCTION__ ": READ_STORED_LINK_KEY Success\n");
- result_param =3D CHAR2INT32(r_val[4], r_val[3],
- r_val[2], r_val[=
1]);
+ result_param =3D le32_to_cpuu(&r_val[1]);
}
DSYS(__FUNCTION__ ": Max number of Linkkeys: %d\n",
- CHAR2INT16(r_val[2], r_val[1]));
+ le16_to_cpuu(&r_val[1]));
DSYS(__FUNCTION__ ": Number of Linkkeys read: %d\n",
- CHAR2INT16(r_val[4], r_val[3]));
+ le16_to_cpuu(&r_val[3]));
break;
=20
case WRITE_STORED_LINK_KEY:
@@ -1296,11 +1289,11 @@
result_param =3D - r_val[0];
} else {
D_CMD(__FUNCTION__ ": DELETE_STORED_LINK_KEY Success\n");
- result_param =3D CHAR2INT16(r_val[2], r_val[1]);
+ result_param =3D le16_to_cpuu(&r_val[1]);
}
=20=09=09=09
D_CMD(__FUNCTION__ ": Number of Linkkeys deleted: %d\n",
- CHAR2INT16(r_val[2], r_val[1]));
+ le16_to_cpuu(&r_val[1]));
break;=09
=20=20=20=20=20=20=20=20=20=20=20=20=20
case READ_TRANSMIT_POWER_LEVEL:=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
@@ -1311,8 +1304,7 @@
get_err_msg(r_val[0]));
break;
} else {
- unsigned short hci_hdl =3D CHAR2INT12(r_val[2], r_val[1]);
- DSYS("READ_TRANSMIT_POWER_LEVEL : handle %d, %d dBm\n", hci_hdl, r_val=
[3]);
+ DSYS("READ_TRANSMIT_POWER_LEVEL: handle %d, %d dBm\n", hci_handle(&r_v=
al[1]), r_val[3]);
}
break;
=20
@@ -1438,7 +1430,7 @@
=20=20=20=20=20=20=20=20=20=20=20=20=20
case READ_LINK_SUPERVISION_TIMEOUT:
D_CMD(__FUNCTION__ ": Link supervision timeout is: %d\n",
- CHAR2INT16(buf[4],buf[3]));
+ le16_to_cpuu(&buf[3]));
break;
=20=20=20=20=20=20=20=20=20=20=20=20=20
case WRITE_LINK_SUPERVISION_TIMEOUT:
@@ -1497,7 +1489,6 @@
release_cmd_timer();
=20
switch (ocf) {
-
case READ_COUNTRY_CODE:
if (r_val[0]) {
D_ERR(__FUNCTION__ ": READ_COUNTRY_CODE : %s\n",
@@ -1528,10 +1519,10 @@
get_err_msg(r_val[0]));
break;
}
- hci_ctrl.hc_buf.acl_len =3D CHAR2INT16(r_val[2],r_val[1]);
+ hci_ctrl.hc_buf.acl_len =3D le16_to_cpuu(&r_val[1]);
hci_ctrl.hc_buf.sco_len =3D (u32) r_val[3];
- hci_ctrl.hc_buf.acl_num =3D CHAR2INT16(r_val[5],r_val[4]);
- hci_ctrl.hc_buf.sco_num =3D CHAR2INT16(r_val[7],r_val[6]);
+ hci_ctrl.hc_buf.acl_num =3D le16_to_cpuu(&r_val[4]);
+ hci_ctrl.hc_buf.sco_num =3D le16_to_cpuu(&r_val[6]);
printk("\nHW module contains...\n");
printk("%d ACL buffers at %d bytes\n%d SCO buffers at %d bytes\n\n",
hci_ctrl.hc_buf.acl_num, hci_ctrl.hc_buf.acl_len,
@@ -1592,10 +1583,9 @@
wake_up_interruptible(&hci_wq);
break;
=20=20=20=20=20=20=20=20=20=20=20
- case MANUFACTURER_SPEC: { /* manufacturer specific */
+ case MANUFACTURER_SPEC: /* Manufacturer specific */
D_CMD(__FUNCTION__ ": MANUFACTURER_SPEC\n");
process_vendor_return_param(ocf, r_val);
- }
break;
=20=20=20=20=20=20=20=20=20
default:
@@ -3531,13 +3521,22 @@
void=20
set_acl_hdr(u8 *data, u32 len, u8 pb, u8 bc, u32 hci_hdl)
{
- u32 tmp_hdr;
+ u32 tmp_hdr =3D 0;
+
+ SET_BITS(tmp_hdr, 0, 12, hci_hdl);
+ SET_BITS(tmp_hdr, 12, 2, pb);
+ SET_BITS(tmp_hdr, 14, 2, bc);
+ SET_BITS(tmp_hdr, 16, 16, len);
=20
data[0] =3D ACL_PKT;
- tmp_hdr =3D MAKE_ACL_HDR(hci_hdl,pb,bc,len);
- memcpy(data + 1, &tmp_hdr, 4);
+ put_unaligned(cpu_to_le32(tmp_hdr), (u32*)&data[1]);
}
=20
+u16
+hci_handle(void *data)
+{
+ return GET_BITS(le16_to_cpuu(data), 0, 12);
+}
=20
/* Returns the error messages according to the specification page 746 */
u8*=20
@@ -3645,9 +3644,9 @@
and 0x13 is the code for "Other End Terminated
Connection: User Ended Connection" */
D_CMD(__FUNCTION__ ": DISCONNECT->disconnection complete\n");
- o_len =3D set_discon_cpl_event(out_event, CHAR2INT12(cmd->data[1], cmd-=
>data[0]), 0x13);
+ o_len =3D set_discon_cpl_event(out_event, hci_handle(cmd->data), 0x13);
bt_write_lower_driver(o_event, o_len);
- if (lp_disconnect_ind(CHAR2INT12(cmd->data[1],cmd->data[0])))
+ if (lp_disconnect_ind(hci_handle(cmd->data)))
if (hci_ctrl.nbr_of_connections > 0) {
hci_ctrl.nbr_of_connections--;
hci_update_load_factor();
--- l2cap.c 2001/09/12 12:38:10 1.118
+++ l2cap.c 2001/09/21 12:51:06 1.119
@@ -59,12 +59,16 @@
#include <linux/bluetooth/l2cap_con.h>
#include <linux/bluetooth/l2cap_sec.h>
#include <linux/bluetooth/bt_errno.h>
+#include <asm/byteorder.h>
+#include <asm/unaligned.h>
#else /* user mode */
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <signal.h>
#include <errno.h>
+#include <asm/unaligned.h>
+
#include "include/l2cap.h"
#include "include/hci.h"
#include "include/hci_internal.h"
@@ -588,7 +592,7 @@
in the connection less packet */
con =3D get_con_hcihdl(hci_handle);
=20=09=09
- get_upper(CHAR2INT16(pkt->data[1], pkt->data[0]))->
+ get_upper(le16_to_cpu(get_unaligned((u16 *)&pkt->data[0])))->
receive_data(con, pkt->data + 2, pkt_len - 2);
break;
=20=20=20=20=20
--- sdp.c 2001/09/19 10:16:27 1.79
+++ sdp.c 2001/09/21 12:51:06 1.80
@@ -58,6 +58,8 @@
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <asm/unaligned.h>
+
#include "include/bluetooth.h"
#include "include/btcommon.h"
#include "include/sdp.h"
@@ -798,7 +800,7 @@
=20
#ifndef __KERNEL__
if (sdp_sock < 0) {
- send_error_rsp(sdp, CHAR2INT16(data[2], data[1]), 6);
+ send_error_rsp(sdp, le16_to_cpu(get_unaligned((u16 *)&data[1])), 6);
}
#endif
=20
|
|
From: Peter K. <pk...@us...> - 2001-10-05 12:25:47
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bluetooth.c 1.201 1.202=20=20=20=20=20=20=20=20=20=20=20 hci.c 1.184 1.185=20=20=20=20=20=20=20=20=20=20=20 hci_vendor.c 1.57 1.58=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Corrected indentation. |
|
From: Peter K. <pk...@us...> - 2001-10-22 13:25:55
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
btmem.c 1.43 1.44=20=20=20=20=20=20=20=20=20=20=20=20
l2cap.c 1.122 1.123=20=20=20=20=20=20=20=20=20=20=20
test.c 1.31 1.32=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Make sure macro arguments are enclosed by parentheses.
The diff of the modified file(s):
--- btmem.c 2001/06/19 06:13:01 1.43
+++ btmem.c 2001/10/22 13:25:54 1.44
@@ -77,7 +77,7 @@
=20
/****************** CONSTANT AND MACRO SECTION ***************************=
***/
=20
-#define BUFFER_USAGE_LEVEL(usage) ((usage*100)/(int)(BT_BUF_SIZE))
+#define BUFFER_USAGE_LEVEL(usage) (((usage)*100)/(int)(BT_BUF_SIZE))
=20
/****************** TYPE DEFINITION SECTION ******************************=
***/
=20
--- l2cap.c 2001/10/16 10:51:29 1.122
+++ l2cap.c 2001/10/22 13:25:54 1.123
@@ -88,7 +88,7 @@
#if L2CAP_DEBUG_STATE
/* State machine */
#define D_STATE(fmt...) printk(L2CAP_DBG_STR fmt)
-#define PRINTSTATE(con) (printk(L2CAP_DBG_STR "Current state of (%d:%d) is=
%s\n", con->local_cid, con->remote_cid, state_name[con->current_state]))
+#define PRINTSTATE(con) (printk(L2CAP_DBG_STR "Current state of (%d:%d) is=
%s\n", (con)->local_cid, (con)->remote_cid, state_name[(con)->current_stat=
e]))
#else
/* State machine */
#define D_STATE(fmt...)
@@ -149,15 +149,16 @@
#define MAX_CID 0xffff
=20
/* EVEN =3D> REQUEST */=20
-#define ISREQUEST(x) (!(x%2))
-#define SET_L2CAP_HDR(frame, len, cid) {\
+#define ISREQUEST(x) (!((x) % 2))
+#define SET_L2CAP_HDR(frame, len, cid) \
+do { \
(*(u8 *)(frame)) =3D (u8)(((len) & 0xff)); \
- (*(u8 *)(frame + 1)) =3D (u8)((len) >> 8); \
- (*(u8 *)(frame + 2)) =3D (u8)(((cid) & 0xff)); \
- (*(u8 *)(frame + 3)) =3D (u8)((cid) >> 8); \
-}
+ (*(u8 *)((frame) + 1)) =3D (u8)((len) >> 8); \
+ (*(u8 *)((frame) + 2)) =3D (u8)(((cid) & 0xff)); \
+ (*(u8 *)((frame) + 3)) =3D (u8)((cid) >> 8); \
+} while (0)
=20
-#define ENTERSTATE(con, state) (con->current_state =3D state)
+#define ENTERSTATE(con, state) ((con)->current_state =3D state)
=20
#define RCID_NOT_SET 0
#define RCID_SET 1
@@ -168,38 +169,6 @@
=20
#define CONFREQ_NO_OPTIONS 0x11
=20
-const u8* psm2str(u16 psm)
-{
- switch (psm) {
- case 1:
- return "SDP";
- break;
-
- case 3:
- return "RFCOMM";
- break;
-
- case 5:
- return "TCS";
- break;
-
- case 0x1231:
- return "TEST";
- break;
-
- case 0x1233:
- return "TEST-2";
- break;
-
- case 0x4561:
- return "TEST-3";
- break;
-
- default :
- return "unknown";
- }
-}
-
const u8* cmdrej_reason[] =3D {
"Command not understood",
"Signalling MTU exceeded",
@@ -3296,6 +3265,7 @@
(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)
@@ -3313,6 +3283,32 @@
else if (i =3D=3D MAX_CID)
return 0;
i++;
+ }
+}
+
+const u8* psm2str(u16 psm)
+{
+ switch (psm) {
+ case 1:
+ return "SDP";
+
+ case 3:
+ return "RFCOMM";
+
+ case 5:
+ return "TCS";
+
+ case 0x1231:
+ return "TEST";
+
+ case 0x1233:
+ return "TEST-2";
+
+ case 0x4561:
+ return "TEST-3";
+
+ default:
+ return "Unknown";
}
}
=20
--- test.c 2001/10/18 15:49:25 1.31
+++ test.c 2001/10/22 13:25:54 1.32
@@ -79,7 +79,7 @@
/* State machine */
#define D_STATE(fmt...) printk(TEST_DBG_STR fmt)
#define PRINTSTATE(con) (printk("Current state : %s\n",\
- state_name[con->current_state]))
+ state_name[(con)->current_state]))
#else
/* State machine */
#define D_STATE(fmt)
@@ -121,7 +121,7 @@
#define TEST_FLUSH_TIMEOUT 0xffff=20
/* Reliable channel, infinite amout of retransmissions */
=20
-#define PRINTPSM(con) (printk("PSM : 0x%x\n", con->psm))
+#define PRINTPSM(con) (printk("PSM : 0x%x\n", (con)->psm))
=20
/****************** TYPE DEFINITION SECTION ******************************=
***/
=20
|
|
From: Peter K. <pk...@us...> - 2001-11-15 11:18:02
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bluetooth.c 1.211 1.212=20=20=20=20=20=20=20=20=20=20=20
btdebug.c 1.22 1.23=20=20=20=20=20=20=20=20=20=20=20=20
btmem.c 1.44 1.45=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Renamed print_time() to bt_log_time().
The diff of the modified file(s):
--- bluetooth.c 2001/11/13 10:45:31 1.211
+++ bluetooth.c 2001/11/15 11:18:00 1.212
@@ -121,7 +121,7 @@
=20
#if BT_DATA_DEBUG
#if BT_USE_TIMESTAMPS
-#define BT_DATA(fmt...) do {print_time(1);printk(BT_DBG_STR"DATA " fmt);} =
while (0)
+#define BT_DATA(fmt...) do { printk(bt_log_time()); printk(BT_DBG_STR"DATA=
" fmt); } while (0)
#else
#define BT_DATA(fmt...) printk(BT_DBG_STR"DATA " fmt)
#endif
@@ -1284,7 +1284,7 @@
{
/* should simply discard data since ttySx only exists for internal use
*/
- BT_LDISC(__FUNCTION__ ": (%d) done!\n", count);
+ BT_LDISC(__FUNCTION__ ": (%lu) done!\n", (unsigned long)count);
=20=20=20
return tty->driver.write(tty, 1/*from user*/, data, count);
}
@@ -2605,8 +2605,8 @@
=20
init_failed_exit1:=20
hci_shutdown();
-init_failed_exit0:
#ifdef CONFIG_BLUETOOTH_SUPPORT_BCSP
+init_failed_exit0:
bcsp_shutdown();
#endif
btmem_shutdown();
--- btdebug.c 2001/06/06 14:57:19 1.22
+++ btdebug.c 2001/11/15 11:18:00 1.23
@@ -63,59 +63,42 @@
=20
/****************** FUNCTION DEFINITION SECTION **************************=
***/
=20
-#ifdef __KERNEL__
-
-static u8 buf[20];
-static struct timeval tv_old =3D {0, 0};
-
-u8* print_time(s32 use_stdout)
+u8*
+bt_log_time(void)
{
- s32 len, diff;
+#if defined(__KERNEL__) && defined(BT_USE_TIMESTAMPS)
+ s32 diff;
struct timeval tv;=20=20
+ static struct timeval tv_old =3D {0, 0};
+ static u8 buf[50];
=20
do_gettimeofday(&tv);
=20=09
- diff =3D ((tv.tv_sec - tv_old.tv_sec)*1000000 + tv.tv_usec) -=20
- tv_old.tv_usec;
+ /* Set tv_old on first call of this function */
+ if (!tv_old.tv_sec && !tv_old.tv_usec)
+ tv_old =3D tv;
=20=09
- if (use_stdout =3D=3D 1) {
- printk("[%03d,%06d<%06d>] ",=20
- (int)tv.tv_sec, (int)tv.tv_usec, diff);
- }
- else
- {
- len =3D sprintf(buf, "[%03d,%06d<%06d>] ",=20
- (int)tv.tv_sec, tv.tv_usec, diff);
- buf[len] =3D 0;
- }
+ diff =3D (tv.tv_sec - tv_old.tv_sec)*1000000 +
+ tv.tv_usec - tv_old.tv_usec;
+
+ sprintf(buf, "[%03ld.%06ld <%03d.%06d>] ", tv.tv_sec, tv.tv_usec, diff / =
1000000, diff % 1000000);
tv_old =3D tv;
- return buf;
-}
=20
+ return buf;
#else
-
-/* No timestamps in usermode yet */
-char* print_time(int use_stdout)
-{
- printf("No timestamps in usermode stack yet\n");
- return "No timestamps in usermode stack yet\n";
-}
+ return "";
#endif
+}
=20
void=20
print_data(const u8 *message, u8 *buf, s32 len)
{=20
s32 t =3D 0;
=20
-#if BT_USE_TIMESTAMPS
- if (message)
- printk("\n%s %s (%d):\n", print_time(0), message, len);
-#else
if (message)
- printk("\n%s (%d):\n", message, len);
-#endif
- while (t < len)
- {
+ printk("\n%s%s (%d):\n", bt_log_time(), message, len);
+
+ while (t < len) {
printk("0x%02x ", buf[t++]);
if (!(t % 16))
printk("\n");
@@ -124,7 +107,8 @@
printk("\n");
}
=20
-const char* bd2str(const unsigned char *bd)
+const char*
+bd2str(const unsigned char *bd)
{
static char buf[20];
=20
--- btmem.c 2001/10/22 13:25:54 1.44
+++ btmem.c 2001/11/15 11:18:00 1.45
@@ -562,11 +562,11 @@
/* Graphical view of buffer size */
void btmem_show_size(s32 count)
{
- u32 i;
- i =3D ((count*BUFFERMETERRESOLUTION)/BT_BUF_SIZE);
+ u32 i =3D ((count*BUFFERMETERRESOLUTION)/BT_BUF_SIZE);
+
memset(buffermeter, '|', i);
buffermeter[i+1] =3D 0; /* null terminate */=20
- printk("%s [%s - %d bytes]\n", buffermeter, print_time(0), count);
+ printk("%s%s [%d bytes]\n", bt_log_time(), buffermeter, count);
}
=20
void show_bt_buf(bt_tx_buf *tx, s32 no_data)
|
|
From: Anders J. <and...@us...> - 2001-11-22 14:02:44
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bluetooth.c 1.213 1.214=20=20=20=20=20=20=20=20=20=20=20
l2cap.c 1.124 1.125=20=20=20=20=20=20=20=20=20=20=20
rfcomm.c 1.128 1.129=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* wq_timers now use a new bt_timer_obj to prevent adding the same timer twi=
ce.
* l2cap ertx and rtx timers changed to the new one.
* One bt_timer on each tty added.
* Disable ertx when we receive a connection_complete after pending.
* bt_shutdown now disable pagescan to prevent any new connections.
The diff of the modified file(s):
--- bluetooth.c 2001/11/15 15:01:57 1.213
+++ bluetooth.c 2001/11/22 14:02:41 1.214
@@ -312,8 +312,6 @@
static tty_linebuffer tty_linebuf;
#endif /* BT_USELINEBUF */
=20
-static struct timer_list bt_timer;
-
#define BT_CON_TIMEOUT (10*HZ)
=20
/****************** FUNCTION DEFINITION SECTION **************************=
***/
@@ -1881,9 +1879,10 @@
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
/* sleep if not yet connected */
if (bt_ctrl.session[line].connect_status =3D=3D -1) {
- start_wq_timer(&bt_timer, BT_CON_TIMEOUT,=20
+ start_wq_timer(&bt_ctrl.bt_timer[line], BT_CON_TIMEOUT,=20
&bt_ctrl.connect_wq[line]);
interruptible_sleep_on(&bt_ctrl.connect_wq[line]);
+ release_wq_timer(&bt_ctrl.bt_timer[line]);
}
return bt_ctrl.session[line].connect_status;
}
@@ -1914,11 +1913,7 @@
don't appear to be working out.
--gmcnutt
*/
- /* fixme -- we probably need a lock on this timer since
- multiple processes could be trying to use it at the
- same time... or maybe use one timer per session.
- */
- start_wq_timer(&bt_timer, BT_CON_TIMEOUT,=20
+ start_wq_timer(&bt_ctrl.bt_timer[line], BT_CON_TIMEOUT,=20
&bt_ctrl.connect_wq[line]);
=20
/* The timeout routine doesn't have a hendle to our=20
@@ -1932,6 +1927,7 @@
=20
BT_DRIVER(__FUNCTION__ ": Sleep on line %d\n", line);
interruptible_sleep_on(&bt_ctrl.connect_wq[line]);
+ release_wq_timer(&bt_ctrl.bt_timer[line]);
=20
/*=20
* If the connect_status is >=3D 0, then the lower
@@ -2052,7 +2048,7 @@
BT_DRIVER(__FUNCTION__ ": Line %d [%s]\n",
line, psmname(psm));
=20
- release_wq_timer(&bt_timer);
+ release_wq_timer(&bt_ctrl.bt_timer[line]);
wake_up_interruptible(&bt_ctrl.connect_wq[line]);
wake_up_interruptible(&bt_ctrl.any_wq);
break;
@@ -2062,7 +2058,7 @@
bt_ctrl.session[line].connect_status =3D status;
BT_DRIVER(__FUNCTION__ ": Line %d [%s]\n", line, psmname(psm));
BT_DRIVER(__FUNCTION__ ": Wake up line %d\n", line);
- release_wq_timer(&bt_timer);
+ release_wq_timer(&bt_ctrl.bt_timer[line]);
wake_up_interruptible(&bt_ctrl.connect_wq[line]);
wake_up_interruptible(&bt_ctrl.any_wq);
break;
@@ -2137,9 +2133,10 @@
=20
/* Sleep if not yet disconnected */
if (bt_ctrl.session[line].disconnect_status =3D=3D -1) {
- start_wq_timer(&bt_timer, BT_CON_TIMEOUT,=20
+ start_wq_timer(&bt_ctrl.bt_timer[line], BT_CON_TIMEOUT,=20
&bt_ctrl.connect_wq[line]);
interruptible_sleep_on(&bt_ctrl.connect_wq[line]);
+ release_wq_timer(&bt_ctrl.bt_timer[line]);
}
=20=09=09
return bt_ctrl.session[line].disconnect_status;
@@ -2185,7 +2182,7 @@
=20
bt_ctrl.session[line].disconnect_status =3D status;
=20
- release_wq_timer(&bt_timer);
+ release_wq_timer(&bt_ctrl.bt_timer[line]);
wake_up_interruptible(&bt_ctrl.connect_wq[line]);
}
=20
@@ -2546,7 +2543,6 @@
}
}
=20
-
s32
bt_init_stack(void)
{
@@ -2698,20 +2694,21 @@
s32 i;
BT_DRIVER("Initialising bt ctrl struct\n");
=20
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
for (i =3D 0; i < BT_NBR_PORTS; i++) {
+ bt_ctrl.bt_timer[i].inuse =3D 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
bt_ctrl.connect_wq[i] =3D NULL;
- bt_reset_session(i);
- }
- bt_ctrl.any_wq =3D NULL;
#else
- for (i =3D 0; i < BT_NBR_PORTS; i++) {
init_waitqueue_head(&bt_ctrl.connect_wq[i]);
+#endif
bt_reset_session(i);
}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
+ bt_ctrl.any_wq =3D NULL;
+#else
init_waitqueue_head(&bt_ctrl.any_wq);
#endif
-
bt_ctrl.nbr_upper =3D 0;
bt_ctrl.nbr_active =3D 0;
bt_ctrl.tty_last_unthrottled =3D 0;
@@ -2981,11 +2978,16 @@
struct bt_session *bt;
DSYS("Shutting down bluetooth stack\n");
=20
+ /* Disable page scan as we don't want any new connections now */
+ DSYS("Disabling page scan\n");
+
+ hci_write_scan_enable(0x00);
if (bt_stack_initiated) {
if (!bt_dfu_mode(-1)) {
/* disconnect all active connections */
for (i =3D 0; i < BT_NBR_DATAPORTS;i++) {
bt =3D &bt_ctrl.session[i];
+ release_wq_timer(&bt_ctrl.bt_timer[i]);
if ((bt->state =3D=3D BT_ACTIVE) ||=20
(bt->state =3D=3D BT_LOWERCONNECTED)) {
DSYS("Disconnecting dlci %d on line %d\n",=20
@@ -3064,32 +3066,43 @@
}
}
=20
+/* FIXME: Make a general sleepfunction a la L2ca_wait and let the this fun=
ction handle all
+ sleeping. Add a waitqueue object to the timer and let timerdata=3Dbt_ti=
mer_obj to set
+ inuse=3D0 if we timeout */
+
#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
void
-start_wq_timer(struct timer_list *wq_timer,
+start_wq_timer(struct bt_timer_obj *wq_bt_timer,
u32 timeout, wait_queue_head_t *wq)
#else
void
-start_wq_timer(struct timer_list *wq_timer,
+start_wq_timer(struct bt_timer_obj *wq_bt_timer,
u32 timeout, struct wait_queue **wq)
#endif /* LINUX_VERSION_CODE */
{
- init_timer(wq_timer);
- wq_timer->function =3D wq_timeout;
- wq_timer->data =3D (unsigned long)wq;
- wq_timer->expires =3D jiffies + timeout;
- add_timer(wq_timer);
-// printk(__FUNCTION__ ": wq: 0x%x, timer: 0x%x\n", wq, wq_timer);
+ if(wq_bt_timer->inuse) {
+ D_ERR(__FUNCTION__ ": timer already used\n");
+ return;
+ }
+=09
+ wq_bt_timer->inuse =3D 1;
+ init_timer(&wq_bt_timer->timer);
+ wq_bt_timer->timer.function =3D wq_timeout;
+ wq_bt_timer->timer.data =3D (unsigned long)wq;
+ wq_bt_timer->timer.expires =3D jiffies + timeout;
+ add_timer(&wq_bt_timer->timer);
}
=20
=20
/* fixme -- only works for one function call at a time */
void
-release_wq_timer(struct timer_list *wq_timer)
+release_wq_timer(struct bt_timer_obj *wq_bt_timer)
{
- del_timer(wq_timer);
-// printk(__FUNCTION__ ": timer: 0x%x\n", wq_timer);
+ if(wq_bt_timer->inuse =3D=3D 1) {
+ del_timer(&wq_bt_timer->timer);
+ wq_bt_timer->inuse =3D 0;
}
+}
=20
void
wq_timeout(unsigned long ptr)
@@ -3100,7 +3113,6 @@
struct wait_queue **wq =3D (struct wait_queue **)ptr;
#endif /* LINUX_VERSION_CODE */
DSYS(__FUNCTION__ "\n");
-
/* wake up wait queue */
wake_up_interruptible(wq);
}
--- l2cap.c 2001/11/15 15:52:15 1.124
+++ l2cap.c 2001/11/22 14:02:41 1.125
@@ -995,6 +995,7 @@
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
disable_rtx(con);
+ disable_ertx(con);
#endif
ENTERSTATE(con, CONFIG);
PRINTSTATE(con);
@@ -1274,6 +1275,7 @@
return;
}
=20=20
+=20
/* FIXME - add check with control block if this bd_addr is allowed */
=20
/* We are server and creates an l2cap connection object=20
@@ -1940,7 +1942,6 @@
}
#endif
/* do some paranoia checks */
-
if (PARANOIA_CHECKCON(con)) {
D_ERR(__FUNCTION__ ": Paranoia check failed\n");
return;
@@ -1948,9 +1949,9 @@
=20
D_TIM(__FUNCTION__ ": current no rtx : %d\n", con->timer.rtx_no);
=20
- con->timer.rtx_inuse =3D 0;
+ con->timers.rtx.inuse =3D 0;
=20
- if (con->timer.rtx_no =3D=3D MAX_NO_RTX) {
+ if (con->timers.rtx_no =3D=3D MAX_NO_RTX) {
con->c_status =3D CSTATUS_MAX_NO_RTX;
=20
D_TIM(__FUNCTION__ ": Max number of retransmit reached\n");
@@ -1963,9 +1964,9 @@
l2ca_wakeup("rtx_timeout", con);
=20
/* reset rtx counter */
- con->timer.rtx_no =3D 0;
+ con->timers.rtx_no =3D 0;
} else {
- con->timer.rtx_no++;
+ con->timers.rtx_no++;
l2ca_timeoutind(con);=09
}
=20
@@ -1980,13 +1981,14 @@
l2cap_con *con;
D_TIM(__FUNCTION__ "\n");
con =3D (l2cap_con*)ptr;
-
/* do paranoia check */
if (PARANOIA_CHECKCON(con)) {
D_ERR(__FUNCTION__ ": Paranoia check failed\n");
return;
}
=20
+ con->timers.ertx.inuse =3D 0;
+
con->c_status =3D CSTATUS_ERTX_TIMEOUT;
l2ca_wakeup("ertx_timeout", con);
}
@@ -2059,7 +2061,7 @@
cmd->code =3D SIG_CONREQ;
=20
/* Don't increment ID if retransmission */
- if (con->timer.rtx_no =3D=3D 0)
+ if (con->timers.rtx_no =3D=3D 0)
cmd->id =3D set_id(con); /* S
ets sig_id_sent in l2cap_con */
else
@@ -2182,7 +2184,7 @@
cmd->code =3D SIG_CONFREQ;
=20
/* Don't increment ID if retransmission */
- if (con->timer.rtx_no =3D=3D 0)
+ if (con->timers.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");
@@ -2241,7 +2243,7 @@
cmd->code =3D SIG_DISCREQ;
=20=20=20=20=20=20=20=20=20
/* Don't increment ID if retransmission */
- if (con->timer.rtx_no =3D=3D 0)
+ if (con->timers.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");
@@ -2992,8 +2994,8 @@
{
/* multiply by 2 each rtx */
=20
- if (con->timer.rtx_no > 0)
- timeout =3D timeout*(2 << (con->timer.rtx_no - 1));
+ if (con->timers.rtx_no > 0)
+ timeout =3D timeout*(2 << (con->timers.rtx_no - 1));
=20
/* FIXME -- use flush timeout to calculate number of
retransmissions */
@@ -3001,18 +3003,18 @@
D_TIM("Starting RTX timer (%d sec)\n", timeout);
=20
/* fixme -- add timer list for multiple calls */
- if (con->timer.rtx_inuse) {
+ if (con->timers.rtx.inuse) {
D_ERR(__FUNCTION__ ": timer already used\n");
return;
}
=20
#ifdef __KERNEL__=09
- init_timer(&con->timer.rtx);
- con->timer.rtx.function =3D l2cap_rtx_timeout;
- con->timer.rtx.data =3D (unsigned long)con;
- con->timer.rtx.expires =3D jiffies + timeout*HZ;
- con->timer.rtx_inuse =3D 1;
- add_timer(&con->timer.rtx);=20=20
+ init_timer(&con->timers.rtx.timer);
+ con->timers.rtx.timer.function =3D l2cap_rtx_timeout;
+ con->timers.rtx.timer.data =3D (unsigned long)con;
+ con->timers.rtx.timer.expires =3D jiffies + timeout*HZ;
+ con->timers.rtx.inuse =3D 1;
+ add_timer(&con->timers.rtx.timer);=20=20
=20
#else /* Usermode stack */
=20
@@ -3046,11 +3048,10 @@
{
D_TIM("Disabling RTX timer\n");
#ifdef __KERNEL__
- 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;
+ if (con->timers.rtx.inuse) {
+ del_timer(&con->timers.rtx.timer);
+ con->timers.rtx.inuse =3D 0;
+ con->timers.rtx_no =3D 0;
} else
D_TIM("RTX never started\n");
#else
@@ -3065,18 +3066,18 @@
{
D_TIM("Starting ERTX timer (%d sec)\n", timeout);
=20
- if (con->timer.ertx_inuse) {
+ if (con->timers.ertx.inuse) {
D_TIM(__FUNCTION__ ": timer already used\n");
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);
+ init_timer(&con->timers.ertx.timer);
+ con->timers.ertx.timer.function =3D l2cap_ertx_timeout;
+ con->timers.ertx.timer.data =3D (unsigned long)con;
+ con->timers.ertx.timer.expires =3D jiffies + timeout*HZ;
+ con->timers.ertx.inuse =3D 1;
+ add_timer(&con->timers.ertx.timer);
#else
/* fixme */
con->timer.ertx_inuse =3D 1;
@@ -3088,17 +3089,15 @@
{
D_TIM("Disabling ERTX timer\n");
#ifdef __KERNEL__
- if (con->timer.ertx_inuse) {
- del_timer(&con->timer.ertx);
- con->timer.ertx_inuse =3D 0;
- con->timer.ertx_action =3D ERTX_ACTION_DISCONNECT;
+ if (con->timers.ertx.inuse) {
+ del_timer(&con->timers.ertx.timer);
+ con->timers.ertx.inuse =3D 0;
} else
D_TIM("ERTX never started\n");
#else /* Usermode stack */
/* FIXME */
D_ERR("disable_ertx FIXME\n");
- con->timer.ertx_inuse =3D 0;
- con->timer.ertx_action =3D ERTX_ACTION_DISCONNECT;
+ con->timers.ertx.inuse =3D 0;
#endif
}
#endif /* CONFIG_BLUETOOTH_L2CAP_USE_TIMERS */
--- rfcomm.c 2001/10/23 10:10:28 1.128
+++ rfcomm.c 2001/11/22 14:02:41 1.129
@@ -506,13 +506,13 @@
rfcomm_con rfcomm_con_list[BT_NBR_DATAPORTS];
=20
#ifdef __KERNEL__
-static struct timer_list rfcomm_timer;
+static struct bt_timer_obj rfcomm_timer;
#endif
=20
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
-static struct wait_queue *rfcomm_disconnect_wq =3D NULL;
+struct wait_queue *rfcomm_disconnect_wq;
#else
-static wait_queue_head_t rfcomm_disconnect_wq;
+wait_queue_head_t rfcomm_disconnect_wq;
#endif /* LINUX_VERSION_CODE */
=20
rpn_values rpn_val;
@@ -553,12 +553,6 @@
s32
rfcomm_module_init(void)
{
-#ifdef __KERNEL__
-#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
- init_waitqueue_head(&rfcomm_disconnect_wq);
-#endif /* LINUX_VERSION_CODE */
-#endif /* __KERNEL__ */
-
return 0;
}
=20
@@ -607,6 +601,16 @@
rpn_val.xoff_u8 =3D 0x13;
memset(&rpn_val.pm, 0 , 2); /* Set the mask to zero */
=20=20=20=20=20=20=20=20=20
+ rfcomm_timer.inuse =3D 0;
+=20=20=20=20
+#ifdef __KERNEL__
+#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0)
+ init_waitqueue_head(&rfcomm_disconnect_wq);
+#else
+ rfcomm_disconnect_wq =3D NULL;
+#endif
+#endif /* __KERNEL__ */
+
#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER
rfcomm_sec_man_init();
#endif
@@ -650,6 +654,9 @@
=20=20=20
DSYS("Shutting down RFCOMM\n");
=20
+ /* Make sure we don't have any outstanding timers */
+ release_wq_timer(&rfcomm_timer);
+
/* First try disconnecting */
for (i =3D 0; i < BT_NBR_DATAPORTS; i++) {
rfcomm_con *rfcomm =3D get_rfcomm_con(i);
@@ -667,7 +674,6 @@
for (i =3D 0; i < BT_NBR_DATAPORTS; i++) {
rfcomm_reset_con(i);
}
-
}
=20
/* This function creates an rfcomm connection over the control channel DCL=
I 0 */
@@ -778,6 +784,7 @@
/* FIXME -- check that we haven't already received=20
disconnect 'acknowledge' */
interruptible_sleep_on(&rfcomm_disconnect_wq);
+ release_wq_timer(&rfcomm_timer);
=20
/* Check that rfcomm session really disconnected */
/* FIXME -- add timer obj with status in rfcomm obj */
@@ -1181,7 +1188,6 @@
=20=09=09=09=09
/* this will take down l2cap aswell */
wake_up_interruptible(&rfcomm_disconnect_wq);
-=09=09=09=09
} else {
/* Data channel */
s32 tmp;
|
|
From: Anders J. <and...@us...> - 2002-02-06 11:23:16
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bluetooth.c 1.221 1.222=20=20=20=20=20=20=20=20=20=20=20
btmem.c 1.47 1.48=20=20=20=20=20=20=20=20=20=20=20=20
hci.c 1.190 1.191=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Patch from Alain Paschoud:
* Added IOCTL to get remotename of a device.
* Added wait_queue to block until we got a reply of the remote_name_request.
* get_remote_name now takes an extra parameter to be used if we want to
wait for the reply before returning from the function.
* Changed returnvalue of btmem_init.
The diff of the modified file(s):
--- bluetooth.c 2002/01/29 15:57:26 1.221
+++ bluetooth.c 2002/02/06 11:23:13 1.222
@@ -91,7 +91,11 @@
#ifdef CONFIG_BLUETOOTH_SUPPORT_BCSP
#include <linux/bluetooth/bcsp.h>
#endif
+#ifdef CONFIG_BLUETOOTH_PAN
+#include <linux/bluetooth/bnep.h>
+#endif
=20
+
#ifdef CONFIG_BLUETOOTH_USE_TCI
#include <linux/bluetooth/tci.h>
#endif
@@ -267,6 +271,7 @@
=20
extern hci_controller hci_ctrl;
static u8 btdm_pid =3D 0;
+extern u8 name_request_response[BT_NAME_LENGTH + 1];
=20
/****************** LOCAL VARIABLE DECLARATION SECTION *******************=
***/
=20
@@ -878,12 +883,10 @@
=20=09
case HCISETLOCALNAME:
{
- /* FIXME: If we send the length of the string too, we don't
- have to copy all the 248 byte... */
- u8 local_name[248];
+ u8 local_name[BT_NAME_LENGTH];
=20
BT_DRIVER(__FUNCTION__ ": HCISETLOCALNAME\n");
- copy_from_user(local_name, (s32*)arg, 248);
+ copy_from_user(local_name, (s32*)arg, BT_NAME_LENGTH);
hci_change_local_name(local_name);
break;
}
@@ -1219,6 +1222,32 @@
=20
#endif /* CONFIG_BLUETOOTH_PAN */
=20
+ case HCIREMOTENAME_REQUEST:
+ {
+ u8 param[6];
+ u8 tmp_bd_addr[6];
+ int i;
+=09=09
+ BT_DRIVER(__FUNCTION__ ": HCIREMOTENAME_REQUEST\n");
+ /* I recieve the BD_ADDR in param, and I send back the name */
+ copy_from_user(param, (u8*)arg, 6);
+ BT_DRIVER("HCIREMOTENAME_REQUEST: message: bd_addr : %02X:%02X:%02X:%02=
X:%02X:%02X\n",
+ param[0], param[1], param[2], param[3], param[4], param[=
5]);
+=20
+ /* Swap the whole address */
+ for (i =3D 0; i< 6; i++)
+ tmp_bd_addr[i] =3D param[5 - i];
+=20
+ if((err =3D remote_name_request(tmp_bd_addr, 1)) < 0) {
+ return err;
+ }
+
+ /* We have to copy it in param from a global variable */
+ copy_to_user((s32*)arg, name_request_response + 1, BT_NAME_LENGTH);
+=20=09=09
+ return name_request_response[0];=09
+ }
+
default:=09=09
return -ENOIOCTLCMD;
}
@@ -2600,7 +2629,9 @@
bt_init_stack(void)
{
unsigned long page;=09
+ s32 retval =3D 0;
=20
+
/* shutdown if already initiated */
if (bt_stack_initiated)
bt_shutdown();
@@ -2636,13 +2667,13 @@
add_timer(&bt_clear_led_timer);
#endif
=20
- if(btmem_init() =3D=3D -1) {
+ if((retval =3D btmem_init()) < 0) {
D_ERR("BTMEM init failed");
#ifdef __CRIS__
del_timer(&bt_clear_led_timer);
bt_set_leds(NO_BLUETOOTH_ACTIVITY);
#endif
- return -1;
+ return retval;
}
=20=09
=20
--- btmem.c 2002/01/24 16:08:47 1.47
+++ btmem.c 2002/02/06 11:23:15 1.48
@@ -129,6 +129,7 @@
#if BTMEM_TEST
btmem_test();
#endif
+ return 0;
}
=20=20
/* Returns success if deallocation was successful */
--- hci.c 2001/12/06 11:21:21 1.190
+++ hci.c 2002/02/06 11:23:15 1.191
@@ -192,7 +192,6 @@
static s32 accept_connection_request(u8 bd_addr[], u8 role);
static s32 reject_connection_request(u8 bd_addr[], u32 reason);
static s32 change_connection_packet_type(u32 hci_hdl, u32 pkt_type);
-static s32 remote_name_request(u8 *bd);
=20
/* Link Policy Commands */
static s32 role_discovery(u16 con_hdl);
@@ -305,11 +304,13 @@
struct wait_queue *inq_wq =3D NULL;
struct wait_queue *set_baudrate_wq =3D NULL;
struct wait_queue *test_wq =3D NULL;
+struct wait_queue *get_name_wq =3D NULL;
#else
wait_queue_head_t hci_wq;
wait_queue_head_t inq_wq;
wait_queue_head_t set_baudrate_wq;
wait_queue_head_t test_wq;
+wait_queue_head_t get_name_wq;
#endif /* LINUX_VERSION_CODE */
=20
static s32 test_wq_active =3D 0;
@@ -320,6 +321,8 @@
=20
static s32 test_hci_hdl;
=20
+u8 name_request_response[BT_NAME_LENGTH + 1]; /* 1 byte more to keep resul=
t */
+
/* temp solution to handle m/s switch */
static s32 force_msswitch =3D 0;
static s32 i_am_initiator =3D 0;
@@ -853,7 +856,7 @@
DM1|DH1|DM3|DH3|DM5|DH5);
#endif
set_hci_con(buf + 3, hci_hdl);
- remote_name_request(buf + 3);
+ remote_name_request(buf + 3, 0);
=20
/* enable m/s switch */=20
write_link_policy_settings(hci_hdl, 0x01);
@@ -940,10 +943,17 @@
} else {
if (strlen(buf + 7) > 248) {
D_ERR(__FUNCTION__ ": REMOTE_NAME_REQUEST_COMPLETE: too long name leng=
th %d\n", (int)strlen(buf + 7));
- break;
- }
+ } else {
set_hci_con_name(buf + 1, buf + 7);
}
+=09=09=09
+ }
+ /* Store the name in a global variable to send back to userland */
+ memcpy(name_request_response + 1, buf + 7, BT_NAME_LENGTH);
+ memcpy(name_request_response, buf, 1); /* Copy the status */
+=20=09=09
+ D_CMD(__FUNCTION__ ": wake_up(get_name_wq)\n");
+ wake_up_interruptible(&get_name_wq);
break;
=20
case ENCRYPTION_CHANGE:
@@ -1686,8 +1696,6 @@
return;
}
}
-
- D_ERR(__FUNCTION__ ": Didn't fin connecton with BD adress 0x%02x:%=
02x:%02x:%02x:%02x:%02x\n", bd[5],bd[4],bd[3],bd[2],bd[1],bd[0]);
}
=20
s32 hci_sprint_local_bd(u8 *buf)
@@ -1827,6 +1835,7 @@
init_waitqueue_head(&inq_wq);
init_waitqueue_head(&set_baudrate_wq);
init_waitqueue_head(&test_wq);
+ init_waitqueue_head(&get_name_wq);
sema_init(&hci_cmd_semaphore, 1);
sema_init(&hci_inq_semaphore, 1);
#endif /* LINUX_VERSION_CODE */
@@ -2377,9 +2386,9 @@
}
=20
s32
-remote_name_request(u8 *bd)
+remote_name_request(u8 *bd, s32 block)
{
- s32 c =3D 0;
+ s32 c =3D 0, retval =3D 0;
s32 zero =3D 0;
=20=09=09
D_CMD(__FUNCTION__ ": for bd address 0x%02x:%02x:%02x:%02x:%02x:%02x\n"
@@ -2394,8 +2403,11 @@
c +=3D 4;
=20
c_pkt.len =3D c;
-
- return send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
+ retval =3D send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
+ if(block) {
+ interruptible_sleep_on(&get_name_wq);
+ }
+ return retval;
}
=20
/* Definitions of the Link Policy Commands functions */
@@ -2518,17 +2530,15 @@
s32
hci_change_local_name(u8 *new_name)
{
-#define NAME_LEN 248
D_CMD(__FUNCTION__ ": New name: %s\n", new_name);
c_pkt.type =3D CMD_PKT;
c_pkt.opcode =3D hci_put_opcode(CHANGE_LOCAL_NAME, HCI_HC);
=20
- memset(c_pkt.data, 0, NAME_LEN);
+ memset(c_pkt.data, 0, BT_NAME_LENGTH);
strcpy(c_pkt.data, new_name);
- c_pkt.len =3D NAME_LEN;
+ c_pkt.len =3D BT_NAME_LENGTH;
=20
return send_cmd_block((u8*) &c_pkt , c_pkt.len + CMD_HDR_LEN + HCI_HDR_LE=
N, DEFAULT_TIMEOUT);=09
-#undef NAME_LEN
}
=20
=20
|
|
From: Anders J. <and...@us...> - 2002-02-13 14:05:07
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bnep.c 1.6 1.7=20=20=20=20=20=20=20=20=20=20=20=20=20
l2cap_sec.c 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20
sec_client.c 1.19 1.20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Check that L2CAP really have an upper connection when we got a disconnect=
_ind.
* Always send authentication_pending as a reply on a l2cap_connection_req w=
hen
using the securitymanager and BNEP.
* Handle NULL-BD adresses in the sec_client.
The diff of the modified file(s):
--- bnep.c 12 Feb 2002 13:54:00 -0000 1.6
+++ bnep.c 13 Feb 2002 14:05:03 -0000 1.7
@@ -1416,11 +1416,13 @@
/* acknowledge the disconnect */
if (l2ca_disconnect_rsp(l2cap)) {
D_ERR("ether_disconnect_ind: l2ca_disconnect_rsp failed\n");
- //return;
}
+=09
+ if(dev) {
local =3D dev->priv;
local->l2cap =3D NULL;
local->state =3D DISCONNECTED;
+ }
}
=20
static void=20
--- l2cap_sec.c 15 Feb 2001 16:27:33 -0000 1.3
+++ l2cap_sec.c 13 Feb 2002 14:05:04 -0000 1.4
@@ -115,6 +115,9 @@
/* send connection response PSM security block */
l2ca_connect_rsp(con, RES_SECNEG, STAT_NOINFO);
break;
+ case AUTHENTICATION_PENDING:
+ l2ca_connect_rsp(con, RES_PENDING, STAT_AUTHENTPEND);
+ break;
=20
case GENERAL_FAILURE:
/* send connection response PSM security block */
--- sec_client.c 10 Dec 2001 16:18:14 -0000 1.19
+++ sec_client.c 13 Feb 2002 14:05:04 -0000 1.20
@@ -171,9 +171,10 @@
s32 delete_link_key(link_key_information_type *link_key);
=20
/****************** GLOBAL VARIABLE DECLARATION SECTION ******************=
***/
+u8 null_bd_addr[BD_ADDRESS_SIZE];
=20
-/****************** LOCAL VARIABLE DECLARATION SECTION *******************=
***/
=20
+/****************** LOCAL VARIABLE DECLARATION SECTION *******************=
***/
static link_key_list_type link_key_list;
=20
#ifdef __KERNEL__
@@ -300,6 +301,7 @@
void=20
sec_man_init(enum security_requests user)
{
+ int i;
#ifndef __KERNEL__
sec_man_sock =3D open_socket(SEC_MAN_SRV_SOCK);
#endif
@@ -307,6 +309,10 @@
=20
/* To indicate that nothing is ready */
security_query.originator =3D SEC_CLIENT;=20
+=09
+ for(i =3D 0 ; i < BD_ADDRESS_SIZE ; i++) {
+ null_bd_addr[i] =3D 0;
+ }
}
=20
void
@@ -552,7 +558,12 @@
D_PROC("Called sec_man_event user:%d event:%02x\n", user, event);
security_query.request_type =3D user;
security_query.request_value =3D event;
+ if(bd_addr) {
memcpy(security_query.remote_bd, bd_addr, BD_ADDRESS_SIZE);
+ } else {
+ memcpy(security_query.remote_bd, null_bd_addr, BD_ADDRESS_SIZE);
+ }
+=09=09
security_query.originator =3D BT_SEC_MAN;
=20=09=09
if (param_len > MAX_EVENT_DATA_LENGTH) {
|
|
From: Anders J. <and...@us...> - 2002-02-25 14:38:05
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bnep.c 1.9 1.10=20=20=20=20=20=20=20=20=20=20=20=20
rfcomm.c 1.131 1.132=20=20=20=20=20=20=20=20=20=20=20
sdp.c 1.85 1.86=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Corrected cut-and-paste mistake.
* Discovered that funcion isn't an english word! :)
The diff of the modified file(s):
--- bnep.c 25 Feb 2002 14:08:35 -0000 1.9
+++ bnep.c 25 Feb 2002 14:28:18 -0000 1.10
@@ -1322,7 +1322,7 @@
=20=09
/* If we weren't the initiator, we now send our configuration request. */
/* Fix l2cap->remote_mtu should be max BNEP_MTU??? */
- if (!l2ca_local_conf_done(con) && !con->conf_req_sent) {
+ if (!l2ca_local_conf_done(l2cap) && !l2cap->conf_req_sent) {
if (l2ca_config_req(l2cap, BNEP_MTU,=20
NULL, BNEP_FLUSH_TIMEOUT, 0)) {
D_ERR(__FUNCTION__": l2ca_config_req failed\n");
--- rfcomm.c 25 Feb 2002 14:08:36 -0000 1.131
+++ rfcomm.c 25 Feb 2002 14:28:19 -0000 1.132
@@ -911,7 +911,7 @@
}
=20
/* check if we received a pos response on a previous conf req */=20
- if (!l2ca_local_conf_done(con) && !con->conf_req_sent) {
+ if (!l2ca_local_conf_done(l2cap) && !l2cap->conf_req_sent) {
l2cap->local_mtu=3Dl2cap->remote_mtu;
=20
DSYS(FNC"Local l2cap mtu set to %d\n",=20
--- sdp.c 25 Feb 2002 14:08:37 -0000 1.85
+++ sdp.c 25 Feb 2002 14:28:19 -0000 1.86
@@ -526,7 +526,7 @@
}
=20
if(l2cap->current_state !=3D OPEN) {
- DSYS(__FUNTION__ ": Configuration not done yet\n");
+ DSYS(__FUNCTION__ ": Configuration not done yet\n");
}
=20
/* Find the connecting sdp_con */
|
|
From: Alain P. <apa...@us...> - 2002-05-15 13:29:44
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
hci.c 1.200 1.201=20=20=20=20=20=20=20=20=20=20=20=20=20
hci_vendor.c 1.64 1.65=20=20=20=20=20=20=20=20=20=20=20=20=20=20
unplug_test.c 1.11 1.12=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Implement the deep_sleep mode for Texas Instruments chip.
Allow to go in deep sleep and to exit from deep sleep. For the
moment only from unplug.
The diff of the modified file(s):
--- hci.c 25 Apr 2002 15:08:49 -0000 1.200
+++ hci.c 15 May 2002 13:29:41 -0000 1.201
@@ -364,6 +364,7 @@
u8 *buf; /* Temporary pointer to the incoming data */
u32 tmp_data_len;
=20=20
+=20
PRINTPKT(__FUNCTION__ ": ", data, count);
=20=20=20
tmp_data_len =3D count;
@@ -387,6 +388,16 @@
case ACL_PKT: state =3D WAIT_FOR_ACL_HDR; break;
case SCO_PKT: state =3D WAIT_FOR_SCO_HDR; break;
default:
+=09=09=09=20=20
+ /* Call vendor specific function if needed */
+#ifdef CONFIG_BLUETOOTH_TEXASINSTRUMENTS=09=09=09=20=20
+ if (hci_receive_data_texas_specific(buf, count) =3D=3D 0) {
+ /* Data has been processed by the function. Normaly, it's one byte.=
*/
+ /* What to do if we received more that one byte ? */
+ return;
+ }
+#endif
+=09=09=09
D_ERR(__FUNCTION__ ": discarding %d bytes\n",
count);
/* An unrecognized HCI header type is usually a
--- hci_vendor.c 10 May 2002 12:27:51 -0000 1.64
+++ hci_vendor.c 15 May 2002 13:29:41 -0000 1.65
@@ -89,14 +89,28 @@
#endif
=20
#ifdef CONFIG_BLUETOOTH_TEXASINSTRUMENTS
-/* Texas instrument defines */
-#define TEXAS_SET_SLEEP_MODE 0x0C
+/* Texas instruments defines */
+#define TEXAS_SET_SLEEP_MODE 0x30c
+
+/* Texas instruments specific short UART messages protocol */
+#define TEXAS_MESSAGE_DEEP_SLEEP_REQUEST 0x30
+#define TEXAS_MESSAGE_DEEP_SLEEP_ACKNOWLEDGE 0x31
+#define TEXAS_MESSAGE_WAKE_UP_REQUEST 0x32
+#define TEXAS_MESSAGE_WAKE_UP_ACKNOWLEDGE 0x33
+
+/* Texas machine state */
+enum texas_states { TI_NORMAL_STATE, TI_WAIT_FOR_DEEP_SLEEP, TI_DEEP_SLEEP=
, TI_WAIT_FOR_WAKE_UP};
#endif
=20
#define BT_HW_INFO_MAX 255
=20
/****************** LOCAL VARIABLE DECLARATION SECTION *******************=
***/
=20
+#ifdef CONFIG_BLUETOOTH_TEXASINSTRUMENTS
+/* The states for specific TI modes */
+static enum texas_states texas_state =3D TI_NORMAL_STATE;
+#endif
+
/* These are declared in hci.c */
extern cmd_pkt c_pkt;
=20
@@ -1441,7 +1455,7 @@
#elif defined(CONFIG_BLUETOOTH_TEXASINSTRUMENTS)
=20
/*************************************************************************=
****/
-/************** Functions for Texas Instrument Bluetooth chips ***********=
****/
+/************** Functions for Texas Instruments Bluetooth chips **********=
****/
/*************************************************************************=
****/
=20
#define VENDOR " [Texas Instruments]"
@@ -1476,7 +1490,30 @@
void
process_vendor_return_param(u32 ocf, u8* r_val)
{
- D_ERR(__FUNCTION__ VENDOR " Texas specific: Invalid reply (0x%x)\n", ocf);
+ switch (ocf) {
+=09
+ case TEXAS_SET_SLEEP_MODE:
+ if (r_val[0] !=3D 0) {
+ D_ERR(__FUNCTION__ VENDOR ": Set sleep mode failure\n");
+ }
+ else {
+ D_CMD(__FUNCTION__ VENDOR ": Set sleep mode : success\n");
+ }
+ break;
+ case 0x0C:
+ D_ERR(__FUNCTION__ VENDOR ": HCI_ERR_COMMAND_DISALLOWED\n");
+ release_cmd_timer();
+ wake_up_interruptible(&hci_wq);
+ break;
+
+ default:
+ release_cmd_timer();
+ D_ERR(__FUNCTION__ VENDOR " Manufacturer specific: Invalid reply (0x%x)\=
n",
+ ocf);
+ wake_up_interruptible(&hci_wq);
+ break;
+ } /* end of switch */
+
}
=20
char*
@@ -1484,6 +1521,111 @@
{
return "Texas Instruments";
}
+
+s32
+hci_set_sleep_mode(int big_sleep, int deep_sleep)
+{
+ u8 settings[2];
+=20=20
+ D_CMD(__FUNCTION__ VENDOR "\n");
+=09
+ /* Verify that big_sleep and deep_sleep are 1 or 0 */
+ if ((big_sleep > 1) || (big_sleep < 0) || (deep_sleep > 1) || (deep_sleep=
< 0)) {
+ D_ERR(__FUNCTION__ VENDOR ": Deep sleep and/or big sleep out of range\n"=
);
+ return -1;
+ }
+=09=09=09
+ /* Verify that we don't want deep_sleep */
+ if (! deep_sleep) {
+ if ((texas_state =3D=3D TI_WAIT_FOR_DEEP_SLEEP) || (texas_state =3D=3D T=
I_DEEP_SLEEP))
+ {
+ /* We should wake-up */
+ u8 command;
+
+ command =3D TEXAS_MESSAGE_WAKE_UP_REQUEST;
+ texas_state =3D TI_WAIT_FOR_WAKE_UP;
+ return hci_send_raw_data(&command, 1);
+ }
+ }
+=09
+ settings[0] =3D big_sleep;
+ settings[1] =3D deep_sleep;
+=20=20
+ PRINTPKT(__FUNCTION__ VENDOR ":", settings, 2);
+ c_pkt.type =3D CMD_PKT;
+ c_pkt.opcode =3D hci_put_opcode(TEXAS_SET_SLEEP_MODE, MANUFACTURER_SPEC);
+ c_pkt.len =3D 2;
+ memcpy(c_pkt.data, settings, 2);
+=09
+ /* Set texas state machine */
+ if (deep_sleep)
+ texas_state =3D TI_WAIT_FOR_DEEP_SLEEP;
+=09
+ /* TO DO : if we ask for deep sleep when in connection, module is set do =
big sleep. */
+ /* So we shouldn't get into TI_WAIT_FOR_DEEP_SLEEP state */
+=09
+ return send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
+}
+
+
+/**** hci_receive_data_texas_specific ************************************=
**/
+/* =
*/
+/* this function process the UART short message protocol specific to =
*/
+/* Texas Instruments =
*/
+/* =
*/
+/* Return 0 if data has been correctly interpreted =
*/
+/* Return -1 if not =
*/
+/*************************************************************************=
**/
+
+int
+hci_receive_data_texas_specific(u8* buf, u32 count)
+{
+
+
+/* Just verify that we are waiting for a request */
+ if (texas_state =3D=3D TI_NORMAL_STATE) {
+ return -1; /* We don't wait for anything */
+ }
+
+ switch(*buf) {
+=20=20=20=20
+ case TEXAS_MESSAGE_DEEP_SLEEP_REQUEST: /* Deep sleep request */
+ {
+ u8 acknowledge;
+ D_CMD(__FUNCTION__ ": Deep sleep request\n");
+ if (texas_state !=3D TI_WAIT_FOR_DEEP_SLEEP) {
+ D_ERR(__FUNCTION__ VENDOR ": Receive deep sleep request, but we are no=
t waiting for deep sleep\n");=20
+ return -1;
+ }
+=09=09=09
+ acknowledge =3D TEXAS_MESSAGE_DEEP_SLEEP_ACKNOWLEDGE;
+ hci_send_raw_data(&acknowledge, 1);
+ texas_state =3D TI_DEEP_SLEEP;
+ return 0;
+ }
+ break;
+ case TEXAS_MESSAGE_WAKE_UP_ACKNOWLEDGE: /* Wake-up acnknowledge */
+ {
+=09=09=09
+ if (texas_state !=3D TI_WAIT_FOR_WAKE_UP) {
+ D_ERR(__FUNCTION__ VENDOR ": Receive Wake-up request, but hardware was=
not in deep_sleep\n");=20
+ return -1;
+ }
+ /* Change state before to call hci_set_sleep_mode */
+ texas_state =3D TI_NORMAL_STATE;
+ /* The module is now waked up. Don't allow it to go back to sleep mode =
*/
+ hci_set_sleep_mode(0, 0);
+ return 0;
+ }
+ break;
+ default:
+ /* Another unknown data : let deal the stack with */
+ return -1;
+
+ }
+}
+
+
=20
#else
/*************************************************************************=
****/
--- unplug_test.c 11 Apr 2002 11:53:22 -0000 1.11
+++ unplug_test.c 15 May 2002 13:29:42 -0000 1.12
@@ -2415,6 +2415,24 @@
return rfcomm_send_data(CREATE_RFCOMM_ID(0,2), atd, strlen(atd));
}
=20
+#ifdef CONFIG_BLUETOOTH_TEXASINSTRUMENTS
+
+static s32 test_ti_deep_sleep(void)
+{
+ printk("test_ti_deep_sleep\n");
+ hci_set_sleep_mode(1, 1);
+ return 0;
+}
+
+static s32 test_ti_exit_deep_sleep(void)
+{
+ printk("test_ti_exit_deep_sleep\n");
+ hci_set_sleep_mode(0, 0);
+ return 0;
+}
+
+#endif
+
s32 process_test_cmd(s32 test_case)
{
if (!test_is_initialized) {
@@ -2554,6 +2572,10 @@
case 56: return test_5_6();
case 57: return test_5_7();
case 100: return test_gateway_call();
+#ifdef CONFIG_BLUETOOTH_TEXASINSTRUMENTS
+ case 7000: return test_ti_deep_sleep();
+ case 7001: return test_ti_exit_deep_sleep();
+#endif
case 9001: return sdp_send_data(&sdp_con_list[0], pan_1, pan_1[4] =
+ 5);
case 9002: return sdp_send_data(&sdp_con_list[0], pan_2, pan_2[4] + 5);=
=20=20
=20=20=20=20=20=20=20=20=20
|
|
From: Alain P. <apa...@us...> - 2002-08-05 15:38:12
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
bluetooth.c 1.230 1.231=20=20=20=20=20=20=20=20=20=20=20=20=20
bt_proc.c 1.25 1.26=20=20=20=20=20=20=20=20=20=20=20=20=20=20
rfcomm.c 1.133 1.134=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added information in proc file bt_channel_con when disconnecting. New synta=
x is :
<line>:<server channel>:<state>
where <state> is either "connected" or "disconnected".
The diff of the modified file(s):
--- bluetooth.c 1 Aug 2002 16:13:17 -0000 1.230
+++ bluetooth.c 5 Aug 2002 15:38:11 -0000 1.231
@@ -277,6 +277,7 @@
#ifdef CONFIG_BLUETOOTH_PROC
extern int new_con_srv_channel;
extern int new_con_line;
+extern int new_con_connected;
=20
#ifdef __KERNEL__
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
@@ -2398,6 +2399,7 @@
#ifdef CONFIG_BLUETOOTH_PROC
new_con_srv_channel =3D bt_ctrl.session[line].dlci >> 1;
new_con_line =3D line;
+ new_con_connected =3D 1; // New connection
/* Wake up if someone reads the proc file */
wake_up_interruptible(&channel_con_wq);
#endif
@@ -2517,6 +2519,7 @@
void
bt_disconnect_ind(u32 con_id)
{
+=09
if (GET_PSM(con_id) =3D=3D RFCOMM_LAYER)
BT_DRIVER(__FUNCTION__ ": RFCOMM dlci: %d\n",
GET_RFCOMMDLCI(con_id));
--- bt_proc.c 1 Aug 2002 16:19:28 -0000 1.25
+++ bt_proc.c 5 Aug 2002 15:38:11 -0000 1.26
@@ -113,9 +113,10 @@
=20
#ifdef CONFIG_BLUETOOTH_PROC
=20
-/* Next variables are declared in bluetooth.c */
+/* Next variables are used to store information to write in channel_con pr=
oc file */
int new_con_srv_channel;
int new_con_line;
+int new_con_connected; // 0 =3D disconnected, 1 =3D connected
=20
=20
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
@@ -400,9 +401,12 @@
/* Maximum : 6:30, so 5 characters with \0 */
=20
position =3D 0;
- position +=3D sprintf(buf + position,"%d", new_con_line);
- position +=3D sprintf(buf + position, ":");
- position +=3D sprintf(buf + position, "%d\n", new_con_srv_channel);
+ position +=3D sprintf(buf + position,"%d:", new_con_line);
+ position +=3D sprintf(buf + position, "%d:", new_con_srv_channel);
+ if (new_con_connected)
+ position +=3D sprintf(buf + position, "connected\n");
+ else
+ position +=3D sprintf(buf + position, "disconnected\n");
=20=09
return position;=09
}
--- rfcomm.c 11 Apr 2002 10:19:50 -0000 1.133
+++ rfcomm.c 5 Aug 2002 15:38:11 -0000 1.134
@@ -501,6 +501,23 @@
=20
/****************** GLOBAL VARIABLE DECLARATION SECTION ******************=
***/
=20
+/****************** EXTERNAL VARIABLE DECLARATION SECTION ****************=
***/
+
+/* Use global variables to store line and server channel of a new incoming=
connection */
+#ifdef CONFIG_BLUETOOTH_PROC
+extern int new_con_srv_channel;
+extern int new_con_line;
+extern int new_con_connected;
+#endif
+
+#ifdef __KERNEL__
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
+extern struct wait_queue *channel_con_wq =3D NULL;
+#else
+extern wait_queue_head_t channel_con_wq;
+#endif /* LINUX_VERSION_CODE */
+#endif /* __KERNEL__ */
+
/****************** LOCAL VARIABLE DECLARATION SECTION *******************=
***/
=20
/* The crctable for the FEC field */
@@ -1177,6 +1194,14 @@
rfcomm->dlci[tmp_dlci].state =3D DISCONNECTED;
tmp =3D get_connected_dlci(rfcomm);
=20
+#ifdef CONFIG_BLUETOOTH_PROC
+ new_con_srv_channel =3D tmp_dlci >> 1;
+ new_con_line =3D rfcomm->line;
+ new_con_connected =3D 0; // Disconnection
+ /* Wake up if someone reads the proc file */
+ wake_up_interruptible(&channel_con_wq);=09=09
+#endif=09
+
if (tmp >=3D 0) {
rfcomm->dlci[tmp].state =3D DISCONNECTING;
send_disc(rfcomm, tmp);
@@ -1222,6 +1247,14 @@
} else {
rfcomm->dlci[tmp_dlci].state =3D DISCONNECTED;
send_ua(rfcomm, tmp_dlci);
+=09=09=09
+#ifdef CONFIG_BLUETOOTH_PROC
+ new_con_srv_channel =3D tmp_dlci >> 1;
+ new_con_line =3D rfcomm->line;
+ new_con_connected =3D 0; // Disconnection
+ /* Wake up if someone reads the proc file */
+ wake_up_interruptible(&channel_con_wq);=09=09
+#endif
D_CTRL("dlci %d was disconnected\n", tmp_dlci);
bt_disconnect_ind(CREATE_RFCOMM_ID(rfcomm->line,=20
tmp_dlci));
|
|
From: Peter K. <pk...@us...> - 2002-09-27 12:54:43
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
l2cap.c 1.133 1.134=20=20=20=20=20=20=20=20=20=20=20=20=20
l2cap_con.c 1.14 1.15=20=20=20=20=20=20=20=20=20=20=20=20=20=20
rfcomm.c 1.136 1.137=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Made the user stack compile again (I am pretty sure it does not
work, but at least it compiles).
The diff of the modified file(s):
--- l2cap.c 11 Apr 2002 10:17:38 -0000 1.133
+++ l2cap.c 27 Sep 2002 12:54:11 -0000 1.134
@@ -3116,7 +3116,7 @@
add_timer(&con->timers.ertx.timer);
#else
/* fixme */
- con->timer.ertx_inuse =3D 1;
+ con->timers.ertx.inuse =3D 1;
#endif
}
=20
--- l2cap_con.c 1 Aug 2002 16:19:28 -0000 1.14
+++ l2cap_con.c 27 Sep 2002 12:54:11 -0000 1.15
@@ -445,11 +445,15 @@
this connection */
if(con->timers.rtx.inuse) {
wake_up_interruptible(&con->wq);
+#ifdef __KERNEL__
del_timer(&con->timers.rtx.timer);
+#endif
}
if(con->timers.ertx.inuse) {
wake_up_interruptible(&con->wq);
+#ifdef __KERNEL__
del_timer(&con->timers.ertx.timer);
+#endif
}
=20
if (con_list.count =3D=3D 1) {
--- rfcomm.c 9 Aug 2002 09:03:36 -0000 1.136
+++ rfcomm.c 27 Sep 2002 12:54:11 -0000 1.137
@@ -526,9 +526,7 @@
/* One RFCOMM connection for each ttyBTx */
rfcomm_con rfcomm_con_list[BT_NBR_DATAPORTS];
=20
-#ifdef __KERNEL__
static struct bt_timer_obj rfcomm_timer;
-#endif
=20
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
struct wait_queue *rfcomm_disconnect_wq;
@@ -675,8 +673,10 @@
=20=20=20
DSYS("Shutting down RFCOMM\n");
=20
+#ifdef __KERNEL__
/* Make sure we don't have any outstanding timers */
release_wq_timer(&rfcomm_timer);
+#endif
=20
/* First try disconnecting */
for (i =3D 0; i < BT_NBR_DATAPORTS; i++) {
@@ -723,7 +723,6 @@
tmp_dlci =3D (server_chn << 1) | (~rfcomm->initiator & 0x1);
=20=09
if (!(rfcomm->l2cap)) {
-
rfcomm->dlci[0].state =3D CONNECTING;=20=20=20=20
=20
/* we don't have a l2cap connection yet */
@@ -732,12 +731,10 @@
return retval;
}
} else if (!((rfcomm->l2cap)->current_state =3D=3D OPEN)) {
-=09=09
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) {
-
/* we have an l2cap channel (server ch) */
D_CTRL(FNC"we already have an l2cap channel)\n");
=20
@@ -751,7 +748,6 @@
return send_sabm(rfcomm, 0);
}
} else if (rfcomm->dlci[tmp_dlci].state !=3D DISCONNECTED) {
-
D_ERR(FNC"trying to connect a non DISCONNECTED server channel (%d)\n",se=
rver_chn);
return -MSGCODE(MSG_LAYER_RFCOMM, RFCOMM_SRVCHN_CONNECTED);
} else {
@@ -805,7 +801,9 @@
/* FIXME -- check that we haven't already received=20
disconnect 'acknowledge' */=09
interruptible_sleep_on(&rfcomm_disconnect_wq);
+#ifdef __KERNEL__
release_wq_timer(&rfcomm_timer);
+#endif
=20
/* Check that rfcomm session really disconnected */
/* FIXME -- add timer obj with status in rfcomm obj */
@@ -831,7 +829,6 @@
return 0;
}
=20=09
-
/* The lower protocol layer, L2CAP, indicates that a new connection has be=
en
established at a lower layer. RFCOMM should ask the control block wheth=
er
to accept or reject the connection and then reply to L2CAP with
@@ -849,7 +846,6 @@
=20
return;
} else {
-=20=20=20=20=20=20=20=20=20=20
if (l2ca_connect_rsp(l2cap, RES_SUCCESS, STAT_NOINFO)) {
D_ERR("rfcomm_connect_ind: l2ca_connect_rsp failed\n");
return;
@@ -913,7 +909,6 @@
} else {
D_ERR(FNC"couldn't find the correct rfcomm_con object\n");
}
-
}
=20
=20
@@ -975,8 +970,8 @@
else if (!rfcomm->initiator &&=20
((l2cap->remote_mtu-5) < DEF_RFCOMM_MTU) )
{
-=09=09=09
s32 j;
+
DSYS(FNC"Setting RFCOMM frame size to %d\n",=20
l2cap->remote_mtu-5);
=20=09=09=09
@@ -985,7 +980,7 @@
}
}
} else {
- DSYS(FNC": configuration not done yet\n");
+ DSYS(FNC"configuration not done yet\n");
}
}
=20
@@ -1024,7 +1019,6 @@
void=20
rfcomm_disconnect_cfm(l2cap_con *l2cap)
{
-
rfcomm_con *rfcomm;
=20=20=20
D_CTRL(FNC"disconnected\n");
@@ -1044,8 +1038,6 @@
l2cap->c_result);
#endif=09
rfcomm_reset_con(rfcomm->line);
-=09
-
}
=20
/* This function should be called from the L2CAP layer data should pos32 at
@@ -1064,8 +1056,7 @@
=20
RF_DATA(FNC"rfcomm_receive_data:",data,len);
=20=09
- D_REC(FNC"%d bytes, our cid is %d\n",len,=20
- l2cap->remote_cid);
+ D_REC(FNC"%d bytes, our cid is %d\n", len, l2cap->remote_cid);
short_pkt =3D (short_frame*) data;
=20
tmp_dlci =3D (((short_pkt->h.addr.server_chn & 0x1f) << 1) |
@@ -1110,7 +1101,6 @@
tmp_dlci, rfcomm);
=20
/* fixme -- check result and send neg response if not allowed */
-=09=09=09
#else
bt_connect_ind(CREATE_RFCOMM_ID(rfcomm->line, tmp_dlci));
rfcomm->dlci[tmp_dlci].state =3D CONNECTED;
@@ -1126,7 +1116,6 @@
send_ua(rfcomm, tmp_dlci);
#endif /* CONFIG_BLUETOOTH_USE_SECURITY_MANAGER */
} else {
-
D_CTRL(FNC"no server on channel %d, sending DM\n",
tmp_dlci);
=20=20=20=20=20=20=20
@@ -1177,7 +1166,6 @@
rfcomm->dlci[tmp_dlci].initiator =3D TRUE;
=20
} else if (rfcomm->dlci[tmp_dlci].state =3D=3D DISCONNECTING) {
-=09=09=20=20
if (tmp_dlci =3D=3D 0) {
/* Control channel */
#ifdef __KERNEL__
@@ -1198,9 +1186,11 @@
new_con_srv_channel =3D tmp_dlci >> 1;
new_con_line =3D rfcomm->line;
new_con_connected =3D 0; // Disconnection
+#ifdef __KERNEL__
/* Wake up if someone reads the proc file */
wake_up_interruptible(&channel_con_wq);=09=09
#endif=09
+#endif
=20
if (tmp >=3D 0) {
rfcomm->dlci[tmp].state =3D DISCONNECTING;
@@ -1208,7 +1198,6 @@
} else {
D_ERR("Could not find connected DLCI\n");
}
-=09=09=09=09
}
} else if (rfcomm->dlci[tmp_dlci].state =3D=3D DISCONNECTED) {
rfcomm->dlci[tmp_dlci].state =3D CONNECTED;
@@ -1249,9 +1238,11 @@
new_con_srv_channel =3D tmp_dlci >> 1;
new_con_line =3D rfcomm->line;
new_con_connected =3D 0; // Disconnection
+#ifdef __KERNEL__
/* Wake up if someone reads the proc file */
wake_up_interruptible(&channel_con_wq);=09=09
#endif
+#endif
=20
send_ua(rfcomm, 0);
} else {
@@ -1291,16 +1282,15 @@
D_REC(FNC"long packet length %d\n",
uih_len);
if (uih_len > (len - 5)) {
- D_WARN(FNC", Long packet length doesn't match, setting length to l2cap=
len - 5\n");
+ D_WARN(FNC"Long packet length doesn't match, setting length to l2cap l=
en - 5\n");
uih_len =3D len - 5;
}
-=09=09=09
} else {
D_REC(FNC"Short UIH pkt received\n");
uih_len =3D short_pkt->h.length.len;
uih_data_start =3D short_pkt->data;
if (uih_len > (len - 4)) {
- D_WARN(FNC", Short packet length doesn't match, setting length to l2ca=
p len - 4\n");
+ D_WARN(FNC"Short packet length doesn't match, setting length to l2cap =
len - 4\n");
uih_len =3D len - 4;
}
}
@@ -1320,7 +1310,6 @@
}
=20=09=09=09
/* feed uih data to tty if any */
-
}
=20
if (crc_check(data, SHORT_CRC_CHECK,
@@ -1340,7 +1329,7 @@
--rfcomm->dlci[tmp_dlci].remote_credits;
}
=20=09=09=09=09
- D_CTRL(FNC": Remote credits: %d\n",rfcomm->dlci[tmp_dlci].remote_credi=
ts);
+ D_CTRL(FNC"Remote credits: %d\n",rfcomm->dlci[tmp_dlci].remote_credits=
);
/* Send new credits in packet only if we totally run out of them. When=
we send
data to the other side we usually send credits needed together with=
the data
(piggy-backed) */
@@ -1349,7 +1338,6 @@
rfcomm->dlci[tmp_dlci].remote_credits +=3D newcredits;
rfcomm_send_credits(rfcomm, tmp_dlci, newcredits);
D_SND(FNC"Remote credits: %d\n",rfcomm->dlci[tmp_dlci].remote_credits=
);
-=09=09=09=09=09
}
}=09=09=09
bt_receive_top(con_id, uih_data_start, uih_len);
@@ -1921,12 +1909,13 @@
if (send_credit) {
l_pkt->h.control =3D SET_PF(UIH);
l_pkt->data[0] =3D (newcredits);
- D_SND(FNC": Remote credits: %d\n",rfcomm->dlci[dlci].remote_credits);
+ D_SND(FNC"Remote credits: %d\n", rfcomm->dlci[dlci].remote_credits);
memcpy(l_pkt->data + 1, data, len);
} else {
memcpy(l_pkt->data, data, len);
}
- l_pkt->data[len + send_credit] =3D crc_calc((u8*) l_pkt, SHORT_CRC_CHECK=
);
+ l_pkt->data[len + send_credit] =3D
+ crc_calc((u8*) l_pkt, SHORT_CRC_CHECK);
swap_long_frame(l_pkt);
} else {
short_frame *s_pkt;
@@ -1952,12 +1941,13 @@
if (send_credit) {
s_pkt->h.control =3D SET_PF(UIH);
s_pkt->data[0] =3D (newcredits);
- D_SND(FNC": Remote credits: %d\n",rfcomm->dlci[dlci].remote_credits);
+ D_SND(FNC"Remote credits: %d\n",rfcomm->dlci[dlci].remote_credits);
memcpy(s_pkt->data + 1, data, len);
} else {
memcpy(s_pkt->data, data, len);
}
- s_pkt->data[len + send_credit] =3D crc_calc((u8*) s_pkt, SHORT_CRC_CHECK=
);
+ s_pkt->data[len + send_credit] =3D
+ crc_calc((u8*) s_pkt, SHORT_CRC_CHECK);
}
=20
/* FIXME - How should we propagate result up to higher layers ?
@@ -2028,8 +2018,8 @@
=20=20=20=20=20
set_uih_hdr((short_frame*) uih_pkt, CTRL_CHAN, len +=20
sizeof(mcc_long_frame), rfcomm->initiator);
- uih_pkt->data[uih_pkt->h.length.bits.len] =3D crc_calc((u8*) uih_pkt,=20
- SHORT_CRC_CHECK);
+ uih_pkt->data[uih_pkt->h.length.bits.len] =3D
+ crc_calc((u8*) uih_pkt, SHORT_CRC_CHECK);
mcc_pkt =3D (mcc_long_frame*) uih_pkt->data;
=20
/* Always one in the TEST messages */
@@ -2062,8 +2052,8 @@
=20=20=20=20=20
set_uih_hdr((short_frame*) uih_pkt, CTRL_CHAN, len +
sizeof(mcc_short_frame), rfcomm->initiator);
- uih_pkt->data[uih_pkt->h.length.bits.len] =3D crc_calc((u8*) uih_pkt,=20
- SHORT_CRC_CHECK);
+ uih_pkt->data[uih_pkt->h.length.bits.len] =3D
+ crc_calc((u8*) uih_pkt, SHORT_CRC_CHECK);
mcc_pkt =3D (mcc_short_frame*) uih_pkt->data;
=20
/* Always one in the TEST messages */
@@ -2095,8 +2085,8 @@
=20=20=20=20=20
set_uih_hdr((void*) uih_pkt, CTRL_CHAN, len
+ sizeof(mcc_short_frame), rfcomm->initiator);
- uih_pkt->data[uih_pkt->h.length.len] =3D crc_calc((u8*) uih_pkt,=20
- SHORT_CRC_CHECK);
+ uih_pkt->data[uih_pkt->h.length.len] =3D
+ crc_calc((u8*) uih_pkt, SHORT_CRC_CHECK);
mcc_pkt =3D (mcc_short_frame*) uih_pkt->data;
=20=20=20=20=20
/* Always one in the TEST messages */
@@ -2136,8 +2126,8 @@
uih_pkt =3D (short_frame*) (tx_buf->data + sizeof(rfcomm_tx_buf));
set_uih_hdr(uih_pkt, CTRL_CHAN, sizeof(mcc_short_frame),
rfcomm->initiator);
- uih_pkt->data[sizeof(mcc_short_frame)] =3D crc_calc((u8*) uih_pkt,=20
- SHORT_CRC_CHECK);
+ uih_pkt->data[sizeof(mcc_short_frame)] =3D
+ crc_calc((u8*) uih_pkt, SHORT_CRC_CHECK);
mcc_pkt =3D (mcc_short_frame*) (uih_pkt->data);
=20=20=20
mcc_pkt->h.type.ea =3D EA;
@@ -2173,8 +2163,8 @@
uih_pkt =3D (short_frame*) (tx_buf->data + sizeof(rfcomm_tx_buf));
set_uih_hdr(uih_pkt, CTRL_CHAN, sizeof(mcc_short_frame),
rfcomm->initiator);
- uih_pkt->data[sizeof(mcc_short_frame)] =3D crc_calc((u8*) uih_pkt,=20
- SHORT_CRC_CHECK);
+ uih_pkt->data[sizeof(mcc_short_frame)] =3D
+ crc_calc((u8*) uih_pkt, SHORT_CRC_CHECK);
mcc_pkt =3D (mcc_short_frame*) (uih_pkt->data);
=20
mcc_pkt->h.type.ea =3D 1;
@@ -2575,7 +2565,6 @@
=20=09=09
for (j =3D 0; j < 62; j++){=09
if (rfcomm_con_list[i].dlci[j].state !=3D DISCONNECTED){
-=09=09=09=09
len+=3Dsprintf(buf+len, "line[%d] mtu[%d] ",
rfcomm_con_list[i].line,=20
rfcomm_con_list[i].dlci[j].mtu);
@@ -2592,6 +2581,7 @@
}
}
}
+
return len;
}
=20
@@ -2599,8 +2589,10 @@
s32 rfcomm_sprint_status(u8 *buf)
{
s32 len=3D0;
+
len+=3Dsprintf(buf+len, "\n[RFCOMM]\n\n");
len+=3Drfcomm_sprint_con(buf+len);
+
return len;
}
=20
@@ -2632,7 +2624,6 @@
data[5] =3D 0x70;
=20
return l2cap_send_data(tx_buf, rfcomm->l2cap);
-=20=20
}
=20
s32
@@ -2651,7 +2642,6 @@
} else {
return send_pn_msg(rfcomm, 0, frame_size, 0, 0, dlci, TRUE);
}
-=09
}
=20
s32
|
|
From: Anders J. <and...@us...> - 2003-01-13 19:49:10
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
bluetooth.c 1.235 1.236=20=20=20=20=20=20=20=20=20=20=20=20=20
hci.c 1.206 1.207=20=20=20=20=20=20=20=20=20=20=20=20=20
l2cap.c 1.134 1.135=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Added support to get class of device.
The diff of the modified file(s):
--- bluetooth.c 19 Nov 2002 14:13:10 -0000 1.235
+++ bluetooth.c 13 Jan 2003 19:48:26 -0000 1.236
@@ -709,6 +709,21 @@
return err;
}
=20
+ case BTREADREMOTECLASSOFDEV:
+ {
+ BD_ADDR rev_bd;
+ l2cap_con *con;
+ BT_DRIVER(__FUNCTION__ ": BTREADREMOTECLASSOFDEV\n");
+ copy_from_user(&rev_bd, (s32*)arg, 6);
+ if((con =3D get_con(rev_bd, ANY_STATE))) {
+ copy_to_user((s32*)arg, con->remote_class_of_dev, 3);
+ } else {
+ return -1;
+ }
+ return 0;
+ }
+=09
+
case BTREADREMOTENAME:
{
u8 remote_name[BT_NAME_LENGTH];
--- hci.c 19 Nov 2002 14:13:10 -0000 1.206
+++ hci.c 13 Jan 2003 19:48:30 -0000 1.207
@@ -940,7 +940,7 @@
D_CMD(__FUNCTION__ ": CONNECTION_REQUEST\n");
=20
if (buf[9] =3D=3D ACL_LINK) {
- lp_connect_ind(buf); /* BD_ADDRESS */
+ lp_connect_ind(buf, buf + 6); /* BD_ADDRESS, Class of device */
} else {
printk(__FUNCTION__ ": CONNECTION_REQUEST for SCO LINK");
accept_connection_request(buf, 0x01); /* role ignored for SCO */
@@ -3496,11 +3496,13 @@
s32
lp_connect_req(u8 bd_addr[])
{
+ u8 class_of_dev[3] =3D { 0, 0, 0 };
PRINTPKT(__FUNCTION__ ": bd address is: ", bd_addr, 6);
- /* FIXME, store the inparameters in the ctrl-block instead */
+ /* FIXME, store the inparameters in the ctrl-block instead and make
+ class of device dynamic */
=20
if (!get_con(bd_addr, ANY_STATE))
- l2cap_create_con(bd_addr);
+ l2cap_create_con(bd_addr, class_of_dev);
=20
i_am_initiator =3D 1;
=20
--- l2cap.c 27 Sep 2002 12:54:11 -0000 1.134
+++ l2cap.c 13 Jan 2003 19:48:32 -0000 1.135
@@ -1283,7 +1283,7 @@
=20
/* Indicates the lower protocol has successfully established connection */
void=20
-lp_connect_ind(BD_ADDR bd_addr)
+lp_connect_ind(BD_ADDR bd_addr, CLASS_OF_DEVICE remote_class)
{
PRINTPKT(__FUNCTION__ ": from: ", bd_addr, 6);
=20
@@ -1304,7 +1304,7 @@
=20
if (hci_ctrl.nbr_of_connections < bt_max_connections) {
D_CON(__FUNCTION__ ": Accepting connection\n");
- l2cap_create_con(bd_addr);
+ l2cap_create_con(bd_addr, remote_class);
lp_connect_rsp(bd_addr, 1);
} else {
D_CON(__FUNCTION__ ": Denying connection. Current connections: %d, max c=
onnections: %d\n", hci_ctrl.nbr_of_connections, bt_max_connections);
@@ -1314,7 +1314,7 @@
=20=09
/* is called when we accept a _new_ baseband connection */
void=20
-l2cap_create_con(BD_ADDR bd)
+l2cap_create_con(BD_ADDR bd, CLASS_OF_DEVICE remote_class)
{
l2cap_con *con;
D_RCV(__FUNCTION__ "\n");=09
@@ -1335,6 +1335,7 @@
=20=20=20=20=20=20=20=20=20
con->link_up =3D TRUE;
memcpy(con->remote_bd, bd, 6);
+ memcpy(con->remote_class_of_dev, remote_class, 3);
=20
/* have not received l2cap connection req yet */
ENTERSTATE(con, CLOSED);=20
|
|
From: Anders J. <and...@us...> - 2003-11-05 21:27:40
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
bluetooth.c 1.240 1.241=20=20=20=20=20=20=20=20=20=20=20=20=
=20
bnep.c 1.19 1.20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20
bnep_status_proc.c 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20
The accompanying log:
Made it possible to specify source and target role for bnep connect.
The diff of the modified file(s):
--- bluetooth.c 2003/11/05 15:21:58 1.240
+++ bluetooth.c 2003/11/05 17:03:14 1.241
@@ -1548,7 +1548,8 @@ hci_inq_exit0:
BT_DRIVER("Using src UUID 0x%04x and dst UUID 0x%04x\n", btcon.bnep_src_=
uuid,
btcon.bnep_dst_uuid);
=20=09=09
- tmp =3D bnep_connect_req(btcon.bd, &btcon.pincode);
+ tmp =3D bnep_connect_req(btcon.bd, &btcon.pincode, btcon.bnep_src_uuid,=
=20
+ btcon.bnep_dst_uuid);
=20
result[0] =3D (tmp>>8)&0x0ff; // conn hdl
result[1] =3D (tmp>>16)&0x0ff; // conn hdl
--- bnep.c 2003/11/05 15:21:58 1.19
+++ bnep.c 2003/11/05 17:03:14 1.20
@@ -114,11 +114,15 @@
#define BNEP_INTERFACES 7
#define MAX_EHEADERS 20
=20
+#define DEFAULT_ROLE UUID_NAP
+
/****************** TYPE DEFINITION SECTION ******************************=
***/
=20
/****************** GLOBAL VARIABLE DECLARATION SECTION ******************=
***/
=20
static s32 result_param_bnep;
+static u16 role =3D 0;
+static u16 remote_role =3D 0;
=20
/*************************** UPF TEST VARS *******************************=
***/
extern int dont_send_reply;
@@ -299,6 +303,8 @@ bnep_init_interface(struct net_device *d
=20=09
local->state =3D DISCONNECTED;
local->magic =3D BNEP_MAGIC_NUMBER;
+ local->role =3D DEFAULT_ROLE;
+ local->remote_role =3D 0;
=20=09
dev->irq =3D 0;
dev->dma =3D 1;
@@ -1068,6 +1074,7 @@ bnep_control(l2cap_con *l2cap, u8 *data,
source_uuid =3D be16_to_cpu(*(u16*)&data[src_pos + uuid_length]);
D_MISC("UUID length: %x, dest uuid: %02lx, source uuid: %02lx\n",
data[0], destination_uuid, source_uuid);
+ local->remote_role =3D source_uuid;
/* Lets compare destination uuid, dont care about source uuid */
if (destination_uuid =3D=3D UUID_NAP || destination_uuid =3D=3D UUID_GN=
) {=09
D_MISC("uuids are matching, enter connected state\n");
@@ -1418,6 +1425,7 @@ bnep_connect_ind(l2cap_con *l2cap)=20
result_param_bnep =3D ((l2cap->hci_hdl<<8)&0x0ffff00) + ((i<<24)&0=
xff000000);
local->state =3D BNEP_CONFIG;
local->initiator =3D 0;
+ local->role =3D DEFAULT_ROLE;
l2cap->upper_con =3D (void *)&dev_bnep[i];
=20
result_param_bnep &=3D 0xffffff00;
@@ -1453,6 +1461,8 @@ bnep_connect_cfm(l2cap_con *l2cap, s32 s
local->l2cap =3D l2cap;
local->state =3D BNEP_CONFIG;
local->initiator =3D 1;
+ local->role =3D role;
+ local->remote_role =3D remote_role;
l2cap->upper_con =3D (void *)&dev_bnep[i];
break;
}=20
@@ -1600,10 +1610,12 @@ bnep_setup_connection(struct net_local *
}
=20
u32
-bnep_connect_req(u8 *bd_addr, bt_pincode *pincode)=20
+bnep_connect_req(u8 *bd_addr, bt_pincode *pincode, u16 src_role, u16 dst_r=
ole)=20
{
DSYS("BNEP: Connect request %02x:%02x:%02x:%02x:%02x:%02x\n",
bd_addr[0],bd_addr[1],bd_addr[2],bd_addr[3],bd_addr[4],bd_addr[5]);
+ role =3D src_role;
+ remote_role =3D dst_role;
=20=09
if (l2ca_connect_req(bd_addr, BNEP_LAYER, pincode)) {
D_ERR(__FUNCTION__": l2ca_connect_req failed\n");
--- bnep_status_proc.c 2003/01/22 13:33:49 1.3
+++ bnep_status_proc.c 2003/11/05 17:03:14 1.4
@@ -117,6 +117,12 @@
static s32
bnep_status_proc_read(char *buf, char **start, off_t offset, int len);
=20
+static u8 *
+bnep_statetostr(int state);
+
+static u8 *
+bnep_roletostr(int role);
+
/****************** LOCAL VARIABLE DECLARATION SECTION *******************=
***/
=20
#ifdef __KERNEL__
@@ -201,23 +207,7 @@ int bnep_status_proc_read(char *buf, int
local =3D dev_bnep[i].priv;
if (local->state !=3D DISCONNECTED) {
len +=3D sprintf(buf + len,"%s State =3D ",dev_bnep[i].name);
- switch (local->state) {
- case DISCONNECTED:
- len +=3D sprintf(buf + len, "DISCONNECTED ");
- break;
- case BNEP_CONFIG:
- len +=3D sprintf(buf + len, "CONFIG ");
- break;
- case SETUP:
- len +=3D sprintf(buf + len, "SETUP ");
- break;
- case CONNECTED:
- len +=3D sprintf(buf + len, "CONNECTED ");
- break;
- default:
- len +=3D sprintf(buf + len, "UNKNOWN ");
- }
-=09=09=09
+ len +=3D sprintf(buf + len, "%s", bnep_statetostr(local->state));
if (local->l2cap !=3D NULL) {
len +=3D sprintf(buf +len," Remote BD %02x:%02x:%02x:%02x:%02x:%02x",
local->l2cap->remote_bd[5],local->l2cap->remote_bd[4],
@@ -228,6 +218,9 @@ int bnep_status_proc_read(char *buf, int
//...
}
=20=09=09=09
+ len +=3D sprintf(buf + len, " Role: %s Remote role: %s", bnep_roletostr=
(local->role),
+ bnep_roletostr(local->remote_role));
+
len +=3D sprintf(buf + len,=20
"\n Stats: tx_packets %ld tx_bytes %ld tx_dropped %ld "
"rx_packets %ld rx_bytes %ld rx_dropped %ld\n",
@@ -269,4 +262,29 @@ bnep_status_proc_write(struct file *f, c
{
D_PROC(__FUNCTION__ " Someone wrote %d bytes to bnep proc-file\n", count);
return 0;
+}
+
+static u8 *
+bnep_statetostr(int state)
+{
+ switch (state)
+ {
+ case DISCONNECTED: return "DISCONNECTED ";
+ case BNEP_CONFIG: return "CONFIG ";
+ case SETUP: return "SETUP ";
+ case CONNECTED: return "CONNECTED ";
+ default: return "UNKNOWN ";
+ }
+}=09
+
+static u8 *
+bnep_roletostr(int role)
+{
+ switch(role)
+ {
+ case UUID_PANU: return "PANU ";
+ case UUID_NAP: return "NAP ";
+ case UUID_GN: return "GN ";
+ default: return "Unknown ";
+ }
}
|
|
From: Anders J. <and...@us...> - 2003-11-12 10:15:28
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
bluetooth.c 1.243 1.244=20=20=20=20=20=20=20=20=20=20=20=20=20
hci.c 1.212 1.213=20=20=20=20=20=20=20=20=20=20=20=20=20
sec_client.c 1.28 1.29=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added block-option to write_link_key.=20
The diff of the modified file(s):
--- bluetooth.c 2003/11/06 19:12:52 1.243
+++ bluetooth.c 2003/11/12 10:15:05 1.244
@@ -1099,7 +1099,7 @@ hci_inq_exit0:
BT_DRIVER(__FUNCTION__ ": HCIWRITESTOREDLINKKEY\n");
copy_from_user(param, (s32*)arg, size);
=20
- result =3D hci_write_stored_link_key(param, param + 6);
+ result =3D hci_write_stored_link_key(param, param + 6, 1);
put_user(result, (s32*)arg);
break;
}
--- hci.c 2003/11/06 19:12:52 1.212
+++ hci.c 2003/11/12 10:15:05 1.213
@@ -1198,7 +1198,7 @@ process_event(u8 *buf, u32 len, u32 even
break;
=20
case LINK_KEY_NOTIFICATION:
- D_CMD(__FUNCTION__ ": LINK_KEY_NOTIFICATION forwarding event to security=
manager\n");
+ D_CMD(__FUNCTION__ ": LINK_KEY_NOTIFICATION (Keytype %02x) forwarding ev=
ent to security manager\n", buf[22]);
#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER
sec_man_event(HCI, buf, LINK_KEY_NOTIFICATION, buf + 6, 16);
#endif
@@ -2695,7 +2695,7 @@ hci_read_stored_link_key(u8 *bd, u8 flag
}
=20
s32
-hci_write_stored_link_key(u8 *bd, u8* link_key)
+hci_write_stored_link_key(u8 *bd, u8* link_key, s32 block)
{
s32 tmp;
D_CMD(__FUNCTION__ "\n");
@@ -2708,11 +2708,15 @@ hci_write_stored_link_key(u8 *bd, u8* li
memcpy(c_pkt.data + 7, link_key, 16);
c_pkt.len =3D 23;
=20
+ if(block) {
tmp =3D send_cmd_block((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LE=
N, DEFAULT_TIMEOUT);
if (tmp < 0) {
return tmp;
} else {
return result_param;
+ }
+ } else {
+ return send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
}
}
=20
--- sec_client.c 2003/11/05 15:21:59 1.28
+++ sec_client.c 2003/11/12 10:15:05 1.29
@@ -609,6 +609,10 @@ sec_man_event(enum security_requests use
case LINK_KEY_REQUEST:
hci_link_key_request_negative_reply(bd_addr, 0);
break;
+
+ case LINK_KEY_NOTIFICATION:
+ hci_write_stored_link_key(bd_addr, param, 0);
+ break;
default:
printk("Received event %d, no action\n", event);
}
|
|
From: Anders J. <and...@us...> - 2003-11-18 18:03:36
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
bluetooth.c 1.245 1.246=20=20=20=20=20=20=20=20=20=20=20=20=20
bt_proc.c 1.26 1.27=20=20=20=20=20=20=20=20=20=20=20=20=20=20
hci.c 1.213 1.214=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added more entries to bt_status procfile.
The diff of the modified file(s):
--- bluetooth.c 2003/11/17 14:56:55 1.245
+++ bluetooth.c 2003/11/18 18:03:32 1.246
@@ -185,7 +185,7 @@ typedef struct bt_inbuffer
=20
#define NO_BLUETOOTH_ACTIVITY 0
#define BLUETOOTH_ACTIVITY 1
-static int ledenable =3D 1;
+u8 ledenable =3D 1;
static struct timer_list bt_clear_led_timer;
static int bt_led_next_time;
static int bt_led_active;
@@ -268,6 +268,7 @@ void bt_linebuf_send(s32 line);
/****************** GLOBAL VARIABLE DECLARATION SECTION ******************=
***/
=20
static u8 btdm_pid =3D 0;
+u8 local_name[BT_NAME_LENGTH];
=20
/****************** EXTERN VARIABLE DECLARATION SECTION ******************=
***/
=20
@@ -1119,8 +1120,6 @@ hci_inq_exit0:
=20
case HCISETLOCALNAME:
{
- u8 local_name[BT_NAME_LENGTH];
-
BT_DRIVER(__FUNCTION__ ": HCISETLOCALNAME\n");
copy_from_user(local_name, (s32*)arg, BT_NAME_LENGTH);
hci_change_local_name(local_name);
@@ -3030,6 +3029,7 @@ s32 bt_init(void)
#ifdef CONFIG_BLUETOOTH_PAN
bnep_init_module();
#endif
+ local_name[0] =3D 0;
=20
return 0; /* success */
}
--- bt_proc.c 2002/08/05 15:38:11 1.26
+++ bt_proc.c 2003/11/18 18:03:33 1.27
@@ -108,7 +108,11 @@ static s32 channel_con_proc_dir_entry_re
/****************** LOCAL VARIABLE DECLARATION SECTION *******************=
***/
=20
/****************** EXTERNAL VARIABLES DECLARATION SECTION ***************=
***/
-
+extern u8 local_name[BT_NAME_LENGTH];
+extern u8 dont_allow_slave;
+#ifdef __CRIS__
+extern u8 ledenable;
+#endif
/**************** VARIABLES FOR CHANNEL CONNECTION PROC FILE *************=
*******/
=20
#ifdef CONFIG_BLUETOOTH_PROC
@@ -276,6 +280,20 @@ int bt_read_status(char *buf, int len)
len +=3D hci_sprint_local_bd(buf + len);
len +=3D sprintf(buf + len, "\n");
=20=09
+ len +=3D sprintf(buf + len, "max_connections : %d\n",
+ hci_read_max_connections());
+ len +=3D sprintf(buf + len, "local_name : %s\n",
+ local_name);
+ len +=3D sprintf(buf + len, "force_ms : %s\n",
+ hci_read_msswitch() ? "TRUE" : "FALSE");
+ len +=3D sprintf(buf + len, "dont_allow_slave : %s\n",
+ dont_allow_slave ? "TRUE" : "FALSE");
+ len +=3D sprintf(buf + len, "pincode_type : %d\n",
+ hci_read_pin_type());
+#ifdef __CRIS__
+ len +=3D sprintf(buf + len, "led_enable : %s\n",
+ ledenable ? "TRUE" : "FALSE");
+#endif
len +=3D sprintf(buf + len, "\n[REMOTE INFO]\n");
len +=3D hci_sprint_remote_info(buf + len);
=20
--- hci.c 2003/11/12 10:15:05 1.213
+++ hci.c 2003/11/18 18:03:33 1.214
@@ -2964,6 +2964,12 @@ hci_set_max_connections(s32 max_connecti
return 0;
}
=20
+s32
+hci_read_max_connections(void)
+{
+ return bt_max_connections;
+}
+
=20
/* Change the 3-bit load factor (all bits set is max load, all zero is min=
load).
* Renew load factor if: Any client is connected, disconnected or if the
@@ -3493,6 +3499,13 @@ hci_force_msswitch(u8 enable)
DSYS("Force M/S switch set to %d\n", enable);
force_msswitch =3D enable;
}
+
+s32
+hci_read_msswitch(void)
+{
+ return force_msswitch;
+}
+
=20
s32
hci_write_page_to(u32 page_to)
|
|
From: Anders J. <and...@us...> - 2004-01-31 02:46:47
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
bluetooth.c 1.247 1.248=20=20=20=20=20=20=20=20=20=20=20=20=20
l2cap.c 1.138 1.139=20=20=20=20=20=20=20=20=20=20=20=20=20
sec_client.c 1.29 1.30=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added 2 new IOCTL:s, BBCONNECT and HCIAUTHENTICATION_ENCRYPTION.
Corrected the case where a disconnect_ind was received but
the PSM in the l2cap_con was invalid. Caused a never-ending while-loop.
The diff of the modified file(s):
--- bluetooth.c 2004/01/09 15:27:18 1.247
+++ bluetooth.c 2004/01/30 12:03:51 1.248
@@ -346,6 +346,18 @@ static tty_linebuffer tty_linebuf;
=20
#define BT_CON_TIMEOUT (10*HZ)
=20
+typedef struct secman_info {
+ bt_timer_obj timer;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
+ struct wait_queue *wq;
+#else
+ wait_queue_head_t wq;
+#endif
+ s32 status;
+} secman_info;
+
+static secman_info secman_handler;
+
/****************** FUNCTION DEFINITION SECTION **************************=
***/
=20
/*
@@ -615,8 +627,15 @@ __bt_ioctl(struct tty_struct *tty, struc
BT_DRIVER(__FUNCTION__ ": SDP_CONNECT\n");
return sdp_connect(btcon.bd, &btcon.pincode);
}
-=09
-
+ case BBCONNECT:
+ {
+ u8 *bd_addr;
+ /* argument is an object with all info to start a remote
+ connection */
+ copy_from_user(&btcon, (s32*)arg, size);
+ BT_DRIVER(__FUNCTION__ ": BB_CONNECT\n");
+ return lp_connect(btcon.bd, &btcon.pincode);
+ }
#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER
case BT_GETCACHEDLINKKEY:
{
@@ -944,6 +963,32 @@ hci_inq_exit0:
break;
}
=20
+ case HCIAUTHENTICATION_ENCRYPTION:
+ {
+ u8 bd_addr[size];
+ BT_DRIVER(__FUNCTION__ ": HCIAUTHENTICATION_ENCRYPTION\n");
+ copy_from_user(bd_addr, (s32*)arg, size);
+ secman_handler.status =3D -1;
+ if(hci_authentication_requested_bd(bd_addr) < 0) {
+ return -1;
+ }
+ start_wq_timer(&secman_handler.timer, 30 * HZ,
+ &secman_handler.wq);
+ interruptible_sleep_on(&secman_handler.wq);
+ if(secman_handler.status !=3D 0) {
+ return -secman_handler.status;
+ }
+ if(hci_set_connection_encryption_bd(bd_addr, 1) < 0) {
+ return -1;
+ }
+ secman_handler.status =3D -1;
+ start_wq_timer(&secman_handler.timer, 10 * HZ,
+ &secman_handler.wq);
+ interruptible_sleep_on(&secman_handler.wq);
+ return -secman_handler.status;
+ }
+=09
+
case HCIREADCLOCKOFFSET:
{
/* Return parameters (4 bytes):
@@ -2855,7 +2900,11 @@ s32 bt_init(void)
bnep_init_module();
#endif
local_name[0] =3D 0;
-
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
+ secman_handler.wq =3D NULL;
+#else
+ init_waitqueue_head(&secman_handler.wq);
+#endif
return 0; /* success */
}
=20
@@ -3478,6 +3527,16 @@ wq_timeout(unsigned long ptr)
wake_up_interruptible(wq);
}
=20
+/* Used only if we are initiating a connection and this function is
+ called when either authentication or encryption is finished */
+void
+bt_secman_notify(s32 status)
+{
+ secman_handler.status =3D status;
+ wake_up_interruptible(&secman_handler.wq);
+ release_wq_timer(&secman_handler.timer);
+}=20=20
+
/************************ MODULE STUFF ***********************************=
***/
=20
#if defined(MODULE) || defined(__KERNEL__)
--- l2cap.c 2003/11/05 15:21:59 1.138
+++ l2cap.c 2004/01/30 12:03:53 1.139
@@ -1444,6 +1444,80 @@ lp_connect_cfm(u8 *bd_addr, u32 status,=20
}
}
=20=20
+/* Creates a new baseband connection if not already present */
+s32
+lp_connect(BD_ADDR bd, bt_pincode *pincode)
+{
+ l2cap_con *con;
+ s32 i, retval =3D 0;
+ u8 rev_bd[6];
+
+ /* Check bd_addr */
+ if (!bd[0] && !bd[1] && !bd[2] && !bd[3] && !bd[4] && !bd[5]) {
+ D_ERR(__FUNCTION__ ": No BD-addr\n");
+ return -EINVAL;
+ }
+ /* bd is big endian, reverse byte order to little endian */
+ for (i =3D 0; i < 6; i++) {
+ rev_bd[5-i] =3D bd[i];
+ }
+=09
+ if(get_con(rev_bd, ANY_STATE))
+ {
+ D_ERR(__FUNCTION__ ": Baseband connection already exists");
+ return -(MSGCODE(MSG_BT_INTERFACE, BT_ALREADYCONNECTED));
+ }
+
+ con =3D create_con(0/* not yet set */, get_cid(), 0/* not yet set */);
+
+ /* Check connection */
+ if (con =3D=3D NULL) {
+ D_ERR(__FUNCTION__ ": no connection created\n");
+ return -ENOMEM;
+ }
+
+ memcpy(con->remote_bd, rev_bd, 6);
+ print_data("bd", con->remote_bd, 6);
+ /* we are client */
+ con->initiator =3D 1;=20
+
+ /* Just clear some values, will not be used for this connection */
+ con->conf_req_ready=3D0;
+ con->conf_rsp_ready=3D0;
+ con->flush_timeout =3D FLUSHTIMEOUT_DEFAULT;
+ con->link_up =3D 0;
+ insert_con(con);
+
+=09
+ D_STATE(__FUNCTION__ ": create new baseband link\n");
+ /* Pincode is set per baseband link */
+ if(pincode) {
+ memcpy(con->pincode.data, pincode->data, 0x10);
+ con->pincode.len =3D pincode->len;
+ }
+
+ retval =3D lp_connect_req(con->remote_bd);
+ if(retval < 0) {
+ D_ERR(__FUNCTION__ ": failed (status %d)\n", retval);
+ delete_con(con);
+ return retval;
+ }
+
+ /* wait here until we received a lp_connect_cfm */
+ l2ca_wait(__FUNCTION__ ": wait baseband", con);
+=09=09
+ if (con->c_status !=3D RES_SUCCESS) {
+ 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 retval;
+ }
+ return retval;
+}=09
+=09
+=09
+=09
+=20
/* Indicates that one of the baseband connections has been shutdown */
s32
lp_disconnect_ind(u32 con_hdl)
@@ -1483,10 +1557,14 @@ lp_disconnect_ind(u32 con_hdl)
ENTERSTATE(con, W4_L2CA_DISCONNECT_RSP);
DSYS("closing l2cap con (%d,%d)\n",
con->local_cid, con->remote_cid);
-
+ if ((con->psm =3D=3D 0) || (get_upper(con->psm) =3D=3D &default_protoco=
l)) {
+ con->current_state =3D CLOSED;
+ delete_con(con);
+ } else {
/* notify upper layers that phys link is down */
get_upper(con->psm)->disc_ind(con);
}
+ }
=20
found =3D 1;
}
--- sec_client.c 2003/11/12 10:15:05 1.29
+++ sec_client.c 2004/01/30 12:03:54 1.30
@@ -57,6 +57,8 @@
#include <linux/bluetooth/hci_internal.h>
#include <linux/bluetooth/btmem.h>
#include <linux/bluetooth/l2cap.h>
+#include <linux/bluetooth/bluetooth.h>
+#include <linux/bluetooth/bt_errno.h>
#include <linux/proc_fs.h>
#else /* user mode */
#include <stdlib.h>
@@ -613,6 +615,13 @@ sec_man_event(enum security_requests use
case LINK_KEY_NOTIFICATION:
hci_write_stored_link_key(bd_addr, param, 0);
break;
+ case AUTHENTICATION_COMPLETE:
+ case ENCRYPTION_CHANGE:
+ pos =3D *param;
+ pos =3D MSGCODE(MSG_LAYER_HCI, pos);
+ bt_secman_notify(pos);
+ break;
+
default:
printk("Received event %d, no action\n", event);
}
|