Module Name:    src
Committed By:   plunky
Date:           Thu Aug 20 21:40:59 UTC 2009

Modified Files:
        src/share/man/man4: bluetooth.4
        src/sys/netbt: hci.h hci_event.c hci_ioctl.c
        src/usr.sbin/btconfig: btconfig.8 btconfig.c

Log Message:
add a per-unit master setting, to control requesting the master role
when accepting connections.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/share/man/man4/bluetooth.4
cvs rdiff -u -r1.30 -r1.31 src/sys/netbt/hci.h
cvs rdiff -u -r1.18 -r1.19 src/sys/netbt/hci_event.c
cvs rdiff -u -r1.8 -r1.9 src/sys/netbt/hci_ioctl.c
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/btconfig/btconfig.8
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/btconfig/btconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man4/bluetooth.4
diff -u src/share/man/man4/bluetooth.4:1.13 src/share/man/man4/bluetooth.4:1.14
--- src/share/man/man4/bluetooth.4:1.13	Mon May  4 20:42:00 2009
+++ src/share/man/man4/bluetooth.4	Thu Aug 20 21:40:59 2009
@@ -1,4 +1,4 @@
-.\"	$NetBSD: bluetooth.4,v 1.13 2009/05/04 20:42:00 wiz Exp $
+.\"	$NetBSD: bluetooth.4,v 1.14 2009/08/20 21:40:59 plunky Exp $
 .\"
 .\" Copyright (c) 2006 Itronix Inc.
 .\" All rights reserved.
@@ -338,6 +338,7 @@
 #define BTF_INIT_FEATURES	(1\*[Lt]\*[Lt]7)	/* waiting for features */
 #define BTF_NOOP_ON_RESET	(1\*[Lt]\*[Lt]8)	/* wait for No-op on reset */
 #define BTF_INIT_COMMANDS	(1\*[Lt]\*[Lt]9)	/* waiting for supported commands */
+#define BTF_MASTER		(1\*[Lt]\*[Lt]10)	/* request Master role */
 
 struct bt_stats {
 	uint32_t	err_tx;

Index: src/sys/netbt/hci.h
diff -u src/sys/netbt/hci.h:1.30 src/sys/netbt/hci.h:1.31
--- src/sys/netbt/hci.h:1.30	Mon Aug 10 18:25:20 2009
+++ src/sys/netbt/hci.h	Thu Aug 20 21:40:59 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: hci.h,v 1.30 2009/08/10 18:25:20 plunky Exp $	*/
+/*	$NetBSD: hci.h,v 1.31 2009/08/20 21:40:59 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2005 Iain Hibbert.
@@ -54,7 +54,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: hci.h,v 1.30 2009/08/10 18:25:20 plunky Exp $
+ * $Id: hci.h,v 1.31 2009/08/20 21:40:59 plunky Exp $
  * $FreeBSD: src/sys/netgraph/bluetooth/include/ng_hci.h,v 1.6 2005/01/07 01:45:43 imp Exp $
  */
 
@@ -2346,6 +2346,7 @@
 #define BTF_INIT_FEATURES	(1<<7)	/* waiting for features */
 #define BTF_POWER_UP_NOOP	(1<<8)	/* should wait for No-op on power up */
 #define BTF_INIT_COMMANDS	(1<<9)	/* waiting for supported commands */
+#define BTF_MASTER		(1<<10) /* request Master role */
 
 #define BTF_INIT		(BTF_INIT_BDADDR	\
 				| BTF_INIT_BUFFER_SIZE	\

Index: src/sys/netbt/hci_event.c
diff -u src/sys/netbt/hci_event.c:1.18 src/sys/netbt/hci_event.c:1.19
--- src/sys/netbt/hci_event.c:1.18	Thu Apr 24 11:38:37 2008
+++ src/sys/netbt/hci_event.c	Thu Aug 20 21:40:59 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: hci_event.c,v 1.18 2008/04/24 11:38:37 ad Exp $	*/
+/*	$NetBSD: hci_event.c,v 1.19 2009/08/20 21:40:59 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2005 Iain Hibbert.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hci_event.c,v 1.18 2008/04/24 11:38:37 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hci_event.c,v 1.19 2009/08/20 21:40:59 plunky Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -653,7 +653,7 @@
 	} else {
 		memset(&ap, 0, sizeof(ap));
 		bdaddr_copy(&ap.bdaddr, &ep.bdaddr);
-		if (unit->hci_link_policy & HCI_LINK_POLICY_ENABLE_ROLE_SWITCH)
+		if (unit->hci_flags & BTF_MASTER)
 			ap.role = HCI_ROLE_MASTER;
 		else
 			ap.role = HCI_ROLE_SLAVE;

Index: src/sys/netbt/hci_ioctl.c
diff -u src/sys/netbt/hci_ioctl.c:1.8 src/sys/netbt/hci_ioctl.c:1.9
--- src/sys/netbt/hci_ioctl.c:1.8	Sun May  3 17:21:12 2009
+++ src/sys/netbt/hci_ioctl.c	Thu Aug 20 21:40:59 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: hci_ioctl.c,v 1.8 2009/05/03 17:21:12 elad Exp $	*/
+/*	$NetBSD: hci_ioctl.c,v 1.9 2009/08/20 21:40:59 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2005 Iain Hibbert.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hci_ioctl.c,v 1.8 2009/05/03 17:21:12 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hci_ioctl.c,v 1.9 2009/08/20 21:40:59 plunky Exp $");
 
 #include <sys/param.h>
 #include <sys/domain.h>
@@ -234,7 +234,8 @@
 			unit->hci_flags &= ~BTF_UP;
 		}
 
-		unit->hci_flags |= (btr->btr_flags & BTF_INIT);
+		unit->hci_flags &= ~BTF_MASTER;
+		unit->hci_flags |= (btr->btr_flags & (BTF_INIT | BTF_MASTER));
 
 		if ((unit->hci_flags & BTF_UP) == 0
 		    && (btr->btr_flags & BTF_UP)) {

Index: src/usr.sbin/btconfig/btconfig.8
diff -u src/usr.sbin/btconfig/btconfig.8:1.10 src/usr.sbin/btconfig/btconfig.8:1.11
--- src/usr.sbin/btconfig/btconfig.8:1.10	Thu Aug 20 11:45:51 2009
+++ src/usr.sbin/btconfig/btconfig.8	Thu Aug 20 21:40:59 2009
@@ -1,4 +1,4 @@
-.\" $NetBSD: btconfig.8,v 1.10 2009/08/20 11:45:51 plunky Exp $
+.\" $NetBSD: btconfig.8,v 1.11 2009/08/20 21:40:59 plunky Exp $
 .\"
 .\" Copyright (c) 2006 Itronix Inc.
 .\" All rights reserved.
@@ -93,11 +93,13 @@
 Enable Role Switching.
 In a Bluetooth piconet there is one Master and up to seven Slaves, and
 normally the device that initiates a connection will take the Master role.
-Enabling this option allows remote devices to switch connection roles
-and become the Master rather than needing to form another piconet
-which may cause problems.
+Enabling this option allows remote devices to switch connection roles.
 .It Cm -switch
 Disable Role Switching.
+.It Cm master
+Request the Master role when accepting connections.
+.It Cm -master
+Do not request Master role.
 .It Cm hold
 Enable Hold Mode.
 .It Cm -hold

Index: src/usr.sbin/btconfig/btconfig.c
diff -u src/usr.sbin/btconfig/btconfig.c:1.13 src/usr.sbin/btconfig/btconfig.c:1.14
--- src/usr.sbin/btconfig/btconfig.c:1.13	Mon Jul 21 13:36:57 2008
+++ src/usr.sbin/btconfig/btconfig.c	Thu Aug 20 21:40:59 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: btconfig.c,v 1.13 2008/07/21 13:36:57 lukem Exp $ */
+/* $NetBSD: btconfig.c,v 1.14 2009/08/20 21:40:59 plunky Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 __COPYRIGHT("@(#) Copyright (c) 2006 Itronix, Inc.  All rights reserved.");
-__RCSID("$NetBSD: btconfig.c,v 1.13 2008/07/21 13:36:57 lukem Exp $");
+__RCSID("$NetBSD: btconfig.c,v 1.14 2009/08/20 21:40:59 plunky Exp $");
 
 #include <sys/ioctl.h>
 #include <sys/param.h>
@@ -106,6 +106,7 @@
 			"\010INIT_FEATURES"	\
 			"\011POWER_UP_NOOP"	\
 			"\012INIT_COMMANDS"	\
+			"\013MASTER"		\
 			""
 
 /* authorisation (flag) */
@@ -118,6 +119,9 @@
 int opt_pscan = 0;
 int opt_iscan = 0;
 
+/* master role option */
+int opt_master = 0;
+
 /* link policy options (flags) */
 int opt_switch = 0;
 int opt_hold = 0;
@@ -172,6 +176,8 @@
 	{ "-pscan",	P_CLR,	&opt_pscan,	NULL	},
 	{ "iscan",	P_SET,	&opt_iscan,	NULL	},
 	{ "-iscan",	P_CLR,	&opt_iscan,	NULL	},
+	{ "master",	P_SET,	&opt_master,	NULL	},
+	{ "-master",	P_CLR,	&opt_master,	NULL	},
 	{ "switch",	P_SET,	&opt_switch,	NULL	},
 	{ "-switch",	P_CLR,	&opt_switch,	NULL	},
 	{ "hold",	P_SET,	&opt_hold,	NULL	},
@@ -506,6 +512,16 @@
 			err(EXIT_FAILURE, "%s", btr.btr_name);
 	}
 
+	if (opt_master) {
+		if (opt_master > 0)
+			btr.btr_flags |= BTF_MASTER;
+		else
+			btr.btr_flags &= ~BTF_MASTER;
+
+		if (ioctl(hci, SIOCSBTFLAGS, &btr) < 0)
+			err(EXIT_FAILURE, "SIOCSBTFLAGS");
+	}
+
 	if (opt_switch || opt_hold || opt_sniff || opt_park) {
 		uint16_t val = btr.btr_link_policy;
 

Reply via email to