You can subscribe to this list here.
2001 |
Jan
|
Feb
(44) |
Mar
(202) |
Apr
(134) |
May
(89) |
Jun
(94) |
Jul
(58) |
Aug
(58) |
Sep
(56) |
Oct
(75) |
Nov
(26) |
Dec
(14) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(24) |
Feb
(30) |
Mar
(15) |
Apr
(49) |
May
(12) |
Jun
(6) |
Jul
(11) |
Aug
(20) |
Sep
(19) |
Oct
(3) |
Nov
(13) |
Dec
(1) |
2003 |
Jan
(7) |
Feb
(4) |
Mar
(7) |
Apr
(5) |
May
(6) |
Jun
(3) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(51) |
Dec
(1) |
2004 |
Jan
(11) |
Feb
(5) |
Mar
|
Apr
(5) |
May
(2) |
Jun
|
Jul
(21) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Anders J. <and...@us...> - 2004-04-14 17:55:53
|
The following files were modified in libs/openbt: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- bt_if.c 1.10 1.11=20=20=20=20=20=20=20=20=20=20=20=20=20=20 bt_if.h 1.9 1.10=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added functions for read/delete linkkeys. The diff of the modified file(s): --- bt_if.c 2004/02/09 15:09:58 1.10 +++ bt_if.c 2004/04/14 17:55:39 1.11 @@ -1268,6 +1268,26 @@ int bb_connect(int bt_cfd, unsigned char return result; } =20 +int bt_read_stored_linkkey(int bt_cfd, unsigned char *bd, + int read_all) +{ + unsigned char data[7]; + data[0] =3D read_all; + memcpy(data + 1, bd, 6); + return ioctl(bt_cfd, HCIREADSTOREDLINKKEY, data); +} + + +int bt_delete_stored_linkkey(int bt_cfd, unsigned char *bd, + int delete_all) +{ + unsigned char data[7]; + data[0] =3D delete_all; + memcpy(data + 1, bd, 6); + return ioctl(bt_cfd, HCIDELETESTOREDLINKKEY, data); +} + + =20 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* Misc functions */ --- bt_if.h 2004/02/09 15:09:58 1.9 +++ bt_if.h 2004/04/14 17:55:39 1.10 @@ -438,6 +438,11 @@ int bt_write_ledenable(int bt_cfd, unsig /* Authenticate and encryption */ int bt_authenticate_encrypt(int bt_cfd, unsigned char *bd); =20 +/* Read / Delete linkkeys */ +int bt_read_stored_linkkey(int bt_cfd, unsigned char *bd, + int read_all); +int bt_delete_stored_linkkey(int bt_cfd, unsigned char *bd, + int delete_all); /* * Misc functions */ |
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-14 17:40:56
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- hci.c 1.215 1.216=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Don't do M/S switch when initiating a baseband connection. The diff of the modified file(s): --- hci.c 2003/12/02 11:58:27 1.215 +++ hci.c 2004/04/14 17:40:38 1.216 @@ -3618,13 +3618,8 @@ lp_connect_req(u8 bd_addr[]) =20 i_am_initiator =3D 1; =20 -#ifdef CONFIG_BLUETOOTH_ENABLE_MSSWITCH - return create_connection(bd_addr, 0xcc18, 0x00, 0x00, - 0x00, ALLOW_ROLE_SWITCH); -#else return create_connection(bd_addr, 0xcc18, 0x00, 0x00, 0x00, DONT_ALLOW_ROLE_SWITCH); -#endif } =20 /* A response from L2CAP to a previous lp_connect_ind */ |
From: Anders J. <and...@us...> - 2004-02-12 22:41:25
|
The following file was modified in apps/bluetooth/utils/btconfig: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- btconfig.c 1.5 1.6=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added -i option to set device from where btconfig shall get the=20 current IP-address. Default is eth0. Changed call to get_local_ip_address so it won't loop forever upon failure getting the address. The diff of the modified file(s): --- btconfig.c 2004/02/09 15:08:23 1.5 +++ btconfig.c 2004/02/12 22:36:12 1.6 @@ -113,6 +113,8 @@ static int var_page_timeout =3D -1; =20 static short var_max_power =3D SHRT_MAX; /* not yet set */ =20 +static char *device =3D "eth0"; + /* long option list */ static struct option long_options[] =3D { @@ -159,6 +161,7 @@ show_usage(void) printf(" 0: Variable pin\n"); printf(" 1: Fixed pin\n"); printf(" -l, --ledenabled=3DNUM Enable or disable the onboard led (= CRIS)\n"); + printf(" -i, --ipdevice=3DDEV Device to read the IP-address found= \n"); } =20 int @@ -179,7 +182,7 @@ main(int argc, char **argv) =20 /* Parse command line options */ =20 - while ((opt =3D getopt_long(argc, argv, "f:hm:n:w:c:p:t:drl:", + while ((opt =3D getopt_long(argc, argv, "f:hm:n:w:c:p:t:drl:i:", long_options, &option_index)) !=3D -1) { switch (opt) @@ -234,6 +237,10 @@ main(int argc, char **argv) var_ledenabled =3D atoi(optarg); break; =20=20=20=20=20=20=20 + case 'i': + device =3D optarg; + break;=20 +=20=20=20=20=20=20 default: break; } @@ -467,6 +474,7 @@ parse_line(char* line, char** field, cha int configure_field(const char* field, const char* value) { + int errorcount =3D 10; if (!strcasecmp(field, "DeviceName")) { if (strlen(value) <=3D MAX_BTNAME_LEN) @@ -492,13 +500,14 @@ configure_field(const char* field, const if (var_add_ip =3D=3D TRUE) { D(syslog(LOG_INFO, __FUNCTION__": add IP address")); - while (1) + while (errorcount) { - strcpy(ip_addr, get_local_ip_address()); + strcpy(ip_addr, get_local_ip_address(device)); if (strncmp(ip_addr, "0.0.0.0", 7) =3D=3D 0) sleep(1); else break; + --errorcount; }=20 } else |
From: Anders J. <and...@us...> - 2004-02-12 22:39:19
|
The following files were modified in libs/openbt: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- bt_misc.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 bt_misc.h 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: get_local_ip_address now takes the device as argument. The diff of the modified file(s): --- bt_misc.c 2003/11/05 19:04:53 1.2 +++ bt_misc.c 2004/02/12 22:34:06 1.3 @@ -286,7 +286,7 @@ open_tcpsocket(const char *addrstr, int=20 * Retrieve the numerical IP address of eth0 for now. */ char * -get_local_ip_address(void) +get_local_ip_address(char *dev) { int fd; struct ifreq ifr; @@ -299,7 +299,7 @@ get_local_ip_address(void) } =20 ifr.ifr_addr.sa_family =3D AF_INET; - strcpy(ifr.ifr_name, "eth0"); + strcpy(ifr.ifr_name, dev); if (ioctl(fd, SIOCGIFADDR, (int)&ifr) < 0) { syslog(LOG_INFO, "%s: Could not determine local IP address!", __FUNCTI= ON__); --- bt_misc.h 2003/11/05 19:04:53 1.2 +++ bt_misc.h 2004/02/12 22:34:06 1.3 @@ -63,7 +63,7 @@ int write_pidfile(const char *pidname); =20 int restart_btd(void); =20 -char *get_local_ip_address(void); +char *get_local_ip_address(char *dev); =20 char* get_domain_name(void); =20 |
From: Anders J. <and...@us...> - 2004-02-10 01:22:00
|
The following file was modified in apps/bluetooth/utils/btconfig: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- btconfig.c 1.4 1.5=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added pagetimeout configuration option. The diff of the modified file(s): --- btconfig.c 2003/11/19 11:49:46 1.4 +++ btconfig.c 2004/02/09 15:08:23 1.5 @@ -109,6 +109,7 @@ static int var_dont_allow_slave =3D -1; /* static int var_set_local_name =3D 0; static int var_max_connections =3D -1; /* not yet set */ static int var_pincode_type =3D -1; +static int var_page_timeout =3D -1; =20 static short var_max_power =3D SHRT_MAX; /* not yet set */ =20 @@ -285,7 +286,8 @@ main(int argc, char **argv) var_max_power !=3D SHRT_MAX || var_dont_allow_slave >=3D 0 || var_pincode_type >=3D 0 || - var_ledenabled >=3D 0) + var_ledenabled >=3D 0 ||=20 + var_page_timeout > 0) { /* Configure BT local name */ if (var_set_local_name) @@ -314,6 +316,9 @@ main(int argc, char **argv) =20=20=20=20=20=20=20 if (var_ledenabled >=3D 0) bt_write_ledenable(bt_cfd, (unsigned char)var_ledenabled); + + if (var_page_timeout > 0) + bt_write_page_to(bt_cfd, var_page_timeout); } } else { if(read_settings(bt_cfd) < 0) @@ -552,6 +557,13 @@ configure_field(const char* field, const (var_dont_allow_slave ? "yes" : "no"))); } =20 + else if (!strcasecmp(field, "PageTimeout")) + { + var_page_timeout =3D atoi(value); + D(syslog(LOG_INFO, __FUNCTION__ ": Page timeout: %d", value)); + } +=20=20 + return TRUE; } /* configure_field */ =20 |
From: Anders J. <and...@us...> - 2004-02-10 00:22:46
|
The following files were modified in libs/openbt: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- bt_if.c 1.9 1.10=20=20=20=20=20=20=20=20=20=20=20=20=20=20 bt_if.h 1.8 1.9=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: bt_write_page_to argument changed to int. The diff of the modified file(s): --- bt_if.c 2004/01/30 11:58:37 1.9 +++ bt_if.c 2004/02/09 15:09:58 1.10 @@ -759,9 +759,9 @@ bt_write_num_broadcast_rtx(int bt_cfd, u } =20 void -bt_write_page_to(int bt_cfd, unsigned char* page_to) +bt_write_page_to(int bt_cfd, int page_to) { - if (ioctl(bt_cfd, HCIWRITEPAGETO, page_to) < 0) + if (ioctl(bt_cfd, HCIWRITEPAGETO, &page_to) < 0) { perror(__FUNCTION__); } --- bt_if.h 2004/01/30 11:58:37 1.8 +++ bt_if.h 2004/02/09 15:09:58 1.9 @@ -412,7 +412,7 @@ void bt_exit_sniff_mode(int bt_cfd, unsi void bt_read_clock_offset(int bt_cfd, unsigned char* con_hdl); void bt_read_num_broadcast_rtx(int bt_cfd); void bt_write_num_broadcast_rtx(int bt_cfd, unsigned char* num_rtx); -void bt_write_page_to(int bt_cfd, unsigned char* page_to); +void bt_write_page_to(int bt_cfd, int page_to); void bt_read_tx_power_level(int bt_cfd, unsigned char* tx_power_level); void bt_write_link_supervision_to(int bt_cfd, unsigned char* link_to); void bt_write_page_scan_activity(int bt_cfd, unsigned char* page_scan); |
From: Anders J. <and...@us...> - 2004-02-04 17:57:48
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- bluetooth.c 1.248 1.249=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Corrected returnvalue for HCIAUTHENTICATION_ENCRYPTION ioctl. The diff of the modified file(s): --- bluetooth.c 2004/01/30 12:03:51 1.248 +++ bluetooth.c 2004/02/04 17:55:23 1.249 @@ -975,7 +975,7 @@ hci_inq_exit0: start_wq_timer(&secman_handler.timer, 30 * HZ, &secman_handler.wq); interruptible_sleep_on(&secman_handler.wq); - if(secman_handler.status !=3D 0) { + if((secman_handler.status & 0xffff) !=3D 0) { return -secman_handler.status; } if(hci_set_connection_encryption_bd(bd_addr, 1) < 0) { @@ -985,8 +985,11 @@ hci_inq_exit0: start_wq_timer(&secman_handler.timer, 10 * HZ, &secman_handler.wq); interruptible_sleep_on(&secman_handler.wq); + if((secman_handler.status & 0xffff) !=3D 0) { return -secman_handler.status; } + return 0; + } =20=09 =20 case HCIREADCLOCKOFFSET: |
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); } |
From: Anders J. <and...@us...> - 2004-01-31 02:46:45
|
The following files were modified in linux/include/linux/bluetooth: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- bluetooth.h 1.50 1.51=20=20=20=20=20=20=20=20=20=20=20=20=20=20 btcommon.h 1.105 1.106=20=20=20=20=20=20=20=20=20=20=20=20=20 l2cap.h 1.46 1.47=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added lp_connect which is a wrapper around lp_connect_req. Added 2 new IOCTL:s. The diff of the modified file(s): --- bluetooth.h 2003/02/06 15:36:22 1.50 +++ bluetooth.h 2004/01/30 12:04:54 1.51 @@ -104,6 +104,7 @@ s32 bt_sprint_status(u8 *buf); void bt_send_sdp_data_received(u8 line, u8 *data, int len); void bt_reset_phys_hw(void); void bt_handle_hw_error(u8 error); +void bt_secman_notify(s32 status); =20 /* Handles wakeup of failed blocking function calls */ #ifdef __KERNEL__ --- btcommon.h 2004/01/09 15:28:59 1.105 +++ btcommon.h 2004/01/30 12:04:54 1.106 @@ -154,6 +154,7 @@ #define BTDISCONNECT_ALL _IO(BT_IOC_MAGIC, 0x14) #define BTLEDSTATUS _IOW(BT_IOC_MAGIC, 0x15, s32) #define SDPCONNECT _IOW(BT_IOC_MAGIC, 0x16, bt_connection) +#define BBCONNECT _IOW(BT_IOC_MAGIC, 0x17, bt_connection) =20 /* Ioctls executing HCI commands */ =20 @@ -167,6 +168,7 @@ #define HCISETCONNECTION_ENCRYPTION _IOW(BT_IOC_MAGIC, 0x26, u8[7]) #define HCIREMOTENAME_REQUEST _IOW(BT_IOC_MAGIC, 0x27, u8[255]) #define HCIREADCLOCKOFFSET _IOWR(BT_IOC_MAGIC, 0x53, u32) +#define HCIAUTHENTICATION_ENCRYPTION _IOW(BT_IOC_MAGIC, 0x66, u8[6]) =20 /* Link Policy Commands */ #define HCISWITCHROLE _IOW(BT_IOC_MAGIC, 0x28, u8[7]) --- l2cap.h 2003/11/05 15:22:54 1.46 +++ l2cap.h 2004/01/30 12:04:55 1.47 @@ -319,6 +319,8 @@ void l2cap_create_con(BD_ADDR bd, CLASS_ /* Indicates the baseband has been shutdown */ s32 lp_disconnect_ind(u32 con_hdl); =20 +s32 lp_connect(BD_ADDR bd, bt_pincode *pincode); + /* FIXME - lp_qos_cfm() */ /* FIXME - lp_qos_violation_ind() */ =20 |
From: Anders J. <and...@us...> - 2004-01-31 02:46:44
|
The following files were modified in libs/openbt: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- bt_if.c 1.8 1.9=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 bt_if.h 1.7 1.8=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added function to only connect basebaned. Added function to do authentication and encryption. The diff of the modified file(s): --- bt_if.c 2004/01/20 17:55:52 1.8 +++ bt_if.c 2004/01/30 11:58:37 1.9 @@ -1245,6 +1245,29 @@ int sdp_connect(int bt_cfd, unsigned cha return result; } =20 +int bb_connect(int bt_cfd, unsigned char *bd, + unsigned char *pin, int pinlen) +{ + int result =3D 0; + bt_connection con; +=20=20 + memcpy(con.bd, bd, 6); + memcpy(con.pincode.data, pin, MIN(pinlen, 0x10)); + con.pincode.len =3D pinlen; +=20=20 + result =3D ioctl(bt_cfd, BBCONNECT, &con); + if (result&0x0ff) + { + printf("BB connect failed [%s ((0x%X))]\n", + error_msg(result), result); + } + else + { + printf("BB connected\n"); + } + return result; +} + =20 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* Misc functions */ @@ -1412,6 +1435,26 @@ int start_sdp_server(void) return sdpsrv_pid; } =20 +/* Will perform an authentication and then encrypt the link associated + with the BD */ +int +bt_authenticate_encrypt(int bt_cfd, unsigned char *bd) +{ + int retval; + unsigned char rev_bd[6]; + for(retval =3D 0; retval < 6 ; retval++) + { + rev_bd[5-retval] =3D bd[retval]; + } +=20=20 + if ((retval =3D ioctl(bt_cfd, HCIAUTHENTICATION_ENCRYPTION, &rev_bd)) < = 0) + { + printf("Authentication/Encryption failed [%s ((0x%X))]\n", + error_msg(retval), retval & 0xff); + } + return retval; +} + int strtobd(unsigned char *src, unsigned char *dst) { int bd[6], parseok =3D 0, i; --- bt_if.h 2004/01/09 15:29:59 1.7 +++ bt_if.h 2004/01/30 11:58:37 1.8 @@ -141,6 +141,9 @@ /* Initiate a SDP-connection */ #define SDPCONNECT _IOW(BT_IOC_MAGIC, 0x16, bt_connection) =20 +/* Initiate a baseband connection */ +#define BBCONNECT _IOW(BT_IOC_MAGIC, 0x17, bt_connection) + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* Ioctls for executing HCI commands */ =20 @@ -155,6 +158,7 @@ #define HCISETCONNECTION_ENCRYPTION _IOW(BT_IOC_MAGIC, 0x26, unsigned char= [7]) #define HCIREMOTENAME_REQUEST _IOW(BT_IOC_MAGIC, 0x27, unsigned char[255]) #define HCIREADCLOCKOFFSET _IOWR(BT_IOC_MAGIC, 0x53, unsigned char[4]) +#define HCIAUTHENTICATION_ENCRYPTION _IOW(BT_IOC_MAGIC, 0x66, unsigned cha= r[6]) =20 /* Link Policy Commands */ =20 @@ -365,6 +369,9 @@ int bt_set_max_conections(int bt_cfd, in /* SDP functions */ int sdp_connect(int bt_cfd, unsigned char *bd, unsigned char *pin, int pin= len); =20 +/* Baseband functions */ +int bb_connect(int bt_cfd, unsigned char *bd, unsigned char *pin, int pinl= en); + /* * HCI command functions */ @@ -428,6 +435,8 @@ int bt_read_pin_type(int bt_cfd); int bt_read_ledenable(int bt_cfd); int bt_write_ledenable(int bt_cfd, unsigned char enable); =20 +/* Authenticate and encryption */ +int bt_authenticate_encrypt(int bt_cfd, unsigned char *bd); =20 /* * Misc functions |
From: Anders J. <and...@us...> - 2004-01-31 02:46:44
|
The following file was modified in apps/bluetooth/utils/btconnect: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- btcon.c 1.5 1.6=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added option to do authentication/encryption. Added option BB to connect baseband. The diff of the modified file(s): --- btcon.c 2004/01/09 15:31:10 1.5 +++ btcon.c 2004/01/30 12:00:04 1.6 @@ -80,7 +80,7 @@ static int connect_bnep(unsigned char *b static void usage() { - printf("btcon -a <BD> [-p <pincode>] [-P <protocol RFCOMM|BNEP|SDP>]\n"); + printf("btcon -a <BD> [-p <pincode>] [-P <protocol RFCOMM|BNEP|SDP|BB>] = [-A]\n"); printf("RFCOMM protocol:\n"); printf(" [-s <rfcomm srv channel>]\n"); printf(" [-d <device>]\n"); @@ -89,6 +89,11 @@ usage() printf(" [-S <source service>]\n"); printf("SDP protocol:\n"); printf(" No options needed\n"); + printf("BB (Baseband):\n"); + printf(" No options needed\n"); + printf("The -A flag:\n"); + printf(" Set this flag to authenticate and encrypt a link, shall on= ly be\n"); + printf(" used with -a. The pin must have been set with a previous B= B connect\n"); printf("Default values:\n"); printf(" -P %s\n", DEFAULT_PROTOCOL); printf(" -s %d\n", DEFAULT_SRV_CHANNEL); @@ -144,6 +149,13 @@ connect_sdp(unsigned char *bd) pin, strlen(pin)); } =20 +static int=20 +connect_bb(unsigned char *bd) +{ + printf("Connecting baseband\n"); + return bb_connect(bt_cfd, bd, + pin, strlen(pin)); +} =20 int main(int argc, char **argv) @@ -157,6 +169,7 @@ main(int argc, char **argv) int dstservice =3D DEFAULT_DEST; int srcservice =3D DEFAULT_SRC; unsigned char *protocol =3D DEFAULT_PROTOCOL;=20 + int doauthentication =3D 0; =20 /* Print header if called via http */ if (getenv("REQUEST_METHOD") !=3D NULL) @@ -165,10 +178,16 @@ main(int argc, char **argv) } =20 /* now parse options */ - while ((opt =3D getopt(argc, argv, "a:d:r:S:p:D:s:S:P:h")) !=3D -1) + while ((opt =3D getopt(argc, argv, "Aa:d:r:S:p:D:s:S:P:h")) !=3D -1) { switch (opt) { + case 'A': + { + doauthentication++; + } + break; +=20=20=20=20=20=20 case 'a': { bd_str =3D optarg; @@ -279,6 +298,12 @@ main(int argc, char **argv) exit(1); } =20 + if(doauthentication) + { + result =3D bt_authenticate_encrypt(bt_cfd, bd); + } + else + { if(!strcmp(protocol, "RFCOMM")) { result =3D connect_rfcomm(bd, srvch, line); @@ -291,11 +316,17 @@ main(int argc, char **argv) { result =3D connect_sdp(bd); } + else if(!strcmp(protocol, "BB")) + { + result =3D connect_bb(bd); + } else { fprintf(stderr, "Unknown protocol, exit\n"); usage(); } + } +=20=20 close(bt_cfd); exit(result); } |
From: Anders J. <and...@us...> - 2004-01-30 23:36:38
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- sdp.c 1.92 1.93=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Set connectionstate to disconnected upon a failed l2cap connection attempt. The diff of the modified file(s): --- sdp.c 2004/01/09 15:27:18 1.92 +++ sdp.c 2004/01/30 13:22:10 1.93 @@ -537,6 +537,9 @@ sdp_connect_cfm(l2cap_con *l2cap, s32 st if (status) { DSYS(__FUNCTION__ " Connection failed\n"); sdp->status =3D status; + sdp->state =3D SDP_DISCONNECTED; + sdp->l2cap =3D NULL; + sdp->request =3D NULL; wake_up_interruptible(&sdp->waitqueue); release_wq_timer(&sdp->timer); return; |
From: Anders J. <and...@us...> - 2004-01-27 12:18:35
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- bnep.c 1.20 1.21=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Handle source/dest UUID correctly when send setup connection for BNEP. The diff of the modified file(s): --- bnep.c 2003/11/05 17:03:14 1.20 +++ bnep.c 2004/01/27 12:17:35 1.21 @@ -1075,6 +1075,7 @@ bnep_control(l2cap_con *l2cap, u8 *data, D_MISC("UUID length: %x, dest uuid: %02lx, source uuid: %02lx\n", data[0], destination_uuid, source_uuid); local->remote_role =3D source_uuid; + local->role =3D destination_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"); @@ -1595,12 +1596,12 @@ bnep_setup_connection(struct net_local * *(u16*)(tx_buf->data +=20 sizeof(bnep_tx_buf) +=20 sizeof(struct bnep_setup_connection_request_msg)) =3D=20 - cpu_to_be16(UUID_NAP); + cpu_to_be16(local->remote_role); =20=09=09 *(u16*)(tx_buf->data +=20 sizeof(bnep_tx_buf) +=20 sizeof(struct bnep_setup_connection_request_msg) + 2) =3D=20 - cpu_to_be16(UUID_PANU); + cpu_to_be16(local->role); =20=09=09 tx_buf->cur_len =3D (sizeof(struct bnep_setup_connection_request_msg) += =20 req.uuid_size * 2); |
From: Anders J. <and...@us...> - 2004-01-20 17:55:53
|
The following file was modified in libs/openbt: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- bt_if.c 1.7 1.8=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Corrected handling of errorcode for sdp_connect. The diff of the modified file(s): --- bt_if.c 2004/01/09 15:29:59 1.7 +++ bt_if.c 2004/01/20 17:55:52 1.8 @@ -1225,7 +1225,7 @@ int bt_write_ledenable(int bt_cfd, unsig int sdp_connect(int bt_cfd, unsigned char *bd, unsigned char *pin, int pinlen) { - unsigned int result =3D 0; + int result =3D 0; bt_connection con; =20=20=20 memcpy(con.bd, bd, 6); @@ -1236,7 +1236,7 @@ int sdp_connect(int bt_cfd, unsigned cha if (result&0x0ff) { printf("SDP connect failed [%s ((0x%X))]\n", - error_msg(result & 0x0ff), result); + error_msg(result), result); } else { |
From: Anders J. <and...@us...> - 2004-01-09 15:31:11
|
The following file was modified in apps/bluetooth/utils/btconnect: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- btcon.c 1.4 1.5=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added SDP. The diff of the modified file(s): --- btcon.c 2003/11/06 19:10:13 1.4 +++ btcon.c 2004/01/09 15:31:10 1.5 @@ -80,13 +80,15 @@ static int connect_bnep(unsigned char *b static void usage() { - printf("btcon -a <BD> [-p <pincode>] [-P <protocol RFCOMM/BNEP>]\n"); + printf("btcon -a <BD> [-p <pincode>] [-P <protocol RFCOMM|BNEP|SDP>]\n"); printf("RFCOMM protocol:\n"); printf(" [-s <rfcomm srv channel>]\n"); printf(" [-d <device>]\n"); printf("BNEP protocol:\n"); printf(" [-D <destination service>]\n"); printf(" [-S <source service>]\n"); + printf("SDP protocol:\n"); + printf(" No options needed\n"); printf("Default values:\n"); printf(" -P %s\n", DEFAULT_PROTOCOL); printf(" -s %d\n", DEFAULT_SRV_CHANNEL); @@ -134,6 +136,15 @@ connect_bnep(unsigned char *bd, pin, strlen(pin)); } =20 +static int=20 +connect_sdp(unsigned char *bd) +{ + printf("Connecting with SDP\n"); + return sdp_connect(bt_cfd, bd, + pin, strlen(pin)); +} + + int main(int argc, char **argv) { @@ -275,6 +286,10 @@ main(int argc, char **argv) else if(!strcmp(protocol, "BNEP")) { result =3D connect_bnep(bd, dstservice, srcservice); + } + else if(!strcmp(protocol, "SDP")) + { + result =3D connect_sdp(bd); } else { |
From: Anders J. <and...@us...> - 2004-01-09 15:30:00
|
The following files were modified in libs/openbt: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- bt_if.c 1.6 1.7=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 bt_if.h 1.6 1.7=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added SDP-stuff. The diff of the modified file(s): --- bt_if.c 2003/11/17 15:00:47 1.6 +++ bt_if.c 2004/01/09 15:29:59 1.7 @@ -1222,6 +1222,30 @@ int bt_write_ledenable(int bt_cfd, unsig return 0; } =20 +int sdp_connect(int bt_cfd, unsigned char *bd, + unsigned char *pin, int pinlen) +{ + unsigned int result =3D 0; + bt_connection con; +=20=20 + memcpy(con.bd, bd, 6); + memcpy(con.pincode.data, pin, MIN(pinlen, 0x10)); + con.pincode.len =3D pinlen; +=20=20 + result =3D ioctl(bt_cfd, SDPCONNECT, &con); + if (result&0x0ff) + { + printf("SDP connect failed [%s ((0x%X))]\n", + error_msg(result & 0x0ff), result); + } + else + { + printf("SDP connected\n"); + } + return result; +} + + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* Misc functions */ =20 --- bt_if.h 2003/11/17 15:00:48 1.6 +++ bt_if.h 2004/01/09 15:29:59 1.7 @@ -123,7 +123,7 @@ #define BTWAITNEWCONNECTIONS _IO(BT_IOC_MAGIC, 0x0D) #define BTISLOWERCONNECTED _IOW(BT_IOC_MAGIC, 0x0E, int) =20 -//#define BT_SDP_REQUEST _IOW(BT_IOC_MAGIC, 0x0F, bt_sdp_request) +#define BT_SDP_REQUEST _IOWR(BT_IOC_MAGIC, 0x0F, bt_sdp_request) #define BT_GETCACHEDLINKKEY _IOWR(BT_IOC_MAGIC, 0x10, unsigned char[22]) =20 /* Disconnect the BB connection */ @@ -138,6 +138,9 @@ /* Read/Write LED enabled, CRIS-specific */ #define BTLEDSTATUS _IOW(BT_IOC_MAGIC, 0x15, int) =20 +/* Initiate a SDP-connection */ +#define SDPCONNECT _IOW(BT_IOC_MAGIC, 0x16, bt_connection) + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* Ioctls for executing HCI commands */ =20 @@ -304,6 +307,14 @@ typedef struct ping_struct unsigned char data[1024]; } ping_struct; =20 +typedef struct bt_sdp_request +{ + u_int16_t len; + u_int16_t allocated; + unsigned char bd[6]; + unsigned char data[0]; +} __attribute__ ((packed)) bt_sdp_request; + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* Functions common to both usermode and kernel stack */ =20 @@ -350,6 +361,9 @@ void bt_showstatus(void); int bt_force_msswitch_as_server(int bt_cfd, int enable); int bt_dont_allow_slave(int bt_cfd, int flag); int bt_set_max_conections(int bt_cfd, int connections); + +/* SDP functions */ +int sdp_connect(int bt_cfd, unsigned char *bd, unsigned char *pin, int pin= len); =20 /* * HCI command functions |
From: Anders J. <and...@us...> - 2004-01-09 15:29:06
|
The following files were modified in linux/include/linux/bluetooth: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- btcommon.h 1.104 1.105=20=20=20=20=20=20=20=20=20=20=20=20=20 sdp.h 1.29 1.30=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added IOCTL and structs used for SDP-queries. The diff of the modified file(s): --- btcommon.h 2003/11/17 14:57:54 1.104 +++ btcommon.h 2004/01/09 15:28:59 1.105 @@ -146,13 +146,14 @@ #define BTWAITFORCONNECTION _IOW(BT_IOC_MAGIC, 0x0C, s32) #define BTWAITNEWCONNECTIONS _IO(BT_IOC_MAGIC, 0x0D) #define BTISLOWERCONNECTED _IOW(BT_IOC_MAGIC, 0x0E, s32) -#define BT_SDP_REQUEST _IOW(BT_IOC_MAGIC, 0x0F, bt_sdp_request) +#define BT_SDP_REQUEST _IOWR(BT_IOC_MAGIC, 0x0F, bt_sdp_request) #define BT_GETCACHEDLINKKEY _IOWR(BT_IOC_MAGIC, 0x10, u8[22]) #define BTDISCONNECT_BB _IOW(BT_IOC_MAGIC, 0x11, u8[6]) #define BTREADREMOTENAME _IOWR(BT_IOC_MAGIC, 0x12, u8[BT_NAME_LENGTH]) #define BTREADREMOTECLASSOFDEV _IOWR(BT_IOC_MAGIC, 0x13, u8[6]) #define BTDISCONNECT_ALL _IO(BT_IOC_MAGIC, 0x14) #define BTLEDSTATUS _IOW(BT_IOC_MAGIC, 0x15, s32) +#define SDPCONNECT _IOW(BT_IOC_MAGIC, 0x16, bt_connection) =20 /* Ioctls executing HCI commands */ =20 @@ -486,13 +487,30 @@ typedef struct rfcomm_con{ /****************** SDP connection object ****************************/ =20 enum sdp_states{SDP_DISCONNECTED, SDP_CONNECTING, SDP_CONNECTED}; +enum sdp_request_states{SDP_REQUEST_IDLE, SDP_REQUEST_SENT, SDP_REQUEST_RE= SPONSE}; + +typedef struct bt_sdp_request +{ + u16 len; + u16 allocated; + u8 bd[6]; + u8 data[0]; +} __attribute__ ((packed)) bt_sdp_request; =20 typedef struct sdp_con{ l2cap_con *l2cap; u32 initiator; enum sdp_states state; u32 id; - u8 line; + bt_timer_obj timer; +#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0) + wait_queue_head_t waitqueue; +#else + struct wait_queue *waitqueue; +#endif + s32 status; + bt_sdp_request *request; + s32 request_status; } __attribute__ ((packed)) sdp_con; =20 /****************** BT connection object ********************************/ @@ -515,17 +533,7 @@ typedef struct bt_connection{ bt_pincode pincode; u16 bnep_src_uuid; u16 bnep_dst_uuid; -} bt_connection; - -typedef struct bt_sdp_request -{ - u32 conID; - u8 sdpCommand; - u8 pduPayload[256]; - int pduLength; - u8 requestResponse[256]; - int responseLength; -} bt_sdp_request; +} __attribute__ ((packed)) bt_connection; =20 /****************** Other structures used in the stack *******************= ***/ =20 @@ -546,13 +554,6 @@ typedef struct bt_session rfcomm_con *rfcomm; u8 dlci; s32 state; - - /* sdp */ - u8 *sdpRequestResponseData; - u16 sdpRequestResponseDataLength; - int sdpID; - - /* tcs ? */ } bt_session; =20 #define ANY_LINE 255 --- sdp.h 2003/11/05 15:22:54 1.29 +++ sdp.h 2004/01/09 15:29:03 1.30 @@ -82,7 +82,8 @@ void sdp_shutdown(void); s32 sdp_create_proc_file(void); s32 sdp_remove_proc_file(void); #endif -s32 sdp_connect_req(u8* bd_addr, u8 line, bt_pincode *pincode); +s32 sdp_connect(u8* bd_addr, bt_pincode *pincode); +s32 sdp_connect_req(u8* bd_addr, bt_pincode *pincode); void sdp_connect_ind(l2cap_con *l2cap); void sdp_connect_pnd(l2cap_con *l2cap, int status); void sdp_connect_cfm(l2cap_con *l2cap, s32 status); @@ -93,6 +94,8 @@ void sdp_disconnect_ind(l2cap_con *l2cap void sdp_disconnect_cfm(l2cap_con *l2cap); void sdp_receive_data(l2cap_con *l2cap, u8* data, u32 len); s32 sdp_send_data(sdp_con *sdp, u8 *data, u32 len); +s32 sdp_query(bt_sdp_request *request); + =20 #ifdef __KERNEL__ s32 sdpStartRequest(u8 sdpIndex, u8 sdpCommand, u8 *pduData, u16 pduLength= ); |
From: Anders J. <and...@us...> - 2004-01-09 15:27:20
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- bluetooth.c 1.246 1.247=20=20=20=20=20=20=20=20=20=20=20=20=20 sdp.c 1.91 1.92=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * Cleanup of old sdp-stuff, bt-lines are now only usable for RFCOMM. * Added IOCTL to send SDP-queries from userspace. The diff of the modified file(s): --- bluetooth.c 2003/11/18 18:03:32 1.246 +++ bluetooth.c 2004/01/09 15:27:18 1.247 @@ -213,7 +213,6 @@ static s32 bt_disconnect(u32 con_id); static const u8* psmname(u16 psm); #endif static void wq_timeout(unsigned long ptr); -static s32 bt_execute_sdp_request(bt_sdp_request *sdpRequest); =20 #ifdef __USE_OLD_SYMTAB__ /* @@ -574,28 +573,49 @@ __bt_ioctl(struct tty_struct *tty, struc switch (cmd) { case BT_SDP_REQUEST: { - bt_sdp_request sdpRequest; + bt_sdp_request *sdpRequest; int returnValue =3D -1; + u16 len; =20 /* Copy arguments to kernel space */ =20 BT_DRIVER(__FUNCTION__ ": Copying arguments from user to kernel space\n"= ); - copy_from_user(&sdpRequest, (s32*)arg, size); =20 - /* Now execute the request */ + /* First two bytes specifies size of data */ + copy_from_user(&len, (s32*)arg, 2); =20 - BT_DRIVER(__FUNCTION__ ": Executing bt_execute_sdp_request\n"); + if(!(sdpRequest =3D (bt_sdp_request *)kmalloc(sizeof(bt_sdp_request) += =20 + len, GFP_KERNEL))) { + D_ERR("%s: Failed to allocate memory\n", __FUNCTION__); + return -ENOMEM; + } =20 - if ((returnValue =3D bt_execute_sdp_request(&sdpRequest)) >=3D 0) { + copy_from_user(sdpRequest, (s32*)arg, sizeof(bt_sdp_request) + len); =20 - /* Copy the data back to user space and return */ + /* Allocate memory for the data * =20 - BT_DRIVER(__FUNCTION__ ": Copying data back to user space\n"); - copy_to_user((s32*)arg, &sdpRequest, size); - } + /* Now execute the request */ + + BT_DRIVER("%s: Executing bt_execute_sdp_request\n", __FUNCTION__); =20 + if ((returnValue =3D sdp_query(sdpRequest)) >=3D 0) { + /* Copy the data back to user space and return */ + copy_to_user((s32*)arg, sdpRequest,=20 + MIN(sdpRequest->allocated, sdpRequest->len) + sizeof(bt_sdp_reque= st)); + } + kfree(sdpRequest); return returnValue; } + case SDPCONNECT: + { + 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__ ": SDP_CONNECT\n"); + return sdp_connect(btcon.bd, &btcon.pincode); + } +=09 =20 #ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER case BT_GETCACHEDLINKKEY: @@ -2289,52 +2309,6 @@ hci_receive_data_task(void) } #endif /* CONFIG_BLUETOOTH_USE_INBUFFER */ =20 - -/* - * Searches data buffer for number of completed packets (NCP) - * If only NCP data was found tell serial driver not to - * schedule a flip of DMA inbuffer. - */ -int bt_catch_ncp(u8* data, u32 count) -{ - int index =3D 0; - - /* fixme -- do this for BCSP as well */ -#ifdef CONFIG_BLUETOOTH_SUPPORT_BCSP - if (bt_use_bcsp(-1)) - return 0; -#endif - - /* || uart hdr | event code | par_len | nbr_handles | [data...] || */ - - while (index+2 < count && - data[index] =3D=3D EVENT_PKT && - data[index+1] =3D=3D NBR_OF_COMPLETED_PACKETS) { - /* we found a NCP */ - index +=3D (3 + data[index + 2]); /* event hdr + par len */ - } - - if (index =3D=3D count) { - /* Contains _only_ NCP data, parse it ! */ - - /* The easy way would be to call bt_receive_data(data, count), - but since it calls hci_receive_data() which is a state - machine, we might mess up its state... */ - index =3D 0; - while (index+2 < count) { - update_ncp(data[index+3], data+index+4); - index +=3D (3 + data[index + 2]); - } - - return 1; - } - - /* Contains more than NCP data, tell serial - driver to queue it up as usual */ - return 0; -} - - static void bt_receive_data(u8* data, u32 count) { @@ -2400,67 +2374,6 @@ bt_connect(bt_connection *btcon) } break; =20 - case SDP_LAYER: - { - int sdp_connection_id =3D -1; - int return_value; - - /* Initiate the connection */ - - BT_DRIVER(__FUNCTION__ ": Connecting SDP on line %d\n", line); - BT_DATADUMP("Remote BD: ", bd_addr, 6); - if ((sdp_connection_id =3D sdp_connect_req(bd_addr, line, &btcon->pincod= e)) >=3D 0) { - - /* - * If here, we have successfully created an SDP - * connection entry and are starting the sequence of - * opening an l2cap connection. Allow the bottom - * half to process the request and get back to us. - */ - - /* I seem to be having a lot of trouble with the L2CAP - traffic just not appearing on this side of the link - while I'm waiting for the SDP conneciton to finish - up. So let's start a timer to wake us up if things - don't appear to be working out. - --gmcnutt - */ - start_wq_timer(&bt_ctrl.bt_timer[line], BT_CON_TIMEOUT, - &bt_ctrl.connect_wq[line]); - - /* The timeout routine doesn't have a hendle to our - session status, so set things up to reflect a - timeout error by default. If we really do get a - connection then this value _should_ be changed by - the time we wake up to reflect a good connection. - --gmcnutt - */ - bt_ctrl.session[line].connect_status =3D -ETIMEDOUT; - - 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]); - - /* - * If the connect_status is >=3D 0, then the lower - * stack did not have a problem handling the request. - * Therefore return the sdp_connection_id - */ - - BT_DRIVER(__FUNCTION__ ": Wake up - line %d\n", line); - if (bt_ctrl.session[line].connect_status >=3D 0) { - return_value =3D sdp_connection_id; - } else { - return_value =3D bt_ctrl.session[line].connect_status; - } - } else { - return_value =3D sdp_connection_id; - } - - return return_value; - } - break; - case L2CAP_TEST_LAYER: case L2CAP_TEST2_LAYER: case L2CAP_TEST3_LAYER: @@ -2484,52 +2397,6 @@ bt_connect(bt_connection *btcon) return -1; } =20 -static s32 bt_execute_sdp_request(bt_sdp_request *sdpRequest) -{ - int line =3D GET_LINE(sdpRequest->conID); - int sdpIndex =3D GET_SDPINDEX(sdpRequest->conID); - - if (SESSIONSTATE(line) !=3D BT_ACTIVE) { - - /* SDP connection not active! Don't issue the request */ - - BT_DRIVER(__FUNCTION__ ": Line %d does not have an active connection!\n"= , line); - return -ENOTCONN; - } - - BT_DRIVER(__FUNCTION__ ": Line %d SDP index %d\n", - line, sdpIndex); - - if (sdpStartRequest(sdpIndex, - sdpRequest->sdpCommand, - sdpRequest->pduPayload, - sdpRequest->pduLength) < 0) - return -1; /* fixme -- EPERM probably not appropriate */ - - /* Sleep on this line while the response is going through */ - - printk(__FUNCTION__ ": Sleep on line %d\n", line); - interruptible_sleep_on(&bt_ctrl.connect_wq[line]); - - /* If we're back, there may be data to send back. - Copy into sdpRequest and return */ - - if (bt_ctrl.session[line].sdpRequestResponseData) { - - BT_DRIVER(__FUNCTION__ ": sdpRequestResponseData 0x%x - copying\n", - (int)bt_ctrl.session[line].sdpRequestResponseData); - - memcpy(sdpRequest->requestResponse, - bt_ctrl.session[line].sdpRequestResponseData, - bt_ctrl.session[line].sdpRequestResponseDataLength); - sdpRequest->responseLength =3D - bt_ctrl.session[line].sdpRequestResponseDataLength; - - } - - return 0; -} - void bt_connect_ind(u32 con_id) { @@ -2573,54 +2440,12 @@ bt_connect_cfm(u32 con_id, s32 status) wake_up_interruptible(&bt_ctrl.any_wq); break; =20 - case SDP_LAYER: - /* Record the connection status for bt_connect() to proces= s. */ - 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_ctrl.bt_timer[line]); - wake_up_interruptible(&bt_ctrl.connect_wq[line]); - wake_up_interruptible(&bt_ctrl.any_wq); - break; - - case TCS_LAYER: - BT_DRIVER(__FUNCTION__ ": [%s]\n", psmname(psm)); - break; - default: D_ERR(__FUNCTION__ ": Unknown layer %d\n", psm); break; } } =20 -void -bt_send_sdp_data_received(u8 line, u8 *data, int len) -{ - /* Check the line for validity */ - if (line > BT_NBR_DATAPORTS) { - D_ERR(__FUNCTION__ ": Invalid line (%d)\n", line); - return; - } - - /* When data received for this line, we simply attach the - data (& length) and wake up */ - - BT_DRIVER(__FUNCTION__ ": data 0x%x len %d\n", (int)data, len); - /* If previous data, deallocate it */ - - if (bt_ctrl.session[line].sdpRequestResponseData) { - D_WARN(__FUNCTION__ ": sdpRequestResponseData set - deallocate\n"); - kfree(bt_ctrl.session[line].sdpRequestResponseData); - bt_ctrl.session[line].sdpRequestResponseData =3D NULL; - bt_ctrl.session[line].sdpRequestResponseDataLength =3D 0; - } - - bt_ctrl.session[line].sdpRequestResponseData =3D data; - bt_ctrl.session[line].sdpRequestResponseDataLength =3D len; - wake_up_interruptible(&bt_ctrl.connect_wq[line]); - return; -} - static s32 bt_disconnect(u32 con_id) { @@ -3389,36 +3214,6 @@ bt_register_rfcomm(struct rfcomm_con *rf } =20 s32 -bt_register_sdp(u8 line, u8 sdpID) -{ - s32 found =3D 0; - - if (!bt_stack_initiated) { - D_WARN(__FUNCTION__ ": Bluetooth stack not initialised\n"); - return -1; - } - - /* Better not have any sdp data pending for this connection */ - - if (bt_ctrl.session[line].sdpRequestResponseData) { - D_WARN(__FUNCTION__ ": Pending SDP data for this new connection on line = %d\n", line); - } - - if (SESSIONSTATE(line) =3D=3D BT_INACTIVE) { - /* now register ! */ - DSYS(__FUNCTION__ ": Line %d\n", line); - SESSIONSTATE(line) =3D BT_ACTIVE; - bt_ctrl.session[line].sdpID =3D sdpID; - found =3D 1; - } - - if (!found) - D_WARN(__FUNCTION__ ": Could not find any available lines\n"); - - return found; -} - -s32 bt_unregister_rfcomm(s32 line) { BT_DRIVER(__FUNCTION__ ": Line %d\n", line); @@ -3444,34 +3239,6 @@ bt_unregister_rfcomm(s32 line) #ifdef __KERNEL__ bt_hangupline(line); #endif - return 0; -} - -s32 bt_unregister_sdp(s32 line) -{ - BT_DRIVER(__FUNCTION__ ": Line %d\n", line); - - if (!bt_stack_initiated) { - D_WARN(__FUNCTION__ ": Bluetooth stack not initialised\n"); - return -1; - } - - /* Part of unregistering SDP is to deallocate any sdp request - response data AND clear length and pointer */ - - if (bt_ctrl.session[line].sdpRequestResponseData) { - DSYS(__FUNCTION__ ": Free request data 0x%x\n", - (unsigned int)bt_ctrl.session[line].sdpRequestResponseData); - kfree(bt_ctrl.session[line].sdpRequestResponseData); - bt_ctrl.session[line].sdpRequestResponseData =3D NULL; - bt_ctrl.session[line].sdpRequestResponseDataLength =3D 0; - } - - if (SESSIONSTATE(line) =3D=3D BT_ACTIVE) { - SESSIONSTATE(line) =3D BT_INACTIVE; - bt_ctrl.session[line].sdpID =3D -1; - } - return 0; } =20 --- sdp.c 2003/11/05 15:21:59 1.91 +++ sdp.c 2004/01/09 15:27:18 1.92 @@ -109,10 +109,6 @@ #define USE_NEW_PROC #endif =20 -#ifndef __KERNEL__ -#define SDP_SRV_SOCK "/tmp/sdp_sock" -#endif - #define GET_TYPE(ch) (((ch) >> 3) & 0x1f) #define GET_SIZE(ch) ((ch) & 0x7) #define SET_DE_HDR(type,size) ((((type) << 3) & 0xf8) + ((size) & 0x7)) @@ -166,11 +162,6 @@ static s32 sdp_database_write(struct ino static s32 sdp_proc_dir_entry_read(char *buf, char **start, off_t offset, s32 len, s32 unused); #endif - -#else /* USERMODE STACK */ -static s32 open_socket(char *name); -static s32 sdp_doquery(s32 fd, u8 *request, s32 len); -static s32 send_error_rsp(sdp_con *sdp, u16 trans_id, u16 err_code); #endif =20 /****************** GLOBAL VARIABLE DECLARATION SECTION ******************= ***/ @@ -311,41 +302,7 @@ static bt_tx_buf *db_write_tx_buf; static s32 db_write_recv; #endif =20 -#ifndef __KERNEL__ -static s32 sdp_sock; -#endif - /****************** FUNCTION DEFINITION SECTION **************************= ***/ - -#ifndef __KERNEL__ -int -open_socket(char *name) -{ - struct sockaddr_un server_address; - s32 client_sockfd; - s32 server_len; - - printf("Opening socket %s\n", name); - - client_sockfd =3D socket(AF_UNIX, SOCK_STREAM, 0); - - /* 'destination' socket */ - server_address.sun_family =3D AF_UNIX; - strcpy(server_address.sun_path, name); - server_len =3D sizeof(server_address); -=20=20 - if (connect(client_sockfd,=20 - (struct sockaddr *)&server_address, server_len) < 0) { - perror("connect client socket"); - D_ERR("Couldn't open socket, sdp will not be used\n"); - return -1; - } - - printf("Socket connected to %s\n", server_address.sun_path); - return client_sockfd; -} -#endif /* !__KERNEL__ */ - void=20 sdp_init(s32 srv) { @@ -376,15 +333,18 @@ sdp_init(s32 srv) sdp_con_list[i].l2cap =3D NULL; sdp_con_list[i].state =3D SDP_DISCONNECTED; sdp_con_list[i].initiator =3D 0; - sdp_con_list[i].line =3D 0; +#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0) + init_waitqueue_head(&sdp_con_list[i].waitqueue); +#else + sdp_con_list[i].waitqueue =3D NULL; +#endif + sdp_con_list[i].status =3D 0; + sdp_con_list[i].request =3D NULL; } =20 if (srv) { DSYS("Init SDP as server\n"); role =3D 1; -#ifndef __KERNEL__ - sdp_sock =3D open_socket(SDP_SRV_SOCK); -#endif } else { DSYS("Init SDP as client\n"); role =3D 0; @@ -467,9 +427,10 @@ sdp_remove_proc_file(void) #endif /* __KERNEL__ */ =20 s32=20 -sdp_connect_req(u8* bd_addr, u8 line, bt_pincode *pincode) +sdp_connect_req(u8* bd_addr, bt_pincode *pincode) { sdp_con *sdp; + s32 retval; =20=20=20 sdp =3D get_free_sdp_con(); if (!sdp) { @@ -479,20 +440,51 @@ sdp_connect_req(u8* bd_addr, u8 line, bt } sdp->state =3D SDP_CONNECTING; sdp->initiator =3D TRUE; - sdp->line =3D line; =20=09 - if (l2ca_connect_req(bd_addr, SDP_LAYER, pincode)) { + if ((retval =3D l2ca_connect_req(bd_addr, SDP_LAYER, pincode)) < 0) { D_ERR(__FUNCTION__ " ERROR l2ca_connect_req failed\n"); - return -1; + return retval; } return sdp->id; } =20 +/* Wrapper for sdp_connect_req to wait here until the connection is comple= te */ +s32 +sdp_connect(u8* bd_addr, bt_pincode *pincode) +{ + s32 retval; + s32 i; + sdp_con *con; +=09 + i =3D sdp_connect_req(bd_addr, pincode); +=09 + if (i < 0) { + return i; + } + + con =3D &sdp_con_list[i]; + + /* Wait for connection complete */ + if(con->state =3D=3D SDP_CONNECTING) + { + start_wq_timer(&sdp_con_list[i].timer, 10 * HZ, &sdp_con_list[i].waitque= ue); + interruptible_sleep_on(&con->waitqueue); + release_wq_timer(&con->timer); + } + + /* Check status and return correct value */ + if(sdp_con_list[i].status) + { + return -sdp_con_list[i].status; + } else { + return i; + } +}=09 + /* only client receives connect pnd */ void sdp_connect_pnd(l2cap_con *l2cap, s32 status) { printk("sdp_connect_pnd : reason %d\n", status);=09 - //PRINTPSM(l2cap); } =20 void=20 @@ -525,16 +517,6 @@ sdp_connect_cfm(l2cap_con *l2cap, s32 st s32 i =3D 0; s32 stop =3D 0; =20=20=20 - if (status) { - DSYS(__FUNCTION__ " Connection failed\n"); - //bt_connect_cfm(CREATE_SDP_ID(sdp->line, 0), -1); - return; - } - - if(l2cap->current_state !=3D OPEN) { - DSYS(__FUNCTION__ ": Configuration not done yet\n"); - } - /* Find the connecting sdp_con */ while ((i < MAX_NBR_SDP) && (!stop)) { if ((sdp_con_list[i].state =3D=3D SDP_CONNECTING) &&=20 @@ -545,11 +527,25 @@ sdp_connect_cfm(l2cap_con *l2cap, s32 st i++; } =20=20=20 - if (sdp !=3D NULL) { - /*-----------------------------------------------------------*/ - /* Set the connection in bt. */ - /*-----------------------------------------------------------*/ - bt_register_sdp(sdp->line, sdp->id); + if(!sdp) { + D_ERR(__FUNCTION__ " couldn't find the correct sdp_connection\n"); + return; + } +=09 + + sdp->status =3D status; + if (status) { + DSYS(__FUNCTION__ " Connection failed\n"); + sdp->status =3D status; + wake_up_interruptible(&sdp->waitqueue); + release_wq_timer(&sdp->timer); + return; + } + + if(l2cap->current_state !=3D OPEN) { + DSYS(__FUNCTION__ ": Configuration not done yet\n"); + } +=20=20 =20 if (!l2ca_local_conf_done(l2cap) && !l2cap->conf_req_sent) { /* still haven't sent config request yet */ @@ -559,11 +555,8 @@ sdp_connect_cfm(l2cap_con *l2cap, s32 st /* store connection */ sdp->l2cap =3D l2cap; l2cap->upper_con =3D (void*) sdp; - } else=20 - DSYS(__FUNCTION__ " already sent back a pos response\n"); } else { - D_ERR(__FUNCTION__ " couldn't find the correct sdp_connection\n"); - bt_connect_cfm(CREATE_SDP_ID(sdp->line, 0), -1); + DSYS(__FUNCTION__ " already sent back a pos response\n"); } } =20 @@ -589,94 +582,57 @@ sdp_config_ind(l2cap_con* l2cap) D_REC("already ready with config req\n"); } =20 -#ifdef __KERNEL__ -/*------------------------------------------------------------------------= ---*/ -/* sdpStartRequest() - This function is used to initiate a SDP request. = */ -/*------------------------------------------------------------------------= ---*/ -int sdpStartRequest(u8 sdpIndex, u8 sdpCommand, u8 *pduData, u16 pduLength) +/* Sends a request over the connection associated to the */ +s32=20 +sdp_query(bt_sdp_request *request) { - s32 returnValue =3D -1; - - /*-------------------------------------------------------------------*/ - /* Check the connection state. State must be SDP_CONNECTED. */ - /*-------------------------------------------------------------------*/ - if (sdp_con_list[sdpIndex].state =3D=3D SDP_CONNECTED) { - /*-----------------------------------------------------------*/ - /* Initiate a query here. Send a SDP_SERVICESEARCH_REQ. */ - /*-----------------------------------------------------------*/ - sdp_tx_buf *sdp_buf; - bt_tx_buf *tx_buf; - u32 sdp_frame_len; - u16 trans_id; + sdp_con *con =3D NULL; + BD_ADDR bd; + int i; + l2cap_con *l2cap; =20=20=20=20 - /*-----------------------------------------------------------*/ - /* What are we sending in the PDU? */ - /* */ - /* A BB CC D E F GG */ - /* A =3D SDP_SERVICESEARCH_REQ */ - /* BB =3D Transaction ID */ - /* CC =3D PDU Length (not including header). */ - /* D =3D Data Element Sequence Header (0x35) */ - /* E =3D Number of bytes (which in this case is 3) */ - /* F =3D UUID16_HDR (1 bytes) (0x19). */ - /* GG =3D PublicBrowseGroup (0x1002). */ - /* Total number of bytes 10. */ - /*-----------------------------------------------------------*/ + /* BD stored as little endian, convert */ + for(i =3D 0 ; i < 6 ; i++) { + bd[i] =3D request->bd[5 - i]; + } =20 - /*-----------------------------------------------------------*/ - /* Generate random tranaction ID. */ - /*-----------------------------------------------------------*/ - get_random_bytes(&trans_id, 2 /* bytes */); + /* Find correct connection in list */ + for (i =3D 0; i < MAX_NBR_SDP; i++) { + if((sdp_con_list[i].state =3D=3D SDP_CONNECTED) && sdp_con_list[i].l2cap= ) { + l2cap =3D sdp_con_list[i].l2cap; + if(memcmp(l2cap->remote_bd, bd, 6) =3D=3D 0) { + break; + } + } + } =20=20=20=20 - /*-----------------------------------------------------------*/ - /* Allocate the buffer. */ - /*-----------------------------------------------------------*/ - sdp_frame_len =3D SDP_HDR_SIZE + pduLength; - tx_buf =3D subscribe_bt_buf(sizeof(sdp_tx_buf) + sdp_frame_len); + if(i =3D=3D MAX_NBR_SDP) { + return -1; + } =20 - if (!tx_buf) { - D_ERR(__FUNCTION__ " failed to get tx buffer\n"); - } else { - /*---------------------------------------------------*/ - /* Set the current length of the transmission buffer */ - /*---------------------------------------------------*/ - tx_buf->cur_len =3D sdp_frame_len; + con =3D &sdp_con_list[i]; + con->request =3D request; + con->request_status =3D SDP_REQUEST_SENT; =20 - /*---------------------------------------------------*/ - /* Poke the SDP header. */ - /* Notice that the "poking" is in little endian */ - /*---------------------------------------------------*/ - sdp_buf =3D (sdp_tx_buf*) (tx_buf->data); - sdp_buf->frame[0] =3D sdpCommand; - sdp_buf->frame[1] =3D (trans_id >> 8) & 0xff; - sdp_buf->frame[2] =3D trans_id & 0xff; - sdp_buf->frame[3] =3D (pduLength >> 8) & 0xff; - sdp_buf->frame[4] =3D pduLength & 0xff; + if(sdp_send_data(con, request->data, request->len) < 0) { + con->request =3D NULL; + con->request_status =3D SDP_REQUEST_IDLE; + return -1; + } =20 - /*---------------------------------------------------*/ - /* Copy the pduData. */ - /*---------------------------------------------------*/ - memcpy(&sdp_buf->frame[5], pduData, pduLength); + /* Wait for the response */ + start_wq_timer(&con->timer, 10 * HZ, &con->waitqueue); + interruptible_sleep_on(&con->waitqueue); + release_wq_timer(&con->timer); =20 - /*---------------------------------------------------*/ - /* Send the l2cap data transfer. */ - /*---------------------------------------------------*/ - l2cap_send_data(tx_buf, sdp_con_list[sdpIndex].l2cap); - DSYS(__FUNCTION__ " Client finished sending data.\n"); - returnValue =3D 0;=20 + if(con->request_status !=3D SDP_REQUEST_RESPONSE) { + return -1; } - } else { - /*-----------------------------------------------------------*/ - /* No active SDP connection here!. This is an error. */ - /*-----------------------------------------------------------*/ - D_ERR(__FUNCTION__ " No active connection on SDP ID =3D %d\n", sdpIndex); + con->request_status =3D SDP_REQUEST_IDLE; + con->request =3D NULL; + return 0; } =20 - return returnValue; -} /* End of sdpStartRequest() */ - -#endif /* __KERNEL__ */ - void=20 sdp_config_cfm(l2cap_con *l2cap, s32 status) { @@ -705,14 +661,12 @@ sdp_config_cfm(l2cap_con *l2cap, s32 sta /* initator, this is a SDP client connection request. If not, then */ /* we're the server and must process requests. */ /*-------------------------------------------------------------------*/ + if (sdp->initiator) { - /*-----------------------------------------------------------*/ - /* We are the initator. Therefore a SDP client on on this */ - /* machine initiated the connection. Inform the "ioctl" or */ - /* bluetooth layer. */ - /*-----------------------------------------------------------*/ - bt_connect_cfm(CREATE_SDP_ID(sdp->line, 0), - ((sdp_con *)l2cap->upper_con)->id); + DSYS(__FUNCTION__ ", we initiated the connection\n"); + /* Wakeup anyone waiting */ + wake_up_interruptible(&sdp->waitqueue); + release_wq_timer(&sdp->timer); } else { DSYS(__FUNCTION__ ", we are the server\n"); } @@ -739,15 +693,10 @@ sdp_disconnect_req(u32 sdp_id) D_ERR(__FUNCTION__ ", An error with error code %d occured during discon= netion of sdp channel %d\n", err, sdp_id); sdp_con_list[sdp_id].state =3D SDP_DISCONNECTED; sdp_con_list[sdp_id].l2cap =3D NULL;=20=20 + sdp_con_list[sdp_id].request =3D NULL; }=20 -#if 0 - /* sdp_disconnect_cfm wakes up this queue, but by the time we - get here it already did, so we sleep forever! - */ - else { - interruptible_sleep_on(&sdp_disc_wq); - } -#endif + } else { + D_ERR("%s: Didn't find connection\n", __FUNCTION__); } } =20 @@ -760,6 +709,10 @@ sdp_disconnect_ind(l2cap_con *l2cap)=20 if ((sdp =3D (sdp_con*) l2cap->upper_con)) { sdp->state =3D SDP_DISCONNECTED; sdp->l2cap =3D NULL; + sdp->status =3D 0; + sdp->request =3D NULL; + wake_up_interruptible(&sdp->waitqueue); + release_wq_timer(&sdp->timer); } =20 l2ca_disconnect_rsp(l2cap); @@ -769,17 +722,14 @@ void=20 sdp_disconnect_cfm(l2cap_con *l2cap) { sdp_con *sdp; - u8 line; =20 D_MISC(__FUNCTION__ ", remote cid : %d\n", l2cap->remote_cid); =20 sdp =3D (sdp_con*) l2cap->upper_con; - line =3D sdp->line; sdp->state =3D SDP_DISCONNECTED; sdp->l2cap =3D NULL;=20=20 - - bt_unregister_sdp(line); - wake_up_interruptible(&sdp_disc_wq); + sdp->status =3D 0; + sdp->request =3D NULL; } =20 void=20 @@ -787,6 +737,7 @@ sdp_receive_data(l2cap_con *l2cap, u8* d { sdp_con *sdp; data_struct *db_hdl; + bt_sdp_request *request; =20 D_REC(__FUNCTION__ "\n"); =20 @@ -798,28 +749,25 @@ sdp_receive_data(l2cap_con *l2cap, u8* d PRINTPKT(__FUNCTION__, data, len);=20=20 sdp =3D (sdp_con*) l2cap->upper_con; =20 -#ifndef __KERNEL__ - if (sdp_sock < 0) { - send_error_rsp(sdp, le16_to_cpu(get_unaligned((u16 *)&data[1])), 6); - } -#endif - /*--------------------------------------------------------*/ /* If __KERNEL__ mode, we must bounce the received data */ /* up if this stack initiated the request. */ /*--------------------------------------------------------*/ -#if __KERNEL__ if (sdp->initiator) { u8 *dataPointer =3D NULL; - - /*------------------------------------------------------*/ - /* Grab a copy of the data to send up. */ - /*------------------------------------------------------*/ - dataPointer =3D (u8 *) kmalloc(len, GFP_ATOMIC); - memcpy(dataPointer, data, len); - bt_send_sdp_data_received(sdp->line, dataPointer, len); + if(!(request =3D sdp->request)) { + return; + } + sdp->request_status =3D SDP_REQUEST_RESPONSE; + if(len > (request->allocated)) { + D_ERR("%s: Received more data than allocated\n", __FUNCTION__); + } + memcpy(request->data, data, MIN(request->allocated, len)); + request->len =3D len; + /* Wakeup anyone waiting */ + wake_up_interruptible(&sdp->waitqueue); + release_wq_timer(&sdp->timer); } else -#endif { db_hdl =3D (data_struct*)database_query.query; =20 @@ -829,54 +777,11 @@ sdp_receive_data(l2cap_con *l2cap, u8* d memcpy(db_hdl->data, data, len); =20 database_query.count =3D sizeof(data_struct) + len; - -#ifdef __KERNEL__ D_PROC("wake_up process %i (%s) awakening\n", current->pid, current->com= m); wake_up_interruptible(&database_wq); D_PROC("wake_up process %i (%s) woke up\n", current->pid, current->comm); -#else - sdp_doquery(sdp_sock, database_query.query, database_query.count); -#endif - } -} - -#ifndef __KERNEL__=20 -s32 -send_error_rsp(sdp_con *sdp, u16 trans_id, u16 err_code) -{ - sdp_tx_buf *sdp_buf; - bt_tx_buf *tx_buf; - u32 sdp_frame_len; - u32 pdu_len; - - /* Since we do not send any error information the pdu length is just - the size of the error code length, which is two bytes */ - pdu_len =3D 2; - sdp_frame_len =3D SDP_HDR_SIZE + pdu_len; - - tx_buf =3D subscribe_bt_buf(sizeof(sdp_tx_buf) + sdp_frame_len); - - if (!tx_buf) { - D_ERR(__FUNCTION__ " failed to get tx buffer\n"); - return -1; } - - tx_buf->cur_len =3D sdp_frame_len; -=09 - sdp_buf =3D (sdp_tx_buf*) (tx_buf->data); - - sdp_buf->frame[0] =3D SDP_ERROR_RSP; - sdp_buf->frame[1] =3D (trans_id >> 8) & 0xff; - sdp_buf->frame[2] =3D trans_id & 0xff; - sdp_buf->frame[3] =3D (pdu_len >> 8) & 0xff; - sdp_buf->frame[4] =3D pdu_len & 0xff; - - sdp_buf->frame[5] =3D (err_code >> 8) & 0xff; - sdp_buf->frame[6] =3D err_code & 0xff; -=09 - return l2cap_send_data(tx_buf, sdp->l2cap); } -#endif =20 #ifdef __KERNEL__ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) @@ -986,35 +891,6 @@ s32 sdp_database_write(struct inode *ino db_write_recv =3D 0; =20 return read1 + read2; -} -#else /* __KERNEL__ */ - -s32 sdp_doquery(s32 fd, u8 *request, s32 len) -{ - s32 n; - u8 tmpbuf[512]; - data_struct *db_hdl; - s32 recv; - - D_XMIT("sdp_doquery : sending request %d bytes\n", len); - write(fd, request, len); -=09 - if ((n =3D read(fd, tmpbuf, 512)) < 0) - return n; - - D_REC(__FUNCTION__ ", Received %d bytes\n", n); -=09 - db_hdl =3D (data_struct*) tmpbuf; -=09 - /* what if not all is written once */ - - for (recv =3D n; recv < sizeof *db_hdl + db_hdl->len; recv +=3D n) - if ((n =3D read(fd, tmpbuf + recv, 512 - recv)) < 0) - return n; - - sdp_send_data(&sdp_con_list[db_hdl->sdp_con_id], db_hdl->data, db_hdl->le= n);=20 -=09 - return recv; } #endif =20 |
From: Anders J. <and...@us...> - 2003-12-02 11:58:28
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- hci.c 1.214 1.215=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Changed some debug printing. The diff of the modified file(s): --- hci.c 2003/11/18 18:03:33 1.214 +++ hci.c 2003/12/02 11:58:27 1.215 @@ -1414,7 +1414,7 @@ process_return_param(u8 *buf) break; =20 case READ_TRANSMIT_POWER_LEVEL: - printk(__FUNCTION__ ": READ_TRANSMIT_POWER_LEVEL\n"); + D_CMD(__FUNCTION__ ": READ_TRANSMIT_POWER_LEVEL\n"); if (r_val[0]) { D_ERR(__FUNCTION__ ": READ_TRANSMIT_POWER_LEVEL: %s\n", get_err_msg(r_val[0])); @@ -1459,7 +1459,6 @@ process_return_param(u8 *buf) } else { result_param =3D r_val[1]; } - printk("READ_SCAN_ENABLE %d\n", result_param); break; =20 case WRITE_SCAN_ENABLE: |
From: Anders J. <and...@us...> - 2003-11-19 11:49:48
|
The following file was modified in apps/bluetooth/utils/btconfig: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- btconfig.c 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Changed read_settings so only relevant information is shown. The diff of the modified file(s): --- btconfig.c 2003/11/18 18:41:42 1.3 +++ btconfig.c 2003/11/19 11:49:46 1.4 @@ -89,7 +89,7 @@ static void show_usage(void); static int parse_file(char *filename); static int parse_line(char* line, char** field, char** value); static int configure_field(const char* field, const char* value); -static void read_settings(int bt_cfd); +static int read_settings(int bt_cfd); =20 /****************** GLOBAL VARIABLE DECLARATION SECTION ******************= ***/ =20 @@ -172,7 +172,7 @@ main(int argc, char **argv) int var_dontusefile =3D 0; int var_readsettings =3D 0; int var_ledenabled =3D -1; -=20=20 + int retval =3D 0; char *opt_name =3D NULL; char *opt_config_file =3D CONF_FILE; =20 @@ -316,11 +316,14 @@ main(int argc, char **argv) bt_write_ledenable(bt_cfd, (unsigned char)var_ledenabled); } } else { - read_settings(bt_cfd); + if(read_settings(bt_cfd) < 0) + { + retval =3D 1; + }=20=20 } =20=20=20 close(bt_cfd); - exit(0); + exit(retval); } =20 /*************************************************************************= */ @@ -552,10 +555,47 @@ configure_field(const char* field, const return TRUE; } /* configure_field */ =20 -void +int read_settings(int bt_cfd) { - system("cat /proc/bt_status"); + FILE *procfile; + unsigned char buf[100]; + int foundsection =3D 0; + int i; +=20=20 + if(!(procfile =3D fopen("/proc/bt_status", "r"))) + { + fprintf(stderr, "Error reading status file: %s\n", strerror(errno)); + return -1; + } + + while(fgets(buf, 100, procfile)) + { + /* Output only first section */ + if(buf[0] =3D=3D '[') + { + if(foundsection)=20 + { + break; + } + foundsection =3D 1; + continue; + } + + /* Strip newline */ + if( ((buf[0] > 'a') && (buf[0] < 'z')) || + ((buf[0] > 'A') && (buf[0] < 'Z')))=20 + { + i =3D strlen(buf); + if(buf[i - 1] =3D=3D '\n') + { + buf[i - 1] =3D 0; + } + printf("%s\n", buf); + } + }=20 + fclose(procfile); + return 0; }=20=20 =20 /****************** END OF FILE btconfig.c *******************************= ***/ |
From: Anders J. <and...@us...> - 2003-11-18 18:41:43
|
The following file was modified in apps/bluetooth/utils/btconfig: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- btconfig.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added option to read settings, enable/disable led and to disable fetching values from the configuration file. The diff of the modified file(s): --- btconfig.c 2003/11/12 10:25:35 1.2 +++ btconfig.c 2003/11/18 18:41:42 1.3 @@ -89,6 +89,7 @@ static void show_usage(void); static int parse_file(char *filename); static int parse_line(char* line, char** field, char** value); static int configure_field(const char* field, const char* value); +static void read_settings(int bt_cfd); =20 /****************** GLOBAL VARIABLE DECLARATION SECTION ******************= ***/ =20 @@ -123,6 +124,9 @@ static struct option long_options[] =3D { "piconet-mode", 1, NULL, 'p' }, /* set if we disallow clients whic= h doesn't support the M/S switch */ { "pincode-type", 1, NULL, 't' }, /* sets pincode type */ + { "dontusefile", 0, NULL, 'd' }, /* don't read any settings from fi= le */ + { "readsettings", 0, NULL, 'r' }, /* show current settings */ + { "ledenabled", 1, NULL, 'l' }, { 0, 0, 0, 0 } }; =20 @@ -134,6 +138,8 @@ show_usage(void) printf("Usage: btconfig [OPTIONS]\n"); printf("Options:\n"); printf(" -f, --file=3DNAME Use configuration file NAME\n"); + printf(" -d, --dontusefile Do not use settings in the configurat= ion file\n"); + printf(" -r, --readsettings Read current settings in the stack\n"= ); printf(" -h, --help Show usage\n"); printf(" -m, --force-msswitch=3DNUM Force m/s switch when acting as a s= erver\n"); printf(" Values are 0 for false and 1 for true= \n"); @@ -151,6 +157,7 @@ show_usage(void) printf(" Types:\n"); printf(" 0: Variable pin\n"); printf(" 1: Fixed pin\n"); + printf(" -l, --ledenabled=3DNUM Enable or disable the onboard led (= CRIS)\n"); } =20 int @@ -162,14 +169,16 @@ main(int argc, char **argv) int opt_max_connections =3D -1; int opt_dont_allow_slave =3D -1; int opt_pincode_type =3D -1; -=20=20 + int var_dontusefile =3D 0; + int var_readsettings =3D 0; + int var_ledenabled =3D -1; =20=20=20 char *opt_name =3D NULL; char *opt_config_file =3D CONF_FILE; =20 /* Parse command line options */ =20 - while ((opt =3D getopt_long(argc, argv, "f:hm:n:w:c:p:t:", + while ((opt =3D getopt_long(argc, argv, "f:hm:n:w:c:p:t:drl:", long_options, &option_index)) !=3D -1) { switch (opt) @@ -212,15 +221,42 @@ main(int argc, char **argv) opt_pincode_type =3D atoi(optarg); break; =20=20=20=20=20=20=20 + case 'd': + var_dontusefile =3D 1; + break; +=20=20=20=20=20=20 + case 'r': + var_readsettings =3D 1; + break; + + case 'l': + var_ledenabled =3D atoi(optarg); + break; +=20=20=20=20=20=20 default: break; } } =20 + if(!var_dontusefile) + { parse_file(opt_config_file); + } =20 - /* Command line arguments override the configuration file */ + /* Open BT ctrl device */=20=20 + if ((bt_cfd =3D bt_openctrl()) < 0) + { + perror("Could not open BT control device"); + exit(1); + } =20 + /* Wait until stack is initiated */ + while (!bt_isinitiated(bt_cfd)) + sleep(1); + + /* Command line arguments override the configuration file */ + if(!var_readsettings) + { if (opt_name) { strncpy(bt_name, opt_name, MAX_BTNAME_LEN); @@ -248,19 +284,9 @@ main(int argc, char **argv) var_max_connections >=3D 0 || var_max_power !=3D SHRT_MAX || var_dont_allow_slave >=3D 0 || - var_pincode_type >=3D 0) - { - /* Open BT ctrl device */=20=20 - if ((bt_cfd =3D bt_openctrl()) < 0) + var_pincode_type >=3D 0 || + var_ledenabled >=3D 0) { - perror("Could not open BT control device"); - exit(1); - } - - /* Wait until stack is initiated */ - while (!bt_isinitiated(bt_cfd)) - sleep(1); - /* Configure BT local name */ if (var_set_local_name) bt_set_local_name(bt_cfd, bt_name); @@ -286,9 +312,14 @@ main(int argc, char **argv) if (var_pincode_type >=3D 0) bt_write_pin_type(bt_cfd, var_pincode_type); =20=20=20=20=20 - close(bt_cfd); + if (var_ledenabled >=3D 0) + bt_write_ledenable(bt_cfd, (unsigned char)var_ledenabled); + } + } else { + read_settings(bt_cfd); } =20 + close(bt_cfd); exit(0); } =20 @@ -520,5 +551,11 @@ configure_field(const char* field, const =20 return TRUE; } /* configure_field */ + +void +read_settings(int bt_cfd) +{ + system("cat /proc/bt_status"); +}=20=20 =20 /****************** END OF FILE btconfig.c *******************************= ***/ |
From: Anders J. <and...@us...> - 2003-11-18 18:12:52
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- bt_proc.c 1.27 1.28=20=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added scanmode. The diff of the modified file(s): --- bt_proc.c 2003/11/18 18:03:33 1.27 +++ bt_proc.c 2003/11/18 18:12:52 1.28 @@ -294,6 +294,8 @@ int bt_read_status(char *buf, int len) len +=3D sprintf(buf + len, "led_enable : %s\n", ledenable ? "TRUE" : "FALSE"); #endif + len +=3D sprintf(buf + len, "scan_mode : %d\n", + hci_read_scan_enable()); len +=3D sprintf(buf + len, "\n[REMOTE INFO]\n"); len +=3D hci_sprint_remote_info(buf + len); =20 |
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...> - 2003-11-18 18:03:35
|
The following file was modified in linux/include/linux/bluetooth: Name Old version New version Tag Comment ---- ----------- ----------- --- ------- hci.h 1.84 1.85=20=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): --- hci.h 2003/11/12 10:15:44 1.84 +++ hci.h 2003/11/18 18:03:31 1.85 @@ -107,6 +107,7 @@ void hci_receive_data(u8* data, u32 coun s32 hci_send_data(bt_tx_buf *tx_buf); =20 s32 hci_set_max_connections(s32 max_connections); +s32 hci_read_max_connections(void); =20 #ifdef CONFIG_BLUETOOTH_SUPPORT_BCSP void hci_receive_event(u8 *data, s32 count); @@ -211,6 +212,7 @@ s32 hci_test_connect_req(u8 *bd); s32 hci_send_raw_data(u8 *data, u8 len); =20 void hci_force_msswitch(u8 enable); +s32 hci_read_msswitch(void); =20 /* Vendor specific */ s32 hci_set_bd_addr(u8 bd[6]); |