CVS commit: src/usr.sbin/btdevctl

2020-06-06 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jun  7 00:12:00 UTC 2020

Modified Files:
src/usr.sbin/btdevctl: btdevctl.c db.c print.c sdp.c

Log Message:
Update for proplib(3) API changes.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/btdevctl/btdevctl.c \
src/usr.sbin/btdevctl/sdp.c
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/btdevctl/db.c
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/btdevctl/print.c

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

Modified files:

Index: src/usr.sbin/btdevctl/btdevctl.c
diff -u src/usr.sbin/btdevctl/btdevctl.c:1.10 src/usr.sbin/btdevctl/btdevctl.c:1.11
--- src/usr.sbin/btdevctl/btdevctl.c:1.10	Sat Aug 27 22:24:14 2011
+++ src/usr.sbin/btdevctl/btdevctl.c	Sun Jun  7 00:12:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: btdevctl.c,v 1.10 2011/08/27 22:24:14 joerg Exp $	*/
+/*	$NetBSD: btdevctl.c,v 1.11 2020/06/07 00:12:00 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -35,7 +35,7 @@
 __COPYRIGHT("@(#) Copyright (c) 2006 The NetBSD Foundation, Inc.\
   @(#) Copyright (c) 2006 Itronix, Inc.\
   All rights reserved.");
-__RCSID("$NetBSD: btdevctl.c,v 1.10 2011/08/27 22:24:14 joerg Exp $");
+__RCSID("$NetBSD: btdevctl.c,v 1.11 2020/06/07 00:12:00 thorpej Exp $");
 
 #include 
 #include 
@@ -62,7 +62,6 @@ int
 main(int argc, char *argv[])
 {
 	prop_dictionary_t dev;
-	prop_object_t obj;
 	bdaddr_t laddr, raddr;
 	const char *service, *mode;
 	int ch, query, verbose, attach, detach, set, none;
@@ -161,11 +160,8 @@ main(int argc, char *argv[])
 	}
 
 	if (mode != NULL) {
-		obj = prop_string_create_cstring_nocopy(mode);
-		if (obj == NULL || !prop_dictionary_set(dev, BTDEVmode, obj))
+		if (!prop_dictionary_set_string_nocopy(dev, BTDEVmode, mode))
 			errx(EXIT_FAILURE, "proplib failure (%s)", BTDEVmode);
-
-		prop_object_release(obj);
 		set = true;
 	}
 
@@ -178,26 +174,17 @@ main(int argc, char *argv[])
 		errx(EXIT_FAILURE, "service store failed");
 
 	/* add binary local-bdaddr */
-	obj = prop_data_create_data(&laddr, sizeof(laddr));
-	if (obj == NULL || !prop_dictionary_set(dev, BTDEVladdr, obj))
+	if (!prop_dictionary_set_data(dev, BTDEVladdr, &laddr, sizeof(laddr)))
 		errx(EXIT_FAILURE, "proplib failure (%s)", BTDEVladdr);
 
-	prop_object_release(obj);
-
 	/* add binary remote-bdaddr */
-	obj = prop_data_create_data(&raddr, sizeof(raddr));
-	if (obj == NULL || !prop_dictionary_set(dev, BTDEVraddr, obj))
+	if (!prop_dictionary_set_data(dev, BTDEVraddr, &raddr, sizeof(raddr)))
 		errx(EXIT_FAILURE, "proplib failure (%s)", BTDEVraddr);
 
-	prop_object_release(obj);
-
 	/* add service name */
-	obj = prop_string_create_cstring(service);
-	if (obj == NULL || !prop_dictionary_set(dev, BTDEVservice, obj))
+	if (!prop_dictionary_set_string(dev, BTDEVservice, service))
 		errx(EXIT_FAILURE, "proplib failure (%s)", BTDEVservice);
 
-	prop_object_release(obj);
-
 	if (verbose == true)
 		cfg_print(dev);
 
Index: src/usr.sbin/btdevctl/sdp.c
diff -u src/usr.sbin/btdevctl/sdp.c:1.10 src/usr.sbin/btdevctl/sdp.c:1.11
--- src/usr.sbin/btdevctl/sdp.c:1.10	Sun Dec 10 20:38:14 2017
+++ src/usr.sbin/btdevctl/sdp.c	Sun Jun  7 00:12:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdp.c,v 1.10 2017/12/10 20:38:14 bouyer Exp $	*/
+/*	$NetBSD: sdp.c,v 1.11 2020/06/07 00:12:00 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -56,7 +56,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: sdp.c,v 1.10 2017/12/10 20:38:14 bouyer Exp $");
+__RCSID("$NetBSD: sdp.c,v 1.11 2020/06/07 00:12:00 thorpej Exp $");
 
 #include 
 
@@ -318,43 +318,27 @@ config_hid(prop_dictionary_t dict, sdp_d
 	|| hid_length == -1)
 		return ENOATTR;
 
-	obj = prop_string_create_cstring_nocopy("bthidev");
-	if (obj == NULL || !prop_dictionary_set(dict, BTDEVtype, obj))
+	if (!prop_dictionary_set_string_nocopy(dict, BTDEVtype, "bthidev"))
 		return errno;
 
-	prop_object_release(obj);
-
-	obj = prop_number_create_integer(control_psm);
-	if (obj == NULL || !prop_dictionary_set(dict, BTHIDEVcontrolpsm, obj))
-		return errno;
-
-	prop_object_release(obj);
-
-	obj = prop_number_create_integer(interrupt_psm);
-	if (obj == NULL || !prop_dictionary_set(dict, BTHIDEVinterruptpsm, obj))
+	if (!prop_dictionary_set_int32(dict, BTHIDEVcontrolpsm, control_psm) ||
+	!prop_dictionary_set_int32(dict, BTHIDEVinterruptpsm,
+				   interrupt_psm))
 		return errno;
 
-	prop_object_release(obj);
-
-	obj = prop_data_create_data(hid_descriptor, hid_length);
+	obj = prop_data_create_copy(hid_descriptor, hid_length);
 	if (obj == NULL || !prop_dictionary_set(dict, BTHIDEVdescriptor, obj))
 		return errno;
 
 	mode = hid_mode(obj);
 	prop_object_release(obj);
 
-	obj = prop_string_create_cstring_nocopy(mode);
-	if (obj == NULL || !prop_dictionary_set(dict, BTDEVmode, obj))
+	if (!prop_dictionary_set_string_nocopy(dict, BTDEVmode, mode))
 		return errno;
 
-	prop_object_release(obj);
-
 	if (!reconnect_initiate) {
-		obj = prop_b

CVS commit: src/usr.sbin/btdevctl

2012-12-26 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Wed Dec 26 17:33:09 UTC 2012

Modified Files:
src/usr.sbin/btdevctl: btdevctl.8

Log Message:
add a comment pointing out that the link-mode may need to be
changed manually, for devices which cannot authenticate

for PR/47286


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/btdevctl/btdevctl.8

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

Modified files:

Index: src/usr.sbin/btdevctl/btdevctl.8
diff -u src/usr.sbin/btdevctl/btdevctl.8:1.7 src/usr.sbin/btdevctl/btdevctl.8:1.8
--- src/usr.sbin/btdevctl/btdevctl.8:1.7	Tue Oct 12 21:49:08 2010
+++ src/usr.sbin/btdevctl/btdevctl.8	Wed Dec 26 17:33:09 2012
@@ -1,4 +1,4 @@
-.\" $NetBSD: btdevctl.8,v 1.7 2010/10/12 21:49:08 wiz Exp $
+.\" $NetBSD: btdevctl.8,v 1.8 2012/12/26 17:33:09 plunky Exp $
 .\"
 .\" Copyright (c) 2006 Itronix Inc.
 .\" All rights reserved.
@@ -51,7 +51,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd October 11, 2010
+.Dd December 26, 2012
 .Dt BTDEVCTL 8
 .Os
 .Sh NAME
@@ -101,7 +101,7 @@ May be given as BDADDR or device name.
 Connection link mode.
 The following modes are supported:
 .Pp
-.Bl -tag -compact
+.Bl -tag -width encrypt -compact
 .It none
 clear previously set mode.
 .It auth
@@ -120,6 +120,8 @@ will set
 by default, or
 .Sq encrypt
 for keyboard devices.
+If the device cannot handle authentication, then the mode will need
+to be cleared manually.
 .It Fl q
 Ignore any cached data and perform a SDP query for the given
 .Ar service .



CVS commit: src/usr.sbin/btdevctl

2012-12-26 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Wed Dec 26 17:57:49 UTC 2012

Modified Files:
src/usr.sbin/btdevctl: btdevctl.8

Log Message:
whitespace '  ' -> ' '


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/btdevctl/btdevctl.8

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

Modified files:

Index: src/usr.sbin/btdevctl/btdevctl.8
diff -u src/usr.sbin/btdevctl/btdevctl.8:1.8 src/usr.sbin/btdevctl/btdevctl.8:1.9
--- src/usr.sbin/btdevctl/btdevctl.8:1.8	Wed Dec 26 17:33:09 2012
+++ src/usr.sbin/btdevctl/btdevctl.8	Wed Dec 26 17:57:49 2012
@@ -1,4 +1,4 @@
-.\" $NetBSD: btdevctl.8,v 1.8 2012/12/26 17:33:09 plunky Exp $
+.\" $NetBSD: btdevctl.8,v 1.9 2012/12/26 17:57:49 plunky Exp $
 .\"
 .\" Copyright (c) 2006 Itronix Inc.
 .\" All rights reserved.
@@ -71,7 +71,7 @@ The
 utility is used to configure bluetooth devices in the system.
 Normally,
 .Nm
-will perform  an SDP query to the remote device as needed, and
+will perform an SDP query to the remote device as needed, and
 cache the results in the
 .Pa /var/db/btdevctl.plist
 file for later use.



CVS commit: src/usr.sbin/btdevctl

2009-04-14 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Wed Apr 15 00:35:04 UTC 2009

Modified Files:
src/usr.sbin/btdevctl: sdp.c

Log Message:
Fix -Wsign-compare issues


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/btdevctl/sdp.c

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

Modified files:

Index: src/usr.sbin/btdevctl/sdp.c
diff -u src/usr.sbin/btdevctl/sdp.c:1.5 src/usr.sbin/btdevctl/sdp.c:1.6
--- src/usr.sbin/btdevctl/sdp.c:1.5	Sun Apr 20 19:34:23 2008
+++ src/usr.sbin/btdevctl/sdp.c	Wed Apr 15 00:35:04 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdp.c,v 1.5 2008/04/20 19:34:23 plunky Exp $	*/
+/*	$NetBSD: sdp.c,v 1.6 2009/04/15 00:35:04 lukem Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -55,7 +55,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: sdp.c,v 1.5 2008/04/20 19:34:23 plunky Exp $");
+__RCSID("$NetBSD: sdp.c,v 1.6 2009/04/15 00:35:04 lukem Exp $");
 
 #include 
 
@@ -154,7 +154,8 @@
 {
 	prop_dictionary_t dict;
 	void *ss;
-	int rv, i;
+	int rv;
+	size_t i;
 
 	dict = prop_dictionary_create();
 	if (dict == NULL)
@@ -212,7 +213,7 @@
 		normally_connectable, hid_length;
 	uint8_t *hid_descriptor;
 	const char *mode;
-	int i;
+	size_t i;
 
 	control_psm = -1;
 	interrupt_psm = -1;
@@ -313,7 +314,7 @@
 {
 	prop_object_t obj;
 	uint32_t channel;
-	int i;
+	size_t i;
 
 	channel = -1;
 
@@ -328,7 +329,7 @@
 		}
 	}
 
-	if (channel == -1)
+	if (channel == (uint32_t)-1)
 		return ENOATTR;
 
 	obj = prop_string_create_cstring_nocopy("btsco");
@@ -354,7 +355,7 @@
 {
 	prop_object_t obj;
 	uint32_t channel;
-	int i;
+	size_t i;
 
 	channel = -1;
 
@@ -369,7 +370,7 @@
 		}
 	}
 
-	if (channel == -1)
+	if (channel == (uint32_t)-1)
 		return ENOATTR;
 
 	obj = prop_string_create_cstring_nocopy("btsco");



CVS commit: src/usr.sbin/btdevctl

2009-05-12 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Tue May 12 13:09:43 UTC 2009

Modified Files:
src/usr.sbin/btdevctl: Makefile

Log Message:
does not need libsdp any longer


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/btdevctl/Makefile

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

Modified files:

Index: src/usr.sbin/btdevctl/Makefile
diff -u src/usr.sbin/btdevctl/Makefile:1.3 src/usr.sbin/btdevctl/Makefile:1.4
--- src/usr.sbin/btdevctl/Makefile:1.3	Thu May  7 18:08:55 2009
+++ src/usr.sbin/btdevctl/Makefile	Tue May 12 13:09:43 2009
@@ -1,11 +1,11 @@
-# $NetBSD: Makefile,v 1.3 2009/05/07 18:08:55 plunky Exp $
+# $NetBSD: Makefile,v 1.4 2009/05/12 13:09:43 plunky Exp $
 
 PROG=		btdevctl
 MAN=		btdevctl.8
 SRCS=		btdevctl.c db.c print.c sdp.c
 
-DPADD+=		${LIBBLUETOOTH} ${LIBPROP} ${LIBSDP} ${LIBUSBHID}
-LDADD+=		-lbluetooth -lprop -lsdp -lusbhid
+DPADD+=		${LIBBLUETOOTH} ${LIBPROP} ${LIBUSBHID}
+LDADD+=		-lbluetooth -lprop -lusbhid
 
 CPPFLAGS+=	-DSDP_COMPAT
 



CVS commit: src/usr.sbin/btdevctl

2009-05-12 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Tue May 12 18:39:20 UTC 2009

Modified Files:
src/usr.sbin/btdevctl: Makefile btdevctl.c sdp.c

Log Message:
update to use new sdp(3) and sdp_data(3) APIs


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/btdevctl/Makefile
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/btdevctl/btdevctl.c
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/btdevctl/sdp.c

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

Modified files:

Index: src/usr.sbin/btdevctl/Makefile
diff -u src/usr.sbin/btdevctl/Makefile:1.4 src/usr.sbin/btdevctl/Makefile:1.5
--- src/usr.sbin/btdevctl/Makefile:1.4	Tue May 12 13:09:43 2009
+++ src/usr.sbin/btdevctl/Makefile	Tue May 12 18:39:20 2009
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4 2009/05/12 13:09:43 plunky Exp $
+# $NetBSD: Makefile,v 1.5 2009/05/12 18:39:20 plunky Exp $
 
 PROG=		btdevctl
 MAN=		btdevctl.8
@@ -7,6 +7,4 @@
 DPADD+=		${LIBBLUETOOTH} ${LIBPROP} ${LIBUSBHID}
 LDADD+=		-lbluetooth -lprop -lusbhid
 
-CPPFLAGS+=	-DSDP_COMPAT
-
 .include 

Index: src/usr.sbin/btdevctl/btdevctl.c
diff -u src/usr.sbin/btdevctl/btdevctl.c:1.7 src/usr.sbin/btdevctl/btdevctl.c:1.8
--- src/usr.sbin/btdevctl/btdevctl.c:1.7	Mon Jul 21 13:36:57 2008
+++ src/usr.sbin/btdevctl/btdevctl.c	Tue May 12 18:39:20 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: btdevctl.c,v 1.7 2008/07/21 13:36:57 lukem Exp $	*/
+/*	$NetBSD: btdevctl.c,v 1.8 2009/05/12 18:39:20 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -32,8 +32,10 @@
  */
 
 #include 
-__COPYRIGHT("@(#) Copyright (c) 2006 Itronix, Inc.  All rights reserved.");
-__RCSID("$NetBSD: btdevctl.c,v 1.7 2008/07/21 13:36:57 lukem Exp $");
+__COPYRIGHT("@(#) Copyright (c) 2006 The NetBSD Foundation, Inc.\
+  @(#) Copyright (c) 2006 Itronix, Inc.\
+  All rights reserved.");
+__RCSID("$NetBSD: btdevctl.c,v 1.8 2009/05/12 18:39:20 plunky Exp $");
 
 #include 
 #include 

Index: src/usr.sbin/btdevctl/sdp.c
diff -u src/usr.sbin/btdevctl/sdp.c:1.6 src/usr.sbin/btdevctl/sdp.c:1.7
--- src/usr.sbin/btdevctl/sdp.c:1.6	Wed Apr 15 00:35:04 2009
+++ src/usr.sbin/btdevctl/sdp.c	Tue May 12 18:39:20 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdp.c,v 1.6 2009/04/15 00:35:04 lukem Exp $	*/
+/*	$NetBSD: sdp.c,v 1.7 2009/05/12 18:39:20 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -29,6 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /*
+ * Copyright (c) 2009 The NetBSD Foundation, Inc.
  * Copyright (c) 2004 Maksim Yevmenkin 
  * All rights reserved.
  *
@@ -55,7 +56,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: sdp.c,v 1.6 2009/04/15 00:35:04 lukem Exp $");
+__RCSID("$NetBSD: sdp.c,v 1.7 2009/05/12 18:39:20 plunky Exp $");
 
 #include 
 
@@ -72,125 +73,104 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "btdevctl.h"
 
-static int32_t parse_l2cap_psm(sdp_attr_t *);
-static int32_t parse_rfcomm_channel(sdp_attr_t *);
-static int32_t parse_hid_descriptor(sdp_attr_t *);
-static int32_t parse_boolean(sdp_attr_t *);
-
-static int config_hid(prop_dictionary_t);
-static int config_hset(prop_dictionary_t);
-static int config_hf(prop_dictionary_t);
+static bool parse_hid_descriptor(sdp_data_t *);
+static int32_t parse_boolean(sdp_data_t *);
+static int32_t parse_pdl_param(sdp_data_t *, uint16_t);
+static int32_t parse_pdl(sdp_data_t *, uint16_t);
+static int32_t parse_apdl(sdp_data_t *, uint16_t);
+
+static int config_hid(prop_dictionary_t, sdp_data_t *);
+static int config_hset(prop_dictionary_t, sdp_data_t *);
+static int config_hf(prop_dictionary_t, sdp_data_t *);
 
 uint16_t hid_services[] = {
-	SDP_SERVICE_CLASS_HUMAN_INTERFACE_DEVICE
-};
-
-uint32_t hid_attrs[] = {
-	SDP_ATTR_RANGE(	SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST,
-			SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST),
-	SDP_ATTR_RANGE( SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS,
-			SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS),
-	SDP_ATTR_RANGE(	0x0205,		/* HIDReconnectInitiate */
-			0x0206),	/* HIDDescriptorList */
-	SDP_ATTR_RANGE(	0x0209,		/* HIDBatteryPower */
-			0x0209),
-	SDP_ATTR_RANGE(	0x020d,		/* HIDNormallyConnectable */
-			0x020d)
+	SDP_SERVICE_CLASS_HUMAN_INTERFACE_DEVICE,
 };
 
 uint16_t hset_services[] = {
-	SDP_SERVICE_CLASS_HEADSET
-};
-
-uint32_t hset_attrs[] = {
-	SDP_ATTR_RANGE(	SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST,
-			SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST),
+	SDP_SERVICE_CLASS_HEADSET,
 };
 
 uint16_t hf_services[] = {
-	SDP_SERVICE_CLASS_HANDSFREE_AUDIO_GATEWAY
-};
-
-uint32_t hf_attrs[] = {
-	SDP_ATTR_RANGE(	SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST,
-			SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST),
+	SDP_SERVICE_CLASS_HANDSFREE_AUDIO_GATEWAY,
 };
 
 static struct {
 	const char		*name;
-	int			(*handler)(prop_dictionary_t);
+	int			(*handler)(prop_dictionary_t, sdp_data_t *);
 	const char		*description;
 	uint16_t		*services;
-	int			nservices;
-	uint32_t		*attrs;
-	int			nattrs;
+	size_t			nservices;
 } cfgtype[] = {
 {
 	"HID",		config_hid,	"Human Interface Device",
 	hid_services,	_

CVS commit: src/usr.sbin/btdevctl

2010-04-27 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Wed Apr 28 06:18:08 UTC 2010

Modified Files:
src/usr.sbin/btdevctl: print.c sdp.c

Log Message:
additionally query the "PnP Information" service record to discover
any USB Forum vendor-id and product-id values and store them in the
property list if found.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/btdevctl/print.c
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/btdevctl/sdp.c

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

Modified files:

Index: src/usr.sbin/btdevctl/print.c
diff -u src/usr.sbin/btdevctl/print.c:1.9 src/usr.sbin/btdevctl/print.c:1.10
--- src/usr.sbin/btdevctl/print.c:1.9	Fri Aug 17 17:59:16 2007
+++ src/usr.sbin/btdevctl/print.c	Wed Apr 28 06:18:07 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.9 2007/08/17 17:59:16 pavel Exp $	*/
+/*	$NetBSD: print.c,v 1.10 2010/04/28 06:18:07 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: print.c,v 1.9 2007/08/17 17:59:16 pavel Exp $");
+__RCSID("$NetBSD: print.c,v 1.10 2010/04/28 06:18:07 plunky Exp $");
 
 #include 
 
@@ -86,6 +86,7 @@
 cfg_print(prop_dictionary_t dict)
 {
 	prop_object_t obj;
+	uint16_t v;
 
 	obj = prop_dictionary_get(dict, BTDEVladdr);
 	if (prop_object_type(obj) != PROP_TYPE_DATA) {
@@ -103,6 +104,12 @@
 	if (prop_object_type(obj) == PROP_TYPE_STRING)
 		printf("link mode: %s\n", prop_string_cstring_nocopy(obj));
 
+	if (prop_dictionary_get_uint16(dict, BTDEVvendor, &v))
+		printf("vendor id: 0x%04x\n", v);
+
+	if (prop_dictionary_get_uint16(dict, BTDEVproduct, &v))
+		printf("product id: 0x%04x\n", v);
+
 	obj = prop_dictionary_get(dict, BTDEVtype);
 	if (prop_object_type(obj) != PROP_TYPE_STRING) {
 		printf("No device type!\n");

Index: src/usr.sbin/btdevctl/sdp.c
diff -u src/usr.sbin/btdevctl/sdp.c:1.7 src/usr.sbin/btdevctl/sdp.c:1.8
--- src/usr.sbin/btdevctl/sdp.c:1.7	Tue May 12 18:39:20 2009
+++ src/usr.sbin/btdevctl/sdp.c	Wed Apr 28 06:18:07 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdp.c,v 1.7 2009/05/12 18:39:20 plunky Exp $	*/
+/*	$NetBSD: sdp.c,v 1.8 2010/04/28 06:18:07 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -56,7 +56,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: sdp.c,v 1.7 2009/05/12 18:39:20 plunky Exp $");
+__RCSID("$NetBSD: sdp.c,v 1.8 2010/04/28 06:18:07 plunky Exp $");
 
 #include 
 
@@ -84,10 +84,15 @@
 static int32_t parse_pdl(sdp_data_t *, uint16_t);
 static int32_t parse_apdl(sdp_data_t *, uint16_t);
 
+static int config_pnp(prop_dictionary_t, sdp_data_t *);
 static int config_hid(prop_dictionary_t, sdp_data_t *);
 static int config_hset(prop_dictionary_t, sdp_data_t *);
 static int config_hf(prop_dictionary_t, sdp_data_t *);
 
+uint16_t pnp_services[] = {
+	SDP_SERVICE_CLASS_PNP_INFORMATION,
+};
+
 uint16_t hid_services[] = {
 	SDP_SERVICE_CLASS_HUMAN_INTERFACE_DEVICE,
 };
@@ -123,14 +128,58 @@
 
 #define MAX_SSP		(2 + 1 * 3)	/* largest nservices is 1 */
 
+static bool
+cfg_ssa(sdp_session_t ss, uint16_t *services, size_t nservices, sdp_data_t *rsp)
+{
+	uint8_t buf[MAX_SSP];
+	sdp_data_t ssp;
+	size_t i;
+
+	ssp.next = buf;
+	ssp.end = buf + sizeof(buf);
+
+	for (i = 0; i < nservices; i++)
+		sdp_put_uuid16(&ssp, services[i]);
+
+	ssp.end = ssp.next;
+	ssp.next = buf;
+
+	return sdp_service_search_attribute(ss, &ssp, NULL, rsp);
+}
+
+static bool
+cfg_search(sdp_session_t ss, int i, prop_dictionary_t dict)
+{
+	sdp_data_t rsp, rec;
+
+	/* check PnP Information first */
+	if (!cfg_ssa(ss, pnp_services, __arraycount(pnp_services), &rsp))
+		return false;
+
+	while (sdp_get_seq(&rsp, &rec)) {
+		if (config_pnp(dict, &rec) == 0)
+			break;
+	}
+
+	/* then requested service */
+	if (!cfg_ssa(ss, cfgtype[i].services, cfgtype[i].nservices, &rsp))
+		return false;
+
+	while (sdp_get_seq(&rsp, &rec)) {
+		errno = (*cfgtype[i].handler)(dict, &rec);
+		if (errno == 0)
+			return true;
+	}
+
+	return false;
+}
+
 prop_dictionary_t
 cfg_query(bdaddr_t *laddr, bdaddr_t *raddr, const char *service)
 {
 	prop_dictionary_t dict;
 	sdp_session_t ss;
-	uint8_t buf[MAX_SSP];
-	sdp_data_t ssp, rsp, rec;
-	size_t i, n;
+	size_t i;
 	bool rv;
 
 	dict = prop_dictionary_create();
@@ -140,35 +189,15 @@
 	for (i = 0; i < __arraycount(cfgtype); i++) {
 		if (strcasecmp(service, cfgtype[i].name) == 0) {
 			ss = sdp_open(laddr, raddr);
-			if (ss == NULL)
-return NULL;
+			if (ss != NULL) {
+rv = cfg_search(ss, i, dict);
 
-			/* build ServiceSearchPattern */
-			ssp.next = buf;
-			ssp.end = buf + sizeof(buf);
-
-			for (n = 0; n < cfgtype[i].nservices; n++)
-sdp_put_uuid16(&ssp, cfgtype[i].services[n]);
-
-			ssp.end = ssp.next;
-			ssp.next = buf;
-
-			rv = sdp_service_search_attribute(ss, &ssp, NULL, &rsp);
-			if (!rv) {
-prop_object_release(dict);
 sdp_close(ss);
-return NULL;
-			}
 
-			while (sdp_get_seq(&rsp, &rec)) {
-errno = (*cfgtype[i].handler)(dict, &rec);
-i

CVS commit: src/usr.sbin/btdevctl

2011-03-20 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Sun Mar 20 19:46:13 UTC 2011

Modified Files:
src/usr.sbin/btdevctl: btdevctl.c sdp.c

Log Message:
provide more informative error messages


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/btdevctl/btdevctl.c \
src/usr.sbin/btdevctl/sdp.c

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

Modified files:

Index: src/usr.sbin/btdevctl/btdevctl.c
diff -u src/usr.sbin/btdevctl/btdevctl.c:1.8 src/usr.sbin/btdevctl/btdevctl.c:1.9
--- src/usr.sbin/btdevctl/btdevctl.c:1.8	Tue May 12 18:39:20 2009
+++ src/usr.sbin/btdevctl/btdevctl.c	Sun Mar 20 19:46:13 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: btdevctl.c,v 1.8 2009/05/12 18:39:20 plunky Exp $	*/
+/*	$NetBSD: btdevctl.c,v 1.9 2011/03/20 19:46:13 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -35,7 +35,7 @@
 __COPYRIGHT("@(#) Copyright (c) 2006 The NetBSD Foundation, Inc.\
   @(#) Copyright (c) 2006 Itronix, Inc.\
   All rights reserved.");
-__RCSID("$NetBSD: btdevctl.c,v 1.8 2009/05/12 18:39:20 plunky Exp $");
+__RCSID("$NetBSD: btdevctl.c,v 1.9 2011/03/20 19:46:13 plunky Exp $");
 
 #include 
 #include 
@@ -158,9 +158,6 @@
 			printf("Performing SDP query for service '%s'..\n", service);
 
 		dev = cfg_query(&laddr, &raddr, service);
-		if (dev == NULL)
-			errx(EXIT_FAILURE, "%s/%s not found", bt_ntoa(&raddr, NULL), service);
-
 		set = true;
 	}
 
Index: src/usr.sbin/btdevctl/sdp.c
diff -u src/usr.sbin/btdevctl/sdp.c:1.8 src/usr.sbin/btdevctl/sdp.c:1.9
--- src/usr.sbin/btdevctl/sdp.c:1.8	Wed Apr 28 06:18:07 2010
+++ src/usr.sbin/btdevctl/sdp.c	Sun Mar 20 19:46:13 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdp.c,v 1.8 2010/04/28 06:18:07 plunky Exp $	*/
+/*	$NetBSD: sdp.c,v 1.9 2011/03/20 19:46:13 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -56,7 +56,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: sdp.c,v 1.8 2010/04/28 06:18:07 plunky Exp $");
+__RCSID("$NetBSD: sdp.c,v 1.9 2011/03/20 19:46:13 plunky Exp $");
 
 #include 
 
@@ -180,26 +180,22 @@
 	prop_dictionary_t dict;
 	sdp_session_t ss;
 	size_t i;
-	bool rv;
 
 	dict = prop_dictionary_create();
 	if (dict == NULL)
-		return NULL;
+		err(EXIT_FAILURE, "prop_dictionary_create()");
 
 	for (i = 0; i < __arraycount(cfgtype); i++) {
 		if (strcasecmp(service, cfgtype[i].name) == 0) {
 			ss = sdp_open(laddr, raddr);
-			if (ss != NULL) {
-rv = cfg_search(ss, i, dict);
+			if (ss == NULL)
+err(EXIT_FAILURE, "SDP connection failed");
 
-sdp_close(ss);
+			if (!cfg_search(ss, i, dict))
+errx(EXIT_FAILURE, "service %s not found", service);
 
-if (rv == true)
-	return dict;
-			}
-
-			prop_object_release(dict);
-			return NULL;
+			sdp_close(ss);
+			return dict;
 		}
 	}
 



CVS commit: src/usr.sbin/btdevctl

2010-10-11 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Mon Oct 11 15:30:57 UTC 2010

Modified Files:
src/usr.sbin/btdevctl: btdevctl.8

Log Message:
add a reference in the SEE ALSO section to "The NetBSD Guide" for
detailed examples of device configuration


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/btdevctl/btdevctl.8

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

Modified files:

Index: src/usr.sbin/btdevctl/btdevctl.8
diff -u src/usr.sbin/btdevctl/btdevctl.8:1.5 src/usr.sbin/btdevctl/btdevctl.8:1.6
--- src/usr.sbin/btdevctl/btdevctl.8:1.5	Sun Dec  2 20:59:29 2007
+++ src/usr.sbin/btdevctl/btdevctl.8	Mon Oct 11 15:30:57 2010
@@ -1,4 +1,4 @@
-.\" $NetBSD: btdevctl.8,v 1.5 2007/12/02 20:59:29 wiz Exp $
+.\" $NetBSD: btdevctl.8,v 1.6 2010/10/11 15:30:57 plunky Exp $
 .\"
 .\" Copyright (c) 2006 Itronix Inc.
 .\" All rights reserved.
@@ -51,10 +51,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $Id: btdevctl.8,v 1.5 2007/12/02 20:59:29 wiz Exp $
-.\" $FreeBSD: src/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.8,v 1.3 2005/01/18 20:02:30 ru Exp $
-.\"
-.Dd April 10, 2007
+.Dd October 11, 2010
 .Dt BTDEVCTL 8
 .Os
 .Sh NAME
@@ -164,6 +161,10 @@
 .Xr bthub 4 ,
 .Xr btsco 4 ,
 .Xr rc.conf 5
+.Pp
+See the Bluetooth chapter of
+.Qq The NetBSD Guide
+for detailed examples of configuring keyboards, mice and audio headsets.
 .Sh HISTORY
 Parts of the
 .Nm



CVS commit: src/usr.sbin/btdevctl

2010-10-12 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Oct 12 21:49:08 UTC 2010

Modified Files:
src/usr.sbin/btdevctl: btdevctl.8

Log Message:
Sort sections, use serial comma.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/btdevctl/btdevctl.8

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

Modified files:

Index: src/usr.sbin/btdevctl/btdevctl.8
diff -u src/usr.sbin/btdevctl/btdevctl.8:1.6 src/usr.sbin/btdevctl/btdevctl.8:1.7
--- src/usr.sbin/btdevctl/btdevctl.8:1.6	Mon Oct 11 15:30:57 2010
+++ src/usr.sbin/btdevctl/btdevctl.8	Tue Oct 12 21:49:08 2010
@@ -1,4 +1,4 @@
-.\" $NetBSD: btdevctl.8,v 1.6 2010/10/11 15:30:57 plunky Exp $
+.\" $NetBSD: btdevctl.8,v 1.7 2010/10/12 21:49:08 wiz Exp $
 .\"
 .\" Copyright (c) 2006 Itronix Inc.
 .\" All rights reserved.
@@ -147,14 +147,14 @@
 variable
 .Sy btdevctl
 to YES.
-.Sh EXIT STATUS
-.Ex -std
 .Sh FILES
 .Bl -tag -compact
 .It Pa /etc/bluetooth/btdevctl.conf
 .It Pa /dev/bthub
 .It Pa /var/db/btdevctl.plist
 .El
+.Sh EXIT STATUS
+.Ex -std
 .Sh SEE ALSO
 .Xr btpin 1 ,
 .Xr bthidev 4 ,
@@ -164,7 +164,7 @@
 .Pp
 See the Bluetooth chapter of
 .Qq The NetBSD Guide
-for detailed examples of configuring keyboards, mice and audio headsets.
+for detailed examples of configuring keyboards, mice, and audio headsets.
 .Sh HISTORY
 Parts of the
 .Nm



CVS commit: src/usr.sbin/btdevctl

2011-08-27 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sat Aug 27 22:24:14 UTC 2011

Modified Files:
src/usr.sbin/btdevctl: btdevctl.c

Log Message:
static + __dead


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/btdevctl/btdevctl.c

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

Modified files:

Index: src/usr.sbin/btdevctl/btdevctl.c
diff -u src/usr.sbin/btdevctl/btdevctl.c:1.9 src/usr.sbin/btdevctl/btdevctl.c:1.10
--- src/usr.sbin/btdevctl/btdevctl.c:1.9	Sun Mar 20 19:46:13 2011
+++ src/usr.sbin/btdevctl/btdevctl.c	Sat Aug 27 22:24:14 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: btdevctl.c,v 1.9 2011/03/20 19:46:13 plunky Exp $	*/
+/*	$NetBSD: btdevctl.c,v 1.10 2011/08/27 22:24:14 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -35,7 +35,7 @@
 __COPYRIGHT("@(#) Copyright (c) 2006 The NetBSD Foundation, Inc.\
   @(#) Copyright (c) 2006 Itronix, Inc.\
   All rights reserved.");
-__RCSID("$NetBSD: btdevctl.c,v 1.9 2011/03/20 19:46:13 plunky Exp $");
+__RCSID("$NetBSD: btdevctl.c,v 1.10 2011/08/27 22:24:14 joerg Exp $");
 
 #include 
 #include 
@@ -54,10 +54,9 @@
 
 #define BTHUB_PATH		"/dev/bthub"
 
-int main(int, char *[]);
-void usage(void);
-char *uppercase(const char *);
-int bthub_pioctl(unsigned long, prop_dictionary_t);
+__dead static void usage(void);
+static char *uppercase(const char *);
+static int bthub_pioctl(unsigned long, prop_dictionary_t);
 
 int
 main(int argc, char *argv[])
@@ -211,7 +210,7 @@
 	exit(EXIT_SUCCESS);
 }
 
-void
+static void
 usage(void)
 {
 
@@ -231,7 +230,7 @@
 	exit(EXIT_FAILURE);
 }
 
-char *
+static char *
 uppercase(const char *arg)
 {
 	char *str, *ptr;
@@ -246,7 +245,7 @@
 	return str;
 }
 
-int
+static int
 bthub_pioctl(unsigned long cmd, prop_dictionary_t dict)
 {
 	int fd;



CVS commit: src/usr.sbin/btdevctl

2015-06-12 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Fri Jun 12 09:43:05 UTC 2015

Modified Files:
src/usr.sbin/btdevctl: btdevctl.8

Log Message:
the Bluetooth rc.d setup was simplified some time ago, so
'btdevctl' variable is no longer used. change wording to
reflect this


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/btdevctl/btdevctl.8

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

Modified files:

Index: src/usr.sbin/btdevctl/btdevctl.8
diff -u src/usr.sbin/btdevctl/btdevctl.8:1.11 src/usr.sbin/btdevctl/btdevctl.8:1.12
--- src/usr.sbin/btdevctl/btdevctl.8:1.11	Tue Mar 18 18:20:46 2014
+++ src/usr.sbin/btdevctl/btdevctl.8	Fri Jun 12 09:43:05 2015
@@ -1,4 +1,4 @@
-.\" $NetBSD: btdevctl.8,v 1.11 2014/03/18 18:20:46 riastradh Exp $
+.\" $NetBSD: btdevctl.8,v 1.12 2015/06/12 09:43:05 plunky Exp $
 .\"
 .\" Copyright (c) 2006 Itronix Inc.
 .\" All rights reserved.
@@ -143,12 +143,11 @@ Be verbose.
 .Pp
 For device configurations to persist across boots, add entries to the
 .Pa /etc/bluetooth/btdevctl.conf
-file and
-set the
+file and ensure the
 .Xr rc.conf 5
 variable
-.Sy btdevctl
-to YES.
+.Sy bluetooth
+is set to YES.
 .Sh FILES
 .Bl -tag -compact
 .It Pa /etc/bluetooth/btdevctl.conf