Use correct variable size for crc's

This commit is contained in:
Jeremy Lakeman 2013-02-15 12:22:31 +10:30
parent e4d6520c46
commit ed7912295a
3 changed files with 8 additions and 8 deletions

View File

@ -20,7 +20,7 @@
\*----------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
/*----------------------------------------------------------------------------*\
* Local functions
@ -45,10 +45,10 @@
* (no errors are possible)
\*----------------------------------------------------------------------------*/
unsigned long Crc32_ComputeBuf( unsigned long inCrc32, const void *buf,
uint32_t Crc32_ComputeBuf( uint32_t inCrc32, const void *buf,
size_t bufLen )
{
static const unsigned long crcTable[256] = {
static const uint32_t crcTable[256] = {
0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F,0xE963A535,
0x9E6495A3,0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988,0x09B64C2B,0x7EB17CBD,
0xE7B82D07,0x90BF1D91,0x1DB71064,0x6AB020F2,0xF3B97148,0x84BE41DE,0x1ADAD47D,
@ -86,7 +86,7 @@ unsigned long Crc32_ComputeBuf( unsigned long inCrc32, const void *buf,
0x47B2CF7F,0x30B5FFE9,0xBDBDF21C,0xCABAC28A,0x53B39330,0x24B4A3A6,0xBAD03605,
0xCDD70693,0x54DE5729,0x23D967BF,0xB3667A2E,0xC4614AB8,0x5D681B02,0x2A6F2B94,
0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D };
unsigned long crc32;
uint32_t crc32;
unsigned char *byteBuf;
size_t i;

View File

@ -374,7 +374,7 @@ struct slip_decode_state{
int rssi_len;
int packet_length;
unsigned char dst[OVERLAY_INTERFACE_RX_BUFFER_SIZE];
unsigned long crc;
uint32_t crc;
int src_offset;
int dst_offset;
};
@ -853,7 +853,7 @@ uint16_t read_uint16(unsigned char *o);
int slip_encode(int format,
unsigned char *src, int src_bytes, unsigned char *dst, int dst_len);
int slip_decode(struct slip_decode_state *state);
unsigned long Crc32_ComputeBuf( unsigned long inCrc32, const void *buf,
size_t bufLen );
uint32_t Crc32_ComputeBuf( uint32_t inCrc32, const void *buf,
size_t bufLen );
#endif // __SERVALD_SERVALD_H

2
slip.c
View File

@ -247,7 +247,7 @@ int slip_decode(struct slip_decode_state *state)
dump("de-slipped packet",state->dst,state->packet_length);
// Check that CRC matches
unsigned long crc=Crc32_ComputeBuf( 0, state->dst, state->packet_length);
uint32_t crc=Crc32_ComputeBuf( 0, state->dst, state->packet_length);
if (crc!=state->crc) {
if (config.debug.packetradio)
DEBUGF("Rejected packet of %d bytes due to CRC mis-match (%08x vs %08x)",