public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Iain Hibbert <plunky@rya-online.net>
To: linux-bluetooth@vger.kernel.org
Subject: "packet types" wrong in libbluetooth
Date: Sat, 10 Jan 2009 13:50:01 +0000 (GMT)	[thread overview]
Message-ID: <1231595402.312160.19752.nullmailer@galant.ukfsn.org> (raw)

Hi,

The HCI packet type functions ptypetostr() and strtoptype() in lib/hci.c
don't work correctly. This is because the HCI spec is messed up wrt the 2
and 3 Mbps packet types, which are indicated by inverted bit logic (see
"Create Connection Command" in core spec document)

I think (you might like to verify that) that the patch below will calm
this hienous situation before anybody needs to call the cops.

regards,
iain

--- lib/hci.c.orig	2009-01-09 20:11:59.000000000 +0000
+++ lib/hci.c	2009-01-09 20:12:02.000000000 +0000
@@ -232,12 +232,18 @@

 char *hci_ptypetostr(unsigned int ptype)
 {
+	ptype ^= (HCI_2DH1|HCI_2DH3|HCI_2DH5|HCI_3DH1|HCI_3DH3|HCI_3DH5);
 	return hci_bit2str(pkt_type_map, ptype);
 }

 int hci_strtoptype(char *str, unsigned int *val)
 {
-	return hci_str2bit(pkt_type_map, str, val);
+
+	if (hci_str2bit(pkt_type_map, str, val) == 0)
+		return 0;
+
+	*val ^= (HCI_2DH1|HCI_2DH3|HCI_2DH5|HCI_3DH1|HCI_3DH3|HCI_3DH5);
+	return 1;
 }

 char *hci_scoptypetostr(unsigned int ptype)

             reply	other threads:[~2009-01-10 13:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-10 13:50 Iain Hibbert [this message]
2009-01-10 14:21 ` "packet types" wrong in libbluetooth Marcel Holtmann
2009-01-10 16:01   ` Iain Hibbert
2009-01-10 16:13     ` Marcel Holtmann
2009-01-10 17:59       ` Iain Hibbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1231595402.312160.19752.nullmailer@galant.ukfsn.org \
    --to=plunky@rya-online.net \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox