|
From: Anders J. <and...@us...> - 2003-04-14 08:47:57
|
The following files were modified in apps/bluetooth/experimental:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
bt_if.c 1.57 1.58=20=20=20=20=20=20=20=20=20=20=20=20=20=20
bt_if.h 1.39 1.40=20=20=20=20=20=20=20=20=20=20=20=20=20=20
btconfig.c 1.11 1.12=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added option p to btconfig, set to one to force piconet mode if we
are acting as a server. This means that any client which fail to
do the M/S switch will be disconnected.
The diff of the modified file(s):
--- bt_if.c 6 Feb 2003 15:31:08 -0000 1.57
+++ bt_if.c 14 Apr 2003 08:47:22 -0000 1.58
@@ -669,6 +669,20 @@
return 0;
}
=20
+int bt_dont_allow_slave(int bt_cfd, int flag)
+{
+ syslog(LOG_INFO, __FUNCTION__": %d", flag);
+#ifndef BT_USERSTACK
+ if (ioctl(bt_cfd, BTDONTALLOWSLAVE, &flag) < 0)
+ {
+ perror(__FUNCTION__);
+ return -1;
+ }
+#endif
+ return 0;
+}
+
+
int bt_set_max_conections(int bt_cfd, int connections)
{
syslog(LOG_INFO, __FUNCTION__ ": %d", connections);
--- bt_if.h 13 Jan 2003 19:48:14 -0000 1.39
+++ bt_if.h 14 Apr 2003 08:47:23 -0000 1.40
@@ -257,6 +257,8 @@
#define BTSETMSSWITCH _IOW(BT_IOC_MAGIC, 0xf3, unsigned char)
#define BTSETBCSPMODE _IOWR(BT_IOC_MAGIC, 0xf4, int)
=20
+#define BTDONTALLOWSLAVE _IOW(BT_IOC_MAGIC, 0xfb, unsigned char)
+
#define CSR_PSKEY_MSGHDR_SIZE 3
#define CSR_PSKEY_MAXPARAMS 40
=20
@@ -340,6 +342,7 @@
int bt_send(int fd, int len, int repeat);
void bt_showstatus(void);
int bt_force_msswitch_as_server(int bt_cfd, int enable);
+int bt_dont_allow_slave(int bt_cfd, int flag);
int bt_set_max_conections(int bt_cfd, int connections);
=20
/*
--- btconfig.c 26 Feb 2002 17:43:32 -0000 1.11
+++ btconfig.c 14 Apr 2003 08:47:23 -0000 1.12
@@ -107,6 +107,7 @@
static int var_add_host_name =3D FALSE;
static int var_write_scan_enable =3D -1; /* not yet set */
static int var_force_ms_switch =3D -1; /* not yet set */
+static int var_dont_allow_slave =3D -1; /* not yet set */
static int var_set_local_name =3D 0;
static int var_max_connections =3D -1; /* not yet set */
static short var_max_power =3D SHRT_MAX; /* not yet set */
@@ -120,6 +121,8 @@
{ "name", 1, NULL, 'n' }, /* set BT friendly name */
{ "wrscan-enable", 1, NULL, 'w' }, /* sets write scan enable */
{ "max-connections", 1, NULL, 'c' }, /* sets max simultatious connectio=
ns */
+ { "piconet-mode", 1, NULL, 'p' }, /* set if we disallow clients whic=
h doesn't support
+ the M/S switch */
{ 0, 0, 0, 0 }
};
=20
@@ -138,13 +141,14 @@
int opt_write_scan_enable =3D -1;
int opt_force_ms_switch =3D -1;
int opt_max_connections =3D -1;
+ int opt_dont_allow_slave =3D -1;
=20=20=20
char *opt_name =3D NULL;
char *opt_config_file =3D CONF_FILE;
=20
/* Parse command line options */
=20
- while ((opt =3D getopt_long(argc, argv, "f:hm:n:w:c:",
+ while ((opt =3D getopt_long(argc, argv, "f:hm:n:w:c:p:",
long_options, &option_index)) !=3D -1)
{
switch (opt)
@@ -177,6 +181,12 @@
opt_max_connections =3D atoi(optarg);
break;
=20=20=20=20=20=20=20
+ case 'p':
+ /* Piconet mode, meaning that we disconnect any
+ clients which fail to do M/S switching */
+ opt_dont_allow_slave =3D atoi(optarg);
+ break;
+=20=20=20=20=20=20
default:
break;
}
@@ -208,7 +218,8 @@
var_write_scan_enable >=3D 0 ||
var_force_ms_switch >=3D 0 ||
var_max_connections >=3D 0 ||
- var_max_power !=3D SHRT_MAX)
+ var_max_power !=3D SHRT_MAX ||
+ var_dont_allow_slave >=3D 0)
{
/* Open BT ctrl device */=20=20
if ((bt_cfd =3D bt_openctrl()) < 0)
@@ -240,6 +251,9 @@
if (var_max_power !=3D SHRT_MAX)
bt_set_max_power(bt_cfd, var_max_power);
=20=20=20=20=20
+ if (var_dont_allow_slave >=3D 0)
+ bt_dont_allow_slave(bt_cfd, var_dont_allow_slave);
+=20=20=20=20
close(bt_cfd);
}
=20
@@ -465,6 +479,13 @@
D(syslog(LOG_INFO, __FUNCTION__ ": Maximum transmit power: %s", value)=
);
}
=20=20=20
+ else if (!strcasecmp(field, "DisconnectOnMSFailure"))
+ {
+ var_dont_allow_slave =3D !strcasecmp(value, "yes");
+ D(syslog(LOG_INFO, __FUNCTION__ ": Disconnect on MS-switch failure: %s=
",
+ (var_dont_allow_slave ? "yes" : "no")));
+ }
+
return TRUE;
} /* configure_field */
=20
|