From: Mattias ?g. <mat...@us...> - 2001-02-28 13:29:48
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- l2cap.c 1.83 1.84=20=20=20=20=20=20=20=20=20=20=20=20 l2cap_con.c 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * fixed incorrect flow structure, used type/len in option data * minor changes The diff of the modified file(s): --- l2cap.c 2001/02/27 15:00:16 1.83 +++ l2cap.c 2001/02/28 13:30:59 1.84 @@ -211,16 +211,16 @@ protocol_layer* get_upper(u32 psm); void remove_all_upper(void); =20 +#ifdef __KERNEL__ +static struct wait_queue *l2cap_disconnect_wq =3D NULL; +#endif + #ifdef L2CAP_USETIMERS #define MAX_NO_RTX 0 #define RTX_TIMEOUT 5 /* sec */ #define ERTX_TIMEOUT 60 /* sec */ =20 #ifdef __KERNEL__ -static struct wait_queue *l2cap_disconnect_wq =3D NULL; -#endif - -#ifdef __KERNEL__ void start_rtx(l2cap_con *con, unsigned short timeout); void disable_rtx(l2cap_con *con); void start_ertx(l2cap_con *con, unsigned short timeout); @@ -2789,6 +2789,7 @@ =20=20=20 /* FIXME -- send l2ca_timeoutind() */ =20 +#ifdef L2CAP_USETIMERS if (MAX_NO_RTX =3D=3D 0) { /* no retransmissions, shutdown connection */ @@ -2812,6 +2813,7 @@ delete_con(con); return; } +#endif =20 /* now resend command */ switch(con->last_cmd.type) { @@ -3103,7 +3105,6 @@ =20 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -= - */ =20 - void=20 print_flow(flow *f) { @@ -3115,8 +3116,8 @@ } else { =20=09=09 printk("flow:\n"); - printk("type:%d flags:%d service:%d token_rate:%d\n", - f->type, f->flags, f->service, (int) f->token_rate); + printk("flags:%d service:%d token_rate:%d\n", + f->flags, f->service, (int) f->token_rate); printk("bucket_size:%d bytes peak:%d bps latency:%d ms delay:%d ms\n", (int)f->bucket_size, (int)f->peak, (int)f->latency,=20 (int)f->delay); --- l2cap_con.c 2001/02/15 16:27:33 1.3 +++ l2cap_con.c 2001/02/28 13:31:00 1.4 @@ -559,8 +559,6 @@ init_flow(flow *f) { D_MISC("init_flow\n"); - f->type =3D 0x3; - f->len =3D 22; f->flags =3D 0; f->service =3D 0x01; f->token_rate =3D 0x00000000; /* No token rate specified, default */ |
From: Marcus A. S. <mar...@us...> - 2001-03-01 00:29:52
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bluetooth.c 1.129 1.130=20=20=20=20=20=20=20=20=20=20=20 sdp.c 1.61 1.62=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added SDP client support. |
From: Gordon M. <gm...@us...> - 2001-03-02 21:09:22
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- Config.in 1.1 Added Makefile 1.13 1.14=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: --Tweaked the Makefile so that I can drop this directory into a 2.4 kernel = source tree. Tested standalone to make sure I didn't break that. --Added an initial Config.in for kernel configuration. The diff of the modified file(s): --- Makefile 2001/03/02 10:50:44 1.13 +++ Makefile 2001/03/02 21:10:41 1.14 @@ -2,18 +2,27 @@ # Makefile for the Bluetooth device driver. # =20 -INCLUDEDIR =3D /usr/include - -O_TARGET :=3D bt.o -O_OBJS =3D bluetooth.o btdebug.o btmem.o hci.o l2cap.o rfcomm.o sdp.o t= cs.o bt_proc.o hci_vendor.o l2cap_con.o sec_client.o l2cap_sec.o rfcomm_sec= .o -M_OBJS =3D $(O_TARGET) =20 ifeq ($(TOPDIR)/Rules.make,$(wildcard $(TOPDIR)/Rules.make)) =20 +#--------------------------------------------------------------------- +# Kernel makefile rules (2.4.x) +#--------------------------------------------------------------------- +O_TARGET :=3D bt.o +obj-$(CONFIG_BLUETOOTH) +=3D $(patsubst %.c, %.o, $(wildcard *.c)) include $(TOPDIR)/Rules.make =20 else =20 +#--------------------------------------------------------------------- +# Standalone makefile rules +#--------------------------------------------------------------------- + +O_TARGET :=3D bt.o +O_OBJS =3D bluetooth.o btdebug.o btmem.o hci.o l2cap.o rfcomm.o sdp.o t= cs.o bt_proc.o hci_vendor.o l2cap_con.o sec_client.o l2cap_sec.o rfcomm_sec= .o +M_OBJS =3D $(O_TARGET) + +INCLUDEDIR =3D /usr/include MODFLAGS =3D -DMODVERSIONS -include $(INCLUDEDIR)/linux/modversions.h CFLAGS =3D -D__KERNEL__ -DMODULE -I../../../include -I$(INCLUDEDIR) -Wal= l -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strength-reduce $(MODFL= AGS) =20 |
From: Peter K. <pk...@us...> - 2001-03-05 15:10:45
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- Config.in 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20 hci_vendor.c 1.13 1.14=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Removed CONFIG_BLUETOOTH_HCI_USB. The diff of the modified file(s): --- Config.in 2001/03/04 17:54:54 1.2 +++ Config.in 2001/03/05 15:12:21 1.3 @@ -10,7 +10,6 @@ =20 bool 'Bluetooth proc entry' CONFIG_BLUETOOTH_PROC bool 'Input buffering' CONFIG_BLUETOOTH_USEINBUFFER - bool 'HCI USB' CONFIG_BLUETOOTH_HCI_USB bool 'Allow connectionless L2CAP' CONFIG_BLUETOOTH_L2CAP_CONNECTIONLESS bool 'Use L2CAP timers' CONFIG_BLUETOOTH_L2CAP_USETIMERS =20 --- hci_vendor.c 2001/03/04 17:54:54 1.13 +++ hci_vendor.c 2001/03/05 15:12:21 1.14 @@ -53,9 +53,7 @@ #include <linux/bluetooth/bluetooth.h> #include <linux/bluetooth/btmem.h> #include <linux/delay.h> -#ifdef CONFIG_BLUETOOTH_HCI_USB #include <linux/interrupt.h> -#endif #else /* user mode */ #include <stdlib.h> #include <string.h> |
From: Peter K. <pk...@us...> - 2001-03-05 16:40:09
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bluetooth.c 1.136 1.137=20=20=20=20=20=20=20=20=20=20=20 l2cap.c 1.90 1.91=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Code clean-up. The diff of the modified file(s): --- bluetooth.c 2001/03/05 15:52:52 1.136 +++ bluetooth.c 2001/03/05 16:41:44 1.137 @@ -1033,8 +1033,8 @@ /*************************************************************************= ****/ /* LINUX 2.0.X SPECIFIC CODE = */ /*************************************************************************= ****/ -static s32 bt_tty_read (struct tty_struct *tty, struct file *file, __u8 * = buf, - u32 nr) +static s32 bt_tty_read(struct tty_struct *tty, struct file *file, + __u8 * buf, u32 nr) #else /*************************************************************************= ****/ /* LINUX 2.2.X SPECIFIC CODE = */ @@ -1894,7 +1894,7 @@ * Register the tty discipline */ =20=09 - (void) memset (&bt_ldisc, 0, sizeof (bt_ldisc)); + memset(&bt_ldisc, 0, sizeof(bt_ldisc)); bt_ldisc.magic =3D TTY_LDISC_MAGIC; bt_ldisc.open =3D bt_tty_open; bt_ldisc.close =3D bt_tty_close; @@ -2483,9 +2483,7 @@ =20=09 if ((SESSIONSTATE(line) =3D=3D BT_ACTIVE) ||=20 (SESSIONSTATE(line) =3D=3D BT_UPPERCONNECTED)) { -=09 if (SESSIONSTATE(line) =3D=3D BT_ACTIVE) { -=09=09=09 SESSIONSTATE(line) =3D BT_LOWERCONNECTED; NBR_ACTIVE--; } --- l2cap.c 2001/03/05 16:39:35 1.90 +++ l2cap.c 2001/03/05 16:41:45 1.91 @@ -159,8 +159,7 @@ =20 const u8* psm2str(u16 psm) { - switch (psm) - { + switch (psm) { case 1: return "SDP"; break; @@ -190,7 +189,6 @@ } } =20 - const u8* cmdrej_reason[] =3D { "Command not understood", "Signalling MTU exceeded", @@ -516,7 +514,6 @@ PRINTPKT("l2cap_receive_data : ", data, len); =20 if (*l2cap_len =3D=3D 0) { -=09=09 /* Start of a new frame received,=20 parse header and set l2cap_len */ =20=09=09 @@ -536,9 +533,7 @@ /* check length */ if (!(pkt->len =3D=3D (len - L2CAP_HDRSIZE))) return; - } else if (len !=3D *l2cap_len) { - /* Not recieved full frame yet or BIG packet */ =20=09=09 if (len > *l2cap_len) { @@ -553,7 +548,6 @@ =20 switch (pkt->cid) { case CIDSIG: -=09 /* Signalling channel */ D_RCV("l2cap_receive_data : Signal data !\n"); =20=09=09 @@ -562,7 +556,6 @@ break; =20=20=20=20=20 case CIDRCVCONLESS: - if (!l2cap->allow_conless) { D_WARN("Connection less data not allowed\n"); return; @@ -579,7 +572,6 @@ break; =20=20=20=20=20 default: -=09=09 /* Data channel */ con =3D get_lcon(pkt->cid); =20=20=20=20=20 @@ -624,7 +616,6 @@ }=20=20 =20 while (pos < len) { -=20=20=20=20 D_RCV(FNC"got packet (%d bytes) with ID : %d\n", cmd->len, cmd->id); =20=20=20=20=20 @@ -662,9 +653,7 @@ (used to detect corrupt packets) */ =20 switch (req->code) { -=09=09 - case SIG_CONREQ: { -=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 + case SIG_CONREQ: /* Request for connection */ conreq =3D (sig_conreq *)req->data; =20=09=09 @@ -718,20 +707,16 @@ #else l2ca_connect_ind(con); #endif -=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 - } break; /* SIG_CONREQ*/ -=09 - case SIG_CONFREQ: { =20 + case SIG_CONFREQ: /* Request for configuration */ confreq =3D (sig_confreq *)req->data; =20=09=09 D_STATE(FNC"config request cid:%d flags: 0x%x\n",=20 confreq->dst_cid, confreq->flags); =20=09=09 - if ((con =3D get_lcon(confreq->dst_cid)) =3D=3D NULL) - { + if ((con =3D get_lcon(confreq->dst_cid)) =3D=3D NULL) { D_ERR("Couldn't find local CID\n"); /* send back response ? */ l2cap_cmdrej(con->hci_hdl, CMDREJ_INVALIDCID, NULL, 0); @@ -739,16 +724,12 @@ } =20=09=09 switch (con->current_state) { - case CLOSED: - /* FIXME - send peer=20 'l2cap_config_rsp_neg' */ -=09=09=20=20 break; =20=09=09=09 - case CONFIG: - { + case CONFIG: { s32 result =3D CONF_SUCCESS; /* Parse remote options and store it in con */ =20 @@ -758,7 +739,6 @@ } =20 if (result !=3D CONF_SUCCESS) { -=09=09=09=09 /* we didn't like the options... */ DSYS("parse_options failed, send neg rsp\n"); =20 @@ -772,11 +752,10 @@ con->sig_id_rcv =3D req->id; =20 l2ca_config_ind(con);=20=20=20=20=20=20=20=20=20=20=20 - } break; + } =20=09=09 - case OPEN: - {=09 + case OPEN: {=09 s32 result =3D CONF_SUCCESS; =20 /*=20 @@ -817,8 +796,8 @@ con->conf_req_ready=3DFALSE; =20=09=09=09 l2ca_config_ind(con); - } break; + } =20=20=20=20=20=20=20=20=20=20=20=20 default: D_ERR("Got config req in invalid state! [%s]\n", @@ -826,11 +805,9 @@ PRINTSTATE(con); break; }=20=20 - }=20=20=20=20=20=20=20=20 break; /* SIG_CONFREQ*/ -=09=09=09 - case SIG_DISCREQ: { =20=20=20=20=20=20=20=20=20=20 + case SIG_DISCREQ: discreq =3D (sig_discreq *)req->data; =20 D_STATE(FNC"disconnection request id %d\n",=20 @@ -857,7 +834,6 @@ PRINTSTATE(con); =20=20=20=20=20=20=20=20=20=20 l2ca_disconnect_ind(con);=20=20=20=20=20=20=20=20=20=20 - }=20 break; /* SIG_DISCREQ */ =20=20=20=20=20=20=20=20 case SIG_ECHOREQ: { @@ -868,8 +844,8 @@ =20 l2cap_echo_rsp(hci_handle, req->id,=20 req->data, req->len- sizeof(sig_echo_pkt)); - } break; + } =20=20=20=20=20=20=20=20 case SIG_INFOREQ: { /* Implementation specific */ @@ -879,33 +855,30 @@ info =3D (sig_info_req*)(req->data); =20=09=09 switch(info->type) { - case INFO_CONNLESS_MTU: DSYS("Request for connectionless MTU\n"); =20=09=09=09 l2cap_info_rsp(hci_handle, req->id, info->type, NULL, 0, 1 /* not supported */); -=09=09=09 break; + default: D_ERR("Unknown info request : type 0x%x\n", info->type); l2cap_cmdrej(con->hci_hdl, CMDREJ_NOTUNDERSTOOD, NULL, 0); break;=09=09 } - }=20=20=20=20 break; + }=20=20=20=20 =20=20=20=20=20=20=20=20 case SIG_RESERVED: D_STATE(FNC"Reserved !\n"); break; =20=20=20=20=20=20=20=20=20 - default: { + default: /* Not a valid command */ DSYS(FNC"Invalid command (code 0x%x)s\n", req->code); - l2cap_cmdrej(con->hci_hdl, CMDREJ_NOTUNDERSTOOD, - NULL, 0); - } + l2cap_cmdrej(con->hci_hdl, CMDREJ_NOTUNDERSTOOD, NULL, 0); break; } #undef FNC @@ -932,8 +905,7 @@ (used to detect corrupt packets) */ =20 switch (rsp->code) { - case SIG_CMDREJECT: { - + case SIG_CMDREJECT: D_STATE(FNC"Command reject - \n"); =20=20=20=20=20=20=20=20=20=20 cmdreject =3D (sig_cmdreject*)rsp->data; @@ -959,11 +931,9 @@ if (opt_len > 0) print_data(FNC"optional data : ",=20 cmdreject->data, rsp->len-2); - } break; =20=20=20=20=20=20=20=20 - case SIG_CONRSP: {=20 - + case SIG_CONRSP: /* client */ D_STATE(FNC"Got connection response\n"); conrsp =3D (sig_conrsp *)rsp->data; @@ -987,7 +957,6 @@ #endif =20 switch (conrsp->result) { - case RES_SUCCESS: ENTERSTATE(con, CONFIG); PRINTSTATE(con); @@ -1028,7 +997,6 @@ } =20=20=20=20=20=20=20=20=20=20 if (failure) { - /* Connection refused=20 FIXME - Disable RTX/ERTX timers @@ -1044,11 +1012,9 @@ ENTERSTATE(con, CLOSED); delete_con(con); } - }=20=20=20=20=20=20 break; =20=20=20=20=20=20=20=20 - case SIG_CONFRSP: { - + case SIG_CONFRSP: D_STATE(FNC"Got configuration response\n"); confrsp =3D (sig_confrsp *)rsp->data; opt_len =3D rsp->len - sizeof(sig_confrsp); @@ -1072,9 +1038,7 @@ } =20 switch (confrsp->result) { -=09 case CONF_SUCCESS: -=20=20=20=20=20=20=20=20=20 #ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS disable_rtx(con); #endif @@ -1085,14 +1049,11 @@ =20=20=20=20=20=20=20=20=20=20=20=20 con->conf_req_ready =3D TRUE; =20 - if (!con->conf_rsp_ready) - { + if (!con->conf_rsp_ready) { /* Upper layers still haven't replied pos */ DSYS("Still haven't replied pos on other sides conf req\n"); return ; - } - else {=09=09=09=09 -=09=09=09=09 + } else {=09=09=09=09 ENTERSTATE(con, OPEN); PRINTSTATE(con); DSYS("l2cap channel (%d,%d) [%s] connected\n",=20 @@ -1122,7 +1083,6 @@ break; } =20=20=20=20=20=20 - /* If we end up here, config failed */ =20 #ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS @@ -1144,12 +1104,9 @@ /* For now we simply disconnect if params failed */ l2ca_config_cfm(con, confrsp->result); l2ca_disconnect_req(con); - - } break; =20=20=20=20=20=20=20=20=20 - case SIG_DISCRSP: { -=09 + case SIG_DISCRSP: D_STATE(FNC"Got disconnect response\n"); discrsp =3D (sig_discrsp *)rsp->data; PRINTPKT(FNC"disconnect response", rsp->data, rsp->len); @@ -1175,8 +1132,6 @@ #endif=09 =20 l2ca_disconnect_cfm(con); - - } break; =20=20=20=20=20=20=20=20 case SIG_ECHORSP: {=20 @@ -1207,23 +1162,18 @@ printk("DO NOT disconnect after doing ping...\n"); //lp_disconnect(hci_handle); } - }=20=20=20=20 break; + }=20=20=20=20 =20=20=20=20=20=20=20=20 - case SIG_INFORSP: {=20=20 + case SIG_INFORSP: info =3D (sig_info_rsp *)(rsp->data); D_STATE(FNC"Got info response : result %d\n", info->result); - }=20=20=20=20 break; -=20=20=20=20=20=20=20 - default: { =20=20=20=20=20=20=20=20=20 + default: /* Not a valid command */ DSYS(FNC"Invalid command 0x%x\n", rsp->code); - l2cap_cmdrej(con->hci_hdl, CMDREJ_NOTUNDERSTOOD, - NULL, 0); - } -=20=20=20=20=20=20=20 + l2cap_cmdrej(con->hci_hdl, CMDREJ_NOTUNDERSTOOD, NULL, 0); break; } =20=09 @@ -1330,7 +1280,6 @@ } =20=09 if (status =3D=3D 0) { -=09=09 /* pos cfm */ con->hci_hdl =3D con_hdl; con->link_up =3D TRUE; @@ -1353,11 +1302,9 @@ } =20=09=09 if (!(con->initiator)) {=09=09 -=09=09=09 D_STATE("we are server\n"); /* now wait for a connection request */ } else { -=09=09=09 D_STATE("we are client\n"); PRINTPKT("lp_connect_cfm : HCI connected to ",=20 bd_addr,6); @@ -1379,7 +1326,6 @@ l2cap_connect_req(con, con->psm); } } else { -=09=09=20 /* neg cfm */ D_STATE("lp_connect_cfm : (neg) %s\n",get_err_msg(status)); con->link_up =3D FALSE; @@ -1416,7 +1362,6 @@ SHOW_LIST(); =20 while (((con =3D get_con_hcihdl(con_hdl)) !=3D NULL)) { - D_STATE("l2cap connection (%d:%d) found on handle %d\n",=20 con->local_cid, con->remote_cid, con_hdl); D_STATE("now closing it...\n"); @@ -1474,7 +1419,6 @@ {=20=20 PRINTPKT("process_frame : ", data, len); =20 -=09 if (len > (con->local_mtu)) { DSYS("l2cap process_frame : len > local_mtu (%d/%d)\n",=20 len- L2CAP_HDRSIZE, con->local_mtu); @@ -1483,7 +1427,6 @@ return; }=20 =20 -=09 get_upper(con->psm)->receive_data(con, data, len); } =20 @@ -1524,7 +1467,6 @@ return -1; } =20=09 - /* bd is big endian, reverse byte order to little endian */ for (i =3D 0;i<6;i++) { rev_bd[5-i] =3D bd[i]; @@ -1559,7 +1501,6 @@ =20 /* if this physical bd link exist for another l2cap con, use that!*/ if (tmpcon) { - D_STATE("l2ca_connect_req : hci handle already exist.\n"); con->hci_hdl =3D tmpcon->hci_hdl; con->link_up =3D 1; @@ -1595,7 +1536,6 @@ /* should already be in CONFIG state */ =20 if (con->current_state =3D=3D CONFIG) {=20=20 - /* local mtu is set in l2cap_config_req */ =20 #ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS @@ -1606,14 +1546,12 @@ flush_timeout, link_to);=20=20 =20 } else if (con->current_state =3D=3D CLOSED) { - l2ca_config_cfm(con, CONF_REJ); return -1; } else if (con->current_state =3D=3D OPEN) { - printk("l2ca_config_req: state OPEN, reconfiguration !\n"); =20 - /* Fixme -=20 + /* FIXME -=20 Is data automatically suspended while reconfiguring ? */ =20 @@ -1632,7 +1570,6 @@ flush_timeout, link_to);=20=20 return -1; } else { - D_ERR("l2cap_config_req : invalid state\n"); PRINTSTATE(con); return -1; @@ -1696,18 +1633,13 @@ result =3D l2cap_connect_rsp(con, response, status); =20=09 if (response =3D=3D RES_SUCCESS) {=20=20 - ENTERSTATE(con, CONFIG); PRINTSTATE(con); - }=20 else if (response =3D=3D RES_PENDING){ -=09=09 /* remain in */ - } else if (response >=3D RES_PSMNEG) { - /* 'l2ca_connect_rsp_neg()' */ ENTERSTATE(con, CLOSED); PRINTSTATE(con); @@ -1789,7 +1721,6 @@ SHOW_CON("disconnecting : ", con); =20 if (con->current_state =3D=3D W4_L2CA_DISCONNECT_RSP) { - /* if we got a link down unexpectedly we cannot send=20 back a response, send nothing... */ if (con->link_up) @@ -1910,7 +1841,6 @@ return hci_send_data(tx); } =20 - /* only specify inparam if it differs from default value */ s32=20 l2cap_config_req(l2cap_con *con, u16 in_mtu, flow *outflow, @@ -2074,7 +2004,6 @@ start_rtx(con, RTX_TIMEOUT); #endif return hci_send_data(tx); - } =20 s32=20 @@ -2123,8 +2052,6 @@ return hci_send_data(tx); } =20 - - s32=20 l2cap_echo_rsp(s32 hci_hdl, s32 id, u8 *opt_data, s32 opt_len) { @@ -2307,8 +2234,7 @@ /****************************/ =20 s32=20 -l2cap_connect_rsp(l2cap_con* con, u16 response,=20 - u16 status) +l2cap_connect_rsp(l2cap_con* con, u16 response, u16 status) { bt_tx_buf *tx;=20 l2cap_tx_buf *l2cap_buf; /* Entire l2cap frame + lower layer hdrs */ @@ -2338,8 +2264,7 @@ =20 if ((rsp->result =3D response) =3D=3D RES_PENDING) rsp->status =3D status; - else=20=20 - { + else { printk("Result not pending, force status =3D no further info\n"); rsp->status =3D STAT_NOINFO; } @@ -2356,11 +2281,10 @@ tx->cur_len =3D L2CAP_HDRSIZE + payload_len; /* Increased when lower layers add header data */ return hci_send_data(tx);=20=20 -}; +} =20=20 s32=20 -l2cap_config_rsp(l2cap_con* con, u32 out_mtu,=20 - flow *in_flow) +l2cap_config_rsp(l2cap_con* con, u32 out_mtu, flow *in_flow) { bt_tx_buf *tx;=20 l2cap_tx_buf *l2cap_buf; /* Entire l2cap frame + lower layer hdrs */ @@ -2371,8 +2295,7 @@ D_XMIT("l2cap_config_rsp : rcid : %d, out_mtu: %d \n",=20 con->remote_cid, out_mtu); #if 0 - if (result !=3D RES_SUCCESS) - { + if (result !=3D RES_SUCCESS) { /* FIXME -- send back negative response */ DSYS("FIXME !!!!!!!!!!!!!!!!!!!!!!!! neg config rsp\n"); } @@ -2413,8 +2336,7 @@ layers add header data */ PRINTPKT("config rsp : ", l2cap_buf, L2CAP_HDRSIZE + payload_len); return hci_send_data(tx); - -}; +} =20 s32=20 l2cap_disconnect_rsp(l2cap_con* con /*FIXME - , u16 status*/) @@ -2469,14 +2391,12 @@ D_XMIT("l2cap_send_data : hdl : %d, rcid : %d, len:%d \n", con->hci_hdl, con->remote_cid, tx->cur_len); =20=09 - if (PARANOIA_CHECKCON(con)) - { + if (PARANOIA_CHECKCON(con)) { D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__); return -1; } =20 - if (tx->cur_len > con->remote_mtu) - { + if (tx->cur_len > con->remote_mtu) { D_ERR("%s tries to send more than remote mtu, ignore\n",=20 psm2str(con->psm)); =20=09=20=20=20=20 @@ -2487,8 +2407,7 @@ } =20 /* Only send on an OPEN channel */ - if (con->current_state!=3DOPEN) - { + if (con->current_state !=3D OPEN) { D_ERR("l2cap_send_data : not in open state\n"); D_ERR("SETTING FLUSHED ON THIS BUFFER !!!\n"); tx->flushed=3D1; @@ -2522,7 +2441,6 @@ D_STATE("l2ca_connect_ind : remote cid : %d psm 0x%x\n",=20 con->remote_cid, con->psm); =20 - if (get_upper(con->psm) =3D=3D &default_protocol) { D_STATE("l2ca_connect_ind : PSM not registered\n"); l2ca_connect_rsp(con, RES_PSMNEG, STAT_NOINFO); @@ -2546,7 +2464,6 @@ get_upper(con->psm)->con_pnd(con, status);=20 } =20 - void=20 l2ca_connect_cfm(l2cap_con *con, s32 result) { @@ -2561,7 +2478,6 @@ get_upper(con->psm)->con_cfm(con, result);=20 } =20 - void=20 l2ca_config_ind(l2cap_con* con) {=20=20 @@ -2570,7 +2486,6 @@ get_upper(con->psm)->conf_ind(con);=20 } =20 - /* according to spec this could be sent to upper layers after=20 receiving a config req but some stacks send their conf req=20 before sending their response we don't send cfm upwards @@ -2627,8 +2542,6 @@ #endif } =20 -=20 - s32 l2ca_ping(BD_ADDR bd) { l2cap_con *con; @@ -2646,13 +2559,11 @@ =20=09 con =3D get_con(rev_bd, ANY_STATE); =20 - if (!con) - { + if (!con) { D_STATE("l2ca_ping : create new baseband link\n"); con =3D create_con(0/* not yet set */,=20 get_cid(), 0/* not yet set */); - if (con =3D=3D NULL) - { + if (con =3D=3D NULL) { D_ERR("l2ca_ping : no connection created"); return -1; } @@ -2664,9 +2575,7 @@ insert_con(con); /* l2cap_echo_req is called in lp_connect_cfm */ return lp_connect_req(con->remote_bd); - } - else - { + } else { /* use existing handle */ D_STATE("l2ca_ping : using existing handle\n"); con->ping_sent=3D1; @@ -2709,13 +2618,11 @@ =20=09 con =3D get_con(rev_bd, ANY_STATE); =20 - if (!con) - { + if (!con) { D_STATE("l2ca_getinfo : create new baseband link\n"); con =3D create_con(0/* not yet set */,=20 get_cid(), 0/* not yet set */); - if (con =3D=3D NULL) - { + if (con =3D=3D NULL) { D_ERR("l2ca_getinfo : no connection created"); return -1; } @@ -2730,9 +2637,7 @@ #endif /* l2cap_echo_req is called in lp_connect_cfm */ return lp_connect_req(con->remote_bd); - } - else - { + } else { /* use existing handle */ D_STATE("l2ca_getinfo : using existing handle\n"); con->inforeq_sent =3D 1; @@ -2782,12 +2687,10 @@ =20=20 // return; =20=20=20 - if (timer_cancelled) - { + if (timer_cancelled) { D_TIM("RTX timer already cancelled\n"); return; } - #endif =20 /* do some paranoia checks */ @@ -2809,15 +2712,12 @@ =20=20=20 /* FIXME -- send l2ca_timeoutind() */ =20 - if (MAX_NO_RTX =3D=3D 0) - { + if (MAX_NO_RTX =3D=3D 0) { /* no retransmissions, shutdown connection */ printk("NO retransmissions, lets shutdown connection...\n"); l2ca_disconnect_req(con); return; - }=20=20 - else if (con->last_cmd.nbr_resends =3D=3D MAX_NO_RTX) - { + } else if (con->last_cmd.nbr_resends =3D=3D MAX_NO_RTX) { /* notify upper layers that link is going down */ =20=09=20=20 /* FIXME l2ca_disconnect_ind */ @@ -2835,7 +2735,6 @@ =20 /* now resend command */ switch(con->last_cmd.type) { - case SIG_CONREQ: D_TIM("resending connection request\n"); l2cap_connect_req(con, con->psm); @@ -2864,7 +2763,6 @@ case SIG_INFOREQ: /* FIXME */ D_TIM("resending echo request NOT\n"); -=09=20=20 break; =20=20=20 default: @@ -2897,10 +2795,8 @@ printk("use NO timer...\n"); return; #else - struct itimerval t =3D {{0,0},{timeout, 0}}; =20=20=20 -=20=20 D_TIM("Starting RTX timer (%d sec)\n", timeout); =20 if (timeout_con) @@ -2999,7 +2895,6 @@ opt =3D (l2cap_option*)(data + pos); switch (opt->type) { case OPT_MTU: - con->remote_mtu =3D *((u16*)opt->option_data); =20 if ((con->remote_mtu < MTU_MIN) &&=20 @@ -3017,11 +2912,9 @@ con->local_cid, con->remote_cid,=20 con->remote_mtu); found_option =3D 1; -=09=09=09 break; =20=20=20=20=20=20=20 case OPT_FLUSH: - con->flush_timeout =3D *((u16*)opt->option_data); =20 /* FIXME -- return error code if not accepted */ @@ -3035,7 +2928,6 @@ break; =20=20=20=20=20=20=20 case OPT_QOS: - memcpy((u8*)&con->remote_qos, opt->option_data,=20 sizeof(struct flow)); =20=09=09=09 @@ -3089,7 +2981,6 @@ return l2cap->id_count++; }; =20 - /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -= - */ =20 s32 l2cap_sprint_bd(u8 *buf, BD_ADDR bd)=20 @@ -3128,7 +3019,6 @@ printk("NULL !\n"); return; } else { -=09=09 printk("flow:\n"); printk("flags:%d service:%d token_rate:%d\n", f->flags, f->service, (int) f->token_rate); |
From: Gordon M. <gm...@us...> - 2001-03-05 23:07:02
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bluetooth.c 1.137 1.138=20=20=20=20=20=20=20=20=20=20=20 hci_vendor.c 1.15 1.16=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: --Modified Ericcson's hci_set_baudrate to return -EINVAL if the baud rate i= s not supported and 0 otherwise. --Modified bt_ioctl to pass this return value on to its caller. The diff of the modified file(s): --- bluetooth.c 2001/03/05 16:41:44 1.137 +++ bluetooth.c 2001/03/05 23:08:39 1.138 @@ -943,8 +943,7 @@ GET_USER(tmp, (s32*)arg); BT_DRIVER(FNC"Setting baudrate in host controller to %d\n", tmp); =20=09=09 - hci_set_baudrate(tmp); - break; + return hci_set_baudrate(tmp); =20 case HCIWRITEBDADDR: copy_from_user(&bd_addr, (s32*)arg, size); --- hci_vendor.c 2001/03/05 15:39:07 1.15 +++ hci_vendor.c 2001/03/05 23:08:39 1.16 @@ -148,7 +148,6 @@ /* Due to the fact that the Ericsson module after P9A sends the reply on the new baudrate, this function can not block (Since btd sets the new physical device speed when this function returns). */=20=20 - s32 tmp; =20=20=20 D_CMD(__FUNCTION__"(%d baud)\n", baudrate); c_pkt.type =3D CMD_PKT; @@ -166,20 +165,22 @@ break; default: D_ERR(__FUNCTION__": Baudrate not supported\n"); - break;=09 + return -EINVAL; } #ifdef CONFIG_BLUETOOTH_SET_BAUDRATE_BLOCKING - tmp =3D send_cmd_block((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LE= N); + send_cmd_block((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN); #else if (hci_ctrl.hc_buf.cmd_num < 1) { DSYS(__FUNCTION__": sleeping\n"); interruptible_sleep_on(&set_baudrate_wq); } - tmp =3D bt_write_lower_driver((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI= _HDR_LEN); + bt_write_lower_driver((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN= ); =20=20=20 hci_ctrl.hc_buf.cmd_num -=3D 1;=20=20 #endif - return tmp; + /* We don't really know if the card accepted the change, but we did + succeed in trying to send it. --gmcnutt */ + return 0; } =20 =20 |
From: Peter K. <pk...@us...> - 2001-03-06 11:04:46
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- sdp.c 1.66 1.67=20=20=20=20=20=20=20=20=20=20=20=20 sec_client.c 1.15 1.16=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added some missing void's. The diff of the modified file(s): --- sdp.c 2001/03/06 11:04:15 1.66 +++ sdp.c 2001/03/06 11:06:24 1.67 @@ -410,7 +410,7 @@ =20 #ifdef __KERNEL__ s32 -sdp_create_proc_file() +sdp_create_proc_file(void) { s32 procfs_status =3D -ENOENT; =20 @@ -453,7 +453,7 @@ } =20 s32 -sdp_remove_proc_file() +sdp_remove_proc_file(void) { #if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0) remove_proc_entry(sdp_proc_entry.name, &proc_root); --- sec_client.c 2001/03/06 11:04:15 1.15 +++ sec_client.c 2001/03/06 11:06:24 1.16 @@ -266,7 +266,7 @@ =20 #ifdef __KERNEL__ s32 -sec_man_create_proc_file() +sec_man_create_proc_file(void) { s32 procfs_status =3D -ENOENT; =20 @@ -309,7 +309,7 @@ } =20 s32 -sec_man_remove_proc_file() +sec_man_remove_proc_file(void) { #if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0) remove_proc_entry(sec_man_proc_entry.name, &proc_root); |
From: Peter K. <pk...@us...> - 2001-03-15 16:25:29
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bluetooth.c 1.148 1.149=20=20=20=20=20=20=20=20=20=20=20 hci.c 1.129 1.130=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Fixed memory leak in hci_inquiry(), and corrected HCIINQUIRY in case hci_inquiry() failed. The diff of the modified file(s): --- bluetooth.c 2001/03/14 16:23:45 1.148 +++ bluetooth.c 2001/03/15 16:27:33 1.149 @@ -476,7 +476,6 @@ u32 utmp; s32 err =3D 0; s32 size =3D _IOC_SIZE(cmd); - inquiry_results *inq_res; bt_connection btcon; u8 bd_addr[6]; =20 @@ -693,13 +692,15 @@ =20 case HCIINQUIRY: {=20 + inquiry_results *inq_res; s32 in_param[2]; u8 lap[3]; =20=09=09 BT_DRIVER(FNC"HCINQUIRY\n"); =20=09=09 copy_from_user(in_param, (s32*)arg, 8); - inq_res =3D hci_inquiry(lap, in_param[1] , in_param[0]); + if (!(inq_res =3D hci_inquiry(lap, in_param[1] , in_param[0]))) + return -ENOMEM; copy_to_user((s32*)arg, inq_res, size + 6 * inq_res->nbr_of_units); break; } --- hci.c 2001/03/15 10:31:11 1.129 +++ hci.c 2001/03/15 16:27:33 1.130 @@ -321,8 +321,6 @@ =20 static s32 test_hci_hdl; =20 - - /****************** FUNCTION DEFINITION SECTION **************************= ***/ =20 /* @@ -347,7 +345,6 @@ u32 c; /* Temporary variable for index calculations */=20=20=20 u8 *buf; /* Temporary pointer to the incoming data */ u32 tmp_data_len; - s32 syncing =3D 1; =20=20 PRINTPKT(__FUNCTION__", ", data, count); =20=20=20 @@ -1695,12 +1692,14 @@ lap[1] =3D 0x8b; lap[2] =3D 0x9e; =20 - if (!inq_res) { + /* Free any previous response */ kfree(inq_res); - } =20 inq_res =3D (inquiry_results*) kmalloc(sizeof(inquiry_results) + 6 * num_resp, GFP_ATOMIC); + if (!inq_res) + return NULL; + inq_res->nbr_of_units =3D 0; =20 c_pkt.type =3D CMD_PKT; @@ -1715,11 +1714,12 @@ =20 tmp =3D send_inq_cmd_block((u8*) &c_pkt ,c_pkt.len + CMD_HDR_LEN + HCI_HD= R_LEN); =20 - if ( tmp >=3D 0) { - return inq_res; - } else { - return NULL; + if (tmp < 0) { + kfree(inq_res); + inq_res =3D NULL; } + + return inq_res; } =20 /* This function will cause the Link Manager to create a connection to the @@ -3254,7 +3254,7 @@ if (cmd_buf.count =3D=3D NBR_CMD_BUFS) { D_ERR("insert_cmd: WARNING Command buffer full !\n"); sti(); - return -1; + return -ENOMEM; } =20 /* Allocate memory (freed from send_cmd_queue) */ |
From: Peter K. <pk...@us...> - 2001-03-16 07:36:41
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- hci.c 1.131 1.132=20=20=20=20=20=20=20=20=20=20=20 hci_vendor.c 1.17 1.18=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Include errno.h where needed when compiling for user mode. The diff of the modified file(s): --- hci.c 2001/03/15 21:50:22 1.131 +++ hci.c 2001/03/16 07:38:48 1.132 @@ -61,6 +61,7 @@ #else /* user mode */ #include <stdlib.h> #include <string.h> +#include <errno.h> #include "include/bluetooth.h" #include "include/hci.h" #include "include/hci_internal.h" @@ -1693,7 +1694,6 @@ lap[2] =3D 0x9e; =20 /* Free any previous response */ - if (inq_res) kfree(inq_res); =20 inq_res =3D (inquiry_results*) kmalloc(sizeof(inquiry_results) --- hci_vendor.c 2001/03/06 10:49:09 1.17 +++ hci_vendor.c 2001/03/16 07:38:48 1.18 @@ -57,6 +57,7 @@ #else /* user mode */ #include <stdlib.h> #include <string.h> +#include <errno.h> #include "include/bluetooth.h" #include "include/hci.h" #include "include/hci_internal.h" @@ -164,11 +165,7 @@ break; default: D_ERR(__FUNCTION__ ": Baudrate not supported\n"); -#ifdef __KERNEL__ return -EINVAL; -#else - return -1; -#endif } =20 #ifdef CONFIG_BLUETOOTH_SET_BAUDRATE_BLOCKING |
From: Gordon M. <gm...@us...> - 2001-03-20 16:41:03
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bluetooth.c 1.154 1.154.2.1=20=20=20=20=20=20=20 hci.c 1.132 1.132.2.1=20=20=20=20=20=20=20 The accompanying log: --Initial checking of changes to HCI. Including a) fixed the hci inquiry ha= ng b) changed buffer allocation strategy for hci inquiry c) converted to ca= ll tables for HCI Command Status & Command Complete processing. The diff of the modified file(s): --- bluetooth.c 2001/03/20 15:29:49 1.154 +++ bluetooth.c 2001/03/20 16:42:53 1.154.2.1 @@ -41,8 +41,16 @@ =20 /****************** INCLUDE FILES SECTION ********************************= ***/ =20 -#include <linux/bluetooth/sysdep-2.1.h> #include <linux/config.h> + +#ifdef CONFIG_BLUETOOTH_KERNEL_THREAD +#define __KERNEL_SYSCALLS__ +#include <linux/proc_fs.h> +#include <linux/devfs_fs_kernel.h> +#include <linux/unistd.h> +#endif + +#include <linux/bluetooth/sysdep-2.1.h> #include <linux/termios.h> #include <linux/tty.h> #include <linux/module.h> @@ -93,6 +101,11 @@ #include <asm/io.h> #endif =20 +#ifdef CONFIG_BLUETOOTH_KERNEL_THREAD +#include <linux/unistd.h> +int bt_kernel_thread(void *); +#endif + /****************** DEBUG CONSTANT AND MACRO SECTION *********************= ***/ =20 #if BT_DRIVER_DEBUG @@ -180,7 +193,9 @@ static s32 bt_ctrl_init(void); static s32 bt_connect(u8 *bd_addr, u32 con_id); static s32 bt_disconnect(u32 con_id); +#ifdef BT_DRIVER_DEBUG static const u8* psmname(u16 psm); +#endif static void release_wq_timer(struct timer_list *wq_timer); static void wq_timeout(unsigned long ptr); static s32 bt_execute_sdp_request(bt_sdp_request *sdpRequest); @@ -388,7 +403,9 @@ static s32 bt_open(struct tty_struct *tty, struct file * filp) { +#if BT_DRIVER_DEBUG s32 line =3D GET_TTYLINE(tty); +#endif s32 ret_val; =20=09 BT_DRIVER("bt_open on line %d\n", line);=09 @@ -691,20 +708,41 @@ =20=09 /* Link Control Command */ =20 +#ifdef CONFIG_BLUETOOTH_HCI_INQUIRY case HCIINQUIRY: {=20 inquiry_results *inq_res; s32 in_param[2]; - u8 lap[3]; + + // REVISIT The user should specify this... + // --gmcnutt + u8 lap[3] =3D { 0x9e, 0x8b, 0x33 }; + u8 num_resp; + int ret; =20=09=09 BT_DRIVER(FNC"HCINQUIRY\n"); =20=09=09 copy_from_user(in_param, (s32*)arg, 8); - if (!(inq_res =3D hci_inquiry(lap, in_param[1] , in_param[0]))) + num_resp =3D in_param[0]; + + if ((inq_res =3D (inquiry_results*)=20 + kmalloc(sizeof(inquiry_results) + 6 * num_resp,=20 + GFP_ATOMIC)) =3D=3D NULL) { return -ENOMEM; - copy_to_user((s32*)arg, inq_res, size + 6 * inq_res->nbr_of_units); + } +=09=09 + if ((ret =3D hci_inquiry(lap, in_param[1] , in_param[0],=20 + inq_res)) < 0) + goto end_inquiry; + + copy_to_user((s32*)arg, inq_res, size + 6 *=20 + inq_res->nbr_of_units); + end_inquiry: + kfree(inq_res); + return ret; break; } +#endif /* CONFIG_BLUETOOTH_HCI_INQUIRY */ =20=09 case HCILINKKEYREPLY: { @@ -1556,7 +1594,11 @@ (SESSIONSTATE(line) =3D=3D BT_ACTIVE)) { D_WARN("already got connection on line %d\n",=20 GET_RFCOMMLINE(con_id));=20 +#ifdef __KERNEL__ + return -EBUSY; +#else return -1; +#endif }=20 =20 BT_DRIVER(FNC"Connecting srv ch %d on line %d\n", @@ -1570,7 +1612,14 @@ &bt_ctrl.connect_wq[line]); =20 interruptible_sleep_on(&bt_ctrl.connect_wq[line]); +#ifdef __KERNEL__ + if ((SESSIONSTATE(line) =3D=3D BT_LOWERCONNECTED)|| + (SESSIONSTATE(line) =3D=3D BT_ACTIVE)) + return 0; + return -EAGAIN; +#else return bt_ctrl.session[line].connect_status; +#endif } break; =20 @@ -1854,6 +1903,7 @@ } #endif =20 + /**********************************/ /* Bluetooth Stack Initialization */ /**********************************/ @@ -2017,7 +2067,6 @@ procfs_status); } =20 -#endif /* CONFIG_BLUETOOTH_PROC */ =20 #ifdef CONFIG_BLUETOOTH_USE_TCI #if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0) @@ -2043,6 +2092,7 @@ =20=09 sdp_create_proc_file(); =20 +#endif /* CONFIG_BLUETOOTH_PROC */ =20 #ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER sec_man_create_proc_file(); @@ -2060,6 +2110,7 @@ hci_data.get =3D hci_data.head;; #endif =20 + return 0; /*success*/ } =20 @@ -2519,6 +2570,7 @@ return 0; } =20 +#if BT_DRIVER_DEBUG static const u8* psmname(u16 psm) { @@ -2534,7 +2586,7 @@ return "UNKNOWN"; } } - +#endif #if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0) void start_wq_timer(struct timer_list *wq_timer, @@ -2628,4 +2680,191 @@ =20 #endif /* MODULE */ =20 +/****************** Kernel Thread ****************************************= ***/ +#ifdef CONFIG_BLUETOOTH_KERNEL_THREAD +#include <linux/bluetooth/btcommon.h> +#include <linux/types.h> + +#define INIT_BAUD B57600 +#define FINAL_BAUD B115200 +#define SERIAL "/dev/ttyS1" + +#ifdef __KERNEL__ +typedef struct my_inquiry_results { + u32 nbr_of_units; + u32 inq_time; + u8 bd_addr[60]; +} inquiry_results_t; +#endif + +static int bt_ldisc =3D N_BT, ser_fd, bt_fd; + +static void cfmakeraw(struct termios *t){ + t->c_iflag &=3D ~(IGNBRK|BRKINT|PARMRK|ISTRIP|IGNCR|IXON); + t->c_oflag &=3D ~OPOST; + t->c_lflag &=3D ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); + t->c_cflag &=3D ~(CSIZE|PARENB); + t->c_cflag |=3D CS8; +} + +static int do_initial_serial_port_setup(void) +{ + struct termios t; + int ret =3D 0; + + printk(__FUNCTION__"\n"); + + if ((ser_fd =3D open(SERIAL, O_RDWR, O_NOCTTY)) < 0) { + printk(__FUNCTION__":open '%s' failed\n", SERIAL); + return ser_fd; + } + + if ((ret =3D ioctl(ser_fd, TCGETA, (unsigned long) &t)) < 0) { + printk(__FUNCTION__":ioctl TCGETA failed\n"); + goto exit; + } + + cfmakeraw(&t); + + t.c_cflag &=3D ~CBAUD; + t.c_cflag |=3D INIT_BAUD | CS8 | CLOCAL; + t.c_oflag =3D 0; + t.c_lflag =3D 0; + t.c_cflag &=3D ~CRTSCTS; + + if ((ret =3D ioctl(ser_fd, TCSETA, (unsigned long) &t)) < 0) { + printk(__FUNCTION__":ioctl TCSETA failed\n"); + goto exit; + } + + if ((ret =3D ioctl(ser_fd, TIOCSETD, (unsigned long)&bt_ldisc)) < 0) { + printk(__FUNCTION__":ioctl TIOCSETD failed\n"); + goto exit; + } + exit: + return ret; +} +static int initialize_bluetooth_stack(void) +{ + unsigned int tmp =3D 115200; + int ret =3D 0; + + printk(__FUNCTION__"\n"); + if ((bt_fd =3D open("/dev/ttyBTC", O_RDWR, O_NOCTTY)) < 0) { + printk(__FUNCTION__":open '/dev/ttyBTC' failed\n"); + ret =3D bt_fd; + goto exit; + } + + if ((ret =3D ioctl(bt_fd, BTINITSTACK, 0)) < 0) { + printk(__FUNCTION__":ioctl BTINITSTACK failed\n"); + goto exit; + } + + if ((ret =3D ioctl(bt_fd, HCISETBAUDRATE, (unsigned long)&tmp)) < 0) { + printk(__FUNCTION__":ioctl HCISETBAUDRATE failed\n"); + goto exit; + } + exit: + return ret; + +} +static int do_final_serial_port_setup(void) +{ + struct termios t; + int ret =3D 0; + + printk(__FUNCTION__"\n"); + + if ((ret =3D ioctl(ser_fd, TCGETA, (unsigned long) &t)) < 0) { + printk(__FUNCTION__":ioctl TCGETA failed\n"); + goto exit; + } + + cfmakeraw(&t); + + t.c_cflag &=3D ~CBAUD; + t.c_cflag |=3D INIT_BAUD | CS8 | CLOCAL; + t.c_oflag =3D 0; + t.c_lflag =3D 0; + t.c_cflag &=3D ~CRTSCTS; + + if ((ret =3D ioctl(ser_fd, TCSETA, (unsigned long) &t)) < 0) { + printk(__FUNCTION__":ioctl TCSETA failed\n"); + goto exit; + } + + if ((ret =3D ioctl(ser_fd, TIOCSETD, (unsigned long)&bt_ldisc)) < 0) { + printk(__FUNCTION__":ioctl TIOCSETD failed\n"); + goto exit; + } + exit: + return ret; +} +static int check_bluetooth_address(void) +{ + unsigned char BD_addr[6]; + int i, ret =3D 0; + + printk(__FUNCTION__"\n"); + if((ret =3D ioctl(bt_fd, HCIREADLOCALBDADDR, (unsigned long)BD_addr)) <= =20 + 0) { + printk(__FUNCTION__":ioctl HCIREADLOCALBDADDR failed"); + goto exit; + } + + printk(__FUNCTION__":Local BD address: "); + for (i =3D 0; i < 6; i++) printk("0x%x ", BD_addr[i]); + printk("\n"); + exit: + return ret; +} +static int look_for_other_bluetooth_devices(void) +{ + inquiry_results_t inq_res; + int i, j, ret =3D 0; + + printk(__FUNCTION__"\n"); + + inq_res.nbr_of_units =3D 10; + inq_res.inq_time =3D 5; + + if ((ret =3D ioctl(bt_fd, HCIINQUIRY, (unsigned long)&inq_res)) < 0) + { + printk(__FUNCTION__":ioctl HCIINQUIRY failed\n"); + goto exit; + } + + printk(__FUNCTION__":Remote BD addresses:\n"); + + for (i =3D 0; i < inq_res.nbr_of_units; i++) { + for (j =3D 0; j < 6; j++)=20 + printk("0x%x ", inq_res.bd_addr[i * j + j]); + printk("\n"); + } + exit: + return ret; +} +int bt_kernel_thread(void *unused) +{ + int ret =3D 0; + + printk(__FUNCTION__"\n"); + + if ((ret =3D do_initial_serial_port_setup()) < 0) goto exit; + if ((ret =3D initialize_bluetooth_stack()) < 0) goto exit; + if ((ret =3D do_final_serial_port_setup()) < 0) goto exit; + if ((ret =3D check_bluetooth_address()) < 0) goto exit; + if ((ret =3D look_for_other_bluetooth_devices()) < 0) goto exit; + + /* + * At this point we can either spawn ppp and wait, or we might be + * able to just hang and let other apps use the other /dev/ttyBT* + * devices. + */ + exit: + printk(__FUNCTION__":Returning %d\n", ret); + return ret; +} +#endif // CONFIG_BLUETOOTH_KERNEL_THREAD /****************** END OF FILE bluetooth.c ******************************= ***/ --- hci.c 2001/03/16 07:38:48 1.132 +++ hci.c 2001/03/20 16:42:53 1.132.2.1 @@ -38,6 +38,8 @@ * * $Id$ * + * REFERENCES + * Bluetooth Core Specification Version 1.0B [BCS] */ =20 /****************** INCLUDE FILES SECTION ********************************= ***/ @@ -135,6 +137,7 @@ =20 #define USE_NCPTIMER=20 #define NCP_TIMEOUT (3*HZ) +#define USE_INQTIMER =20 /****************** TYPE DEFINITION SECTION ******************************= ***/ =20 @@ -187,7 +190,6 @@ static void init_cmd_buf(void); static void send_cmd_queue(void); static void update_nhcp(s32 nhcp); -static s32 send_inq_cmd_block(u8 *cmd, u8 len); #ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER static u8* get_bd(u16 con_hdl); #endif @@ -226,19 +228,11 @@ static void release_ncp_timer(void); #endif =20 -#ifdef USE_INQTIMER -static void start_inq_timer(void); -static void release_inq_timer(void); -#endif - #ifdef __KERNEL__ #ifdef USE_NCPTIMER static void ncp_timeout(unsigned long ptr); #endif static void cmd_timeout(unsigned long ptr); -#ifdef USE_INQTIMER -static void inq_timeout(unsigned long ptr); -#endif #endif =20 #ifdef HCI_EMULATION @@ -269,10 +263,8 @@ #ifdef USE_NCPTIMER static struct timer_list hci_ncp_timer; #endif +static int hci_cmd_timeout; static struct timer_list hci_cmd_timer; -#ifdef USE_INQTIMER -static struct timer_list hci_inq_timer; -#endif =20 #ifdef USE_NCPTIMER static struct hw_info { @@ -288,17 +280,18 @@ =20 /* semaphore for protecting shared data */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) +#define DECLARE_SEMAPHORE(sem) static struct semaphore sem =3D MUTEX +#define INIT_SEMAPHORE(sem,val) static struct semaphore hci_cmd_semaphore =3D MUTEX; -static struct semaphore hci_inq_semaphore =3D MUTEX; #else +#define DECLARE_SEMAPHORE(sem) static struct semaphore sem +#define INIT_SEMAPHORE(sem,val) sema_init(&sem,val) static struct semaphore hci_cmd_semaphore; -static struct semaphore hci_inq_semaphore; #endif /* LINUX_VERSION_CODE */ =20 #endif /* __KERNEL__ */ =20 static u32 hci_cmd_pending =3D 0; -static u32 hci_inq_pending =3D 0; =20 #if __KERNEL__ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) @@ -318,9 +311,8 @@ =20 static s32 result_param; =20 -static struct inquiry_results *inq_res =3D NULL; - static s32 test_hci_hdl; +static u8 cmd_timer_active =3D 0; =20 /****************** FUNCTION DEFINITION SECTION **************************= ***/ =20 @@ -358,6 +350,7 @@ =20=20=20 D_INDATA(__FUNCTION__", hci-%d\n", tmp_data_len); while (count > 0) { + c =3D 0; switch (state) { =20=09=09=09 /* The first byte will tell us whether it is an event or a @@ -370,8 +363,6 @@ case ACL_PKT: state =3D WAIT_FOR_ACL_HDR; break; case SCO_PKT: state =3D WAIT_FOR_SCO_HDR; break; default: - D_ERR(__FUNCTION__ ": discarding %d bytes\n", - count); /* An unrecognized HCI header type is usually a * sign of a problem with the lower level=20 * driver. For example, if the UART drops some @@ -381,10 +372,11 @@ * the next one. * --gmcnutt */ - return; + D_ERR(__FUNCTION__":bad packet type '0x%x', "\ + "discarding %d bytes\n", *buf, count); + state =3D WAIT_FOR_PACKET_TYPE;=09 } - buf +=3D 1; - count -=3D 1; + c =3D 1; break; =20 /* If it is an event packet we wait for the next byte @@ -393,22 +385,21 @@ D_STATE(__FUNCTION__", WAIT_FOR_EVENT_TYPE\n"); event_type =3D *buf; state =3D WAIT_FOR_EVENT_LENGTH; - buf +=3D 1; - count -=3D 1;=20=20 + c =3D 1; break; =20 /* If it is an event the length-field is one byte */ case WAIT_FOR_EVENT_LENGTH: D_STATE(__FUNCTION__", WAIT_FOR_EVENT_LENGTH\n"); event_len =3D *buf; + if (event_len <=3D count) { buf +=3D 1; count -=3D 1; - if (event_len <=3D count) { process_event(buf, event_len, event_type); - buf +=3D event_len; - count -=3D event_len; + c =3D event_len; state =3D WAIT_FOR_PACKET_TYPE; } else { + c =3D 1; state =3D WAIT_FOR_EVENT_PARAM; } break; @@ -417,18 +408,14 @@ whole event */ case WAIT_FOR_EVENT_PARAM: D_STATE(__FUNCTION__", WAIT_FOR_EVENT_PARAM\n"); - if (tmp_pos < event_len) { c =3D MIN(count, event_len - tmp_pos); memcpy(event_buf + tmp_pos, buf, c); tmp_pos +=3D c; - count -=3D c; - buf +=3D c; if (tmp_pos =3D=3D event_len) { process_event(event_buf,event_len, event_type); state =3D WAIT_FOR_PACKET_TYPE; } - } break; =20 /* Here we wait for the whole data header, four bytes*/ @@ -437,8 +424,6 @@ c =3D MIN(count, ACL_HDR_LEN - tmp_pos); memcpy(hdr + tmp_pos, buf, c); tmp_pos +=3D c; - buf +=3D c; - count -=3D c; if (tmp_pos =3D=3D ACL_HDR_LEN) { hci_hdl =3D CHAR2INT12(hdr[1],hdr[0]); pb_flag =3D (((u32) hdr[1]) & 0x30) >> 4; @@ -460,20 +445,13 @@ } } =20 - host_nbrcompleted_packets(hci_hdl, 1); =20 - - /* When we change state we reset data_index, because we are using separate buffers for the HCI header and the HCI data */ tmp_pos =3D 0; state =3D WAIT_FOR_ACL_DATA; - } else if (tmp_pos < ACL_HDR_LEN) { - D_REC(__FUNCTION__" Didn't got whole header length, waiting for more\n= "); - } else { - D_ERR(__FUNCTION__" incorredt ACL header length\n"); } break; =20 @@ -481,7 +459,6 @@ whole data packet and then we send it to a higher protocol layer, in this case the L2CAP-layer */ case WAIT_FOR_ACL_DATA: - D_STATE(__FUNCTION__", WAIT_FOR_ACL_DATA\n"); /* Find out how much data we can copy, don't copy more than one HCI packet at time */ c =3D MIN(count, data_len - tmp_pos); @@ -489,15 +466,12 @@ memcpy(in_buf->buf_ptr, buf, c); in_buf->buf_ptr +=3D c; in_buf->count +=3D c; - D_REC(__FUNCTION__", in_buf->count =3D %d\n",in_buf->count); + D_REC(__FUNCTION__", Copied %d bytes into "\ + "inbuffer\n", c); } =20=20=20=20=20=20=20 - /* Increase the data_index and decrease the amount of - data */ tmp_pos +=3D c; - count -=3D c; =20=20=20=20=20=20=20 - D_REC(__FUNCTION__", Copied %d bytes into inbuffer\n",c); if (tmp_pos =3D=3D data_len) { if (in_buf) { process_acl_data(in_buf, pb_flag); @@ -506,7 +480,6 @@ } state =3D WAIT_FOR_PACKET_TYPE; } - buf +=3D c; break; =20=20=20=20=20=20=20 /* wait for the SCO header, three bytes */ @@ -516,8 +489,6 @@ c =3D MIN(count,SCO_HDR_LEN - tmp_pos); memcpy(hdr + tmp_pos, buf, c); tmp_pos +=3D c; - buf +=3D c; - count -=3D c; if (tmp_pos =3D=3D SCO_HDR_LEN) { hci_hdl =3D CHAR2INT12(hdr[1],hdr[0]); data_len =3D hdr[2]; @@ -534,8 +505,6 @@ c =3D MIN(count, data_len - tmp_pos); process_sco_packet(buf, hci_hdl, c); tmp_pos +=3D c; - buf +=3D c; - count -=3D c; if (tmp_pos =3D=3D data_len) { state =3D WAIT_FOR_PACKET_TYPE; =20=20=20=20=20=20=20=20=20 @@ -545,10 +514,17 @@ break; =20 default: - D_ERR(__FUNCTION__", : Oups shouldn't be possible...\n"); + D_ERR(__FUNCTION__", : Oups shouldn't be possible..."\ + "\n"); break; } + + buf +=3D c; + count -=3D c; } + + return; + } =20 void @@ -592,761 +568,8 @@ #endif=09 } =20 -/* - * Parses an eventpacket, buf is the event parameters, length the event le= ngth - * and event_code is the event's opcode - */ - -void -process_event(u8 *buf, u32 len, u32 event_code) -{ - u16 hci_hdl; - s32 i; - PRINTPKT(__FUNCTION__, buf, len); - - switch (event_code) { - case INQUIRY_COMPLETE: - D_CMD("INQUIRY_COMPLETE\n"); - hci_inq_pending =3D 0; - wake_up_interruptible(&inq_wq); -#ifndef __KERNEL__ - for (i =3D 0; i < inq_res->nbr_of_units; i++) { - D_CMD(__FUNCTION__", BD %d: %02x:%02x:%02x:%02x:%02x:%02x\n",i, - inq_res->bd_addr[0+6*i],inq_res->bd_addr[1+6*i], - inq_res->bd_addr[2+6*i],inq_res->bd_addr[3+6*i], - inq_res->bd_addr[4+6*i],inq_res->bd_addr[5+6*i]); - } -#endif - break; - - case INQUIRY_RESULT: - { - s32 i, j; - u8 tmp_bd[6]; - - D_CMD(__FUNCTION__", INQUIRY_RESULT\n"); - for(i =3D 1; i < (buf[0] * 14) + 1; i +=3D 14) {=09=09 - printk("BD addr %d\n", i % 14); -=09=09=09 - for (j =3D 0; j < 6; j++) { - tmp_bd[5-j] =3D buf[i + j]; - } - print_data("BD",tmp_bd, 6); - for (j =3D 0; j < inq_res->nbr_of_units; j++) { - if (!memcmp(inq_res->bd_addr + inq_res->nbr_of_units * 6, tmp_bd, 6)) { - j =3D inq_res->nbr_of_units; - } - } - if (j >=3D inq_res->nbr_of_units) { - memcpy(inq_res->bd_addr + inq_res->nbr_of_units * 6, tmp_bd, 6); - inq_res->nbr_of_units +=3D 1; - } - } - break; - } - - case CONNECTION_COMPLETE: - { - u8 link_type; - - D_CMD(__FUNCTION__", CONNECTION_COMPLETE: %s\n", - get_err_msg(buf[0])); - - hci_ctrl.nbr_of_connections +=3D 1; - - link_type =3D buf[9]; - hci_hdl =3D CHAR2INT12(buf[2], buf[1]); - test_hci_hdl =3D hci_hdl; - - if (link_type =3D=3D ACL_LINK) { - lp_connect_cfm(buf + 3, (u32) buf[0], hci_hdl); - } else { - tcs_add_sco_link(buf[0], hci_hdl); - } - -#ifndef HCI_EMULATION - if (buf[0]) { - /* remove hci handle if connection failed */ - DSYS(__FUNCTION__", CONNECTION_COMPLETE %s\n", get_err_msg(buf[0])); - hci_ctrl.nbr_of_connections -=3D 1; - reset_hci_con_bd(hci_hdl); - } else { - DSYS(__FUNCTION__", ACL link is up\n"); - change_connection_packet_type(hci_hdl, DM3|DH3|DM5|DH5); - set_hci_con(buf + 3, hci_hdl); - remote_name_request(buf + 3); -// write_link_policy_settings(hci_hdl, 0x01); /* enable m/s switch */ -// hci_switch_role(buf + 3, 0); - role_discovery(hci_hdl); - } -#endif /* HCI_EMULATION */ - - if (test_wq_active) { - test_wq_active =3D 0; - wake_up_interruptible(&test_wq); - } -=09=09 - break; - } - case CONNECTION_REQUEST: - D_CMD(__FUNCTION__", CONNECTION_REQUEST\n"); - - if (buf[9] =3D=3D ACL_LINK) { - lp_connect_ind(buf); /* BD_ADDRESS */ - } else { - printk(__FUNCTION__", CONNECTION_REQUEST for SCO LINK"); - accept_connection_request(buf, 0x01); /* role ignored for SCO */ - } - break; - - case DISCONNECTION_COMPLETE: - DSYS(__FUNCTION__", DISCONNECTION_COMPLETE %s\n", get_err_msg(buf[3])); - - lp_disconnect_ind(CHAR2INT12(buf[2], buf[1])); - /* FIXME: No more NBR_OF_COMPLETE_PACKETS will arrive for this - connection handle, if we only support point-to-point - connections we can acl_num by reading the buffersizes again, - but this will not work in a multipoint connection. */ - hci_ctrl.nbr_of_connections -=3D 1; - - reset_hci_con_bd(CHAR2INT12(buf[2], buf[1])); -=09=09 - if (hci_ctrl.nbr_of_connections <=3D 0) { - hci_read_buffer_size(HCI_NON_BLOCK); - } - break; - - case AUTHENTICATION_COMPLETE: - DSYS(__FUNCTION__", AUTHENTICATION_COMPLETE\n"); -#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER - if (buf[0]) { - D_ERR(__FUNCTION__", AUTHENTICATION_COMPLETE: %s\n", get_err_msg(buf[0]= )); -=09=09=09 - } -=09=09 - sec_man_event(HCI, get_bd(CHAR2INT12(buf[2], buf[1])), AUTHENTICATION_CO= MPLETE, buf, 1); -#endif - break; - - case REMOTE_NAME_REQUEST_COMPLETE: - D_CMD(__FUNCTION__", REMOTE_NAME_REQUEST_COMPLETE %s\n", buf + 7); - if (buf[0]) { - D_ERR(__FUNCTION__", REMOTE_NAME_REQUEST_COMPLETE: %s\n", - get_err_msg(buf[0])); - } else { - if (strlen(buf + 7) > 248) { - D_ERR(__FUNCTION__", REMOTE_NAME_REQUEST_COMPLETE: too long name lengt= h %d\n", (int)strlen(buf + 7)); - break; - } - set_hci_con_name(buf + 1, buf + 7); - } - break; - - case ENCRYPTION_CHANGE: - DSYS(__FUNCTION__", ENCRYPTION_CHANGE\n"); -#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER - if (buf[0]) { - D_ERR(__FUNCTION__", ENCRYPTION_CHANGE: %s\n", get_err_msg(buf[0])); - } - - { - u8 tmp[2]; - tmp[0] =3D buf[0]; - tmp[1] =3D buf[3]; -=09=09 - sec_man_event(HCI, get_bd(CHAR2INT12(buf[2], buf[1= ])), ENCRYPTION_CHANGE, tmp, 2); - } -#endif - break; -=09 - case CHANGE_CONNECTION_LINK_KEY_COMPLETE: - DSYS(__FUNCTION__", CHANGE_CONNECTION_LINK_KEY_COMPLETE Not implemented!= \n"); - break; - - case MASTER_LINK_KEY_COMPLETE: - DSYS(__FUNCTION__", MASTER_LINK_KEY_COMPLETE Not implemented!\n"); - break; - - case READ_REMOTE_SUPPORTED_FEATURES_COMPLETE: - DSYS(__FUNCTION__", READ_REMOTE_SUPPORTED_FEATURES_COMPLETE Not implemen= ted!\n"); - break; - - case READ_REMOTE_VERSION_INFORMATION_COMPLETE: - DSYS(__FUNCTION__", READ_REMOTE_VERSION_INFORMATION_COMPLETE Not impleme= nted!\n"); - break; - - case QOS_SETUP_COMPLETE: - DSYS(__FUNCTION__", QOS_SETUP_COMPLETE Not implemented!\n"); - break; - - case COMMAND_COMPLETE: - D_CMD(__FUNCTION__", COMMAND_COMPLETE\n"); - - /* FIXME - stop any outstanding send timers if cmd_num is > 0*/ - D_QUEUE("<CC>\n"); - - process_return_param(buf); - update_nhcp(buf[0]); - break; - - /* used to prevent host from waiting on reply when a=20 - command has been received in HW and is currently=20 - performing the task for this command */ -=09=09 - case COMMAND_STATUS: - release_cmd_timer(); - /*FIXME: hci_switch_role() will generate COMMAND_STATUS that - shouldn't call wake_up_interruptible() */ - D_CMD(__FUNCTION__", COMMAND_STATUS\n"); -=09=09 - if (buf[0]) { - D_ERR(__FUNCTION__", COMMAND_STATUS: %s\n",get_err_msg(buf[0])); - } -=09=09 - update_nhcp(buf[1]); - wake_up_interruptible(&hci_wq); - break; - case FLUSH_OCCURRED: - D_CMD(__FUNCTION__", FLUSH_OCCURRED on hci_hdl %d\n", - CHAR2INT12(buf[1],buf[0])); - btmem_flushhandle(CHAR2INT12(buf[1],buf[0]));=09=09 - break; - - case HARDWARE_ERROR: - D_ERR(__FUNCTION__", An hardware error with error code 0x%02x occurred\n= Please refer to your bluetooth module manual\n", buf[0]); - break; - - case ROLE_CHANGED: - D_CMD(__FUNCTION__", ROLE_CHANGED\n"); - - if (buf[0]) {=20 - D_ERR(__FUNCTION__", Role changed faild due to %s\n", - get_err_msg(buf[0])); - } else if (buf[7]) { - DSYS(__FUNCTION__", Role was changed to Slave for unit with BD Address = 0x%04x%08x\n", CHAR2INT16(buf[6], buf[5]), CHAR2INT32(buf[4], buf[3], buf[2= ], buf[1])); - } else { - DSYS(__FUNCTION__", Role was changed to Master for unit with BD Address= 0x%04x%08x\n", CHAR2INT16(buf[6], buf[5]), CHAR2INT32(buf[4], buf[3], buf[= 2], buf[1])); - } - break; - - case NBR_OF_COMPLETED_PACKETS:=20 - - D_CMD(__FUNCTION__", NUMBER_OF_COMPLETED_PACKETS\n"); -=09 - update_ncp(buf[0], buf + 1); - - D_QUEUE("<NCP:%d>\n",hci_ctrl.hc_buf.acl_num); - - break; - - case MODE_CHANGE: - D_CMD(__FUNCTION__", MODE_CHANGE on hci_hdl %d\n", - CHAR2INT12(buf[2],buf[1])); - break; - - case RETURN_LINK_KEYS: - D_CMD(__FUNCTION__", RETURN_LINK_KEYS event\n"); -#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER - { - u8 tmp_str[23]; - - for (i =3D 0; i < buf[0]; i++) { - D_CMD("%d: ",i); - tmp_str[0] =3D i; - memcpy(tmp_str + 1, (buf + 1) + (i * 6), 6= ); - memcpy(tmp_str + 7, (buf + 1) + (buf[0] * = 6) + (i * 16), 16); - sec_man_event(HCI, buf + 1, RETURN_LINK_KE= YS, tmp_str, 17); - } - } -#endif - break; -=09 - case PIN_CODE_REQUEST: - D_CMD(__FUNCTION__", PIN_CODE_REQUEST forwarding event to security manag= er\n"); -#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER - sec_man_event(HCI, buf, PIN_CODE_REQUEST, NULL, 0); -#endif - break; -=09 - case LINK_KEY_REQUEST: - D_CMD(__FUNCTION__", LINK_KEY_REQUEST\n"); -#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER - sec_man_event(HCI, buf, LINK_KEY_REQUEST, NULL, 0); -#endif - break; - - case LINK_KEY_NOTIFICATION: - D_CMD(__FUNCTION__", LINK_KEY_NOTIFICATION forwarding event to security = manager\n"); -#ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER - sec_man_event(HCI, buf, LINK_KEY_NOTIFICATION, buf + 6, 16); -#endif - break; - - case LOOPBACK_COMMAND: - DSYS(__FUNCTION__", LOOPBACK_COMMAND, loopback mode not supported\n"); - break; - - case DATA_BUFFER_OVERFLOW: - D_ERR(__FUNCTION__", DATA_BUFFER_OVERFLOW\n"); - break; - - case MAX_SLOTS_CHANGE: - D_CMD(__FUNCTION__", MAX_SLOTS_CHANGE to %d\n", - (u32) buf[2]); - break; - - case READ_CLOCK_OFFSET_COMPLETE: - D_CMD(__FUNCTION__", READ_CLOCK_OFFSET_COMPLETE\n"); - break; - - case CONNECTION_PACKET_TYPE_CHANGED: - D_CMD(__FUNCTION__", CHANGE_CONNECTION_PACKET_TYPE\n"); - break; - - case QOS_VIOLATION: - D_CMD(__FUNCTION__", QOS_VIOLATION\n"); - break; - - case PAGE_SCAN_MODE_CHANGE: - DSYS(__FUNCTION__", PAGE_SCAN_MODE_CHANGE Not implemented\n"); - break; - - case PAGE_SCAN_REPETITION_MODE_CHANGE: - DSYS(__FUNCTION__", PAGE_SCAN_REPETITION_MODE_CHANGE Not implemented\n"); - break;=09 - - case VENDOR_EVENT: - process_vendor_event(buf, len, event_code); - break; - - default: - DSYS(__FUNCTION__", UNKNOWN EVENT CODE 0x%x\n",event_code); - break; - } -} - - -/* Parses the return parameters from the command complete event, see the - bluetooth baseband specification part H:1, chapter 5.2.14 for a further - description of the command complete event. */ - -void=20 -process_return_param(u8 *buf) -{ - u32 ogf,ocf; - u8 *r_val; - - /* buf points at the start of the event parameters of the command - complete event. The second and third byte (buf[1] and buf[2]) - contains the op-code, which consists of the OGF and the OCF values, - see the baseband specification part H:1, chapter 4.4.1 for a - description of these. - - r_val is set to point at the beginning of the return parameters at - the command complete event */ - - ogf =3D (u32) buf[2] >> 2; - ocf =3D CHAR2INT10(buf[2],buf[1]); - r_val =3D buf + 3; - - switch (ogf) { - - case HCI_LC: -=20=20=20=20=20=20=20=20=20=20 - switch (ocf) { - case LINK_KEY_REQUEST_REPLY: - release_cmd_timer(); -=09=09=09 - D_CMD(__FUNCTION__", LINK_KEY_REQUEST_REPLY\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", LINK_KEY_REQUEST_REPLY %s\n", get_err_msg(r_val[0= ])); - result_param =3D - r_val[0];=20 - } - else { - D_CMD(__FUNCTION__", LINK_KEY_REQUEST_REPLY Success\n"); - result_param =3D 0; - } -=09=09=09 - wake_up_interruptible(&hci_wq); - break; -=09=09 - case LINK_KEY_REQUEST_NEGATIVE_REPLY: - release_cmd_timer(); -=09=09=09 - D_CMD(__FUNCTION__", LINK_KEY_REQUEST_NEGATIVE_REPLY\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", LINK_KEY_REQUEST_NEGATIVE_REPLY %s\n", get_err_ms= g(r_val[0])); - result_param =3D - r_val[0];=20 - } - else { - D_CMD(__FUNCTION__", LINK_KEY_REQUEST_NEGATIVE_REPLY Success\n"); - result_param =3D 0; - } -=09=09=09 - wake_up_interruptible(&hci_wq); - break; -=09=09 - case PIN_CODE_REQUEST_REPLY: - release_cmd_timer(); -=09=09=09=09=09 - D_CMD(__FUNCTION__", PIN_CODE_REQUEST_REPLY\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", PIN_CODE_REQUEST_REPLY %s\n", get_err_msg(r_val[0= ])); - result_param =3D - r_val[0];=20 - } - else { - D_CMD(__FUNCTION__", PIN_CODE_REQUEST_REPLY Success\n"); - result_param =3D 0; - } - - wake_up_interruptible(&hci_wq); - break; - - - case PIN_CODE_REQUEST_NEGATIVE_REPLY: - release_cmd_timer(); -=09=09=09 - D_CMD(__FUNCTION__", PIN_CODE_REQUEST_NEGATIVE_REPLY\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", PIN_CODE_REQUEST_NEGATIVE_REPLY %s\n", get_err_ms= g(r_val[0])); - result_param =3D - r_val[0];=20 - } - else { - D_CMD(__FUNCTION__", PIN_CODE_REQUEST_NEGATIVE_REPLY Success\n"); - result_param =3D 0; - } - - wake_up_interruptible(&hci_wq); - break;=09 - - default: - D_CMD(__FUNCTION__", HCI_LC, ocf %d not recognised!\n", ocf); - break; - } - - break; -=20=20=20=20=20=20=20=20=20=20 - case HCI_HC: /* Host Controller commands */ - release_cmd_timer(); -/* FIX ME : The correct timer should be released */ -=20=20=20=20=20=20=20=20=20=20 - switch (ocf) { -=09=09=09 - case CREATE_NEW_UNIT_KEY: - D_CMD(__FUNCTION__", CREATE_NEW_UNIT_KEY\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", CREATE_NEW_UNIT_KEY %s\n", get_err_msg(r_val[0])); - result_param =3D - r_val[0];=20 - } else { - D_CMD(__FUNCTION__", CREATE_NEW_UNIT_KEY Success\n"); - result_param =3D 0; - } - break; -=09=09=09 -=09=09=09 - case READ_STORED_LINK_KEY: - D_CMD(__FUNCTION__", READ_STORED_LINK_KEY\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", READ_STORED_LINK_KEY %s\n", get_err_msg(r_val[0])= ); - result_param =3D - r_val[0]; - } else { - D_CMD(__FUNCTION__", READ_STORED_LINK_KEY Success\n"); - result_param =3D CHAR2INT16(r_val[4], r_val[3]); - } - D_CMD(__FUNCTION__", Max number of Linkkeys: %d\n", - CHAR2INT16(r_val[2], r_val[1])); - D_CMD(__FUNCTION__", Number of Linkkeys read: %d\n", - CHAR2INT16(r_val[4], r_val[3])); - break; - - case WRITE_STORED_LINK_KEY: - D_CMD(__FUNCTION__", WRITE_STORED_LINK_KEY\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", WRITE_STORED_LINK_KEY %s\n", get_err_msg(r_val[0]= )); - result_param =3D - r_val[0];=20 - } - else { - D_CMD(__FUNCTION__", WRITE_STORED_LINK_KEY Success\n"); - result_param =3D 0; - } - break; - - case DELETE_STORED_LINK_KEY: - D_CMD(__FUNCTION__", DELETE_STORED_LINK_KEY\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", DELETE_STORED_LINK_KEY %s\n", get_err_msg(r_val[0= ])); - result_param =3D - r_val[0]; - } else { - D_CMD(__FUNCTION__", DELETE_STORED_LINK_KEY Success\n"); - result_param =3D CHAR2INT16(r_val[2], r_val[1]); - } -=09=09=09 - D_CMD(__FUNCTION__", Number of Linkkeys deleted: %d\n", - CHAR2INT16(r_val[2], r_val[1])); - break;=09 -=20=20=20=20=20=20=20=20=20=20=20=20 - case SET_HOST_CONTROLLER_TO_HOST_FLOW_CONTROL: - D_CMD(__FUNCTION__", SET_HOST_CONTROLLER_TO_HOST_FLOW_CONTROL\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", SET_HOST_CONTROLLER_TO_HOST_FLOW_CONTROL: %s\n", - get_err_msg(r_val[0])); - break; - } - break; -=20=20=20=20=20=20=20=20=20=20=20=20 - case HOST_BUFFER_SIZE:=20=20 - D_CMD(__FUNCTION__", HOST_BUFFER_SIZE\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", HOST_BUFFER_SIZE: %s\n", - get_err_msg(r_val[0])); - } - break; -=20=20=20=20=20=20=20=20=20=20=20=20 - case CHANGE_LOCAL_NAME: - D_CMD(__FUNCTION__", CHANGE_LOCAL_NAME\n");=20=20=20=20=20=20=20=20=20= =20=20=20 - if (r_val[0]) { - D_ERR(__FUNCTION__", CHANGE_LOCAL_NAME: %s\n", - get_err_msg(r_val[0])); - } - break; - - case READ_SCAN_ENABLE: - D_CMD(__FUNCTION__", READ_SCAN_ENABLE\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", READ_SCAN_ENABLE: %s\n", - get_err_msg(r_val[0])); - result_param =3D -r_val[0]; - } else { - result_param =3D r_val[1]; - } - printk("READ_SCAN_ENABLE %d\n", result_param); - break; -=09=09=09 - case WRITE_SCAN_ENABLE: - D_CMD(__FUNCTION__", WRITE_SCAN_ENABLE\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", WRITE_SCAN_ENABLE: %s\n", - get_err_msg(r_val[0])); - } - break; -=20=20=20=20=20=20=20=20=20=20=20=20 - case WRITE_PAGESCAN_ACTIVITY: - D_CMD(__FUNCTION__", WRITE_PAGESCAN_ACTIVITY\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", WRITE_PAGESCAN_ACTIVITY: %s\n", - get_err_msg(r_val[0])); - } - break; -=20=20=20=20=20=20=20=20=20=20=20=20 - case WRITE_INQUIRYSCAN_ACTIVITY: - D_CMD(__FUNCTION__", WRITE_INQUIRYSCAN_ACTIVITY\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", WRITE_INQUIRYSCAN_ACTIVITY: %s\n", - get_err_msg(r_val[0])); - result_param =3D -r_val[0]; - } - break; - - case READ_AUTHENTICATION_ENABLE: - D_CMD(__FUNCTION__", READ_AUTHENTICATION_ENABLE\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", READ_AUTHENTICATION_ENABLE: %s\n", get_err_msg(r_= val[0])); - result_param =3D -r_val[0]; - } else { - result_param =3D r_val[1]; - } - break; -=09=09=09 - case WRITE_AUTHENTICATION_ENABLE: - D_CMD(__FUNCTION__", WRITE_AUTHENTICATION_ENABLE\n"); - if(r_val[0]) { - D_ERR(__FUNCTION__", WRITE_AUTHENTICATION_ENABLE: %s\n", - get_err_msg(r_val[0])); - result_param =3D -r_val[0]; - }=20 - break; -=09=09=09 - case READ_ENCRYPTION_MODE: - D_CMD(__FUNCTION__", READ_ENCRYPTION_MODE\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", READ_ENCRYPTION_MODE: %s\n", get_err_msg(r_val[0]= )); - result_param =3D -r_val[0]; - } else { - result_param =3D r_val[1]; - } - break; -=09=09=09 - case WRITE_ENCRYPTION_MODE: - D_CMD(__FUNCTION__", WRITE_AUTHENTICATION_ENABLE\n"); - if(r_val[0]) { - D_ERR(__FUNCTION__", WRITE_AUTHENTICATION_ENABLE: %s\n", - get_err_msg(r_val[0])); - result_param =3D -r_val[0]; - } - break; -=09=09=09 - case WRITE_CLASS_OF_DEVICE: - D_CMD(__FUNCTION__", WRITE_CLASS_OF_DEVICE\n"); - if(r_val[0]) { - D_ERR(__FUNCTION__", WRITE_CLASS_OF_DEVICE: %s\n", - get_err_msg(r_val[0])); - } - break; - - case WRITE_AUTOMATIC_FLUSH_TIMEOUT: - D_CMD(__FUNCTION__" WRITE_AUTOMATIC_FLUSH_TIMEOUT\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", WRITE_AUTOMATIC_FLUSH_TIMEOUT: %s\n", - get_err_msg(r_val[0])); - } else { - D_CMD(__FUNCTION__", WRITE_AUTOMATIC_FLUSH_TIMEOUT Success\n"); - } -=09=09=09 - break; - -=20=20=20=20=20=20=20=20=20=20=20=20 - case READ_LINK_SUPERVISION_TIMEOUT: - D_CMD(__FUNCTION__", Link supervision timeout is: %d\n", - CHAR2INT16(buf[4],buf[3])); - break; -=20=20=20=20=20=20=20=20=20=20=20=20 - case WRITE_LINK_SUPERVISION_TIMEOUT: - D_CMD(__FUNCTION__", WRITE_LINK_SUPERVISION_TO (%d)\n", r_val[0]); - if (r_val[0]) { - D_ERR(__FUNCTION__", WRITE_LINK_SUPERVISION_TO: %s\n", - get_err_msg(r_val[0])); - } - break; -=20=20=20=20=20=20=20=20=20=20=20=20 - case RESET: - D_CMD(__FUNCTION__", RESET\n");=09=09=09=20=20=20=20=20=20 - break; -=20=20=20=20=20=20=20=20=20=20=20=20 - case SET_EVENT_FILTER: - D_CMD(__FUNCTION__", SET_EVENT_FILTER\n");=09=09=09=20=20=20=20=20=20 - break; -=20=20=20=20=20=20=20=20=20=20=20=20 - default: - D_CMD(__FUNCTION__", HCI_HC, ocf %d not recognised!\n", ocf); - break; - } - /* FIX ME : Wake up from the correct queue */ - wake_up_interruptible(&hci_wq); - break; - - case HCI_LP: /* Link policy commands */ - switch (ocf) { - case ROLE_DISCOVERY: - printk(__FUNCTION__", ROLE_DISCOVERY: "); - if (r_val[0]) { - D_ERR(__FUNCTION__", ROLE_DISCOVERY: %s\n", - get_err_msg(r_val[0])); - break; - } - if (r_val[3]) - printk("Connected as Slave.\n"); - else - printk("Connected as Master. \n"); - break; - case WRITE_LINK_POLICY_SETTINGS: - printk(__FUNCTION__", WRITE_LINK_POLICY_SETTINGS \n "); - if (r_val[0]) { - D_ERR(__FUNCTION__", WRITE_LINK_POLICY_SETTINGS: %s\n", - get_err_msg(r_val[0])); - break; - } - break; - default: - D_CMD(__FUNCTION__", HCI_LP, ocf %d not recognised!\n", ocf); - break; - } - break; -=09=09 - case HCI_IP: /* Informational parameters */ - release_cmd_timer(); - - switch (ocf) { - case READ_BUFFER_SIZE: - D_CMD(__FUNCTION__", READ_BUFFER_SIZE\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", READ_BUFFER_SIZE: %s\n", - get_err_msg(r_val[0])); - break; - } - hci_ctrl.hc_buf.acl_len =3D CHAR2INT16(r_val[2],r_val[1]); - hci_ctrl.hc_buf.sco_len =3D (u32) r_val[3]; - hci_ctrl.hc_buf.acl_num =3D CHAR2INT16(r_val[5],r_val[4]); - hci_ctrl.hc_buf.sco_num =3D CHAR2INT16(r_val[7],r_val[6]); - printk("\nHW module contains...\n"); - printk("%d ACL buffers at %d bytes\n%d SCO buffers at %d bytes\n\n", - hci_ctrl.hc_buf.acl_num, hci_ctrl.hc_buf.acl_len, - hci_ctrl.hc_buf.sco_num, hci_ctrl.hc_buf.sco_len); - -#ifdef __KERNEL__ -#ifdef USE_NCPTIMER - hw.max_acl_num =3D hci_ctrl.hc_buf.acl_num; -#endif -#endif - break; -=20=20=20=20=20=20=20=20=20=20=20=20 - case READ_BD_ADDR: - D_CMD(__FUNCTION__", READ_BD_ADDR\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", READ_BD_ADDR: %s\n", - get_err_msg(r_val[0])); - break; - }=20=20=20=20=20=20=20=20=20=20=20=20 - PRINTPKT(__FUNCTION__", READ_BD_ADDR : ", &r_val[1], 6); - memcpy(hci_ctrl.local_bd, &r_val[1],6); - break; -=20=20=20=20=20=20=20=20=20=20=20=20 - default: - D_CMD(__FUNCTION__", HCI_IP, ocf %d not recognised!\n", ocf); - break; - } - wake_up_interruptible(&hci_wq); - break; -=20=20=20=20=20=20=20=20=20=20 - case HCI_TC: /* Test Commands */ - release_cmd_timer(); - - switch (ocf) {=20=20 - case READ_LOOPBACK_MODE: - D_CMD(__FUNCTION__", READ_LOOPBACK_MODE -- not impl\n"); - break; -=20=20=20=20=20=20=20=20=20=20=20=20 - case WRITE_LOOPBACK_MODE: - D_CMD(__FUNCTION__", WRITE_LOOPBACK_MODE -- not impl\n"); - break; -=20=20=20=20=20=20=20=20=20=20=20=20 - case ENABLE_DEVICE_UNDER_TEST_MODE: - D_CMD(__FUNCTION__", ENABLE_DEVICE_UNDER_TEST_MODE\n"); - if (r_val[0]) { - D_ERR(__FUNCTION__", ENABLE_DEVICE_UNDER_TEST_MODE: %s\n", - get_err_msg(r_val[0])); - break; - } - printk(__FUNCTION__", *** Local device now under test\n***"); - break; -=20=20=20=20=20=20=20=20=20=20=20=20 - default: - D_CMD(__FUNCTION__", HCI_TC, ocf %d not recognised!\n", ocf); - break; - } - wake_up_interruptible(&hci_wq); - break; =20=20=20=20=20=20=20=20=20=20=20 - case MANUFACTURER_SPEC: { /* manufacturer specific */ - D_CMD(__FUNCTION__", MANUFACTURER_SPEC\n"); - process_vendor_return_param(ocf, r_val); - } - break; =20=20=20=20=20=20=20=20=20 - default: - D_CMD(__FUNCTION__", ogf %d, not recognised! \n", ogf); - break; - } -} =20 /*Parses an ACL-data packet and copies it into the hci_in-buffer, data is = a=20 pointer to the data in the memory, pb_flag is the packet boundary flag= =20 @@ -1419,24 +642,34 @@ return; } } - if (i >=3D MAX_NBR_OF_CONNECTIONS) { - D_ERR(__FUNCTION__", : Didn't find connection with con_hdl %d\n", con_hd= l); - } + + D_ERR(__FUNCTION__" : Didn't find connection with con_hdl %d\n",=20 + con_hdl); } =20 void set_hci_con_name(u8 *bd, u8 *name) { s32 i; + u8 len; =20 if (!name) { - D_ERR(__FUNCTION__", set_hci_con_name: No name defined\n"); + D_ERR(__FUNCTION__": No name defined\n"); return; } =20 + // "A UTF-8 encoded name can be up to 248 bytes in length. + // If it is shorter than 248 bytes, the end is indicated by + // a NULL bytes (0x00)" -- Bluetooth Core Spec 1.0b p. 714 + // We'll truncate the name if it's too long. + // --gmcnutt + + if ((len =3D strlen(name)) > 248) + len =3D 248; + for (i =3D 0; i < MAX_NBR_OF_CONNECTIONS; i++) { if (memcmp(hci_ctrl.con[i].bd, bd, 6) =3D=3D 0) { - strcpy(hci_ctrl.con[i].name, name); + memcpy(hci_ctrl.con[i].name, name, len); return; } } @@ -1576,87 +809,6 @@ } =20 void=20 -hci_init(void) -{ - u32 i; - - DSYS(__FUNCTION__", Initialising HCI\n"); - -#ifdef HCI_EMULATION - DSYS("*** HCI emulator on ***\n"); -#else - DSYS("HCI emulator off\n"); -#endif -=09 -#ifdef __KERNEL__ -#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0) - init_waitqueue_head(&hci_wq); - init_waitqueue_head(&inq_wq); - init_waitqueue_head(&set_baudrate_wq); - init_waitqueue_head(&test_wq); - sema_init(&hci_cmd_semaphore, 1); - sema_init(&hci_inq_semaphore, 1); -#endif /* LINUX_VERSION_CODE */ -#endif /* __KERNEL__ */ - - DSYS(__FUNCTION__", Initialising HCI inbuffers [%d]\n", HCI_IN_SIZE); - - /* Initiate the hci inbuffers */ - for (i =3D 0; i < NBR_OF_HCI_INBUFFERS; i++) { - hci_ctrl.hci_in_buf[i].buf_ptr =3D hci_ctrl.hci_in_buf[i].buf; - hci_ctrl.hci_in_buf[i].count =3D 0; - hci_ctrl.hci_in_buf[i].l2cap_len =3D 0; - hci_ctrl.hci_in_buf[i].empty =3D TRUE; - } -=09 - for (i =3D 0; i < MAX_NBR_OF_CONNECTIONS; i ++) { - hci_ctrl.con[i].state =3D NOT_CONNECTED; - hci_ctrl.con[i].con_hdl =3D -1; - } - -/* Here we set the buffer sizes to zero, just to avoid that they should get - undefined values if the initiating read buffersize fails */ - - hci_ctrl.hc_buf.acl_len =3D 0; - hci_ctrl.hc_buf.sco_len =3D 0; - hci_ctrl.hc_buf.acl_num =3D 0; - hci_ctrl.hc_buf.sco_num =3D 0; - - init_cmd_buf(); - - hci_ctrl.nbr_of_connections =3D 0; - hci_ctrl.hc_buf.cmd_num =3D 1; - -#ifdef __KERNEL__ - send_data_task.routine =3D (void*)send_acl_data_task; - send_data_task.data =3D NULL; -#endif - - /* always... */ - DSYS(__FUNCTION__", Reading buffer sizes in the module...\n"); - hci_read_buffer_size(HCI_BLOCK); - - hci_read_firmware_rev_info(); - -// hci_read_stored_link_key(NULL,1); - - //hci_write_authentication_enable(1); -#ifdef HOST_FLOW_CTRL - DSYS(__FUNCTION__", Host flow control enabled\n"); -#else - DSYS(__FUNCTION__", Host flow control not enabled\n"); -#endif -=09 - hci_set_host_controller_flow_control(TRUE); - - hci_host_buffer_size(HCI_ACL_LEN,HCI_SCO_LEN,HCI_ACL_NUM,HCI_SCO_NUM); - -#ifdef USE_NCPTIMER - start_ncp_timer();=09 -#endif -} - -void=20 hci_shutdown(void) { #ifdef USE_NCPTIMER @@ -1664,6 +816,10 @@ #endif } =20 +/*************************************************************************= ***/ +/*************************** HCI Commands ********************************= ***/ +/*************************************************************************= ***/ + /* Start of the definition of the functions performing all the different HCI commands. The functions will be defined in the same order as they a= re described in the HCI specification, part H:1 of the bluetooh core @@ -1672,57 +828,247 @@ =20 /* Definition of Link Control Commands */ =20 -/* This function will cause the Bluetooth device to enter Inquiry Mode. In= quiry - Mode is used to discover other nearby Bluetooth devices. The LAP input - parameter contains the LAP from which the inquiry access code shall be - derived when the inquiry procedure is made. The Inquiry_length parameter - specifies the total duration of the Inquiry Mode and, when this time=20 - expires, Inquiry will be halted. The Num_Responses parameter specifies= =20 - the number of responses that can be received before the Inquiry is halt= ed.*/ +#ifdef CONFIG_BLUETOOTH_HCI_INQUIRY /************************************= ***/ +// Adds about 1k =20 -inquiry_results*=20 -hci_inquiry(u8 *lap, u8 inq_len, u8 num_resp) +// See [BSC] Appendix VIII 1.1 +static const u8 GIAC[] =3D { 0x9e, 0x8b, 0x33 }; +static const u8 LIAC[] =3D { 0x9e, 0x8b, 0x00 }; + +static struct inquiry_results *pending_inq_res =3D NULL; +static u32 hci_inq_pending =3D 0; + +#ifdef __KERNEL__ +static struct timer_list hci_inq_timer; +DECLARE_SEMAPHORE(hci_inq_semaphore); +static void hci_inquiry_init(void) { - s32 tmp; + INIT_SEMAPHORE(hci_inq_semaphore, 1); +} +static void inq_timeout(unsigned long ptr) +{ + /* The command timed out, then we reset the command buffer counter to + 1 again */ + /* FIX ME: What to do here !! */ +/* hci_ctrl.hc_buf.cmd_num =3D 1;*/ + printk(__FUNCTION__", Timeout when waiting for inquiry response\n"); + hci_inq_pending =3D 0; + wake_up_interruptible(&inq_wq); +} +static void start_inq_timer(void) +{ + D_CMD(__FUNCTION__"\n"); + init_timer(&hci_inq_timer); + hci_inq_timer.function =3D inq_timeout; + hci_inq_timer.data =3D 0; + hci_inq_timer.expires =3D jiffies + 10*HZ; + add_timer(&hci_inq_timer); +} +static void release_inq_timer(void) +{ + D_CMD(__FUNCTION__"\n"); + del_timer(&hci_inq_timer); + hci_inq_pending =3D 0; +} +#else +#define inq_timeour(ptr) +#define start_inq_timer() +#define release_inq_timer() +#endif // __KERNEL__ +//------------------------------------------------------------------------= ----- +// hci_inquiry -- find other Bluetooth devices +// +// "This function will cause the Bluetooth device to enter Inquiry= =20 +// Mode. Inquiry Mode is used to discover other nearby Bluetooth= =20 +// devices. The LAP input parameter contains the LAP from which t= he=20 +// inquiry access code shall be derived when the inquiry procedur= e is=20 +// made. The Inquiry_length parameter specifies the total duratio= n of=20 +// the Inquiry Mode and, when this time expires, Inquiry will be= =20 +// halted. The Num_Responses parameter specifies the number of=20 +// responses that can be received before the Inquiry is halted." +// [BCS] 4.5.1 p= 542 +// +// This routine blocks the calling process until a) we receive the +// Inquiry Complete event b) the Command Status returns an error c) +// we time out waiting for Command Status or d) we timeout waiting +// for the Inquiry Complete event. +// +// Also, if another process has already started an HCI Inquiry then +// the calling process will proceed only after that inquiry comple= tes. +// +// PARMS +// lap Specifies the Inquiry Access Code (IAC) we'll use. All +// devices in range will respond to the General Inquiry Ac= cess +// Code (GIAC) (LAP =3D 0x9e8b33). The only other legal va= lue as +// of [BCS] is the Limited Dedicated Inquiry Access Code= =20 +// (LIAC) (LAP=3D0x9e8b00). +// +// inq_len +// The maximum amount of time spent before the h/w stops t= he +// inquiry. Units are 1.28 sec. Range: 0x01 - 0x30. +// REFERENCES +// [BCS] 4.2.1, 13.1, Appendix VIII 1.1 +//------------------------------------------------------------------------= ----- +int hci_inquiry(u8 *lap, u8 inq_len, u8 num_resp, inquiry_results *inq_res) +{ + int ret =3D 0; =20 - D_CMD(__FUNCTION__", Sending inquiry()\n"); +#ifdef __KERNEL__ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) + struct wait_queue wait =3D { current, NULL}; +#else + DECLARE_WAITQUEUE(wait, current); +#endif +#endif =20 - /* FIXME: Check if lap is valid first */ - /* Set default lap */ - lap[0] =3D 0x33; - lap[1] =3D 0x8b; - lap[2] =3D 0x9e; + D_CMD(__FUNCTION__ "\n"); =20 - /* Free any previous response */ - kfree(inq_res); + // Check for a valid LAP. + if (!memcmp(lap, GIAC, 3) && !memcmp(lap, LIAC, 3)) + return -EINVAL;=09 =20 - inq_res =3D (inquiry_results*) kmalloc(sizeof(inquiry_results) - + 6 * num_resp, GFP_ATOMIC); - if (!inq_res) - return NULL; +#ifdef __KERNEL__ + // Become the pending inquiry... + down(&hci_inq_semaphore); + pending_inq_res =3D inq_res; + hci_inq_pending =3D 1;=09 +#endif =20 inq_res->nbr_of_units =3D 0; =20 c_pkt.type =3D CMD_PKT; c_pkt.opcode =3D hci_put_opcode(INQUIRY, HCI_LC) ; - memcpy(c_pkt.data, lap, 3); c_pkt.data[3] =3D inq_len; c_pkt.data[4] =3D num_resp; c_pkt.len =3D 5; =20 - print_data("hci_inquiry", (u8*) &c_pkt ,c_pkt.len + CMD_HDR_LEN + HCI_HDR= _LEN); + PRINTPKT(__FUNCTION__, (u8*) &c_pkt ,c_pkt.len + CMD_HDR_LEN +=20 + HCI_HDR_LEN); =20 - tmp =3D send_inq_cmd_block((u8*) &c_pkt ,c_pkt.len + CMD_HDR_LEN + HCI_HD= R_LEN); + // Send the command and wait for the Command Status event + if ((ret =3D send_cmd_block((u8*)&c_pkt, c_pkt.len + CMD_HDR_LEN +=20 + HCI_HDR_LEN)) < 0) + goto exit; =20 - if (tmp < 0) { - kfree(inq_res); - inq_res =3D NULL; +#ifdef __KERNEL__ + // Now, if we didn't time out or cancel, we'll wait for the Inquiry=20 + // Complete event (or an inquiry result time out). + if (!hci_cmd_timeout && hci_inq_pending) { + add_wait_queue(&inq_wq, &wait); + current->state =3D TASK_INTERRUPTIBLE;=09=09 + start_inq_timer(); + + while (hci_inq_pending) + schedule();=09=09 + + remove_wait_queue(&inq_wq, &wait); + } else { + ret =3D -EAGAIN; } + pending_inq_res =3D NULL; + up(&hci_inq_semaphore); +#endif =20 - return inq_res; + exit: + return ret; +} +//------------------------------------------------------------------------= ----- +// inquiry_complete_handler +//=20=20=20=20=20=20=20=20=20 +// "The Inquiry Complete event indicates that the Inquiry is finis= hed." +// --Bluetooth Core Spec 1.0B +// +// We're done. Wake the process up. +// +// buf[0] =3D Status +// buf[1] =3D Num_Responses +//------------------------------------------------------------------------= ----- +static void inquiry_complete_handler(u8 *buf, u32 len) +{ + D_CMD(__FUNCTION__":%s\n", get_err_msg(buf[0])); + release_inq_timer(); + wake_up_interruptible(&inq_wq); } +//------------------------------------------------------------------------= ----- +// inquiry_result_handler +// +// "The Inquiry Result event indicates that a Bluetooth device or +// multiple Bluetooth devices have responded so far during the +// current Inquiry process." --Bluetooth Core Spec 1.0B +// +// We'll add the information to our pending inquiry data structure. +// +// buf[0] =3D Num_Responses +// buf[1-6] =3D BD_ADDR[0] +// buf[7] =3D Page_Scan_Repitition_Mode[0] +// buf[8] =3D Page_Scan_Period_Mode[0] +// buf[9] =3D Page_Scan_Mode[0] +// buf[10-12] =3D Class_Of_Device[0] +// buf[13] =3D Clock_Offset[0] +// buf[14] =3D BD_ADDR[1] +// ... (etc for the remaining responses) +// +// REVISIT We're ignoring all the information except for the BD=20 +// address. Presumably apps will want the rest of the info, +// to... +// +//------------------------------------------------------------------------= ----- +static void inquiry_result_handler(u8 *buf, u32 len) +{ + + s32 i, j; + u8 tmp_bd[6]; +=09 + D_CMD(__FUNCTION__"\n"); + + // for each response address in the result... + for(i =3D 1; i < (buf[0] * 14) + 1; i +=3D 14) { +=09=09=09 + // reverse the address into a tmp buffer + for (j =3D 0; j < 6; j++) tmp_bd[5-j] =3D buf[i + j]; + + // check if we already have that address listed + for (j =3D 0; j < pending_inq_res->nbr_of_units; j++) { + if (!memcmp(pending_inq_res->bd_addr +=20 + pending_inq_res->nbr_of_units * 6, tmp_bd, + 6)) { + j =3D pending_inq_res->nbr_of_units; + } + } =20 + // if not then add it to the back of the list + if (j >=3D pending_inq_res->nbr_of_units) { + memcpy(pending_inq_res->bd_addr +=20 + pending_inq_res->nbr_of_units * 6, tmp_bd, 6); + pending_inq_res->nbr_of_units +=3D 1; + } + } +} +//------------------------------------------------------------------------= ----- +// inquiry_status_handler +// +// The Host Controller has started the Inquiry or determined that = it +// can't due to some error. If there was an error then we need to +// wake the inquiring process up. +// +//------------------------------------------------------------------------= ----- +static void inquiry_status_handler(u8 *buf) +{ + if (buf[0]) { + D_ERR(__FUNCTION__ ":%s\n", get_err_msg(buf[0])); + hci_inq_pending =3D 0; + wake_up_interruptible(&inq_wq); + } +} +#else +#define hci_inquiry_init() +#define inquiry_complete_handler NULL +#define inquiry_result_handler NULL +#define inquiry_status_handler NULL +#endif /* CONFIG_BLUETOOTH_INQUIRY **************************************= ***/ + + /* This function will cause the Link Manager to create a connection to the Bluetooth device with the BD_ADDR specified by the function parameters. This function causes the local Bluetooth device to begin the Page proce= ss @@ -1750,10 +1096,9 @@ =20 return send_cmd((u8*) &c_pkt ,c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);=20= =20 } - =20 -s32 -hci_add_sco_connection(u32 hci_hdl) +#ifdef CONFIG_BLUETOOTH_SCO /* Add_SCO_Connection ************************= ***/ +int hci_add_sco_connection(u32 hci_hdl) { D_CMD(__FUNCTION__"\n"); c_pkt.type =3D CMD_PKT; @@ -1767,6 +1112,7 @@ =20 return send_cmd_block((u8*) &c_pkt ,c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN= ); } +#endif /* Add_SCO_Connection *********************************************= ***/ =20 /* The Hci_Disconnect function is used to terminate an existing connection. The Connection_Handle function parameter indicates which connection is = to be @@ -2539,7 +1885,6 @@ s32 tmp; =20=09 D_CMD(__FUNCTION__", hci_hdl:0x%x, for %d packets\n", hci_hdl,nbr_of_pack= ets); - c_pkt.type =3D CMD_PKT; c_pkt.opcode =3D hci_put_opcode(HOST_NUMBER_OF_COMPLETED_PACKETS, HCI_HC)= ; =20 @@ -2550,7 +1895,6 @@ c_pkt.data[4] =3D ((nbr_of_packets >> 8) & 0xff); c_pkt.len =3D 5; =20 -=09 /*FIXME Risk for race against sending acl packets ? */ //printk("Host pkt start\n"); tmp =3D bt_write_lower_driver((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI= _HDR_LEN); @@ -2624,7 +1968,6 @@ { /* Consider changing bd to BD_ADDR */ s32 tmp; - D_CMD(__FUNCTION__"\n"); c_pkt.type =3D CMD_PKT; c_pkt.opcode =3D hci_put_opcode(READ_BD_ADDR, HCI_IP) ; @@ -2812,7 +2155,9 @@ =20 #ifdef __KERNEL__ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) + printk(__FUNCTION__ ": queueing task...\n"); // gjm queue_task(&send_data_task, &tq_scheduler); + printk(__FUNCTION__ ": ...done queueing task\n"); // gjm #else queue_task(&send_data_task, &tq_immediate); mark_bh(IMMEDIATE_BH); @@ -3300,7 +2645,7 @@ queue_task(&send_cmd_task, &tq_immediate); mark_bh(IMMEDIATE_BH); #endif /* LINUX_VERSION_CODE */ -#else +#else /* __KERNEL__ */ send_cmd_queue(); #ifdef HCI_EMULATION hci_cmd_pending =3D 0; @@ -3416,11 +2761,18 @@ start_cmd_timer(void) { #ifdef __KERNEL__ + // NOTE The caller should have locked out interrupts. + D_CTRL(__FUNCTION__"\n"); init_timer(&hci_cmd_timer); hci_cmd_timer.function =3D cmd_timeout; hci_cmd_timer.data =3D 0; hci_cmd_timer.expires =3D jiffies + 3*HZ; + + if (cmd_timer_active)=20 + D_ERR(__FUNCTION__":cmd_timer_active still set!\n"); + cmd_timer_active =3D 1; + add_timer(&hci_cmd_timer); #endif } @@ -3430,7 +2782,14 @@ release_cmd_timer(void) { #ifdef __KERNEL__ + // NOTE The caller should have locked out interrupts. + D_CTRL(__FUNCTION__"\n"); + + if (!cmd_timer_active)=20 + D_ERR(__FUNCTION__":cmd_timer_active not set!\n"); + cmd_timer_active =3D 0; + del_timer(&hci_cmd_timer); #endif hci_cmd_pending =3D 0; @@ -3446,56 +2805,24 @@ =20=09 printk(__FUNCTION__", Timeout when waiting for command response\n"); hci_cmd_pending =3D 0; - wake_up_interruptible(&hci_wq); -} -#endif =20 -#ifdef USE_INQTIMER -static void + if (!cmd_timer_active)=20 + D_ERR(__FUNCTION__":cmd_timer_active not set!\n"); + cli(); + cmd_timer_active =3D 0; + sti(); =20 -start_inq_timer(void) -{ -#ifdef __KERNEL__ - D_CMD(__FUNCTION__"\n"); - init_timer(&hci_inq_timer); - hci_inq_timer.function =3D inq_timeout; - hci_inq_timer.data =3D 0; - hci_inq_timer.expires =3D jiffies + 10*HZ; - add_timer(&hci_inq_timer); -#endif + hci_cmd_timeout =3D 1; + wake_up_interruptible(&hci_wq); } - -static void -release_inq_timer(void) -{ -#ifdef __KERNEL__ - D_CMD(__FUNCTION__"\n"); - del_timer(&hci_inq_timer); #endif - hci_inq_pending =3D 0; -} =20 -#ifdef __KERNEL__ -static void -inq_timeout(unsigned long ptr) -{ - /* The command timed out, then we reset the command buffer counter to - 1 again */ - /* FIX ME: What to do here !! */ -/* hci_ctrl.hc_buf.cmd_num =3D 1;*/ =20 - printk(__FUNCTION__", Timeout when waiting for inquiry response\n"); - hci_inq_pending =3D 0; - wake_up_interruptible(&inq_wq); -} -#endif -#endif /* USE_INQTIMER */ - =20 s32=20 send_cmd_block(u8 *cmd, u8 len) { - u32 tmp; + s32 tmp; =20 #ifdef __KERNEL__ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) @@ -3508,12 +2835,15 @@ =20 add_wait_queue(&hci_wq, &wait); current->state =3D TASK_INTERRUPTIBLE; + hci_cmd_timeout =3D 0; =20 -#endif +#endif /* __ KERNEL__ */ hci_cmd_pending =3D 1; =20=20=20 - start_cmd_timer(); tmp =3D send_cmd(cmd, len); + cli(); + start_cmd_timer(); + sti(); =20=20=20 #ifdef __KERNEL__ while (hci_cmd_pending) @@ -3529,38 +2859,6 @@ return tmp; } =20 -s32=20 -send_inq_cmd_block(u8 *cmd, u8 len) -{ - u32 tmp; -#ifdef __KERNEL__ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) - struct wait_queue wait =3D { current, NULL}; -#else - DECLARE_WAITQUEUE(wait, current); -#endif - - down(&hci_inq_semaphore); - - add_wait_queue(&inq_wq, &wait); - current->state =3D TASK_INTERRUPTIBLE; - - hci_inq_pending =3D 1; -#endif - - /*FIXME: currently we have no timer for inquiry */ - tmp =3D send_cmd(cmd, len); -=20=20 -#ifdef __KERNEL__ - while (hci_inq_pending) - schedule(); - - remove_wait_queue(&inq_wq, &wait); - - up(&hci_inq_semaphore); -#endif - return tmp; -} =20 #if 0 /* Used for testing */ @@ -3581,5 +2879,960 @@ printk("------------------------------------------\n"); } #endif + +//------------------------------------------------------------------------= ----- +// Command Complete Parameter Handlers +// process_return_param() calls these functions when we receive a +// Command Complete Event. It first uses the OGF of the command op= code +// to index into the OGF handler table. Then each OGF handler uses= the +// OCF of the opcode to pick an OCF handler. +// +// In all cases the 'buf' argument to the param handlers is the st= art +// of the Return_Parameters section of the HCI packet. +// +// REVISIT Investigate consolidating all the OGF handlers into one routine. +//------------------------------------------------------------------------= ----- + +typedef void (*param_handler_t)(u8 *buf); + +static void default_param_handler(u8 *buf) +{ + // buf[0] =3D Status + + D_CMD(__FUNCTION__ ": %s\n", get_err_msg(buf[0]));=09 + result_param =3D - buf[0]; +} + +static void null_param_handler(u8 *buf) {} + + +//------------------------------------------------------------------------= ----- +// Link Control Command Result Param handlers +//------------------------------------------------------------------------= ----- +#define inquiry_cancel_param_handler NULL // command never sent +#define periodic_inquiry_mod_param_handler NULL // command never sent +#define exit_periodic_inquiry_mod_param_handler NULL // command never sent +#define create_connection_param_handler null_param_handler +#define disconnect_param_handler null_param_handler +#define add_sco_connection_param_handler null_param_handler +#define accept_connection_request_param_handler null_param_handler +#define reject_connection_request_param_handler null_param_handler +#define link_key_request_reply_param_handler default_param_handler +#define link_key_request_negative_reply_param_handler default_param_handler +#define pin_code_request_reply_param_handler default_param_handler +#define pin_code_request_negative_reply_param_handler default_param_handler +#define change_connection_packet_type_param_handler null_param_handler +#define authentication_requested_param_handler null_param_handler +#define set_connection_encryption_param_handler null_param_handler +#define change_connection_link_key_param_handler NULL // command never sent +#define master_link_key_param_handler NULL // command never sent +#define remote_name_request_param_handler null_param_handler +#define read_remote_supported_features_param_handler NULL // co... [truncated message content] |
From: Peter K. <pk...@us...> - 2001-03-27 19:32:30
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bluetooth.c 1.154 1.155=20=20=20=20=20=20=20=20=20=20=20 l2cap.c 1.93 1.94=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Improved LED blink. The diff of the modified file(s): --- bluetooth.c 2001/03/20 15:29:49 1.154 +++ bluetooth.c 2001/03/27 19:32:27 1.155 @@ -162,11 +162,18 @@ =20 #ifdef __CRIS__ #define BT_FLASH_LED_TIME (HZ/50) /* 20 ms */ +#define BT_FLASH_LED_PAUSE (HZ/100) /* 10 ms */ + +#define NO_BLUETOOTH_ACTIVITY 0 +#define BLUETOOTH_ACTIVITY 1 =20 static struct timer_list bt_clear_led_timer; -static int bt_led_clear_time; +static int bt_led_next_time; +static int bt_led_active; static void bt_clear_led(unsigned long dummy); +static void bt_set_leds(int active); #endif + static void bt_flash_led(void); =20 #ifdef CONFIG_BLUETOOTH_USE_INBUFFER @@ -1835,20 +1842,48 @@ static void bt_clear_led(unsigned long dummy) { - if (jiffies > bt_led_clear_time) - LED_ACTIVE_SET(0); + if (bt_led_active && jiffies > bt_led_next_time) { + bt_set_leds(NO_BLUETOOTH_ACTIVITY); + + /* Set the earliest time we may set the LED */ + bt_led_next_time =3D jiffies + BT_FLASH_LED_PAUSE; + bt_led_active =3D 0; + } + bt_clear_led_timer.expires =3D jiffies + HZ/10; add_timer(&bt_clear_led_timer); } =20 -void bt_flash_led(void) +static void +bt_flash_led(void) { - LED_ACTIVE_SET(1); - bt_led_clear_time =3D jiffies + BT_FLASH_LED_TIME;=20 + if (!bt_led_active && jiffies > bt_led_next_time) { + bt_set_leds(BLUETOOTH_ACTIVITY); + + /* Set the earliest time we may clear the LED */ + bt_led_next_time =3D jiffies + BT_FLASH_LED_TIME; + bt_led_active =3D 1; + } +} + +static void +bt_set_leds(int active) +{ + extern int bt_connections; + int light_leds =3D ((!bt_connections && active =3D=3D BLUETOOTH_ACTIVITY)= || + (bt_connections && active =3D=3D NO_BLUETOOTH_ACTIVITY)); + + if (light_leds) { + LED_ACTIVE_SET(LED_GREEN); + } + else { + LED_ACTIVE_SET(LED_OFF); + } } =20 #else -void bt_flash_led(void) +static void +bt_flash_led(void) { /* blink blink :) */ } --- l2cap.c 2001/03/12 16:09:37 1.93 +++ l2cap.c 2001/03/27 19:32:28 1.94 @@ -253,6 +253,10 @@ =20 /****************** GLOBAL VARIABLE DECLARATION SECTION ******************= ***/ =20 +#ifdef __CRIS__ +int bt_connections =3D 0; +#endif + /****************** LOCAL VARIABLE DECLARATION SECTION *******************= ***/ =20 static l2cap_layer l2capmain; /* Main structure */ @@ -275,6 +279,10 @@ init_con_list(); l2cap->cid_count =3D MIN_CID; /* Moved from init_con_list */ =20=20=20=20=20=20=20=20=20 +#ifdef __CRIS__ + bt_connections =3D 0; +#endif + /* Set all upper layers to default */ =20 l2cap_protocol_default(&default_protocol); @@ -361,6 +369,11 @@ =20 free_list(); remove_all_upper(); + +#ifdef __CRIS__ + bt_connections =3D 0; +#endif + /*ALWAYS SUCCESS*/ return 0; } @@ -1315,6 +1328,10 @@ con->hci_hdl =3D con_hdl; con->link_up =3D TRUE; =20 +#ifdef __CRIS__ + bt_connections++; +#endif +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 /* Check if a ping is to be sent */ if (con->ping_sent) { D_STATE("baseband up, now send ping\n"); @@ -1427,7 +1444,13 @@ /* flush old buffers waiting to be sent on this handle */ btmem_flushhandle((u16)con_hdl); //btmem_reset(); - return; + +#ifdef __CRIS__ + if (bt_connections > 0) + bt_connections--; + else + D_ERR(__FUNCTION__ ": bt_connections =3D=3D 0\n"); +#endif } =20 /* FIXME - lp_qos_violation_ind() */ |
From: Peter K. <pk...@us...> - 2001-03-30 06:17:24
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- Config.in 1.8 1.9=20=20=20=20=20=20=20=20=20=20=20=20=20 bluetooth.c 1.155 1.156=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Allow pin G11 to be used for reset of the Bluetooth hardware too. The diff of the modified file(s): --- Config.in 2001/03/21 16:27:39 1.8 +++ Config.in 2001/03/30 06:17:19 1.9 @@ -32,7 +32,8 @@ "None CONFIG_BLUETOOTH_RESET_NONE \ Port_PA_Bit_7 CONFIG_BLUETOOTH_RESET_PA7 \ Port_PB_Bit_5 CONFIG_BLUETOOTH_RESET_PB5 \ - Port_G_Bit_10 CONFIG_BLUETOOTH_RESET_G10" None + Port_G_Bit_10 CONFIG_BLUETOOTH_RESET_G10 \ + Port_G_Bit_11 CONFIG_BLUETOOTH_RESET_G11" None fi =20 endmenu --- bluetooth.c 2001/03/27 19:32:27 1.155 +++ bluetooth.c 2001/03/30 06:17:19 1.156 @@ -668,6 +668,18 @@ udelay(1000); REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 10, 1); #endif +#elif defined(CONFIG_BLUETOOTH_RESET_G11) +#if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH) + BT_DRIVER(FNC"Resetting hardware (G11) Active High\n"); + REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 11, 1); + udelay(1000); + REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 11, 0); +#else + BT_DRIVER(FNC"Resetting hardware (G11) Active Low\n "); + REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 11, 0); + udelay(1000); + REG_SHADOW_SET(R_PORT_G_DATA, port_g_data_shadow, 11, 1); +#endif #else D_ERR(FNC"Resetting hardware : No reset pin defined\n"); #endif |
From: Peter K. <pk...@us...> - 2001-04-12 15:56:42
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bluetooth.c 1.155 1.155.2.1=20=20=20=20=20=20=20 rfcomm.c 1.95 1.95.4.1=20=20=20=20=20=20=20=20 The accompanying log: Branch to fix disconnection of Bluetooth connection in R2_1_11. The diff of the modified file(s): --- bluetooth.c 2001/03/27 19:32:27 1.155 +++ bluetooth.c 2001/04/12 15:56:40 1.155.2.1 @@ -466,6 +466,7 @@ static void bt_flush_buffer(struct tty_struct *tty) { +#if 0=09 bt_tx_buf* tx_buf; =20 BT_DRIVER("bt_flush_buffer\n"); @@ -473,6 +474,7 @@ while ((tx_buf =3D get_bt_buf())) { unsubscribe_bt_buf(tx_buf); } +#endif } =20 static s32 @@ -2378,6 +2380,11 @@ D_WARN("bt_unregister_rfcomm : inactive session\n"); return -1; } + + /* notify upper tty that this rfcomm connection is down */ +#ifdef __KERNEL__ + bt_hangupline(line); +#endif return 0; } =20 --- rfcomm.c 2001/03/12 15:54:35 1.95 +++ rfcomm.c 2001/04/12 15:56:40 1.95.4.1 @@ -975,31 +975,30 @@ void=20 rfcomm_disconnect_ind(l2cap_con *l2cap) { -#define FNC "rfcomm_disconnect_ind: " rfcomm_con *rfcomm; =20 - D_CTRL(FNC"remote cid %d\n", l2cap->remote_cid); + D_CTRL(__FUNCTION__" remote cid %d\n", l2cap->remote_cid); =20 rfcomm =3D ((rfcomm_con*) l2cap->upper_con); =20 - if (l2ca_disconnect_rsp(l2cap)) { - D_ERR(FNC"l2ca_disconnect_rsp failed\n"); - return; - } + /* This l2cap connection is going down, remove all rfcomm cons=20 + and notify upper tty */ =20 + if (!l2cap->link_up) + { + DSYS("Baseband is down, reset this RFCOMM session\n"); #ifdef __KERNEL__ - bt_unregister_rfcomm(rfcomm->line); - - /* notify upper tty that this rfcomm connection is down */ - bt_hangupline(rfcomm->line); -#else - bt_disconnect_ind(CREATE_RFCOMM_ID(rfcomm->line, 0)); #endif -=09 + bt_disconnect_ind(CREATE_RFCOMM_ID(rfcomm->line, 0)); rfcomm_reset_con(rfcomm->line); + } =20=09 -#undef FNC + /* always try to send back rsp (if link is down con is deleted) */ + if (l2ca_disconnect_rsp(l2cap)) { + D_ERR(__FUNCTION__" l2ca_disconnect_rsp failed\n"); + return; + } } =20 void=20 @@ -1013,8 +1012,17 @@ =20 rfcomm =3D (rfcomm_con*) l2cap->upper_con; =20 + /* fixme -- should we indicate to bt interface when rfcomm is=20 + down or when l2cap for rfcomm is down ? */ bt_disconnect_ind(CREATE_RFCOMM_ID(rfcomm->line, 0)); =20=09 + /* fixme -- add these glue layer functions in userstack */ +#ifdef __KERNEL__ + bt_unregister_rfcomm(rfcomm->line); + + /* wake up bt line */ + bt_disconnect_cfm(CREATE_RFCOMM_ID(rfcomm->line, 0), 0); +#endif=09 rfcomm_reset_con(rfcomm->line); =20=09 #undef FNC @@ -1154,6 +1162,7 @@ =20 } else if (rfcomm->dlci[tmp_dlci].state =3D=3D DISCONNECTING) { if (tmp_dlci =3D=3D 0) { + rfcomm->dlci[0].state =3D DISCONNECTED; #ifdef __KERNEL__=20=20 wake_up_interruptible(&rfcomm_disconnect_wq); #else @@ -1197,6 +1206,8 @@ Tell the tty that the link is down */ send_ua(rfcomm, tmp_dlci); bt_disconnect_ind(CREATE_RFCOMM_ID(rfcomm->line, 0)); + bt_unregister_rfcomm(rfcomm->line); + } else { rfcomm->dlci[tmp_dlci].state =3D DISCONNECTED; send_ua(rfcomm, tmp_dlci); |
From: Gordon M. <gm...@us...> - 2001-04-18 00:54:07
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bluetooth.c 1.166 1.167=20=20=20=20=20=20=20=20=20=20=20 hci.c 1.139 1.140=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Fixed the hci_inquiry hang (hopefully). The diff of the modified file(s): --- bluetooth.c 2001/04/17 23:50:26 1.166 +++ bluetooth.c 2001/04/18 00:53:37 1.167 @@ -706,7 +706,7 @@ extern void test_process_cmd(unsigned char *cmd, s32 size); u8 cmd[size]; copy_from_user(cmd, (s32*)arg, size); - printk("TEST_COMMAND %d %d\n", cmd, size); + printk("TEST_COMMAND %d %d\n", (int)cmd, (int)size); test_process_cmd(cmd, size); } =20 @@ -719,13 +719,31 @@ inquiry_results *inq_res; s32 in_param[2]; u8 lap[3]; + int ret; =20=09=09 BT_DRIVER(FNC"HCINQUIRY\n"); =20=09=09 copy_from_user(in_param, (s32*)arg, 8); - if (!(inq_res =3D hci_inquiry(lap, in_param[1] , in_param[0]))) - return -ENOMEM; - copy_to_user((s32*)arg, inq_res, size + 6 * inq_res->nbr_of_units); + + if ((inq_res =3D=20 + (inquiry_results*) kmalloc(sizeof(inquiry_results) + + 6 * in_param[0],=20 + GFP_ATOMIC)) < 0) { + ret =3D -ENOMEM; + goto hci_inq_exit0; + } + + if ((ret =3D hci_inquiry(lap, in_param[1], in_param[0], + inq_res)) < 0) + goto hci_inq_exit1; + + copy_to_user((s32*)arg, inq_res, size + 6 *=20 + inq_res->nbr_of_units); +=09=09 + hci_inq_exit1: + kfree(inq_res);=09=09 + hci_inq_exit0: + return ret; break; } =20=09 --- hci.c 2001/04/17 12:04:00 1.139 +++ hci.c 2001/04/18 00:53:37 1.140 @@ -191,7 +191,7 @@ static void init_cmd_buf(void); static void send_cmd_queue(void); static void update_nhcp(s32 nhcp); -static s32 send_inq_cmd_block(u8 *cmd, u8 len); +static s32 send_inq_cmd_block(u8 *cmd, u8 len, u8 inq_len); #ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER static u8* get_bd(u16 con_hdl); #endif @@ -229,8 +229,9 @@ static void release_ncp_timer(void); #endif =20 +#define USE_INQTIMER 1 #ifdef USE_INQTIMER -static void start_inq_timer(void); +static void start_inq_timer(u8 inq_len); static void release_inq_timer(void); #endif =20 @@ -303,6 +304,7 @@ =20 static u32 hci_cmd_pending =3D 0; static u32 hci_inq_pending =3D 0; +static u8 hci_inq_aborted =3D 0; =20 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) struct wait_queue *hci_wq =3D NULL; @@ -640,6 +642,9 @@ case INQUIRY_COMPLETE: D_CMD("INQUIRY_COMPLETE\n"); hci_inq_pending =3D 0; +#if USE_INQTIMER + release_inq_timer(); +#endif wake_up_interruptible(&inq_wq); #ifndef __KERNEL__ for (i =3D 0; i < inq_res->nbr_of_units; i++) { @@ -665,12 +670,15 @@ } print_data("BD",tmp_bd, 6); for (j =3D 0; j < inq_res->nbr_of_units; j++) { - if (!memcmp(inq_res->bd_addr + inq_res->nbr_of_units * 6, tmp_bd, 6)) { + if (!memcmp(inq_res->bd_addr +=20 + inq_res->nbr_of_units * 6, tmp_bd, + 6)) { j =3D inq_res->nbr_of_units; } } if (j >=3D inq_res->nbr_of_units) { - memcpy(inq_res->bd_addr + inq_res->nbr_of_units * 6, tmp_bd, 6); + memcpy(inq_res->bd_addr +=20 + inq_res->nbr_of_units * 6, tmp_bd, 6); inq_res->nbr_of_units +=3D 1; } } @@ -843,6 +851,10 @@ =20=09=09 if (buf[0]) { D_ERR(__FUNCTION__", COMMAND_STATUS: %s\n",get_err_msg(buf[0])); +#ifdef USE_INQTIMER + if (hci_inq_pending) + release_inq_timer(); +#endif } =20=09=09 update_nhcp(buf[1]); @@ -1750,27 +1762,23 @@ expires, Inquiry will be halted. The Num_Responses parameter specifies= =20 the number of responses that can be received before the Inquiry is halt= ed.*/ =20 -inquiry_results*=20 -hci_inquiry(u8 *lap, u8 inq_len, u8 num_resp) +int hci_inquiry(u8 *lap, u8 inq_len, u8 num_resp, inquiry_results *results) { s32 tmp; =20 D_CMD(__FUNCTION__", Sending inquiry()\n"); =20 + if (!results) + return -EINVAL; + + inq_res =3D results; + /* FIXME: Check if lap is valid first */ /* Set default lap */ lap[0] =3D 0x33; lap[1] =3D 0x8b; lap[2] =3D 0x9e; =20 - /* Free any previous response */ - kfree(inq_res); -=09 - inq_res =3D (inquiry_results*) kmalloc(sizeof(inquiry_results) - + 6 * num_resp, GFP_ATOMIC); - if (!inq_res) - return NULL; - inq_res->nbr_of_units =3D 0; =20 c_pkt.type =3D CMD_PKT; @@ -1785,14 +1793,10 @@ c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN); =20 tmp =3D send_inq_cmd_block((u8*) &c_pkt,=20 - c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN); - - if (tmp < 0) { - kfree(inq_res); - inq_res =3D NULL; - } + c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN, + inq_len); =20 - return inq_res; + return tmp; } =20 /* This function will cause the Link Manager to create a connection to the @@ -3556,14 +3560,15 @@ #ifdef USE_INQTIMER static void =20 -start_inq_timer(void) +start_inq_timer(u8 inq_len) { #ifdef __KERNEL__ +#define INQ_FUDGE_FACTOR (2 * HZ) D_CMD(__FUNCTION__"\n"); init_timer(&hci_inq_timer); hci_inq_timer.function =3D inq_timeout; hci_inq_timer.data =3D 0; - hci_inq_timer.expires =3D jiffies + 10*HZ; + hci_inq_timer.expires =3D jiffies + inq_len * INQ_FUDGE_FACTOR; add_timer(&hci_inq_timer); #endif } @@ -3590,6 +3595,7 @@ =20 printk(__FUNCTION__", Timeout when waiting for inquiry response\n"); hci_inq_pending =3D 0; + hci_inq_aborted =3D 1; wake_up_interruptible(&inq_wq); } #endif @@ -3633,9 +3639,10 @@ } =20 s32=20 -send_inq_cmd_block(u8 *cmd, u8 len) +send_inq_cmd_block(u8 *cmd, u8 len, u8 inq_len) { u32 tmp; + #ifdef __KERNEL__ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) struct wait_queue wait =3D { current, NULL}; @@ -3644,24 +3651,35 @@ #endif =20 down(&hci_inq_semaphore); - add_wait_queue(&inq_wq, &wait); current->state =3D TASK_INTERRUPTIBLE; - hci_inq_pending =3D 1; -#endif =20 - /*FIXME: currently we have no timer for inquiry */ - tmp =3D send_cmd(cmd, len); + if ((tmp =3D send_cmd(cmd, len)) < 0) + goto inq_done; =20=20=20 -#ifdef __KERNEL__ +#ifdef USE_INQTIMER + hci_inq_aborted =3D 0; + start_inq_timer(inq_len); +#endif while (hci_inq_pending) schedule(); =20 - remove_wait_queue(&inq_wq, &wait); +#ifdef USE_INQTIMER + if (hci_inq_aborted) + tmp =3D -ETIME; +#endif =20 + inq_done: + remove_wait_queue(&inq_wq, &wait); up(&hci_inq_semaphore); -#endif + +#else /* __KERNEL__ */ + + tmp =3D send_cmd(cmd, len); + +#endif /* __KERNEL__ */ + return tmp; } =20 |
From: Peter K. <pk...@us...> - 2001-04-18 14:45:22
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bluetooth.c 1.167 1.168=20=20=20=20=20=20=20=20=20=20=20 hci_vendor.c 1.24 1.25=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Removed bt_show_vendor(). The diff of the modified file(s): --- bluetooth.c 2001/04/18 00:53:37 1.167 +++ bluetooth.c 2001/04/18 14:45:21 1.168 @@ -2255,7 +2255,8 @@ =20=09 DSYS("Initialising Bluetooth Stack\n"); =20 - bt_show_vendor(); + DSYS("Current HW: %s\n", bt_hw_vendor()); + hci_init(); l2cap_init(); =20 --- hci_vendor.c 2001/04/17 21:55:56 1.24 +++ hci_vendor.c 2001/04/18 14:45:21 1.25 @@ -494,20 +494,22 @@ char* bt_hw_vendor(void) { - return "Unknown hardware"; +#if defined(CONFIG_BLUETOOTH_USB) + return "USB"; +#elif defined(CONFIG_BLUETOOTH_GENERIC) + return "Generic"; +#else + return "Unknown"; +#endif } #endif =20 +/*************************************************************************= ****/ + char* bt_hw_firmware(void) { return bt_hw_firmware_info; -} - -void -bt_show_vendor(void) -{ - DSYS("Current HW: %s\n", VENDOR); } =20 /********************* END OF FILE hci_vendor.c **************************= ****/ |
From: Peter K. <pk...@us...> - 2001-04-19 10:32:05
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- l2cap.c 1.100 1.101=20=20=20=20=20=20=20=20=20=20=20 l2cap_con.c 1.8 1.9=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * Renamed free_list() to free_con_list(). * Redefined FLAG_* defines to more sensible values. The diff of the modified file(s): --- l2cap.c 2001/04/18 14:25:30 1.100 +++ l2cap.c 2001/04/19 10:31:34 1.101 @@ -361,7 +361,7 @@ } #endif =20 - free_list(); + free_con_list(); remove_all_upper(); =20 #ifdef __CRIS__ --- l2cap_con.c 2001/04/19 10:29:14 1.8 +++ l2cap_con.c 2001/04/19 10:31:34 1.9 @@ -130,7 +130,7 @@ } =20 void=20 -free_list(void) +free_con_list(void) { D_CON(__FUNCTION__ ": Freeing connection list\n"); while (con_list.count) @@ -550,7 +550,7 @@ show_list(); remove_rcid(5); show_list(); - free_list(); + free_con_list(); show_list(); /* ... */ } |
From: Ulf H. <ul...@us...> - 2001-04-26 13:33:27
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- l2cap.c 1.106 1.107=20=20=20=20=20=20=20=20=20=20=20 l2cap_con.c 1.9 1.10=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Moved functions from l2cap_con to l2cap The diff of the modified file(s): --- l2cap.c 2001/04/25 17:12:48 1.106 +++ l2cap.c 2001/04/26 13:33:26 1.107 @@ -1847,6 +1847,43 @@ return result;=20=20=20=20 } =20 +/* only supports one call at a time */ +void +l2ca_wait(const char *str, l2cap_con *con) +{ + if (!(con->c_flags & FLAG_WAKEMEUP)) { + if (con->c_flags & FLAG_DONTSLEEP) { + printk("l2ca_wait : don't sleep flag set\n"); + return; + } + + con->c_flags |=3D FLAG_WAKEMEUP; + printk("%s, sleep on wq 0x%x\n", str, (int)&con->wq); + interruptible_sleep_on(&con->wq); + printk("%s, woke up !\n", str); + } else { + printk("%s, wq already in use\n", str); + } +} + +void=20 +l2ca_wakeup(const char *str, l2cap_con *con) +{ + if (con->c_flags & FLAG_WAKEMEUP) { + if (con->c_flags & FLAG_DONTSLEEP) { + printk("l2ca_wakeup : don't sleep flag set\n"); + con->c_flags &=3D ~FLAG_DONTSLEEP; + return; + } + + con->c_flags &=3D ~FLAG_WAKEMEUP; + printk("%s, wake up wq 0x%x\n", str,(int)&con->wq); + wake_up_interruptible(&con->wq); + } else { + printk("%s, wake up flag not set\n", str); + } +} + /*******************************************************************/ /* (E5) Timer events */ /********************/ --- l2cap_con.c 2001/04/19 10:31:34 1.9 +++ l2cap_con.c 2001/04/26 13:33:26 1.10 @@ -479,43 +479,6 @@ return sum; } =20 -/* only supports one call at a time */ -void -l2ca_wait(const char *str, l2cap_con *con) -{ - if (!(con->c_flags & FLAG_WAKEMEUP)) { - if (con->c_flags & FLAG_DONTSLEEP) { - printk("l2ca_wait : don't sleep flag set\n"); - return; - } - - con->c_flags |=3D FLAG_WAKEMEUP; - printk("%s, sleep on wq 0x%x\n", str, (int)&con->wq); - interruptible_sleep_on(&con->wq); - printk("%s, woke up !\n", str); - } else { - printk("%s, wq already in use\n", str); - } -} - -void=20 -l2ca_wakeup(const char *str, l2cap_con *con) -{ - if (con->c_flags & FLAG_WAKEMEUP) { - if (con->c_flags & FLAG_DONTSLEEP) { - printk("l2ca_wakeup : don't sleep flag set\n"); - con->c_flags &=3D ~FLAG_DONTSLEEP; - return; - } - - con->c_flags &=3D ~FLAG_WAKEMEUP; - printk("%s, wake up wq 0x%x\n", str,(int)&con->wq); - wake_up_interruptible(&con->wq); - } else { - printk("%s, wake up flag not set\n", str); - } -} - #if L2CAP_SELFTEST s32=20 remove_rcid(CID rcid) /* Searches for remote_cid */ |
From: Peter K. <pk...@us...> - 2001-04-26 16:43:58
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- Config.in 1.10 1.11=20=20=20=20=20=20=20=20=20=20=20=20 hci.c 1.143 1.144=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Set CONFIG_BLUETOOTH_EARLY_MSSWITCH in Config.in instead. The diff of the modified file(s): --- Config.in 2001/03/30 11:31:55 1.10 +++ Config.in 2001/04/26 16:43:56 1.11 @@ -6,16 +6,7 @@ =20 tristate 'Bluetooth driver' CONFIG_BLUETOOTH =20 -if [ "$CONFIG_BLUETOOTH" !=3D "n" ]; then - - bool ' Bluetooth proc entries' CONFIG_BLUETOOTH_PROC - bool ' Input buffering' CONFIG_BLUETOOTH_USE_INBUFFER - bool ' Use Security Manager' CONFIG_BLUETOOTH_USE_SECURITY_MANAGER - bool ' Use L2CAP timers' CONFIG_BLUETOOTH_L2CAP_USE_TIMERS - bool ' Allow connectionless L2CAP' CONFIG_BLUETOOTH_L2CAP_CONNECTIONLESS - bool ' Enable TCI' CONFIG_BLUETOOTH_USE_TCI - bool ' Enable M/S Switch' CONFIG_BLUETOOTH_ENABLE_MSSWITCH - bool ' Force M/S Switch as server' CONFIG_BLUETOOTH_FORCE_MSSWITCH +if [ "$CONFIG_BLUETOOTH" =3D "y" -o "$CONFIG_BLUETOOTH" =3D "m" ]; then =20 choice ' Bluetooth hardware type' \ "None CONFIG_BLUETOOTH_NOINIT \ @@ -29,12 +20,31 @@ bool ' Block when setting baudrate' CONFIG_BLUETOOTH_SET_BAUDRATE_BLO= CKING fi =20 + bool ' Bluetooth proc entries' CONFIG_BLUETOOTH_PROC + bool ' Input buffering' CONFIG_BLUETOOTH_USE_INBUFFER + bool ' Use Security Manager' CONFIG_BLUETOOTH_USE_SECURITY_MANAGER + bool ' Use L2CAP timers' CONFIG_BLUETOOTH_L2CAP_USE_TIMERS + bool ' Allow connectionless L2CAP' CONFIG_BLUETOOTH_L2CAP_CONNECTIONLESS + bool ' Enable TCI' CONFIG_BLUETOOTH_USE_TCI + bool ' Enable M/S Switch' CONFIG_BLUETOOTH_ENABLE_MSSWITCH + + if [ "$CONFIG_BLUETOOTH_ENABLE_MSSWITCH" =3D "y" ]; then + bool ' Force M/S Switch as server' CONFIG_BLUETOOTH_FORCE_MSSWITCH + + # CSR can't do scatternet yet, so we need to do M/S switch=20 + # as early as in lp_connect_rsp() + if [ "$CONFIG_BLUETOOTH_CSR" =3D "y" ]; then + define_bool CONFIG_BLUETOOTH_EARLY_MSSWITCH y + fi + fi + choice ' Bluetooth reset pin' \ "None CONFIG_BLUETOOTH_RESET_NONE \ Port_PA_Bit_7 CONFIG_BLUETOOTH_RESET_PA7 \ Port_PB_Bit_5 CONFIG_BLUETOOTH_RESET_PB5 \ Port_G_Bit_10 CONFIG_BLUETOOTH_RESET_G10 \ Port_G_Bit_11 CONFIG_BLUETOOTH_RESET_G11" None + fi =20 endmenu --- hci.c 2001/04/25 16:54:47 1.143 +++ hci.c 2001/04/26 16:43:56 1.144 @@ -1743,12 +1743,6 @@ #ifdef CONFIG_BLUETOOTH_ENABLE_MSSWITCH DSYS("M/S switch enabled\n"); =20 -#ifdef CONFIG_BLUETOOTH_CSR - /* CSR can't do scatternet yet, so we need to do m/s switch=20 - as early as in lp_connect_rsp */ -#define CONFIG_BLUETOOTH_EARLY_MSSWITCH -#endif - #ifdef CONFIG_BLUETOOTH_FORCE_MSSWITCH hci_force_msswitch(1); #else |
From: Peter K. <pk...@us...> - 2001-04-29 11:37:03
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- Config.in 1.12 1.13=20=20=20=20=20=20=20=20=20=20=20=20 hci.c 1.145 1.146=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Always do master/slave switch as server if it is enabled (it can be turned off using the BTSETMSSWITCH ioctl). The diff of the modified file(s): --- Config.in 2001/04/27 16:46:21 1.12 +++ Config.in 2001/04/29 11:37:02 1.13 @@ -30,8 +30,6 @@ bool ' Enable M/S Switch' CONFIG_BLUETOOTH_ENABLE_MSSWITCH =20 if [ "$CONFIG_BLUETOOTH_ENABLE_MSSWITCH" =3D "y" ]; then - bool ' Force M/S Switch as server' CONFIG_BLUETOOTH_FORCE_MSSWITCH - # CSR can't do scatternet yet, so we need to do M/S switch=20 # as early as in lp_connect_rsp() if [ "$CONFIG_BLUETOOTH_CSR" =3D "y" ]; then --- hci.c 2001/04/27 15:19:29 1.145 +++ hci.c 2001/04/29 11:37:02 1.146 @@ -1743,12 +1743,7 @@ #ifdef CONFIG_BLUETOOTH_ENABLE_MSSWITCH DSYS("M/S switch enabled\n"); =20 -#ifdef CONFIG_BLUETOOTH_FORCE_MSSWITCH hci_force_msswitch(1); -#else - hci_force_msswitch(0); -#endif - #else /* CONFIG_BLUETOOTH_ENABLE_MSSWITCH */ DSYS("M/S switch disabled\n"); #endif |
From: Peter K. <pk...@us...> - 2001-05-17 15:55:00
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bcsp_mux.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20 bcsp_sequence.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Removed unused variables. The diff of the modified file(s): --- bcsp_mux.c 2001/05/17 15:25:15 1.2 +++ bcsp_mux.c 2001/05/17 15:55:00 1.3 @@ -67,8 +67,7 @@ s32 mux_receive(struct bcsp *bcsp) { - - /* If we received an ack packet, we discards the packet, sice the ack + /* If we received an ack packet, we discard the packet, sice the ack has already been handled by signal_rxack */ if (bcsp->identifier =3D=3D 0) { D(__FUNCTION__ ": Received ack, returning\n"); @@ -99,7 +98,6 @@ s32 send_txack(u8 txack) { struct bcsp bcsp; - s32 tmp; =20 D(__FUNCTION__ ": txack: 0x%x\n", txack); =20 --- bcsp_sequence.c 2001/05/17 15:25:15 1.2 +++ bcsp_sequence.c 2001/05/17 15:55:00 1.3 @@ -141,7 +141,6 @@ signal_rxack(u8 ack) { static u8 last_ack =3D 0; - u8 stop =3D FALSE; =20 remote_ack_nbr =3D ack; =20=09 |
From: Peter K. <pk...@us...> - 2001-05-18 13:48:48
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bcsp_sequence.c 1.5 1.6=20=20=20=20=20=20=20=20=20=20=20=20=20 bcsp_slip.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Minor clean-up. The diff of the modified file(s): --- bcsp_sequence.c 2001/05/18 09:14:20 1.5 +++ bcsp_sequence.c 2001/05/18 13:48:46 1.6 @@ -126,14 +126,12 @@ } =20=09 if (expected_rxseq =3D=3D BCSP_GET_SEQ(bcsp)) { -=09=09 cli(); txack =3D (BCSP_GET_SEQ(bcsp) + 1) % 8; expected_rxseq =3D (expected_rxseq + 1) % 8; sti(); =20 bcsp_receive_top(bcsp->payload, bcsp->payload_length, bcsp->identifier); -=09=09 } =20 /* FIXME: Do we need a task_queue for sending the ack packets ? */ @@ -216,7 +214,6 @@ D(__FUNCTION__": winspace after:%d\n", winspace); } =20 -=09 rxack =3D new_ack; =20 if (winspace =3D=3D WINSIZE) { @@ -231,7 +228,6 @@ u8 resend_cnt =3D rxack; =20=09 while (resend_cnt !=3D txseq) { -=09 printk(__FUNCTION__": Resending with seq_nbr:%d, last ack was %d, cur se= q_nbr:%d\n", resend_cnt, rxack, txseq); =20=09=09 init_bcsp_packet(&bcsp); --- bcsp_slip.c 2001/05/17 15:25:15 1.2 +++ bcsp_slip.c 2001/05/18 13:48:46 1.3 @@ -1,9 +1,9 @@ /* * bcsp_slip -- Implementation of the SLIP layer in the BCSP protocol stack * - * Copyright (C) 2000, 2001 Axis Communications AB + * Copyright (C) 2001 Axis Communications AB * - * Author: Peter Kjellerstedt <Pet...@ax...> + * Author: Peter Kjellerstedt <pet...@ax...> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -55,7 +55,6 @@ #define PRINTPKT(data, len) #endif =20 - /****************** TYPE DEFINITION SECTION ******************************= ***/ =20 /****************** LOCAL FUNCTION DECLARATION SECTION *******************= ***/ @@ -69,7 +68,6 @@ static void slip_send_add_byte(struct bcsp* bcsp, u8 data) { - switch (data) { case 0xC0: bcsp->packet[bcsp->packet_length++] =3D 0xDB; |
From: Mats F. <ma...@us...> - 2001-06-14 10:52:15
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- hci.c 1.158 1.159=20=20=20=20=20=20=20=20=20=20=20 l2cap.c 1.108 1.109=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * Clear the HCI inbuffers when l2cap_con =3D=3D NULL * Handle L2CAP packets < 3 bytes * Minor debug changes The diff of the modified file(s): --- hci.c 2001/06/13 12:00:35 1.158 +++ hci.c 2001/06/14 10:52:14 1.159 @@ -1436,7 +1436,7 @@ case HCI_LP: /* Link policy commands */ switch (ocf) { case ROLE_DISCOVERY: - printk(__FUNCTION__ ": ROLE_DISCOVERY: "); + D_CMD(__FUNCTION__ ": ROLE_DISCOVERY: "); if (r_val[0]) { D_ERR(__FUNCTION__ ": ROLE_DISCOVERY: %s\n", get_err_msg(r_val[0])); @@ -1448,7 +1448,7 @@ printk("Connected as Master. \n"); break; case WRITE_LINK_POLICY_SETTINGS: - printk(__FUNCTION__ ": WRITE_LINK_POLICY_SETTINGS \n "); + D_CMD(__FUNCTION__ ": WRITE_LINK_POLICY_SETTINGS \n "); if (r_val[0]) { D_ERR(__FUNCTION__ ": WRITE_LINK_POLICY_SETTINGS: %s\n", get_err_msg(r_val[0])); @@ -1575,7 +1575,7 @@ l2cap_receive_data(in_buf->buf, in_buf->count, in_buf->hci_hdl, &in_buf->l2cap_len); =20 - } else if (in_buf->count =3D=3D in_buf->l2cap_len) { + } else if (in_buf->count >=3D in_buf->l2cap_len) { l2cap_receive_data(in_buf->buf, in_buf->count, in_buf->hci_hdl, &in_buf->l2cap_len); } @@ -1818,6 +1818,7 @@ hci_ctrl.hci_in_buf[i].count =3D 0; hci_ctrl.hci_in_buf[i].l2cap_len =3D 0; hci_ctrl.hci_in_buf[i].empty =3D TRUE; + hci_ctrl.hci_in_buf[i].nbr_of_hci_pkt =3D 0; } =20=09 for (i =3D 0; i < MAX_NBR_OF_CONNECTIONS; i ++) { @@ -2291,7 +2292,7 @@ s32 role_discovery(u16 con_hdl) { - printk(__FUNCTION__ "\n"); + D_CMD(__FUNCTION__ "\n"); =20 c_pkt.type =3D CMD_PKT; c_pkt.opcode =3D hci_put_opcode(ROLE_DISCOVERY, HCI_LP) ; @@ -2306,7 +2307,7 @@ s32 write_link_policy_settings(u16 con_hdl, u16 settings) { - printk(__FUNCTION__ "\n"); + D_CMD(__FUNCTION__ "\n"); =20 c_pkt.type =3D CMD_PKT; c_pkt.opcode =3D hci_put_opcode(WRITE_LINK_POLICY_SETTINGS, HCI_LP) ; @@ -3074,7 +3075,8 @@ =20 if (active >=3D 0 && active < MAX_NBR_OF_CONNECTIONS) { memcpy(bd, hci_ctrl.con[active].bd, 6); - print_data("get_remote_bd: \n", bd, 6);=20=20=20=20=20=20=20=20 + DSYS(__FUNCTION__": %02x:%02x:%02x:%02x:%02x:%02x\n", + bd[5], bd[4], bd[3], bd[2], bd[1], bd[0]); return 0; } else { /* No connection yet */ --- l2cap.c 2001/05/21 07:32:50 1.108 +++ l2cap.c 2001/06/14 10:52:14 1.109 @@ -587,6 +587,7 @@ case CIDRCVCONLESS: if (!l2cap->allow_conless) { D_WARN("Connection less data not allowed\n"); + hci_clear_buffer(hci_handle); return; } =20=09=09 @@ -604,8 +605,11 @@ /* Data channel */ con =3D get_lcon(pkt_cid); =20=20=20=20=20 - if (con =3D=3D NULL) + if (con =3D=3D NULL) { + D_WARN(__FUNCTION__": No connection object found\n"); + hci_clear_buffer(hci_handle); return; + } =20 if (con->current_state =3D=3D OPEN ) {=20=20=20=20=20=20 process_frame(con, pkt->data, pkt_len); |
From: Peter K. <pk...@us...> - 2001-06-15 12:30:04
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bluetooth.c 1.182 1.183=20=20=20=20=20=20=20=20=20=20=20 hci.c 1.159 1.160=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added line argument to get_remote_bd() and corresponding ioctl to retrieve the BD address for a specific line, instead of the last one connected. The diff of the modified file(s): --- bluetooth.c 2001/06/14 10:59:58 1.182 +++ bluetooth.c 2001/06/15 12:30:03 1.183 @@ -628,22 +628,24 @@ break; =20 case BTREADREMOTEBDADDR: - BT_DRIVER(FNC"BTREADREMOTEBDADDR\n"); - - /* FIXME -- add parameter do get remote bd from any - connected device */ - get_remote_bd(bd_addr); - { BD_ADDR rev_bd; + s32 line;=09=20=20 u16 i; + + BT_DRIVER(FNC"BTREADREMOTEBDADDR\n"); + + copy_from_user(&line, (s32*)arg, size); + + get_remote_bd(line, bd_addr); + /* return as big endian */ for (i =3D 0; i < 6; i++) { rev_bd[5-i] =3D bd_addr[i]; } copy_to_user((s32*)arg, rev_bd, 6); - } break; + } =20 case BTRESETPHYSICALHW: bt_reset_phys_hw(); @@ -2429,7 +2431,7 @@ if (!tmp_bt_buf) { page =3D get_free_page(GFP_KERNEL); if (!page) - return; + return -ENOMEM; =20=09=09 if (tmp_bt_buf) free_page(page); --- hci.c 2001/06/14 10:52:14 1.159 +++ hci.c 2001/06/15 12:30:03 1.160 @@ -1609,14 +1609,12 @@ memcpy(hci_ctrl.con[i].bd, bd, 6); hci_ctrl.con[i].con_hdl =3D con_hdl; hci_ctrl.con[i].state =3D UNIT_ACTIVE; - hci_ctrl.active_connection =3D i; return; } } - if (i >=3D MAX_NBR_OF_CONNECTIONS) { + D_ERR(__FUNCTION__ ": No free connection object\n"); } -} =20 void reset_hci_con_bd(u16 con_hdl) { @@ -1630,10 +1628,9 @@ return; } } - if (i >=3D MAX_NBR_OF_CONNECTIONS) { + D_ERR(__FUNCTION__ ": Didn't find connection with con_hdl %d\n", con_hdl= ); } -} =20 void set_hci_con_name(u8 *bd, u8 *name) @@ -1651,10 +1648,9 @@ return; } } - if (i >=3D MAX_NBR_OF_CONNECTIONS) { + D_ERR(__FUNCTION__ ": Didn't fin connecton with BD adress 0x%02x:%02x:%0= 2x:%02x:%02x:%02x\n", bd[5],bd[4],bd[3],bd[2],bd[1],bd[0]); } -} =20 s32 hci_sprint_local_bd(u8 *buf) { @@ -1673,7 +1669,6 @@ =20 pos +=3D sprintf(buf + pos, "unit_id unit_bd_address unit_mode unit_name\= n"); =20 - /* Then we printout the other connections bd addresses and their user friendly device names */ for (i =3D 0; i < MAX_NBR_OF_CONNECTIONS; i++) { @@ -1692,7 +1687,6 @@ } pos +=3D sprintf(buf + pos, "%s\n", hci_ctrl.con[i].name); } - } =20=09 return pos; @@ -3024,17 +3018,13 @@ =20=09 for (i =3D 0 ; i < MAX_NBR_OF_CONNECTIONS ; i ++) { if (memcmp(hci_ctrl.con[i].bd, bd, 6) =3D=3D 0) { - break; + return hci_ctrl.con[i].con_hdl; } } =20 - if (i >=3D MAX_NBR_OF_CONNECTIONS) { D_ERR(__FUNCTION__ ": No connection handle found for bd 0x%02x:%02x:%02x= :%02x:%02x:%02x:\n", bd[5], bd[4], bd[3], bd[2], bd[1], bd[0]); return -1; - } else { - return hci_ctrl.con[i].con_hdl; } -} =20 #ifdef CONFIG_BLUETOOTH_USE_SECURITY_MANAGER u8* @@ -3044,43 +3034,36 @@ =20=20 for (i =3D 0 ; i < MAX_NBR_OF_CONNECTIONS ; i ++) { if (hci_ctrl.con[i].con_hdl =3D=3D con_hdl) { - break; + return hci_ctrl.con[i].bd; } } =20 - if (i >=3D MAX_NBR_OF_CONNECTIONS) { D_ERR(__FUNCTION__ ": No BD Address found for connection handle %d\n", c= on_hdl); return NULL; - } else { - return hci_ctrl.con[i].bd; - } } #endif /* CONFIG_BLUETOOTH_USE_SECURITY_MANAGER */ =20 /* - * This function will return the value of the active bd address, i.e. the - * bd address of the last connected client + * This function will return the BD address for a specific line */ =20 /* Consider changing bd to BD_ADDR */ =20 s32 -get_remote_bd(u8 *bd) +get_remote_bd(s32 line, u8 *bd) { - s32 active =3D hci_ctrl.active_connection; - D_CMD(__FUNCTION__ "\n"); =20 memset(bd, 0, 6); =20 - if (active >=3D 0 && active < MAX_NBR_OF_CONNECTIONS) { - memcpy(bd, hci_ctrl.con[active].bd, 6); + if (line >=3D 0 && line < MAX_NBR_OF_CONNECTIONS) { + memcpy(bd, hci_ctrl.con[line].bd, 6); DSYS(__FUNCTION__": %02x:%02x:%02x:%02x:%02x:%02x\n", bd[5], bd[4], bd[3], bd[2], bd[1], bd[0]); return 0; } else { /* No connection yet */ - D_WARN("get_remote_bd : No active connection!\n"); + D_WARN(__FUNCTION__ ": Unknown line: %d!\n", line); return -1; } } |
From: Lena H. <le...@us...> - 2001-06-20 13:46:07
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bcsp.c 1.14 1.15=20=20=20=20=20=20=20=20=20=20=20=20 hci_vendor.c 1.46 1.47=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Made it compile for linux 2.4.x The diff of the modified file(s): --- bcsp.c 2001/06/13 12:11:53 1.14 +++ bcsp.c 2001/06/20 13:46:07 1.15 @@ -90,7 +90,11 @@ /****************** LOCAL VARIABLE DECLARATION SECTION *******************= ***/ =20 static struct timer_list bcsp_sync_timer; +#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0) +static wait_queue_head_t bcsp_sync_wq; +#else static struct wait_queue *bcsp_sync_wq =3D NULL; +#endif static u32 bcsp_sync =3D FALSE; =20 /****************** FUNCTION DEFINITION SECTION **************************= ***/ @@ -123,6 +127,10 @@ { DSYS("Initializing BCSP\n"); =20=09 +#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,4,0) + init_waitqueue_head(&bcsp_sync_wq); +#endif + bcsp_datagram_init(); bcsp_sequence_init(); =20=09 --- hci_vendor.c 2001/06/15 13:39:08 1.46 +++ hci_vendor.c 2001/06/20 13:46:07 1.47 @@ -691,10 +691,14 @@ /* wait for command status */ while (hci_ctrl.hc_buf.cmd_num =3D=3D 0) { - current->timeout =3D HZ/100; current->state =3D TASK_INTERRUPTIBLE; +#if LINUX_VERSION_CODE >=3D KERNEL_VERSION(2,2,0) + schedule_timeout(HZ/100); +#else + current->timeout =3D HZ/100; schedule(); current->timeout =3D 0; +#endif } } =20 |
From: Mattias A. <mat...@us...> - 2001-08-02 16:05:08
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- test.c 1.21 1.22=20=20=20=20=20=20=20=20=20=20=20=20 unplug_test.c 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * fixed some errors for unplug tests * cleanup The diff of the modified file(s): --- test.c 2001/08/01 10:20:07 1.21 +++ test.c 2001/08/02 16:04:48 1.22 @@ -128,7 +128,7 @@ l2cap_con *testcon2; l2cap_con *testcon3; s32 emulate_pending =3D 0; -s32 test_assymmetric_mtu =3D 0; +s32 test_inmtu =3D 0; s32 dont_send_config_req =3D 0; s32 use_multiple_conf_params =3D 0; s32 disable_testpsm =3D 0; @@ -154,7 +154,6 @@ l2cap_register_upper(L2CAP_TEST_LAYER, &this_layer); l2cap_register_upper(L2CAP_TEST2_LAYER, &this_layer); l2cap_register_upper(L2CAP_TEST3_LAYER, &this_layer); - //l2cap_register_upper(7, &this_layer); } =20 void test_shutdown(void) @@ -186,44 +185,51 @@ return 0; } =20 -void test_connect_ind(l2cap_con *l2cap)=20 +static struct timer_list test_timer; + +static void +test_timeout(unsigned long ptr) { -#ifdef __KERNEL__ - struct tq_struct test_task; - static s32 t_init =3D -1; + struct l2cap_con *con =3D (struct l2cap_con *)ptr; + printk("Test timeout\n"); =20 - if (t_init < 0) - t_init =3D jiffies; -#endif + if (emulate_pending) { + + printk("Now sending config rsp non-pending...\n"); + emulate_pending =3D 0; +=09=09 + if (l2ca_connect_rsp(con, RES_SUCCESS, STAT_NOINFO)) { + D_ERR("test_connect_ind: l2ca_connect_rsp failed\n");=20 + return; + } + emulate_pending =3D 0; + } +} + + +void test_connect_ind(l2cap_con *l2cap)=20 +{ D_STATE("test_connect_ind : remote cid : %d\n", l2cap->remote_cid); PRINTPSM(l2cap); =20 - if (emulate_pending) - { + if (emulate_pending) { + printk("Sending connect rsp pending and waiting 5 secs\n"); if (l2ca_connect_rsp(l2cap, RES_PENDING, STAT_AUTHENTPEND)) { D_ERR("test_connect_ind: l2ca_connect_rsp failed\n");=20 return; } + + /* start 5 sec timer */=09=09 #ifndef __KERNEL__ - printk("'Authorization' pending for 5 secs...\n"); - sleep(5); -#else - while ((jiffies - t_init) < 5*HZ) { - test_task.routine =3D (void*)test_connect_ind; - test_task.data =3D l2cap; =20=09=09=09 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) - queue_task(&test_task, &tq_scheduler); #else - queue_task(&test_task, &tq_immediate); - mark_bh(IMMEDIATE_BH); -#endif - } + init_timer(&test_timer); + test_timer.function =3D test_timeout; + test_timer.data =3D l2cap; + test_timer.expires =3D jiffies + 5*HZ; + add_timer(&test_timer); #endif - - printk("Shutting off authorization pending.\n"); - emulate_pending =3D 0; - printk("Sending connect rsp with result =3D success back\n"); + return; } =20=09 if (disable_testpsm =3D=3D 1) @@ -238,6 +244,7 @@ return; } =20=09 + printk("now sending back result success !\n"); if (l2ca_connect_rsp(l2cap, RES_SUCCESS, STAT_NOINFO)) { D_ERR("test_connect_ind: l2ca_connect_rsp failed\n");=20 return; @@ -251,8 +258,6 @@ testcon2 =3D l2cap; else if (l2cap->psm =3D=3D L2CAP_TEST3_LAYER) testcon3 =3D l2cap; -// else -// testcon =3D l2cap; } =20 /* only client receives connect pnd */ @@ -267,8 +272,6 @@ testcon2 =3D l2cap; else if (l2cap->psm =3D=3D L2CAP_TEST3_LAYER) testcon3 =3D l2cap; -// else -// testcon =3D l2cap; } =20 /* only client receives connect cfm */ @@ -294,15 +297,12 @@ } =20=09=09 /* store connection */ - if (l2cap->psm =3D=3D L2CAP_TEST_LAYER) testcon =3D l2cap; else if (l2cap->psm =3D=3D L2CAP_TEST2_LAYER) testcon2 =3D l2cap; else if (l2cap->psm =3D=3D L2CAP_TEST3_LAYER) testcon3 =3D l2cap; -// else -// testcon =3D l2cap; } else=20=09=20=20=20=20=20=20=20 D_RCV("test_config_cfm : already have sent config request\n"); } @@ -327,7 +327,6 @@ =20 /* check if we received a pos response on a previous config req */=20 if (!l2ca_local_conf_done(l2cap)) { - u16 tmp_mtu; =20 /* still haven't sent config request yet */ =20 @@ -346,13 +345,14 @@ D_ERR("test_config_cfm : Configuration request failed\n"); } } else { - if (test_assymmetric_mtu)=20=09 - tmp_mtu =3D 8192; - else - tmp_mtu =3D 0; /* use default */ -=09=09=09 - if (l2ca_config_req(l2cap, tmp_mtu, NULL, 0, 0)) + if (l2ca_config_req(l2cap, test_inmtu, NULL, 0, 0)) D_ERR("test_config_ind : configuration request failed\n"); + + if (test_inmtu) + { + printk("Set back our test_inmtu to default\n"); + test_inmtu =3D 0; + } } =20 } else=20 --- unplug_test.c 2001/07/31 19:28:55 1.3 +++ unplug_test.c 2001/08/02 16:04:47 1.4 @@ -35,7 +35,8 @@ * the executable file might be covered by the provisions of the GNU * General Public License. * - * $Id$ + * $Id: unplug_test.c,v 1. +3 2001/07/31 19:28:55 pkj Exp $ * */ =20 @@ -63,7 +64,6 @@ #include "include/btcommon.h" #endif =20 - extern rfcomm_con rfcomm_con_list[7]; =20 extern rpn_values rpn_val; @@ -74,7 +74,7 @@ =20 extern l2cap_con *testcon; /* is set in test.c */ extern s32 emulate_pending; /* is set in test.c */ -extern s32 test_assymmetric_mtu; +extern s32 test_inmtu; extern s32 dont_send_config_req; extern s32 use_multiple_conf_params; extern s32 disable_testpsm; @@ -287,15 +287,13 @@ =20 =20 /* - * Test case : Opening of a Connection-Oriented Channel,=20 - * Device B Initiator (L2CAP Test 1) - * (see btd.c, issue command 'test_conn <bd addr>') + * Test case 1 : Opening of a Connection-Oriented Channel,=20 + * + * (see bttest.c, issue command 'test_conn <bd addr> <psm>') */ =20 /* - * Test case : Opening of a Connection-Oriented Channel,=20 - * Device A Initiator (L2CAP Test 2) - * (see test.c, handled automatically as server) + * Test case : Data transfer via Open L2CAP Channel (L2CAP Test 2) */ =20 /* @@ -346,17 +344,17 @@ =20 /* * Test case : Disconnection of a Connection Oriented Channel - * Device B Initiator (L2CAP Test 4) - * (see btd.c, issue command 'test_disc') + * Device B Initiator (L2CAP Test 3) + * (see btd.c, issue command 'test_disc <local CID>') */ =20 =20=20 /* - * Test case : Disconnection of a Connection-Oriented Channel,=20 - * Device A Initiator (L2CAP Test 5) - * (see test.c, handled automatically as server) + * Test case : Echo + * Device A Initiator (L2CAP Test 4) + * */ -/* test_conn 00:e0:03:78:b0:db */ +/* upt t 241 */ =20 /* =20 @@ -364,38 +362,48 @@ * Data Transferred (L2CAP Test 5) */ =20 +#define OPTION_MTU1 4096 +#define OPTION_MTU2 8192 =20 static void test_2_5_1(void) { - /* FIXME - Client sends configure request with MTU 4096 */ - if (l2ca_config_req(testcon, 48, NULL, 0, 0)) { + printk("[Client] Sending config req for mtu =3D %d\n", OPTION_MTU1); + if (l2ca_config_req(testcon, OPTION_MTU1, NULL, 0, 0)) { D_ERR("l2ca_connect_cfm : Configuration request failed\n"); } } =20 +static void test_2_5_2(void) +{ + printk("[Server] Set our in_mtu to :%d\n", OPTION_MTU2); + test_inmtu =3D OPTION_MTU2; +} + + static void test_2_5_3(void) { - /* FIXME - Server sends configure request with MTU 16384 */ - if (l2ca_config_req(testcon, 16384, NULL, 0xffff, 0)) { + printk("[Client] Sending config req for mtu =3D %d\n", OPTION_MTU2); + if (l2ca_config_req(testcon, OPTION_MTU2, NULL, 0xffff, 0)) { D_ERR("l2ca_connect_cfm : Configuration request failed\n"); } } =20 static void test_2_5_4(void) { - /* FIXME - Client responds success in configure response */ + printk("[Server] Set our in_mtu to :%d\n", OPTION_MTU1); + test_inmtu =3D OPTION_MTU1; } =20 static void test_2_5_5(void) { /* Client sends 8192 bytes of data */ - printk("test_2_5_6, client sends 8192 bytes\n"); + printk("Sends 8192 bytes\n"); test_send_data(testcon, tmpdata, 8192); } =20 static void test_2_5_6(void) { - printk("test_2_5_6, server sends 4096 bytes\n"); + printk("Sending 4096 bytes\n"); /* Server sends 4096 bytes of data */ test_send_data(testcon, tmpdata, 4096); } @@ -1391,6 +1399,8 @@ case 226: test_2_2_6(); break; case 251: test_2_5_1(); + break; + case 252: test_2_5_2(); break; case 253: test_2_5_3(); break; |