After spending several hours tracking down this bug, my friend Gustav Munkby and I found the cause of this bug. In a few places in the checksum calculation code similar to this appears:
CODE
checksum += checksum>>16;
checksum &= 0xFFFF;
checksum &= 0xFFFF;
This code is meant to take of the carries from the ones'-complement additions. The correct way of doing this is like this:
CODE
while(checksum >> 16) checksum = (checksum & 0xFFFF) + (checksum >> 16);
As an example, if checksum = 0x1FFFF the former code give an incorrect result (0), but the later code will give the correct result (1).
I have updated my hacked version to fix this in at least some places:
http://www.itstud.chalmers.se/~larssten/wifi_lib.tar.bz2
