Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src add a per-unit master setting, to control requesting the mas...



details:   https://anonhg.NetBSD.org/src/rev/9b1374499bff
branches:  trunk
changeset: 746829:9b1374499bff
user:      plunky <plunky%NetBSD.org@localhost>
date:      Thu Aug 20 21:40:59 2009 +0000

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

diffstat:

 share/man/man4/bluetooth.4   |   3 ++-
 sys/netbt/hci.h              |   5 +++--
 sys/netbt/hci_event.c        |   6 +++---
 sys/netbt/hci_ioctl.c        |   7 ++++---
 usr.sbin/btconfig/btconfig.8 |  10 ++++++----
 usr.sbin/btconfig/btconfig.c |  20 ++++++++++++++++++--
 6 files changed, 36 insertions(+), 15 deletions(-)

diffs (186 lines):

diff -r bddecf15618c -r 9b1374499bff share/man/man4/bluetooth.4
--- a/share/man/man4/bluetooth.4        Thu Aug 20 21:34:03 2009 +0000
+++ b/share/man/man4/bluetooth.4        Thu Aug 20 21:40:59 2009 +0000
@@ -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;
diff -r bddecf15618c -r 9b1374499bff sys/netbt/hci.h
--- a/sys/netbt/hci.h   Thu Aug 20 21:34:03 2009 +0000
+++ b/sys/netbt/hci.h   Thu Aug 20 21:40:59 2009 +0000
@@ -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  \
diff -r bddecf15618c -r 9b1374499bff sys/netbt/hci_event.c
--- a/sys/netbt/hci_event.c     Thu Aug 20 21:34:03 2009 +0000
+++ b/sys/netbt/hci_event.c     Thu Aug 20 21:40:59 2009 +0000
@@ -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;
diff -r bddecf15618c -r 9b1374499bff sys/netbt/hci_ioctl.c
--- a/sys/netbt/hci_ioctl.c     Thu Aug 20 21:34:03 2009 +0000
+++ b/sys/netbt/hci_ioctl.c     Thu Aug 20 21:40:59 2009 +0000
@@ -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)) {
diff -r bddecf15618c -r 9b1374499bff usr.sbin/btconfig/btconfig.8
--- a/usr.sbin/btconfig/btconfig.8      Thu Aug 20 21:34:03 2009 +0000
+++ b/usr.sbin/btconfig/btconfig.8      Thu Aug 20 21:40:59 2009 +0000
@@ -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
diff -r bddecf15618c -r 9b1374499bff usr.sbin/btconfig/btconfig.c
--- a/usr.sbin/btconfig/btconfig.c      Thu Aug 20 21:34:03 2009 +0000
+++ b/usr.sbin/btconfig/btconfig.c      Thu Aug 20 21:40:59 2009 +0000
@@ -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;
 



Home | Main Index | Thread Index | Old Index