public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* "packet types" wrong in libbluetooth
@ 2009-01-10 13:50 Iain Hibbert
  2009-01-10 14:21 ` Marcel Holtmann
  0 siblings, 1 reply; 5+ messages in thread
From: Iain Hibbert @ 2009-01-10 13:50 UTC (permalink / raw)
  To: linux-bluetooth

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)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-01-10 17:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-10 13:50 "packet types" wrong in libbluetooth Iain Hibbert
2009-01-10 14:21 ` Marcel Holtmann
2009-01-10 16:01   ` Iain Hibbert
2009-01-10 16:13     ` Marcel Holtmann
2009-01-10 17:59       ` Iain Hibbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox