|
From: Gordon M. <gm...@us...> - 2001-03-24 21:12:09
|
The following files were modified in apps/bluetooth/experimental:
Name Old version New version Comment
---- ----------- ----------- -------
Makefile 1.2 1.2.2.1=20=20=20=20=20=20=20=20=20
bt_if.c 1.2 1.2.2.1=20=20=20=20=20=20=20=20=20
bt_if.h 1.1 1.1.2.1=20=20=20=20=20=20=20=20=20
bt_ipa.c 1.1 1.1.2.1=20=20=20=20=20=20=20=20=20
bt_ipa.h 1.1 1.1.2.1=20=20=20=20=20=20=20=20=20
bt_misc.c 1.2 1.2.2.1=20=20=20=20=20=20=20=20=20
bt_misc.h 1.1 1.1.2.1=20=20=20=20=20=20=20=20=20
bt_vendor.c 1.3 1.3.2.1=20=20=20=20=20=20=20=20=20
btcon.c 1.1 1.1.2.1=20=20=20=20=20=20=20=20=20
btd.c 1.4 1.4.2.1=20=20=20=20=20=20=20=20=20
btdisc.c 1.1 1.1.2.1=20=20=20=20=20=20=20=20=20
btinit.c 1.2 1.2.2.1=20=20=20=20=20=20=20=20=20
bttest.c 1.2 1.2.2.1=20=20=20=20=20=20=20=20=20
The accompanying log:
Merged from trunk
The diff of the modified file(s):
--- Makefile 2001/03/10 12:49:32 1.2
+++ Makefile 2001/03/24 21:11:38 1.2.2.1
@@ -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)
--- bt_if.c 2001/03/13 22:21:17 1.2
+++ bt_if.c 2001/03/24 21:11:38 1.2.2.1
@@ -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
--- bt_if.h 2001/03/02 10:59:57 1.1
+++ bt_if.h 2001/03/24 21:11:38 1.1.2.1
@@ -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);
--- bt_ipa.c 2001/03/02 10:59:57 1.1
+++ bt_ipa.c 2001/03/24 21:11:38 1.1.2.1
@@ -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/24 21:11:38 1.1.2.1
@@ -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 */
--- bt_misc.c 2001/03/02 14:30:32 1.2
+++ bt_misc.c 2001/03/24 21:11:38 1.2.2.1
@@ -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);
--- bt_misc.h 2001/03/02 10:59:57 1.1
+++ bt_misc.h 2001/03/24 21:11:38 1.1.2.1
@@ -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__*/
--- bt_vendor.c 2001/03/10 12:47:09 1.3
+++ bt_vendor.c 2001/03/24 21:11:38 1.3.2.1
@@ -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)
--- btcon.c 2001/03/02 10:59:57 1.1
+++ btcon.c 2001/03/24 21:11:38 1.1.2.1
@@ -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
--- btd.c 2001/03/13 22:21:17 1.4
+++ btd.c 2001/03/24 21:11:38 1.4.2.1
@@ -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*)MODEME...
[truncated message content] |