Module Name:    src
Committed By:   plunky
Date:           Tue Oct  6 19:21:17 UTC 2009

Modified Files:
        src/usr.bin/sdpquery: command.c sdpquery.1

Log Message:
allow to specify 32-bit bluetooth short alias or full UUID strings
on the commandline.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/sdpquery/command.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/sdpquery/sdpquery.1

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

Modified files:

Index: src/usr.bin/sdpquery/command.c
diff -u src/usr.bin/sdpquery/command.c:1.1 src/usr.bin/sdpquery/command.c:1.2
--- src/usr.bin/sdpquery/command.c:1.1	Tue May 12 18:37:50 2009
+++ src/usr.bin/sdpquery/command.c	Tue Oct  6 19:21:17 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: command.c,v 1.1 2009/05/12 18:37:50 plunky Exp $	*/
+/*	$NetBSD: command.c,v 1.2 2009/10/06 19:21:17 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: command.c,v 1.1 2009/05/12 18:37:50 plunky Exp $");
+__RCSID("$NetBSD: command.c,v 1.2 2009/10/06 19:21:17 plunky Exp $");
 
 #include <bluetooth.h>
 #include <err.h>
@@ -129,7 +129,7 @@
 		if (*argv[0] == '\0' || *ep != '\0' || handle > UINT32_MAX)
 			errx(EXIT_FAILURE, "Invalid handle: %s\n", *argv);
 
-		rv = sdp_service_attribute(ss, handle, NULL, &rsp);
+		rv = sdp_service_attribute(ss, (uint32_t)handle, NULL, &rsp);
 		if (!rv)
 			warn("%s", *argv);
 		else
@@ -205,36 +205,42 @@
 static void
 build_ssp(sdp_data_t *ssp, int argc, const char **argv)
 {
-	static uint8_t	data[36];	/* 12 * sizeof(uuid16) */
+	static uint8_t	data[12 * sizeof(uuid_t)];
 	char *		ep;
-	unsigned long	uuid;
+	uintmax_t	umax;
+	uuid_t		uuid;
+	uint32_t	status;
 	int		i;
 
 	ssp->next = data;
 	ssp->end = data + sizeof(data);
 
 	for (; argc-- > 0; argv++) {
-		uuid = strtoul(*argv, &ep, 0);
-		if (*argv[0] == '\0' || *ep != '\0') {
-			for (i = 0;; i++) {
-				if (i == __arraycount(aliases))
-					errx(EXIT_FAILURE,
-					    "Unknown alias \"%s\"", *argv);
-
-				if (strcasecmp(aliases[i].name, *argv) == 0)
-					break;
-			}
+		uuid_from_string(*argv, &uuid, &status);
+		if (status != uuid_s_ok) {
+			umax = strtoumax(*argv, &ep, 0);
+			if (*argv[0] == '\0' || *ep != '\0') {
+				for (i = 0;; i++) {
+					if (i == __arraycount(aliases))
+						errx(EXIT_FAILURE,
+						    "%s: Bad UUID", *argv);
+
+					if (strcasecmp(aliases[i].name,
+					    *argv) == 0)
+						break;
+				}
+
+				umax = aliases[i].uuid;
+			} else if (umax > UINT32_MAX)
+				errx(EXIT_FAILURE, "%s: Bad UUID", *argv);
 
-			uuid = aliases[i].uuid;
+			uuid = BLUETOOTH_BASE_UUID;
+			uuid.time_low = (uint32_t)umax;
 		}
 
-		if (uuid > UINT16_MAX)
-			errx(EXIT_FAILURE, "%s: Not 16-bit UUID", *argv);
-
-		sdp_put_uuid16(ssp, uuid);
+		sdp_put_uuid(ssp, &uuid);
 	}
 
 	ssp->end = ssp->next;
 	ssp->next = data;
-	return;
 }

Index: src/usr.bin/sdpquery/sdpquery.1
diff -u src/usr.bin/sdpquery/sdpquery.1:1.11 src/usr.bin/sdpquery/sdpquery.1:1.12
--- src/usr.bin/sdpquery/sdpquery.1:1.11	Tue May 12 18:54:31 2009
+++ src/usr.bin/sdpquery/sdpquery.1	Tue Oct  6 19:21:17 2009
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sdpquery.1,v 1.11 2009/05/12 18:54:31 wiz Exp $
+.\"	$NetBSD: sdpquery.1,v 1.12 2009/10/06 19:21:17 plunky Exp $
 .\"
 .\" Copyright (c) 2006 Itronix Inc.
 .\" All rights reserved.
@@ -54,7 +54,7 @@
 .\"
 .\" $FreeBSD: src/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.8,v 1.6 2005/07/09 19:04:43 markus Exp $
 .\"
-.Dd May 7, 2009
+.Dd Oct 6, 2009
 .Dt SDPQUERY 1
 .Os
 .Sh NAME
@@ -130,7 +130,7 @@
 Browse for services.
 The
 .Ar group
-parameter is a 16-bit UUID of the group to browse.
+parameter is the UUID of the group to browse.
 If omitted, the "Public Browse Group" is used.
 .Pp
 .It Cm Record Ar handle Op Ar handle...
@@ -140,7 +140,6 @@
 .Pp
 .It Cm Search Ar uuid Op Ar uuid...
 Search for records matching the list of
-.Pq 16-bit
 UUIDs which can be given in numerical form, or the
 following aliases are known:
 .Pp
@@ -215,8 +214,3 @@
 .An Maksim Yevmenkin Aq [email protected]
 .An Iain Hibbert
 for Itronix, Inc.
-.Sh BUGS
-.Nm
-will only search for Bluetooth
-.Qq short alias
-16-bit UUIDs.

Reply via email to