[Dibbler] dibbler-server an debian-armel

Christian Andersen lists at milindur.de
Sun Aug 17 01:19:00 CEST 2008


> Thanks! That helped a lot. Now I know what is going wrong, but I don't
> know the exact cause. During message parsing, when msg-type and
> transaction-id is parsed, dibbler starts option parsing. But for some
> reason, it starts one by too early. The suspected code is in
> SrvMsg.cpp, lines 132 and following:

I did some debugging and changed the code.

-        unsigned short code   = ntohs( *((unsigned short*) (buf+pos)));
-        pos+=2;
-        unsigned short length = ntohs( *((unsigned short*) (buf+pos)));
-        pos+=2;
+	unsigned short tmp = 0;
+	memcpy(&tmp, buf+pos, 2);
+	unsigned short code = ntohs(tmp);
+	pos+=2;
+	memcpy(&tmp, buf+pos, 2);
+	unsigned short length = ntohs(tmp);
+	pos+=2;

With this code the options can be parsed (at this point) and the
solicit-message is accepted. However I did not check if all option contents
were interpreted correctly, maybe there are similar issues. Now Dibbler
sends the advertise-message but the content is not correct. So the client
(currently dibbler-client on Debian/x86) does not accept it.

> Very long time ago I've read about architecture that is not able to
> read words from memory that are not word-aligned. Maybe that is the case
> here?

Yes, I think so. I found a nice description of the problem with pointer
casts and alignment. The relevant part is the second half of the page

With MinGW/Vista and GCC/Debian this is no problem, unaligned pointer casts
are possible (CPU and/or OS allow it). But ARM (and other architectures)
seems to not support this. I think that all pointer casts with possible
unaligned data has to be rewritten to use memcpy (for parsing received
messages and for building messages to send). 

I did another dump of the communication (solicit-messages and corrupt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dibbler-cvs-with-memcpy-1.cap
Type: application/octet-stream
Size: 2904 bytes
Desc: not available
Url : http://klub.com.pl/pipermail/dibbler/attachments/20080817/7e54d697/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dibbler-cvs-with-memcpy-1.log
Type: application/octet-stream
Size: 13641 bytes
Desc: not available
Url : http://klub.com.pl/pipermail/dibbler/attachments/20080817/7e54d697/attachment-0001.obj 

More information about the Dibbler mailing list