From owner-freebsd-bluetooth@FreeBSD.ORG Tue Dec 7 22:44:28 2004 Return-Path: Delivered-To: freebsd-bluetooth@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D2C2B16A4CE for ; Tue, 7 Dec 2004 22:44:28 +0000 (GMT) Received: from mailgate1b.savvis.net (mailgate1b.savvis.net [216.91.182.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 587B443D5A for ; Tue, 7 Dec 2004 22:44:28 +0000 (GMT) (envelope-from Maksim.Yevmenkin@savvis.net) Received: from out001.email.savvis.net (out001.apptix.savvis.net [216.91.32.44])iB7MiOkV012153 for ; Tue, 7 Dec 2004 16:44:24 -0600 Received: from s228130hz1ew17.apptix-01.savvis.net ([10.146.4.29]) by out001.email.savvis.net with Microsoft SMTPSVC(6.0.3790.211); Tue, 7 Dec 2004 16:44:20 -0600 Received: from [10.254.186.111] ([66.35.239.94]) by s228130hz1ew17.apptix-01.savvis.net with Microsoft SMTPSVC(6.0.3790.211); Tue, 7 Dec 2004 16:44:13 -0600 Message-ID: <41B63238.8050209@savvis.net> Date: Tue, 07 Dec 2004 14:44:08 -0800 From: Maksim Yevmenkin User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.2) Gecko/20040822 X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-bluetooth@freebsd.org Content-Type: multipart/mixed; boundary="------------010207060106030207040500" X-OriginalArrivalTime: 07 Dec 2004 22:44:13.0771 (UTC) FILETIME=[467501B0:01C4DCAE] X-ECS-MailScanner: No virus is found Subject: [patch] libsdp(3) - please test. X-BeenThere: freebsd-bluetooth@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Using Bluetooth in FreeBSD environments List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Dec 2004 22:44:29 -0000 This is a multi-part message in MIME format. --------------010207060106030207040500 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hello, please try attached patch for libsdp(3). this patch adds workaround for devices that cannot handle sdp query with attribute id range that has only one attribute id. currently i know of one such device - audiovox smt5600. i suspect that palm treo 650 might have the same problem. if your device worked before it should continue to work. there should be no visible changes. if you have problems then please send me hcidump(1) binary dump (can be created with -w option). thanks, max --------------010207060106030207040500 Content-Type: text/plain; name="libsdp.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="libsdp.patch.txt" Index: search.c =================================================================== RCS file: /usr/local/cvs/lib/libsdp/search.c,v retrieving revision 1.6 diff -u -r1.6 search.c --- search.c 23 Aug 2004 17:52:46 -0000 1.6 +++ search.c 7 Dec 2004 22:22:58 -0000 @@ -55,7 +55,8 @@ sdp_session_p ss = (sdp_session_p) xss; uint8_t *req = NULL, *rsp = NULL, *rsp_tmp = NULL; - int32_t type, len; + int32_t t, len; + uint16_t lo, hi; if (ss == NULL) return (-1); @@ -66,11 +67,29 @@ return (-1); } - /* Calculate length of the request */ req = ss->req; + + /* Calculate ServiceSearchPattern length */ plen = plen * (sizeof(pp[0]) + 1); - alen = alen * (sizeof(ap[0]) + 1); + /* Calculate AttributeIDList length */ + for (len = 0, t = 0; t < alen; t ++) { + lo = (uint16_t) (ap[t] >> 16); + hi = (uint16_t) (ap[t]); + + if (lo > hi) { + ss->error = EINVAL; + return (-1); + } + + if (lo != hi) + len += (sizeof(ap[t]) + 1); + else + len += (sizeof(lo) + 1); + } + alen = len; + + /* Calculate length of the request */ len = plen + sizeof(uint8_t) + sizeof(uint16_t) + /* ServiceSearchPattern */ sizeof(uint16_t) + @@ -97,9 +116,21 @@ /* Put AttributeIDList */ SDP_PUT8(SDP_DATA_SEQ16, req); SDP_PUT16(alen, req); - for (; alen > 0; ap ++, alen -= (sizeof(ap[0]) + 1)) { - SDP_PUT8(SDP_DATA_UINT32, req); - SDP_PUT32(*ap, req); + for (; alen > 0; ap ++) { + lo = (uint16_t) (*ap >> 16); + hi = (uint16_t) (*ap); + + if (lo != hi) { + /* Put attribute range */ + SDP_PUT8(SDP_DATA_UINT32, req); + SDP_PUT32(*ap, req); + alen -= (sizeof(ap[0]) + 1); + } else { + /* Put attribute */ + SDP_PUT8(SDP_DATA_UINT16, req); + SDP_PUT16(lo, req); + alen -= (sizeof(lo) + 1); + } } /* Submit ServiceSearchAttributeRequest and wait for response */ @@ -241,8 +272,8 @@ rsp_tmp = ss->rsp; /* Skip the first SEQ */ - SDP_GET8(type, rsp_tmp); - switch (type) { + SDP_GET8(t, rsp_tmp); + switch (t) { case SDP_DATA_SEQ8: SDP_GET8(len, rsp_tmp); break; @@ -263,8 +294,8 @@ for (; rsp_tmp < rsp && vlen > 0; ) { /* Get set of attributes for the next record */ - SDP_GET8(type, rsp_tmp); - switch (type) { + SDP_GET8(t, rsp_tmp); + switch (t) { case SDP_DATA_SEQ8: SDP_GET8(len, rsp_tmp); break; @@ -286,8 +317,8 @@ /* Now rsp_tmp points to list of (attr,value) pairs */ for (; len > 0 && vlen > 0; vp ++, vlen --) { /* Attribute */ - SDP_GET8(type, rsp_tmp); - if (type != SDP_DATA_UINT16) { + SDP_GET8(t, rsp_tmp); + if (t != SDP_DATA_UINT16) { ss->error = ENOATTR; return (-1); } --------------010207060106030207040500--