summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bluetooth/l2control
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2003-05-10 21:50:37 +0000
committerjulian <julian@FreeBSD.org>2003-05-10 21:50:37 +0000
commitfe2526340b1a2d7ed079617d2eca31aa6425d937 (patch)
tree6e0dee485a2a2757ceb37dde12c1fa3ef410e6b7 /usr.sbin/bluetooth/l2control
parentdc5734d94b071df224b65d45b95d9ae7c5d563ab (diff)
downloadFreeBSD-src-fe2526340b1a2d7ed079617d2eca31aa6425d937.zip
FreeBSD-src-fe2526340b1a2d7ed079617d2eca31aa6425d937.tar.gz
Part 2 of the commit if new bluetooth code.
Submitted by: Maksim Yevmenkin <m_evmenkin@yahoo.com> Approved by: re@
Diffstat (limited to 'usr.sbin/bluetooth/l2control')
-rw-r--r--usr.sbin/bluetooth/l2control/Makefile4
-rw-r--r--usr.sbin/bluetooth/l2control/l2cap.c75
-rw-r--r--usr.sbin/bluetooth/l2control/l2control.866
-rw-r--r--usr.sbin/bluetooth/l2control/l2control.c14
-rw-r--r--usr.sbin/bluetooth/l2control/l2control.h2
5 files changed, 98 insertions, 63 deletions
diff --git a/usr.sbin/bluetooth/l2control/Makefile b/usr.sbin/bluetooth/l2control/Makefile
index b098874..f6fb501 100644
--- a/usr.sbin/bluetooth/l2control/Makefile
+++ b/usr.sbin/bluetooth/l2control/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.3 2002/09/04 21:30:40 max Exp $
+# $Id: Makefile,v 1.2 2003/03/15 03:07:47 max Exp $
# $FreeBSD$
DESTDIR= /usr/sbin/
@@ -6,7 +6,7 @@ MANDIR= ../share/man/man
PROG= l2control
MAN8= l2control.8
WARNS?= 2
-CFLAGS+= -g -I../../../sys/netgraph/bluetooth/include
+CFLAGS+= -g -I${.CURDIR}/../../../sys/netgraph/bluetooth/include
SRCS= l2cap.c l2control.c
.include <bsd.prog.mk>
diff --git a/usr.sbin/bluetooth/l2control/l2cap.c b/usr.sbin/bluetooth/l2control/l2cap.c
index a0f2d24..ca4111d 100644
--- a/usr.sbin/bluetooth/l2control/l2cap.c
+++ b/usr.sbin/bluetooth/l2control/l2cap.c
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: l2cap.c,v 1.6 2002/09/04 21:30:40 max Exp $
+ * $Id: l2cap.c,v 1.4 2003/04/26 23:11:25 max Exp $
* $FreeBSD$
*/
@@ -53,9 +53,6 @@ l2cap_read_node_flags(int s, int argc, char **argv)
if (ioctl(s, SIOC_L2CAP_NODE_GET_FLAGS, &r, sizeof(r)) < 0)
return (ERROR);
- fprintf(stdout, "BD_ADDR: %x:%x:%x:%x:%x:%x\n",
- r.src.b[5], r.src.b[4], r.src.b[3],
- r.src.b[2], r.src.b[1], r.src.b[0]);
fprintf(stdout, "Connectionless traffic flags:\n");
fprintf(stdout, "\tSDP: %s\n",
(r.flags & NG_L2CAP_CLT_SDP_DISABLED)? "disabled" : "enabled");
@@ -77,9 +74,6 @@ l2cap_read_debug_level(int s, int argc, char **argv)
if (ioctl(s, SIOC_L2CAP_NODE_GET_DEBUG, &r, sizeof(r)) < 0)
return (ERROR);
- fprintf(stdout, "BD_ADDR: %x:%x:%x:%x:%x:%x\n",
- r.src.b[5], r.src.b[4], r.src.b[3],
- r.src.b[2], r.src.b[1], r.src.b[0]);
fprintf(stdout, "Debug level: %d\n", r.debug);
return (OK);
@@ -135,17 +129,14 @@ l2cap_read_connection_list(int s, int argc, char **argv)
goto out;
}
- fprintf(stdout, "BD_ADDR: %x:%x:%x:%x:%x:%x\n",
- r.src.b[5], r.src.b[4], r.src.b[3],
- r.src.b[2], r.src.b[1], r.src.b[0]);
fprintf(stdout, "L2CAP connections:\n");
fprintf(stdout,
"Remote BD_ADDR Handle Flags Pending State\n");
for (n = 0; n < r.num_connections; n++) {
fprintf(stdout,
"%02x:%02x:%02x:%02x:%02x:%02x " \
- " %5d " \
- "%2.2s %2.2s " \
+ "%6d " \
+ "%c%c%c%c%c " \
"%7d " \
"%s\n",
r.connections[n].remote.b[5],
@@ -155,8 +146,11 @@ l2cap_read_connection_list(int s, int argc, char **argv)
r.connections[n].remote.b[1],
r.connections[n].remote.b[0],
r.connections[n].con_handle,
- ((r.connections[n].flags & NG_L2CAP_CON_TX)? "TX" : ""),
- ((r.connections[n].flags & NG_L2CAP_CON_RX)? "RX" : ""),
+ ((r.connections[n].flags & NG_L2CAP_CON_OUTGOING)? 'O' : 'I'),
+ ((r.connections[n].flags & NG_L2CAP_CON_LP_TIMO)? 'L' : ' '),
+ ((r.connections[n].flags & NG_L2CAP_CON_AUTO_DISCON_TIMO)? 'D' : ' '),
+ ((r.connections[n].flags & NG_L2CAP_CON_TX)? 'T' : ' '),
+ ((r.connections[n].flags & NG_L2CAP_CON_RX)? 'R' : ' '),
r.connections[n].pending,
con_state2str(r.connections[n].state));
}
@@ -198,9 +192,6 @@ l2cap_read_channel_list(int s, int argc, char **argv)
goto out;
}
- fprintf(stdout, "BD_ADDR: %x:%x:%x:%x:%x:%x\n",
- r.src.b[5], r.src.b[4], r.src.b[3],
- r.src.b[2], r.src.b[1], r.src.b[0]);
fprintf(stdout, "L2CAP channels:\n");
fprintf(stdout,
"Remote BD_ADDR SCID/ DCID PSM IMTU/ OMTU State\n");
@@ -224,6 +215,46 @@ out:
return (error);
} /* l2cap_read_channel_list */
+/* Send read_auto_disconnect_timeout command to the node */
+static int
+l2cap_read_auto_disconnect_timeout(int s, int argc, char **argv)
+{
+ struct ng_btsocket_l2cap_raw_auto_discon_timo r;
+
+ memset(&r, 0, sizeof(r));
+ if (ioctl(s, SIOC_L2CAP_NODE_GET_AUTO_DISCON_TIMO, &r, sizeof(r)) < 0)
+ return (ERROR);
+
+ if (r.timeout != 0)
+ fprintf(stdout, "Auto disconnect timeout: %d sec\n", r.timeout);
+ else
+ fprintf(stdout, "Auto disconnect disabled\n");
+
+ return (OK);
+} /* l2cap_read_auto_disconnect_timeout */
+
+/* Send write_auto_disconnect_timeout command to the node */
+static int
+l2cap_write_auto_disconnect_timeout(int s, int argc, char **argv)
+{
+ struct ng_btsocket_l2cap_raw_auto_discon_timo r;
+
+ memset(&r, 0, sizeof(r));
+ switch (argc) {
+ case 1:
+ r.timeout = atoi(argv[0]);
+ break;
+
+ default:
+ return (USAGE);
+ }
+
+ if (ioctl(s, SIOC_L2CAP_NODE_SET_AUTO_DISCON_TIMO, &r, sizeof(r)) < 0)
+ return (ERROR);
+
+ return (OK);
+} /* l2cap_write_auto_disconnect_timeout */
+
struct l2cap_command l2cap_commands[] = {
{
"read_node_flags",
@@ -251,6 +282,16 @@ struct l2cap_command l2cap_commands[] = {
&l2cap_read_channel_list
},
{
+"read_auto_disconnect_timeout",
+"Get L2CAP node auto disconnect timeout (in sec)",
+&l2cap_read_auto_disconnect_timeout
+},
+{
+"write_auto_disconnect_timeout <timeout>",
+"Set L2CAP node auto disconnect timeout (in sec)",
+&l2cap_write_auto_disconnect_timeout
+},
+{
NULL,
}};
diff --git a/usr.sbin/bluetooth/l2control/l2control.8 b/usr.sbin/bluetooth/l2control/l2control.8
index 51018b4..fb09276 100644
--- a/usr.sbin/bluetooth/l2control/l2control.8
+++ b/usr.sbin/bluetooth/l2control/l2control.8
@@ -1,6 +1,8 @@
+.\" l2control.8
+.\"
.\" Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
.\" All rights reserved.
-.\"
+.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@@ -9,7 +11,7 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\"
+.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -21,9 +23,9 @@
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
-.\"
+.\"
+.\" $Id: l2control.8,v 1.3 2003/04/27 19:45:34 max Exp $
.\" $FreeBSD$
-.\"
.Dd June 14, 2002
.Dt L2CONTROL 8
.Os
@@ -32,38 +34,33 @@
.Nd L2CAP configuration utility
.Sh SYNOPSIS
.Nm
-.Op Fl a Ar BD_ADDR
-.Op Ar command
+.Op Fl a Ar local BD_ADDR
+.Op Fl h
+.Op Ar command
.Op Ar parameters ...
.Sh DESCRIPTION
The
.Nm
-utility connects to the local device with specified
-.Ar BD_ADDR
-and attempts to send specified
-.Ar command .
-The
+utility connects to the local device with specified BD_ADDR and attempts
+to send specified command.
.Nm
-utility
-will print results to the standard output and error messages to
+will print results to the standard output and error messages to
the standard error.
.Pp
The options are as follows:
.Bl -tag -width indent
-.It Fl a Ar BD_ADDR
-Connect to the local device with specified
-.Ar BD_ADDR .
-Example:
-.Fl a Li 00:01:02:03:04:05 .
-.It Ar command
-One of the supported commands (see below).
-Special command
-.Cm help
-can be used to obtain the list of all supported commands.
-To get more
+.It Fl a Ar local BD_ADDR
+Connect to the local device with specified BD_ADDR. Example:
+.Fl a Ar 00:01:02:03:04:05 .
+.It Fl h
+Display usage message and exit.
+.It command
+One of the supported commands (see below). Special command
+.Dq help
+can be used to obtain the list of all supported commands. To get more
information about specific command use
-.Cm help Ar command .
-.It Ar parameters
+.Dq help command .
+.It parameters
One or more optional space separated command parameters.
.El
.Sh COMMANDS
@@ -71,13 +68,16 @@ The currently supported node commands in
.Nm
are:
.Pp
-.Bl -tag -offset indent -compact
-.It Cm Read_Node_Flags
-.It Cm Read_Debug_Level
-.It Cm Write_Debug_Level
-.It Cm Read_Connection_List
-.It Cm Read_Channel_List
-.El
+.Bd -literal -offset indent -compact
+Read_Node_Flags
+Read_Debug_Level
+Write_Debug_Level
+Read_Connection_List
+Read_Channel_List
+Read_Auto_Disconnect_Timeout
+Write_Auto_Disconnect_Timeout
+.Ed
+.Pp
.Sh DIAGNOSTICS
.Ex -std
.Sh SEE ALSO
diff --git a/usr.sbin/bluetooth/l2control/l2control.c b/usr.sbin/bluetooth/l2control/l2control.c
index ef65826..a259657 100644
--- a/usr.sbin/bluetooth/l2control/l2control.c
+++ b/usr.sbin/bluetooth/l2control/l2control.c
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: l2control.c,v 1.5 2002/09/04 21:30:40 max Exp $
+ * $Id: l2control.c,v 1.3 2003/04/27 19:45:34 max Exp $
* $FreeBSD$
*/
@@ -61,7 +61,7 @@ main(int argc, char *argv[])
memset(&bdaddr, 0, sizeof(bdaddr));
/* Process command line arguments */
- while ((n = getopt(argc, argv, "a:")) != -1) {
+ while ((n = getopt(argc, argv, "a:h")) != -1) {
switch (n) {
case 'a': {
int a0, a1, a2, a3, a4, a5;
@@ -80,6 +80,7 @@ main(int argc, char *argv[])
bdaddr.b[5] = (a5 & 0xff);
} break;
+ case 'h':
default:
usage();
break;
@@ -148,13 +149,6 @@ do_l2cap_command(bdaddr_p bdaddr, int argc, char **argv)
sa.l2cap_bdaddr.b[3], sa.l2cap_bdaddr.b[2],
sa.l2cap_bdaddr.b[1], sa.l2cap_bdaddr.b[0]);
- if (connect(s, (struct sockaddr *) &sa, sizeof(sa)) < 0)
- err(2,
-"Could not connect socket, bdaddr=%x:%x:%x:%x:%x:%x",
- sa.l2cap_bdaddr.b[5], sa.l2cap_bdaddr.b[4],
- sa.l2cap_bdaddr.b[3], sa.l2cap_bdaddr.b[2],
- sa.l2cap_bdaddr.b[1], sa.l2cap_bdaddr.b[0]);
-
e = 0x0ffff;
if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, &e, sizeof(e)) < 0)
err(3, "Coult not setsockopt(RCVBUF, %d)", e);
@@ -220,7 +214,7 @@ print_l2cap_command(struct l2cap_command *category)
static void
usage(void)
{
- fprintf(stdout, "Usage: l2control -a BD_ADDR cmd [p1] [..]]\n");
+ fprintf(stdout, "Usage: l2control -a BD_ADDR [-h] cmd [p1] [..]]\n");
exit(255);
} /* usage */
diff --git a/usr.sbin/bluetooth/l2control/l2control.h b/usr.sbin/bluetooth/l2control/l2control.h
index 0f6e5dc..43d4561 100644
--- a/usr.sbin/bluetooth/l2control/l2control.h
+++ b/usr.sbin/bluetooth/l2control/l2control.h
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: l2control.h,v 1.2 2002/09/04 21:30:40 max Exp $
+ * $Id: l2control.h,v 1.1 2002/11/24 20:22:41 max Exp $
* $FreeBSD$
*/
OpenPOWER on IntegriCloud