pairing on x86_64
Hi.
I've got an athlon64, a pda and a bluetooth usb dongle. Pairing under debian unstable (32bit) works fine,
but under suse 9.0 (amd64) or the debian pure64 port it doesn't work.
I've tried selfcompiled kernels (2.4's up to 2.6.3), suse's kernels; i've tried selfcompiled bluez libraries (and utils) as well as those shipped with the above mentioned distributions.
When working in 64bit mode, pairing always seems to 'time out'.
hcidump:
HCIDump - HCI packet analyzer ver 1.5
device: hci0 snap_len: 1028 filter: 0xffffffffffffffff
Quoted 1 line
HCI Event: Connect Request(0x04) plen 10
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
Quoted 2 lines
HCI Event: Command Status(0x0f) plen 4
HCI Event: Connect Complete(0x03) plen 11
< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
Quoted 3 lines
HCI Event: Page Scan Repetition Mode Change(0x20) plen 7 HCI Event: Max Slots Change(0x1b) plen 3
HCI Event: Command Complete(0x0e) plen 6
< HCI Command: Change Connection Packet Type(0x01|0x000f) plen 4
Quoted 3 lines
HCI Event: Command Status(0x0f) plen 4
HCI Event: Connection Packet Type Changed(0x1d) plen 5 HCI Event: PIN Code Request(0x16) plen 6
and that's where it stops - and some time after that my pda aborts the connection.
has anyone managed to get pairing working under x86_64?
thanks in advance, Volker
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Bluez-users mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users
Marcel Holtmann
maintainerHi Volker,
Quoted 22 lines
I've got an athlon64, a pda and a bluetooth usb dongle. Pairing under debian unstable (32bit) works fine,
but under suse 9.0 (amd64) or the debian pure64 port it doesn't work.I've tried selfcompiled kernels (2.4's up to 2.6.3), suse's kernels; i've tried selfcompiled bluez libraries (and utils) as well as those shipped with the above mentioned distributions.
When working in 64bit mode, pairing always seems to 'time out'.
hcidump:
HCIDump - HCI packet analyzer ver 1.5
device: hci0snap_len: 1028 filter:0xffffffffffffffffQuoted 1 line
HCI Event: Connect Request(0x04) plen 10
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
Quoted 2 lines
HCI Event: Command Status(0x0f) plen 4
HCI Event: Connect Complete(0x03) plen 11< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
Quoted 3 lines
HCI Event: Page Scan Repetition Mode Change(0x20) plen 7 HCI Event: Max Slots Change(0x1b) plen 3
HCI Event: Command Complete(0x0e) plen 6
Quoted 7 lines
< HCI Command: Change Connection Packet Type(0x01|0x000f) plen 4
Quoted 3 lines
HCI Event: Command Status(0x0f) plen 4
HCI Event: Connection Packet Type Changed(0x1d) plen 5 HCI Event: PIN Code Request(0x16) plen 6and that's where it stops - and some time after that my pda aborts the connection.
what does your syslog say? Put some syslog() debugging messages in utils/hcid/security.c to see where it stops.
Regards
Marcel
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Bluez-users mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users
Quoted 2 lines · Marcel Holtmann
what does your syslog say? Put some
syslog()debugging messages inutils/hcid/security.cto see where it stops.
security.c loads the right pin at startup.
during pairing, it enters
gboolean io_security_event(GIOChannel *chan, GIOCondition cond, gpointer data)
and leaves the method at this point:
if (type != HCI_EVENT_PKT) {
syslog(LOG_INFO, "** type not HCI_EVENT_PKT");
return TRUE;
}any more points, where I should've a look at?
Volker
Marcel Holtmann
maintainerHi Volker,
Quoted 5 lines
security.cloads the right pin at startup.
during pairing, it entersgboolean
io_security_event(GIOChannel *chan, GIOCondition cond, gpointer data)
Quoted 8 lines
and leaves the method at this point:
if (type != HCI_EVENT_PKT) { syslog(LOG_INFO, "** type not HCI_EVENT_PKT"); return TRUE; }any more points, where I should've a look at?
try the attached patch.
Regards
Marcel
hcid/security.c +2 -1
@@ -367,7 +367,8 @@ {char buf[HCI_MAX_EVENT_SIZE ], *ptr = buf;struct hci_dev_info *di = (void *) data; -int len, type, dev; +unsigned char type; +int len, dev;hci_event_hdr *eh;GIOError err;
Hi Marcel,
Quoted 1 line
try the attached patch.
unfortunatly, the patch didn't fix it. I've added some more syslog() calls to security.c:
type = *ptr++;
syslog(LOG_INFO, "** type is %s", type);
if (type == HCI_EVENT_PKT) {
syslog(LOG_INFO, "** type is HCI_EVENT_PKT");
}
if (type == HCI_COMMAND_PKT) {
syslog(LOG_INFO, "** type is HCI_COMMAND_PKT");
}
if (type == HCI_ACLDATA_PKT) {
syslog(LOG_INFO, "** type is HCI_ACLDATA_PKT");
}
if (type == HCI_SCODATA_PKT) {
syslog(LOG_INFO, "** type is HCI_SCODATA_PKT");
}
if (type == HCI_UNKNOWN_PKT) {
syslog(LOG_INFO, "** type is HCI_UNKNOWN_PKT");
}
if (type != HCI_EVENT_PKT) {
syslog(LOG_INFO, "** type not HCI_EVENT_PKT");
return TRUE;
}now it says:
'** type is (null)'
(without your patch and withsyslog(LOG_INFO, "** type is %d", type);
it was
'** type is 0'
)
thanks, Volker
Marcel Holtmann
maintainerHi Volker,
Quoted 1 line
unfortunatly, the patch didn't fix it.
maybe this one helps.
Regards
Marcel
hcid/security.c +5 -5
@@ -365,9 +365,9 @@gboolean io_security_event (GIOChannel *chan,GIOCondition cond,gpointer data) { -char buf[HCI_MAX_EVENT_SIZE ], *ptr = buf; +unsigned char buf[HCI_MAX_EVENT_SIZE ], *ptr = buf;struct hci_dev_info *di = (void *) data; -int len, type, dev; +int len, dev;hci_event_hdr *eh;GIOError err;
@@ -385,11 +385,11 @@return FALSE; } - type = *ptr++; - -if (type !=HCI_EVENT_PKT ) +if (buf[0 ] !=HCI_EVENT_PKT )return TRUE; + ptr++; + eh = (hci_event_hdr *) ptr; ptr +=HCI_EVENT_HDR_SIZE ;
Hi Marcel,
Quoted 1 line
maybe this one helps.
neither did this :(
so I had a deeper look into it myself.
It seemed, as if the first four chars of buf get blanked after leaving g_io_channel_read.
have a look at my syslog below:
Feb 21 16:13:57 dionysos hcid[5088]: ** io_security_event Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[0]: 4 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[1]: 22 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[2]: 6 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[3]: 121 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[4]: -109 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[5]: 50 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[6]: -32 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[7]: 7 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[8]: 0 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf points to: -1073745232 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[0] = 0 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[1] = 0 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[2] = 0 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[3] = 0 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[4] = -109 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[5] = 50 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[6] = -32 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[7] = 7 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[8] = 0 Feb 21 16:13:57 dionysos hcid[5088]: security * buf points to -1073745232 Feb 21 16:13:57 dionysos hcid[5088]: ** type not HCI_EVENT_PKT
the appended patch does work for me - at least at this point, because now I get the following from hcidump:
HCIDump - HCI packet analyzer ver 1.5
device: hci0 snap_len: 1028 filter: 0xffffffffffffffff
Quoted 1 line
HCI Event: Connect Request(0x04) plen 10
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
Quoted 2 lines
HCI Event: Command Status(0x0f) plen 4
HCI Event: Connect Complete(0x03) plen 11
< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
Quoted 3 lines
HCI Event: Page Scan Repetition Mode Change(0x20) plen 7 HCI Event: Max Slots Change(0x1b) plen 3
HCI Event: Command Complete(0x0e) plen 6
< HCI Command: Change Connection Packet Type(0x01|0x000f) plen 4
Quoted 3 lines
HCI Event: Command Status(0x0f) plen 4
HCI Event: Connection Packet Type Changed(0x1d) plen 5 HCI Event: PIN Code Request(0x16) plen 6
< HCI Command: PIN Code Request Negative Reply(0x01|0x000e) plen 6
Quoted 1 line
HCI Event: Command Complete(0x0e) plen 10
I'll have a deeper look into that issue later today.
Yours, Volker
security.c renamed from orig/bluez-utils-2.4/hcid/security.c +2 -1
@@ -354,7 +354,8 @@gboolean io_security_event (GIOChannel *chan,GIOCondition cond,gpointer data) { -char buf[HCI_MAX_EVENT_SIZE ], *ptr = buf; +char *buf =malloc (sizeof (char ) *HCI_MAX_EVENT_SIZE ); +char *ptr = buf;struct hci_dev_info *di = (void *) data;int len, type, dev;hci_event_hdr *eh;
Marcel Holtmann
maintainerHi Volker,
Quoted 3 lines
so I had a deeper look into it myself.
It seemed, as if the first four chars of buf get blanked after leavingg_io_channel_read.
what is the sizeof(unsigned char) and sizeof(char) on x86_64?
Quoted 14 lines
Feb 21 16:13:57 dionysos hcid[5088]: ** io_security_event Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[0]: 4 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[1]: 22 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[2]: 6 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[3]: 121 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[4]: -109 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[5]: 50 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[6]: -32 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[7]: 7 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[8]: 0 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf points to: -1073745232 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[0] = 0 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[1] = 0 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[2] = 0
Quoted 8 lines
Feb 21 16:13:57 dionysos hcid[5088]: security * buf[3] = 0 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[4] = -109 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[5] = 50 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[6] = -32 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[7] = 7 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[8] = 0 Feb 21 16:13:57 dionysos hcid[5088]: security * buf points to -1073745232 Feb 21 16:13:57 dionysos hcid[5088]: ** type not HCI_EVENT_PKT
I don't know why this happens.
Quoted 2 lines
the appended patch does work for me - at least at this point, because now I get the following from hcidump:
We should use a static buffer and it should be unsigned char.
Quoted 7 lines
HCIDump - HCI packet analyzer ver 1.5
device: hci0snap_len: 1028 filter:0xffffffffffffffffQuoted 1 line
HCI Event: Connect Request(0x04) plen 10
< HCI Command: Accept Connection Request(0x01|0x0009) plen 7
Quoted 2 lines
HCI Event: Command Status(0x0f) plen 4
HCI Event: Connect Complete(0x03) plen 11< HCI Command: Write Link Policy Settings(0x02|0x000d) plen 4
Quoted 9 lines
Quoted 3 lines
HCI Event: Page Scan Repetition Mode Change(0x20) plen 7 HCI Event: Max Slots Change(0x1b) plen 3
HCI Event: Command Complete(0x0e) plen 6< HCI Command: Change Connection Packet Type(0x01|0x000f) plen 4
Quoted 3 lines
HCI Event: Command Status(0x0f) plen 4
HCI Event: Connection Packet Type Changed(0x1d) plen 5 HCI Event: PIN Code Request(0x16) plen 6< HCI Command: PIN Code Request Negative Reply(0x01|0x000e) plen 6
Quoted 1 line
HCI Event: Command Complete(0x0e) plen 10
This can be a problem that the call of the PIN helper program fails.
Regards
Marcel
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Bluez-users mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users
Hi Marcel.
Quoted 1 line
what is the sizeof(unsigned char) and sizeof(char) on
x86_64?
printf says 1 (for both).
Quoted 23 lines
Quoted 14 lines
Feb 21 16:13:57 dionysos hcid[5088]: ** io_security_event Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[0]: 4 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[1]: 22 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[2]: 6 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[3]: 121 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[4]: -109 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[5]: 50 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[6]: -32 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[7]: 7 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf[8]: 0 Feb 21 16:13:57 dionysos hcid[5088]: glib-ectomy * buf points to: -1073745232 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[0] = 0 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[1] = 0 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[2] = 0Quoted 8 lines
Feb 21 16:13:57 dionysos hcid[5088]: security * buf[3] = 0 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[4] = -109 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[5] = 50 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[6] = -32 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[7] = 7 Feb 21 16:13:57 dionysos hcid[5088]: security * buf[8] = 0 Feb 21 16:13:57 dionysos hcid[5088]: security * buf points to -1073745232 Feb 21 16:13:57 dionysos hcid[5088]: ** type not HCI_EVENT_PKT
Quoted 1 line
I don't know why this happens.
I couldn't understand too, but with your sizeof(char) question you made me curious.
On x86_64, int has a size of 4 and size_t takes 8 (while on x86 both have a size of 4).
By passing &len to g_io_channel_read (which takes a size_t *buffer_read as argument), we blank out the first four bytes of buf - which sits directly after len in memory ('oh wonderful world...').
Quoted 1 line
This can be a problem that the call of the PIN helper program fails.
This problem is also solved with the change from int len to size_t len.
So, please trash my first patch and take this instead.
Regards
Volker
security.c renamed from orig/bluez-utils-2.4/hcid/security.c +2 -1
@@ -356,7 +356,8 @@ {char buf[HCI_MAX_EVENT_SIZE ], *ptr = buf;struct hci_dev_info *di = (void *) data; -int len, type, dev; +int type, dev; +size_t len;hci_event_hdr *eh;GIOError err;
Marcel Holtmann
maintainerHi Volker,
Quoted 9 lines
I couldn't understand too, but with your sizeof(char) question you made me curious.
On
x86_64, int has a size of 4 andsize_ttakes 8 (while on x86 both have a size of 4).
By passing &len tog_io_channel_read(which takes asize_t*buffer_readas argument), we blank out the first four bytes of buf - which sits directly after len in memory ('oh wonderful world...').
Quoted 4 lines
Quoted 1 line
This can be a problem that the call of the PIN helper program fails.
This problem is also solved with the change from int len to
size_tlen.So, please trash my first patch and take this instead.
and here is the patch I am going to apply. Please test it.
Regards
Marcel
Index: hcid/main.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/main.c,v
retrieving revision 1.11
main.c +3 -2
@@ -397,10 +397,11 @@gboolean io_stack_event (GIOChannel *chan,GIOCondition cond,gpointer data) { -char buf[HCI_MAX_FRAME_SIZE ], *ptr; +unsigned char buf[HCI_MAX_FRAME_SIZE ], *ptr;evt_stack_internal *si;hci_event_hdr *eh; -int len, type; +int type; +size_t len;GIOError err; ptr = buf;
Index: hcid/security.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/security.c,v
retrieving revision 1.9
security.c +3 -2
@@ -365,9 +365,10 @@gboolean io_security_event (GIOChannel *chan,GIOCondition cond,gpointer data) { -char buf[HCI_MAX_EVENT_SIZE ], *ptr = buf; +unsigned char buf[HCI_MAX_EVENT_SIZE ], *ptr = buf;struct hci_dev_info *di = (void *) data; -int len, type, dev; +int type, dev; +size_t len;hci_event_hdr *eh;GIOError err;
Hi Marcel,
Quoted 1 line
and here is the patch I am going to apply. Please test it.
It works ;)
Yours, Volker