Do you have any reason to suspect that it isn't functioning correctly?

It seems like you are assuming that arr is an array of bytes.  However, if you 
look at the top of the function, you'll see that it's actually an array.array 
of "H" values, which are unsigned two-byte values.

-- Murphy

On Aug 24, 2011, at 4:19 AM, ibrahim mun wrote:

> 
> Hi,
> 
> I think we have a bug in packet_utils.checksum, please check it:
> =============================
> def checksum(data, start, skip_word = 0):
> 
>     if len(data) % 2 != 0:
>         arr = array.array('H', data[:-1])
>     else:
>         arr = array.array('H', data)
> 
>     if skip_word:
>         for i in range(0, len(arr)):
>             if i == skip_word:
>                 continue
>             start +=  arr[i]
>     else:        
>        for i in range(0,len(arr)): # BUG?   
>             start +=  arr[i]        # BUG? 
>        # IT should be :
>        # for i in range(0, len(arr)-1,2):
>        # start +=  arr[i]*0x100 +arr[i+1]
> 
>     if len(data) % 2 != 0:
>         start += struct.unpack('H', data[-1]+'\0')[0]
> 
>     start  = (start >> 16) + (start & 0xffff)
>     start += (start >> 16);
> 
>     return ntohs(~start & 0xffff)
> ===============================
> 
> Thanks,
> 
> Ibrahim
> 
> 
> _______________________________________________
> nox-dev mailing list
> nox-dev@noxrepo.org
> http://noxrepo.org/mailman/listinfo/nox-dev

_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev

Reply via email to