|
From: Peter K. <pk...@us...> - 2001-02-27 12:40:28
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- sec_client.c 1.9 1.10=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Debug defines are now in btdebug.h The diff of the modified file(s): --- sec_client.c 2001/02/15 16:27:34 1.9 +++ sec_client.c 2001/02/27 12:41:36 1.10 @@ -62,13 +62,14 @@ #include "include/rfcomm_sec.h" #include "include/sec_client.h" #include "include/btmem.h" +#include "include/btdebug.h" #endif =20 /****************** DEBUG CONSTANT AND MACRO SECTION *********************= ***/ =20 #if SEC_CLIENT_DEBUG_MISC /* Misc */ -#define D_MISC(fmt...) printk(L2CAP_DBG_STR fmt) +#define D_MISC(fmt...) printk(SEC_DBG_STR fmt) #else #define D_MISC(fmt...) #endif |
|
From: Peter K. <pk...@us...> - 2001-03-03 15:31:39
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- sec_client.c 1.11 1.12=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: The proc interface was changed already in version 2.2.14, so check for that version instead of 2.4.0 |
|
From: Olov H. <ol...@us...> - 2001-03-19 12:40:54
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
sec_client.c 1.16 1.17=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added KERNEL as originator. This tells that the stack is going down and tha=
t there is nothing to read.
The diff of the modified file(s):
--- sec_client.c 2001/03/06 11:06:24 1.16
+++ sec_client.c 2001/03/19 12:43:11 1.17
@@ -233,7 +233,8 @@
=20
enum originator_types {
BT_SEC_MAN,
- SEC_CLIENT
+ SEC_CLIENT,
+ KERNEL
};=20
=20
struct security_query {
@@ -242,7 +243,7 @@
u8 remote_bd[6]; /* out */
u8 event_param[MAX_EVENT_DATA_LENGTH];
/* out */
- u8 originator; /* out/in BT_SEC_MAN or SEC_CLIENT */
+ u8 originator; /* out/in BT_SEC_MAN, SEC_CLIENT or KERNEL*/
u32 originator_data; /* out/in con or rfcomm struct pointer */
u16 request_result; /* in */=09
} security_query;
@@ -253,6 +254,16 @@
=20
/****************** FUNCTION DEFINITION SECTION **************************=
***/
=20=20=20
+void sec_client_shutdown()
+{
+ security_query.originator =3D KERNEL;=20=20
+#ifdef __KERNEL__
+ D_PROC("wake_up process %i (%s) awakening\n", current->pid, current->com=
m);
+ wake_up_interruptible(&sec_man_wq);
+ D_PROC("wake_up process %i (%s) woke up\n", current->pid, current->comm);
+#endif
+}
+
void=20
sec_man_init(enum security_requests user)
{
@@ -460,6 +471,12 @@
=20=09
D_PROC(FNC" Someone is trying to read % d bytes from sec proc-file\n",
count);
+
+ if (security_query.originator =3D=3D KERNEL) {
+ D_PROC(FNC"Shutdown of stack in progress, nothing to read!\n");
+ return 1;
+ }
+
cli();
if (security_query.originator !=3D BT_SEC_MAN) {
D_PROC(FNC"No response yet, going to sleep\n");
|
|
From: Ulf H. <ul...@us...> - 2001-04-26 13:58:18
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
sec_client.c 1.17 1.18=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added sec_man_get_cached_link_key, list handling for cached link keys.
Removed "magic" numbers
The diff of the modified file(s):
--- sec_client.c 2001/03/19 12:43:11 1.17
+++ sec_client.c 2001/04/26 13:58:18 1.18
@@ -96,10 +96,48 @@
#define SEC_MAN_SRV_SOCK "/tmp/sec_sock"
#endif
=20
+#define HCI_VALUE_RETURN_LINK_KEYS 0x15
+#define BD_ADDRESS_SIZE 6
+#define LINK_KEY_SIZE 16
+#define BUFFER_SIZE 256
#define MAX_EVENT_DATA_LENGTH 16
+#define MAX_LINKKEYLISTSIZE 255 /* for now */
=20
/****************** TYPE DEFINITION SECTION ******************************=
***/
=20
+typedef struct link_key_information_type {
+ unsigned char bd_addr[BD_ADDRESS_SIZE];
+ unsigned char link_key[LINK_KEY_SIZE];
+=09
+ struct link_key_information_type *prev;
+ struct link_key_information_type *next;
+} link_key_information_type;
+
+typedef struct link_key_list_type {
+ link_key_information_type *first;
+ link_key_information_type *last;
+ link_key_information_type *cur;
+ u32 count;
+} link_key_list_type;
+
+enum originator_types {
+ BT_SEC_MAN,
+ SEC_CLIENT,
+ KERNEL
+};=20
+
+struct security_query {
+ u16 request_type; /* out */
+ u32 request_value; /* out */
+ u8 remote_bd[BD_ADDRESS_SIZE];
+ /* out */
+ u8 event_param[MAX_EVENT_DATA_LENGTH];
+ /* out */
+ u8 originator; /* out/in BT_SEC_MAN, SEC_CLIENT or KERNEL*/
+ u32 originator_data; /* out/in con or rfcomm struct pointer */
+ u16 request_result; /* in */=09
+} security_query;
+
/****************** LOCAL FUNCTION DECLARATION SECTION *******************=
***/
=20
#ifdef __KERNEL__
@@ -122,10 +160,22 @@
static s32 sec_man_doquery(s32 fd, u8 *request);
#endif
=20
+
+void init_link_key_list(void);
+void free_link_key_list(void);
+link_key_information_type* create_link_key(unsigned char *bd_addr,
+ unsigned char *link_key_str);
+link_key_information_type* get_first_link_key(void);
+link_key_information_type* get_next_link_key(link_key_information_type* li=
nk_key);
+void insert_link_key(link_key_information_type *new_link_key);
+s32 delete_link_key(link_key_information_type *link_key);
+
/****************** GLOBAL VARIABLE DECLARATION SECTION ******************=
***/
=20
/****************** LOCAL VARIABLE DECLARATION SECTION *******************=
***/
=20
+static link_key_list_type link_key_list;
+
#ifdef __KERNEL__
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
static struct wait_queue *sec_man_wq =3D NULL;
@@ -231,23 +281,6 @@
=20
#endif /* __KERNEL__ */
=20
-enum originator_types {
- BT_SEC_MAN,
- SEC_CLIENT,
- KERNEL
-};=20
-
-struct security_query {
- u16 request_type; /* out */
- u32 request_value; /* out */
- u8 remote_bd[6]; /* out */
- u8 event_param[MAX_EVENT_DATA_LENGTH];
- /* out */
- u8 originator; /* out/in BT_SEC_MAN, SEC_CLIENT or KERNEL*/
- u32 originator_data; /* out/in con or rfcomm struct pointer */
- u16 request_result; /* in */=09
-} security_query;
-
#ifndef __KERNEL__
static s32 sec_man_sock;
#endif
@@ -270,11 +303,135 @@
#ifndef __KERNEL__
sec_man_sock =3D open_socket(SEC_MAN_SRV_SOCK);
#endif
+ init_link_key_list();
=20
/* To indicate that nothing is ready */
security_query.originator =3D SEC_CLIENT;=20
}
=20
+void
+init_link_key_list(void)
+{
+ /* Init list */
+ link_key_list.first =3D NULL;
+ link_key_list.last =3D NULL;
+ link_key_list.cur =3D NULL;
+ link_key_list.count =3D 0;=09
+}
+
+void=20
+free_link_key_list(void)
+{
+ while (link_key_list.count)
+ delete_link_key(link_key_list.first);
+}=20
+
+link_key_information_type*=20
+create_link_key(unsigned char *bd_addr, unsigned char *link_key_str)
+{=20
+ link_key_information_type *link_key;
+
+ if (link_key_list.count =3D=3D MAX_LINKKEYLISTSIZE) {
+ D_ERR("Connection list full!\n");
+ return NULL;
+ }
+ /* Add check if already in list ?? or rely on that otherwhere ?*/
+=20=20
+ /* Allocate new element */
+ if ((link_key =3D kmalloc(sizeof *link_key, GFP_ATOMIC)) < 0) {
+ D_ERR(__FUNCTION__ ": could not allocate new link key element\n");
+ return NULL;
+ }
+=09
+ memcpy(link_key->bd_addr, bd_addr, BD_ADDRESS_SIZE);
+ memcpy(link_key->link_key, link_key_str, LINK_KEY_SIZE);
+
+ link_key->next =3D link_key;
+ link_key->prev =3D link_key;
+
+ return link_key;
+}
+
+link_key_information_type* get_first_link_key(void)
+{
+ return link_key_list.first;
+}
+
+link_key_information_type* get_next_link_key(link_key_information_type* li=
nk_key)
+{
+ if (link_key->next =3D=3D link_key_list.first)
+ return NULL;
+ else
+ return link_key->next;
+}
+
+void=20
+insert_link_key(link_key_information_type *new_link_key)
+{
+ link_key_information_type *old_link_key;
+
+ if (!link_key_list.count) {
+ /* Empty list */
+ D_PROC("Inserting into empty list\n");
+ link_key_list.first =3D new_link_key;=20
+ link_key_list.cur =3D new_link_key;
+ link_key_list.last =3D new_link_key;
+ link_key_list.count++;
+
+ new_link_key->next =3D link_key_list.first; /* Pos32 at itself */
+ new_link_key->prev =3D link_key_list.first;
+
+ return;
+ }
+=20=20
+ /* Not empty */
+ D_PROC("Inserting into list\n");
+=09
+ old_link_key =3D link_key_list.first; /* mark oldlink_key first */
+ new_link_key->next =3D old_link_key;
+ link_key_list.last->next =3D new_link_key;
+ old_link_key->prev =3D new_link_key;
+ new_link_key->prev =3D link_key_list.last;
+=20=20
+ link_key_list.cur =3D new_link_key; /* Set current to new element */
+ link_key_list.first =3D new_link_key; /* Set first to new element */
+ link_key_list.count++;
+}
+
+s32=20
+delete_link_key(link_key_information_type *link_key)
+{=20=20
+ if (link_key_list.count =3D=3D 1) {
+ /* Last element */
+ D_PROC("Deleting last element\n");
+=09=09
+ link_key_list.count--;
+ link_key_list.first =3D NULL;
+ link_key_list.cur =3D NULL;
+ link_key_list.last =3D NULL;
+ kfree(link_key);
+
+ return 0;
+ }
+
+ D_PROC("Deleting element in list\n");
+ link_key->prev->next =3D link_key->next; /* Take it out */
+ link_key->next->prev =3D link_key->prev;
+=20=20
+ if (link_key_list.first =3D=3D link_key) /* Update first pointer */
+ link_key_list.first =3D link_key->next;
+=20=20
+ if (link_key_list.last =3D=3D link_key) /* Update last pointer */
+ link_key_list.last =3D link_key->prev;
+=20=20
+ link_key_list.cur =3D link_key->next; /* Update cur pointer */
+ link_key_list.count--;
+=20=20
+ kfree(link_key);=20
+
+ return 0;=20=20
+}
+
#ifdef __KERNEL__
s32
sec_man_create_proc_file(void)
@@ -357,7 +514,7 @@
=20
security_query.request_type =3D user;
security_query.request_value =3D service_data;
- memcpy(security_query.remote_bd, bd_addr, 6);
+ memcpy(security_query.remote_bd, bd_addr, BD_ADDRESS_SIZE);
security_query.originator =3D BT_SEC_MAN;
security_query.originator_data =3D user_data;
security_query.request_result =3D GENERAL_FAILURE;
@@ -379,16 +536,29 @@
{
#define FNC "sec_man_event: "
=20
+ if (event =3D=3D HCI_VALUE_RETURN_LINK_KEYS)
+ {
+ /* Ok, link key has to be stored locally */
+ link_key_information_type *link_key;
+ unsigned char link_key_str[LINK_KEY_SIZE];
+=09=09
+ memcpy(link_key_str, param, LINK_KEY_SIZE);
+ link_key =3D create_link_key(bd_addr, link_key_str);
+ insert_link_key(link_key);
+ D_PROC("sec_man_event: Number of elements in list: %d\n", link_key_list.=
count);
+=09=09
+ }
+ else
+ {
#ifndef __KERNEL__
if (sec_man_sock < 0) {
/* What to do if no security manager present?? */
}
#endif
-
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;
- memcpy(security_query.remote_bd, bd_addr, 6);
+ memcpy(security_query.remote_bd, bd_addr, BD_ADDRESS_SIZE);
security_query.originator =3D BT_SEC_MAN;
=20
if (param_len > MAX_EVENT_DATA_LENGTH) {
@@ -407,10 +577,40 @@
#else
sec_man_doquery(sec_man_sock, (u8*) &security_query);
#endif
-=09
+ }
#undef FNC=09
}
=20
+void sec_man_get_cached_link_key(u8 *param)
+{
+ link_key_information_type *link_key;
+
+ link_key =3D get_first_link_key();
+=09=09=09
+ D_PROC("sec_man_get_cached_link_key: \n");
+=09=09=09
+ if (link_key !=3D NULL)
+ {
+ memcpy(param, link_key->bd_addr, BD_ADDRESS_SIZE);
+ memcpy(param + BD_ADDRESS_SIZE,
+ link_key->link_key,
+ LINK_KEY_SIZE);
+
+ D_PROC("Returning bd address %02x:%02x:%02x:%02x:%02x:%02x",
+ link_key->bd_addr[0],
+ link_key->bd_addr[1],
+ link_key->bd_addr[2],
+ link_key->bd_addr[3],
+ link_key->bd_addr[4],
+ link_key->bd_addr[5]);
+=09=09
+ delete_link_key(link_key);
+=09=09
+ } else {
+ memset(param, 0, BD_ADDRESS_SIZE + LINK_KEY_SIZE);
+ }
+}
+
/* -------------------- Local functions --------------------------- */
#ifndef __KERNEL__
int open_socket(char *name)
@@ -545,7 +745,7 @@
s32 sec_man_doquery(s32 fd, u8 *request)
{
s32 n;
- u8 tmpbuf[256];
+ u8 tmpbuf[BUFFER_SIZE];
struct security_query *sec_hdl;
=20
sec_hdl =3D (struct security_query*) (request);
@@ -553,7 +753,7 @@
syslog(LOG_INFO, "sec_man_doquery : sending request\n");
write(fd, request, sizeof(struct security_query));
=20=09
- n =3D read(fd, tmpbuf, 256);
+ n =3D read(fd, tmpbuf, BUFFER_SIZE);
=20=09
/* what if not all is written once */
=20
|
|
From: Peter K. <pk...@us...> - 2001-12-10 16:18:15
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
sec_client.c 1.18 1.19=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Do not treat originator =3D=3D KERNEL specially in sec_man_read()
(there was no reason for it, and it should never be KERNEL at
that location anyway, so it should not change anything in
reality either).
The diff of the modified file(s):
--- sec_client.c 2001/04/26 13:58:18 1.18
+++ sec_client.c 2001/12/10 16:18:14 1.19
@@ -339,7 +339,7 @@
=20=20=20
/* Allocate new element */
if ((link_key =3D kmalloc(sizeof *link_key, GFP_ATOMIC)) < 0) {
- D_ERR(__FUNCTION__ ": could not allocate new link key element\n");
+ D_ERR(__FUNCTION__ ": Could not allocate new link key element\n");
return NULL;
}
=20=09
@@ -494,8 +494,6 @@
sec_man_check(enum security_requests user, BD_ADDR bd_addr, u32 service_da=
ta,
u32 user_data)
{
-#define FNC "sec_man_check: "
-
#ifndef __KERNEL__
if (sec_man_sock < 0) {
/* What to do if no security manager present?? */
@@ -526,16 +524,12 @@
#else
sec_man_doquery(sec_man_sock, (u8*) &security_query);
#endif
-=09
-#undef FNC
}
=20
void
sec_man_event(enum security_requests user, BD_ADDR bd_addr, u8 event,
u8 *param, u8 param_len)
{
-#define FNC "sec_man_event: "
-=09
if (event =3D=3D HCI_VALUE_RETURN_LINK_KEYS)
{
/* Ok, link key has to be stored locally */
@@ -578,7 +572,6 @@
sec_man_doquery(sec_man_sock, (u8*) &security_query);
#endif
}
-#undef FNC=09
}
=20
void sec_man_get_cached_link_key(u8 *param)
@@ -646,15 +639,11 @@
s32 sec_man_proc_dir_entry_read(char *buf, char **start, off_t offset,
s32 len, s32 unused)
{
-#define FNC "sec_proc_dir_entry_read: "
-
#ifdef USE_NEW_PROC
return sec_man_read(NULL, buf, len, 0);
#else
return sec_man_read(NULL, NULL, buf, len);
#endif
-
-#undef FNC
}
=20
#ifdef USE_NEW_PROC
@@ -665,33 +654,24 @@
char * buf, s32 count)
#endif
{
-#define FNC "sec_man_read: "
-=09
s32 tmp;
=20=09
- D_PROC(FNC" Someone is trying to read % d bytes from sec proc-file\n",
- count);
-
- if (security_query.originator =3D=3D KERNEL) {
- D_PROC(FNC"Shutdown of stack in progress, nothing to read!\n");
- return 1;
- }
+ D_PROC(__FUNCTION__ ": Someone is trying to read %d bytes from sec proc-f=
ile\n", count);
=20
cli();
if (security_query.originator !=3D BT_SEC_MAN) {
- D_PROC(FNC"No response yet, going to sleep\n");
+ D_PROC(__FUNCTION__ ": No response yet, going to sleep\n");
interruptible_sleep_on(&sec_man_wq);
}
sti();
- tmp =3D sizeof(struct security_query);
+
+ tmp =3D sizeof security_query;
memcpy(buf, &security_query, tmp);
=20=09
- D_PROC(FNC"Returning %d bytes\n", tmp);
+ D_PROC(__FUNCTION__ ": Returning %d bytes\n", tmp);
security_query.originator =3D SEC_CLIENT; /* Change so we lock aga=
in */
=20=20=20=20=20=20=20=20=20
return tmp;
-=09
-#undef FNC
}
=20
#ifdef USE_NEW_PROC
@@ -702,14 +682,13 @@
const char * buf, s32 count)
#endif
{
-#define FNC "sec_man_write: "=09
struct security_query *sec_hdl;
=20=09
sec_hdl =3D (struct security_query *)(buf);
=20=09
- D_PROC(FNC"Someone wrote %d bytes to sec proc-file\n",count);
+ D_PROC(__FUNCTION__ ": Someone wrote %d bytes to sec proc-file\n", count);
=20=09
-/* D_XMIT(FNC"preparing to send data to sec_con[%d]\n", secb_hdl->sec_con_=
id); */
+/* D_XMIT(__FUNCTION__ ": Preparing to send data to sec_con[%d]\n", secb_h=
dl->sec_con_id); */
if (sec_hdl->originator =3D=3D BT_SEC_MAN) /* o.k. new request */
{
/* Change so we do not receive old data */
@@ -717,13 +696,13 @@
=20=09=09
switch (sec_hdl->request_type) {
case L2CAP:
- D_PROC(FNC"Message to L2CAP\n");
+ D_PROC(__FUNCTION__ ": Message to L2CAP\n");
l2cap_process_sec_man_response(sec_hdl->request_result,
sec_hdl->originator_data);
break;
=20
case RFCOMM:
- D_PROC(FNC"Message to RFCOMM\n");
+ D_PROC(__FUNCTION__ ": Message to RFCOMM\n");
rfcomm_process_sec_man_response(sec_hdl->request_result,
sec_hdl->originator_data,
sec_hdl->request_value);
@@ -735,9 +714,7 @@
}
}
=20=09
-=09
return count;
-#undef FNC
}
=20
#else /* __KERNEL__ */
|
|
From: Alain P. <apa...@us...> - 2002-02-22 14:08:03
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
sec_client.c 1.20 1.21=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added a call for security event concerning the HCI layer. Include hci_sec.h.
The diff of the modified file(s):
--- sec_client.c 13 Feb 2002 14:05:04 -0000 1.20
+++ sec_client.c 22 Feb 2002 14:02:40 -0000 1.21
@@ -49,6 +49,7 @@
#include <linux/bluetooth/sec_client.h>
#include <linux/bluetooth/l2cap_sec.h>
#include <linux/bluetooth/rfcomm_sec.h>
+#include <linux/bluetooth/hci_sec.h>
#include <linux/bluetooth/btmem.h>
#include <linux/proc_fs.h>
#else /* user mode */
@@ -699,6 +700,10 @@
=20=09
D_PROC(__FUNCTION__ ": Someone wrote %d bytes to sec proc-file\n", count);
=20=09
+ /* Verify that I read at least the number of byte I am waiting */
+ if (count < sizeof (*sec_hdl))
+ D_ERR(__FUNCTION__ ": Only %d bytes were wroten in proc file instead of=
%d", count, sizeof (*sec_hdl));
+=09
/* D_XMIT(__FUNCTION__ ": Preparing to send data to sec_con[%d]\n", secb_h=
dl->sec_con_id); */
if (sec_hdl->originator =3D=3D BT_SEC_MAN) /* o.k. new request */
{
@@ -717,6 +722,15 @@
rfcomm_process_sec_man_response(sec_hdl->request_result,
sec_hdl->originator_data,
sec_hdl->request_value);
+ break;
+=09=09
+ case HCI:
+ D_PROC(FNC"Message to HCI\n");
+ hci_process_sec_man_response(sec_hdl->request_result,
+ sec_hdl->originator_data,
+ sec_hdl->request_value,
+ sec_hdl->event_param,
+ sec_hdl->remote_bd);
break;
=20
default:
|
|
From: Willy S. <sag...@us...> - 2002-04-11 14:36:54
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- sec_client.c 1.23 1.24=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added linux version ifdef for malloc.h/slab.h The diff of the modified file(s): --- sec_client.c 28 Feb 2002 20:12:15 -0000 1.23 +++ sec_client.c 11 Apr 2002 11:52:14 -0000 1.24 @@ -44,8 +44,11 @@ #define __NO_VERSION__ /* don't define kernel_version in module.h */ =20 #ifdef __KERNEL__ +#if LINUX_VERSION_CODE >=3D 0x20200 +#include <linux/slab.h> +#else #include <linux/malloc.h> - +#endif #include <linux/bluetooth/sec_client.h> #include <linux/bluetooth/l2cap_sec.h> #include <linux/bluetooth/rfcomm_sec.h> |
|
From: Peter K. <pk...@us...> - 2002-08-01 16:16:10
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
sec_client.c 1.24 1.25=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Fixed two compiler warnings.
The diff of the modified file(s):
--- sec_client.c 11 Apr 2002 11:52:14 -0000 1.24
+++ sec_client.c 1 Aug 2002 16:16:09 -0000 1.25
@@ -157,8 +157,10 @@
const char * buf, s32 count);
#endif
=20
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
static s32 sec_man_proc_dir_entry_read(char *buf, char **start, off_t offs=
et,
s32 len, s32 unused);
+#endif
#else
static s32 open_socket(char *name);
static s32 sec_man_doquery(s32 fd, u8 *request);
@@ -651,6 +653,7 @@
=20
=20
#ifdef __KERNEL__
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
s32 sec_man_proc_dir_entry_read(char *buf, char **start, off_t offset,
s32 len, s32 unused)
{
@@ -660,6 +663,7 @@
return sec_man_read(NULL, NULL, buf, len);
#endif
}
+#endif
=20
#ifdef USE_NEW_PROC
ssize_t sec_man_read(struct file * file, char * buf, size_t count,
@@ -705,7 +709,7 @@
=20=09
/* Verify that I read at least the number of byte I am waiting */
if (count < sizeof (*sec_hdl))
- D_ERR(__FUNCTION__ ": Only %d bytes were wroten in proc file instead of =
%d", count, sizeof (*sec_hdl));
+ D_ERR(__FUNCTION__ ": Only %ld bytes were written in proc file instead o=
f %d", count, sizeof (*sec_hdl));
=20=09
/* D_XMIT(__FUNCTION__ ": Preparing to send data to sec_con[%d]\n", secb_h=
dl->sec_con_id); */
if (sec_hdl->originator =3D=3D BT_SEC_MAN) /* o.k. new request */
|
|
From: Anders J. <and...@us...> - 2003-05-22 15:17:36
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
sec_client.c 1.26 1.27=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Removed global request struct, replaced with a ringbuffer as we need to=20
be able to receive more than one request before the sec client has a=20
chance to read data. Will solve the problem with linkeys which aren't
saved due to overwrite of previous data.
The diff of the modified file(s):
--- sec_client.c 2002/08/01 16:19:29 1.26
+++ sec_client.c 2003/05/22 14:51:11 1.27
@@ -107,6 +107,7 @@
#define BUFFER_SIZE 256
#define MAX_EVENT_DATA_LENGTH 16
#define MAX_LINKKEYLISTSIZE 255 /* for now */
+#define MAX_QUEUE_ENTRIES 5
=20
/****************** TYPE DEFINITION SECTION ******************************=
***/
=20
@@ -131,7 +132,7 @@ enum originator_types {
KERNEL
};
=20
-struct security_query {
+typedef struct security_query {
u16 request_type; /* out */
u32 request_value; /* out */
u8 remote_bd[BD_ADDRESS_SIZE];
@@ -143,6 +144,16 @@ struct security_query {
u16 request_result; /* in */=09
} security_query;
=20
+struct proc_buffer {
+ u8 elements;
+ u8 data[sizeof(security_query) * MAX_QUEUE_ENTRIES];
+ u32 in;
+ u32 out;
+} proc_buffer;
+
+
+=09
+
/****************** LOCAL FUNCTION DECLARATION SECTION *******************=
***/
=20
#ifdef __KERNEL__
@@ -297,7 +308,7 @@ static s32 sec_man_sock;
=20
void sec_client_shutdown()
{
- security_query.originator =3D KERNEL;=20=20
+ proc_buffer.elements =3D 0;
#ifdef __KERNEL__
D_PROC("wake_up process %i (%s) awakening\n", current->pid, current->com=
m);
wake_up_interruptible(&sec_man_wq);
@@ -313,9 +324,9 @@ sec_man_init(enum security_requests user
sec_man_sock =3D open_socket(SEC_MAN_SRV_SOCK);
#endif
init_link_key_list();
-
- /* To indicate that nothing is ready */
- security_query.originator =3D SEC_CLIENT;
+ proc_buffer.in =3D 0;
+ proc_buffer.out =3D 0;
+ proc_buffer.elements =3D 0;
=20=09
for(i =3D 0 ; i < BD_ADDRESS_SIZE ; i++) {
null_bd_addr[i] =3D 0;
@@ -503,10 +514,13 @@ sec_man_remove_proc_file(void)
=20
/* fixme -- add return value for calling functions to indicate status of=
=20
check */
-void=20
+s32
sec_man_check(enum security_requests user, BD_ADDR bd_addr, u32 service_da=
ta,
u32 user_data)
{
+ u32 pos;
+ security_query *query;
+=09
#ifndef __KERNEL__
if (sec_man_sock < 0) {
/* What to do if no security manager present?? */
@@ -522,27 +536,46 @@ sec_man_check(enum security_requests use
=20
}
#endif
+ D_PROC(__FUNCTION__ ": Current elements in buffer: %d\n", proc_buffer.ele=
ments);
=20
- security_query.request_type =3D user;
- security_query.request_value =3D service_data;
- memcpy(security_query.remote_bd, bd_addr, BD_ADDRESS_SIZE);
- security_query.originator =3D BT_SEC_MAN;
- security_query.originator_data =3D user_data;
- security_query.request_result =3D GENERAL_FAILURE;
+ if(proc_buffer.elements >=3D MAX_QUEUE_ENTRIES) {
+ D_ERR(__FUNCTION__ ": Not room for any queries at the moment");
+ return -1;
+ }
+=09
+ pos =3D proc_buffer.in;
+ proc_buffer.in +=3D sizeof(security_query);
+ ++proc_buffer.elements;
+ if(proc_buffer.in >=3D (sizeof(security_query) * MAX_QUEUE_ENTRIES)) {
+ proc_buffer.in =3D 0;
+ }
+
+ query =3D (security_query *)(proc_buffer.data + pos);
+
+ query->request_type =3D user;
+ query->request_value =3D service_data;
+ memcpy(query->remote_bd, bd_addr, BD_ADDRESS_SIZE);
+ query->originator =3D BT_SEC_MAN;
+ query->originator_data =3D user_data;
+ query->request_result =3D GENERAL_FAILURE;
=20
#ifdef __KERNEL__
D_PROC("wake_up process %i (%s) awakening\n", current->pid, current->comm=
);
wake_up_interruptible(&sec_man_wq);
D_PROC("wake_up process %i (%s) woke up\n", current->pid, current->comm);
+ return 0;
#else
- sec_man_doquery(sec_man_sock, (u8*) &security_query);
+ return sec_man_doquery(sec_man_sock, (u8*)query);
#endif
}
=20
-void
+s32
sec_man_event(enum security_requests user, BD_ADDR bd_addr, u8 event,
u8 *param, u8 param_len)
{
+ security_query *query;
+ u32 pos;
+=09
if (event =3D=3D HCI_VALUE_RETURN_LINK_KEYS)
{
/* Ok, link key has to be stored locally */
@@ -553,41 +586,59 @@ sec_man_event(enum security_requests use
link_key =3D create_link_key(bd_addr, link_key_str);
insert_link_key(link_key);
D_PROC("sec_man_event: Number of elements in list: %d\n", link_key_list.=
count);
+ return 0;
=20=09=09
}
else
{
#ifndef __KERNEL__
if (sec_man_sock < 0) {
- /* What to do if no security manager present?? */
+ return -1;
}
#endif
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;
+ D_PROC(__FUNCTION__ ": Current elements in buffer: %d\n", proc_buffer.el=
ements);
+
+ if(proc_buffer.elements >=3D MAX_QUEUE_ENTRIES) {
+ D_ERR(__FUNCTION__ ": Not room for any queries at the moment");
+ return -1;
+ }
+=09=09
+ pos =3D proc_buffer.in;
+ proc_buffer.in +=3D sizeof(security_query);
+ ++proc_buffer.elements;
+ if(proc_buffer.in >=3D (sizeof(security_query) * MAX_QUEUE_ENTRIES)) {
+ proc_buffer.in =3D 0;
+ }
+=09=09
+ query =3D (security_query *)(proc_buffer.data + pos);
+=09=09
+ query->request_type =3D user;
+ query->request_value =3D event;
if(bd_addr) {
- memcpy(security_query.remote_bd, bd_addr, BD_ADDRESS_SIZE);
+ memcpy(query->remote_bd, bd_addr, BD_ADDRESS_SIZE);
} else {
- memcpy(security_query.remote_bd, null_bd_addr, BD_ADDRESS_SIZE);
+ memcpy(query->remote_bd, null_bd_addr, BD_ADDRESS_SIZE);
}
=20=09=09
- security_query.originator =3D BT_SEC_MAN;
+ query->originator =3D BT_SEC_MAN;
=20=09=09
if (param_len > MAX_EVENT_DATA_LENGTH) {
D_PROC("Event data length too long, %d byte\n", param_len);
- memcpy(security_query.event_param, param, MAX_EVENT_DATA_LENGTH);
+ memcpy(query->event_param, param, MAX_EVENT_DATA_LENGTH);
} else {
- memcpy(security_query.event_param, param, param_len);
+ memcpy(query->event_param, param, param_len);
}
=20=09=09
- security_query.request_result =3D GENERAL_FAILURE;
+ query->request_result =3D GENERAL_FAILURE;
=20=09=09
#ifdef __KERNEL__
D_PROC("wake_up process %i (%s) awakening\n", current->pid, current->com=
m);
wake_up_interruptible(&sec_man_wq);
D_PROC("wake_up process %i (%s) woke up\n", current->pid, current->comm);
+ return 0;
#else
- sec_man_doquery(sec_man_sock, (u8*) &security_query);
+ return sec_man_doquery(sec_man_sock, (u8*)query);
#endif
}
}
@@ -674,24 +725,33 @@ s32 sec_man_read(struct inode *inode, st
char * buf, s32 count)
#endif
{
- s32 tmp;
-=09
+ u16 entry_size =3D sizeof(security_query);
D_PROC(__FUNCTION__ ": Someone is trying to read %d bytes from sec proc-f=
ile\n", count);
+ D_PROC(__FUNCTION__ ": Current elements in buffer: %d\n", proc_buffer.ele=
ments);
=20
cli();
- if (security_query.originator !=3D BT_SEC_MAN) {
- D_PROC(__FUNCTION__ ": No response yet, going to sleep\n");
+ if (proc_buffer.elements =3D=3D 0) {
+ D_PROC(__FUNCTION__ ": Nothing to be read, going to sleep\n");
interruptible_sleep_on(&sec_man_wq);
}
sti();
=20
- tmp =3D sizeof security_query;
- memcpy(buf, &security_query, tmp);
-=09
- D_PROC(__FUNCTION__ ": Returning %d bytes\n", tmp);
- security_query.originator =3D SEC_CLIENT; /* Change so we lock aga=
in */
=20=20=20=20=20=20=20=20=20
- return tmp;
+ if(proc_buffer.elements > 0)
+ {
+ memcpy(buf, proc_buffer.data + proc_buffer.out, entry_size);
+ D_PROC(__FUNCTION__ ": Returning %d bytes\n", entry_size);
+ --proc_buffer.elements;
+ proc_buffer.out +=3D entry_size;
+ if(proc_buffer.out >=3D (entry_size * MAX_QUEUE_ENTRIES)) {
+ proc_buffer.out =3D 0;
+ }
+ return entry_size;
+ } else {
+ /* If no data was available (weird case), send a EAGAIN
+ error to the client which probably will try again. */
+ return -EAGAIN;
+ }
}
=20
#ifdef USE_NEW_PROC
@@ -715,9 +775,6 @@ s32 sec_man_write(struct inode *inode, s
/* D_XMIT(__FUNCTION__ ": Preparing to send data to sec_con[%d]\n", secb_h=
dl->sec_con_id); */
if (sec_hdl->originator =3D=3D BT_SEC_MAN) /* o.k. new request */
{
- /* Change so we do not receive old data */
- security_query.originator =3D SEC_CLIENT;
-=09=09
switch (sec_hdl->request_type) {
case L2CAP:
D_PROC(__FUNCTION__ ": Message to L2CAP\n");
|
|
From: Anders J. <and...@us...> - 2004-04-14 17:45:50
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
sec_client.c 1.30 1.31=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Don't store any linkkeys as initiator.
The diff of the modified file(s):
--- sec_client.c 2004/01/30 12:03:54 1.30
+++ sec_client.c 2004/04/14 17:45:40 1.31
@@ -613,7 +613,9 @@ sec_man_event(enum security_requests use
break;
=20
case LINK_KEY_NOTIFICATION:
+#if 0=09=09=09=09
hci_write_stored_link_key(bd_addr, param, 0);
+#endif
break;
case AUTHENTICATION_COMPLETE:
case ENCRYPTION_CHANGE:
|
|
From: Anders J. <and...@us...> - 2004-04-15 08:21:14
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
sec_client.c 1.31 1.32=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Re-enabled storing of linkkey.
The diff of the modified file(s):
--- sec_client.c 2004/04/14 17:45:40 1.31
+++ sec_client.c 2004/04/15 08:21:07 1.32
@@ -613,9 +613,7 @@ sec_man_event(enum security_requests use
break;
=20
case LINK_KEY_NOTIFICATION:
-#if 0=09=09=09=09
hci_write_stored_link_key(bd_addr, param, 0);
-#endif
break;
case AUTHENTICATION_COMPLETE:
case ENCRYPTION_CHANGE:
|