CVS commit: src/usr.bin/sdpquery

2015-12-11 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Fri Dec 11 21:05:18 UTC 2015

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
update several profiles, bringing up to date decoding of all the
Bluetooth 1.1->4.2 Service Discovery specifications I could find,
namely:

Wireless Access Protocol
Multi-Profile Specification
Calendar, Tasks & Notes
Message Access Profile
Message Notification Service
Global Navigation Satellite System
Health Device Profile
File Transfer Protocol
3D Display
General Access Profile
Generic Attribute Server

all documentation is on bluetooth.org, under

https://www.bluetooth.org/en-us/specification


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.21 src/usr.bin/sdpquery/print.c:1.22
--- src/usr.bin/sdpquery/print.c:1.21	Mon Mar 16 19:10:48 2015
+++ src/usr.bin/sdpquery/print.c	Fri Dec 11 21:05:18 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.21 2015/03/16 19:10:48 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.22 2015/12/11 21:05:18 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: print.c,v 1.21 2015/03/16 19:10:48 plunky Exp $");
+__RCSID("$NetBSD: print.c,v 1.22 2015/12/11 21:05:18 plunky Exp $");
 
 #include 
 #include 
@@ -103,6 +103,9 @@ static void print_asink_features(sdp_dat
 static void print_avrcp_features(sdp_data_t *);
 static void print_supported_data_stores(sdp_data_t *);
 static void print_supported_formats(sdp_data_t *);
+static void print_wap_addr(sdp_data_t *);
+static void print_wap_gateway(sdp_data_t *);
+static void print_wap_type(sdp_data_t *);
 static void print_hid_version(sdp_data_t *);
 static void print_hid_device_subclass(sdp_data_t *);
 static void print_hid_descriptor_list(sdp_data_t *);
@@ -114,15 +117,22 @@ static void print_hfag_features(sdp_data
 static void print_net_access_type(sdp_data_t *);
 static void print_pnp_source(sdp_data_t *);
 static void print_mas_types(sdp_data_t *);
-static void print_supported_repositories(sdp_data_t *);
+static void print_map_features(sdp_data_t *);
+static void print_pse_repositories(sdp_data_t *);
+static void print_pse_features(sdp_data_t *);
+static void print_hdp_features(sdp_data_t *);
+static void print_hdp_specification(sdp_data_t *);
+static void print_mcap_procedures(sdp_data_t *);
 static void print_character_repertoires(sdp_data_t *);
 static void print_bip_capabilities(sdp_data_t *);
 static void print_bip_features(sdp_data_t *);
 static void print_bip_functions(sdp_data_t *);
 static void print_bip_capacity(sdp_data_t *);
 static void print_1284id(sdp_data_t *);
+static void print_ctn_features(sdp_data_t *);
 
 static void print_rfcomm(sdp_data_t *);
+static void print_att(sdp_data_t *);
 static void print_bnep(sdp_data_t *);
 static void print_avctp(sdp_data_t *);
 static void print_avdtp(sdp_data_t *);
@@ -135,6 +145,7 @@ attr_t protocol_list[] = {
 	{ 0x0004, "TCP",NULL },
 	{ 0x0005, "TCS_BIN",NULL },
 	{ 0x0006, "TCS_AT",NULL },
+	{ 0x0007, "ATT",print_att },
 	{ 0x0008, "OBEX",NULL },
 	{ 0x0009, "IP",	NULL },
 	{ 0x000a, "FTP",NULL },
@@ -216,9 +227,14 @@ attr_t irmc_sync_attrs[] = { /* IrMC Syn
 };
 
 attr_t opush_attrs[] = { /* Object Push */
+	{ 0x0200, "GeopL2capPSM",			print_uint16x },
 	{ 0x0303, "SupportedFormatsList",		print_supported_formats },
 };
 
+attr_t ft_attrs[] = { /* File Transfer */
+	{ 0x0200, "GeopL2capPSM",			print_uint16x },
+};
+
 attr_t hset_attrs[] = {	/* Headset */
 	{ 0x0302, "RemoteAudioVolumeControl",		print_bool },
 };
@@ -230,11 +246,20 @@ attr_t fax_attrs[] = {	/* Fax */
 	{ 0x0305, "AudioFeedbackSupport",		print_bool },
 };
 
+attr_t wap_attrs[] = {	/* WAP Bearer */
+	{ 0x0306, "NetworkAddress",			print_wap_addr },
+	{ 0x0307, "WAPGateway",print_wap_gateway },
+	{ 0x0308, "HomePageURL",			print_url },
+	{ 0x0309, "WAPStackType",			print_wap_type },
+};
+
 attr_t panu_attrs[] = {	/* Personal Area Networking User */
+	{ 0x0200, "IpSubnet",print_string },
 	{ 0x030a, "SecurityDescription",		print_security_description },
 };
 
 attr_t nap_attrs[] = {	/* Network Access Point */
+	{ 0x0200, "IpSubnet",print_string },
 	{ 0x030a, "SecurityDescription",		print_security_description },
 	{ 0x030b, "NetAccessType",			print_net_access_type },
 	{ 0x030c, "MaxNetAccessRate",			print_uint32d },
@@ -243,6 +268,7 @@ attr_t nap_attrs[] = {	/* Network Access
 };
 
 attr_t gn_attrs[] = {	/* Group Network */
+	{ 0x0200, "IpSubnet",print_string },
 	{ 0x030a, "SecurityDescription",		print_security_description },
 	{ 0x030d, "IPv4Subnet",print_string },
 	{ 0x030e, "IPv6Subnet",print_string },
@@ -270,6 +296,7 @@ attr_t bp_attrs[] = {	/* 

CVS commit: src/usr.bin/sdpquery

2015-03-16 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Mon Mar 16 19:10:48 UTC 2015

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
parse and print the HIDLANGIDBaseList attribute


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.20 src/usr.bin/sdpquery/print.c:1.21
--- src/usr.bin/sdpquery/print.c:1.20	Fri Oct 18 20:47:06 2013
+++ src/usr.bin/sdpquery/print.c	Mon Mar 16 19:10:48 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.20 2013/10/18 20:47:06 christos Exp $	*/
+/*	$NetBSD: print.c,v 1.21 2015/03/16 19:10:48 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.20 2013/10/18 20:47:06 christos Exp $);
+__RCSID($NetBSD: print.c,v 1.21 2015/03/16 19:10:48 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -106,6 +106,7 @@ static void print_supported_formats(sdp_
 static void print_hid_version(sdp_data_t *);
 static void print_hid_device_subclass(sdp_data_t *);
 static void print_hid_descriptor_list(sdp_data_t *);
+static void print_hid_langid_base_list(sdp_data_t *);
 static void print_security_description(sdp_data_t *);
 static void print_hf_features(sdp_data_t *);
 static void print_hfag_network(sdp_data_t *);
@@ -297,7 +298,7 @@ attr_t hid_attrs[] = {	/* Human Interfac
 	{ 0x0204, HIDVirtualCable,			print_bool },
 	{ 0x0205, HIDReconnectInitiate,		print_bool },
 	{ 0x0206, HIDDescriptorList,			print_hid_descriptor_list },
-	{ 0x0207, HIDLANGIDBaseList,			NULL },
+	{ 0x0207, HIDLANGIDBaseList,			print_hid_langid_base_list },
 	{ 0x0208, HIDSDPDisable,			print_bool },
 	{ 0x0209, HIDBatteryPower,			print_bool },
 	{ 0x020a, HIDRemoteWake,			print_bool },
@@ -1275,7 +1276,6 @@ print_hid_descriptor_list(sdp_data_t *da
 	char *str;
 	size_t len;
 
-
 	if (!sdp_get_seq(data, list))
 		return;
 
@@ -1301,6 +1301,38 @@ print_hid_descriptor_list(sdp_data_t *da
 }
 
 static void
+print_hid_langid_base_list(sdp_data_t *data)
+{
+	sdp_data_t list, seq;
+	uint16_t lang, base;
+
+	if (!sdp_get_seq(data, list))
+		return;
+
+	while (list.next  list.end) {
+		if (!sdp_get_seq(list, seq)
+		|| !sdp_get_uint16(seq, lang)
+		|| !sdp_get_uint16(seq, base))
+			return;
+
+		printf(\n);
+		/*
+		 * The language is encoded according to the
+		 *   Universal Serial Bus Language Identifiers (LANGIDs)
+		 * specification. It does not seem worth listing them all
+		 * here, but feel free to add if you notice any being used.
+		 */
+		switch (lang) {
+		case 0x0409:	printf(English (US));		break;
+		case 0x0809:	printf(English (UK));		break;
+		default:	printf(0x%04x, lang);		break;
+		}
+
+		printf( base 0x%04x\n, base);
+	}
+}
+
+static void
 print_security_description(sdp_data_t *data)
 {
 	uint16_t v;



CVS commit: src/usr.bin/sdpquery

2011-09-15 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Thu Sep 15 17:52:53 UTC 2011

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
when printing URL strings, don't use VIS_HTTPSTYLE, it does
not quite work as I expected.. just use VIS_CSTYLE


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.18 src/usr.bin/sdpquery/print.c:1.19
--- src/usr.bin/sdpquery/print.c:1.18	Sat Aug 20 09:18:47 2011
+++ src/usr.bin/sdpquery/print.c	Thu Sep 15 17:52:53 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.18 2011/08/20 09:18:47 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.19 2011/09/15 17:52:53 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.18 2011/08/20 09:18:47 plunky Exp $);
+__RCSID($NetBSD: print.c,v 1.19 2011/09/15 17:52:53 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -64,7 +64,7 @@
 } language_t;
 
 static const char *string_uuid(uuid_t *);
-static const char *string_vis(int, const char *, size_t);
+static const char *string_vis(const char *, size_t);
 
 static void print_hexdump(const char *, const uint8_t *, size_t);
 static bool print_attribute(uint16_t, sdp_data_t *, attr_t *, size_t);
@@ -553,13 +553,14 @@
 }
 
 static const char *
-string_vis(int style, const char *src, size_t len)
+string_vis(const char *src, size_t len)
 {
 	static char buf[50];
 	char *dst = buf;
+	int style;
 
 	buf[0] = '\0';
-	style |= VIS_NL;
+	style = VIS_CSTYLE | VIS_NL;
 	while (len  0  (dst + 5)  (buf + sizeof(buf))) {
 		dst = vis(dst, src[0], style, (len  1 ? src[1] : 0));
 		src++;
@@ -776,7 +777,7 @@
 	if (!sdp_get_str(data, str, len))
 		return;
 
-	printf(\%s\\n, string_vis(VIS_CSTYLE, str, len));
+	printf(\%s\\n, string_vis(str, len));
 }
 
 static void
@@ -799,7 +800,7 @@
 			len -= l + 1;
 			ep++;
 		}
-		printf(%s\n, string_vis(VIS_CSTYLE, str, l));
+		printf(%s\n, string_vis(str, l));
 		str = ep;
 	}
 }
@@ -813,7 +814,7 @@
 	if (!sdp_get_url(data, url, len))
 		return;
 
-	printf(\%s\\n, string_vis(VIS_HTTPSTYLE, url, len));
+	printf(\%s\\n, string_vis(url, len));
 }
 
 static void
@@ -1608,7 +1609,7 @@
 		}
 
 		l = (size_t)(ep - str + 1);
-		printf(%s\n, string_vis(VIS_CSTYLE, str, l));
+		printf(%s\n, string_vis(str, l));
 		str += l;
 		len -= l;
 	}



CVS commit: src/usr.bin/sdpquery

2011-08-20 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Sat Aug 20 09:18:48 UTC 2011

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
add print_utf8_string for some profiles that specify UTF-8 specifically,
and supply a print_codeset_string() so we don't need void * casts to avoid
the char ** - const char ** complaint


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.17 src/usr.bin/sdpquery/print.c:1.18
--- src/usr.bin/sdpquery/print.c:1.17	Sun Aug 14 13:27:47 2011
+++ src/usr.bin/sdpquery/print.c	Sat Aug 20 09:18:47 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.17 2011/08/14 13:27:47 christos Exp $	*/
+/*	$NetBSD: print.c,v 1.18 2011/08/20 09:18:47 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.17 2011/08/14 13:27:47 christos Exp $);
+__RCSID($NetBSD: print.c,v 1.18 2011/08/20 09:18:47 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -85,7 +85,9 @@
 static void print_string_list(sdp_data_t *);
 static void print_url(sdp_data_t *);
 static void print_profile_version(sdp_data_t *);
+static void print_codeset_string(const char *, size_t, const char *);
 static void print_language_string(sdp_data_t *);
+static void print_utf8_string(sdp_data_t *);
 
 static void print_service_class_id_list(sdp_data_t *);
 static void print_protocol_descriptor(sdp_data_t *);
@@ -251,8 +253,8 @@
 	{ 0x0354, XHTML-PrintImageFormatsSupported,	print_string_list },
 	{ 0x0356, ColorSupported,			print_bool },
 	{ 0x0358, 1284ID,print_1284id },
-	{ 0x035a, PrinterName,			print_string },
-	{ 0x035c, PrinterLocation,			print_string },
+	{ 0x035a, PrinterName,			print_utf8_string },
+	{ 0x035c, PrinterLocation,			print_utf8_string },
 	{ 0x035e, DuplexSupported,			print_bool },
 	{ 0x0360, MediaTypesSupported,		print_string_list },
 	{ 0x0362, MaxMediaWidth,			print_uint16d },
@@ -263,7 +265,7 @@
 	{ 0x0372, DirectPrintingRUISupported,		print_bool },
 	{ 0x0374, ReferencePrintingTopURL,		print_url },
 	{ 0x0376, DirectPrintingTopURL,		print_url },
-	{ 0x037a, DeviceName,print_string },
+	{ 0x037a, DeviceName,print_utf8_string },
 };
 
 attr_t bi_attrs[] = {	/* Basic Imaging */
@@ -307,9 +309,9 @@
 
 attr_t hcr_attrs[] = {	/* Hardcopy Cable Replacement */
 	{ 0x0300, 1284ID,print_1284id },
-	{ 0x0302, DeviceName,print_string },
-	{ 0x0304, FriendlyName,			print_string },
-	{ 0x0306, DeviceLocation,			print_string },
+	{ 0x0302, DeviceName,print_utf8_string },
+	{ 0x0304, FriendlyName,			print_utf8_string },
+	{ 0x0306, DeviceLocation,			print_utf8_string },
 };
 
 attr_t pnp_attrs[] = {	/* Device ID */
@@ -825,38 +827,57 @@
 	printf(v%d.%d\n, (v  8), (v  0xff));
 }
 
-/*
- * This should only be called through print_language_attribute() which
- * sets codeset of the string to be printed.
- */
 static void
-print_language_string(sdp_data_t *data)
+print_codeset_string(const char *src, size_t srclen, const char *codeset)
 {
-	char buf[50], *dst, *src;
+	char buf[50], *dst;
 	iconv_t ih;
-	size_t n, srcleft, dstleft;
-
-	if (!sdp_get_str(data, src, srcleft))
-		return;
+	size_t n, dstlen;
 
 	dst = buf;
-	dstleft = sizeof(buf);
+	dstlen = sizeof(buf);
 
-	ih = iconv_open(nl_langinfo(CODESET), language[current].codeset);
+	ih = iconv_open(nl_langinfo(CODESET), codeset);
 	if (ih == (iconv_t)-1) {
-		printf(Can't convert %s string\n, language[current].codeset);
+		printf(Can't convert %s string\n, codeset);
 		return;
 	}
 
-	n = iconv(ih, (void *)src, srcleft, dst, dstleft);
+	n = iconv(ih, src, srclen, dst, dstlen);
 
 	iconv_close(ih);
 
-	if (Nflag || n  0)
-		printf((%s) , language[current].codeset);
+	printf(\%.*s%s\n, (int)(sizeof(buf) - dstlen), buf,
+	(srclen  0 ?  ... : \));
+}
+
+/*
+ * This should only be called through print_language_attribute() which
+ * sets codeset of the string to be printed.
+ */
+static void
+print_language_string(sdp_data_t *data)
+{
+	char *str;
+	size_t len;
+
+	if (!sdp_get_str(data, str, len))
+		return;
+
+	print_codeset_string(str, len, language[current].codeset);
+}
+
+
+static void
+print_utf8_string(sdp_data_t *data)
+{
+	char *str;
+	size_t len;
+
+	if (!sdp_get_str(data, str, len))
+		return;
 
-	printf(\%.*s%s\n, (int)(sizeof(buf) - dstleft), buf,
-	(srcleft  0 ?  ... : \));
+	print_codeset_string(str, len, UTF-8);
 }
 
 static void



CVS commit: src/usr.bin/sdpquery

2011-08-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 14 13:27:47 UTC 2011

Modified Files:
src/usr.bin/sdpquery: Makefile print.c sdpquery.c

Log Message:
kill gcc-4.5 warnings


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/sdpquery/Makefile
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/sdpquery/print.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/sdpquery/sdpquery.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.bin/sdpquery/Makefile
diff -u src/usr.bin/sdpquery/Makefile:1.7 src/usr.bin/sdpquery/Makefile:1.8
--- src/usr.bin/sdpquery/Makefile:1.7	Tue Jun 21 22:49:44 2011
+++ src/usr.bin/sdpquery/Makefile	Sun Aug 14 09:27:47 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.7 2011/06/22 02:49:44 mrg Exp $
+# $NetBSD: Makefile,v 1.8 2011/08/14 13:27:47 christos Exp $
 
 USE_FORT?= yes	# network client
 
@@ -10,9 +10,3 @@
 LDADD+=		-lbluetooth
 
 .include bsd.prog.mk
-
-# XXX
-.if ${HAVE_GCC} == 45
-COPTS.sdpquery.c+=	-Wno-error
-COPTS.print.c+=	-Wno-error
-.endif

Index: src/usr.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.16 src/usr.bin/sdpquery/print.c:1.17
--- src/usr.bin/sdpquery/print.c:1.16	Thu Jul  7 06:49:38 2011
+++ src/usr.bin/sdpquery/print.c	Sun Aug 14 09:27:47 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.16 2011/07/07 10:49:38 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.17 2011/08/14 13:27:47 christos Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.16 2011/07/07 10:49:38 plunky Exp $);
+__RCSID($NetBSD: print.c,v 1.17 2011/08/14 13:27:47 christos Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -848,7 +848,7 @@
 		return;
 	}
 
-	n = iconv(ih, (const char **)src, srcleft, dst, dstleft);
+	n = iconv(ih, (void *)src, srcleft, dst, dstleft);
 
 	iconv_close(ih);
 

Index: src/usr.bin/sdpquery/sdpquery.c
diff -u src/usr.bin/sdpquery/sdpquery.c:1.5 src/usr.bin/sdpquery/sdpquery.c:1.6
--- src/usr.bin/sdpquery/sdpquery.c:1.5	Tue May 12 14:37:50 2009
+++ src/usr.bin/sdpquery/sdpquery.c	Sun Aug 14 09:27:47 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdpquery.c,v 1.5 2009/05/12 18:37:50 plunky Exp $	*/
+/*	$NetBSD: sdpquery.c,v 1.6 2011/08/14 13:27:47 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -35,7 +35,7 @@
 __COPYRIGHT(@(#) Copyright (c) 2009 The NetBSD Foundation, Inc.\
  Copyright (c) 2006 Itronix, Inc.\
  All rights reserved.);
-__RCSID($NetBSD: sdpquery.c,v 1.5 2009/05/12 18:37:50 plunky Exp $);
+__RCSID($NetBSD: sdpquery.c,v 1.6 2011/08/14 13:27:47 christos Exp $);
 
 #include bluetooth.h
 #include err.h
@@ -142,7 +142,7 @@
 
 	for (cmd = commands ; cmd-command != NULL; cmd++) {
 		if (strcasecmp(*argv, cmd-command) == 0)
-			return (*cmd-handler)(--argc, (char const **)++argv);
+			return (*cmd-handler)(--argc, (void *)++argv);
 	}
 
 	usage();



CVS commit: src/usr.bin/sdpquery

2011-07-07 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Thu Jul  7 10:26:01 UTC 2011

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
parse IEEE 1284 Device ID, since it is not strictly a
string, and may run longer than a line


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.14 src/usr.bin/sdpquery/print.c:1.15
--- src/usr.bin/sdpquery/print.c:1.14	Sat Jun 25 09:16:52 2011
+++ src/usr.bin/sdpquery/print.c	Thu Jul  7 10:26:00 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.14 2011/06/25 09:16:52 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.15 2011/07/07 10:26:00 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.14 2011/06/25 09:16:52 plunky Exp $);
+__RCSID($NetBSD: print.c,v 1.15 2011/07/07 10:26:00 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -117,6 +117,7 @@
 static void print_bip_features(sdp_data_t *);
 static void print_bip_functions(sdp_data_t *);
 static void print_bip_capacity(sdp_data_t *);
+static void print_1284id(sdp_data_t *);
 
 static void print_rfcomm(sdp_data_t *);
 static void print_bnep(sdp_data_t *);
@@ -249,7 +250,7 @@
 	{ 0x0352, CharacterRepertoiresSupported,	print_character_repertoires },
 	{ 0x0354, XHTML-PrintImageFormatsSupported,	print_string_list },
 	{ 0x0356, ColorSupported,			print_bool },
-	{ 0x0358, 1284ID,print_string },
+	{ 0x0358, 1284ID,print_1284id },
 	{ 0x035a, PrinterName,			print_string },
 	{ 0x035c, PrinterLocation,			print_string },
 	{ 0x035e, DuplexSupported,			print_bool },
@@ -305,7 +306,7 @@
 };
 
 attr_t hcr_attrs[] = {	/* Hardcopy Cable Replacement */
-	{ 0x0300, 1284ID,print_string },
+	{ 0x0300, 1284ID,print_1284id },
 	{ 0x0302, DeviceName,print_string },
 	{ 0x0304, FriendlyName,			print_string },
 	{ 0x0306, DeviceLocation,			print_string },
@@ -1560,6 +1561,38 @@
 }
 
 static void
+print_1284id(sdp_data_t *data)
+{
+	char *str, *ep;
+	size_t len, l;
+
+	if (!sdp_get_str(data, str, len))
+		return;
+
+	if (len  2 || len != be16dec(str)) {
+		printf([invalid IEEE 1284 Device ID]\n);
+		return;
+	}
+
+	str += 2;
+	len -= 2;
+
+	printf(\n);
+	while (len  0) {
+		ep = memchr(str, (int)';', len);
+		if (ep == NULL) {
+			printf([invalid IEEE 1284 Device ID]\n);
+			return;
+		}
+
+		l = (size_t)(ep - str + 1);
+		printf(%s\n, string_vis(VIS_CSTYLE, str, l));
+		str += l;
+		len -= l;
+	}
+}
+
+static void
 print_rfcomm(sdp_data_t *data)
 {
 	uint8_t v;



CVS commit: src/usr.bin/sdpquery

2011-07-07 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Thu Jul  7 10:49:39 UTC 2011

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
ensure string buffer is null terminated, for zero length strings..


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.15 src/usr.bin/sdpquery/print.c:1.16
--- src/usr.bin/sdpquery/print.c:1.15	Thu Jul  7 10:26:00 2011
+++ src/usr.bin/sdpquery/print.c	Thu Jul  7 10:49:38 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.15 2011/07/07 10:26:00 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.16 2011/07/07 10:49:38 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.15 2011/07/07 10:26:00 plunky Exp $);
+__RCSID($NetBSD: print.c,v 1.16 2011/07/07 10:49:38 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -556,6 +556,7 @@
 	static char buf[50];
 	char *dst = buf;
 
+	buf[0] = '\0';
 	style |= VIS_NL;
 	while (len  0  (dst + 5)  (buf + sizeof(buf))) {
 		dst = vis(dst, src[0], style, (len  1 ? src[1] : 0));



CVS commit: src/usr.bin/sdpquery

2011-06-25 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Sat Jun 25 09:16:52 UTC 2011

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
use size_t to satisfy lint


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.13 src/usr.bin/sdpquery/print.c:1.14
--- src/usr.bin/sdpquery/print.c:1.13	Fri Jun 24 20:53:56 2011
+++ src/usr.bin/sdpquery/print.c	Sat Jun 25 09:16:52 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.13 2011/06/24 20:53:56 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.14 2011/06/25 09:16:52 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.13 2011/06/24 20:53:56 plunky Exp $);
+__RCSID($NetBSD: print.c,v 1.14 2011/06/25 09:16:52 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -67,7 +67,7 @@
 static const char *string_vis(int, const char *, size_t);
 
 static void print_hexdump(const char *, const uint8_t *, size_t);
-static bool print_attribute(uint16_t, sdp_data_t *, attr_t *, int);
+static bool print_attribute(uint16_t, sdp_data_t *, attr_t *, size_t);
 static bool print_universal_attribute(uint16_t, sdp_data_t *);
 static bool print_language_attribute(uint16_t, sdp_data_t *);
 static bool print_service_attribute(uint16_t, sdp_data_t *);
@@ -481,7 +481,8 @@
 	while (sdp_get_attr(rec, id, value)) {
 		if (Xflag) {
 			printf(AttributeID 0x%04x:\n, id);
-			print_hexdump( , value.next, value.end - value.next);
+			print_hexdump( , value.next,
+			(size_t)(value.end - value.next));
 		} else if (Rflag) {
 			printf(AttributeID 0x%04x:\n, id);
 			sdp_data_print(value, 4);
@@ -585,9 +586,9 @@
 }
 
 static bool
-print_attribute(uint16_t id, sdp_data_t *value, attr_t *attr, int count)
+print_attribute(uint16_t id, sdp_data_t *value, attr_t *attr, size_t count)
 {
-	int i;
+	size_t i;
 
 	for (i = 0; i  count; i++) {
 		if (id == attr[i].id) {



CVS commit: src/usr.bin/sdpquery

2011-06-24 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Fri Jun 24 19:03:47 UTC 2011

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
interpret Hardcopy Cable Replacement Profile attributes


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.9 src/usr.bin/sdpquery/print.c:1.10
--- src/usr.bin/sdpquery/print.c:1.9	Fri Jun 24 18:50:32 2011
+++ src/usr.bin/sdpquery/print.c	Fri Jun 24 19:03:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.9 2011/06/24 18:50:32 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.10 2011/06/24 19:03:46 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.9 2011/06/24 18:50:32 plunky Exp $);
+__RCSID($NetBSD: print.c,v 1.10 2011/06/24 19:03:46 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -303,6 +303,13 @@
 	{ 0x020e, HIDBootDevice,			print_bool },
 };
 
+attr_t hcr_attrs[] = {	/* Hardcopy Cable Replacement */
+	{ 0x0300, 1284ID,print_string },
+	{ 0x0302, DeviceName,print_string },
+	{ 0x0304, FriendlyName,			print_string },
+	{ 0x0306, DeviceLocation,			print_string },
+};
+
 attr_t pnp_attrs[] = {	/* Device ID */
 	{ 0x0200, SpecificationID,			print_profile_version },
 	{ 0x0201, VendorID,print_uint16x },
@@ -363,8 +370,8 @@
 	{ 0x1123, Printing Status,			NULL, 0 },
 	{ 0x1124, Human Interface Device,		A(hid_attrs) },
 	{ 0x1125, Hardcopy Cable Replacement,		NULL, 0 },
-	{ 0x1126, Hardcopy Cable Replacement Print,	NULL, 0 },
-	{ 0x1127, Hardcopy Cable Replacement Scan,	NULL, 0 },
+	{ 0x1126, Hardcopy Cable Replacement Print,	A(hcr_attrs) },
+	{ 0x1127, Hardcopy Cable Replacement Scan,	A(hcr_attrs) },
 	{ 0x1128, Common ISDN Access,			NULL, 0 },
 	{ 0x1129, Video Conferencing GW,		NULL, 0 },
 	{ 0x112a, UDI MT,NULL, 0 },



CVS commit: src/usr.bin/sdpquery

2011-06-24 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Fri Jun 24 20:06:04 UTC 2011

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
if print_attribute() did not print, we should try the next
service_class before failing


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.10 src/usr.bin/sdpquery/print.c:1.11
--- src/usr.bin/sdpquery/print.c:1.10	Fri Jun 24 19:03:46 2011
+++ src/usr.bin/sdpquery/print.c	Fri Jun 24 20:06:04 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.10 2011/06/24 19:03:46 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.11 2011/06/24 20:06:04 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.10 2011/06/24 19:03:46 plunky Exp $);
+__RCSID($NetBSD: print.c,v 1.11 2011/06/24 20:06:04 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -646,10 +646,10 @@
 
 	for (i = 0; i  nservices; i++) {
 		for (j = 0; j  __arraycount(service_list); j++) {
-			if (service_class[i] == service_list[j].class)
-return print_attribute(id, value,
-service_list[j].attrs,
-service_list[j].nattr);
+			if (service_class[i] == service_list[j].class
+			 print_attribute(id, value,
+			service_list[j].attrs, service_list[j].nattr))
+return true;
 		}
 	}
 



CVS commit: src/usr.bin/sdpquery

2011-06-24 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Fri Jun 24 20:11:23 UTC 2011

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
in the Basic Printing Profile it is not really very clear
which ServiceClass the attributes relate to, so link them
to Direct Printing and Printer Status as well as
Reference Printing, since I have a printer (HP460) which
does not claim the latter.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.11 src/usr.bin/sdpquery/print.c:1.12
--- src/usr.bin/sdpquery/print.c:1.11	Fri Jun 24 20:06:04 2011
+++ src/usr.bin/sdpquery/print.c	Fri Jun 24 20:11:23 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.11 2011/06/24 20:06:04 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.12 2011/06/24 20:11:23 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.11 2011/06/24 20:06:04 plunky Exp $);
+__RCSID($NetBSD: print.c,v 1.12 2011/06/24 20:11:23 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -356,7 +356,7 @@
 	{ 0x1115, Personal Area Networking User,	A(panu_attrs) },
 	{ 0x1116, Network Access Point,		A(nap_attrs) },
 	{ 0x1117, Group Network,			A(gn_attrs) },
-	{ 0x1118, Direct Printing,			NULL, 0 },
+	{ 0x1118, Direct Printing,			A(bp_attrs) },
 	{ 0x1119, Reference Printing,			A(bp_attrs) },
 	{ 0x111a, Imaging,NULL, 0 },
 	{ 0x111b, Imaging Responder,			A(bi_attrs) },
@@ -367,7 +367,7 @@
 	{ 0x1120, Direct Printing Reference Objects,	NULL, 0 },
 	{ 0x1121, Reflected User Interface,		A(rui_attrs) },
 	{ 0x1122, Basic Printing,			NULL, 0 },
-	{ 0x1123, Printing Status,			NULL, 0 },
+	{ 0x1123, Printing Status,			A(bp_attrs) },
 	{ 0x1124, Human Interface Device,		A(hid_attrs) },
 	{ 0x1125, Hardcopy Cable Replacement,		NULL, 0 },
 	{ 0x1126, Hardcopy Cable Replacement Print,	A(hcr_attrs) },



CVS commit: src/usr.bin/sdpquery

2011-06-24 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Fri Jun 24 20:53:56 UTC 2011

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
some attributes contain comma separated lists which are too long to
show on a single line, split them up


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.12 src/usr.bin/sdpquery/print.c:1.13
--- src/usr.bin/sdpquery/print.c:1.12	Fri Jun 24 20:11:23 2011
+++ src/usr.bin/sdpquery/print.c	Fri Jun 24 20:53:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.12 2011/06/24 20:11:23 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.13 2011/06/24 20:53:56 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.12 2011/06/24 20:11:23 plunky Exp $);
+__RCSID($NetBSD: print.c,v 1.13 2011/06/24 20:53:56 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -82,6 +82,7 @@
 static void print_uuid(sdp_data_t *);
 static void print_uuid_list(sdp_data_t *);
 static void print_string(sdp_data_t *);
+static void print_string_list(sdp_data_t *);
 static void print_url(sdp_data_t *);
 static void print_profile_version(sdp_data_t *);
 static void print_language_string(sdp_data_t *);
@@ -244,19 +245,19 @@
 };
 
 attr_t bp_attrs[] = {	/* Basic Printing */
-	{ 0x0350, DocumentFormatsSupported,		print_string },
+	{ 0x0350, DocumentFormatsSupported,		print_string_list },
 	{ 0x0352, CharacterRepertoiresSupported,	print_character_repertoires },
-	{ 0x0354, XHTML-PrintImageFormatsSupported,	print_string },
+	{ 0x0354, XHTML-PrintImageFormatsSupported,	print_string_list },
 	{ 0x0356, ColorSupported,			print_bool },
 	{ 0x0358, 1284ID,print_string },
 	{ 0x035a, PrinterName,			print_string },
 	{ 0x035c, PrinterLocation,			print_string },
 	{ 0x035e, DuplexSupported,			print_bool },
-	{ 0x0360, MediaTypesSupported,		print_string },
+	{ 0x0360, MediaTypesSupported,		print_string_list },
 	{ 0x0362, MaxMediaWidth,			print_uint16d },
 	{ 0x0364, MaxMediaLength,			print_uint16d },
 	{ 0x0366, EnhancedLayoutSupport,		print_bool },
-	{ 0x0368, RUIFormatsSupported,		print_string },
+	{ 0x0368, RUIFormatsSupported,		print_string_list },
 	{ 0x0370, ReferencePrintingRUISupported,	print_bool },
 	{ 0x0372, DirectPrintingRUISupported,		print_bool },
 	{ 0x0374, ReferencePrintingTopURL,		print_url },
@@ -281,7 +282,7 @@
 };
 
 attr_t rui_attrs[] = {	/* Reflected User Interface */
-	{ 0x0368, RUIFormatsSupported,		print_string },
+	{ 0x0368, RUIFormatsSupported,		print_string_list },
 	{ 0x0378, PrinterAdminRUITopURL,		print_url },
 };
 
@@ -774,6 +775,31 @@
 }
 
 static void
+print_string_list(sdp_data_t *data)
+{
+	char *str, *ep;
+	size_t len, l;
+
+	if (!sdp_get_str(data, str, len))
+		return;
+
+	printf(\n);
+	while (len  0) {
+		ep = memchr(str, (int)',', len);
+		if (ep == NULL) {
+			l = len;
+			len = 0;
+		} else {
+			l = (size_t)(ep - str);
+			len -= l + 1;
+			ep++;
+		}
+		printf(%s\n, string_vis(VIS_CSTYLE, str, l));
+		str = ep;
+	}
+}
+
+static void
 print_url(sdp_data_t *data)
 {
 	char *url;



CVS commit: src/usr.bin/sdpquery

2011-02-08 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Tue Feb  8 18:14:00 UTC 2011

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

Log Message:
use built-in macro ___STRING() rather than rolling our own


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/sdpquery/command.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.bin/sdpquery/command.c
diff -u src/usr.bin/sdpquery/command.c:1.3 src/usr.bin/sdpquery/command.c:1.4
--- src/usr.bin/sdpquery/command.c:1.3	Sat Dec  5 16:54:13 2009
+++ src/usr.bin/sdpquery/command.c	Tue Feb  8 18:14:00 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: command.c,v 1.3 2009/12/05 16:54:13 plunky Exp $	*/
+/*	$NetBSD: command.c,v 1.4 2011/02/08 18:14:00 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: command.c,v 1.3 2009/12/05 16:54:13 plunky Exp $);
+__RCSID($NetBSD: command.c,v 1.4 2011/02/08 18:14:00 plunky Exp $);
 
 #include bluetooth.h
 #include err.h
@@ -97,9 +97,7 @@
 int
 do_sdp_browse(int argc, const char **argv)
 {
-#define STR(x)	__STRING(x)
-	const char *av = STR(SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP);
-#undef STR
+	const char *av = ___STRING(SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP);
 
 	if (argc  1)
 		errx(EXIT_FAILURE, Too many arguments);



CVS commit: src/usr.bin/sdpquery

2010-12-14 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Tue Dec 14 15:18:20 UTC 2010

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
on reflection we can use uintmax_t here instead of trying to decode
the value manually, as only 17 bits are defined and the value is
unlikely to exceed UINTMAX_MAX (would only prevent decoding)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.6 src/usr.bin/sdpquery/print.c:1.7
--- src/usr.bin/sdpquery/print.c:1.6	Mon Dec 13 21:08:37 2010
+++ src/usr.bin/sdpquery/print.c	Tue Dec 14 15:18:20 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.6 2010/12/13 21:08:37 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.7 2010/12/14 15:18:20 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.6 2010/12/13 21:08:37 plunky Exp $);
+__RCSID($NetBSD: print.c,v 1.7 2010/12/14 15:18:20 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -1375,45 +1375,39 @@
 static void
 print_character_repertoires(sdp_data_t *data)
 {
-	sdp_data_t d;
-	uint32_t v0, v1, v2, v3;
+	uintmax_t v;
 
 	/*
-	 * we have no uint128 type, so need to decode it manually
+	 * we have no uint128 type so use uintmax as only
+	 * only 17-bits are currently defined, and if the
+	 * value is out of bounds it will be printed anyway
 	 */
-
-	if (sdp_data_type(data) != SDP_DATA_UINT128)
+	if (sdp_data_type(data) != SDP_DATA_UINT128
+	|| !sdp_get_uint(data, v))
 		return;
 
-	sdp_get_data(data, d);
-	v0 = be32dec(d.next + 1);
-	v1 = be32dec(d.next + 5);
-	v2 = be32dec(d.next + 9);
-	v3 = be32dec(d.next + 13);
-
 	if (Nflag)
-		printf((0x%08x%08x%08x%08x), v0, v1, v2, v3);
+		printf((0x%016jx), v);
 
 	printf(\n);
-
-	if (v0  (1 0)) printf(ISO-8859-1\n);
-	if (v0  (1 1)) printf(ISO-8859-2\n);
-	if (v0  (1 2)) printf(ISO-8859-3\n);
-	if (v0  (1 3)) printf(ISO-8859-4\n);
-	if (v0  (1 4)) printf(ISO-8859-5\n);
-	if (v0  (1 5)) printf(ISO-8859-6\n);
-	if (v0  (1 6)) printf(ISO-8859-7\n);
-	if (v0  (1 7)) printf(ISO-8859-8\n);
-	if (v0  (1 8)) printf(ISO-8859-9\n);
-	if (v0  (1 9)) printf(ISO-8859-10\n);
-	if (v0  (110)) printf(ISO-8859-13\n);
-	if (v0  (111)) printf(ISO-8859-14\n);
-	if (v0  (112)) printf(ISO-8859-15\n);
-	if (v0  (113)) printf(GB18030\n);
-	if (v0  (114)) printf(JIS X0208-1990, JIS X0201-1976\n);
-	if (v0  (115)) printf(KSC 5601-1992\n);
-	if (v0  (116)) printf(Big5\n);
-	if (v0  (117)) printf(TIS-620\n);
+	if (v  (1 0)) printf(ISO-8859-1\n);
+	if (v  (1 1)) printf(ISO-8859-2\n);
+	if (v  (1 2)) printf(ISO-8859-3\n);
+	if (v  (1 3)) printf(ISO-8859-4\n);
+	if (v  (1 4)) printf(ISO-8859-5\n);
+	if (v  (1 5)) printf(ISO-8859-6\n);
+	if (v  (1 6)) printf(ISO-8859-7\n);
+	if (v  (1 7)) printf(ISO-8859-8\n);
+	if (v  (1 8)) printf(ISO-8859-9\n);
+	if (v  (1 9)) printf(ISO-8859-10\n);
+	if (v  (110)) printf(ISO-8859-13\n);
+	if (v  (111)) printf(ISO-8859-14\n);
+	if (v  (112)) printf(ISO-8859-15\n);
+	if (v  (113)) printf(GB18030\n);
+	if (v  (114)) printf(JIS X0208-1990, JIS X0201-1976\n);
+	if (v  (115)) printf(KSC 5601-1992\n);
+	if (v  (116)) printf(Big5\n);
+	if (v  (117)) printf(TIS-620\n);
 }
 
 static void



CVS commit: src/usr.bin/sdpquery

2010-12-13 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Mon Dec 13 21:08:38 UTC 2010

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
add attributes from the Basic Printing Profile v1.2r00


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.5 src/usr.bin/sdpquery/print.c:1.6
--- src/usr.bin/sdpquery/print.c:1.5	Sun Nov 22 18:53:44 2009
+++ src/usr.bin/sdpquery/print.c	Mon Dec 13 21:08:37 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.5 2009/11/22 18:53:44 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.6 2010/12/13 21:08:37 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.5 2009/11/22 18:53:44 plunky Exp $);
+__RCSID($NetBSD: print.c,v 1.6 2010/12/13 21:08:37 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -111,6 +111,7 @@
 static void print_pnp_source(sdp_data_t *);
 static void print_mas_types(sdp_data_t *);
 static void print_supported_repositories(sdp_data_t *);
+static void print_character_repertoires(sdp_data_t *);
 
 static void print_rfcomm(sdp_data_t *);
 static void print_bnep(sdp_data_t *);
@@ -238,6 +239,27 @@
 	{ 0x030e, IPv6Subnet,print_string },
 };
 
+attr_t bp_attrs[] = {	/* Basic Printing */
+	{ 0x0350, DocumentFormatsSupported,		print_string },
+	{ 0x0352, CharacterRepertoiresSupported,	print_character_repertoires },
+	{ 0x0354, XHTML-PrintImageFormatsSupported,	print_string },
+	{ 0x0356, ColorSupported,			print_bool },
+	{ 0x0358, 1284ID,print_string },
+	{ 0x035a, PrinterName,			print_string },
+	{ 0x035c, PrinterLocation,			print_string },
+	{ 0x035e, DuplexSupported,			print_bool },
+	{ 0x0360, MediaTypesSupported,		print_string },
+	{ 0x0362, MaxMediaWidth,			print_uint16d },
+	{ 0x0364, MaxMediaLength,			print_uint16d },
+	{ 0x0366, EnhancedLayoutSupport,		print_bool },
+	{ 0x0368, RUIFormatsSupported,		print_string },
+	{ 0x0370, ReferencePrintingRUISupported,	print_bool },
+	{ 0x0372, DirectPrintingRUISupported,		print_bool },
+	{ 0x0374, ReferencePrintingTopURL,		print_url },
+	{ 0x0376, DirectPrintingTopURL,		print_url },
+	{ 0x037a, DeviceName,print_string },
+};
+
 attr_t hf_attrs[] = {	/* Handsfree */
 	{ 0x0311, SupportedFeatures,			print_hf_features },
 };
@@ -247,6 +269,11 @@
 	{ 0x0311, SupportedFeatures,			print_hfag_features },
 };
 
+attr_t rui_attrs[] = {	/* Reflected User Interface */
+	{ 0x0368, RUIFormatsSupported,		print_string },
+	{ 0x0378, PrinterAdminRUITopURL,		print_url },
+};
+
 attr_t hid_attrs[] = {	/* Human Interface Device */
 	{ 0x0200, HIDDeviceReleaseNumber,		print_hid_version },
 	{ 0x0201, HIDParserVersion,			print_hid_version },
@@ -312,7 +339,7 @@
 	{ 0x1116, Network Access Point,		A(nap_attrs) },
 	{ 0x1117, Group Network,			A(gn_attrs) },
 	{ 0x1118, Direct Printing,			NULL, 0 },
-	{ 0x1119, Reference Printing,			NULL, 0 },
+	{ 0x1119, Reference Printing,			A(bp_attrs) },
 	{ 0x111a, Imaging,NULL, 0 },
 	{ 0x111b, Imaging Responder,			NULL, 0 },
 	{ 0x111c, Imaging Automatic Archive,		NULL, 0 },
@@ -320,7 +347,7 @@
 	{ 0x111e, Handsfree,A(hf_attrs) },
 	{ 0x111f, Handsfree Audio Gateway,		A(hfag_attrs) },
 	{ 0x1120, Direct Printing Reference Objects,	NULL, 0 },
-	{ 0x1121, Reflected User Interface,		NULL, 0 },
+	{ 0x1121, Reflected User Interface,		A(rui_attrs) },
 	{ 0x1122, Basic Printing,			NULL, 0 },
 	{ 0x1123, Printing Status,			NULL, 0 },
 	{ 0x1124, Human Interface Device,		A(hid_attrs) },
@@ -1346,6 +1373,50 @@
 }
 
 static void
+print_character_repertoires(sdp_data_t *data)
+{
+	sdp_data_t d;
+	uint32_t v0, v1, v2, v3;
+
+	/*
+	 * we have no uint128 type, so need to decode it manually
+	 */
+
+	if (sdp_data_type(data) != SDP_DATA_UINT128)
+		return;
+
+	sdp_get_data(data, d);
+	v0 = be32dec(d.next + 1);
+	v1 = be32dec(d.next + 5);
+	v2 = be32dec(d.next + 9);
+	v3 = be32dec(d.next + 13);
+
+	if (Nflag)
+		printf((0x%08x%08x%08x%08x), v0, v1, v2, v3);
+
+	printf(\n);
+
+	if (v0  (1 0)) printf(ISO-8859-1\n);
+	if (v0  (1 1)) printf(ISO-8859-2\n);
+	if (v0  (1 2)) printf(ISO-8859-3\n);
+	if (v0  (1 3)) printf(ISO-8859-4\n);
+	if (v0  (1 4)) printf(ISO-8859-5\n);
+	if (v0  (1 5)) printf(ISO-8859-6\n);
+	if (v0  (1 6)) printf(ISO-8859-7\n);
+	if (v0  (1 7)) printf(ISO-8859-8\n);
+	if (v0  (1 8)) printf(ISO-8859-9\n);
+	if (v0  (1 9)) printf(ISO-8859-10\n);
+	if (v0  (110)) printf(ISO-8859-13\n);
+	if (v0  (111)) printf(ISO-8859-14\n);
+	if (v0  (112)) printf(ISO-8859-15\n);
+	if (v0  (113)) printf(GB18030\n);
+	if (v0  (114)) printf(JIS X0208-1990, JIS X0201-1976\n);
+	if (v0  (115)) printf(KSC 5601-1992\n);
+	if (v0  (116)) printf(Big5\n);
+	if (v0  (117)) printf(TIS-620\n);
+}
+

CVS commit: src/usr.bin/sdpquery

2009-12-05 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Sat Dec  5 16:54:14 UTC 2009

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

Log Message:
add alias for Plug'n'Play Information service UUID.
(This is sometimes used in HID devices to provide manufacturer information)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/sdpquery/command.c
cvs rdiff -u -r1.13 -r1.14 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.2 src/usr.bin/sdpquery/command.c:1.3
--- src/usr.bin/sdpquery/command.c:1.2	Tue Oct  6 19:21:17 2009
+++ src/usr.bin/sdpquery/command.c	Sat Dec  5 16:54:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: command.c,v 1.2 2009/10/06 19:21:17 plunky Exp $	*/
+/*	$NetBSD: command.c,v 1.3 2009/12/05 16:54:13 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: command.c,v 1.2 2009/10/06 19:21:17 plunky Exp $);
+__RCSID($NetBSD: command.c,v 1.3 2009/12/05 16:54:13 plunky Exp $);
 
 #include bluetooth.h
 #include err.h
@@ -82,6 +82,8 @@
 	  OPUSH,	Object Push Service},
 	{ SDP_SERVICE_CLASS_PANU,
 	  PANU,	Personal Area Networking User Service		},
+	{ SDP_SERVICE_CLASS_PNP_INFORMATION,
+	  PNP,	PNP Information Service			},
 	{ SDP_UUID_PROTOCOL_RFCOMM,
 	  RFCOMM,	RFCOMM Protocol},
 	{ SDP_UUID_PROTOCOL_SDP,

Index: src/usr.bin/sdpquery/sdpquery.1
diff -u src/usr.bin/sdpquery/sdpquery.1:1.13 src/usr.bin/sdpquery/sdpquery.1:1.14
--- src/usr.bin/sdpquery/sdpquery.1:1.13	Tue Oct  6 21:39:58 2009
+++ src/usr.bin/sdpquery/sdpquery.1	Sat Dec  5 16:54:13 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: sdpquery.1,v 1.13 2009/10/06 21:39:58 wiz Exp $
+.\	$NetBSD: sdpquery.1,v 1.14 2009/12/05 16:54:13 plunky Exp $
 .\
 .\ Copyright (c) 2006 Itronix Inc.
 .\ All rights reserved.
@@ -178,6 +178,8 @@
 Object Push Service
 .It PANU
 Personal Area Networking User Service
+.It PNP
+Plug'n'Play Information Service
 .It RFCOMM
 RFCOMM Protocol
 .It SDP



CVS commit: src/usr.bin/sdpquery

2009-11-22 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Sun Nov 22 18:53:44 UTC 2009

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
add translation for 802.1Q ethertype


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.4 src/usr.bin/sdpquery/print.c:1.5
--- src/usr.bin/sdpquery/print.c:1.4	Thu Aug 20 11:07:42 2009
+++ src/usr.bin/sdpquery/print.c	Sun Nov 22 18:53:44 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.4 2009/08/20 11:07:42 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.5 2009/11/22 18:53:44 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.4 2009/08/20 11:07:42 plunky Exp $);
+__RCSID($NetBSD: print.c,v 1.5 2009/11/22 18:53:44 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -1374,6 +1374,7 @@
 		switch (v) {
 		case 0x0800:	printf(IPv4);		break;
 		case 0x0806:	printf(ARP);		break;
+		case 0x8100:	printf(802.1Q);	break;
 		case 0x86dd:	printf(IPv6);		break;
 		default:	printf(0x%04x, v);	break;
 		}



CVS commit: src/usr.bin/sdpquery

2009-10-06 Thread Iain Hibbert
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 m_evmen...@yahoo.com
 .An Iain Hibbert
 for Itronix, Inc.
-.Sh BUGS
-.Nm
-will only search for Bluetooth
-.Qq short alias
-16-bit UUIDs.



CVS commit: src/usr.bin/sdpquery

2009-10-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Oct  6 21:39:58 UTC 2009

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

Log Message:
Fix Dd argument (use full month names).


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 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/sdpquery.1
diff -u src/usr.bin/sdpquery/sdpquery.1:1.12 src/usr.bin/sdpquery/sdpquery.1:1.13
--- src/usr.bin/sdpquery/sdpquery.1:1.12	Tue Oct  6 19:21:17 2009
+++ src/usr.bin/sdpquery/sdpquery.1	Tue Oct  6 21:39:58 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: sdpquery.1,v 1.12 2009/10/06 19:21:17 plunky Exp $
+.\	$NetBSD: sdpquery.1,v 1.13 2009/10/06 21:39:58 wiz 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 Oct 6, 2009
+.Dd October 6, 2009
 .Dt SDPQUERY 1
 .Os
 .Sh NAME



CVS commit: src/usr.bin/sdpquery

2009-08-20 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Thu Aug 20 11:07:42 UTC 2009

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
add SupportedRepositories attribute for Phonebook Access profile
providing PhonebookAccessServer service


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.3 src/usr.bin/sdpquery/print.c:1.4
--- src/usr.bin/sdpquery/print.c:1.3	Sat Jul 25 17:32:47 2009
+++ src/usr.bin/sdpquery/print.c	Thu Aug 20 11:07:42 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.3 2009/07/25 17:32:47 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.4 2009/08/20 11:07:42 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.3 2009/07/25 17:32:47 plunky Exp $);
+__RCSID($NetBSD: print.c,v 1.4 2009/08/20 11:07:42 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -110,6 +110,7 @@
 static void print_net_access_type(sdp_data_t *);
 static void print_pnp_source(sdp_data_t *);
 static void print_mas_types(sdp_data_t *);
+static void print_supported_repositories(sdp_data_t *);
 
 static void print_rfcomm(sdp_data_t *);
 static void print_bnep(sdp_data_t *);
@@ -278,6 +279,10 @@
 	{ 0x0316, SupportedMessageTypes,		print_mas_types },
 };
 
+attr_t pse_attrs[] = {	/* Phonebook Access Server */
+	{ 0x0314, SupportedRepositories,		print_supported_repositories },
+};
+
 #define A(a)	a, __arraycount(a)
 service_t service_list[] = {
 	{ 0x1000, Service Discovery Server,		A(sds_attrs) },
@@ -328,8 +333,8 @@
 	{ 0x112b, UDI TA,NULL, 0 },
 	{ 0x112c, Audio/Video,			NULL, 0 },
 	{ 0x112d, SIM Access,NULL, 0 },
-	{ 0x112e, Phonebook Access PCE,		NULL, 0 },
-	{ 0x112f, Phonebook Access PSE,		NULL, 0 },
+	{ 0x112e, Phonebook Access Client,		NULL, 0 },
+	{ 0x112f, Phonebook Access Server,		A(pse_attrs) },
 	{ 0x1130, Phonebook Access,			NULL, 0 },
 	{ 0x1131, Headset HS,NULL, 0 },
 	{ 0x1132, Message Access Server,		A(mas_attrs) },
@@ -1325,6 +1330,22 @@
 }
 
 static void
+print_supported_repositories(sdp_data_t *data)
+{
+	uint8_t v;
+
+	if (!sdp_get_uint8(data, v))
+		return;
+
+	if (Nflag)
+		printf((0x%02x), v);
+
+	printf(\n);
+	if (v  (10))	printf(Local Phonebook\n);
+	if (v  (11))	printf(SIM Card\n);
+}
+
+static void
 print_rfcomm(sdp_data_t *data)
 {
 	uint8_t v;



CVS commit: src/usr.bin/sdpquery

2009-07-25 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Sat Jul 25 17:32:47 UTC 2009

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
add new Service Class ID and Protocol UUIDs from the Service Discovery
assigned numbers document at www.bluetooth.com

add detail printing for Message Access Profile v1.0


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.2 src/usr.bin/sdpquery/print.c:1.3
--- src/usr.bin/sdpquery/print.c:1.2	Sat Jul  4 16:01:15 2009
+++ src/usr.bin/sdpquery/print.c	Sat Jul 25 17:32:47 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.2 2009/07/04 16:01:15 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.3 2009/07/25 17:32:47 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.2 2009/07/04 16:01:15 plunky Exp $);
+__RCSID($NetBSD: print.c,v 1.3 2009/07/25 17:32:47 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -73,6 +73,7 @@
 static bool print_service_attribute(uint16_t, sdp_data_t *);
 
 static void print_bool(sdp_data_t *);
+static void print_uint8d(sdp_data_t *);
 static void print_uint8x(sdp_data_t *);
 static void print_uint16d(sdp_data_t *);
 static void print_uint16x(sdp_data_t *);
@@ -108,6 +109,7 @@
 static void print_hfag_features(sdp_data_t *);
 static void print_net_access_type(sdp_data_t *);
 static void print_pnp_source(sdp_data_t *);
+static void print_mas_types(sdp_data_t *);
 
 static void print_rfcomm(sdp_data_t *);
 static void print_bnep(sdp_data_t *);
@@ -137,6 +139,8 @@
 	{ 0x0019, AVDTP,print_avdtp },
 	{ 0x001b, CMTP,NULL },
 	{ 0x001d, UDI_C_PLANE,			NULL },
+	{ 0x001e, MCAP_CONTROL_CHANNEL,		NULL },
+	{ 0x001f, MCAP_DATA_CHANNEL,			NULL },
 	{ 0x0100, L2CAP,print_l2cap },
 };
 
@@ -269,6 +273,11 @@
 	{ 0x0205, VendorIDSource,			print_pnp_source },
 };
 
+attr_t mas_attrs[] = {	/* Message Access Server */
+	{ 0x0315, InstanceID,print_uint8d },
+	{ 0x0316, SupportedMessageTypes,		print_mas_types },
+};
+
 #define A(a)	a, __arraycount(a)
 service_t service_list[] = {
 	{ 0x1000, Service Discovery Server,		A(sds_attrs) },
@@ -319,6 +328,13 @@
 	{ 0x112b, UDI TA,NULL, 0 },
 	{ 0x112c, Audio/Video,			NULL, 0 },
 	{ 0x112d, SIM Access,NULL, 0 },
+	{ 0x112e, Phonebook Access PCE,		NULL, 0 },
+	{ 0x112f, Phonebook Access PSE,		NULL, 0 },
+	{ 0x1130, Phonebook Access,			NULL, 0 },
+	{ 0x1131, Headset HS,NULL, 0 },
+	{ 0x1132, Message Access Server,		A(mas_attrs) },
+	{ 0x1133, Message Notification Server,	NULL, 0 },
+	{ 0x1134, Message Access Profile,		NULL, 0 },
 	{ 0x1200, PNP Information,			A(pnp_attrs) },
 	{ 0x1201, Generic Networking,			NULL, 0 },
 	{ 0x1202, Generic File Transfer,		NULL, 0 },
@@ -329,6 +345,12 @@
 	{ 0x1300, UPNP IP PAN,			NULL, 0 },
 	{ 0x1301, UPNP IP LAP,			NULL, 0 },
 	{ 0x1302, UPNP IP L2CAP,			NULL, 0 },
+	{ 0x1303, Video Source,			NULL, 0 },
+	{ 0x1304, Video Sink,NULL, 0 },
+	{ 0x1305, Video Distribution,			NULL, 0 },
+	{ 0x1400, HDP,NULL, 0 },
+	{ 0x1401, HDP Source,NULL, 0 },
+	{ 0x1402, HDP Sink,NULL, 0 },
 };
 #undef A
 
@@ -583,6 +605,17 @@
 }
 
 static void
+print_uint8d(sdp_data_t *data)
+{
+	uint8_t v;
+
+	if (!sdp_get_uint8(data, v))
+		return;
+
+	printf(%d\n, v);
+}
+
+static void
 print_uint8x(sdp_data_t *data)
 {
 	uint8_t v;
@@ -1274,6 +1307,24 @@
 }
 
 static void
+print_mas_types(sdp_data_t *data)
+{
+	uint8_t v;
+
+	if (!sdp_get_uint8(data, v))
+		return;
+
+	if (Nflag)
+		printf((0x%02x), v);
+
+	printf(\n);
+	if (v  (10))	printf(EMAIL\n);
+	if (v  (11))	printf(SMS_GSM\n);
+	if (v  (12))	printf(SMS_CDMA\n);
+	if (v  (13))	printf(MMS\n);
+}
+
+static void
 print_rfcomm(sdp_data_t *data)
 {
 	uint8_t v;



CVS commit: src/usr.bin/sdpquery

2009-07-04 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Sat Jul  4 16:01:15 UTC 2009

Modified Files:
src/usr.bin/sdpquery: print.c

Log Message:
add interpretation of PNP Information service class (Device ID profile)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/sdpquery/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.bin/sdpquery/print.c
diff -u src/usr.bin/sdpquery/print.c:1.1 src/usr.bin/sdpquery/print.c:1.2
--- src/usr.bin/sdpquery/print.c:1.1	Tue May 12 18:37:50 2009
+++ src/usr.bin/sdpquery/print.c	Sat Jul  4 16:01:15 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.1 2009/05/12 18:37:50 plunky Exp $	*/
+/*	$NetBSD: print.c,v 1.2 2009/07/04 16:01:15 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: print.c,v 1.1 2009/05/12 18:37:50 plunky Exp $);
+__RCSID($NetBSD: print.c,v 1.2 2009/07/04 16:01:15 plunky Exp $);
 
 #include ctype.h
 #include iconv.h
@@ -75,6 +75,7 @@
 static void print_bool(sdp_data_t *);
 static void print_uint8x(sdp_data_t *);
 static void print_uint16d(sdp_data_t *);
+static void print_uint16x(sdp_data_t *);
 static void print_uint32x(sdp_data_t *);
 static void print_uint32d(sdp_data_t *);
 static void print_uuid(sdp_data_t *);
@@ -106,6 +107,7 @@
 static void print_hfag_network(sdp_data_t *);
 static void print_hfag_features(sdp_data_t *);
 static void print_net_access_type(sdp_data_t *);
+static void print_pnp_source(sdp_data_t *);
 
 static void print_rfcomm(sdp_data_t *);
 static void print_bnep(sdp_data_t *);
@@ -258,6 +260,15 @@
 	{ 0x020e, HIDBootDevice,			print_bool },
 };
 
+attr_t pnp_attrs[] = {	/* Device ID */
+	{ 0x0200, SpecificationID,			print_profile_version },
+	{ 0x0201, VendorID,print_uint16x },
+	{ 0x0202, ProductID,print_uint16x },
+	{ 0x0203, Version,print_hid_version },
+	{ 0x0204, PrimaryRecord,			print_bool },
+	{ 0x0205, VendorIDSource,			print_pnp_source },
+};
+
 #define A(a)	a, __arraycount(a)
 service_t service_list[] = {
 	{ 0x1000, Service Discovery Server,		A(sds_attrs) },
@@ -308,7 +319,7 @@
 	{ 0x112b, UDI TA,NULL, 0 },
 	{ 0x112c, Audio/Video,			NULL, 0 },
 	{ 0x112d, SIM Access,NULL, 0 },
-	{ 0x1200, PNP Information,			NULL, 0 },
+	{ 0x1200, PNP Information,			A(pnp_attrs) },
 	{ 0x1201, Generic Networking,			NULL, 0 },
 	{ 0x1202, Generic File Transfer,		NULL, 0 },
 	{ 0x1203, Generic Audio,			NULL, 0 },
@@ -594,6 +605,17 @@
 }
 
 static void
+print_uint16x(sdp_data_t *data)
+{
+	uint16_t v;
+
+	if (!sdp_get_uint16(data, v))
+		return;
+
+	printf(0x%04x\n, v);
+}
+
+static void
 print_uint32x(sdp_data_t *data)
 {
 	uint32_t v;
@@ -1235,6 +1257,23 @@
 }
 
 static void
+print_pnp_source(sdp_data_t *data)
+{
+	uint16_t v;
+
+	if (!sdp_get_uint16(data, v))
+		return;
+
+	switch (v) {
+	case 0x0001:	printf(Bluetooth SIG);		break;
+	case 0x0002:	printf(USB Implementers Forum);	break;
+	default:	printf(0x%04x, v);			break;
+	}
+
+	printf(\n);
+}
+
+static void
 print_rfcomm(sdp_data_t *data)
 {
 	uint8_t v;



CVS commit: src/usr.bin/sdpquery

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

Modified Files:
src/usr.bin/sdpquery: Makefile sdpquery.1 sdpquery.c sdpquery.h
Added Files:
src/usr.bin/sdpquery: command.c print.c
Removed Files:
src/usr.bin/sdpquery: search.c

Log Message:
update sdpquery with a newer version that fetches the whole service
record and displays it in a human readable fashion.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/sdpquery/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/sdpquery/command.c \
src/usr.bin/sdpquery/print.c
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/sdpquery/sdpquery.1
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/sdpquery/sdpquery.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/sdpquery/sdpquery.h
cvs rdiff -u -r1.7 -r0 src/usr.bin/sdpquery/search.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.bin/sdpquery/Makefile
diff -u src/usr.bin/sdpquery/Makefile:1.5 src/usr.bin/sdpquery/Makefile:1.6
--- src/usr.bin/sdpquery/Makefile:1.5	Tue May 12 13:15:10 2009
+++ src/usr.bin/sdpquery/Makefile	Tue May 12 18:37:50 2009
@@ -1,14 +1,12 @@
-# $NetBSD: Makefile,v 1.5 2009/05/12 13:15:10 plunky Exp $
+# $NetBSD: Makefile,v 1.6 2009/05/12 18:37:50 plunky Exp $
 
 USE_FORT?= yes	# network client
 
 PROG=		sdpquery
 MAN=		sdpquery.1
-SRCS=		sdpquery.c search.c
+SRCS=		sdpquery.c command.c print.c
 
 DPADD+=		${LIBBLUETOOTH}
 LDADD+=		-lbluetooth
 
-CPPFLAGS+=	-DSDP_COMPAT
-
 .include bsd.prog.mk

Index: src/usr.bin/sdpquery/sdpquery.1
diff -u src/usr.bin/sdpquery/sdpquery.1:1.9 src/usr.bin/sdpquery/sdpquery.1:1.10
--- src/usr.bin/sdpquery/sdpquery.1:1.9	Tue Mar 10 20:30:08 2009
+++ src/usr.bin/sdpquery/sdpquery.1	Tue May 12 18:37:50 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: sdpquery.1,v 1.9 2009/03/10 20:30:08 joerg Exp $
+.\	$NetBSD: sdpquery.1,v 1.10 2009/05/12 18:37:50 plunky Exp $
 .\
 .\ Copyright (c) 2006 Itronix Inc.
 .\ All rights reserved.
@@ -27,6 +27,7 @@
 .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\ POSSIBILITY OF SUCH DAMAGE.
 .\
+.\ Copyright (c) 2009 The NetBSD Foundation, Inc.
 .\ Copyright (c) 2003 Maksim Yevmenkin m_evmen...@yahoo.com
 .\ All rights reserved.
 .\
@@ -51,24 +52,23 @@
 .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\ SUCH DAMAGE.
 .\
-.\ $Id: sdpquery.1,v 1.9 2009/03/10 20:30:08 joerg Exp $
 .\ $FreeBSD: src/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.8,v 1.6 2005/07/09 19:04:43 markus Exp $
 .\
-.Dd February 17, 2007
+.Dd May 7, 2009
 .Dt SDPQUERY 1
 .Os
 .Sh NAME
 .Nm sdpquery
-.Nd SDP query utility
+.Nd Service Discovery Protocol query utility
 .Sh SYNOPSIS
 .Nm
-.Fl h
-.Nm
+.Op Fl NRX
 .Op Fl d Ar device
 .Fl a Ar address
 .Ar command
 .Op Ar parameters ...
 .Nm
+.Op Fl NRX
 .Op Fl c Ar path
 .Fl l
 .Ar command
@@ -82,8 +82,9 @@
 Connection to the local SDP server is made via the control socket.
 The
 .Nm
-utility uses Service Search Attribute Requests and prints results to
-standard output and error messages to standard error.
+utility retrieves complete Service Records as directed and prints
+each records attribute ID/value list to standard output and error
+messages to standard error.
 .Pp
 The options are as follows:
 .Bl -tag -width .Fl a Ar address
@@ -112,61 +113,84 @@
 utility will use the best available.
 .It Fl l
 Query the local SDP server via the control socket.
-.It Fl h
-Display usage message and exit.
+.It Fl N
+Additionally display numerical values.
+.It Fl R
+Display service attributes in raw (uninterpreted) format.
+.It Fl X
+Display service attribute values in hex.
 .El
 .Pp
 The currently supported commands in
 .Nm
 are:
 .Pp
-.Bl -tag -width .Cm search Ar service -compact
+.Bl -tag -width Browse -compact
 .It Cm Browse Op Ar group
 Browse for services.
 The
 .Ar group
 parameter is a 16-bit UUID of the group to browse.
-If omitted, the Public Browse Group. is used.
-.Pp
-.It Cm Search Ar service
-Search for the
-.Ar service .
-The
-.Ar service
-parameter is a 16-bit UUID of the service to search for.
-For the following services it is possible to use service name
-instead of service UUID:
+If omitted, the Public Browse Group is used.
 .Pp
-.Bl -tag -compact -width OPUSH
+.It Cm Record Ar handle Op Ar handle...
+Retrieve the Service Record with the given
+.Ar handle .
+Multiple handles can be given.
+.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
+.Bl -tag -offset indent -compact -width RFCOMMxxx
+.It A2DP
+Advanced Audio Distribution Profile
+.It BNEP
+Bluetooth Network Encapsulation Protocol
 .It CIP
-Common ISDN Access
+Common ISDN Access Service
 .It CTP
-Cordless Telephony
+Cordless Telephony Service
 .It DUN
-DialUp Networking
+Dialup Networking Service
 .It FAX
-Fax
+Fax Service
 .It FTRN
-OBEX File 

CVS commit: src/usr.bin/sdpquery

2009-04-13 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Mon Apr 13 07:23:14 UTC 2009

Modified Files:
src/usr.bin/sdpquery: search.c

Log Message:
Fix -Wsign-compare issues


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/sdpquery/search.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.bin/sdpquery/search.c
diff -u src/usr.bin/sdpquery/search.c:1.6 src/usr.bin/sdpquery/search.c:1.7
--- src/usr.bin/sdpquery/search.c:1.6	Tue Nov  6 21:35:52 2007
+++ src/usr.bin/sdpquery/search.c	Mon Apr 13 07:23:14 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: search.c,v 1.6 2007/11/06 21:35:52 plunky Exp $	*/
+/*	$NetBSD: search.c,v 1.7 2009/04/13 07:23:14 lukem Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -55,12 +55,12 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: search.c,v 1.6 2007/11/06 21:35:52 plunky Exp $
+ * $Id: search.c,v 1.7 2009/04/13 07:23:14 lukem Exp $
  * $FreeBSD: src/usr.sbin/bluetooth/sdpcontrol/search.c,v 1.4 2005/05/27 19:11:33 emax Exp $
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: search.c,v 1.6 2007/11/06 21:35:52 plunky Exp $);
+__RCSID($NetBSD: search.c,v 1.7 2009/04/13 07:23:14 lukem Exp $);
 
 #include netinet/in.h
 #include bluetooth.h
@@ -568,7 +568,9 @@
 	struct service	*s;
 	void		*xs;
 	char		*ep;
-	int32_t		 n, type, value;
+	int32_t		 type, value;
+	size_t		 n;
+	int		 sdp;
 	uint16_t	 service;
 
 	if (argc != 1)
@@ -603,8 +605,8 @@
 		err(EXIT_FAILURE, sdp_open);
 
 	/* Do SDP Service Search Attribute Request */
-	n = sdp_search(xs, 1, service, attrs_len, attrs, values_len, values);
-	if (n != 0)
+	sdp = sdp_search(xs, 1, service, attrs_len, attrs, values_len, values);
+	if (sdp != 0)
 		err(EXIT_FAILURE, sdp_search);
 
 	sdp_close(xs);