You can subscribe to this list here.
| 2001 |
Jan
|
Feb
(44) |
Mar
(202) |
Apr
(134) |
May
(89) |
Jun
(94) |
Jul
(58) |
Aug
(58) |
Sep
(56) |
Oct
(75) |
Nov
(26) |
Dec
(14) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2002 |
Jan
(24) |
Feb
(30) |
Mar
(15) |
Apr
(49) |
May
(12) |
Jun
(6) |
Jul
(11) |
Aug
(20) |
Sep
(19) |
Oct
(3) |
Nov
(13) |
Dec
(1) |
| 2003 |
Jan
(7) |
Feb
(4) |
Mar
(7) |
Apr
(5) |
May
(6) |
Jun
(3) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(51) |
Dec
(1) |
| 2004 |
Jan
(11) |
Feb
(5) |
Mar
|
Apr
(5) |
May
(2) |
Jun
|
Jul
(21) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Peter K. <pk...@us...> - 2001-03-23 13:21:59
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
btmem.c 1.38 1.39=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Replaced FNC with __FUNCTION__.
The diff of the modified file(s):
--- btmem.c 2001/03/23 13:12:45 1.38
+++ btmem.c 2001/03/23 13:21:57 1.39
@@ -214,7 +214,6 @@
=20
bt_tx_buf* subscribe_bt_buf(s32 send_len)
{
-#define FNC "subscribe_bt_buf : "
bt_tx_buf *tx;
s32 buf_len; /* Total size of bt_tx_object */
u32 head_free;
@@ -222,7 +221,7 @@
=20
cli();
buf_len =3D send_len + BT_TX_HDRSIZE;=20=20
- D_MEM(FNC"buf_len %d\n", buf_len);
+ D_MEM(__FUNCTION__ ": buf_len %d\n", buf_len);
=20
/*=20=20
'Normal' case
@@ -243,7 +242,7 @@
head_free =3D (bt_buf.send - bt_buf.head);
=20
if (tail_free >=3D buf_len) {
- D_MEM(FNC"subscribe in tail at pos %d\n",=20
+ D_MEM(__FUNCTION__ ": subscribe in tail at pos %d\n",=20
bt_buf.free - bt_buf.head);
tx =3D (bt_tx_buf *)bt_buf.free;
/* Don't touch send, only update free and count */
@@ -261,8 +260,8 @@
bt_buf.nbr_bufs++;
bt_buf.count +=3D buf_len;
} else {
- D_ERR(FNC"Cannot subscribe %d bytes !\n", send_len);
- D_ERR(FNC"Only %d available (non - fragmented)\n",
+ D_ERR(__FUNCTION__ ": Cannot subscribe %d bytes !\n", send_len);
+ D_ERR(__FUNCTION__ ": Only %d available (non - fragmented)\n",
buf_write_room());
=20
#if PANIC_AT_ERROR
@@ -292,8 +291,8 @@
btmem_reset();
=20=09=09=09
if (buf_len > bt_buf.size) {
- D_ERR(FNC"Cannot subscribe %d bytes !\n", send_len);=20
- D_ERR(FNC"Only %d available (non - fragmented)\n",
+ D_ERR(__FUNCTION__ ": Cannot subscribe %d bytes !\n", send_len);=20
+ D_ERR(__FUNCTION__ ": Only %d available (non - fragmented)\n",
buf_write_room());
btmem_get_status(NULL);
sti();
@@ -307,9 +306,9 @@
bt_buf.count +=3D buf_len;
bt_buf.nbr_bufs++;
} else {
- D_ERR(FNC"Cannot subscribe requested size (%d) !\n",=20
+ D_ERR(__FUNCTION__ ": Cannot subscribe requested size (%d) !\n",=20
send_len);
- D_ERR(FNC"Only %d available (non - fragmented)\n",
+ D_ERR(__FUNCTION__ ": Only %d available (non - fragmented)\n",
buf_write_room());
btmem_get_status(NULL);
#if PANIC_AT_ERROR
@@ -326,7 +325,6 @@
=20
sti();
return tx;
-#undef FNC
}
=20
/* Returns number of buffers */
@@ -366,7 +364,6 @@
don't count a tossed tail ! */
space_left =3D (BT_BUF_SIZE -=20
(bt_buf.tail - bt_buf.toss_tail) - bt_buf.count);
-=20=20
}
=20
space_left -=3D (BT_TX_HDRSIZE+BTMEM_EXTRASPACE);
@@ -432,14 +429,13 @@
=20
void unsubscribe_bt_buf(bt_tx_buf *tx)
{
-#define FNC "unsubscribe_bt_buf : "
s32 tail_free; /* for debug */
s32 head_free;
=20
if (!tx)
return;
=20
- D_MEM(FNC"%d bytes (not incl hdrs) at pos %d\n",=20
+ D_MEM(__FUNCTION__ ": %d bytes (not incl hdrs) at pos %d\n",=20
tx->subscr_len, (u8 *)tx - bt_buf.head);
=20=20=20
/* Check that tx is valid for unssubscribe. We must process the=20
@@ -453,12 +449,12 @@
bt_buf.count -=3D (tx->subscr_len + BT_TX_HDRSIZE);
bt_buf.nbr_bufs--;=20=20=20=20=20=20
} else {
- D_ERR(FNC"failed, out of boundary\n");
+ D_ERR(__FUNCTION__ ": failed, out of boundary\n");
}
} else if (bt_buf.count =3D=3D 0)
- D_MEM(FNC"no data in buffer\n");
+ D_MEM(__FUNCTION__ ": no data in buffer\n");
else {
- D_ERR(FNC"invalid data segment!\n");
+ D_ERR(__FUNCTION__ ": invalid data segment!\n");
#ifdef __KERNEL__
=20
D_ERR("pid : %d (tx:0x%x - send:0x%x=3D%d) send:%ld free:%ld\n",
@@ -486,7 +482,7 @@
=20
/* Is also checked done in get_bt_buf */
if (bt_buf.send =3D=3D bt_buf.toss_tail) {
- D_MEM(FNC"toss_tail, now send pos is 0\n");
+ D_MEM(__FUNCTION__ ": toss_tail, now send pos is 0\n");
bt_buf.send =3D bt_buf.head;
bt_buf.toss_tail =3D bt_buf.tail;
=20
|
|
From: Peter K. <pk...@us...> - 2001-03-23 13:12:47
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
btmem.c 1.37 1.38=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Allow unsubscribe_bt_buf() to be called with NULL as argument.
The diff of the modified file(s):
--- btmem.c 2001/03/02 21:52:15 1.37
+++ btmem.c 2001/03/23 13:12:45 1.38
@@ -239,12 +239,10 @@
get_bt_buf();
=20
if (bt_buf.free > bt_buf.send) {
-=20=20=20=20
tail_free =3D (bt_buf.tail - bt_buf.free);
head_free =3D (bt_buf.send - bt_buf.head);
=20
if (tail_free >=3D buf_len) {
-
D_MEM(FNC"subscribe in tail at pos %d\n",=20
bt_buf.free - bt_buf.head);
tx =3D (bt_tx_buf *)bt_buf.free;
@@ -253,7 +251,6 @@
bt_buf.count +=3D buf_len;
bt_buf.nbr_bufs++;
} else if (head_free >=3D buf_len) {=20=20
-
D_MEM("No room in tail, subscribe at head (WRAP!)\n");
tx =3D (bt_tx_buf *)bt_buf.head;
=20=09=09=09
@@ -264,7 +261,6 @@
bt_buf.nbr_bufs++;
bt_buf.count +=3D buf_len;
} else {
-
D_ERR(FNC"Cannot subscribe %d bytes !\n", send_len);
D_ERR(FNC"Only %d available (non - fragmented)\n",
buf_write_room());
@@ -277,7 +273,6 @@
return NULL;
}
} else if (bt_buf.free <=3D bt_buf.send) {
-=20=20=20=20
/* 'Wrap' case */
tail_free =3D (bt_buf.send - bt_buf.free);
head_free =3D 0; /* head_free is not interesting since we cannot=20
@@ -286,7 +281,6 @@
buffer! (Fragmentation) */
=20=20=20=20=20
if (tail_free >=3D buf_len) {
-
D_MEM("Wrapped buffer, subscribe at free (pos %d)\n",=20
bt_buf.free - bt_buf.head);
tx =3D (bt_tx_buf *)bt_buf.free;
@@ -294,7 +288,6 @@
bt_buf.count +=3D buf_len;
bt_buf.nbr_bufs++;
} else if (!bt_buf.count) {
-
/* If buffer empty, reset buffer */=20=20=20=20=20=20=20=20=20=20
btmem_reset();
=20=09=09=09
@@ -343,7 +336,6 @@
return bt_buf.nbr_bufs;
}
=20
-
/* Returns total number of bytes in buffer (fragmented) */
=20
s32 buf_byte_count()
@@ -351,7 +343,6 @@
return bt_buf.count;
}
=20
-
/* Returns unfragmented buffer space */=20
=20
#define BTMEM_EXTRASPACE BT_BUF_SIZE/10 /* always an extra 10 % marginal
@@ -412,8 +403,7 @@
=20
tx =3D (bt_tx_buf *)(bt_buf.send);
=20
- if (tx->magic !=3D 0x4321)
- {
+ if (tx->magic !=3D 0x4321) {
D_ERR("get_bt_buf : wrong magic!\n");
#if PANIC_AT_ERROR
panic("lets stop here...\n");
@@ -446,6 +436,9 @@
s32 tail_free; /* for debug */
s32 head_free;
=20=20=20
+ if (!tx)
+ return;
+
D_MEM(FNC"%d bytes (not incl hdrs) at pos %d\n",=20
tx->subscr_len, (u8 *)tx - bt_buf.head);
=20=20=20
@@ -453,10 +446,8 @@
buffers in fifo order ! */
=20
cli();
- if (tx && (bt_buf.send =3D=3D (u8*)tx)) {
-
+ if (bt_buf.send =3D=3D (u8*)tx) {
if ((u8*)(tx->data + tx->subscr_len) <=3D bt_buf.tail) {
-=20=20=20=20=20=20
/* don't touch free, only subscribe_bt_buf change free */
bt_buf.send +=3D (tx->subscr_len + BT_TX_HDRSIZE);
bt_buf.count -=3D (tx->subscr_len + BT_TX_HDRSIZE);
@@ -603,13 +594,11 @@
bt_tx_buf *tx;
=20=20=20=20
for (i =3D 0; i < count; i++) {
-
if (cursize > buf_write_room())
return;
=20=09=20=20=20=20=20
printk("storing %d bytes packets\n", cursize);
while (buf_write_room() >=3D cursize) {
-=09=20=20=20=20=20=20=20
if (!(tx =3D subscribe_bt_buf(cursize))) {
return ;
}
|
|
From: Mattias A. <mat...@us...> - 2001-03-22 11:12:12
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
btinit.c 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
fixed typo, SIGTERM calls exit which activates atexit function
The diff of the modified file(s):
--- btinit.c 2001/03/21 20:50:17 1.3
+++ btinit.c 2001/03/22 11:12:10 1.4
@@ -265,7 +265,7 @@
=20=20
longjmp(jmpbuffer, 1);
}
- if (sig =3D=3D SIGUSR1)
+ if (sig =3D=3D SIGTERM)
{
exit(0);
}
|
|
From: Gordon M. <gm...@us...> - 2001-03-21 23:23:27
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
hci.c 1.132.2.2 1.132.2.3=20=20=20=20=20=20=20
The accompanying log:
--Reversed the bytes in the GIAC and LIAC.
--Extended the Inquiry timer to 40 seconds.
The diff of the modified file(s):
--- hci.c 2001/03/20 20:12:35 1.132.2.2
+++ hci.c 2001/03/21 23:23:25 1.132.2.3
@@ -831,9 +831,10 @@
#ifdef CONFIG_BLUETOOTH_HCI_INQUIRY /************************************=
***/
// Adds about 1k
=20
-// See [BSC] Appendix VIII 1.1
-static const u8 GIAC[] =3D { 0x9e, 0x8b, 0x33 };
-static const u8 LIAC[] =3D { 0x9e, 0x8b, 0x00 };
+// See [BSC] Appendix VIII 1.1. Note that these must be reversed from that
+// shown in the Spec. Why?
+static const u8 GIAC[] =3D { 0x33, 0x8b, 0x9e };
+static const u8 LIAC[] =3D { 0x00, 0x8b, 0x9e };
=20
static struct inquiry_results *pending_inq_res =3D NULL;
static u32 hci_inq_pending =3D 0;
@@ -861,7 +862,7 @@
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 + 40*HZ;
add_timer(&hci_inq_timer);
}
static void release_inq_timer(void)
@@ -922,6 +923,8 @@
#endif
=20
D_CMD(__FUNCTION__ "\n");
+
+ PRINTPKT("LAP:", lap, 3);
=20
// Check for a valid LAP.
if (!memcmp(lap, GIAC, 3) && !memcmp(lap, LIAC, 3))
|
|
From: Gordon M. <gm...@us...> - 2001-03-21 23:22:59
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bluetooth.c 1.154.2.1 1.154.2.2=20=20=20=20=20=20=20
The accompanying log:
--Needed to reverse the LAP bytes.
The diff of the modified file(s):
--- bluetooth.c 2001/03/20 16:42:53 1.154.2.1
+++ bluetooth.c 2001/03/21 23:22:31 1.154.2.2
@@ -716,7 +716,7 @@
=20
// REVISIT The user should specify this...
// --gmcnutt
- u8 lap[3] =3D { 0x9e, 0x8b, 0x33 };
+ u8 lap[3] =3D { 0x33, 0x8b, 0x9e };
u8 num_resp;
int ret;
=20=09=09
@@ -2686,7 +2686,7 @@
#include <linux/types.h>
=20
#define INIT_BAUD B57600
-#define FINAL_BAUD B115200
+#define FINAL_BAUD B57600
#define SERIAL "/dev/ttyS1"
=20
#ifdef __KERNEL__
@@ -2718,7 +2718,7 @@
printk(__FUNCTION__":open '%s' failed\n", SERIAL);
return ser_fd;
}
-
+#if 0
if ((ret =3D ioctl(ser_fd, TCGETA, (unsigned long) &t)) < 0) {
printk(__FUNCTION__":ioctl TCGETA failed\n");
goto exit;
@@ -2736,7 +2736,7 @@
printk(__FUNCTION__":ioctl TCSETA failed\n");
goto exit;
}
-
+#endif
if ((ret =3D ioctl(ser_fd, TIOCSETD, (unsigned long)&bt_ldisc)) < 0) {
printk(__FUNCTION__":ioctl TIOCSETD failed\n");
goto exit;
@@ -2853,9 +2853,9 @@
=20
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 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;
+// if ((ret =3D look_for_other_bluetooth_devices()) < 0) goto exit;
=20
/*
* At this point we can either spawn ppp and wait, or we might be
|
|
From: Mattias A. <mat...@us...> - 2001-03-21 20:50:18
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
btinit.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
added SIGTERMI in sighandler to cope with atexit() functionality
added option -i used to set default speed on physdev
minor changes
The diff of the modified file(s):
--- btinit.c 2001/03/13 22:21:17 1.2
+++ btinit.c 2001/03/21 20:50:17 1.3
@@ -107,6 +107,7 @@
=20
static int btd_pid;
static char local_name[LOCAL_NAME_LENGTH+1]; /* 'friendly' name in HW modu=
le */
+static int init_hw_speed =3D 0; /* not set */
static int do_hwinit =3D 1; /* do vendor specific initialization */
static int do_reset =3D 0; /* reset hw using I/O pins */
static int phys_fd =3D -1; /* physical device e.g ttyS0 */
@@ -155,6 +156,11 @@
{
switch(opt)
{
+ case 'i':
+ /* uart device */
+ init_hw_speed =3D atoi(optarg);
+ syslog(LOG_INFO, "init_hw_speed %d baud\n", init_hw_speed);
+ break;
=20
case 'n':
printf("setting local name to %s\n", optarg);
@@ -205,12 +211,16 @@
}
=20
/* Set default speed */
+
+ if (init_hw_speed !=3D 0)
+ fd_setup(phys_fd, init_hw_speed, 1);
+ else
init_phys(phys_fd);
=20
/* Set the current tty to the bluetooth discpline */
set_bt_line_disc(phys_fd, bt_disc, physdev);
=20=20=20
- bt_cfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY);
+ bt_cfd =3D bt_openctrl();
=20
init_stack(bt_cfd, atoi(speedstr));
=20
@@ -237,6 +247,7 @@
sigemptyset(&act.sa_mask);
act.sa_flags =3D 0;
sigaction(SIGUSR1, &act, 0);
+ sigaction(SIGTERM, &act, 0);
/* other sigs ? */
}
=20
@@ -253,6 +264,10 @@
btd_cleanup();
=20=20
longjmp(jmpbuffer, 1);
+ }
+ if (sig =3D=3D SIGUSR1)
+ {
+ exit(0);
}
return;
}
|
|
From: Mattias A. <mat...@us...> - 2001-03-21 20:48:07
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
btd.c 1.4 1.5=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
fixed communication with IPA server
added option -i, --hwinit to set initial baud rate on physdev
made strings used for building pppd options static
added SIGTERM in sighandler to handle atexit() functionality
fixed some warnings & minor changes
The diff of the modified file(s):
--- btd.c 2001/03/13 22:21:17 1.4
+++ btd.c 2001/03/21 20:48:04 1.5
@@ -50,6 +50,10 @@
=20=09=20=20=20=20=20
options:=20
=20=20=20
+ -i, --hwinit=20
+=09
+ default: ttyS0
+=20=20
-u, --physdev <uart device>
Sets which uart device that will be used by the stack
default: ttyS0
@@ -106,6 +110,8 @@
#include "bt_if.h"
#include "bt_ipa.h"
=20
+#define D(x) //x
+
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
/* PPPD stuff */
=20
@@ -129,13 +135,22 @@
struct peer_struct peerlist[BT_NBR_DATAPORTS];
struct ip_set ipsetlist[BT_NBR_DATAPORTS];
=20
+static unsigned char dev[20];
+static unsigned char ip_addresses[35];
+static unsigned char ms_dns1[35];
+static unsigned char ms_dns2[35];
+static unsigned char ms_wins1[35];
+static unsigned char ms_wins2[35];
+static unsigned char netmask[35];
+
static fd_set rfd;
static struct timeval tv;
=20
#define PEER(line) (peerlist[line])
+#define IPSET(line) (ipsetlist[line])
#define STATE(line) (peerlist[line].state)
=20
-char *pppd_options[32];
+static unsigned char *pppd_options[32];
=20
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
/* IPA stuff */
@@ -145,7 +160,7 @@
static struct ipa_msg *msg;
static unsigned char ipa_buf[256];
static int parse_ipa_response(struct ipa_msg *msg);
-static int ipa_sendrequest(int line, unsigned char bd[6],
+static int ipa_sendrequest(int line, unsigned char *bd,
unsigned short type);
#endif
=20
@@ -165,6 +180,7 @@
static char local_name[LOCAL_NAME_LENGTH+1]; /* 'friendly' name in HW modu=
le */
static int do_hwinit =3D 1; /* do vendor specific initialization */
static int do_reset =3D 0; /* reset hw using I/O pins */
+static int init_hw_speed =3D 0; /* not set */
static int modem_emul =3D 1; /* default modem emulation is enabled */
static int phys_fd =3D -1; /* physical device e.g ttyS0 */
static jmp_buf jmpbuffer; /* used to jump back in program after doing rese=
t */
@@ -189,7 +205,7 @@
static void btd_killchilds(void);
static void sighandler(int sig);
=20
-static void handle_new_connections(int bt_cfd);
+static void discover_connections(int bt_cfd);
static void build_pppdopts(int line, char **opts);
static int start_pppd(int line, char *speedstr, char **opts);
=20
@@ -210,13 +226,19 @@
}
=20=20=20
/* now parse options */
-#define OPTIONS_STRING "mnRs:u:"
+#define OPTIONS_STRING "i:m:nRs:u:"
=20=20=20
while ((opt =3D getopt_long(argc, argv, OPTIONS_STRING,
long_options, &option_index)) !=3D -1)
{
switch(opt)
{
+ case 'i':
+ /* uart device */
+ init_hw_speed =3D atoi(optarg);
+ syslog(LOG_INFO, "init_hw_speed %d baud\n", init_hw_speed);
+ break;
+
case 'm':
/* uart device */
modem_emul =3D atoi(optarg);
@@ -270,12 +292,16 @@
exit(1);
}
=20=20=20
+ /* Sets initial HW baudrate */
+ if (init_hw_speed !=3D 0)
+ fd_setup(phys_fd, init_hw_speed, 1);
+ else
init_phys(phys_fd);
=20=20=20
/* Set the current tty to the bluetooth discpline */
set_bt_line_disc(phys_fd, bt_disc, physdev);
=20=20=20
- bt_cfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY);
+ bt_cfd =3D bt_openctrl();
=20=20=20
init_stack(bt_cfd, atoi(speedstr));
=20=20=20
@@ -284,24 +310,22 @@
=20=20=20
/* All initialized and ready to accept connections */
=20=20=20
- bt_waitnewconnections(bt_cfd);
- syslog(LOG_INFO, "handle_new_connections");
- handle_new_connections(bt_cfd);
+ while (1)
+ {
+ int i, waiting_iparsp =3D 0;
+ tv.tv_sec =3D 1;
+ tv.tv_usec =3D 0;
=20=20=20
FD_ZERO(&rfd);=20=20
FD_SET(ipa_fd, &rfd);
FD_SET(0, &rfd);
=20=20=20
- while (1)
- {
- int i;
- tv.tv_sec =3D 2;
- tv.tv_usec =3D 0;
result =3D select(FD_SETSIZE, &rfd, (fd_set*)0,=20
(fd_set*)0, &tv);
switch (result)
{
case 0:
+ {
/* Timeout, check for new rfcomm cons */
=20=20=20=20=20=20=20
/* Check for outstanding IPA requests */
@@ -310,38 +334,42 @@
{
if ((STATE(i) =3D=3D WAITING_PPPCONF) ||
(STATE(i) =3D=3D WAITING_RETURN_PPPCONF))
- break;=20=20
+ {
+ D(syslog(LOG_INFO, "Waiting for IPA response\n"));
+ waiting_iparsp =3D 1;
+ }
i++;
}
-=20=20=20=20=20=20
- /* If no outstanding IPA req, simply wait for new rfcomm */
- if (i =3D=3D BT_NBR_DATAPORTS)
- bt_waitnewconnections(bt_cfd);=20=20=20=20=20
=20=20=20=20=20=20=20
- handle_new_connections(bt_cfd);
+ if (waiting_iparsp)
+ break;
=20=20=20=20=20=20=20
+ discover_connections(bt_cfd);
+ }
break;
=20=20=20=20=20=20=20
case -1:
+ {=20=20
/* Error */
perror("select");
+
+ /* FIXME -- e.g if ipa server restarts !!! */
+ }
break;
=20=20=20=20=20=20=20
default:
{
/* Got data on some fd */
int i;=20=20=20=20=20=20=20=20
+=20
for (i=3D0; i < result; i++)=20
{
-=20
#ifdef USE_IPASSIGN
/* IPA response */
if (FD_ISSET(ipa_fd, &rfd))
{
msg =3D (struct ipa_msg*) ipa_buf;
-=20=20=20=20=20=20=20=20=20=20=20=20
/* Got response from IPA, if ok then start pppd or modem emul =
*/
- syslog(LOG_INFO, "IPA data\n");=20=20=20=20=20=20=20=20=20=20=
=20=20
ipa_read(ipa_fd, msg);
parse_ipa_response(msg);
}
@@ -357,41 +385,44 @@
} /* main */
=20=20
/* Checks for new connections and starts pppd/modememulator */
-static void handle_new_connections(int bt_cfd)
+static void discover_connections(int bt_cfd)
{
int line;
=20=20=20
- syslog(LOG_INFO, "handle_new_connections");
+ D(syslog(LOG_INFO, "discover_connections"));
for (line =3D 0; line < BT_NBR_DATAPORTS; line++)
{
-
if ((STATE(line) =3D=3D NOCONNECTION) &&=20
bt_isconnected(bt_cfd, line))
{
- syslog(LOG_INFO, "We got a new connection on line : %d !\n", line);
+ syslog(LOG_INFO, "Found connection on line : %d !\n", line);
STATE(line) =3D CONNECTED;
=20=20=20=20=20=20=20
read_remote_bd(bt_cfd, PEER(line).remote_bd);
print_bd_addr("remote bd ", PEER(line).remote_bd);
=20=20=20=20=20=20=20
#ifdef USE_IPASSIGN
- syslog(LOG_INFO, "Sending IPA request\n");
+ D(syslog(LOG_INFO, "Sending IPA request\n"));
+=20=20=20=20=20=20
+ PEER(line).ipset =3D &IPSET(line);
+
STATE(line) =3D WAITING_PPPCONF;
- if (ipa_sendrequest(line, PEER(line).remote_bd, IPAREQ_GETIPSET) < 0)
+ if (ipa_sendrequest(line, (unsigned char *)&PEER(line).remote_bd,=20
+ IPAREQ_GETIPSET) < 0)
{
syslog(LOG_INFO, "IPA request failed or no IPA server");
=20
/* Build without IPA anyway */
STATE(line) =3D PPPCONF_DONE;
- build_pppdopts(line, pppd_options);=20=20=20=20=20=20
- start_pppd(line, speedstr, pppd_options);=20=20=20=20=20
+ build_pppdopts(line, (char**)pppd_options);=20=20=20=20=20=20
+ start_pppd(line, speedstr, (char**)pppd_options);=20=20=20=20=20
}
else
- syslog(LOG_INFO, "IPA request sent");
+ D(syslog(LOG_INFO, "IPA request sent"));
#else
STATE(line) =3D PPPCONF_DONE;
- build_pppdopts(line, pppd_options);=20=20=20=20=20=20
- start_pppd(line, speedstr, pppd_options);=20=20=20=20=20
+ build_pppdopts(line, (char**)pppd_options);=20=20=20=20=20=20
+ start_pppd(line, speedstr, (char**)pppd_options);=20=20=20=20=20
#endif=20=20
}
}
@@ -400,35 +431,28 @@
/* only server */
void build_pppdopts(int line, char **opts)
{
-=20=20
int i=3D0;
- char dev[20];
- char ip_addresses[35];
- char ms_dns1[35];
- char ms_dns2[35];
- char ms_wins1[35];
- char ms_wins2[35];
- char netmask[35];
struct ip_set *ipset =3D PEER(line).ipset;
+ char local_ip[20];
=20=20=20
#ifdef USE_IPASSIGN
show_ipset(ipset, line);
#endif
=20=20=20
- syslog(LOG_INFO, "build_pppdopts\n");
+ D(syslog(LOG_INFO, "build_pppdopts\n"));
=20=20=20
sprintf(dev, "/dev/ttyBT%d",line);
=20=20=20
/* general options */
- pppd_options[i++] =3D (char*)PPPDCMD;
- pppd_options[i++] =3D dev;
- pppd_options[i++] =3D speedstr;
+ opts[i++] =3D (char*)PPPDCMD;
+ opts[i++] =3D dev;
+ opts[i++] =3D speedstr;
=20=20=20
/* move these to options file ? */
- pppd_options[i++] =3D "crtscts";
- pppd_options[i++] =3D "nopersist";
- pppd_options[i++] =3D "silent";
- pppd_options[i++] =3D "passive";
+ opts[i++] =3D "crtscts";
+ opts[i++] =3D "nopersist";
+ opts[i++] =3D "silent";
+ opts[i++] =3D "passive";
=20=20=20
/* check if we have used IPA */
if (ipset)
@@ -439,75 +463,80 @@
/* Use radius ? */
if (ipset->useradius)
{
- pppd_options[i++] =3D "useradius";
- pppd_options[i++] =3D "auth";
- pppd_options[i++] =3D "login";
+ opts[i++] =3D "useradius";
+ opts[i++] =3D "auth";
+ opts[i++] =3D "login";
=20=20=20=20=20=20=20
if (ipset->useradiusip)
{
- pppd_options[i++] =3D "useautoip";
+ opts[i++] =3D "useautoip";
}=20=20=20
}=20=20
else=20
{
- pppd_options[i++] =3D "noauth";
+ opts[i++] =3D "noauth";
}=20=20
=20=20=20=20=20
if (ipset->proxyarp)
{
- pppd_options[i++] =3D "proxyarp";
+ opts[i++] =3D "proxyarp";
/* ktune only works on pppd version > 2.3.10 */
/* similar as doing ' echo 1 > /proc/sys/net/ipv4/ip_forward */
- pppd_options[i++] =3D "ktune"; /* enables ip_forwarding */
+ opts[i++] =3D "ktune"; /* enables ip_forwarding */
}=20=20
=20
+ get_local_addr(local_ip);
/* local/remote ip */
- sprintf(ip_addresses, "%s:%s", get_local_addr(),=20
+ sprintf(ip_addresses, "%s:%s", local_ip,=20
inet_ntoa(ipset->ip));
=20=20=20=20=20
printf("IP used : %s\n", ip_addresses);
=20=20=20=20=20
+ opts[i++] =3D ip_addresses;
+=20=20=20=20
/* DNS */
if (ipset->nbr_of_dns > 0)
{
- /* at lease one... */
- pppd_options[i++] =3D "ms-dns";
+ /* at least one... */
+ opts[i++] =3D "ms-dns";
sprintf(ms_dns1, "%s", inet_ntoa(ipset->dns[0]));
- pppd_options[i++] =3D ms_dns1;
+ opts[i++] =3D ms_dns1;
=20=20=20=20=20=20=20
if (ipset->nbr_of_dns > 1)
{
- pppd_options[i++] =3D "ms-dns";
+ opts[i++] =3D "ms-dns";
sprintf(ms_dns2, "%s", inet_ntoa(ipset->dns[1]));
- pppd_options[i++] =3D ms_dns2;
+ opts[i++] =3D ms_dns2;
}
}
=20=20=20=20=20
/* WINS */
if (ipset->nbr_of_wins > 0)
{
- /* at lease one... */
- pppd_options[i++] =3D "ms-wins";
+ /* at least one... */
+ opts[i++] =3D "ms-wins";
sprintf(ms_wins1, "%s", inet_ntoa(ipset->wins[0]));
- pppd_options[i++] =3D ms_wins1;
+ opts[i++] =3D ms_wins1;
=20=20=20=20=20=20=20
if (ipset->nbr_of_wins > 1)
{
- pppd_options[i++] =3D "ms-wins";
- sprintf(ms_dns2, "%s", inet_ntoa(ipset->wins[1]));
- pppd_options[i++] =3D ms_wins2;
+ opts[i++] =3D "ms-wins";
+ sprintf(ms_wins2, "%s", inet_ntoa(ipset->wins[1]));
+ opts[i++] =3D ms_wins2;
}
}
=20=20=20=20=20
/* Netmask */=20=20=20=20=20=20
- pppd_options[i++] =3D "netmask";
+ opts[i++] =3D "netmask";
sprintf(netmask, "%s", inet_ntoa(ipset->netmask));
- pppd_options[i++] =3D netmask;
+ opts[i++] =3D netmask;
}
else
{
- /* local ip */
- sprintf(ip_addresses, "%s:", get_local_addr());
+ get_local_addr(local_ip);
+=20=20=20=20
+ /* local IP */
+ sprintf(ip_addresses, "%s:", local_ip);
=20=20=20=20=20
/* Use /etc/ppp/options file for remote ppp settings.
IPA is needed for correct multipoint setting or use a=20
@@ -515,26 +544,28 @@
options.ttyBT1 which contains the remote IP address,=20
dns, wins etc*/
=20=20=20=20=20
- syslog(LOG_INFO, "WARNING NO REMOTE IP SET, only local %s\n",=20
+ syslog(LOG_INFO, "WARNING No remote ip addr set, only local %s",=20
ip_addresses);
- printf("WARNING NO REMOTE IP SET, only local %s\n", ip_addresses);
=20
+ opts[i++] =3D ip_addresses;
+
/* always do proxyarp */=20
- pppd_options[i++] =3D "proxyarp";
+ opts[i++] =3D "proxyarp";
=20
/* ktune only works on pppd version > 2.3.10 */
/* similar as doing ' echo 1 > /proc/sys/net/ipv4/ip_forward */
- pppd_options[i++] =3D "ktune"; /* enables ip_forwarding */
- }
+ opts[i++] =3D "ktune"; /* enables ip_forwarding */
=20=20=20
- pppd_options[i] =3D NULL;
+ } /* end -- no ipa */
=20=20=20
-#if 1
+ opts[i] =3D NULL;
+=20=20
+#if 0
/* print pppd_options */
i =3D 0;
syslog(LOG_INFO, "pppd options used :");
- while (pppd_options[i])
- syslog(LOG_INFO, "%s", pppd_options[i++]);
+ while (opts[i])
+ syslog(LOG_INFO, "%s", opts[i++]);
#endif
}
=20
@@ -543,18 +574,16 @@
char dev[20];
=20=20=20
sprintf(dev, "/dev/ttyBT%d",line);
- printf("start_pppd on %s at %s baud\n", dev, speedstr);
=20=20=20
/* check state */
if (STATE(line) !=3D PPPCONF_DONE)
{
- syslog(LOG_INFO, "Warning : ppp config not done!!!\n");
+ syslog(LOG_INFO, "Warning : ppp config not done (%d)\n", STATE(line));
return -1;
}
=20=20=20
if (PEER(line).do_modememul)=20
{
- printf("Starting modem emulator...\n");
STATE(line) =3D MODEM_STARTED;
=20=20=20=20=20
/* run modem emulator in a child */
@@ -565,9 +594,9 @@
/* replace first arg with MODEMEMULCMD (is handled by=20
modem emulator) */
=20=20=20=20=20=20=20
- pppd_options[0]=3D (char*)MODEMEMULCMD;=20=20=20=20=20=20
+ opts[0]=3D (char*)MODEMEMULCMD;
=20=20=20=20=20=20=20
- execvp(MODEMEMULCMD, pppd_options);
+ execvp(MODEMEMULCMD, opts);
=20=20=20=20=20=20=20
fprintf(stderr, "%s: no such file or directory\n", MODEMEMULCMD);
=20=20=20=20=20=20=20
@@ -578,14 +607,13 @@
}
else
{
- printf("Starting pppd...\n");
STATE(line) =3D PPPD_STARTED;
if (!(PEER(line).pppd_pid =3D vfork()))
{
syslog(LOG_INFO, "Starting pppd on %s", dev);
=20=20=20=20=20=20=20
- /* FIXME -- use opts inparam and not static pppd_options */
- execvp(PPPDCMD, pppd_options);
+ /* FIXME -- use opts inparam and not static opts */
+ execvp(PPPDCMD, opts);
=20=20=20=20=20=20=20
fprintf(stderr, "%s: no such file or directory\n", PPPDCMD);
=20=20=20=20=20=20=20
@@ -617,7 +645,7 @@
static void
sighandler(int sig)
{
- printf("Sighandler : %d\n", sig);
+ syslog(LOG_INFO, "Sighandler got signal : %d\n", sig);
=20=20=20
if (sig =3D=3D SIGUSR1)
{
@@ -629,9 +657,16 @@
{=20=20=20=20
/* Close down phys dev, run hw_upgrade and restart btd */
btd_cleanup();
- /* execvp(hw_upgrade_prog) */
+=20
+ /* FIXME -- execvp(hw_upgrade_prog) */
+=20=20=20=20
longjmp(jmpbuffer, 1);
}
+ else if (sig =3D=3D SIGTERM) /* ? */
+ {=20
+ syslog(LOG_INFO, "Got SIGTERM, now exiting");
+ exit(0);
+ }
else if (sig =3D=3D SIGCHLD)=20=20
{
int line =3D 0, pid, status;
@@ -665,18 +700,21 @@
syslog(LOG_INFO, "PPP line %d was shutdown\n", line);
=20=20=20=20=20
#ifdef USE_IPASSIGN
- /* FIXME -- Now release IPA settings */
- if (ipa_sendrequest(line, PEER(line).remote_bd, IPAREQ_RELEASEIPSET) <=
0)
+ STATE(line) =3D WAITING_RETURN_PPPCONF;
+
+ if (ipa_sendrequest(line, (unsigned char *)&PEER(line).remote_bd,=20
+ IPAREQ_RELEASEIPSET) < 0)
{
syslog(LOG_INFO, "IPA request failed or no IPA server");
- /* check if still connected first ? */
+ /* put peer into state NOCONNECTION, if still connected this
+ will be discovered in timout */
STATE(line) =3D NOCONNECTION;=20=20=20=20
}=20=20=20=20
#else
- /* check if still connected first ? */
STATE(line) =3D NOCONNECTION;=20=20=20=20
#endif
=20=20=20=20=20
+ PEER(line).ipset =3D NULL;
PEER(line).pppd_pid =3D -1;
=20=20=20=20=20
return;
@@ -691,6 +729,7 @@
static void init()
{=20
int i;
+
btd_pid =3D write_pidfile(PID_FILE);=20=20
init_sighandler();
=20=20=20
@@ -714,6 +753,7 @@
if (ipa_fd < 0)
{
printf("Found no IPA server\n");
+ exit(1);=20
}
#endif
=20=20=20
@@ -762,7 +802,6 @@
printf("btd_killchilds\n");
if (sdpsrv_pid > 0)
{
- printf("btd_killchilds SDP server\n");
syslog(LOG_INFO, "Killing SDP server\n");
kill(sdpsrv_pid, SIGTERM);
=20=20=20=20=20
@@ -777,7 +816,6 @@
{
if (STATE(line) =3D=3D PPPD_STARTED)
{
- printf("btd_killchilds PPP server on line %d\n", line);
syslog(LOG_INFO, "Killing pppd on line %d\n", line);
kill(PEER(line).pppd_pid, SIGTERM);
if (waitpid(PEER(line).pppd_pid, NULL, 0) < 0)
@@ -792,20 +830,20 @@
=20
#ifdef USE_IPASSIGN
=20
-static int ipa_sendrequest(int line, unsigned char bd[6], unsigned short t=
ype)
+static int ipa_sendrequest(int line, unsigned char *bd, unsigned short typ=
e)
{
unsigned char buf[IPA_MSG_MAXSIZE];
struct ipa_msg *msg;
struct ipa_request *req;
=20=20=20
- printf("ipa_request : type %d\n", type);
+ D(syslog(LOG_INFO, "ipa_request : type %d\n", type));
=20=20=20
msg =3D (struct ipa_msg*)buf;
msg->type =3D type;
msg->len =3D sizeof(struct ipa_request);
req =3D (struct ipa_request*)msg->msg;
req->id =3D line;
- memcpy(&req->remote_bd, &bd, 6);=20
+ memcpy(&req->remote_bd, bd, 6);=20
return ipa_write(ipa_fd, msg);
}
=20
@@ -816,20 +854,28 @@
case IPARSP_STATUS:
{
ipa_status *rsp =3D (struct ipa_status*)(msg->msg);
- syslog(LOG_INFO, "ipa_parse_msg : got status %d on line\n",=20
- rsp->status, rsp->id);=20=20
+ D(syslog(LOG_INFO, "ipa_parse_msg : got status %d on line\n",=20
+ rsp->status, rsp->id));
=20=20=20=20=20=20=20
/* Check status */
if (rsp->status =3D=3D IPA_STATUSFAILED)
- printf("parse_ipa_response : request failed [line:%d]\n", rsp->id);
+ syslog(LOG_INFO, "parse_ipa_response : request failed [line:%d]\n"=
,=20
+ rsp->id);
+ else
+ D(syslog(LOG_INFO, "parse_ipa_response : request succeeded [line:%d]\n", =
rsp->id));
=20=20=20=20=20=20=20
+ /* put peer into NOCONNECTION, if still connected this will=20
+ be discovered from timeout */
+
+ STATE(rsp->id) =3D NOCONNECTION;
+
return rsp->status;
}
=20=20=20=20=20
case IPARSP_PEERSETTINGS:
{
ipa_response* rsp =3D (struct ipa_response*)(msg->msg);
- syslog(LOG_INFO, "ipa_parse_msg : got client settings\n");=20=20=20=
=20=20=20
+ D(syslog(LOG_INFO, "ipa_parse_msg : got client settings\n"));
=20=20=20=20=20=20=20
/* Check status */
if (rsp->status =3D=3D IPA_STATUSFAILED)
@@ -842,12 +888,17 @@
/* Store ipa settings in peer struct */
memcpy(PEER(rsp->id).ipset, &rsp->set, msg->len);
=20=20=20=20=20=20=20
- /* print settings ! */
- show_ipset(PEER(rsp->id).ipset, rsp->id);
+ /* Now proceed to next state */
+ if (PEER(rsp->id).state =3D=3D WAITING_PPPCONF)
+ {
+ PEER(rsp->id).state =3D PPPCONF_DONE;
+ }=20=20=20=20=20=20
+ else
+ syslog(LOG_INFO, "Warning : Wrong state on line %d, should have been WAIT=
ING_PPPCONF", rsp->id);
=20=20=20=20=20=20=20
/* Build options and start ppp */
- build_pppdopts(rsp->id, pppd_options);
- start_pppd(rsp->id, speedstr, pppd_options);
+ build_pppdopts(rsp->id, (char**)pppd_options);
+ start_pppd(rsp->id, speedstr, (char**)pppd_options);
return 0;
}=20
=20=20=20=20=20
|
|
From: Gordon M. <gm...@us...> - 2001-03-21 19:38:22
|
The following file was modified in apps/bluetooth/btd:
Name Old version New version Comment
---- ----------- ----------- -------
btd.c 1.88.2.1 1.88.2.2=20=20=20=20=20=20=20=20
The accompanying log:
--If the HCIINQUIRY ioctl fails we just return now instead of exiting.
The diff of the modified file(s):
--- btd.c 2001/03/20 16:42:53 1.88.2.1
+++ btd.c 2001/03/21 19:38:19 1.88.2.2
@@ -2913,7 +2913,7 @@
if (ioctl(bt_cfd, HCIINQUIRY, inq_res) < 0)
{
perror("Inquiry");
- exit(1);
+ return;
}
=20=20=20=20=20
for (i =3D 0; i < inq_res->nbr_of_units; i++)
|
|
From: Mattias A. <mat...@us...> - 2001-03-21 19:03:10
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
bttest.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
replaced code with functions in bt_xxx files
lots of cleanup
The diff of the modified file(s):
--- bttest.c 2001/03/10 12:49:32 1.2
+++ bttest.c 2001/03/21 19:03:09 1.3
@@ -39,12 +39,6 @@
*
*/
=20
-/*=20
- * FIXME !!!
- * THIS FILE HAS NOT BEEN TESTED AFTER SPLIT UP OF BTD=20
- * AND SHOULD NOT BE USED AS IS
- */
-
#include <sys/time.h>
#include <sys/types.h>
#include <sys/ioctl.h>
@@ -76,12 +70,10 @@
#include "bt_if.h"
#include "bt_misc.h"
#include "bt_conf.h"
+#include "bt_vendor.h"
=20
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
=20
-#define START_PPP 1
-#define QUIT_BTD 2
-
#define BTD_HISTORY_FILE "/tmp/btd_history"
=20
char* menu[] =3D
@@ -97,9 +89,7 @@
" readbd", /* read module bd address */
" reset", /* reset board */
" role_switch <xx:xx:xx:xx:xx:xx> <role> (0=3Dmaster, 1=3Dslave)",
-#ifdef BT_USERSTACK
" stat ", /* similar to reading the /proc/bt */
-#endif
#ifdef ECS_TEST_FUNCTIONS
" ecs_entertest <handle> (hex)",
" ecs_testctrl <par1,par2,...,par9> (hex)",
@@ -107,7 +97,6 @@
" ecs_testcon <xx:xx:xx:xx:xx:xx> (hex)",=20=20
" enable_dut", /* enable device under test mode */
#endif
- " ppp",
" quit",
#ifdef BT_USERSTACK
"",
@@ -150,27 +139,21 @@
}=20=20=20=20=20=20=20=20=20
}
=20
-void=20
-testmain(void)
+int
+main(void)
{
- int start_ppp =3D 0;
int bt_cfd;=20=20
=20
- if ((bt_cfd =3D open_device(BT_CTRL_TTY, O_RDWR, 0)) < 0)
+ /* First of all check that stack is running */
+ if (!bt_isinitiated())
{
- perror("Could not open BT control TTY\n");
+ printf("Stack not initiated, exit\n");
exit(1);
}
-
-// if (enter_cmd_mode)
- {
- read_history(BTD_HISTORY_FILE);
=20
-#ifdef BT_USERSTACK
- sleep(2); /* temp fix - wait for last command response to be returned =
*/
-#endif
+ bt_cfd =3D bt_openctrl();
=20
- printf("Now entering cmd line mode\n");
+ read_history(BTD_HISTORY_FILE);=20=20
=20
show_menu();
=20=20=20=20=20
@@ -178,62 +161,37 @@
{
int tmp;
char *line =3D (char*) readline("> ");
-
- if (!line)
- {
- start_ppp =3D 0;
- break;
- }
-
add_history(line);
=20=20=20=20=20=20=20
tmp =3D process_cmd(line, bt_cfd);
=20
- if (tmp =3D=3D START_PPP)
- {
- start_ppp =3D 1;
- break;
- }
- else if (tmp =3D=3D QUIT_BTD)
+ if (tmp =3D=3D QUIT_BTD)
{
- start_ppp =3D 0;
break;
}
free(line);
}
write_history(BTD_HISTORY_FILE);
- }=20=20
+ exit(0);
}
=20
int
process_cmd(char *buf, int bt_cfd)
{
- int bd[6];
- unsigned char my_bd_addr[6];
unsigned int tmp[11];
int repeat;
int i, line;
-#ifdef BT_USERSTACK
- unsigned char tmp_bd[6]; /* used for byte swapping */
- int server_channel, profile;
-#endif
=20=20
if (!strncmp(buf, "quit", 4))
{
return QUIT_BTD;
}
- else if (!strncmp(buf, "ppp", 3))
- {
- return START_PPP;
- }
-
- if (sscanf(buf, "rf_conn %x:%x:%x:%x:%x:%x %d %d",
+ else if (sscanf(buf, "rf_conn %x:%x:%x:%x:%x:%x %d %d",
&tmp[0], &tmp[1], &tmp[2],
&tmp[3], &tmp[4], &tmp[5],
&tmp[6], &tmp[7]) =3D=3D 8)
{
- int i;
- unsigned int con_id;
+ unsigned int con_id, i;
unsigned short srv_ch, line;
unsigned char tmp_bd[6];
=20
@@ -268,118 +226,33 @@
}
else if (sscanf(buf, "rf_send %d %d %d", &i, &repeat, &line) =3D=3D 3)
{
-#define MAXSIZE (4096*2)
- struct timeval start_t, stop_t;
- int bytes_tot =3D i*repeat;
- int avg_speed =3D 0; /* bps */
- unsigned int ms;
- char tmp[MAXSIZE];
+ int btfd;
char dev[20];
- int fd;
- int j;
-
sprintf(dev, "/dev/ttyBT%d",line);
-
-#ifndef BT_USERSTACK=20=20=20=20
- printf("Opening %s\n", dev);
- if ((fd =3D open_device(dev, O_RDWR, CLIENT)) < 0)
- {
- perror("open_device");
- return 0;
- }=20=20=20=20
- printf("Done.\n");
-
- bt_waitconnection(fd, line);
-
-#else
- /* FIXME -- currently only uses line 0 */
- if (line !=3D 0) {
- printf("No support for sending data on line %d, use line 0 instead !=
(userstack only)\n", line);
- fd=3D-1;
- return 0;
- }
-#endif
-
- if (i > MAXSIZE)
- {
- printf("Max 8192 bytes per write!\n");
- i =3D MAXSIZE;
- bytes_tot =3D i*repeat; /* update this aswell */
- }
-
- /* fill them with letters... */
- for(j =3D 0; j < i; j++)
- {
- tmp[j] =3D (j % 25) + 65;
+ btfd =3D open(dev, O_RDWR | O_NOCTTY);
+ bt_send(bt_cfd, i, repeat);
+ close(btfd);
}
-=20=20=20=20
- printf("\nNow sending %d %d-bytes packet (%d kB) on line %d\n",=20
- repeat, i, bytes_tot/1000, line);
-
- gettimeofday(&start_t, NULL);
-=20
- while (repeat)
+ else if (sscanf(buf, "setbd %x:%x:%x:%x:%x:%x",
+ &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]) =
=3D=3D 6)
{
- int n =3D 0;
-#ifndef BT_USERSTACK
- n =3D write(fd, tmp, i);=20=20=20
-#else
- n =3D bt_write_top(tmp, i, line);
-#endif
+ unsigned char tmp_bd[6];
=20=20=20=20=20=20=20
- if (n <=3D0)
+ for (i =3D 0; i < 6; i++)
{
- printf("couldn't write any more data...\n\n");
- bytes_tot =3D bytes_tot-repeat*i;
- break;
- }
-
- repeat--;
- printf("%6d kB left to send... \r",
- ((repeat*i)/1000));
- fflush(stdout);
+ tmp_bd[i] =3D (unsigned char)tmp[i];
}
- gettimeofday(&stop_t, NULL);
- printf("\ndone.\n");
=20
- ms =3D (stop_t.tv_sec-start_t.tv_sec)*1000 +=20
- (stop_t.tv_usec-start_t.tv_usec)/1000;
- if (ms)
- avg_speed =3D ((8*bytes_tot)/ms);
- printf("Average TX rate : %d kbps (%d kB/s)\n", avg_speed, avg_speed/8=
);
-#ifndef BT_USERSTACK
- printf("Closing %s\n", dev);
- close_device(fd);
-#endif
- }
- else if (sscanf(buf, "setbd %x:%x:%x:%x:%x:%x",
- &bd[0], &bd[1], &bd[2], &bd[3], &bd[4], &bd[5]) =3D=3D 6)
- {
- bt_set_bd_addr(bt_cfd, &bd[0]);
+ bt_set_bd_addr(bt_cfd, &tmp_bd[0]);
}
else if (strncmp(buf, "readbd", 6) =3D=3D 0)
{
+ unsigned char my_bd_addr[6];=20=20
read_local_bd(bt_cfd, my_bd_addr);
}
- else if (strncmp(buf, "reset", 5) =3D=3D 0)
- {
- /* FIXME */
-#if 0
-
- close_device(bt_cfd);
- close_device(phys_fd);
- bt_cfd =3D -1;
- phys_fd =3D -1;
- reset_hw();
-#ifdef RESTART_ENABLED
- /* must set baud rate to default for hw again... */
- siglongjmp(jmpbuffer, 1);
-#endif
-
-#endif
- }
else if(sscanf(buf, "role_switch %x:%x:%x:%x:%x:%x %d ",
- &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5], &tmp[6]) =3D=3D 7)
+ &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4],=20
+ &tmp[5], &tmp[6])=3D=3D 7)
{
unsigned char tmp_bd[6];
=20
@@ -422,22 +295,16 @@
ericsson_tx_test(&tmp[0]);
}
#endif
-
-/*
- * Non usermode stack functions for the stuff=20
- * below will be added later on
- */
-
-#ifdef BT_USERSTACK
else if (strncmp(buf, "stat", 4) =3D=3D 0)
{
-
- char tmp[4096];
- int len;
- len =3D bt_read_internal(tmp);
- tmp[len] =3D 0;
- printf("%s", tmp);
+ bt_showstatus();
}
+/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
+/* FIXME !!! -- make this work for both kernel / usermode stack */
+/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
+
+
+#ifdef BT_USERSTACK
else if (sscanf(buf, "ping %x:%x:%x:%x:%x:%x",
&bd[0], &bd[1], &bd[2], &bd[3], &bd[4], &bd[5]) =3D=3D 6)
{
@@ -575,7 +442,6 @@
printf("> error: command not recognized or wrong syntax\n");
show_menu();
}
-
return 0;
}
=20
|
|
From: Mattias A. <mat...@us...> - 2001-03-21 18:47:19
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
btdisc.c 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
use return code from bt_disconnect as exit code
The diff of the modified file(s):
--- btdisc.c 2001/03/02 10:59:57 1.1
+++ btdisc.c 2001/03/21 18:47:18 1.2
@@ -71,6 +71,7 @@
{
int con_id, bt_cfd, dlci=3D-1, line, opt;
char *btdev =3D "/dev/ttyBT0"; /* default */=20=20
+ int ret_val;
=20
#ifdef __CRIS__
/* Print header if called via http */
@@ -128,8 +129,8 @@
=20
con_id =3D CREATE_RFCOMM_ID(line, dlci);
=20
- bt_disconnect(bt_cfd, con_id);
+ ret_val =3D bt_disconnect(bt_cfd, con_id);
=20=20
close(bt_cfd);
- exit(0);
+ exit(ret_val);
}
|
|
From: Mattias A. <mat...@us...> - 2001-03-21 18:46:04
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
btcon.c 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
added two more options to write BD address, e.g 001122334455, 00-11-22-33-4=
4-55
The diff of the modified file(s):
--- btcon.c 2001/03/02 10:59:57 1.1
+++ btcon.c 2001/03/21 18:46:02 1.2
@@ -100,21 +100,45 @@
{
switch(opt)
{
+=20=20=20=20=20=20
case 'a':
{
- int tmp[6];
+ int tmp[6], all_read =3D 0;
bd_str =3D optarg;
- printf("Connecting to bd : %s\n", bd_str);
- if (sscanf(optarg, "%x:%x:%x:%x:%x:%x",
+ if (sscanf(optarg, "%2x%2x%2x%2x%2x%2x",
+ &tmp[0], &tmp[1], &tmp[2],
+ &tmp[3], &tmp[4], &tmp[5]) =3D=3D 6)
+ {=20=20
+ all_read =3D 1;
+ }
+ else if (sscanf(optarg, "%x:%x:%x:%x:%x:%x",
+ &tmp[0], &tmp[1], &tmp[2],
+ &tmp[3], &tmp[4], &tmp[5]) =3D=3D 6)
+ {=20=20
+ all_read =3D 1;
+ }
+ else if (sscanf(optarg, "%x-%x-%x-%x-%x-%x",
&tmp[0], &tmp[1], &tmp[2],
&tmp[3], &tmp[4], &tmp[5]) =3D=3D 6)
{
+ all_read =3D 1;
+ }
+=20=20=20=20=20=20=20=20
+ /* now convert to real bd format if syntax was correct */
+ if(all_read)
+ {
for (i =3D 0; i < 6; i++)
{
bd[i] =3D (unsigned char)tmp[i];=20
}
+ printf("Connecting to bd : %2x:%2x:%2x:%2x:%2x:%2x\n",
+ bd[0], bd[1], bd[2], bd[3], bd[4], bd[5]);
}
-=20=20=20=20=20=20=20=20
+ else
+ {
+ printf("Invalid syntax : %s\n", bd_str);
+ exit(1);
+ }
}
break;
=20
|
|
From: Mattias A. <mat...@us...> - 2001-03-21 18:35:21
|
The following files were modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
bt_ipa.c 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20
bt_ipa.h 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
fixed error in show_ipset
minor changes and added some debug
The diff of the modified file(s):
--- bt_ipa.c 2001/03/02 10:59:57 1.1
+++ bt_ipa.c 2001/03/21 18:35:20 1.2
@@ -46,6 +46,7 @@
#include <syslog.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <string.h>
=20
/* print in_addr */
#include <sys/socket.h>
@@ -81,7 +82,9 @@
/* Sends msg to IPA socket */
int ipa_write(int ipa_fd, ipa_msg *msg)
{
- syslog(LOG_INFO, "ipa_send : sending ipa request (type : %d)\n", msg->ty=
pe);
+ syslog(LOG_INFO, "ipa_send : sending ipa request (type : %d) len %d \n",
+ msg->type, msg->len);
+=20=20
return write(ipa_fd, msg, msg->len + sizeof(struct ipa_msg));
}
=20
@@ -99,6 +102,8 @@
{
c =3D read(ipa_fd, &ipa_buf+offset, 256-offset);=20=20
=20
+ syslog(LOG_INFO, "ipa_receive : got %d bytes", c);=20=20
+
if (c < 0)
return c;
=20
@@ -117,25 +122,36 @@
=20=20=20
memcpy(msg, ipa_buf, offset);
=20
+ syslog(LOG_INFO, "Got %d bytes", offset);
+
return msg_len;=20=20
}
=20
void show_ipset(struct ip_set* set, int line)
{
- printf("IP set [line:%d]\n", line);
- printf(" ip : %s\n", inet_ntoa(set->ip));
+ syslog(LOG_INFO, "IP set [line:%d]\n", line);
+
+ if (set)
+ {=20=20=20=20
+ syslog(LOG_INFO, " ip : %s\n", inet_ntoa(set->ip));
+
if (set->nbr_of_dns >=3D 1)
- printf(" dns1 : %s\n", inet_ntoa(set->dns[1]));
+ syslog(LOG_INFO, " dns1 : %s\n", inet_ntoa(set->dns[0]));
+
if (set->nbr_of_dns =3D=3D 2)
- printf(" dns2 : %s\n", inet_ntoa(set->dns[2]));
+ syslog(LOG_INFO, " dns2 : %s\n", inet_ntoa(set->dns[1]));
+
if (set->nbr_of_wins >=3D 1)
- printf(" wins 1 : %s\n", inet_ntoa(set->wins[1]));
- if (set->nbr_of_dns =3D=3D 2)
- printf(" wins2 : %s\n", inet_ntoa(set->wins[2]));
- printf(" netmask : %s\n", inet_ntoa(set->netmask));
- printf("useradius : %d\n", set->useradius);
- printf("useradiusip : %d\n", set->useradiusip);
- printf("usingmasq : %d\n", set->usingmasq);
+ syslog(LOG_INFO, " wins 1 : %s\n", inet_ntoa(set->wins[0]));
+
+ if (set->nbr_of_wins =3D=3D 2)
+ syslog(LOG_INFO, " wins2 : %s\n", inet_ntoa(set->wins[1]));
+
+ syslog(LOG_INFO, " netmask : %s\n", inet_ntoa(set->netmask));
+ syslog(LOG_INFO, "useradius : %d\n", set->useradius);
+ syslog(LOG_INFO, "useradiusip : %d\n", set->useradiusip);
+ syslog(LOG_INFO, "usingmasq : %d\n", set->usingmasq);
+ }
}
=20
#endif /* USE_IPASSIGN */
--- bt_ipa.h 2001/03/02 10:59:57 1.1
+++ bt_ipa.h 2001/03/21 18:35:20 1.2
@@ -63,8 +63,8 @@
#define IPARSP_PEERSETTINGS 11
=20
/* Status codes */
-#define IPA_STATUSFAILED 0
-#define IPA_STATUSSUCCESS 1
+#define IPA_STATUSSUCCESS 0
+#define IPA_STATUSFAILED 1
=20
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
/* IPA Client struct */
|
|
From: Mattias A. <mat...@us...> - 2001-03-21 18:31:24
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- Makefile 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: added bttest added bt_misc.o for BTDISCOBJS and BTINQOBJS The diff of the modified file(s): --- Makefile 2001/03/10 12:49:32 1.2 +++ Makefile 2001/03/21 18:31:22 1.3 @@ -5,12 +5,13 @@ include $(APPS)/Rules.elinux endif =20 -PROGS =3D btdm memul bti btinq btcon btsend btdisc +PROGS =3D btdm memul bti btinq bttest btcon btsend btdisc =20 # Define HAVE_READLINE_READLINE if you have readline support, with the inc= lude # files in $(include_dir)/readline. Define HAVE_READLINE if you have the # include files in $(include_dir). Define neither if you do not want to use # readline. + HAVE_READLINE_READLINE =3D 1 #HAVE_READLINE =3D 1 =20 @@ -19,13 +20,14 @@ INSTOWNER =3D root INSTGROUP =3D root =20 -BTDOBJS =3D btd.o bttest.o bt_ipa.o bt_vendor.o bt_if.o bt_misc.o +BTDOBJS =3D btd.o bt_ipa.o bt_vendor.o bt_if.o bt_misc.o MEMULOBJS =3D modememul.o bt_misc.o BTINITOBJS =3D btinit.o bt_vendor.o bt_if.o bt_misc.o BTCONOBJS =3D btcon.o bt_if.o bt_misc.o BTSENDOBJS =3D btsend.o bt_if.o bt_misc.o -BTDISCOBJS =3D btdisc.o bt_if.o -BTINQOBJS =3D btinq.o bt_if.o +BTDISCOBJS =3D btdisc.o bt_if.o bt_misc.o +BTINQOBJS =3D btinq.o bt_if.o bt_misc.o +BTTESTOBJS =3D bttest.o bt_misc.o bt_vendor.o bt_if.o =20 ifdef HAVE_READLINE_READLINE LDLIBS +=3D -lreadline -ltermcap @@ -63,6 +65,9 @@ $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@=09 =20 btinq: $(BTINQOBJS) + $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ + +bttest: $(BTTESTOBJS) $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ =20 install: $(PROGS) |
|
From: Mattias A. <mat...@us...> - 2001-03-21 18:27:24
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
bt_vendor.c 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
minor change
The diff of the modified file(s):
--- bt_vendor.c 2001/03/10 12:47:09 1.3
+++ bt_vendor.c 2001/03/21 18:27:23 1.4
@@ -318,7 +318,7 @@
/* Set the phys device to CSR default, 115200 */=20
void init_phys(int fd)
{
- syslog(LOG_INFO, "Setting default baud 115200");
+ syslog(LOG_INFO, "Setting default speed 115200");
fd_setup(fd, 115200, USE_FLOW_CTRL);
}
=20
@@ -365,15 +365,6 @@
hci_write_pagescan_activity(0x50, 0x20); /* more reliable connection pro=
cess */
sleep(1); /* wait for HW */
#endif
-
-#if 0
- /* fixme -- don't know how to change baudrate yet !*/=20
- /* Now set phys device speed to whatever HW was set to use */
- fd_setup(phys_fd, spd, USE_FLOW_CTRL);=20=20
-
- tcflush(phys_fd, TCIOFLUSH);
-#endif
-
}
=20
#elif HW_USED(HW_GENERIC)
|
|
From: Mattias A. <mat...@us...> - 2001-03-21 18:25:57
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_misc.h 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * changed declaration for get_local_addr and print_data The diff of the modified file(s): --- bt_misc.h 2001/03/02 10:59:57 1.1 +++ bt_misc.h 2001/03/21 18:25:56 1.2 @@ -58,9 +58,9 @@ int open_tcpsocket(char *addrstr, int role); =20 int write_pidfile(char *pidname); -char* get_local_addr(void); +void get_local_addr(char *str); void print_bd_addr(char* str, unsigned char *bd); -void print_data(const char *message, char *buf, int len); +void print_data(const char *message, unsigned char *buf, int len); void set_pin_code(char *pin); =20 #endif /* __BT_MISC_H__*/ |
|
From: Mattias A. <mat...@us...> - 2001-03-21 18:24:42
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
bt_misc.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
return -1 if connect fails in open_socket
changed get_local_addr, free string after strdup
modified set_pin_code
The diff of the modified file(s):
--- bt_misc.c 2001/03/02 14:30:32 1.2
+++ bt_misc.c 2001/03/21 18:24:40 1.3
@@ -136,7 +136,7 @@
(struct sockaddr *)&server_address,=20
server_len) < 0) {
syslog(LOG_ERR, "open_socket %s failed", name);
- return 0;
+ return -1;
}
=20
=20
@@ -234,7 +234,7 @@
* Set server_name to the numerical IP of eth0 instead of using DNS or
* relying on /etc/hosts being correct. for now.
*/
-char* get_local_addr(void)
+void get_local_addr(char *str)
{
char *local_address =3D NULL;
int fd =3D socket(AF_INET, SOCK_DGRAM, 0);
@@ -249,7 +249,10 @@
{
syslog(LOG_INFO, "could not determine local IP address!\n");
}
- return local_address;
+
+ strcpy(str, local_address);
+
+ free(local_address);
}
=20
int=20
@@ -339,7 +342,7 @@
}
=20
void=20
-print_data(const char *message, char *buf, int len)
+print_data(const char *message, unsigned char *buf, int len)
{=20
int t;
printf("\n%s (%d)", message, len);
@@ -347,7 +350,7 @@
{
if((t%16)=3D=3D0)
printf("\n ");
- printf("0x%x ", buf[t]);
+ printf("0x%02x ", (uint)(buf[t]));
}
printf("\n");
}
@@ -362,14 +365,13 @@
if (strncmp(pin, "disable", 7) =3D=3D 0)
{
printf("Disable PIN usage\n");
- system("/bin/parhandclient -nosync set root.Security.UseLANSecurity ye=
s");
+ system("/bin/parhandclient -nosync set root.Security.UseLANSecurity no=
");
system("/bin/parhandclient sync");
return;
}
=20
- sprintf(exec_pinstr, "/bin/parhandclient -nosync set root.Security.PINCo=
de %s", (char*) pin);
-=20=20
/* Set pin in stack */
+ sprintf(exec_pinstr, "/bin/parhandclient -nosync set root.Security.PINCo=
de %s", (char*) pin);=20=20
=20=20=20
system("/bin/parhandclient -nosync set root.Security.UseLANSecurity yes"=
);
system(exec_pinstr);
|
|
From: Mattias A. <mat...@us...> - 2001-03-21 17:29:56
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.h 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: added return value on bt_disconnect changed defines for l2cap error codes changed ioctl define for sending raw hci data minor changes The diff of the modified file(s): --- bt_if.h 2001/03/02 10:59:57 1.1 +++ bt_if.h 2001/03/21 17:29:55 1.2 @@ -92,10 +92,12 @@ #define MSG_LAYER_TCS 8 =20 /* Result in responses in L2CAP */ -#define RES_PSMNEG 0x02 -#define RES_SECNEG 0x03 -#define RES_NOSRC 0x04 +#define L2CAP_PSMNEG 0x02 +#define L2CAP_SECNEG 0x03 +#define L2CAP_NOSRC 0x04 =20 +#define L2CAP_CON_UNRESPONSIVE 0xf1 + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* IF Macros */ =20 @@ -185,8 +187,10 @@ =20 #define HCISETBAUDRATE _IOW(BT_IOC_MAGIC, 0x70, int) #define HCIWRITEBDADDR _IOW(BT_IOC_MAGIC, 0x71, unsigned char[6]) -#define HCISENDRAWDATA _IOW(BT_IOC_MAGIC, 0x72, unsigned char[256]) =20 +/* | len 1 byte | 4 bytes hci header | data (max 256) | */ +#define HCISENDRAWDATA _IOW(BT_IOC_MAGIC, 0x72, unsigned char[261]) + /* Used to calculate opcode for HCI commands using raw interface */ #define OPCODE_MSB(ocf, ogf) ((ocf) & 0xff) #define OPCODE_LSB(ocf, ogf) (((ocf) >> 8) | (((ogf) & 0x3f) << 2)) @@ -245,21 +249,23 @@ */ =20 int bt_connect(int bt_fd, unsigned char *bd, unsigned int con_id); -void bt_disconnect(int bt_fd, unsigned int con_id); +int bt_disconnect(int bt_fd, unsigned int con_id); =20 void bt_waitline(int bt_fd, int line); void bt_waitconnection(int bt_fd, int line); void bt_waitnewconnections(int bt_fd); int bt_isconnected(int bt_cfd, int line); int bt_send(int fd, int len, int repeat); +void bt_showstatus(void); =20 /*=20 * HCI command functions=20 */ =20 +int bt_send_raw_hci(int bt_cfd, unsigned char *data, char len); void bt_inquiry(int bt_cfd, int nbr_rsp, int t); int bt_set_baudrate(int bt_cfd, int spd); -void bt_set_bd_addr(int bt_cfd, int* bd); +void bt_set_bd_addr(int bt_cfd, unsigned char *bd); void read_local_bd(int bt_cfd, unsigned char *bd_addr); void read_remote_bd(int bt_cfd, unsigned char *bd_addr); void role_switch(int bt_cfd, unsigned char *bd_addr, int role); @@ -270,6 +276,9 @@ unsigned char major_class,=20 unsigned char minor_class,=20 unsigned char format); + +void enable_dut(int bt_cfd); + =20 /* Sets friendly name in HW to hostname */ void set_local_name(int bt_cfd, const char *local_name); |
|
From: Mattias A. <mat...@us...> - 2001-03-21 17:26:46
|
The following file was modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
bt_if.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* added function to send raw hci data
* added status message in bt_disconnect
* added bt_showstatus
* modified and added error codes for l2cap in error_msg()
The diff of the modified file(s):
--- bt_if.c 2001/03/13 22:21:17 1.2
+++ bt_if.c 2001/03/21 17:26:44 1.3
@@ -62,6 +62,29 @@
#include "bt_misc.h"
#include "bt_conf.h"
=20
+
+int bt_send_raw_hci(int bt_cfd, unsigned char *data, char len)
+{
+ unsigned char buf[261];
+
+ buf[0] =3D len;
+=20=20
+ memcpy(buf+1, data, len);
+
+ print_data("data :",(char*) buf,(int) len+1);
+
+#ifndef BT_USERSTACK=20
+ if (ioctl(bt_cfd, HCISENDRAWDATA, buf) < 0)
+ {
+ perror("ecs_testctrl");
+ }
+#else
+ printf("not yet for usermode stack...\n");
+ //hci_send_raw_data(data, 16);
+#endif
+ return 0;
+}
+
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
/* Functions common for kernel and usermode stack */
/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */
@@ -214,16 +237,16 @@
return result;
}
=20
-void
+int
bt_disconnect(int bt_fd, unsigned int con_id)
{
-#ifndef BT_USERSTACK
+ int ret_val;
=20
- if (ioctl(bt_fd, BTDISCONNECT, &con_id) < 0)
- {
- perror("Disconnect");
- exit(1);
- }
+#ifndef BT_USERSTACK=20=20
+ if ((ret_val =3D ioctl(bt_fd, BTDISCONNECT, &con_id)))
+ printf("Disconnect failed, %s [%d]\n", error_msg(ret_val), ret_val);
+ else
+ printf("Disconnected.\n");
#else
/* fixme<3> -- only works for rfcomm */
u8 line;=09=09=09=09
@@ -236,9 +259,10 @@
return;
}
=20=20=20
- rfcomm_disconnect_req(GET_RFCOMMLINE(con_id));
+ ret_val =3D rfcomm_disconnect_req(GET_RFCOMMLINE(con_id));
#endif
- printf("Disconnected!\n");
+
+ return ret_val;
}
=20
/* Check whether this line is lower connected in stack (rfcomm ready) */
@@ -258,6 +282,21 @@
return ret;
}
=20
+void bt_showstatus(void)
+{
+#ifdef BT_USERSTACK
+
+ char tmp[4096];
+ int len;
+ len =3D bt_read_internal(tmp);
+ tmp[len] =3D 0;
+ printf("%s", tmp);
+#else
+ /*FIXME -- read /proc/bt_internal and print it on the console */
+ printf("not yet...\n");
+#endif=20
+}
+
=20
/* fixme<1> -- add usermode stack version */
int
@@ -319,6 +358,8 @@
return 0;
}
=20
+
+
void
bt_waitline(int bt_fd, int line)
{
@@ -417,29 +458,20 @@
}
=20
void
-bt_set_bd_addr(int bt_cfd, int* bd)
-{
- int i;
- unsigned char new_bd[6];
-=20=20=20=20
- for (i =3D 0; i < 6; i++)
+bt_set_bd_addr(int bt_cfd, unsigned char *bd)
{
- new_bd[i] =3D (unsigned char) *bd++;
- }
-
printf("Setting BD address to: %02X:%02X:%02X:%02X:%02X:%02X\n",
- new_bd[0], new_bd[1], new_bd[2],
- new_bd[3], new_bd[4], new_bd[5]);
+ bd[0], bd[1], bd[2],
+ bd[3], bd[4], bd[5]);
=20=20=20=20=20
#ifndef BT_USERSTACK
- if (ioctl(bt_cfd, HCIWRITEBDADDR, new_bd) < 0)
+ if (ioctl(bt_cfd, HCIWRITEBDADDR, bd) < 0)
{
perror("Set bd addr");
}
#else
- hci_set_bd_addr(new_bd);
+ hci_set_bd_addr(bd);
#endif=20=20=20=20
-=20
printf("Please reset HW to activate bd change\n");
}
=20
@@ -449,7 +481,7 @@
int bt_set_baudrate(int bt_cfd, int spd)
{
int result;
-=20=20
+ syslog(LOG_INFO, "bt_set_baudrate %d baud", spd);
#ifdef BT_USERSTACK
tcflush(phys_fd, TCIOFLUSH);
hci_set_baudrate(spd);
@@ -473,15 +505,12 @@
}
#else
BD_ADDR rev_bd;
- int i;
-=20=20
hci_read_local_bd(rev_bd);
=20
/* return as big endian */
for (i =3D 0; i < 6; i++) {
bd_addr[i] =3D rev_bd[5-i];
}
-
#endif
}
=20
@@ -755,12 +784,15 @@
{
switch(code)
{=20
- case RES_PSMNEG:
+ case L2CAP_PSMNEG:
return "L2CAP - PSM not valid";
- case RES_SECNEG:
+ case L2CAP_SECNEG:
return "L2CAP - Security block";
- case RES_NOSRC:
+ case L2CAP_NOSRC:
return "L2CAP - Remote side has no resources";
+ case L2CAP_CON_UNRESPONSIVE:
+ return "L2CAP - Unresponsive link";
+
default:
return "L2CAP - unknown reason";
}
@@ -768,7 +800,7 @@
break;
=20=20=20=20=20
default:
- return "Unknown layer - unknown reason";
+ return "General failure";
}
}
=20
|
|
From: Mattias A. <mat...@us...> - 2001-03-21 17:17:39
|
The following file was modified in apps/bluetooth/sdp_server:
Name Old version New version Comment
---- ----------- ----------- -------
sdp_parser.c 1.11 1.12=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
added debug when server starts
The diff of the modified file(s):
--- sdp_parser.c 2001/03/06 11:07:37 1.11
+++ sdp_parser.c 2001/03/21 17:17:38 1.12
@@ -949,6 +949,8 @@
exit(1);
}
=20=20=20
+ syslog(LOG_INFO, "SDP Server starting");=20=20
+
xml_file =3D (argc >=3D 2 ? argv[1] : SDP_XML_FILE);
proc_file =3D (argc >=3D 3 ? argv[2] : SDP_PROC_FILE);
=20=20=20
|
|
From: Mattias A. <mat...@us...> - 2001-03-21 16:27:41
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- Config.in 1.7 1.8=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: added option to enable master slave switch The diff of the modified file(s): --- Config.in 2001/03/05 15:58:22 1.7 +++ Config.in 2001/03/21 16:27:39 1.8 @@ -14,6 +14,7 @@ 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 =20 choice ' Bluetooth hardware type' \ "None CONFIG_BLUETOOTH_NOINIT \ |
|
From: Peter K. <pk...@us...> - 2001-03-21 11:53:11
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- hci.c 1.132 1.133=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Corrected potential NULL-dereference in send_acl_data_task() (thanks to Claus Tondering). The diff of the modified file(s): --- hci.c 2001/03/16 07:38:48 1.132 +++ hci.c 2001/03/21 11:53:09 1.133 @@ -2839,7 +2839,7 @@ bytes2send =3D tx_buf->cur_len; } =20=09 - D_SND(__FUNCTION__", %d bytes \n", tx_buf->cur_len); + D_SND(__FUNCTION__", %d bytes \n", bytes2send); =20=09 /* while there is space in the hardware buffers and we have hci packets to send, we send them. After each sent packet |
|
From: Gordon M. <gm...@us...> - 2001-03-20 20:10:15
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- hci.c 1.132.2.1 1.132.2.2=20=20=20=20=20=20=20 The accompanying log: --Fixed a bug in hci_inquiry. We needed to release the semaphore if the com= mand timer times out or Command Status returns an error. The diff of the modified file(s): --- hci.c 2001/03/20 16:42:53 1.132.2.1 +++ hci.c 2001/03/20 20:12:35 1.132.2.2 @@ -967,10 +967,12 @@ ret =3D -EAGAIN; } pending_inq_res =3D NULL; - up(&hci_inq_semaphore); #endif =20 exit: +#ifdef __KERNEL__ + up(&hci_inq_semaphore); +#endif return ret; } //------------------------------------------------------------------------= ----- |
|
From: Gordon M. <gm...@us...> - 2001-03-20 16:46:24
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- Config.in 1.7 1.7.2.1=20=20=20=20=20=20=20=20=20 The accompanying log: --Forgot to update the configs. This adds CONFIG_BLUETOOTH_HCI_INQUIRY and = CONFIG_BLUETOOTH_SCO (I think). The diff of the modified file(s): --- Config.in 2001/03/05 15:58:22 1.7 +++ Config.in 2001/03/20 16:48:15 1.7.2.1 @@ -14,6 +14,8 @@ 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 ' HCI Inquiry' CONFIG_BLUETOOTH_HCI_INQUIRY + bool ' Kernel Thread' CONFIG_BLUETOOTH_KERNEL_THREAD =20 choice ' Bluetooth hardware type' \ "None CONFIG_BLUETOOTH_NOINIT \ |
|
From: Gordon M. <gm...@us...> - 2001-03-20 16:45:55
|
The following file was modified in linux/include/linux/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
btconfig.h 1.23 1.23.2.1=20=20=20=20=20=20=20=20
The accompanying log:
--Forgot to update the configs. This adds CONFIG_BLUETOOTH_HCI_INQUIRY and =
CONFIG_BLUETOOTH_SCO (I think).
The diff of the modified file(s):
--- btconfig.h 2001/03/05 16:33:36 1.23
+++ btconfig.h 2001/03/20 16:48:15 1.23.2.1
@@ -83,6 +83,8 @@
/* This should be defined if you are using Ericsson firmware that is
older than P9A */
#undef CONFIG_BLUETOOTH_SET_BAUDRATE_BLOCKING
+#define CONFIG_BLUETOOTH_HCI_INQUIRY
+#define CONFIG_BLUETOOTH_SCO
=20
/****************
* L2CAP *
|
|
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] |